Title: [113791] trunk
Revision
113791
Author
[email protected]
Date
2012-04-10 16:40:51 -0700 (Tue, 10 Apr 2012)

Log Message

Initial support for fixed position elements in Qt WebKit2
https://bugs.webkit.org/show_bug.cgi?id=81786

Reviewed by Noam Rosenthal.

.: 

* ManualTests/fixed-position.html: Added.

Source/WebCore: 

When the setting acceleratedCompositingForFixedPositionEnabled is true, we update
the position of fixed layers, and send updates to the UI process as we scroll.
Before painting, TextureMapperLayer receives a delta of the scroll positions between the UI 
and the web processes, and adjusts its transform position accordingly.

* page/FrameView.cpp:
(WebCore::FrameView::setFixedVisibleContentRect):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::setScrollPositionDelta):
(WebCore):
* platform/graphics/texmap/TextureMapperLayer.h:
(TextureMapperLayer):

Source/WebKit2: 

Turn on the flag acceleratedCompositingForFixedPositionEnabled when using fixed layout.
As we scroll, we keep track of the delta in scroll position between the UI and web processes,
and adjust the position of all the fixed layers by that delta.
When WebLayerTreeRenderer receives a new scroll position from the web process, it keeps it as pending,
and commit the new scroll position in flushLayerChanges.
This patch does not address scrolling overshoot and it does not fix the wrong positioning
that occurs when we zoom. These issues will be addressed in future patches.

* Shared/WebLayerTreeInfo.h:
* UIProcess/API/qt/qquickwebpage.cpp:
(QQuickWebPagePrivate::updateSize):
* UIProcess/LayerTreeHostProxy.cpp:
(WebKit::LayerTreeHostProxy::setContentsSize):
(WebKit):
(WebKit::LayerTreeHostProxy::renderNextFrame):
(WebKit::LayerTreeHostProxy::didChangeScrollPosition):
* UIProcess/LayerTreeHostProxy.h:
(LayerTreeHostProxy):
* UIProcess/LayerTreeHostProxy.messages.in:
* UIProcess/WebLayerTreeRenderer.cpp:
(WebKit::boundedScrollPosition):
(WebKit):
(WebKit::WebLayerTreeRenderer::paintToCurrentGLContext):
(WebKit::WebLayerTreeRenderer::setContentsSize):
(WebKit::WebLayerTreeRenderer::adjustPositionForFixedLayers):
(WebKit::WebLayerTreeRenderer::didChangeScrollPosition):
(WebKit::WebLayerTreeRenderer::syncLayerParameters):
(WebKit::WebLayerTreeRenderer::deleteLayer):
(WebKit::WebLayerTreeRenderer::flushLayerChanges):
* UIProcess/WebLayerTreeRenderer.h:
(WebLayerTreeRenderer):
* WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
(WebCore::WebGraphicsLayer::WebGraphicsLayer):
(WebCore::WebGraphicsLayer::syncCompositingState):
(WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly):
* WebProcess/WebCoreSupport/WebGraphicsLayer.h:
(WebGraphicsLayerClient):
(WebCore::WebGraphicsLayer::fixedToViewport):
(WebCore::WebGraphicsLayer::setFixedToViewport):
(WebGraphicsLayer):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setResizesToContentsUsingLayoutSize):
* WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
(WebKit::LayerTreeHostQt::LayerTreeHostQt):
(WebKit::LayerTreeHostQt::didSyncCompositingStateForLayer):
(WebKit::updateOffsetFromViewportForSelf):
(WebKit):
(WebKit::updateOffsetFromViewportForLayer):
(WebKit::LayerTreeHostQt::syncFixedLayers):
(WebKit::LayerTreeHostQt::setVisibleContentsRect):
* WebProcess/WebPage/qt/LayerTreeHostQt.h:
(LayerTreeHostQt):

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (113790 => 113791)


