[CSS Grid Layout] Sort items by span when resolving content-based track sizing functions
https://bugs.webkit.org/show_bug.cgi?id=135701

Reviewed by Darin Adler.

Source/WebCore:

Section 10.4 of the specs mentions that we should first treat non
spanning items and then incrementally proceed with items with
greater spans when resolving the track breaths in the Track Sizing
Algorithm.

As a nice side effect we're removing the multiple processing of
spanning grid items caused by GridIterator (it returns the same
item as many times as the number of cells it spans). This adds a
~4% performance penalty in auto-grid-lots-of-data.html mainly due
to the use of a hash to remove duplicates.

Test: fast/css-grid-layout/grid-item-order-in-content-sized-columns-resolution.html

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::gridItemSpan):
(WebCore::gridItemWithSpanSorter):
(WebCore::uniquePointerInPair):
(WebCore::RenderGrid::resolveContentBasedTrackSizingFunctions):
* rendering/RenderGrid.h:

LayoutTests:

Tests that check that items are sorted by span to resolve content
based track sizing functions instead of directly using DOM order.

* fast/css-grid-layout/grid-item-order-in-content-sized-columns-resolution-expected.txt: Added.
* fast/css-grid-layout/grid-item-order-in-content-sized-columns-resolution.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173620 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Ecore and Eina are initialized twice in TestWebKitAPI
https://bugs.webkit.org/show_bug.cgi?id=136822

Reviewed by Gyuyoung Kim.

In TestWebKitAPI/efl/main.cpp, ecore and eina modules are unnecessarily
initialized as we already does it in PlatformWebView::PlatformWebView
calling ewk_init(). The reason for that was to ensure testing for example,
WTF where creating the view is not mandatory.

Call ewk_init() and ewk_shutdown() in TestWebKitAPI/efl/main.cpp
in order to properly initalize and release EWebKit.

* TestWebKitAPI/PlatformEfl.cmake:
* TestWebKitAPI/efl/PlatformWebView.cpp:
(TestWebKitAPI::PlatformWebView::PlatformWebView):
(TestWebKitAPI::PlatformWebView::~PlatformWebView):
* TestWebKitAPI/efl/main.cpp:
(main):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Avoid redundant isElementNode() checks in Traversal<HTML*Element> / Traversal<SVG*Element>
https://bugs.webkit.org/show_bug.cgi?id=136719

Reviewed by Darin Adler.

Avoid redundant isElementNode() checks in Traversal<HTML*Element> /
Traversal<SVG*Element>.  We used to iterate through Elements, and then
call isElementOfType<HTML*Element>()  on each Element. This made sense
because hasTagName() used to be defined on Element. However, after
http://trac.webkit.org/changeset/165699, hasTagName() is now defined on
Node for HTMLQualifiedName / SVGQualifiedName arguments.

Node::hasTagName(HTMLQualifiedName) basically does the following check
"isHTMLElement() &&  toHTMLElement(*this).hasTagName(tagName)". As a
consequence, doing an isElementNode() check is now redundant as
isHTMLElement() is defined on Node.

This patch adds a template parameter to isElementOfType() so that it can
take any type in argument (particulaly Node, Element, HTMLElement,
SVGElement, MathMLElement), not just an Element. I had to add an
ElementTypeCastTraits struct to support partial specialization as C++
does not support partial specialization of template functions.
This patch also updates Traversal<ElementType> so that the methods use
NodeTraversal internally instead of Traversal<ElementType>. As a result,
we now iterate over Nodes (not Elements) and call the new
isElementOfType<ElementType>(Node) helpers (which are efficient after
r165699).

Before the patch, the code ended up doing the following checks for
Traversal<HTML*element>:
node.isElementNode() && toElement(node).isHTMLElement()
    && toHTMLElement(node).hasTagName(HTMLNames::fooTag)

After the patch, the code only does:
node.isHTMLElement()
    && toHTMLElement(node).hasTagName(HTMLNames::fooTag)

No new tests, no behavior change.

* dom/Element.h:
(WebCore::Element>):
(WebCore::isElementOfType):
Add template parameter to isElementOfType() function so that it can
handle any argument type, not just Elements. Also introduce an
ElementTypeCastTraits struct that is called by isElementOfType()
function so that we can so partial template specialization.

