Support document-relative and custom-frame page overlays
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Apr 2014 21:41:28 +0000 (21:41 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Apr 2014 21:41:28 +0000 (21:41 +0000)
commitc9c09288fdc1cfcb1897e7f076ed876524531416
treeb510468f670f166db0893793d30eac4aa40a0a37
parent2a48a7e3e6c9e0d0600ae134cc5c064a31343c56
Support document-relative and custom-frame page overlays
https://bugs.webkit.org/show_bug.cgi?id=131560
<rdar://problem/16595556>

Reviewed by Simon Fraser.

Add "document-relative" overlays, which attach to (and scroll with) the document,
and can be given a frame rect within the document to avoid overallocation of backing store.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::didChangeScrollOffset):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::mainFrame):
(WebKit::WebPage::mainFrameView):
(WebKit::WebPage::didChangeScrollOffsetForFrame):
* WebProcess/WebPage/WebPage.h:
Let the PageOverlayController know *which* frame scrolled, instead of "any frame".

* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindUIAfterPageScroll):
Factor out shared code.

(WebKit::FindController::willMoveToWebPage):
(WebKit::FindController::drawRect):
We can use clearRect() instead of a transparency layer and fillRect().
I've looked through all the other overlay clients I know of and none of them
depend on having a transparency layer at the overlay level.

* WebProcess/WebPage/PageOverlay.cpp:
(WebKit::PageOverlay::create):
(WebKit::PageOverlay::PageOverlay):
(WebKit::PageOverlay::bounds):
(WebKit::PageOverlay::frame):
(WebKit::PageOverlay::setFrame):
(WebKit::PageOverlay::drawRect):
Add OverlayType, which allows creation of Document or View relative overlays.
All overlays up to this point are View relative, so we default to that.
Document-relative overlays scroll with the page instead of repainting as
the page scrolls. They can also be given an explicit frame, allowing them
to be smaller than the entire document.

* WebProcess/WebPage/PageOverlay.h:
(WebKit::PageOverlay::overlayType):
(WebKit::PageOverlay::webPage):
(WebKit::PageOverlay::client): Deleted.
* WebProcess/WebPage/PageOverlayController.cpp:
(WebKit::PageOverlayController::initialize):
(WebKit::PageOverlayController::installPageOverlay):
(WebKit::PageOverlayController::uninstallPageOverlay):
(WebKit::PageOverlayController::updateForceSynchronousScrollLayerPositionUpdates):
(WebKit::updateOverlayGeometry):
(WebKit::PageOverlayController::setPageOverlayNeedsDisplay):
(WebKit::PageOverlayController::didChangeViewSize):
(WebKit::PageOverlayController::didChangeDocumentSize):
(WebKit::PageOverlayController::didChangeDeviceScaleFactor):
(WebKit::PageOverlayController::didScrollFrame):
(WebKit::PageOverlayController::flushPageOverlayLayers):
(WebKit::PageOverlayController::didChangeOverlayFrame):
Keep two overlay root layers - one for view-relative
and one for document-relative overlays.
Don't force synchronous scrolling if we only have document-relative overlays.
Update the overlay's position as well as its size whenever necessary.
Update document-relative overlay geometry when the document size changes.
Only explicitly flush view-relative overlays; document-relative ones
are plugged into the WebCore layer tree and flushed along with the page.

* WebProcess/WebPage/PageOverlayController.h:
(WebKit::PageOverlayController::documentOverlayRootLayer):
(WebKit::PageOverlayController::viewOverlayRootLayer):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::setRootCompositingLayer):
(WebKit::RemoteLayerTreeDrawingArea::mainFrameContentSizeChanged):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::mainFrameContentSizeChanged):
(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
Let the PageOverlay controller know when the document size changes.
When we set up compositing, push the document overlay root layer
down into WebCore.

* WebCore.exp.in:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::RenderLayerCompositor):
(WebCore::RenderLayerCompositor::rebuildCompositingLayerTree):
(WebCore::RenderLayerCompositor::setDocumentOverlayRootLayer):
* rendering/RenderLayerCompositor.h:
Add the concept of a document overlay layer, which is plugged in as the
last child of the root content layer. Expose it to WebKit2.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167152 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp
Source/WebKit2/WebProcess/WebPage/PageOverlay.h
Source/WebKit2/WebProcess/WebPage/PageOverlayController.cpp
Source/WebKit2/WebProcess/WebPage/PageOverlayController.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm