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

Side by Side Diff: Source/core/frame/VisualViewport.cpp

Issue 1305223004: Reland of place pinch scrollbars with regular scrollbars. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/loader/FrameLoaderClient.h" 42 #include "core/loader/FrameLoaderClient.h"
43 #include "core/page/ChromeClient.h" 43 #include "core/page/ChromeClient.h"
44 #include "core/page/Page.h" 44 #include "core/page/Page.h"
45 #include "core/page/scrolling/ScrollingCoordinator.h" 45 #include "core/page/scrolling/ScrollingCoordinator.h"
46 #include "platform/TraceEvent.h" 46 #include "platform/TraceEvent.h"
47 #include "platform/geometry/DoubleRect.h" 47 #include "platform/geometry/DoubleRect.h"
48 #include "platform/geometry/FloatSize.h" 48 #include "platform/geometry/FloatSize.h"
49 #include "platform/graphics/GraphicsLayer.h" 49 #include "platform/graphics/GraphicsLayer.h"
50 #include "platform/graphics/GraphicsLayerFactory.h" 50 #include "platform/graphics/GraphicsLayerFactory.h"
51 #include "platform/scroll/Scrollbar.h" 51 #include "platform/scroll/Scrollbar.h"
52 #include "platform/scroll/ScrollbarTheme.h" 52 #include "platform/scroll/ScrollbarThemeOverlay.h"
53 #include "public/platform/Platform.h" 53 #include "public/platform/Platform.h"
54 #include "public/platform/WebCompositorSupport.h" 54 #include "public/platform/WebCompositorSupport.h"
55 #include "public/platform/WebLayer.h" 55 #include "public/platform/WebLayer.h"
56 #include "public/platform/WebLayerTreeView.h" 56 #include "public/platform/WebLayerTreeView.h"
57 #include "public/platform/WebScrollbar.h" 57 #include "public/platform/WebScrollbar.h"
58 #include "public/platform/WebScrollbarLayer.h" 58 #include "public/platform/WebScrollbarLayer.h"
59 59
60 using blink::WebLayer; 60 using blink::WebLayer;
61 using blink::WebLayerTreeView; 61 using blink::WebLayerTreeView;
62 using blink::WebScrollbar; 62 using blink::WebScrollbar;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 && mainFrame()->settings() 99 && mainFrame()->settings()
100 && mainFrame()->settings()->textAutosizingEnabled(); 100 && mainFrame()->settings()->textAutosizingEnabled();
101 101
102 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height()); 102 TRACE_EVENT2("blink", "VisualViewport::setSize", "width", size.width(), "hei ght", size.height());
103 m_size = size; 103 m_size = size;
104 104
105 if (m_innerViewportContainerLayer) { 105 if (m_innerViewportContainerLayer) {
106 m_innerViewportContainerLayer->setSize(m_size); 106 m_innerViewportContainerLayer->setSize(m_size);
107 107
108 // Need to re-compute sizes for the overlay scrollbars. 108 // Need to re-compute sizes for the overlay scrollbars.
109 setupScrollbar(WebScrollbar::Horizontal); 109 initializeScrollbars();
110 setupScrollbar(WebScrollbar::Vertical);
111 } 110 }
112 111
113 if (autosizerNeedsUpdating) { 112 if (autosizerNeedsUpdating) {
114 // This needs to happen after setting the m_size member since it'll be r ead in the update call. 113 // This needs to happen after setting the m_size member since it'll be r ead in the update call.
115 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize r()) 114 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize r())
116 textAutosizer->updatePageInfoInAllFrames(); 115 textAutosizer->updatePageInfoInAllFrames();
117 } 116 }
118 } 117 }
119 118
120 void VisualViewport::reset() 119 void VisualViewport::reset()
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // 265 //
267 // *rootTransformLayer 266 // *rootTransformLayer
268 // +- *innerViewportContainerLayer (fixed pos container) 267 // +- *innerViewportContainerLayer (fixed pos container)
269 // | +- *overscrollElasticityLayer 268 // | +- *overscrollElasticityLayer
270 // | +- *pageScaleLayer 269 // | +- *pageScaleLayer
271 // | +- *innerViewportScrollLayer 270 // | +- *innerViewportScrollLayer
272 // | +-- overflowControlsHostLayer (root layer) 271 // | +-- overflowControlsHostLayer (root layer)
273 // | +-- outerViewportContainerLayer (fixed pos container) [f rame container layer in DeprecatedPaintLayerCompositor] 272 // | +-- outerViewportContainerLayer (fixed pos container) [f rame container layer in DeprecatedPaintLayerCompositor]
274 // | | +-- outerViewportScrollLayer [frame scroll layer in DeprecatedPaintLayerCompositor] 273 // | | +-- outerViewportScrollLayer [frame scroll layer in DeprecatedPaintLayerCompositor]
275 // | | +-- content layers ... 274 // | | +-- content layers ...
276 // | +-- horizontal ScrollbarLayer (non-overlay) 275 // +- horizontalScrollbarLayer
277 // | +-- verticalScrollbarLayer (non-overlay) 276 // +- verticalScrollbarLayer
278 // | +-- scroll corner (non-overlay) 277 // +- scroll corner (non-overlay only)
279 // +- *horizontalScrollbarLayer (overlay)
280 // +- *verticalScrollbarLayer (overlay)
281 // 278 //
282 void VisualViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, Grap hicsLayerFactory* graphicsLayerFactory) 279 void VisualViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, Grap hicsLayerFactory* graphicsLayerFactory)
283 { 280 {
284 TRACE_EVENT1("blink", "VisualViewport::attachToLayerTree", "currentLayerTree Root", (bool)currentLayerTreeRoot); 281 TRACE_EVENT1("blink", "VisualViewport::attachToLayerTree", "currentLayerTree Root", (bool)currentLayerTreeRoot);
285 if (!currentLayerTreeRoot) { 282 if (!currentLayerTreeRoot) {
286 if (m_innerViewportScrollLayer) 283 if (m_innerViewportScrollLayer)
287 m_innerViewportScrollLayer->removeAllChildren(); 284 m_innerViewportScrollLayer->removeAllChildren();
288 return; 285 return;
289 } 286 }
290 287
(...skipping 26 matching lines...) Expand all
317 m_innerViewportContainerLayer->setSize(m_size); 314 m_innerViewportContainerLayer->setSize(m_size);
318 315
319 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( 316 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer(
320 m_innerViewportContainerLayer->platformLayer()); 317 m_innerViewportContainerLayer->platformLayer());
321 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru e); 318 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru e);
322 319
323 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get()); 320 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get());
324 m_innerViewportContainerLayer->addChild(m_overscrollElasticityLayer.get( )); 321 m_innerViewportContainerLayer->addChild(m_overscrollElasticityLayer.get( ));
325 m_overscrollElasticityLayer->addChild(m_pageScaleLayer.get()); 322 m_overscrollElasticityLayer->addChild(m_pageScaleLayer.get());
326 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); 323 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get());
327 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get ());
328 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get() );
329 324
330 // Ensure this class is set as the scroll layer's ScrollableArea. 325 // Ensure this class is set as the scroll layer's ScrollableArea.
331 coordinator->scrollableAreaScrollLayerDidChange(this); 326 coordinator->scrollableAreaScrollLayerDidChange(this);
332 327
333 // Setup the inner viewport overlay scrollbars. 328 initializeScrollbars();
334 setupScrollbar(WebScrollbar::Horizontal);
335 setupScrollbar(WebScrollbar::Vertical);
336 } 329 }
337 330
338 m_innerViewportScrollLayer->removeAllChildren(); 331 m_innerViewportScrollLayer->removeAllChildren();
339 m_innerViewportScrollLayer->addChild(currentLayerTreeRoot); 332 m_innerViewportScrollLayer->addChild(currentLayerTreeRoot);
340 } 333 }
341 334
335 void VisualViewport::initializeScrollbars()
336 {
337 if (visualViewportSuppliesScrollbars()) {
338 if (!m_overlayScrollbarHorizontal->parent())
339 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal .get());
340 if (!m_overlayScrollbarVertical->parent())
341 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.g et());
342 } else {
343 m_overlayScrollbarHorizontal->removeFromParent();
344 m_overlayScrollbarVertical->removeFromParent();
345 }
346
347 setupScrollbar(WebScrollbar::Horizontal);
348 setupScrollbar(WebScrollbar::Vertical);
349 }
350
342 void VisualViewport::setupScrollbar(WebScrollbar::Orientation orientation) 351 void VisualViewport::setupScrollbar(WebScrollbar::Orientation orientation)
343 { 352 {
344 bool isHorizontal = orientation == WebScrollbar::Horizontal; 353 bool isHorizontal = orientation == WebScrollbar::Horizontal;
345 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? 354 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ?
346 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); 355 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get();
347 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? 356 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ?
348 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; 357 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical;
349 358
350 int thumbThickness = frameHost().settings().pinchOverlayScrollbarThickness() ; 359 ScrollbarTheme* theme = ScrollbarThemeOverlay::mobileTheme();
351 int scrollbarThickness = thumbThickness; 360 int thumbThickness = theme->thumbThickness(0);
352 int scrollbarMargin = scrollbarThickness; 361 int scrollbarThickness = theme->scrollbarThickness(RegularScrollbar);
353 362 int scrollbarMargin = theme->scrollbarMargin();
354 // FIXME: Rather than manually creating scrollbar layers, we should create
355 // real scrollbars so we can reuse all the machinery from ScrollbarTheme.
356 #if OS(ANDROID)
357 thumbThickness = ScrollbarTheme::theme()->thumbThickness(0);
358 scrollbarThickness = ScrollbarTheme::theme()->scrollbarThickness(RegularScro llbar);
359 scrollbarMargin = ScrollbarTheme::theme()->scrollbarMargin();
360 #endif
361 363
362 if (!webScrollbarLayer) { 364 if (!webScrollbarLayer) {
363 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina tor(); 365 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina tor();
364 ASSERT(coordinator); 366 ASSERT(coordinator);
365 ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrol lbar : VerticalScrollbar; 367 ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrol lbar : VerticalScrollbar;
366 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO rientation, thumbThickness, scrollbarMargin, false); 368 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO rientation, thumbThickness, scrollbarMargin, false);
367 369
368 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL ayer()); 370 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL ayer());
369 371
370 // The compositor will control the scrollbar's visibility. Set to invisi ble by defualt 372 // The compositor will control the scrollbar's visibility. Set to invisi ble by defualt
371 // so scrollbars don't show up in layout tests. 373 // so scrollbars don't show up in layout tests.
372 webScrollbarLayer->layer()->setOpacity(0); 374 webScrollbarLayer->layer()->setOpacity(0);
373
374 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la yer()); 375 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la yer());
375 scrollbarGraphicsLayer->setDrawsContent(false); 376 scrollbarGraphicsLayer->setDrawsContent(false);
376 } 377 }
377 378
378 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid th() - scrollbarThickness; 379 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid th() - scrollbarThickness;
379 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height( ) - scrollbarThickness : 0; 380 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height( ) - scrollbarThickness : 0;
380 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s crollbarThickness : scrollbarThickness; 381 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s crollbarThickness : scrollbarThickness;
381 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay er->size().height() - scrollbarThickness; 382 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay er->size().height() - scrollbarThickness;
382 383
383 // Use the GraphicsLayer to position the scrollbars. 384 // Use the GraphicsLayer to position the scrollbars.
(...skipping 18 matching lines...) Expand all
402 403
403 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer); 404 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer);
404 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer); 405 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer);
405 406
406 ASSERT(compositor); 407 ASSERT(compositor);
407 layerTreeView->registerViewportLayers( 408 layerTreeView->registerViewportLayers(
408 m_overscrollElasticityLayer->platformLayer(), 409 m_overscrollElasticityLayer->platformLayer(),
409 m_pageScaleLayer->platformLayer(), 410 m_pageScaleLayer->platformLayer(),
410 m_innerViewportScrollLayer->platformLayer(), 411 m_innerViewportScrollLayer->platformLayer(),
411 scrollLayer); 412 scrollLayer);
413
414 // TODO(aelias): Remove this call after this setting is deleted.
415 layerTreeView->setHidePinchScrollbarsNearMinScale(false);
416 }
417
418 bool VisualViewport::visualViewportSuppliesScrollbars() const
419 {
420 return frameHost().settings().viewportMetaEnabled();
412 } 421 }
413 422
414 void VisualViewport::clearLayersForTreeView(WebLayerTreeView* layerTreeView) con st 423 void VisualViewport::clearLayersForTreeView(WebLayerTreeView* layerTreeView) con st
415 { 424 {
416 ASSERT(layerTreeView); 425 ASSERT(layerTreeView);
417 426
418 layerTreeView->clearViewportLayers(); 427 layerTreeView->clearViewportLayers();
419 } 428 }
420 429
421 DoubleRect VisualViewport::visibleContentRectDouble(IncludeScrollbarsInRect) con st 430 DoubleRect VisualViewport::visibleContentRectDouble(IncludeScrollbarsInRect) con st
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 } else if (graphicsLayer == m_rootTransformLayer) { 667 } else if (graphicsLayer == m_rootTransformLayer) {
659 name = "Root Transform Layer"; 668 name = "Root Transform Layer";
660 } else { 669 } else {
661 ASSERT_NOT_REACHED(); 670 ASSERT_NOT_REACHED();
662 } 671 }
663 672
664 return name; 673 return name;
665 } 674 }
666 675
667 } // namespace blink 676 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/VisualViewport.h ('k') | Source/core/layout/compositing/CompositedDeprecatedPaintLayerMapping.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698