Uncatched NSExceptions should crash the web process
https://bugs.webkit.org/show_bug.cgi?id=130923
<rdar://problem/16463751>

Reviewed by Dan Bernstein.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166452 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Tweak ChangeLog

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166453 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Convert yet more of HTMLConverter to C++
https://bugs.webkit.org/show_bug.cgi?id=130850

Reviewed by Anders Carlsson.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverterCaches::isAncestorsOfStartToBeConverted):
(HTMLConverter::HTMLConverter):
(HTMLConverter::~HTMLConverter):
(HTMLConverter::convert):
(HTMLConverter::computedAttributesForElement):
(HTMLConverter::attributesForElement):
(HTMLConverter::_newParagraphForElement):
(HTMLConverter::_newLineForElement):
(HTMLConverter::_newTabForElement):
(HTMLConverter::_addAttachmentForElement):
(HTMLConverter::_addQuoteForElement):
(HTMLConverter::_addValue):
(HTMLConverter::_processHeadElement):
(HTMLConverter::_enterElement):
(HTMLConverter::_addTableCellForElement):
(HTMLConverter::_processElement):
(HTMLConverter::_addMarkersToList):
(HTMLConverter::_exitElement):
(HTMLConverter::_processText):
(HTMLConverter::_traverseNode):
(HTMLConverter::_traverseFooterNode):
(WebCore::attributedStringFromRange):
(_childrenForNode): Deleted.
(HTMLConverter::_computedAttributesForElement): Deleted.
(HTMLConverter::_attributesForElement): Deleted.
(HTMLConverter::_loadFromDOMRange): Deleted.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166454 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Subpixel rendering: Make GraphicsContext::drawImageBuffer* functions float based.
https://bugs.webkit.org/show_bug.cgi?id=130932

Reviewed by Simon Fraser.

This is in preparation to support device pixel based filter painting.
Filter calculation is still integral based.

No change in behavior.

* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawImageBuffer):
* platform/graphics/GraphicsContext.h:
* platform/graphics/filters/FilterEffect.cpp: This will eventually be fully float based.
Right now, this IntRect->FloatRect change is only to ensure that we can call
the float based drawImageBuffer().
(WebCore::FilterEffect::drawingRegionOfInputImage):
* platform/graphics/filters/FilterEffect.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Subpixel rendering: Simple line layout should not round to integral position while painting.
https://bugs.webkit.org/show_bug.cgi?id=130934

Reviewed by Simon Fraser.

Remove rounding to integral position. When RenderLayer is injected and hides subpixel positions,
integral rounding produces different paint position.

Source/WebCore:

Test: fast/flexbox/hidpi-simple-line-layout-with-flexbox-and-transition.html

* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::paintFlow):

LayoutTests:

* fast/flexbox/hidpi-simple-line-layout-with-flexbox-and-transition-expected.html: Added.
* fast/flexbox/hidpi-simple-line-layout-with-flexbox-and-transition.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166456 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Preserve selection end positions in directionOfSelection
<http://webkit.org/b/104813>
<rdar://problem/13666417>

Reviewed by Brent Fulgham.

Merged from Blink (patch by kenrb@chromium.org):
https://src.chromium.org/viewvc/blink?revision=150621&view=revision
http://crbug.com/164263

    VisibleSelection::visibleStart() and VisibleSelection::visibleEnd()
    can both cause layouts, which has the potential to invalidate any
    rendertree-based objects. This was causing a problem in
    FrameSelection::directionOfSelection(), where a reference to a
    lineBox was being held across a call to visibleEnd().

    This patch ensures that the any layout is completed before linebox
    references are retrieved.

Source/WebCore:

Test: editing/selection/layout-during-move-selection-crash.html

* editing/FrameSelection.cpp:
(WebCore::FrameSelection::directionOfSelection):

LayoutTests:

* editing/selection/layout-during-move-selection-crash-expected.txt: Added.
* editing/selection/layout-during-move-selection-crash.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Update WebKit1.StringTruncator for Mountain Lion.

* TestWebKitAPI/Tests/mac/StringTruncator.mm: Looks like one subtest was failing
due to different font metrics on 10.8.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166458 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r166434.
https://bugs.webkit.org/show_bug.cgi?id=130938