--- trunk/ChangeLog	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/ChangeLog	2012-04-10 23:40:51 UTC (rev 113791)
@@ -1,3 +1,12 @@
+2012-04-10  Yael Aharon  <[email protected]>
+
+        Initial support for fixed position elements in Qt WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=81786
+
+        Reviewed by Noam Rosenthal.
+
+        * ManualTests/fixed-position.html: Added.
+
 2012-04-10  Raphael Kubo da Costa  <[email protected]>
 
         [CMake] Do not pass -P to the preprocessor when running make_names.pl.

Added: trunk/ManualTests/fixed-position.html (0 => 113791)


--- trunk/ManualTests/fixed-position.html	                        (rev 0)
+++ trunk/ManualTests/fixed-position.html	2012-04-10 23:40:51 UTC (rev 113791)
@@ -0,0 +1,92 @@
+<html><head>
+
+<meta content="text/html; charset=windows-1251" http-equiv="Content-Type">
+<style>
+.d1{position:fixed;top:50%;right:50%;z-index:2;overflow:hidden;}
+.d2{position:fixed;bottom:5em;left:50;z-index:2;overflow:hidden;}
+.o {background:green;height:40px;width:200px;}
+.t { width:2000px; height:198px;background-color: lightgray; border: 1px solid blue;}
+body { margin: 0px; }
+</style>
+<script>
+function remove_fixed()
+{
+  document.getElementById("d1").style.position = "static";
+}
+
+function change_fixed()
+{
+  document.getElementById("d2").style.bottom = "10em";
+}
+
+</script>
+</head>
+<body class="Gradient">
+<div class="d1" id="d1"><div class="o">This is a test</div></div>
+<div class="d2" id="d2"><div class="o">This is a test</div></div>
+<div class="t" _onclick_="remove_fixed();">
+000
+</div>
+<div class="t">
+200<br>
+<button _onclick_="remove_fixed();">remove fixed</button>
+</div>
+<div class="t">
+400<br>
+<button _onclick_="change_fixed();">change fixed</button>
+</div>
+<div class="t">
+600
+</div>
+<div class="t">
+800
+</div>
+<div class="t">
+1000
+</div>
+<div class="t">
+1200
+</div>
+<div class="t">
+1400
+</div>
+<div class="t">
+1600
+</div>
+<div class="t">
+1800
+</div>
+<div class="t">
+2000
+</div>
+<div class="t">
+2200
+</div>
+<div class="t">
+2400
+</div>
+<div class="t">
+2600
+</div>
+<div class="t">
+2800
+</div>
+<div class="t">
+3000
+</div>
+<div class="t">
+3200
+</div>
+<div class="t">
+3400
+</div>
+<div class="t">
+3600
+</div>
+<div class="t">
+3800
+</div>
+<div class="t">
+4000
+</div>
+</body></html>

Modified: trunk/Source/WebCore/ChangeLog (113790 => 113791)


--- trunk/Source/WebCore/ChangeLog	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebCore/ChangeLog	2012-04-10 23:40:51 UTC (rev 113791)
@@ -1,3 +1,23 @@
+2012-04-10  Yael Aharon  <[email protected]>
+
+        Initial support for fixed position elements in Qt WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=81786
+
+        Reviewed by Noam Rosenthal.
+
+        When the setting acceleratedCompositingForFixedPositionEnabled is true, we update
+        the position of fixed layers, and send updates to the UI process as we scroll.
+        Before painting, TextureMapperLayer receives a delta of the scroll positions between the UI 
+        and the web processes, and adjusts its transform position accordingly.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::setFixedVisibleContentRect):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::setScrollPositionDelta):
+        (WebCore):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (TextureMapperLayer):
+
 2012-04-10  Peter Rybin  <[email protected]>
 
         Web Inspector: CodeGeneratorInspector.py: do not expose raw methods from generated types

Modified: trunk/Source/WebCore/page/FrameView.cpp (113790 => 113791)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -1702,8 +1702,11 @@
 {
     IntSize offset = scrollOffset();
     ScrollView::setFixedVisibleContentRect(visibleContentRect);
-    if (offset != scrollOffset())
+    if (offset != scrollOffset()) {
+        if (m_frame->page()->settings()->acceleratedCompositingForFixedPositionEnabled())
+            updateFixedElementsAfterScrolling();
         scrollPositionChanged();
+    }
     frame()->loader()->client()->didChangeScrollOffset();
 }
 

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (113790 => 113791)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -511,5 +511,14 @@
     }
 }
 