* dom/ElementTraversal.h:
(WebCore::Traversal<ElementType>::firstWithinTemplate):
(WebCore::Traversal<ElementType>::lastWithinTemplate):
(WebCore::Traversal<ElementType>::nextTemplate):
(WebCore::Traversal<ElementType>::previousTemplate):
Use NodeTraversal API internally instead of Traversal<Element> to avoid
redundant isElementNode() checks.

(WebCore::Traversal<Element>::lastWithinTemplate): Deleted.
The code is now identical to the generic version.

(WebCore::Traversal<Element>::previousTemplate): Deleted.
The code is now identical to the generic version.

* dom/make_names.pl:
(printTypeHelpers):
- Generate template specializations for ElementTypeCastTraits struct
  instead of isElementOfType(). This avoids having to provide overloads
  for specific argument types (e.g. Node, Element, HTMLElement, ...).
- Share more code between HTML code path and the other path (for SVG,
  MTHML).

* html/HTMLElement.h:
(WebCore::HTMLElement>):
Provide HTMLElement template specialization for ElementTypeCastTraits
struct instead of isElementOfType().

* html/HTMLFormControlElement.h:
(WebCore::HTMLFormControlElement>):
Provide HTMLFormControlElement template specialization for
ElementTypeCastTraits struct instead of isElementOfType().

* html/HTMLFrameElementBase.h:
(WebCore::isHTMLFrameElementBase):
- Remove helper taking an Element in argument as it does not bring any
  benefit. Instead, update the overload taking a Node in argument to
  remove the unnecessary isElementNode() check as isHTMLFrameElement(Node)
  is now efficient.
- Add an overload taking an HTMLElement in argument so that we can bypass
  the isHTMLElement() check when we know the input is an HTMLElement.

* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement>):
Provide HTMLMediaElement template specialization for ElementTypeCastTraits
struct instead of isElementOfType().

* html/HTMLPlugInImageElement.h:
(WebCore::HTMLPlugInImageElement>):
Provide HTMLPlugInImageElement template specialization for
ElementTypeCastTraits struct instead of isElementOfType().

* html/LabelableElement.h:
(WebCore::LabelableElement>):
Provide LabelableElement template specialization for ElementTypeCastTraits
struct instead of isElementOfType().

* mathml/MathMLElement.h:
(WebCore::MathMLElement>):
Provide MathMLElement template specialization for ElementTypeCastTraits
struct for consistency with HTMLElement / SVGElement.

* svg/SVGElement.h:
(WebCore::SVGElement>):
- Provide SVGElement template specialization for ElementTypeCastTraits
  struct instead of isElementOfType().
- include SVGElementTypeHelpers.h at the end of the file (similarly to
  what is already done in HTMLElement.h because
  isElementOfType(const SVGElement&) needs to be defiend because the
  include.

* svg/SVGFilterPrimitiveStandardAttributes.h:
(WebCore::SVGFilterPrimitiveStandardAttributes>):
Provide SVGFilterPrimitiveStandardAttributes template specialization for
ElementTypeCastTraits struct instead of isElementOfType().

* svg/animation/SVGSMILElement.h:
(WebCore::SVGSMILElement>):
Provide SVGSMILElement template specialization for ElementTypeCastTraits
struct instead of isElementOfType().


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Should call [BKSProcessAssertion invalidate]
https://bugs.webkit.org/show_bug.cgi?id=136804
<rdar://problem/17897780>

Reviewed by Darin Adler.

We should invalidate the process assertion before releasing it. Fortunately this is really easy,
since there is a simple 1:1 relationship with ProcessAssertion, with their lifetimes matching exactly.

* UIProcess/ProcessAssertion.cpp:
(WebKit::ProcessAssertion::~ProcessAssertion):
    - no-op implementation.
* UIProcess/ProcessAssertion.h:
    - added destructor.
* UIProcess/ios/ProcessAssertionIOS.mm:
(WebKit::ProcessAssertion::~ProcessAssertion):
    - destructor invalidates the BKSProcessAssertion.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173623 268f45cc-cd09-0410-ab3c-d52691b4dbfc
DFG ref count calculation should be reusable
https://bugs.webkit.org/show_bug.cgi?id=136811

Reviewed by Oliver Hunt.
        
Henceforth if you call Graph::computeRefCounts(), a nifty O(n) operation, every Node
will be able to tell you how many places it is used from. Currently only DCE uses this,
but it will be useful for https://bugs.webkit.org/show_bug.cgi?id=136330.

* dfg/DFGDCEPhase.cpp:
(JSC::DFG::DCEPhase::run):
(JSC::DFG::DCEPhase::findTypeCheckRoot): Deleted.
(JSC::DFG::DCEPhase::countNode): Deleted.
(JSC::DFG::DCEPhase::countEdge): Deleted.
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::computeRefCounts):
* dfg/DFGGraph.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add another Apple build slave to the Mountain Lion Debug WK1 queue
        
