Put some common code in StorageNamespaceProvider
https://bugs.webkit.org/show_bug.cgi?id=139682

Reviewed by Tim Horton.

We have code in two places that gets the local storage area from a given document,
choosing either the local storage namespace or the transient local storage namespace.
Move it to StorageNamespaceProvider::localStorageArea.

* bindings/js/ScriptController.cpp:
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::findStorageArea):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::localStorage):
* page/Navigator.cpp:
* storage/StorageNamespaceProvider.cpp:
(WebCore::StorageNamespaceProvider::localStorageArea):
(WebCore::StorageNamespaceProvider::localStorageNamespace):
* storage/StorageNamespaceProvider.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Document.contentType implementation
https://bugs.webkit.org/show_bug.cgi?id=132269

Patch by Tibor Meszaros <tmeszaros.u-szeged@partner.samsung.com> on 2014-12-16
Reviewed by Darin Adler.

Chromium merge from https://codereview.chromium.org/151653004

Source/WebCore:

Tests: fast/dom/document-contentType-DOMParser.html
       fast/dom/document-contentType-createDocument.html
       fast/dom/document-contentType-data-uri.html
       fast/xsl/xslt-contentType.html
       http/tests/dom/document-contentType-meta.html
       http/tests/dom/document-contentType-xhr.html
       http/tests/dom/document-contentType.html

* dom/Document.cpp:
(WebCore::Document::overrideMIMEType):
(WebCore::Document::contentType):
(WebCore::Document::cloneDataFromDocument):
* dom/Document.h:
* dom/Document.idl:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::currentContentType):
* loader/DocumentLoader.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseXML):
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource):

LayoutTests:

* fast/dom/Document/clone-node-expected.txt:
* fast/dom/Document/clone-node.html:
* fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt:
* fast/dom/HTMLDocument/clone-node-quirks-mode.html:
* fast/dom/document-contentType-DOMParser-expected.txt: Added.
* fast/dom/document-contentType-DOMParser.html: Added.
* fast/dom/document-contentType-createDocument-expected.txt: Added.
* fast/dom/document-contentType-createDocument.html: Added.
* fast/dom/document-contentType-data-uri-expected.txt: Added.
* fast/dom/document-contentType-data-uri.html: Added.
* fast/xsl/xslt-contentType-expected.txt: Added.
* fast/xsl/xslt-contentType.html: Added.
* http/tests/dom/document-contentType-expected.txt: Added.
* http/tests/dom/document-contentType-meta-expected.txt: Added.
* http/tests/dom/document-contentType-meta.html: Added.
* http/tests/dom/document-contentType-xhr-expected.txt: Added.
* http/tests/dom/document-contentType-xhr.html: Added.
* http/tests/dom/document-contentType.html: Added.
* http/tests/dom/resources/dummy.css: Added.
(body):
* http/tests/dom/resources/dummy.html: Added.
* http/tests/dom/resources/dummy.js: Added.
* http/tests/dom/resources/dummy.txt: Added.
* http/tests/dom/resources/dummy.xml: Added.
* http/tests/dom/resources/send-mime-type.php: Added.
* http/tests/dom/resources/square20.bmp: Added.
* http/tests/dom/resources/square20.gif: Added.
* http/tests/dom/resources/square20.jpg: Added.
* http/tests/dom/resources/square20.png: Added.
* resources/js-test.js:
(shouldBeEqualToNumber):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177366 268f45cc-cd09-0410-ab3c-d52691b4dbfc
media/video-controls-toggling.html always times out
https://bugs.webkit.org/show_bug.cgi?id=116266

Skip it.

* platform/mac/TestExpectations:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177367 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit2 test expectations gardening.

Update syntax, unskip some tests that were skipped before we had expectations.

* platform/wk2/TestExpectations:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177368 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sort out timeout implementations in DRT and WKTR
https://bugs.webkit.org/show_bug.cgi?id=139671

Remove an obsolete test that doesn't capture how run-webkit-tests interacts
with the tool.

* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(RunTest.test_hung_thread):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177370 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Disable TextIndication for Lookup immediate actions
https://bugs.webkit.org/show_bug.cgi?id=139684
rdar://problem/19266902

Reviewed by Anders Carlsson.

* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _animationControllerForText]):