+void TextureMapperLayer::setScrollPositionDelta(const IntPoint& delta)
+{
+    // delta is the difference between the scroll offset in the ui process and the scroll offset
+    // in the web process. We add this delta to the position of fixed layers, to make
+    // sure that they do not move while scrolling.
+    m_scrollPositionDelta = delta;
+    m_transform.setPosition(m_state.pos + m_scrollPositionDelta);
 }
+
+}
 #endif

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (113790 => 113791)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h	2012-04-10 23:40:51 UTC (rev 113791)
@@ -126,6 +126,8 @@
     PassRefPtr<TextureMapperBackingStore> backingStore() { return m_backingStore; }
     void clearBackingStoresRecursive();
 
+    void setScrollPositionDelta(const IntPoint&);
+
 private:
     TextureMapperLayer* rootLayer();
     void computeTransformsRecursive();
@@ -217,6 +219,7 @@
     State m_state;
     TextureMapper* m_textureMapper;
     TextureMapperAnimations m_animations;
+    IntPoint m_scrollPositionDelta;
 };
 
 

Modified: trunk/Source/WebKit2/ChangeLog (113790 => 113791)


--- trunk/Source/WebKit2/ChangeLog	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-10 23:40:51 UTC (rev 113791)
@@ -1,3 +1,63 @@
+2012-04-10  Yael Aharon  <[email protected]>
+
+        Initial support for fixed position elements in Qt WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=81786
+
+        Reviewed by Noam Rosenthal.
+
+        Turn on the flag acceleratedCompositingForFixedPositionEnabled when using fixed layout.
+        As we scroll, we keep track of the delta in scroll position between the UI and web processes,
+        and adjust the position of all the fixed layers by that delta.
+        When WebLayerTreeRenderer receives a new scroll position from the web process, it keeps it as pending,
+        and commit the new scroll position in flushLayerChanges.
+        This patch does not address scrolling overshoot and it does not fix the wrong positioning
+        that occurs when we zoom. These issues will be addressed in future patches.
+
+        * Shared/WebLayerTreeInfo.h:
+        * UIProcess/API/qt/qquickwebpage.cpp:
+        (QQuickWebPagePrivate::updateSize):
+        * UIProcess/LayerTreeHostProxy.cpp:
+        (WebKit::LayerTreeHostProxy::setContentsSize):
+        (WebKit):
+        (WebKit::LayerTreeHostProxy::renderNextFrame):
+        (WebKit::LayerTreeHostProxy::didChangeScrollPosition):
+        * UIProcess/LayerTreeHostProxy.h:
+        (LayerTreeHostProxy):
+        * UIProcess/LayerTreeHostProxy.messages.in:
+        * UIProcess/WebLayerTreeRenderer.cpp:
+        (WebKit::boundedScrollPosition):
+        (WebKit):
+        (WebKit::WebLayerTreeRenderer::paintToCurrentGLContext):
+        (WebKit::WebLayerTreeRenderer::setContentsSize):
+        (WebKit::WebLayerTreeRenderer::adjustPositionForFixedLayers):
+        (WebKit::WebLayerTreeRenderer::didChangeScrollPosition):
+        (WebKit::WebLayerTreeRenderer::syncLayerParameters):
+        (WebKit::WebLayerTreeRenderer::deleteLayer):
+        (WebKit::WebLayerTreeRenderer::flushLayerChanges):
+        * UIProcess/WebLayerTreeRenderer.h:
+        (WebLayerTreeRenderer):
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp:
+        (WebCore::WebGraphicsLayer::WebGraphicsLayer):
+        (WebCore::WebGraphicsLayer::syncCompositingState):
+        (WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly):
+        * WebProcess/WebCoreSupport/WebGraphicsLayer.h:
+        (WebGraphicsLayerClient):
+        (WebCore::WebGraphicsLayer::fixedToViewport):
+        (WebCore::WebGraphicsLayer::setFixedToViewport):
+        (WebGraphicsLayer):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setResizesToContentsUsingLayoutSize):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+        (WebKit::LayerTreeHostQt::LayerTreeHostQt):
+        (WebKit::LayerTreeHostQt::didSyncCompositingStateForLayer):
+        (WebKit::updateOffsetFromViewportForSelf):
+        (WebKit):
+        (WebKit::updateOffsetFromViewportForLayer):
+        (WebKit::LayerTreeHostQt::syncFixedLayers):
+        (WebKit::LayerTreeHostQt::setVisibleContentsRect):
+        * WebProcess/WebPage/qt/LayerTreeHostQt.h:
+        (LayerTreeHostQt):
+
 2012-04-10  Anders Carlsson  <[email protected]>
 
         Fix fast/images/exif-orientation.html WebKitTestRunner failure