Caused crashes and other failures on cache tests (Requested by
ap on #webkit).

Reverted changeset:

Source/WebCore:

"Web Replay: add page-level setting to bypass the MemoryCache"
https://bugs.webkit.org/show_bug.cgi?id=130728
http://trac.webkit.org/changeset/166434

Source/WebKit2:

"Web Replay: add page-level setting to bypass the MemoryCache"
https://bugs.webkit.org/show_bug.cgi?id=130728
http://trac.webkit.org/changeset/166434

LayoutTests:

"Web Replay: add page-level setting to bypass the MemoryCache"
https://bugs.webkit.org/show_bug.cgi?id=130728
http://trac.webkit.org/changeset/166434

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LiveNodeLists should use ElementDescendantIterator
https://bugs.webkit.org/show_bug.cgi?id=130931

Reviewed by Andreas Kling.
        
Make LiveNodeList traversal use the common DOM tree iterator.

* dom/ChildNodeList.cpp:
(WebCore::ChildNodeList::ChildNodeList):
(WebCore::ChildNodeList::collectionBegin):
(WebCore::ChildNodeList::collectionTraverseForward):
(WebCore::ChildNodeList::collectionTraverseBackward):
(WebCore::ChildNodeList::invalidateCache):
(WebCore::ChildNodeList::collectionFirst): Deleted.
        
    Iterator for ChildNodeList is still just Node*.

* dom/ChildNodeList.h:
* dom/CollectionIndexCache.h:
(WebCore::CollectionIndexCache::hasValidCache):
(WebCore::Iterator>::CollectionIndexCache):
(WebCore::Iterator>::nodeCount):
(WebCore::Iterator>::computeNodeCountUpdatingListCache):
(WebCore::Iterator>::traverseBackwardTo):
(WebCore::Iterator>::traverseForwardTo):
(WebCore::Iterator>::nodeAt):
(WebCore::Iterator>::invalidate):
        
    Make CollectionIndexCache iterator based instead of using NodeType*. The iterator type may
    still be a Node* though.

(WebCore::NodeType>::CollectionIndexCache): Deleted.
(WebCore::NodeType>::nodeCount): Deleted.
(WebCore::NodeType>::computeNodeCountUpdatingListCache): Deleted.
(WebCore::NodeType>::nodeBeforeCached): Deleted.
(WebCore::NodeType>::nodeAfterCached): Deleted.
(WebCore::NodeType>::nodeAt): Deleted.
(WebCore::NodeType>::invalidate): Deleted.
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::operator--):
        
    Add backward iteration support.

(WebCore::ElementDescendantIteratorAdapter::last):
(WebCore::ElementDescendantConstIteratorAdapter::last):
        
    Add a way to get the last item.
    Provide std::iterator_traits so we can extract the type.

* dom/LiveNodeList.h:
(WebCore::CachedLiveNodeList::collectionEnd):
(WebCore::CachedLiveNodeList<NodeListType>::CachedLiveNodeList):
(WebCore::CachedLiveNodeList<NodeListType>::~CachedLiveNodeList):
(WebCore::CachedLiveNodeList<NodeListType>::collectionBegin):
(WebCore::CachedLiveNodeList<NodeListType>::collectionLast):
(WebCore::CachedLiveNodeList<NodeListType>::collectionTraverseForward):
(WebCore::CachedLiveNodeList<NodeListType>::collectionTraverseBackward):
(WebCore::CachedLiveNodeList<NodeListType>::invalidateCache):
(WebCore::CachedLiveNodeList<NodeListType>::collectionFirst): Deleted.
        
    Make LiveNodeList traversal use ElementDescendantIterator.

(WebCore::nextMatchingElement): Deleted.
(WebCore::previousMatchingElement): Deleted.
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::HTMLCollection):
(WebCore::HTMLCollection::~HTMLCollection):
(WebCore::HTMLCollection::collectionBegin):
(WebCore::HTMLCollection::collectionTraverseForward):
(WebCore::HTMLCollection::collectionTraverseBackward):
(WebCore::HTMLCollection::invalidateCache):
(WebCore::HTMLCollection::collectionFirst): Deleted.
* html/HTMLCollection.h:
(WebCore::HTMLCollection::collectionEnd):
        
    HTMLCollection still uses Element* as iterator for now.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166460 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make NodeList and HTMLCollection caching helpers use PassRef.
<https://webkit.org/b/130943>

Tweak the helpers in NodeListsNodeData to return PassRef instead of
PassRefPtr. This knocks 2 branches off of some pretty hot code on
Dromaeo/dom-query.

Reviewed by Antti Koivisto.

* dom/ChildNodeList.h:
* dom/ClassNodeList.h:
* dom/NameNodeList.h:
* dom/NodeRareData.h:
(WebCore::NodeListsNodeData::ensureChildNodeList):
(WebCore::NodeListsNodeData::ensureEmptyChildNodeList):
(WebCore::NodeListsNodeData::addCacheWithAtomicName):
(WebCore::NodeListsNodeData::addCacheWithName):
(WebCore::NodeListsNodeData::addCacheWithQualifiedName):
(WebCore::NodeListsNodeData::addCachedCollection):
* dom/TagNodeList.h:
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::create):
* html/HTMLCollection.h:
* html/HTMLFormControlsCollection.cpp:
(WebCore::HTMLFormControlsCollection::create):
* html/HTMLFormControlsCollection.h:
* html/RadioNodeList.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166461 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LongSpider 3d-morph result check is inappropriate.
<https://webkit.org/b/130928>