Rubber stamped by Matt Hanson.
        
* BuildSlaveSupport/build.webkit.org-config/config.json:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] Support audioSourceProvider() in MediaPlayerPrivateAVFoundationObjC
https://bugs.webkit.org/show_bug.cgi?id=135042

Reviewed by Eric Carlson.

Source/WebCore:

Add support for AudioSourceProvider in MediaPlayerPrivateAVFoundationObjC, thereby
supporting MediaElementAudioSourceNode.

Import the CARingBuffer from CoreAudio sample code, making the necessary modifications
for WebKit style and coding conventions. The threading assumptions for this class are
that there will be a single writer thread and a single reader thread.

* platform/audio/mac/CARingBuffer.cpp: Added.
(WebCore::CARingBuffer::create): Create a unique_ptr.
(WebCore::CARingBuffer::CARingBuffer): Simple constructor.
(WebCore::CARingBuffer::~CARingBuffer): Simple destructor.
(WebCore::CARingBuffer::allocate): Initialize the buffers and time bounds structures.
(WebCore::CARingBuffer::deallocate): Destroy same.
(WebCore::ZeroRange): Static utility method.
(WebCore::StoreABL): Ditto.
(WebCore::FetchABL): Ditto.
(WebCore::ZeroABL): Ditto.
(WebCore::CARingBuffer::store): Store the passed in buffer in the ring buffer, wrapping
    if necessary.
(WebCore::CARingBuffer::setTimeBounds): Set the new time bounds by incrementing the
    bounds index locally, filling in the new values, then atomically incrementing the
    reader-visible index.
(WebCore::CARingBuffer::getTimeBounds): Get the new time bounds by masking the time
    bounds index, and using it as an offset to the time bounds array. Protect against
    CPU starvation on the reading thread by checking the index against the stored
    index in the array entry. This check will fail if the writing thread has wrapped
    more than the size of the array.
(WebCore::CARingBuffer::clipTimeBounds): Clamp the passed values to the available bounds.
(WebCore::CARingBuffer::startFrame): Simple accessor.
(WebCore::CARingBuffer::endFrame): Ditto.
(WebCore::CARingBuffer::fetch): Read an audio buffer list from the ring buffer, possbily
    wrapping around to the start of the ring buffer.
* platform/audio/mac/CARingBuffer.h: Added.
(WebCore::CARingBuffer::numberOfChannels): Simple accessor.
(WebCore::CARingBuffer::frameOffset): Ditto.
(WebCore::CARingBuffer::TimeBounds::TimeBounds): Struct holding the start and end frame values.

Add an implementation of AudioSourceProvider, using AVAudioMix and MTAudioProcessingTap
to tap an AVPlayerItem's audio output and feed it to a MediaElementAudioSourceNode.

* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h: Added.
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: Added.
(WebCore::AudioSourceProviderAVFObjC::create): Simple factory.
(WebCore::AudioSourceProviderAVFObjC::AudioSourceProviderAVFObjC): Simple constructor.
(WebCore::AudioSourceProviderAVFObjC::~AudioSourceProviderAVFObjC): Simple destructor.
(WebCore::AudioSourceProviderAVFObjC::provideInput): Push audio into the ring buffer.
(WebCore::AudioSourceProviderAVFObjC::setClient): Call destroyMix()/createMix() as appropriate.
(WebCore::AudioSourceProviderAVFObjC::setPlayerItem): Ditto.
(WebCore::AudioSourceProviderAVFObjC::destroyMix): Detach and destroy the AVAudioMix and tap.
(WebCore::AudioSourceProviderAVFObjC::createMix): Set up the AVAudioMix and tap and attach to
    the AVPlayerItem.
