OLD | NEW |
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 Loading... |
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/ScrollbarThemeOverlay.h" | 52 #include "platform/scroll/ScrollbarTheme.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 Loading... |
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 initializeScrollbars(); | 109 setupScrollbar(WebScrollbar::Horizontal); |
| 110 setupScrollbar(WebScrollbar::Vertical); |
110 } | 111 } |
111 | 112 |
112 if (autosizerNeedsUpdating) { | 113 if (autosizerNeedsUpdating) { |
113 // This needs to happen after setting the m_size member since it'll be r
ead in the update call. | 114 // This needs to happen after setting the m_size member since it'll be r
ead in the update call. |
114 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize
r()) | 115 if (TextAutosizer* textAutosizer = mainFrame()->document()->textAutosize
r()) |
115 textAutosizer->updatePageInfoInAllFrames(); | 116 textAutosizer->updatePageInfoInAllFrames(); |
116 } | 117 } |
117 } | 118 } |
118 | 119 |
119 void VisualViewport::reset() | 120 void VisualViewport::reset() |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // | 266 // |
266 // *rootTransformLayer | 267 // *rootTransformLayer |
267 // +- *innerViewportContainerLayer (fixed pos container) | 268 // +- *innerViewportContainerLayer (fixed pos container) |
268 // | +- *overscrollElasticityLayer | 269 // | +- *overscrollElasticityLayer |
269 // | +- *pageScaleLayer | 270 // | +- *pageScaleLayer |
270 // | +- *innerViewportScrollLayer | 271 // | +- *innerViewportScrollLayer |
271 // | +-- overflowControlsHostLayer (root layer) | 272 // | +-- overflowControlsHostLayer (root layer) |
272 // | +-- outerViewportContainerLayer (fixed pos container) [f
rame container layer in DeprecatedPaintLayerCompositor] | 273 // | +-- outerViewportContainerLayer (fixed pos container) [f
rame container layer in DeprecatedPaintLayerCompositor] |
273 // | | +-- outerViewportScrollLayer [frame scroll layer in
DeprecatedPaintLayerCompositor] | 274 // | | +-- outerViewportScrollLayer [frame scroll layer in
DeprecatedPaintLayerCompositor] |
274 // | | +-- content layers ... | 275 // | | +-- content layers ... |
275 // +- horizontalScrollbarLayer | 276 // | +-- horizontal ScrollbarLayer (non-overlay) |
276 // +- verticalScrollbarLayer | 277 // | +-- verticalScrollbarLayer (non-overlay) |
277 // +- scroll corner (non-overlay only) | 278 // | +-- scroll corner (non-overlay) |
| 279 // +- *horizontalScrollbarLayer (overlay) |
| 280 // +- *verticalScrollbarLayer (overlay) |
278 // | 281 // |
279 void VisualViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, Grap
hicsLayerFactory* graphicsLayerFactory) | 282 void VisualViewport::attachToLayerTree(GraphicsLayer* currentLayerTreeRoot, Grap
hicsLayerFactory* graphicsLayerFactory) |
280 { | 283 { |
281 TRACE_EVENT1("blink", "VisualViewport::attachToLayerTree", "currentLayerTree
Root", (bool)currentLayerTreeRoot); | 284 TRACE_EVENT1("blink", "VisualViewport::attachToLayerTree", "currentLayerTree
Root", (bool)currentLayerTreeRoot); |
282 if (!currentLayerTreeRoot) { | 285 if (!currentLayerTreeRoot) { |
283 if (m_innerViewportScrollLayer) | 286 if (m_innerViewportScrollLayer) |
284 m_innerViewportScrollLayer->removeAllChildren(); | 287 m_innerViewportScrollLayer->removeAllChildren(); |
285 return; | 288 return; |
286 } | 289 } |
287 | 290 |
(...skipping 26 matching lines...) Expand all Loading... |
314 m_innerViewportContainerLayer->setSize(m_size); | 317 m_innerViewportContainerLayer->setSize(m_size); |
315 | 318 |
316 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( | 319 m_innerViewportScrollLayer->platformLayer()->setScrollClipLayer( |
317 m_innerViewportContainerLayer->platformLayer()); | 320 m_innerViewportContainerLayer->platformLayer()); |
318 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru
e); | 321 m_innerViewportScrollLayer->platformLayer()->setUserScrollable(true, tru
e); |
319 | 322 |
320 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get()); | 323 m_rootTransformLayer->addChild(m_innerViewportContainerLayer.get()); |
321 m_innerViewportContainerLayer->addChild(m_overscrollElasticityLayer.get(
)); | 324 m_innerViewportContainerLayer->addChild(m_overscrollElasticityLayer.get(
)); |
322 m_overscrollElasticityLayer->addChild(m_pageScaleLayer.get()); | 325 m_overscrollElasticityLayer->addChild(m_pageScaleLayer.get()); |
323 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); | 326 m_pageScaleLayer->addChild(m_innerViewportScrollLayer.get()); |
| 327 m_innerViewportContainerLayer->addChild(m_overlayScrollbarHorizontal.get
()); |
| 328 m_innerViewportContainerLayer->addChild(m_overlayScrollbarVertical.get()
); |
324 | 329 |
325 // Ensure this class is set as the scroll layer's ScrollableArea. | 330 // Ensure this class is set as the scroll layer's ScrollableArea. |
326 coordinator->scrollableAreaScrollLayerDidChange(this); | 331 coordinator->scrollableAreaScrollLayerDidChange(this); |
327 | 332 |
328 initializeScrollbars(); | 333 // Setup the inner viewport overlay scrollbars. |
| 334 setupScrollbar(WebScrollbar::Horizontal); |
| 335 setupScrollbar(WebScrollbar::Vertical); |
329 } | 336 } |
330 | 337 |
331 m_innerViewportScrollLayer->removeAllChildren(); | 338 m_innerViewportScrollLayer->removeAllChildren(); |
332 m_innerViewportScrollLayer->addChild(currentLayerTreeRoot); | 339 m_innerViewportScrollLayer->addChild(currentLayerTreeRoot); |
333 } | 340 } |
334 | 341 |
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 | |
351 void VisualViewport::setupScrollbar(WebScrollbar::Orientation orientation) | 342 void VisualViewport::setupScrollbar(WebScrollbar::Orientation orientation) |
352 { | 343 { |
353 bool isHorizontal = orientation == WebScrollbar::Horizontal; | 344 bool isHorizontal = orientation == WebScrollbar::Horizontal; |
354 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? | 345 GraphicsLayer* scrollbarGraphicsLayer = isHorizontal ? |
355 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); | 346 m_overlayScrollbarHorizontal.get() : m_overlayScrollbarVertical.get(); |
356 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? | 347 OwnPtr<WebScrollbarLayer>& webScrollbarLayer = isHorizontal ? |
357 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; | 348 m_webOverlayScrollbarHorizontal : m_webOverlayScrollbarVertical; |
358 | 349 |
359 ScrollbarTheme* theme = ScrollbarThemeOverlay::mobileTheme(); | 350 int thumbThickness = frameHost().settings().pinchOverlayScrollbarThickness()
; |
360 int thumbThickness = theme->thumbThickness(0); | 351 int scrollbarThickness = thumbThickness; |
361 int scrollbarThickness = theme->scrollbarThickness(RegularScrollbar); | 352 int scrollbarMargin = scrollbarThickness; |
362 int scrollbarMargin = theme->scrollbarMargin(); | 353 |
| 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 |
363 | 361 |
364 if (!webScrollbarLayer) { | 362 if (!webScrollbarLayer) { |
365 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina
tor(); | 363 ScrollingCoordinator* coordinator = frameHost().page().scrollingCoordina
tor(); |
366 ASSERT(coordinator); | 364 ASSERT(coordinator); |
367 ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrol
lbar : VerticalScrollbar; | 365 ScrollbarOrientation webcoreOrientation = isHorizontal ? HorizontalScrol
lbar : VerticalScrollbar; |
368 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO
rientation, thumbThickness, scrollbarMargin, false); | 366 webScrollbarLayer = coordinator->createSolidColorScrollbarLayer(webcoreO
rientation, thumbThickness, scrollbarMargin, false); |
369 | 367 |
370 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL
ayer()); | 368 webScrollbarLayer->setClipLayer(m_innerViewportContainerLayer->platformL
ayer()); |
371 | 369 |
372 // The compositor will control the scrollbar's visibility. Set to invisi
ble by defualt | 370 // The compositor will control the scrollbar's visibility. Set to invisi
ble by defualt |
373 // so scrollbars don't show up in layout tests. | 371 // so scrollbars don't show up in layout tests. |
374 webScrollbarLayer->layer()->setOpacity(0); | 372 webScrollbarLayer->layer()->setOpacity(0); |
| 373 |
375 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la
yer()); | 374 scrollbarGraphicsLayer->setContentsToPlatformLayer(webScrollbarLayer->la
yer()); |
376 scrollbarGraphicsLayer->setDrawsContent(false); | 375 scrollbarGraphicsLayer->setDrawsContent(false); |
377 } | 376 } |
378 | 377 |
379 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - scrollbarThickness; | 378 int xPosition = isHorizontal ? 0 : m_innerViewportContainerLayer->size().wid
th() - scrollbarThickness; |
380 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - scrollbarThickness : 0; | 379 int yPosition = isHorizontal ? m_innerViewportContainerLayer->size().height(
) - scrollbarThickness : 0; |
381 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s
crollbarThickness : scrollbarThickness; | 380 int width = isHorizontal ? m_innerViewportContainerLayer->size().width() - s
crollbarThickness : scrollbarThickness; |
382 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay
er->size().height() - scrollbarThickness; | 381 int height = isHorizontal ? scrollbarThickness : m_innerViewportContainerLay
er->size().height() - scrollbarThickness; |
383 | 382 |
384 // Use the GraphicsLayer to position the scrollbars. | 383 // Use the GraphicsLayer to position the scrollbars. |
(...skipping 18 matching lines...) Expand all Loading... |
403 | 402 |
404 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer); | 403 m_webOverlayScrollbarHorizontal->setScrollLayer(scrollLayer); |
405 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer); | 404 m_webOverlayScrollbarVertical->setScrollLayer(scrollLayer); |
406 | 405 |
407 ASSERT(compositor); | 406 ASSERT(compositor); |
408 layerTreeView->registerViewportLayers( | 407 layerTreeView->registerViewportLayers( |
409 m_overscrollElasticityLayer->platformLayer(), | 408 m_overscrollElasticityLayer->platformLayer(), |
410 m_pageScaleLayer->platformLayer(), | 409 m_pageScaleLayer->platformLayer(), |
411 m_innerViewportScrollLayer->platformLayer(), | 410 m_innerViewportScrollLayer->platformLayer(), |
412 scrollLayer); | 411 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(); | |
421 } | 412 } |
422 | 413 |
423 void VisualViewport::clearLayersForTreeView(WebLayerTreeView* layerTreeView) con
st | 414 void VisualViewport::clearLayersForTreeView(WebLayerTreeView* layerTreeView) con
st |
424 { | 415 { |
425 ASSERT(layerTreeView); | 416 ASSERT(layerTreeView); |
426 | 417 |
427 layerTreeView->clearViewportLayers(); | 418 layerTreeView->clearViewportLayers(); |
428 } | 419 } |
429 | 420 |
430 DoubleRect VisualViewport::visibleContentRectDouble(IncludeScrollbarsInRect) con
st | 421 DoubleRect VisualViewport::visibleContentRectDouble(IncludeScrollbarsInRect) con
st |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 } else if (graphicsLayer == m_rootTransformLayer) { | 658 } else if (graphicsLayer == m_rootTransformLayer) { |
668 name = "Root Transform Layer"; | 659 name = "Root Transform Layer"; |
669 } else { | 660 } else { |
670 ASSERT_NOT_REACHED(); | 661 ASSERT_NOT_REACHED(); |
671 } | 662 } |
672 | 663 |
673 return name; | 664 return name; |
674 } | 665 } |
675 | 666 |
676 } // namespace blink | 667 } // namespace blink |
OLD | NEW |