Reviewed by Filip Pizlo.

The LongSpider 3d-morph component expected result check is incorrect.
The existing test checks if the leading digit of a sum starts with "-1".
However, it turned out that the expected sum is in the order of
-1.8735013540549517e-16 (i.e. very close to 0).  With small errors in
the terms of the sum adding up, it is very easy for the resultant sum 
to fluctuate.  There is no guarantee that the resultant sum's most
significant digit will start with -1 either.

The fix is to do a tolerance check on all the terms of the sum as well
as the total sum value instead.  The tolerance should be more lenient
for the sum which accumulates error from the individual terms, then for
individual terms.

* LongSpider/3d-morph.js:
(expect):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166462 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Land the stackmap register liveness glue with the uses of the liveness disabled
https://bugs.webkit.org/show_bug.cgi?id=130924

Source/JavaScriptCore: 

Reviewed by Oliver Hunt.
        
Add the liveness and fix other bugs I found.

* bytecode/PutByIdStatus.cpp:
(JSC::PutByIdStatus::computeFor):
* ftl/FTLCompile.cpp:
(JSC::FTL::usedRegistersFor):
(JSC::FTL::fixFunctionBasedOnStackMaps):
* ftl/FTLSlowPathCall.cpp:
* ftl/FTLSlowPathCallKey.cpp:
(JSC::FTL::SlowPathCallKey::dump):
* ftl/FTLSlowPathCallKey.h:
(JSC::FTL::SlowPathCallKey::SlowPathCallKey):
(JSC::FTL::SlowPathCallKey::argumentRegisters):
(JSC::FTL::SlowPathCallKey::withCallTarget):
* ftl/FTLStackMaps.cpp:
(JSC::FTL::StackMaps::Record::locationSet):
(JSC::FTL::StackMaps::Record::liveOutsSet):
(JSC::FTL::StackMaps::Record::usedRegisterSet):
* ftl/FTLStackMaps.h:
* ftl/FTLThunks.cpp:
(JSC::FTL::registerClobberCheck):
(JSC::FTL::slowPathCallThunkGenerator):
* jit/RegisterSet.cpp:
(JSC::RegisterSet::stackRegisters):
(JSC::RegisterSet::reservedHardwareRegisters):
(JSC::RegisterSet::runtimeRegisters):
(JSC::RegisterSet::specialRegisters):
(JSC::RegisterSet::dump):
* jit/RegisterSet.h:
(JSC::RegisterSet::RegisterSet):
(JSC::RegisterSet::setAny):
(JSC::RegisterSet::setMany):
* jit/Repatch.cpp:
(JSC::tryCacheGetByID):
(JSC::tryCachePutByID):
(JSC::tryRepatchIn):
* runtime/Options.cpp:
(JSC::recomputeDependentOptions):
* runtime/Options.h:

Tools: 

Reviewed by Oliver Hunt.

* Scripts/run-jsc-stress-tests:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] Fix build of HTMLConverter.mm after r166454

Fixes the following build failures:

    WebCore/editing/cocoa/HTMLConverter.mm:1507:13: error: value of type 'WebCore::Element' is not contextually convertible to 'bool'
            if (element)
                ^~~~~~~
    WebCore/editing/cocoa/HTMLConverter.mm:1508:49: error: no matching function for call to 'core'
                _caches->floatPropertyValueForNode(*core(element), CSSPropertyVerticalAlign, verticalAlign);
                                                    ^~~~
    In file included from WebCore/editing/cocoa/HTMLConverter.mm:41:
    In file included from WebCore/page/Frame.h:42:
    In file included from WebCore/editing/VisibleSelection.h:30:
    In file included from WebCore/editing/VisiblePosition.h:30:
    In file included from WebCore/dom/Position.h:31:
    WebCore/editing/TextAffinity.h:54:27: note: candidate function not viable: no known conversion from 'WebCore::Element' to 'NSSelectionAffinity' (aka '_NSSelectionAffinity') for 1st argument
    inline WebCore::EAffinity core(NSSelectionAffinity affinity)
                              ^
    WebCore/editing/cocoa/HTMLConverter.mm:1509:81: error: reference to non-static member function must be called; did you mean to call it with no arguments?
            attachment.get().bounds = CGRectMake(0, (verticalAlign / 100) * element.clientHeight, element.clientWidth, element.clientHeight);
                                                                            ~~~~~~~~^~~~~~~~~~~~
                                                                                                ()
    WebCore/editing/cocoa/HTMLConverter.mm:1509:103: error: reference to non-static member function must be called; did you mean to call it with no arguments?
            attachment.get().bounds = CGRectMake(0, (verticalAlign / 100) * element.clientHeight, element.clientWidth, element.clientHeight);
                                                                                                  ~~~~~~~~^~~~~~~~~~~
                                                                                                                     ()
    WebCore/editing/cocoa/HTMLConverter.mm:1509:124: error: reference to non-static member function must be called; did you mean to call it with no arguments?
            attachment.get().bounds = CGRectMake(0, (verticalAlign / 100) * element.clientHeight, element.clientWidth, element.clientHeight);
                                                                                                                       ~~~~~~~~^~~~~~~~~~~~
                                                                                                                                           ()
    5 errors generated.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_addAttachmentForElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166464 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make RenderStyle's non inherited flags more JSC friendly
https://bugs.webkit.org/show_bug.cgi?id=130939

Reviewed by Andreas Kling.

Make RenderStyle::NonInheritedFlags accessible to the JIT:
-Make the struct public to give access to the offset.
-Move away from a bit field to static offsets we can use
 with the MacroAssembler.
-Reorder the field to simplify bit access of the flags we need.

* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyVerticalAlign::createHandler):
(WebCore::ApplyPropertyDisplay::applyInitialValue):
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::RenderStyle):
(WebCore::RenderStyle::copyNonInheritedFrom):
(WebCore::RenderStyle::hashForTextAutosizing):
(WebCore::RenderStyle::equalForTextAutosizing):
(WebCore::RenderStyle::changeRequiresLayout):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::hasAnyPublicPseudoStyles):
(WebCore::RenderStyle::hasPseudoStyle):
(WebCore::RenderStyle::setHasPseudoStyle):
* rendering/style/StyleMultiColData.cpp:
(WebCore::StyleMultiColData::StyleMultiColData):
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166465 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Cocoa] Add an originatingWebView property to _WKDownload
https://bugs.webkit.org/show_bug.cgi?id=130945

Reviewed by Anders Carlsson.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]): Passed self to WKView's initializer.
* UIProcess/API/Cocoa/_WKDownload.h: Declared originatingWebView as a weak, readonly property.
* UIProcess/API/Cocoa/_WKDownload.mm:
(-[_WKDownload originatingWebView]):
(-[_WKDownload setOriginatingWebView:]):
* UIProcess/API/Cocoa/_WKDownloadInternal.h: Re-declared originatingWebView as readwrite so that
PageClientImpl can call setOriginatingWebView:. Removed some dead code.
* UIProcess/API/mac/WKView.mm:
(-[WKView initWithFrame:context:configuration:webView:]): Updated to accept a webView parameter.
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]): Passed nil for the webView parameter.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::decideDestinationWithSuggestedFilename): Ensured allowOverwrite is initialized.
* UIProcess/PageClient.h: Included handleDownloadRequest() on all platforms.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedPolicyDecision): Ditto.
(WebKit::WebPageProxy::handleDownloadRequest): Ditto.
* UIProcess/WebPageProxy.h: Ditto.
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::handleDownloadRequest): Called -[_WKDownload setOriginatingWebView:].
* UIProcess/mac/PageClientImpl.h: Added a m_webView member variable.
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::PageClientImpl): Asserted that m_webView is nil if WK API isn't enabled.
(WebKit::PageClientImpl::handleDownloadRequest): Called -[_WKDownload setOriginatingWebView:].

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm:
(-[DownloadDelegate _downloadDidStart:]):
(-[OriginatingWebViewDownloadDelegate initWithWebView:]):
(-[OriginatingWebViewDownloadDelegate _downloadDidStart:]):
(TEST):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: Add a new layout test for better coverage of accessibility "focused" in inspector-protocol DOM.getAccessibilityPropertiesForNode
https://bugs.webkit.org/show_bug.cgi?id=130196

Patch by Diego Pino Garcia <dpino@igalia.com> on 2014-03-30
Reviewed by Timothy Hatcher.

* inspector-protocol/dom/getAccessibilityPropertiesForNode-focused-expected.txt: Added.
* inspector-protocol/dom/getAccessibilityPropertiesForNode-focused.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Attempt to fix 32bits build after r166465

* rendering/style/RenderStyle.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166468 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Second attempt to fix 32bits build after r166465

* rendering/style/RenderStyle.h:
The compiler probably complain about the return value, that makes more sense.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166469 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix two failing layout tests on Mountain Lion after r166466.

* TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm:
(-[DownloadDelegate _downloadDidStart:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166470 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r166467.
https://bugs.webkit.org/show_bug.cgi?id=130952

The test fails (Requested by ap_ on #webkit).

Reverted changeset:

"Web Inspector: Add a new layout test for better coverage of
accessibility "focused" in inspector-protocol
DOM.getAccessibilityPropertiesForNode"
https://bugs.webkit.org/show_bug.cgi?id=130196
http://trac.webkit.org/changeset/166467

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166471 268f45cc-cd09-0410-ab3c-d52691b4dbfc