Modified: trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h (113790 => 113791)


--- trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h	2012-04-10 23:40:51 UTC (rev 113791)
@@ -65,6 +65,7 @@
             bool masksToBounds : 1;
             bool preserves3D : 1;
             bool isRootLayer: 1;
+            bool fixedToViewport : 1;
         };
         unsigned int flags;
     };

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp (113790 => 113791)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -139,6 +139,9 @@
     QSizeF scaledSize = contentsSize * contentsScale;
     q->setSize(scaledSize);
     viewportItem->updateContentsSize(scaledSize);
+    DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+    if (drawingArea && drawingArea->layerTreeHostProxy())
+        drawingArea->layerTreeHostProxy()->setContentsSize(WebCore::FloatSize(contentsSize.width(), contentsSize.height()));
 }
 
 QQuickWebPagePrivate::~QQuickWebPagePrivate()

Modified: trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp (113790 => 113791)


--- trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -122,6 +122,11 @@
     dispatchUpdate(bind(&WebLayerTreeRenderer::destroyImage, m_renderer.get(), key));
 }
 
+void LayerTreeHostProxy::setContentsSize(const FloatSize& contentsSize)
+{
+    m_renderer->setContentsSize(contentsSize);
+}
+
 void LayerTreeHostProxy::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector)
 {
     m_renderer->setVisibleContentsRect(rect, scale);
@@ -133,6 +138,11 @@
     m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
 }
 
+void LayerTreeHostProxy::didChangeScrollPosition(const IntPoint& position)
+{
+    dispatchUpdate(bind(&WebLayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position));
+}
+
 void LayerTreeHostProxy::purgeBackingStores()
 {
     m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());

Modified: trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h (113790 => 113791)


--- trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h	2012-04-10 23:40:51 UTC (rev 113791)
@@ -56,6 +56,7 @@
     void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity, const WebCore::FloatRect& clip);
     void paintToGraphicsContext(BackingStore::PlatformGraphicsContext);
     void purgeGLResources();
+    void setContentsSize(const WebCore::FloatSize&);
     void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint& trajectory);
     void didRenderFrame();
     void createTileForLayer(int layerID, int tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&);
@@ -66,6 +67,7 @@
     void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
     void updateViewport();
     void renderNextFrame();
+    void didChangeScrollPosition(const WebCore::IntPoint& position);
     void purgeBackingStores();
     WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
 

Modified: trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in (113790 => 113791)


--- trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in	2012-04-10 23:40:51 UTC (rev 113791)
@@ -29,5 +29,6 @@
     CreateDirectlyCompositedImage(int64_t key, WebKit::ShareableBitmap::Handle handle)
     DestroyDirectlyCompositedImage(int64_t key)
     DidRenderFrame()
+    DidChangeScrollPosition(WebCore::IntPoint position)
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp (113790 => 113791)


--- trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -73,6 +73,17 @@
         MainThreadGuardedInvoker<WebLayerTreeRenderer>::call(this, function);
 }
 
