Changeset 113791 in webkit
- Timestamp:
- Apr 10, 2012 4:40:51 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r113786 r113791 1 2012-04-10 Yael Aharon <yael.aharon@nokia.com> 2 3 Initial support for fixed position elements in Qt WebKit2 4 https://bugs.webkit.org/show_bug.cgi?id=81786 5 6 Reviewed by Noam Rosenthal. 7 8 * ManualTests/fixed-position.html: Added. 9 1 10 2012-04-10 Raphael Kubo da Costa <rakuco@webkit.org> 2 11 -
trunk/Source/WebCore/ChangeLog
r113783 r113791 1 2012-04-10 Yael Aharon <yael.aharon@nokia.com> 2 3 Initial support for fixed position elements in Qt WebKit2 4 https://bugs.webkit.org/show_bug.cgi?id=81786 5 6 Reviewed by Noam Rosenthal. 7 8 When the setting acceleratedCompositingForFixedPositionEnabled is true, we update 9 the position of fixed layers, and send updates to the UI process as we scroll. 10 Before painting, TextureMapperLayer receives a delta of the scroll positions between the UI 11 and the web processes, and adjusts its transform position accordingly. 12 13 * page/FrameView.cpp: 14 (WebCore::FrameView::setFixedVisibleContentRect): 15 * platform/graphics/texmap/TextureMapperLayer.cpp: 16 (WebCore::TextureMapperLayer::setScrollPositionDelta): 17 (WebCore): 18 * platform/graphics/texmap/TextureMapperLayer.h: 19 (TextureMapperLayer): 20 1 21 2012-04-10 Peter Rybin <peter.rybin@gmail.com> 2 22 -
trunk/Source/WebCore/page/FrameView.cpp
r113287 r113791 1703 1703 IntSize offset = scrollOffset(); 1704 1704 ScrollView::setFixedVisibleContentRect(visibleContentRect); 1705 if (offset != scrollOffset()) 1705 if (offset != scrollOffset()) { 1706 if (m_frame->page()->settings()->acceleratedCompositingForFixedPositionEnabled()) 1707 updateFixedElementsAfterScrolling(); 1706 1708 scrollPositionChanged(); 1709 } 1707 1710 frame()->loader()->client()->didChangeScrollOffset(); 1708 1711 } -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
r113678 r113791 512 512 } 513 513 514 } 515 #endif 514 void TextureMapperLayer::setScrollPositionDelta(const IntPoint& delta) 515 { 516 // delta is the difference between the scroll offset in the ui process and the scroll offset 517 // in the web process. We add this delta to the position of fixed layers, to make 518 // sure that they do not move while scrolling. 519 m_scrollPositionDelta = delta; 520 m_transform.setPosition(m_state.pos + m_scrollPositionDelta); 521 } 522 523 } 524 #endif -
trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
r107814 r113791 126 126 PassRefPtr<TextureMapperBackingStore> backingStore() { return m_backingStore; } 127 127 void clearBackingStoresRecursive(); 128 129 void setScrollPositionDelta(const IntPoint&); 128 130 129 131 private: … … 218 220 TextureMapper* m_textureMapper; 219 221 TextureMapperAnimations m_animations; 222 IntPoint m_scrollPositionDelta; 220 223 }; 221 224 -
trunk/Source/WebKit2/ChangeLog
r113777 r113791 1 2012-04-10 Yael Aharon <yael.aharon@nokia.com> 2 3 Initial support for fixed position elements in Qt WebKit2 4 https://bugs.webkit.org/show_bug.cgi?id=81786 5 6 Reviewed by Noam Rosenthal. 7 8 Turn on the flag acceleratedCompositingForFixedPositionEnabled when using fixed layout. 9 As we scroll, we keep track of the delta in scroll position between the UI and web processes, 10 and adjust the position of all the fixed layers by that delta. 11 When WebLayerTreeRenderer receives a new scroll position from the web process, it keeps it as pending, 12 and commit the new scroll position in flushLayerChanges. 13 This patch does not address scrolling overshoot and it does not fix the wrong positioning 14 that occurs when we zoom. These issues will be addressed in future patches. 15 16 * Shared/WebLayerTreeInfo.h: 17 * UIProcess/API/qt/qquickwebpage.cpp: 18 (QQuickWebPagePrivate::updateSize): 19 * UIProcess/LayerTreeHostProxy.cpp: 20 (WebKit::LayerTreeHostProxy::setContentsSize): 21 (WebKit): 22 (WebKit::LayerTreeHostProxy::renderNextFrame): 23 (WebKit::LayerTreeHostProxy::didChangeScrollPosition): 24 * UIProcess/LayerTreeHostProxy.h: 25 (LayerTreeHostProxy): 26 * UIProcess/LayerTreeHostProxy.messages.in: 27 * UIProcess/WebLayerTreeRenderer.cpp: 28 (WebKit::boundedScrollPosition): 29 (WebKit): 30 (WebKit::WebLayerTreeRenderer::paintToCurrentGLContext): 31 (WebKit::WebLayerTreeRenderer::setContentsSize): 32 (WebKit::WebLayerTreeRenderer::adjustPositionForFixedLayers): 33 (WebKit::WebLayerTreeRenderer::didChangeScrollPosition): 34 (WebKit::WebLayerTreeRenderer::syncLayerParameters): 35 (WebKit::WebLayerTreeRenderer::deleteLayer): 36 (WebKit::WebLayerTreeRenderer::flushLayerChanges): 37 * UIProcess/WebLayerTreeRenderer.h: 38 (WebLayerTreeRenderer): 39 * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp: 40 (WebCore::WebGraphicsLayer::WebGraphicsLayer): 41 (WebCore::WebGraphicsLayer::syncCompositingState): 42 (WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly): 43 * WebProcess/WebCoreSupport/WebGraphicsLayer.h: 44 (WebGraphicsLayerClient): 45 (WebCore::WebGraphicsLayer::fixedToViewport): 46 (WebCore::WebGraphicsLayer::setFixedToViewport): 47 (WebGraphicsLayer): 48 * WebProcess/WebPage/WebPage.cpp: 49 (WebKit::WebPage::setResizesToContentsUsingLayoutSize): 50 * WebProcess/WebPage/qt/LayerTreeHostQt.cpp: 51 (WebKit::LayerTreeHostQt::LayerTreeHostQt): 52 (WebKit::LayerTreeHostQt::didSyncCompositingStateForLayer): 53 (WebKit::updateOffsetFromViewportForSelf): 54 (WebKit): 55 (WebKit::updateOffsetFromViewportForLayer): 56 (WebKit::LayerTreeHostQt::syncFixedLayers): 57 (WebKit::LayerTreeHostQt::setVisibleContentsRect): 58 * WebProcess/WebPage/qt/LayerTreeHostQt.h: 59 (LayerTreeHostQt): 60 1 61 2012-04-10 Anders Carlsson <andersca@apple.com> 2 62 -
trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h
r113640 r113791 66 66 bool preserves3D : 1; 67 67 bool isRootLayer: 1; 68 bool fixedToViewport : 1; 68 69 }; 69 70 unsigned int flags; -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
r113172 r113791 140 140 q->setSize(scaledSize); 141 141 viewportItem->updateContentsSize(scaledSize); 142 DrawingAreaProxy* drawingArea = webPageProxy->drawingArea(); 143 if (drawingArea && drawingArea->layerTreeHostProxy()) 144 drawingArea->layerTreeHostProxy()->setContentsSize(WebCore::FloatSize(contentsSize.width(), contentsSize.height())); 142 145 } 143 146 -
trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.cpp
r113773 r113791 123 123 } 124 124 125 void LayerTreeHostProxy::setContentsSize(const FloatSize& contentsSize) 126 { 127 m_renderer->setContentsSize(contentsSize); 128 } 129 125 130 void LayerTreeHostProxy::setVisibleContentsRect(const IntRect& rect, float scale, const FloatPoint& trajectoryVector) 126 131 { … … 134 139 } 135 140 141 void LayerTreeHostProxy::didChangeScrollPosition(const IntPoint& position) 142 { 143 dispatchUpdate(bind(&WebLayerTreeRenderer::didChangeScrollPosition, m_renderer.get(), position)); 144 } 145 136 146 void LayerTreeHostProxy::purgeBackingStores() 137 147 { -
trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
r113773 r113791 57 57 void paintToGraphicsContext(BackingStore::PlatformGraphicsContext); 58 58 void purgeGLResources(); 59 void setContentsSize(const WebCore::FloatSize&); 59 60 void setVisibleContentsRect(const WebCore::IntRect&, float scale, const WebCore::FloatPoint& trajectory); 60 61 void didRenderFrame(); … … 67 68 void updateViewport(); 68 69 void renderNextFrame(); 70 void didChangeScrollPosition(const WebCore::IntPoint& position); 69 71 void purgeBackingStores(); 70 72 WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); } -
trunk/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in
r113773 r113791 30 30 DestroyDirectlyCompositedImage(int64_t key) 31 31 DidRenderFrame() 32 DidChangeScrollPosition(WebCore::IntPoint position) 32 33 } 33 34 #endif -
trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.cpp
r113773 r113791 74 74 } 75 75 76 static IntPoint boundedScrollPosition(const IntPoint& scrollPosition, const IntRect& visibleContentRect, const FloatSize& contentSize) 77 { 78 IntSize size(contentSize.width(), contentSize.height()); 79 int scrollPositionX = std::max(scrollPosition.x(), 0); 80 scrollPositionX = std::min(scrollPositionX, size.width() - visibleContentRect.width()); 81 82 int scrollPositionY = std::max(scrollPosition.y(), 0); 83 scrollPositionY = std::min(scrollPositionY, size.height() - visibleContentRect.height()); 84 return IntPoint(scrollPositionX, scrollPositionY); 85 } 86 76 87 WebLayerTreeRenderer::WebLayerTreeRenderer(LayerTreeHostProxy* layerTreeHostProxy) 77 88 : m_layerTreeHostProxy(layerTreeHostProxy) … … 99 110 100 111 syncRemoteContent(); 112 adjustPositionForFixedLayers(); 101 113 GraphicsLayer* currentRootLayer = rootLayer(); 102 114 if (!currentRootLayer) … … 144 156 } 145 157 158 void WebLayerTreeRenderer::setContentsSize(const WebCore::FloatSize& contentsSize) 159 { 160 m_contentsSize = contentsSize; 161 } 162 146 163 void WebLayerTreeRenderer::setVisibleContentsRect(const IntRect& rect, float scale) 147 164 { … … 154 171 if (m_layerTreeHostProxy) 155 172 m_layerTreeHostProxy->updateViewport(); 173 } 174 175 void WebLayerTreeRenderer::adjustPositionForFixedLayers() 176 { 177 if (m_fixedLayers.isEmpty()) 178 return; 179 180 IntPoint scrollPosition = boundedScrollPosition(m_visibleContentsRect.location(), m_visibleContentsRect, m_contentsSize); 181 182 LayerMap::iterator end = m_fixedLayers.end(); 183 for (LayerMap::iterator it = m_fixedLayers.begin(); it != end; ++it) 184 toTextureMapperLayer(it->second)->setScrollPositionDelta(IntPoint(scrollPosition.x() - m_renderedContentsScrollPosition.x(), scrollPosition.y() - m_renderedContentsScrollPosition.y())); 185 } 186 187 void WebLayerTreeRenderer::didChangeScrollPosition(const IntPoint& position) 188 { 189 m_pendingRenderedContentsScrollPosition = boundedScrollPosition(position, m_visibleContentsRect, m_contentsSize); 156 190 } 157 191 … … 196 230 layer->setDrawsContent(layerInfo.drawsContent); 197 231 232 if (layerInfo.fixedToViewport) 233 m_fixedLayers.add(id, layer); 234 else 235 m_fixedLayers.remove(id); 236 198 237 assignImageToLayer(layer, layerInfo.imageBackingStoreID); 199 238 … … 214 253 layer->removeFromParent(); 215 254 m_layers.remove(layerID); 255 m_fixedLayers.remove(layerID); 216 256 delete layer; 217 257 } … … 311 351 void WebLayerTreeRenderer::flushLayerChanges() 312 352 { 353 m_renderedContentsScrollPosition = m_pendingRenderedContentsScrollPosition; 354 313 355 m_rootLayer->syncCompositingState(FloatRect()); 314 356 commitTileOperations(); -
trunk/Source/WebKit2/UIProcess/WebLayerTreeRenderer.h
r113773 r113791 65 65 void paintToGraphicsContext(BackingStore::PlatformGraphicsContext); 66 66 void syncRemoteContent(); 67 void setContentsSize(const WebCore::FloatSize&); 67 68 void setVisibleContentsRect(const WebCore::IntRect&, float scale); 69 void didChangeScrollPosition(const WebCore::IntPoint& position); 68 70 69 71 void detach(); … … 95 97 void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) { } 96 98 void callOnMainTread(const Function<void()>&); 99 void adjustPositionForFixedLayers(); 97 100 98 101 typedef HashMap<WebLayerID, WebCore::GraphicsLayer*> LayerMap; 102 WebCore::FloatSize m_contentsSize; 99 103 WebCore::IntRect m_visibleContentsRect; 100 104 float m_contentsScale; … … 125 129 126 130 LayerMap m_layers; 131 LayerMap m_fixedLayers; 127 132 WebLayerID m_rootLayerID; 133 WebCore::IntPoint m_renderedContentsScrollPosition; 134 WebCore::IntPoint m_pendingRenderedContentsScrollPosition; 128 135 }; 129 136 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
r113773 r113791 97 97 , m_maskTarget(0) 98 98 , m_inUpdateMode(false) 99 , m_fixedToViewport(false) 99 100 , m_shouldUpdateVisibleRect(true) 100 101 , m_shouldSyncLayerState(true) … … 388 389 replica->syncCompositingStateForThisLayerOnly(); 389 390 391 m_webGraphicsLayerClient->syncFixedLayers(); 392 390 393 syncCompositingStateForThisLayerOnly(); 391 394 … … 416 419 return; 417 420 m_shouldSyncLayerState = false; 421 m_layerInfo.fixedToViewport = fixedToViewport(); 418 422 419 423 m_layerInfo.anchorPoint = anchorPoint(); -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
r113773 r113791 60 60 virtual void attachLayer(WebCore::WebGraphicsLayer*) = 0; 61 61 virtual void detachLayer(WebCore::WebGraphicsLayer*) = 0; 62 virtual void syncFixedLayers() = 0; 62 63 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&) = 0; 63 64 }; … … 112 113 Image* image() { return m_image.get(); } 113 114 115 bool fixedToViewport() const { return m_fixedToViewport; } 116 void setFixedToViewport(bool isFixed) { m_fixedToViewport = isFixed; } 117 114 118 GraphicsLayer* maskTarget() const { return m_maskTarget; } 115 119 void setMaskTarget(GraphicsLayer* layer) { m_maskTarget = layer; } … … 154 158 bool m_shouldSyncLayerState: 1; 155 159 bool m_shouldSyncChildren: 1; 160 bool m_fixedToViewport : 1; 156 161 157 162 void notifyChange(); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r113486 r113791 836 836 view->setFixedLayoutSize(targetLayoutSize); 837 837 838 m_page->settings()->setAcceleratedCompositingForFixedPositionEnabled(true); 839 838 840 // Schedule a layout to use the new target size. 839 841 if (!view->layoutPending()) { -
trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
r113773 r113791 40 40 #include <WebCore/FrameView.h> 41 41 #include <WebCore/Page.h> 42 #include <WebCore/RenderLayer.h> 43 #include <WebCore/RenderLayerBacking.h> 44 #include <WebCore/RenderLayerCompositor.h> 45 #include <WebCore/RenderView.h> 42 46 #include <WebCore/Settings.h> 43 47 … … 69 73 , m_isSuspended(false) 70 74 , m_contentsScale(1) 75 , m_shouldSendScrollPositionUpdate(true) 71 76 , m_shouldSyncFrame(false) 72 77 , m_shouldSyncRootLayer(true) … … 231 236 void LayerTreeHostQt::syncLayerState(WebLayerID id, const WebLayerInfo& info) 232 237 { 238 if (m_shouldSendScrollPositionUpdate) { 239 m_webPage->send(Messages::LayerTreeHostProxy::DidChangeScrollPosition(m_visibleContentsRect.location())); 240 m_shouldSendScrollPositionUpdate = false; 241 } 233 242 m_shouldSyncFrame = true; 234 243 m_webPage->send(Messages::LayerTreeHostProxy::SetCompositingLayerState(id, info)); … … 255 264 m_shouldSyncFrame = true; 256 265 m_webPage->send(Messages::LayerTreeHostProxy::DeleteCompositingLayer(layer->id())); 266 } 267 268 static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer) 269 { 270 // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition. 271 RenderLayerBacking* backing = renderLayer->backing(); 272 if (!backing) 273 return; 274 275 RenderStyle* style = renderLayer->renderer()->style(); 276 if (!style) 277 return; 278 279 if (!renderLayer->renderer()->isPositioned() || renderLayer->renderer()->style()->position() != FixedPosition) 280 return; 281 282 if (!renderLayer->renderer()->container()->isRenderView()) 283 return; 284 285 if (!renderLayer->isStackingContext()) 286 return; 287 288 WebGraphicsLayer* graphicsLayer = toWebGraphicsLayer(backing->graphicsLayer()); 289 graphicsLayer->setFixedToViewport(true); 290 } 291 292 static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer) 293 { 294 updateOffsetFromViewportForSelf(renderLayer); 295 296 if (renderLayer->firstChild()) 297 updateOffsetFromViewportForLayer(renderLayer->firstChild()); 298 if (renderLayer->nextSibling()) 299 updateOffsetFromViewportForLayer(renderLayer->nextSibling()); 300 } 301 302 void LayerTreeHostQt::syncFixedLayers() 303 { 304 if (!m_webPage->corePage()->settings() || !m_webPage->corePage()->settings()->acceleratedCompositingForFixedPositionEnabled()) 305 return; 306 307 if (!m_webPage->mainFrame()->view()->hasFixedObjects()) 308 return; 309 310 RenderLayer* rootRenderLayer = m_webPage->mainFrame()->contentRenderer()->compositor()->rootRenderLayer(); 311 ASSERT(rootRenderLayer); 312 if (rootRenderLayer->firstChild()) 313 updateOffsetFromViewportForLayer(rootRenderLayer->firstChild()); 257 314 } 258 315 … … 448 505 if (m_webPage->useFixedLayout()) 449 506 m_webPage->setFixedVisibleContentRect(rect); 507 if (contentsRectDidChange) 508 m_shouldSendScrollPositionUpdate = true; 450 509 } 451 510 -
trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
r113773 r113791 77 77 virtual void attachLayer(WebCore::WebGraphicsLayer*); 78 78 virtual void detachLayer(WebCore::WebGraphicsLayer*); 79 virtual void syncFixedLayers(); 79 80 80 81 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&); … … 120 121 WebCore::IntRect m_visibleContentsRect; 121 122 float m_contentsScale; 123 bool m_shouldSendScrollPositionUpdate; 122 124 123 125 LayerTreeContext m_layerTreeContext;
Note: See TracChangeset
for help on using the changeset viewer.