Implement beginScrubbing and endScrubbing for video fullscreen.
https://bugs.webkit.org/show_bug.cgi?id=132520

Patch by Jeremy Jones <jeremyj@apple.com> on 2014-05-05
Reviewed by Eric Carlson.

Source/WebCore:
Plumb through beginScrubbing and endScrubbing from AVKit down to HTMLMediaElement.
This keeps the playback state consistent while scrubbing and allows playback state
to return to the original state when scrubbing is complete.

* WebCore.exp.in:
* platform/ios/WebVideoFullscreenInterfaceAVKit.mm:
(-[WebAVPlayerController beginScrubbing:]):
(-[WebAVPlayerController endScrubbing:]):
* platform/ios/WebVideoFullscreenModel.h:
* platform/ios/WebVideoFullscreenModelMediaElement.h:
* platform/ios/WebVideoFullscreenModelMediaElement.mm:
(WebVideoFullscreenModelMediaElement::beginScrubbing):
(WebVideoFullscreenModelMediaElement::endScrubbing):

Source/WebKit2:
Plumb through beginScrubbing and endScrubbing.

* UIProcess/ios/WebVideoFullscreenManagerProxy.h:
* UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::beginScrubbing):
(WebKit::WebVideoFullscreenManagerProxy::endScrubbing):
* WebProcess/ios/WebVideoFullscreenManager.messages.in:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=132522
Clean up ProcessThrottler

Reviewed by Geoffrey Garen.

The initial implementation of ProcessThrottler relied on the reply from the
SetViewState message to ensure the page visibility notifications have a chance
to be delivered. This resulted in:
    - unnecessarily complicated interface to ProcessThrottler (in VisibilityState class)
    - complexity bleeding out into WebPageProxy (handling 'hiding' state).
    - for cases other than view hiding, no suspension notification in the WebContent.

To fix these issues add an explicit handshake from the ProcessThrottler to the WebPage.
This gives us two things:
    - All previously posted messages (e.g. SetViewState) will be processed before suspension.
    - WebContent is always (bar timeout) notified before suspension.

Since this interlock ensures the SetViewState message will be processed, the WKContentView no
longer needs to request a reply from SetViewState, and WebPageProxy can lose all the 'hiding'
state tracking. In turn, we can simplify VisibilityToken to a couple of simpler types, without
the interface to change state - just acquire/release to keep the process runnable or permit
suspension.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
    - VisibilityToken -> BackgroundActivityToken
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
    - m_visibilityToken -> m_activityToken, remove m_pendingViewStateUpdates
      updateVisibilityToken -> updateActivityToken
(WebKit::WebPageProxy::reattachToWebProcess):
    - updateVisibilityToken -> updateActivityToken
(WebKit::WebPageProxy::viewStateDidChange):
    - remove m_pendingViewStateUpdates, updateActivityToken after sending SetViewState
(WebKit::WebPageProxy::updateActivityToken):
    - m_visibilityToken -> m_activityToken, no need to handle 'hiding' state.
(WebKit::WebPageProxy::updateVisibilityToken): Deleted.
    - renamed to updateActivityToken
(WebKit::WebPageProxy::didUpdateViewState): Deleted.
    - implementation moved back into header.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::didUpdateViewState):
    - implementation moved back into header.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::WebProcessProxy):
    - ProcessThrottler constructor now passed WebProcessProxy.
* UIProcess/WebProcessProxy.h:
    - added ProcessWillSuspend/ProcessReadyToSuspend
* UIProcess/WebProcessProxy.messages.in:
    - added ProcessWillSuspend/ProcessReadyToSuspend
* UIProcess/ios/ProcessAssertion.h:
(WebKit::ProcessAssertion::state):
    - accessor
* UIProcess/ios/ProcessThrottler.h:
(WebKit::ProcessThrottler::VisibilityToken::visibility): Deleted.
(WebKit::ProcessThrottler::VisibilityToken::setVisibility): Deleted.
    - removed VisibilityToken class, replaced with ForegroundActivityToken/BackgroundActivityToken.
(WebKit::ProcessThrottler::ProcessThrottler): Deleted.
(WebKit::ProcessThrottler::visibilityToken): Deleted.
(WebKit::ProcessThrottler::didConnnectToProcess): Deleted.
(WebKit::ProcessThrottler::assertionState): Deleted.
(WebKit::ProcessThrottler::updateAssertion): Deleted.
    - moved implementations to .mm.
* UIProcess/ios/ProcessThrottler.mm:
(WebKit::ProcessThrottler::ForegroundActivityToken::ForegroundActivityToken):
(WebKit::ProcessThrottler::ForegroundActivityToken::~ForegroundActivityToken):
(WebKit::ProcessThrottler::BackgroundActivityToken::BackgroundActivityToken):
(WebKit::ProcessThrottler::BackgroundActivityToken::~BackgroundActivityToken):
    - new, simpler replacement for VisibilityToken. Instantiate to keep a processes running, release to suspend.