* WebView/WebView.mm:
(-[WebView _animationControllerForDictionaryLookupPopupInfo:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Nested template contents are not cloned by document.importNode
https://bugs.webkit.org/show_bug.cgi?id=137619

Reviewed by Andreas Kling.

Source/WebCore:

The bug was caused by Document.importNode not cloning HTMLTemplateElement's content.

Fixed the bug by sharing code between Document::importNode and Node::cloneNode by
generalizing Node::cloneNodeInternal, added in r177314, by taking the owner document
as an argument. The most of code changes are the result of adding this argument.

Document::importNode is the only function in which the actual logic changes.
Note that the code to import TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE,
PROCESSING_INSTRUCTION_NODE and COMMENT_NODE nodes are identical to that of cloneNode.

This patch removes the call to hasValidNamespaceForElements in ELEMENT_NODE but this
should not introduce an observable behavior change since all instantiated elements
should have a valid namespace in the first place.

Because DOCUMENT_NODE and DOCUMENT_TYPE_NODE cannot be imported and DOCUMENT_TYPE_NODE
can only appear as a direct child of DOCUMENT_NODE, neither nodes nor unimplemented
XPATH_NAMESPACE_NODE and XPATH_NAMESPACE_NODE can appear inside the recursive calls
for ELEMENT_NODE and DOCUMENT_FRAGMENT_NODE nodes.

While importNode behaves differently from cloneNode for ATTRIBUTE_NODE, namely that
it merges all of its child nodes, this behavior isn't present when recursing inside
ELEMENT_NODE and DOCUMENT_FRAGMENT_NODE since we are using cloneDataFromElement.

Thus there should be no observable behavior changes for DOCUMENT_FRAGMENT_NODE and
ELEMENT_NODE nodes either.

Test: fast/dom/HTMLTemplateElement/importNode-nested-templates.html

* dom/Attr.cpp:
(WebCore::Attr::cloneNodeInternal):
* dom/Attr.h:
* dom/CDATASection.cpp:
(WebCore::CDATASection::cloneNodeInternal):
* dom/CDATASection.h:
* dom/Comment.cpp:
(WebCore::Comment::cloneNodeInternal):
* dom/Comment.h:
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::cloneChildNodes):
* dom/Document.cpp:
(WebCore::Document::importNode):
(WebCore::Document::cloneNodeInternal):
* dom/Document.h:
* dom/DocumentFragment.cpp:
(WebCore::DocumentFragment::cloneNodeInternal):
* dom/DocumentFragment.h:
* dom/DocumentType.cpp:
(WebCore::DocumentType::cloneNodeInternal):
* dom/DocumentType.h:
* dom/Element.cpp:
(WebCore::Element::cloneNodeInternal):
(WebCore::Element::cloneElementWithChildren):
(WebCore::Element::cloneElementWithoutChildren):
(WebCore::Element::cloneElementWithoutAttributesAndChildren):
* dom/Element.h:
* dom/EntityReference.cpp:
(WebCore::EntityReference::cloneNodeInternal):
* dom/EntityReference.h:
* dom/Node.h:
(WebCore::Node::cloneNode):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::cloneNodeInternal):
* dom/ProcessingInstruction.h:
* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::cloneNodeInternal):
* dom/ShadowRoot.h:
* dom/Text.cpp:
(WebCore::Text::cloneNodeInternal):
* dom/Text.h:
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode):
(WebCore::ApplyStyleCommand::applyInlineStyleChange):
* editing/BreakBlockquoteCommand.cpp:
(WebCore::BreakBlockquoteCommand::doApply):
* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::cloneHierarchyUnderNewBlock):
(WebCore::InsertParagraphSeparatorCommand::doApply):
* editing/ModifySelectionListLevel.cpp:
(WebCore::IncreaseSelectionListLevelCommand::doApply):
* editing/SplitElementCommand.cpp:
(WebCore::SplitElementCommand::doApply):
* editing/markup.cpp:
(WebCore::createFragmentFromText):
* html/HTMLKeygenElement.cpp:
* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::cloneElementWithoutAttributesAndChildren):
* html/HTMLScriptElement.h:
* html/HTMLTemplateElement.cpp:
(WebCore::HTMLTemplateElement::cloneNodeInternal):
* html/HTMLTemplateElement.h:
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::cloneElementWithoutAttributesAndChildren):
* html/shadow/SliderThumbElement.h:
* html/track/WebVTTElement.cpp:
(WebCore::WebVTTElement::cloneElementWithoutAttributesAndChildren):
* html/track/WebVTTElement.h:
* svg/SVGScriptElement.cpp:
(WebCore::SVGScriptElement::cloneElementWithoutAttributesAndChildren):
* svg/SVGScriptElement.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::buildShadowTree):
(WebCore::SVGUseElement::expandUseElementsInShadowTree):

