Move PageOverlay[Controller] to WebCore
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Oct 2014 21:06:14 +0000 (21:06 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Oct 2014 21:06:14 +0000 (21:06 +0000)
commit2e189e88ced8995c2e41fcc0d2817efaeb517929
tree36dac9283e81900d4825b207c5ca74b85f2ce718
parent192cf77c499de398c3c1fecb94843cd9a3a0a9e5
Move PageOverlay[Controller] to WebCore
https://bugs.webkit.org/show_bug.cgi?id=137164
<rdar://problem/18508258>

Reviewed by Anders Carlsson.

* CMakeLists.txt:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Make the appropriate build system changes.

* WebCore.exp.in:
Export the new PageOverlay[Controller] symbols from WebCore.

* loader/EmptyClients.h:
* page/ChromeClient.h:
(WebCore::ChromeClient::documentOverlayLayerForFrame): Deleted.
Add attachViewOverlayGraphicsLayer, which allows PageOverlayController
to push view-relative page overlay root layers down to WebKit to be
installed just inside the view.

Remove documentOverlayLayerForFrame because RenderLayerCompositor can now
talk directly to PageOverlayController.

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::mouseMoved):
(WebCore::EventHandler::handleMouseReleaseEvent):
When the mouse is moved, pressed, or released, give PageOverlayController
the first shot at handling the event.

* page/FrameView.cpp:
(WebCore::FrameView::setFrameRect):
Inform PageOverlayController that the main FrameView's size changed,
so it can update the size of view-relative overlays.

(WebCore::FrameView::setContentsSize):
Inform PageOverlayController that the main FrameView's contents size changed,
so it can update the size of document-relative overlays.

(WebCore::FrameView::setFixedVisibleContentRect):
(WebCore::FrameView::didChangeScrollOffset):
(WebCore::FrameView::scrollTo):
(WebCore::FrameView::wheelEvent):
Inform PageOverlayController that something scrolled.

(WebCore::FrameView::setExposedRect):
Inform PageOverlayController that the exposed rect changed, so it can push
the new exposed rect down to the overlays.

* page/FrameView.h:
Add didChangeScrollOffset.

* page/MainFrame.cpp:
(WebCore::MainFrame::MainFrame):
* page/MainFrame.h:
Keep one PageOverlayController per MainFrame.

* page/Page.cpp:
(WebCore::Page::setDeviceScaleFactor):
Inform PageOverlayController that the device scale factor changed.

(WebCore::Page::setSessionID):
Remove a blank line.

* page/PageOverlay.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp.
Move PageOverlay from WebKit2 to WebCore.
A few overarching changes that I won't detail in each place:
    - references instead of pointers in many places
    - WebCore types instead of WebKit2 types everywhere

(WebCore::PageOverlay::bounds):
It is possible to install an overlay before we have a FrameView.
We will eventually get a view/contents size changed notification and try again.

(WebCore::PageOverlay::copyAccessibilityAttributeStringValueForPoint):
(WebCore::PageOverlay::copyAccessibilityAttributeBoolValueForPoint):
(WebCore::PageOverlay::copyAccessibilityAttributeNames):
Split copyAccessibilityAttribute into "StringValueForPoint" and "BoolValueForPoint"
variants, because we don't have anything like WKTypeRef here.

* page/PageOverlay.h: Renamed from Source/WebKit2/WebProcess/WebPage/PageOverlay.h.
Make PageOverlay a normal RefCounted object instead of a WebKit2 API object.
Leave a comment noting that we should move the PageOverlay's GraphicsLayer
to PageOverlay instead of a map on PageOverlayController.

* page/PageOverlayController.cpp: Renamed from Source/WebKit2/WebProcess/WebPage/PageOverlayController.cpp.
Move PageOverlayController from WebKit2 to WebCore.
A few overarching changes that I won't detail in each place:
    - references instead of pointers in many places
    - WebCore types instead of WebKit2 types everywhere

Leave a FIXME that didChangeSettings is not currently called when settings change.
This is not a problem for normal use of overlays, only for dynamically changing
layer border/repaint counter settings.

(WebCore::PageOverlayController::PageOverlayController):
(WebCore::PageOverlayController::createRootLayersIfNeeded):
We will now lazily initialize the root layers when we first try to use them,
because otherwise we try to create them before the ChromeClient's GraphicsLayerFactory
is hooked up, in some cases, and that can cause us to create the wrong kind of GraphicsLayers.