(WebKit::ProcessThrottler::ProcessThrottler):
    - constructor, now initializes WebProcessProxy pointer & timer mechanism
(WebKit::ProcessThrottler::assertionState):
    - select the appropriate AssertionState give current ActivityTokens.
(WebKit::ProcessThrottler::updateAssertionNow):
    - update the current ProcessAssertion.
(WebKit::ProcessThrottler::updateAssertion):
    - update the current ProcessAssertion, delay running->suspended transitions to give the process a chance to clean up.
(WebKit::ProcessThrottler::didConnnectToProcess):
    - moved from header.
(WebKit::ProcessThrottler::suspendTimerFired):
    - timeout to prevent processes from running in the background for too long.
(WebKit::ProcessThrottler::processReadyToSuspend):
    - handshake from the WebContent process to acknowledge it is ready to suspend.
(WebKit::ProcessThrottler::VisibilityToken::VisibilityToken): Deleted.
(WebKit::ProcessThrottler::VisibilityToken::~VisibilityToken): Deleted.
(WebKit::ProcessThrottler::VisibilityToken::hideTimerFired): Deleted.
(WebKit::ProcessThrottler::VisibilityToken::setVisibilityInternal): Deleted.
    - removed VisibilityToken class, replaced with ForegroundActivityToken/BackgroundActivityToken.
* UIProcess/ios/WKContentView.mm:
(-[WKContentView didMoveToWindow]):
    - no longer necessary to request a response from SetViewState; this interlock is now managed by the ProcessThrottler.
* UIProcess/ios/WebProcessProxyIOS.mm:
(WebKit::WebProcessProxy::sendProcessWillSuspend):
(WebKit::WebProcessProxy::processReadyToSuspend):
    - added ProcessWillSuspend/ProcessReadyToSuspend
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::processWillSuspend):
    - notification from the WebContent process that we will be suspended; for now just send back an ack.
* WebProcess/WebProcess.h:
    - added ProcessWillSuspend/ProcessReadyToSuspend
* WebProcess/WebProcess.messages.in:
    - added ProcessWillSuspend/ProcessReadyToSuspend



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168312 268f45cc-cd09-0410-ab3c-d52691b4dbfc
AX: tabindex support in SVG2
https://bugs.webkit.org/show_bug.cgi?id=130212

Reviewed by Chris Fleizach.

Source/WebCore:
The patch is mainly based on a patch for Blink by Erik Dahlström.
https://src.chromium.org/viewvc/blink?revision=172964&view=revision

It adds support for tabindex to SVG by reusing the HTML code.

Spec: https://svgwg.org/svg2-draft/interact.html#sequential-focus-navigation-and-the-tabindex-attribute
IDL attribute: https://svgwg.org/svg2-draft/types.html#__svg__SVGElement__tabIndex

Test: svg/custom/tabindex-order.html

* dom/Element.cpp:
(WebCore::Element::setTabIndex): Moved from HTMLElement and shared with all elements.
* dom/Element.h:
* html/HTMLAnchorElement.cpp: Remove outdated comment.
(WebCore::HTMLAnchorElement::canStartSelection):
* html/HTMLElement.cpp:
(WebCore::HTMLElement::setTabIndex): Deleted.
* html/HTMLElement.h:
* svg/SVGAElement.cpp: Uses the same logic as HTMLAnchorElement now.
(WebCore::SVGAElement::tabIndex):
(WebCore::SVGAElement::supportsFocus):
(WebCore::SVGAElement::isMouseFocusable):
(WebCore::SVGAElement::isKeyboardFocusable):
(WebCore::SVGAElement::canStartSelection):
* svg/SVGAElement.h:
* svg/SVGCircleElement.h:
* svg/SVGClipPathElement.h:
* svg/SVGDefsElement.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::tabIndex): Return -1 if element can not be focused.
(WebCore::SVGElement::parseAttribute):
(WebCore::SVGElement::isMouseFocusable):
(WebCore::SVGElement::isKeyboardFocusable): Deleted. Use function on Element.
* svg/SVGElement.h:
* svg/SVGElement.idl:
* svg/SVGEllipseElement.h:
* svg/SVGGElement.h:
* svg/SVGGraphicsElement.h: Remove supportsFocus() from inheriting functions.
    Don't just return true. SVG elements should not be focusable by default.
    Instead check if tabindex was set explicitly.
* svg/SVGImageElement.h:
* svg/SVGLineElement.h:
* svg/SVGPathElement.h:
* svg/SVGPolyElement.h:
* svg/SVGRectElement.h:
* svg/SVGSVGElement.h:
* svg/SVGSwitchElement.h:
* svg/SVGSymbolElement.h:
* svg/SVGTextElement.h:

LayoutTests:
Add test for tabindex on various SVG elements. Negative tests included.