LayoutTests:

Added a regression test.

* fast/dom/HTMLTemplateElement/importNode-nested-templates-expected.txt: Added.
* fast/dom/HTMLTemplateElement/importNode-nested-templates.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177372 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Update some test expectations from Failure to Timeout, which is now correctly detected.

* platform/mac/TestExpectations:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] Crash in WebKit::WebPageProxy::dispatchViewStateChange() tapping a link from another app while playing a video
https://bugs.webkit.org/show_bug.cgi?id=139550

Reviewed by Anders Carlsson.

The existing "dispatch to WebThread, then release" model is insufficient and still
can result in RefPtr race conditions between the main thread and the web thread.
Make WebVideoFullscreenInterfaceAVKit a thread-safe ref-counted class, which
eliminates the necessity of disptaching back to the web thread before releasing.

* platform/ios/WebVideoFullscreenInterfaceAVKit.h:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(WebVideoFullscreenInterfaceAVKit::setDuration): Use a strongThis model.
(WebVideoFullscreenInterfaceAVKit::setCurrentTime): Ditto.
(WebVideoFullscreenInterfaceAVKit::setRate): Ditto.
(WebVideoFullscreenInterfaceAVKit::setVideoDimensions): Ditto.
(WebVideoFullscreenInterfaceAVKit::setSeekableRanges): Ditto.
(mediaSelectionOptions): Return a RetainPtr object.
(WebVideoFullscreenInterfaceAVKit::setAudioMediaSelectionOptions): Use a strongThis model.
(WebVideoFullscreenInterfaceAVKit::setLegibleMediaSelectionOptions): Ditto.
(WebVideoFullscreenInterfaceAVKit::setExternalPlayback): Ditto.
(WebVideoFullscreenInterfaceAVKit::setupFullscreen): Ditto.
(WebVideoFullscreenInterfaceAVKit::enterFullscreen): Ditto.
(WebVideoFullscreenInterfaceAVKit::exitFullscreen): Ditto.
(WebVideoFullscreenInterfaceAVKit::cleanupFullscreen): Ditto.
(WebVideoFullscreenInterfaceAVKit::setupFullscreenInternal): Added utility
    function. Lets us use the implied this pointer rather than an explicit
    strongThis.
(WebVideoFullscreenInterfaceAVKit::enterFullscreenOptimized): Ditto.
(WebVideoFullscreenInterfaceAVKit::enterFullscreenStandard): Ditto.
(WebVideoFullscreenInterfaceAVKit::exitFullscreenInternal): Ditto.
(WebVideoFullscreenInterfaceAVKit::cleanupFullscreenInternal): Ditto.
(WebVideoFullscreenInterfaceAVKit::requestHideAndExitFullscreen): Use a strongThis model.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177375 268f45cc-cd09-0410-ab3c-d52691b4dbfc
More expectations updated to Timeout.

Also, undone some accidental skips. It may be right to skip tests that always time
out, but let's do that intentionally, and with a review.

* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177376 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Ruby does not preserve expansion opportunities from enclosing context
https://bugs.webkit.org/show_bug.cgi?id=139618

Source/WebCore:

Patch by Myles C. Maxfield <litherum@gmail.com> on 2014-12-16
Reviewed by David Hyatt.

There is currently no sharing of expansion opportunity information between
ruby bases and the text surrounding the ruby. This patch adds a bit on
RenderText, m_contentIsKnownToFollow, which affects how expansion
opportunities are handled at paint-time, as well as a bit on RenderRubyBase,
m_isAfterExpansion, which affects how expansions are calculated when laying
out a line. This patch also adds a field to RenderRubyBase which represents
the base's starting position within a ruby. This field is necessary because
an expansion from a line might occur at the very beginning of a ruby base,
so we have to remember some state from expansion time to RenderRubyBase
layout time.

Added more tests to fast/ruby/ruby-justification.html.

* rendering/InlineBox.h:
(WebCore::InlineBox::setExpansionWithoutGrowing):
(WebCore::InlineBox::expansion):
* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::removeChild): Keep the bit on InlineTextBox up to
date.
(WebCore::InlineFlowBox::placeBoxRangeInInlineDirection): Set expansion
information in InlineFlowBoxes so the total expansion for a whole line
is held in the RootInlineBox's expansion.
* rendering/InlineTextBox.h:
(WebCore::InlineTextBox::expansionBehavior):
* rendering/RenderBlockFlow.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::updateRubyForJustifiedText):
updateRubyForJustifiedText() had a bunch of problems with it. First of all,
it didn't actually set the InlineBoxes as dirty, so the second layout pass
sometimes wouldn't perform any updates. Secondarily, it didn't take
overhangs into account. Thirdly, it didn't mark the ruby base and text as
needing layout so that subsequent layouts would actually traverse into them.
(WebCore::RenderBlockFlow::computeExpansionForJustifiedText):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
This nested if triangle is super nasty, but I'm not sure of a better way to
write it.
(WebCore::updateRubyForJustifiedText): Deleted.
(WebCore::computeExpansionForJustifiedText): Deleted.
* rendering/RenderRubyBase.cpp:
(WebCore::RenderRubyBase::RenderRubyBase):
(WebCore::RenderRubyBase::adjustInlineDirectionLineBounds):
* rendering/RenderRubyBase.h:
* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::layout):
* rendering/RenderText.cpp:
(WebCore::RenderText::RenderText):
* rendering/RenderText.h:
(WebCore::RenderText::contentIsKnownToFollow):
(WebCore::RenderText::setContentIsKnownToFollow):

LayoutTests:

Updating test for new expansion logic.

Patch by Myles C. Maxfield <litherum@gmail.com> on 2014-12-16
Reviewed by David Hyatt.

* fast/ruby/ruby-justification-expected.html:
* fast/ruby/ruby-justification.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177377 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Introduce PageActivityState
https://bugs.webkit.org/show_bug.cgi?id=139687

Reviewed by Anders Carlsson.

Add a bitfield to track each of the activities on the page separately.
Split the hysteresis & counters so we can track these separately.

* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
    - initialze new hysteresis, counters; closures call setActivityFlag.
(WebCore::PageThrottler::mediaActivityToken):
(WebCore::PageThrottler::pageLoadActivityToken):
    - split m_pageActivityCounter -> m_mediaActivityCounter, m_pageLoadActivityCounter.
(WebCore::PageThrottler::updateUserActivity):
    - use m_activityState to check for activity.
(WebCore::PageThrottler::setActivityFlag):
    - helper to clear/set a bit in m_activityState, and call updateUserActivity as necessary.
* page/PageThrottler.h:
(WebCore::PageThrottler::didReceiveUserInput):
(WebCore::PageThrottler::pluginDidEvaluateWhileAudioIsPlaying):
    - split m_hysteresis -> m_userInputHysteresis, m_audiblePluginHysteresis



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177378 268f45cc-cd09-0410-ab3c-d52691b4dbfc
RefPtr::copyRef should be const
https://bugs.webkit.org/show_bug.cgi?id=139689

Reviewed by Andreas Kling.

copyRef() doesn't modify the original object so it should be const.
Also, add a && qualified overload and mark it deleted so that calls to copyRef() where
the object is an rvalue will fail to compile.

* wtf/RefPtr.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fixes operationPutByIdOptimizes such that they check that the put didn't
change the structure of the object who's property access is being
cached.
https://bugs.webkit.org/show_bug.cgi?id=139500

Reviewed by Geoffrey Garen.

* jit/JITOperations.cpp:
(JSC::operationPutByIdStrictOptimize): saved the structure before the put.
(JSC::operationPutByIdNonStrictOptimize): ditto.
(JSC::operationPutByIdDirectStrictOptimize): ditto.
(JSC::operationPutByIdDirectNonStrictOptimize): ditto.
* jit/Repatch.cpp:
(JSC::tryCachePutByID): Added argument for the old structure
(JSC::repatchPutByID): Added argument for the old structure
* jit/Repatch.h:
* tests/stress/put-by-id-build-list-order-recurse.js:
Added test that fails without this patch.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
More expectations updated to Timeout.

* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177381 268f45cc-cd09-0410-ab3c-d52691b4dbfc
More expectations updated to Timeout.

* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:



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