(WebCore::PageOverlayController::installPageOverlay):
Enter compositing mode when installing a PageOverlay.
Avoid pushing the Page to the PageOverlay until after we've set up
its root layer, so that the installation process can make use of that layer;
clients may, for example, expect to be able to setNeedsDisplay() in the
didMoveToPage callback.
Avoid updateOverlayGeometry until the layer is created and we've pushed
the Page down, so that e.g. bounds() will use the right Page.

(WebCore::PageOverlayController::didChangeSettings):
Leave a FIXME about a future improvement to didChangeSettings.

(WebCore::PageOverlayController::deviceScaleFactor):
(WebCore::PageOverlayController::notifyFlushRequired):
Null-check Page; these can get called when tearing down the Frame.

* page/PageOverlayController.h: Renamed from Source/WebKit2/WebProcess/WebPage/PageOverlayController.h.

* platform/graphics/GraphicsLayerClient.h:
Add wtf/Forward.h, because GraphicsLayerClient.h uses String.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollTo):
Inform PageOverlayController that something scrolled.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::hasAnyAdditionalCompositedLayers):
Make hasAnyAdditionalCompositedLayers return true if there are any page overlays,
because we need to avoid falling out of compositing mode if we still have
page overlays.

(WebCore::RenderLayerCompositor::updateCompositingLayers):
Enter compositing mode if we have page overlays.

(WebCore::RenderLayerCompositor::appendOverlayLayers): Deleted.
(WebCore::RenderLayerCompositor::appendDocumentOverlayLayers):
Rename appendOverlayLayers -> appendDocumentOverlayLayers.

(WebCore::RenderLayerCompositor::attachRootLayer):
(WebCore::RenderLayerCompositor::detachRootLayer):
Attach/detach the view overlay root layer when attaching/detaching the
normal compositing root layer.

(WebCore::RenderLayerCompositor::rootLayerAttachmentChanged):
* rendering/RenderLayerCompositor.h:

* CMakeLists.txt:
* WebKit2.xcodeproj/project.pbxproj:
Make the appropriate build system changes.

* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
Make WKBundlePageOverlayRef map to WebPageOverlay instead of PageOverlay.

* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageInstallPageOverlay):
(WKBundlePageUninstallPageOverlay):
(WKBundlePageInstallPageOverlayWithAnimation):
(WKBundlePageUninstallPageOverlayWithAnimation):
Forward PageOverlay installation/uninstallation to WebCore.

* WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp:
(WKBundlePageOverlayGetTypeID):
(WKBundlePageOverlayCreate):
(WKBundlePageOverlaySetAccessibilityClient):
Use WebPageOverlay instead of PageOverlay, and references instead of pointers.
We forward client callbacks through from PageOverlay::Client to WebPageOverlay::Client.

(PageOverlayClientImpl::copyAccessibilityAttributeValue):
(PageOverlayClientImpl::copyAccessibilityAttributeNames):
Convert from wtf types to WebKit2 types.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::graphicsLayerFactory):
If we don't have a drawing area, don't dereference it!

(WebKit::WebChromeClient::attachViewOverlayGraphicsLayer):
Forward attachViewOverlayGraphicsLayer to the DrawingArea.

* WebProcess/WebCoreSupport/WebChromeClient.h:

* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
* WebProcess/WebCoreSupport/WebInspectorClient.h:
* WebProcess/WebPage/FindController.cpp:
* WebProcess/WebPage/FindController.h:
* WebProcess/WebPage/ios/FindControllerIOS.mm:
* WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h:
* WebProcess/WebPage/mac/ServicesOverlayController.mm:
* WebProcess/WebPage/ServicesOverlayController.h:
Mechanical changes to adopt to the fact that PageOverlay is in WebCore now.

* WebProcess/WebPage/LayerTreeHost.h:
* WebProcess/WebPage/WebPage.cpp:
* WebProcess/WebPage/WebPage.h:
Remove support for WebKit2-based page overlays.
Return MainFrame instead of Frame from mainFrame().

