[Qt][WK2] Nested fixed elements scroll too fast
authoryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 15:35:13 +0000 (15:35 +0000)
committeryael.aharon@nokia.com <yael.aharon@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2012 15:35:13 +0000 (15:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83720

Reviewed by Noam Rosenthal.

.:

* ManualTests/nested-fixed-position.html: Added.

Source/WebCore:

Before setting the scrollPositionDelta to a fixed layer, check if it has an ancestor which also has fixed position.
If it does, do not set scrollPositionDelta.
Added a flag to TextureMapperLayer and GraphicsLayerTextureMapper indicating if it is a fixed position layer.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
(WebCore::GraphicsLayerTextureMapper::setFixedToViewport):
(WebCore::GraphicsLayerTextureMapper::fixedToViewport):
(GraphicsLayerTextureMapper):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::syncCompositingStateSelf):
(WebCore::TextureMapperLayer::isAncestorFixedToViewport):
(WebCore):
(WebCore::TextureMapperLayer::setScrollPositionDeltaIfNeeded):
* platform/graphics/texmap/TextureMapperLayer.h:
(TextureMapperLayer):
(WebCore::TextureMapperLayer::setFixedToViewport):

Source/WebKit2:

Set the fixedToViewport flag on the fixed position layers and adjust to
the new function name for setting scrollPositionDelta.

* UIProcess/WebLayerTreeRenderer.cpp:
(WebKit::WebLayerTreeRenderer::adjustPositionForFixedLayers):
(WebKit::WebLayerTreeRenderer::setLayerState):

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

ChangeLog
ManualTests/nested-fixed-position.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp

index a69f535..05d69e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-04-12  Yael Aharon  <yael.aharon@nokia.com>
+
+        [Qt][WK2] Nested fixed elements scroll too fast
+        https://bugs.webkit.org/show_bug.cgi?id=83720
+
+        Reviewed by Noam Rosenthal.
+
+        * ManualTests/nested-fixed-position.html: Added.
+
 2012-03-15  Martin Robinson  <mrobinson@igalia.com>
 
         [CAIRO] Make GLContextGLX a subclass of GLContext
diff --git a/ManualTests/nested-fixed-position.html b/ManualTests/nested-fixed-position.html
new file mode 100644 (file)
index 0000000..9bb5200
--- /dev/null
@@ -0,0 +1,93 @@
+<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:0;left:0;z-index:2;width:100%;background-color:darkgray;}
+.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("d2").style.position = "static";
+}
+
+function add_fixed()
+{
+  document.getElementById("d2").style.position = "fixed";
+}
+
+</script>
+</head>
+<body>
+<div class="d2" id="d2">This is the parent div.
+<div class="d1" id="d1"><div class="o">This is the nested div.</div></div>
+</div>
+<div class="t">
+000
+</div>
+<div class="t">
+200
+</div>
+<div class="t">
+400<br>
+<button onclick="remove_fixed();">remove fixed</button>
+</div>
+<div class="t">
+600<br>
+<button onclick="add_fixed();">add fixed</button>
+</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>
index ee03cfc..1db6095 100644 (file)
@@ -1,3 +1,29 @@
+2012-04-12  Yael Aharon  <yael.aharon@nokia.com>
+
+        [Qt][WK2] Nested fixed elements scroll too fast
+        https://bugs.webkit.org/show_bug.cgi?id=83720
+
+        Reviewed by Noam Rosenthal.
+
+        Before setting the scrollPositionDelta to a fixed layer, check if it has an ancestor which also has fixed position.
+        If it does, do not set scrollPositionDelta.
+        Added a flag to TextureMapperLayer and GraphicsLayerTextureMapper indicating if it is a fixed position layer.
+
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
+        (WebCore::GraphicsLayerTextureMapper::setFixedToViewport):
+        (WebCore::GraphicsLayerTextureMapper::fixedToViewport):
+        (GraphicsLayerTextureMapper):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::syncCompositingStateSelf):
+        (WebCore::TextureMapperLayer::isAncestorFixedToViewport):
+        (WebCore):
+        (WebCore::TextureMapperLayer::setScrollPositionDeltaIfNeeded):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (TextureMapperLayer):
+        (WebCore::TextureMapperLayer::setFixedToViewport):
+
 2012-04-12  Charles Wei  <charles.wei@torchmobile.com.cn>
 
         [BlackBerry] Revert the patch for 82764