Test is based upon a test from Erik Dahlström. Modified to test all SVGGraphicsElements.

* svg/custom/tabindex-order-expected.txt: Added.
* svg/custom/tabindex-order.html: Added.
* accessibility/svg-group-element-with-title.html: Give group element a role.
* platform/gtk/svg/custom/linking-uri-01-b-expected.txt:
* platform/ios-sim/svg/custom/linking-uri-01-b-expected.txt:
* platform/mac/svg/custom/linking-uri-01-b-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168313 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Blending] Webkit-blend-mode fails for accelerated parent with overflow:hidden
https://bugs.webkit.org/show_bug.cgi?id=126160

Source/WebCore:
When the isolating layer has overflow:hidden, it will create a descendant clipping layer
(m_childContainmentLayer), which will restrict the bleding layer to reading the backdrop
from the isolating layer.
The solution in this patch is to forbid the isolating layer to create a descendant clipping
layer and make all the children to get their own ancestor clipping layers instead.

Patch by Ion Rosca <rosca@adobe.com> on 2014-05-05
Reviewed by Dean Jackson.

Tests: css3/compositing/blend-mode-accelerated-parent-overflow-hidden.html
       css3/compositing/blend-mode-clip-accelerated-blending-canvas.html
       css3/compositing/blend-mode-clip-accelerated-blending-child.html
       css3/compositing/blend-mode-clip-accelerated-blending-double.html
       css3/compositing/blend-mode-clip-accelerated-blending-with-siblings.html
       css3/compositing/blend-mode-clip-accelerated-transformed-blending.html
       css3/compositing/blend-mode-clip-rect-accelerated-blending.html

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
when the compositing ancestor isolates blending we take it into account for computing
the clipping rect for this layer, because it was not allowed to create the descendant
clipping layer.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::clippedByAncestor):
when the compositing ancestor isolates blending we decide if a layer is clipped by ancestor
by computing the clipping rect taking into account all the ancestors up to and including
the compositing ancestor.
(WebCore::RenderLayerCompositor::clipsCompositingDescendants):
if a layer isolates blending, it is not allowed to create a descendant clipping layer.

LayoutTests:
Patch by Ion Rosca <rosca@adobe.com> on 2014-05-05
Reviewed by Dean Jackson.

* css3/compositing/blend-mode-accelerated-parent-overflow-hidden-expected.html: Added.
* css3/compositing/blend-mode-accelerated-parent-overflow-hidden.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-canvas-expected.txt: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-canvas.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-child-expected.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-child.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-double-expected.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-double.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-with-siblings-expected.html: Added.
* css3/compositing/blend-mode-clip-accelerated-blending-with-siblings.html: Added.
* css3/compositing/blend-mode-clip-accelerated-transformed-blending-expected.html: Added.
* css3/compositing/blend-mode-clip-accelerated-transformed-blending.html: Added.
* css3/compositing/blend-mode-clip-rect-accelerated-blending.html: Added.
* css3/compositing/blend-mode-clip-rect-accelerated-blending-expected.html: Added.
* css3/compositing/blend-mode-isolation-accelerated-overflow-hidden-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Special case ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture() for image documents
https://bugs.webkit.org/show_bug.cgi?id=132553

Reviewed by Tim Horton.


Source/WebCore: 
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* html/ImageDocument.cpp:
(WebCore::ImageDocument::imageElement):
* html/ImageDocument.h:

Source/WebKit2: 
When collecting the geometry for the smart magnification gesture, always return the image of an image document
on iOS. On iOS, it does not make much sense to return the whole document rect when the gesture is not over the image.

* WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
(WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Cocoa WebKit2] Add SPI to clear all visited links in a VisitedLinkProvider
https://bugs.webkit.org/show_bug.cgi?id=132573

Patch by Sam Weinig <sam@webkit.org> on 2014-05-05
Reviewed by Dan Bernstein.

* Shared/VisitedLinkTable.cpp:
(WebKit::VisitedLinkTable::VisitedLinkTable):
(WebKit::VisitedLinkTable::clear):
* Shared/VisitedLinkTable.h:
Add functions to clear the visited link table.

* UIProcess/API/Cocoa/_WKVisitedLinkProvider.h:
* UIProcess/API/Cocoa/_WKVisitedLinkProvider.mm:
(-[_WKVisitedLinkProvider removeAll]):
Add SPI.

* UIProcess/VisitedLinkProvider.cpp:
(WebKit::VisitedLinkProvider::removeAll):
* UIProcess/VisitedLinkProvider.h:
A remove all resets the provider and notifies all the attached processes.

* WebProcess/WebPage/VisitedLinkTableController.cpp:
(WebKit::VisitedLinkTableController::removeAllVisitedLinks):
* WebProcess/WebPage/VisitedLinkTableController.h:
* WebProcess/WebPage/VisitedLinkTableController.messages.in:
Add message to clear the visited links for a process.

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