+static IntPoint boundedScrollPosition(const IntPoint& scrollPosition, const IntRect& visibleContentRect, const FloatSize& contentSize)
+{
+    IntSize size(contentSize.width(), contentSize.height());
+    int scrollPositionX = std::max(scrollPosition.x(), 0);
+    scrollPositionX = std::min(scrollPositionX, size.width() - visibleContentRect.width());
+
+    int scrollPositionY = std::max(scrollPosition.y(), 0);
+    scrollPositionY = std::min(scrollPositionY, size.height() - visibleContentRect.height());
+    return IntPoint(scrollPositionX, scrollPositionY);
+}
+
 WebLayerTreeRenderer::WebLayerTreeRenderer(LayerTreeHostProxy* layerTreeHostProxy)
     : m_layerTreeHostProxy(layerTreeHostProxy)
     , m_rootLayerID(0)
@@ -98,6 +109,7 @@
     ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode);
 
     syncRemoteContent();
+    adjustPositionForFixedLayers();
     GraphicsLayer* currentRootLayer = rootLayer();
     if (!currentRootLayer)
         return;
@@ -143,6 +155,11 @@
     m_textureMapper->setGraphicsContext(0);
 }
 
+void WebLayerTreeRenderer::setContentsSize(const WebCore::FloatSize& contentsSize)
+{
+    m_contentsSize = contentsSize;
+}
+
 void WebLayerTreeRenderer::setVisibleContentsRect(const IntRect& rect, float scale)
 {
     m_visibleContentsRect = rect;
@@ -155,6 +172,23 @@
         m_layerTreeHostProxy->updateViewport();
 }
 
+void WebLayerTreeRenderer::adjustPositionForFixedLayers()
+{
+    if (m_fixedLayers.isEmpty())
+        return;
+
+    IntPoint scrollPosition = boundedScrollPosition(m_visibleContentsRect.location(), m_visibleContentsRect, m_contentsSize);
+
+    LayerMap::iterator end = m_fixedLayers.end();
+    for (LayerMap::iterator it = m_fixedLayers.begin(); it != end; ++it)
+        toTextureMapperLayer(it->second)->setScrollPositionDelta(IntPoint(scrollPosition.x() - m_renderedContentsScrollPosition.x(), scrollPosition.y() - m_renderedContentsScrollPosition.y()));
+}
+
+void WebLayerTreeRenderer::didChangeScrollPosition(const IntPoint& position)
+{
+    m_pendingRenderedContentsScrollPosition = boundedScrollPosition(position, m_visibleContentsRect, m_contentsSize);
+}
+
 void WebLayerTreeRenderer::setLayerChildren(WebLayerID id, const Vector<WebLayerID>& childIDs)
 {
     ensureLayer(id);
@@ -195,6 +229,11 @@
     layer->setContentsRect(layerInfo.contentsRect);
     layer->setDrawsContent(layerInfo.drawsContent);
 
+    if (layerInfo.fixedToViewport)
+        m_fixedLayers.add(id, layer);
+    else
+        m_fixedLayers.remove(id);
+
     assignImageToLayer(layer, layerInfo.imageBackingStoreID);
 
     // Never make the root layer clip.
@@ -213,6 +252,7 @@
 
     layer->removeFromParent();
     m_layers.remove(layerID);
+    m_fixedLayers.remove(layerID);
     delete layer;
 }
 
@@ -310,6 +350,8 @@
 
 void WebLayerTreeRenderer::flushLayerChanges()
 {
+    m_renderedContentsScrollPosition = m_pendingRenderedContentsScrollPosition;
+
     m_rootLayer->syncCompositingState(FloatRect());
     commitTileOperations();
 

Modified: trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h (113790 => 113791)


--- trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h	2012-04-10 23:40:51 UTC (rev 113791)
@@ -64,7 +64,9 @@
     void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float, const WebCore::FloatRect&);
     void paintToGraphicsContext(BackingStore::PlatformGraphicsContext);
     void syncRemoteContent();