index 8998973..b5d03a1 100644 (file)
@@ -29,6 +29,7 @@ GraphicsLayerTextureMapper::GraphicsLayerTextureMapper(GraphicsLayerClient* clie
     , m_layer(adoptPtr(new TextureMapperLayer()))
     , m_changeMask(0)
     , m_needsDisplay(false)
+    , m_fixedToViewport(false)
     , m_contentsLayer(0)
     , m_animationStartedTimer(this, &GraphicsLayerTextureMapper::animationStartedTimerFired)
 {
index bdcd930..c82e943 100644 (file)
@@ -94,6 +94,9 @@ public:
     virtual bool setFilters(const FilterOperations&);
 #endif
 
+    void setFixedToViewport(bool fixed) { m_fixedToViewport = fixed; }
+    bool fixedToViewport() const { return m_fixedToViewport; }
+
 private:
     virtual void willBeDestroyed();
 
@@ -103,6 +106,7 @@ private:
     bool m_syncQueued;
     int m_changeMask;
     bool m_needsDisplay;
+    bool m_fixedToViewport;
     TextureMapperPlatformLayer* m_contentsLayer;
     FloatRect m_needsDisplayRect;
     TextureMapperAnimations m_animations;
index 5775cdb..9ac33dd 100644 (file)
@@ -427,6 +427,7 @@ void TextureMapperLayer::syncCompositingStateSelf(GraphicsLayerTextureMapper* gr
 #if ENABLE(CSS_FILTERS)
     m_state.filters = graphicsLayer->filters();
 #endif
+    m_fixedToViewport = graphicsLayer->fixedToViewport();
 
     m_state.needsDisplay = m_state.needsDisplay || graphicsLayer->needsDisplay();
     if (!m_state.needsDisplay)
@@ -511,12 +512,26 @@ void TextureMapperLayer::syncCompositingState(GraphicsLayerTextureMapper* graphi
     }
 }
 
-void TextureMapperLayer::setScrollPositionDelta(const IntPoint& delta)
+bool TextureMapperLayer::isAncestorFixedToViewport() const
+{
+    for (TextureMapperLayer* parent = m_parent; parent; parent = parent->m_parent) {
+        if (parent->m_fixedToViewport)
+            return true;
+    }
+
+    return false;
+}
+
+void TextureMapperLayer::setScrollPositionDeltaIfNeeded(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;
+    // sure that they do not move while scrolling. We need to reset this delta to fixed layers
+    // that have an ancestor which is also a fixed layer, because the delta will be added to the ancestor.
+    if (isAncestorFixedToViewport())
+        m_scrollPositionDelta = IntPoint();
+    else
+        m_scrollPositionDelta = delta;
     m_transform.setPosition(m_state.pos + m_scrollPositionDelta);
 }
 
index ed3b1af..f800b6f 100644 (file)
@@ -126,7 +126,8 @@ public:
     PassRefPtr<TextureMapperBackingStore> backingStore() { return m_backingStore; }
     void clearBackingStoresRecursive();
 
-    void setScrollPositionDelta(const IntPoint&);
+    void setScrollPositionDeltaIfNeeded(const IntPoint&);
+    void setFixedToViewport(bool fixed) { m_fixedToViewport = fixed; }
 
 private:
     TextureMapperLayer* rootLayer();
@@ -145,6 +146,7 @@ private:
     static void sortByZOrder(Vector<TextureMapperLayer* >& array, int first, int last);
 
     PassRefPtr<BitmapTexture> texture() { return m_backingStore ? m_backingStore->texture() : 0; }
+    bool isAncestorFixedToViewport() const;
 
     void paintRecursive(const TextureMapperPaintOptions&);
     void paintSelf(const TextureMapperPaintOptions&);
@@ -220,6 +222,7 @@ private:
     TextureMapper* m_textureMapper;
     TextureMapperAnimations m_animations;
     IntPoint m_scrollPositionDelta;
+    bool m_fixedToViewport;
 };
 
 
index 530ef9a..758c952 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-12  Yael Aharon  <yael.aharon@nokia.com>
+
+        [Qt][WK2] Nested fixed elements scroll too fast
+        https://bugs.webkit.org/show_bug.cgi?id=83720
+
+        Reviewed by Noam Rosenthal.
+
+        Set the fixedToViewport flag on the fixed position layers and adjust to
+        the new function name for setting scrollPositionDelta.
+
+        * UIProcess/WebLayerTreeRenderer.cpp:
+        (WebKit::WebLayerTreeRenderer::adjustPositionForFixedLayers):
+        (WebKit::WebLayerTreeRenderer::setLayerState):
+
 2012-04-12  Kenneth Rohde Christiansen  <kenneth@webkit.org>
 
         Move viewport meta handling to the web process side
index 85a2ae2..98538d6 100644 (file)
@@ -179,7 +179,7 @@ void WebLayerTreeRenderer::adjustPositionForFixedLayers()
 
     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()));
+        toTextureMapperLayer(it->second)->setScrollPositionDeltaIfNeeded(IntPoint(scrollPosition.x() - m_renderedContentsScrollPosition.x(), scrollPosition.y() - m_renderedContentsScrollPosition.y()));
 }
 
 void WebLayerTreeRenderer::didChangeScrollPosition(const IntPoint& position)
@@ -226,6 +226,7 @@ void WebLayerTreeRenderer::setLayerState(WebLayerID id, const WebLayerInfo& laye
     layer->setContentsOpaque(layerInfo.contentsOpaque);
     layer->setContentsRect(layerInfo.contentsRect);
     layer->setDrawsContent(layerInfo.drawsContent);
+    toGraphicsLayerTextureMapper(layer)->setFixedToViewport(layerInfo.fixedToViewport);
 
     if (layerInfo.fixedToViewport)
         m_fixedLayers.add(id, layer);