Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 138453004: Pinch/Zoom Infrastructure & Plumbing CL (Prequel) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use setContentsRect() instead of directly accessing contentLayer bounds. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 { 73 {
74 return layer->platformLayer(); 74 return layer->platformLayer();
75 } 75 }
76 76
77 WebLayer* ScrollingCoordinator::scrollingWebLayerForScrollableArea(ScrollableAre a* scrollableArea) 77 WebLayer* ScrollingCoordinator::scrollingWebLayerForScrollableArea(ScrollableAre a* scrollableArea)
78 { 78 {
79 GraphicsLayer* graphicsLayer = scrollLayerForScrollableArea(scrollableArea); 79 GraphicsLayer* graphicsLayer = scrollLayerForScrollableArea(scrollableArea);
80 return graphicsLayer ? scrollingWebLayerForGraphicsLayer(graphicsLayer) : 0; 80 return graphicsLayer ? scrollingWebLayerForGraphicsLayer(graphicsLayer) : 0;
81 } 81 }
82 82
83 WebLayer* ScrollingCoordinator::containerWebLayerForScrollableArea(ScrollableAre a* scrollableArea)
84 {
85 GraphicsLayer* graphicsLayer = scrollLayerForScrollableArea(scrollableArea);
86 if (!graphicsLayer)
87 return 0;
88 graphicsLayer = graphicsLayer->parent();
89 return graphicsLayer ? graphicsLayer->platformLayer() : 0;
90 }
91
83 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) 92 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
84 { 93 {
85 return adoptRef(new ScrollingCoordinator(page)); 94 return adoptRef(new ScrollingCoordinator(page));
86 } 95 }
87 96
88 ScrollingCoordinator::ScrollingCoordinator(Page* page) 97 ScrollingCoordinator::ScrollingCoordinator(Page* page)
89 : m_page(page) 98 : m_page(page)
90 , m_scrollGestureRegionIsDirty(false) 99 , m_scrollGestureRegionIsDirty(false)
91 , m_touchEventTargetRectsAreDirty(false) 100 , m_touchEventTargetRectsAreDirty(false)
92 , m_wasFrameScrollable(false) 101 , m_wasFrameScrollable(false)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 252 }
244 253
245 static void detachScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer) 254 static void detachScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer)
246 { 255 {
247 ASSERT(scrollbarGraphicsLayer); 256 ASSERT(scrollbarGraphicsLayer);
248 257
249 scrollbarGraphicsLayer->setContentsToPlatformLayer(0); 258 scrollbarGraphicsLayer->setContentsToPlatformLayer(0);
250 scrollbarGraphicsLayer->setDrawsContent(true); 259 scrollbarGraphicsLayer->setDrawsContent(true);
251 } 260 }
252 261
253 static void setupScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer, WebScroll barLayer* scrollbarLayer, WebLayer* scrollLayer) 262 static void setupScrollbarLayer(GraphicsLayer* scrollbarGraphicsLayer, WebScroll barLayer* scrollbarLayer, WebLayer* scrollLayer, WebLayer* containerLayer)
254 { 263 {
255 ASSERT(scrollbarGraphicsLayer); 264 ASSERT(scrollbarGraphicsLayer);
256 ASSERT(scrollbarLayer); 265 ASSERT(scrollbarLayer);
257 266
258 if (!scrollLayer) { 267 if (!scrollLayer) {
259 detachScrollbarLayer(scrollbarGraphicsLayer); 268 detachScrollbarLayer(scrollbarGraphicsLayer);
260 return; 269 return;
261 } 270 }
262 scrollbarLayer->setScrollLayer(scrollLayer); 271 scrollbarLayer->setScrollLayer(scrollLayer);
272 scrollbarLayer->setClipLayer(containerLayer);
263 scrollbarGraphicsLayer->setContentsToPlatformLayer(scrollbarLayer->layer()); 273 scrollbarGraphicsLayer->setContentsToPlatformLayer(scrollbarLayer->layer());
264 scrollbarGraphicsLayer->setDrawsContent(false); 274 scrollbarGraphicsLayer->setDrawsContent(false);
265 } 275 }
266 276
267 WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer(ScrollableArea* sc rollableArea, ScrollbarOrientation orientation, PassOwnPtr<blink::WebScrollbarLa yer> scrollbarLayer) 277 WebScrollbarLayer* ScrollingCoordinator::addWebScrollbarLayer(ScrollableArea* sc rollableArea, ScrollbarOrientation orientation, PassOwnPtr<blink::WebScrollbarLa yer> scrollbarLayer)
268 { 278 {
269 ScrollbarMap& scrollbars = orientation == HorizontalScrollbar ? m_horizontal Scrollbars : m_verticalScrollbars; 279 ScrollbarMap& scrollbars = orientation == HorizontalScrollbar ? m_horizontal Scrollbars : m_verticalScrollbars;
270 return scrollbars.add(scrollableArea, scrollbarLayer).iterator->value.get(); 280 return scrollbars.add(scrollableArea, scrollbarLayer).iterator->value.get();
271 } 281 }
272 282
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w ebScrollbarLayer.release()); 328 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w ebScrollbarLayer.release());
319 } 329 }
320 330
321 // Root layer non-overlay scrollbars should be marked opaque to disable 331 // Root layer non-overlay scrollbars should be marked opaque to disable
322 // blending. 332 // blending.
323 bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar(); 333 bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar();
324 if (!scrollbarGraphicsLayer->contentsOpaque()) 334 if (!scrollbarGraphicsLayer->contentsOpaque())
325 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScr ollbar); 335 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScr ollbar);
326 scrollbarLayer->layer()->setOpaque(scrollbarGraphicsLayer->contentsOpaqu e()); 336 scrollbarLayer->layer()->setOpaque(scrollbarGraphicsLayer->contentsOpaqu e());
327 337
328 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollingWeb LayerForScrollableArea(scrollableArea)); 338 WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(scrollableAre a);
339 WebLayer* containerLayer = containerWebLayerForScrollableArea(scrollable Area);
340 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer, containerLayer);
329 } else 341 } else
330 removeWebScrollbarLayer(scrollableArea, orientation); 342 removeWebScrollbarLayer(scrollableArea, orientation);
331 } 343 }
332 344
333 bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc rollableArea) 345 bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc rollableArea)
334 { 346 {
335 GraphicsLayer* scrollLayer = scrollLayerForScrollableArea(scrollableArea); 347 GraphicsLayer* scrollLayer = scrollLayerForScrollableArea(scrollableArea);
336 if (scrollLayer) { 348 if (scrollLayer) {
337 bool isMainFrame = isForMainFrame(scrollableArea); 349 bool isMainFrame = isForMainFrame(scrollableArea);
338 scrollLayer->setScrollableArea(scrollableArea, isMainFrame); 350 scrollLayer->setScrollableArea(scrollableArea, isMainFrame);
339 } 351 }
340 352
341 WebLayer* webLayer = scrollingWebLayerForScrollableArea(scrollableArea); 353 WebLayer* webLayer = scrollingWebLayerForScrollableArea(scrollableArea);
354 WebLayer* containerLayer = containerWebLayerForScrollableArea(scrollableArea );
342 if (webLayer) { 355 if (webLayer) {
356 // TODO(wjmaclean) Remove the next line once https://codereview.chromium .org/23983047 lands.
343 webLayer->setScrollable(true); 357 webLayer->setScrollable(true);
358 webLayer->setScrollClipLayer(containerLayer);
344 webLayer->setScrollPosition(IntPoint(scrollableArea->scrollPosition() - scrollableArea->minimumScrollPosition())); 359 webLayer->setScrollPosition(IntPoint(scrollableArea->scrollPosition() - scrollableArea->minimumScrollPosition()));
360 // TODO(wjmaclean) Remove the next line once https://codereview.chromium .org/23983047 lands.
345 webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(Horizo ntalScrollbar), scrollableArea->scrollSize(VerticalScrollbar))); 361 webLayer->setMaxScrollPosition(IntSize(scrollableArea->scrollSize(Horizo ntalScrollbar), scrollableArea->scrollSize(VerticalScrollbar)));
362 webLayer->setBounds(scrollableArea->contentsSize());
346 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba r); 363 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba r);
347 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar) ; 364 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar) ;
348 webLayer->setUserScrollable(canScrollX, canScrollY); 365 webLayer->setUserScrollable(canScrollX, canScrollY);
349 } 366 }
350 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) { 367 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, HorizontalScrollbar)) {
351 GraphicsLayer* horizontalScrollbarLayer = horizontalScrollbarLayerForScr ollableArea(scrollableArea); 368 GraphicsLayer* horizontalScrollbarLayer = horizontalScrollbarLayerForScr ollableArea(scrollableArea);
352 if (horizontalScrollbarLayer) 369 if (horizontalScrollbarLayer)
353 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay er); 370 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay er, containerLayer);
354 } 371 }
355 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) { 372 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea, VerticalScrollbar)) {
356 GraphicsLayer* verticalScrollbarLayer = verticalScrollbarLayerForScrolla bleArea(scrollableArea); 373 GraphicsLayer* verticalScrollbarLayer = verticalScrollbarLayerForScrolla bleArea(scrollableArea);
357 if (verticalScrollbarLayer) 374 if (verticalScrollbarLayer)
358 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer ); 375 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer , containerLayer);
359 } 376 }
360 377
361 return !!webLayer; 378 return !!webLayer;
362 } 379 }
363 380
364 // In order to do a DFS cross-frame walk of the RenderLayer tree, we need to kno w which 381 // In order to do a DFS cross-frame walk of the RenderLayer tree, we need to kno w which
365 // RenderLayers have child frames inside of them. This computes a mapping for th e 382 // RenderLayers have child frames inside of them. This computes a mapping for th e
366 // current frame which we can consult while walking the layers of that frame. 383 // current frame which we can consult while walking the layers of that frame.
367 // Whenever we descend into a new frame, a new map will be created. 384 // Whenever we descend into a new frame, a new map will be created.
368 typedef HashMap<const RenderLayer*, Vector<const Frame*> > LayerFrameMap; 385 typedef HashMap<const RenderLayer*, Vector<const Frame*> > LayerFrameMap;
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 940 }
924 941
925 bool ScrollingCoordinator::frameViewIsScrollableIsDirty() const 942 bool ScrollingCoordinator::frameViewIsScrollableIsDirty() const
926 { 943 {
927 FrameView* frameView = m_page->mainFrame()->view(); 944 FrameView* frameView = m_page->mainFrame()->view();
928 bool frameIsScrollable = frameView && frameView->isScrollable(); 945 bool frameIsScrollable = frameView && frameView->isScrollable();
929 return frameIsScrollable != m_wasFrameScrollable; 946 return frameIsScrollable != m_wasFrameScrollable;
930 } 947 }
931 948
932 } // namespace WebCore 949 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/scrolling/ScrollingCoordinator.h ('k') | Source/core/rendering/RenderLayerCompositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698