+    void setContentsSize(const WebCore::FloatSize&);
     void setVisibleContentsRect(const WebCore::IntRect&, float scale);
+    void didChangeScrollPosition(const WebCore::IntPoint& position);
 
     void detach();
     void appendUpdate(const Function<void()>&);
@@ -94,8 +96,10 @@
     virtual bool showRepaintCounter(const WebCore::GraphicsLayer*) const { return false; }
     void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) { }
     void callOnMainTread(const Function<void()>&);
+    void adjustPositionForFixedLayers();
 
     typedef HashMap<WebLayerID, WebCore::GraphicsLayer*> LayerMap;
+    WebCore::FloatSize m_contentsSize;
     WebCore::IntRect m_visibleContentsRect;
     float m_contentsScale;
 
@@ -124,7 +128,10 @@
     Vector<WebLayerID> m_layersToDelete;
 
     LayerMap m_layers;
+    LayerMap m_fixedLayers;
     WebLayerID m_rootLayerID;
+    WebCore::IntPoint m_renderedContentsScrollPosition;
+    WebCore::IntPoint m_pendingRenderedContentsScrollPosition;
 };
 
 };

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp (113790 => 113791)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -96,6 +96,7 @@
     : GraphicsLayer(client)
     , m_maskTarget(0)
     , m_inUpdateMode(false)
+    , m_fixedToViewport(false)
     , m_shouldUpdateVisibleRect(true)
     , m_shouldSyncLayerState(true)
     , m_shouldSyncChildren(true)
@@ -387,6 +388,8 @@
     if (WebGraphicsLayer* replica = toWebGraphicsLayer(replicaLayer()))
         replica->syncCompositingStateForThisLayerOnly();
 
+    m_webGraphicsLayerClient->syncFixedLayers();
+
     syncCompositingStateForThisLayerOnly();
 
     for (size_t i = 0; i < children().size(); ++i)
@@ -415,6 +418,7 @@
     if (!m_shouldSyncLayerState)
         return;
     m_shouldSyncLayerState = false;
+    m_layerInfo.fixedToViewport = fixedToViewport();
 
     m_layerInfo.anchorPoint = anchorPoint();
     m_layerInfo.backfaceVisible = backfaceVisibility();

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h (113790 => 113791)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h	2012-04-10 23:40:51 UTC (rev 113791)
@@ -59,6 +59,7 @@
     virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&) = 0;
     virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0;
     virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0;
+    virtual void syncFixedLayers() = 0;
     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&) = 0;
 };
 }
@@ -111,6 +112,9 @@
     void didSynchronize();
     Image* image() { return m_image.get(); }
 
+    bool fixedToViewport() const { return m_fixedToViewport; }
+    void setFixedToViewport(bool isFixed) { m_fixedToViewport = isFixed; }
+
     GraphicsLayer* maskTarget() const { return m_maskTarget; }
     void setMaskTarget(GraphicsLayer* layer) { m_maskTarget = layer; }
 
@@ -153,6 +157,7 @@
     bool m_shouldUpdateVisibleRect: 1;
     bool m_shouldSyncLayerState: 1;
     bool m_shouldSyncChildren: 1;
+    bool m_fixedToViewport : 1;
 
     void notifyChange();
     void didChangeGeometry();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (113790 => 113791)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -835,6 +835,8 @@
     // Always reset even when empty.
     view->setFixedLayoutSize(targetLayoutSize);
 
+    m_page->settings()->setAcceleratedCompositingForFixedPositionEnabled(true);
+
     // Schedule a layout to use the new target size.
     if (!view->layoutPending()) {
         view->setNeedsLayout();

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (113790 => 113791)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp	2012-04-10 23:40:51 UTC (rev 113791)
@@ -39,6 +39,10 @@
 #include <WebCore/Frame.h>
 #include <WebCore/FrameView.h>
 #include <WebCore/Page.h>
+#include <WebCore/RenderLayer.h>
+#include <WebCore/RenderLayerBacking.h>
+#include <WebCore/RenderLayerCompositor.h>
+#include <WebCore/RenderView.h>
 #include <WebCore/Settings.h>
 
 using namespace WebCore;
@@ -68,6 +72,7 @@
     , m_waitingForUIProcess(false)
     , m_isSuspended(false)
     , m_contentsScale(1)
+    , m_shouldSendScrollPositionUpdate(true)
     , m_shouldSyncFrame(false)
     , m_shouldSyncRootLayer(true)
     , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired)