* WebProcess/WebPage/WebPageOverlay.cpp: Added.
* WebProcess/WebPage/WebPageOverlay.h: Added.
(WebKit::WebPageOverlay::create):
(WebKit::WebPageOverlay::WebPageOverlay):
(WebKit::WebPageOverlay::~WebPageOverlay):
(WebKit::WebPageOverlay::setNeedsDisplay):
(WebKit::WebPageOverlay::clear):
(WebKit::WebPageOverlay::pageOverlayDestroyed):
(WebKit::WebPageOverlay::willMoveToPage):
(WebKit::WebPageOverlay::didMoveToPage):
(WebKit::WebPageOverlay::drawRect):
(WebKit::WebPageOverlay::mouseEvent):
(WebKit::WebPageOverlay::didScrollFrame):
(WebKit::WebPageOverlay::copyAccessibilityAttributeStringValueForPoint):
(WebKit::WebPageOverlay::copyAccessibilityAttributeBoolValueForPoint):
(WebKit::WebPageOverlay::copyAccessibilityAttributeNames):
WebPageOverlay exists to be our API object, but forwards everything
to its WebCore::PageOverlay, and implements WebCore::PageOverlay::Client, and
forwards client callbacks to its WebPageOverlay::Client (which
WKBundlePageOverlay implements).

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject accessibilityParameterizedAttributeNames]):
(-[WKAccessibilityWebPageObject accessibilityAttributeValue:forParameter:]):
Forward the three AX properties that PageOverlays are ever queried for
to the appropriate PageOverlayController function.

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
(WebKit::RemoteLayerTreeDrawingArea::updateRootLayers):
Factor updateRootLayers out of setRootCompositingLayer.

(WebKit::RemoteLayerTreeDrawingArea::attachViewOverlayGraphicsLayer):
If we attach/detach the view-relative page overlay root layer,
reattach the root compositing layer's children.

(WebKit::RemoteLayerTreeDrawingArea::setRootCompositingLayer):
Ditto for the root compositing layer.

(WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
(WebKit::RemoteLayerTreeDrawingArea::mainFrameContentSizeChanged):
Informing PageOverlayController of exposed rect/document size changes is now
WebCore's job.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::updateRootLayers):
Factor updateRootLayers out of setRootCompositingLayer.

(WebKit::TiledCoreAnimationDrawingArea::attachViewOverlayGraphicsLayer):
(WebKit::TiledCoreAnimationDrawingArea::setRootCompositingLayer):
Make use of updateRootLayers when we attach/detach root compositing layer/view overlay layer.

(WebKit::TiledCoreAnimationDrawingArea::mainFrameContentSizeChanged):
(WebKit::TiledCoreAnimationDrawingArea::flushLayers):
(WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):
Informing PageOverlayController of exposed rect/document size changes is now
WebCore's job.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::attachViewOverlayGraphicsLayer):

* Shared/WebRenderLayer.cpp:
* Shared/WebRenderObject.cpp:
* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
* WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm:
* WebProcess/WebProcess.cpp:
Include MainFrame.h because WebPage::mainFrame returns a MainFrame now.

* WebCoreSupport/WebChromeClient.h:
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::attachViewOverlayGraphicsLayer):
Add an empty ChromeClient override.

* WebCoreSupport/WebChromeClient.cpp:
(WebChromeClient::attachViewOverlayGraphicsLayer):
* WebCoreSupport/WebChromeClient.h:
Add an empty ChromeClient override.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174231 268f45cc-cd09-0410-ab3c-d52691b4dbfc
60 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/EmptyClients.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/MainFrame.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageOverlay.cpp [moved from Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp with 66% similarity]
Source/WebCore/page/PageOverlay.h [moved from Source/WebKit2/WebProcess/WebPage/PageOverlay.h with 51% similarity]
Source/WebCore/page/PageOverlayController.cpp [moved from Source/WebKit2/WebProcess/WebPage/PageOverlayController.cpp with 65% similarity]
Source/WebCore/page/PageOverlayController.h [moved from Source/WebKit2/WebProcess/WebPage/PageOverlayController.h with 57% similarity]
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebChromeClient.h
Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/win/WebCoreSupport/WebChromeClient.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebRenderLayer.cpp
Source/WebKit2/Shared/WebRenderObject.cpp
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePageOverlay.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebEditorClientMac.mm
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Source/WebKit2/WebProcess/WebPage/FindController.h
Source/WebKit2/WebProcess/WebPage/LayerTreeHost.h
Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPageOverlay.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebPageOverlay.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/ios/FindControllerIOS.mm
Source/WebKit2/WebProcess/WebPage/ios/FindIndicatorOverlayClientIOS.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm
Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
Source/WebKit2/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm
Source/WebKit2/WebProcess/WebProcess.cpp