(WebCore::AudioSourceProviderAVFObjC::initCallback): Pass to class method.
(WebCore::AudioSourceProviderAVFObjC::finalizeCallback): Ditto.
(WebCore::AudioSourceProviderAVFObjC::prepareCallback): Ditto.
(WebCore::AudioSourceProviderAVFObjC::unprepareCallback): Ditto.
(WebCore::AudioSourceProviderAVFObjC::processCallback): Ditto.
(WebCore::AudioSourceProviderAVFObjC::init): Set up the storage pointer for the tap.
(WebCore::AudioSourceProviderAVFObjC::finalize): No-op.
(WebCore::operator==): Compare two AudioStreamBasicDescription objects.
(WebCore::operator!=): Ditto.
(WebCore::AudioSourceProviderAVFObjC::prepare): Create an AudioCoverter object if necessary,
    create the ring buffer, and notify the client of format changes.
(WebCore::AudioSourceProviderAVFObjC::unprepare): Destroy same.
(WebCore::AudioSourceProviderAVFObjC::process): Copy samples out of the ring buffer,
    format converting them if necessary. Mute original audio.

Create the AudioSourceProviderAVFObjC object and notify it when the current AVPlayerItem changes.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem):
(WebCore::MediaPlayerPrivateAVFoundationObjC::audioSourceProvider):

Enable SOFT_LINK_MAY_FAIL on the Mac platform.

* platform/mac/SoftLinking.h:

Add new files to the project.

* WebCore.xcodeproj/project.pbxproj:

Source/WTF:

* wtf/Platform.h: Add WTF_USE_MEDIATOOLBOX.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Change all snapshotting tests to use quicktime.

* platform/mac-wk2/TestExpectations:
* platform/mac-wk2/plugins/snapshotting/autoplay-similar-to-dominant-expected.txt:
* plugins/snapshotting/autoplay-dominant-blank-plugin-moved-into-view.html:
* plugins/snapshotting/autoplay-dominant.html:
* plugins/snapshotting/autoplay-plugin-blocked-by-image.html:
* plugins/snapshotting/autoplay-plugin-mostly-blocked-by-image.html:
* plugins/snapshotting/autoplay-similar-to-dominant.html:
* plugins/snapshotting/plugin-receives-click-event.html:
* plugins/snapshotting/restart.html:
* plugins/snapshotting/set-plugin-size-to-tiny.html:
* plugins/snapshotting/simple.html:
* plugins/snapshotting/snapshot-plugin-not-quite-blocked-by-image.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173629 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Add an unimplemented case to handle CSSPropertyWebkitInitialLetter so we don't get an assertion failure.

* css/SVGCSSStyleSelector.cpp:
(WebCore::StyleResolver::applySVGProperty):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Videos with controls enabled never receive 'dragstart' events.
https://bugs.webkit.org/show_bug.cgi?id=136837

Reviewed by Simon Fraser.

When initiating a drag, the DragController checks whether the hit-tested element at a
drag location is a child of the drag source, and bails if early if that is not the case.
For a <video> element with controls, the hit-tested element is an element within the
<video> element's Shadow DOM. Because the DragController uses a method which does not
take Shadow DOM into account when determining a child-parent relationship, this test fails
and all drag operations fail as well.

For <video> elements only, when testing whether the drag source is an ancestor of the
hit-tested element, use containsIncludingShadowDOM() instead of contains(). To ensure that
the controls are still usable when a drag listener is active on a <video> element, mark
the controls as a draggable element, but simply call preventDefault() in the controls'
'dragstart' handler, ensuring the timeline and volume controls are themselves still draggable.

* Modules/mediacontrols/mediaControlsApple.css:
(audio::-webkit-media-controls-panel):
* Modules/mediacontrols/mediaControlsApple.js:
(Controller.prototype.createControls):
(Controller.prototype.handlePanelDragStart):
* page/DragController.cpp:
(WebCore::DragController::startDrag):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed logic fix from r173631. Logic for includeShadowDOM was reversed.

* page/DragController.cpp:
(WebCore::DragController::startDrag):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Skip initial-letter tests on Windows.
https://bugs.webkit.org/show_bug.cgi?id=136841
* platform/win/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173633 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed build fix for 32-bit builds.

Make casts from unsigned long long -> size_t explicit, rather than implicit. Also
make CARingBuffer be protected by USING_MEDIA_TOOLBOX so ports without that flag
won't try to compile unused code.

* platform/audio/mac/CARingBuffer.cpp:
(WebCore::CARingBuffer::fetch):
* platform/audio/mac/CARingBuffer.h:
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
(WebCore::AudioSourceProviderAVFObjC::provideInput):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Crash when logging in to optionshouse.com
https://bugs.webkit.org/show_bug.cgi?id=136834

Reviewed by Anders Carlsson.

No test, because I couldn't make one. I don't have a way to reproduce first-hand.

* platform/network/cf/SocketStreamHandleCFNet.cpp:
(WebCore::SocketStreamHandle::readStreamCallback):
(WebCore::SocketStreamHandle::writeStreamCallback):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173635 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Create a JSCallee for GlobalExec object
https://bugs.webkit.org/show_bug.cgi?id=136840

Reviewed by Geoffrey Garen.

Added m_globalCallee, initialized it and then used it to set the globalExec's callee.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Skip yet another ecma/Date test that fails only on Windows.
https://bugs.webkit.org/show_bug.cgi?id=25160

* Scripts/run-javascriptcore-tests:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173637 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Naming clean-up.

Rubber-stamped by Andy Estes.

* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::requestAutocomplete):
(WebCore::HTMLFormElement::finishRequestAutocomplete):
Remove superfluous "AutocompleteResult".

* html/HTMLFormElement.h:
Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173638 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Inspector: mouse drifts away from resizer when resizing docked inspector
https://bugs.webkit.org/show_bug.cgi?id=22263

Patch by Matt Baker <mattbaker@apple.com> on 2014-09-15
Reviewed by Joseph Pecoraro.

Modified the docked resizer dragging logic to record the initial mouse down position relative to the
resizer client rectangle. Added check while dragging the resizer to ensure that the cursor is positioned
correctly with respect to the resize direction before updating the attached window dimension.

* UserInterface/Base/Main.js:
(WebInspector._dockedResizerMouseDown.dockedResizerDrag):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173640 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Windows rebaselining to account for subpixel layout Part 1.

* platform/win/editing/selection/move-left-right-expected.txt:
* platform/win/editing/selection/vertical-lr-ltr-extend-line-backward-br-expected.txt:
* platform/win/editing/selection/vertical-lr-ltr-extend-line-forward-br-expected.txt:
* platform/win/editing/selection/vertical-rl-ltr-extend-line-backward-br-expected.txt:
* platform/win/editing/selection/vertical-rl-ltr-extend-line-backward-p-expected.txt:
* platform/win/editing/selection/vertical-rl-ltr-extend-line-forward-br-expected.txt:
* platform/win/editing/selection/vertical-rl-ltr-extend-line-forward-p-expected.txt:
* platform/win/editing/selection/vertical-rl-rtl-extend-line-backward-p-expected.txt:
* platform/win/editing/selection/vertical-rl-rtl-extend-line-forward-br-expected.txt:
* platform/win/editing/selection/vertical-rl-rtl-extend-line-forward-p-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173641 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Core: Websocket state should be set to closed in didReceiveMessage call back.
https://bugs.webkit.org/show_bug.cgi?id=136219

Patch by Shivakumar JM <shiva.jm@samsung.com> on 2014-09-15
Reviewed by Alexey Proskuryakov.

Source/WebCore:

Set the Websocket state to closed in didReceiveMessage call back.

Test: http/tests/websocket/tests/hybi/error-event-ready-state.html

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::didReceiveMessageError):

LayoutTests:

Added test to check readyState is CLOSED within onerror event.

* http/tests/websocket/tests/hybi/error-event-ready-state-expected.txt: Added.
* http/tests/websocket/tests/hybi/error-event-ready-state.html: Added.

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