@@ -230,6 +235,10 @@
 
 void LayerTreeHostQt::syncLayerState(WebLayerID id, const WebLayerInfo& info)
 {
+    if (m_shouldSendScrollPositionUpdate) {
+        m_webPage->send(Messages::LayerTreeHostProxy::DidChangeScrollPosition(m_visibleContentsRect.location()));
+        m_shouldSendScrollPositionUpdate = false;
+    }
     m_shouldSyncFrame = true;
     m_webPage->send(Messages::LayerTreeHostProxy::SetCompositingLayerState(id, info));
 }
@@ -256,6 +265,54 @@
     m_webPage->send(Messages::LayerTreeHostProxy::DeleteCompositingLayer(layer->id()));
 }
 
+static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer)
+{
+    // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition.
+    RenderLayerBacking* backing = renderLayer->backing();
+    if (!backing)
+        return;
+
+    RenderStyle* style = renderLayer->renderer()->style();
+    if (!style)
+        return;
+
+    if (!renderLayer->renderer()->isPositioned() || renderLayer->renderer()->style()->position() != FixedPosition)
+        return;
+
+    if (!renderLayer->renderer()->container()->isRenderView())
+        return;
+
+    if (!renderLayer->isStackingContext())
+        return;
+
+    WebGraphicsLayer* graphicsLayer = toWebGraphicsLayer(backing->graphicsLayer());
+    graphicsLayer->setFixedToViewport(true);
+}
+
+static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer)
+{
+    updateOffsetFromViewportForSelf(renderLayer);
+
+    if (renderLayer->firstChild())
+        updateOffsetFromViewportForLayer(renderLayer->firstChild());
+    if (renderLayer->nextSibling())
+        updateOffsetFromViewportForLayer(renderLayer->nextSibling());
+}
+
+void LayerTreeHostQt::syncFixedLayers()
+{
+    if (!m_webPage->corePage()->settings() || !m_webPage->corePage()->settings()->acceleratedCompositingForFixedPositionEnabled())
+        return;
+
+    if (!m_webPage->mainFrame()->view()->hasFixedObjects())
+        return;
+
+    RenderLayer* rootRenderLayer = m_webPage->mainFrame()->contentRenderer()->compositor()->rootRenderLayer();
+    ASSERT(rootRenderLayer);
+    if (rootRenderLayer->firstChild())
+        updateOffsetFromViewportForLayer(rootRenderLayer->firstChild());
+}
+
 void LayerTreeHostQt::performScheduledLayerFlush()
 {
     if (m_isSuspended || m_waitingForUIProcess)
@@ -447,6 +504,8 @@
     scheduleLayerFlush();
     if (m_webPage->useFixedLayout())
         m_webPage->setFixedVisibleContentRect(rect);
+    if (contentsRectDidChange)
+        m_shouldSendScrollPositionUpdate = true;
 }
 
 void LayerTreeHostQt::renderNextFrame()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h (113790 => 113791)


--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h	2012-04-10 23:34:52 UTC (rev 113790)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h	2012-04-10 23:40:51 UTC (rev 113791)
@@ -76,6 +76,7 @@
     virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&);
     virtual void attachLayer(WebCore::WebGraphicsLayer*);
     virtual void detachLayer(WebCore::WebGraphicsLayer*);
+    virtual void syncFixedLayers();
 
     virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&);
 
@@ -119,6 +120,7 @@
     bool m_isSuspended;
     WebCore::IntRect m_visibleContentsRect;
     float m_contentsScale;
+    bool m_shouldSendScrollPositionUpdate;
 
     LayerTreeContext m_layerTreeContext;
     bool m_shouldSyncFrame;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to