OLD | NEW |
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 if (settings->useSolidColorScrollbars()) { | 374 if (settings->useSolidColorScrollbars()) { |
375 ASSERT(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); | 375 ASSERT(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); |
376 webScrollbarLayer = createSolidColorScrollbarLayer(orientation,
scrollbar->theme()->thumbThickness(scrollbar), scrollbar->theme()->trackPosition
(scrollbar), scrollableArea->shouldPlaceVerticalScrollbarOnLeft()); | 376 webScrollbarLayer = createSolidColorScrollbarLayer(orientation,
scrollbar->theme()->thumbThickness(scrollbar), scrollbar->theme()->trackPosition
(scrollbar), scrollableArea->shouldPlaceVerticalScrollbarOnLeft()); |
377 } else { | 377 } else { |
378 webScrollbarLayer = createScrollbarLayer(scrollbar); | 378 webScrollbarLayer = createScrollbarLayer(scrollbar); |
379 } | 379 } |
380 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w
ebScrollbarLayer.release()); | 380 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w
ebScrollbarLayer.release()); |
381 } | 381 } |
382 | 382 |
383 WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling()); | 383 WebLayer* scrollLayer = toWebLayer(scrollableArea->layerForScrolling()); |
384 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer(
)); | 384 WebLayer* scrollbarContainerLayer = toWebLayer(scrollableArea->layerForS
crollbarContainer()); |
385 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer,
containerLayer); | 385 setupScrollbarLayer(scrollbarGraphicsLayer, scrollbarLayer, scrollLayer,
scrollbarContainerLayer); |
386 | 386 |
387 // Root layer non-overlay scrollbars should be marked opaque to disable | 387 // Root layer non-overlay scrollbars should be marked opaque to disable |
388 // blending. | 388 // blending. |
389 bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar(); | 389 bool isOpaqueScrollbar = !scrollbar->isOverlayScrollbar(); |
390 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollb
ar); | 390 scrollbarGraphicsLayer->setContentsOpaque(isMainFrame && isOpaqueScrollb
ar); |
391 } else | 391 } else |
392 removeWebScrollbarLayer(scrollableArea, orientation); | 392 removeWebScrollbarLayer(scrollableArea, orientation); |
393 } | 393 } |
394 | 394 |
395 bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc
rollableArea) | 395 bool ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea* sc
rollableArea) |
396 { | 396 { |
397 GraphicsLayer* scrollLayer = scrollableArea->layerForScrolling(); | 397 GraphicsLayer* scrollLayer = scrollableArea->layerForScrolling(); |
398 | 398 |
399 if (scrollLayer) { | 399 if (scrollLayer) { |
400 ASSERT(m_page); | 400 ASSERT(m_page); |
401 scrollLayer->setScrollableArea(scrollableArea, isForViewport(scrollableA
rea)); | 401 scrollLayer->setScrollableArea(scrollableArea, isForViewport(scrollableA
rea)); |
402 } | 402 } |
403 | 403 |
404 WebLayer* webLayer = toWebLayer(scrollableArea->layerForScrolling()); | 404 WebLayer* webLayer = toWebLayer(scrollableArea->layerForScrolling()); |
405 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer()); | 405 WebLayer* containerLayer = toWebLayer(scrollableArea->layerForContainer()); |
| 406 WebLayer* scrollbarContainerLayer = toWebLayer(scrollableArea->layerForScrol
lbarContainer()); |
406 if (webLayer) { | 407 if (webLayer) { |
407 webLayer->setScrollClipLayer(containerLayer); | 408 webLayer->setScrollClipLayer(containerLayer); |
408 // Non-layered Viewport constrained objects, e.g. fixed position element
s, are | 409 // Non-layered Viewport constrained objects, e.g. fixed position element
s, are |
409 // positioned in Blink using integer coordinates. In that case, we don't
want | 410 // positioned in Blink using integer coordinates. In that case, we don't
want |
410 // to set the WebLayer's scroll position at fractional precision otherwi
se the | 411 // to set the WebLayer's scroll position at fractional precision otherwi
se the |
411 // WebLayer's position after snapping to device pixel can be off with re
gard to | 412 // WebLayer's position after snapping to device pixel can be off with re
gard to |
412 // fixed position elements. | 413 // fixed position elements. |
413 if (m_lastMainThreadScrollingReasons & ScrollingCoordinator::HasNonLayer
ViewportConstrainedObjects) { | 414 if (m_lastMainThreadScrollingReasons & ScrollingCoordinator::HasNonLayer
ViewportConstrainedObjects) { |
414 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll
Position() - scrollableArea->minimumScrollPosition())); | 415 webLayer->setScrollPositionDouble(DoublePoint(scrollableArea->scroll
Position() - scrollableArea->minimumScrollPosition())); |
415 } else { | 416 } else { |
416 DoublePoint scrollPosition(scrollableArea->scrollPositionDouble() -
scrollableArea->minimumScrollPositionDouble()); | 417 DoublePoint scrollPosition(scrollableArea->scrollPositionDouble() -
scrollableArea->minimumScrollPositionDouble()); |
417 IntPoint flooredScrollPosition(flooredIntPoint(scrollPosition)); | 418 IntPoint flooredScrollPosition(flooredIntPoint(scrollPosition)); |
418 DoublePoint fractionalPart(scrollPosition.x() - flooredScrollPositio
n.x(), scrollPosition.y() - flooredScrollPosition.y()); | 419 DoublePoint fractionalPart(scrollPosition.x() - flooredScrollPositio
n.x(), scrollPosition.y() - flooredScrollPosition.y()); |
419 webLayer->setScrollPositionDouble(scrollPosition); | 420 webLayer->setScrollPositionDouble(scrollPosition); |
420 // Blink can only use the integer part of the scroll offset to posit
ion elements. | 421 // Blink can only use the integer part of the scroll offset to posit
ion elements. |
421 // Sends the fractional part of the scroll offset to CC as scroll ad
justment for | 422 // Sends the fractional part of the scroll offset to CC as scroll ad
justment for |
422 // fixed-position layer. | 423 // fixed-position layer. |
423 webLayer->setScrollCompensationAdjustment(fractionalPart); | 424 webLayer->setScrollCompensationAdjustment(fractionalPart); |
424 } | 425 } |
425 | 426 |
426 webLayer->setBounds(scrollableArea->contentsSize()); | 427 webLayer->setBounds(scrollableArea->contentsSize()); |
427 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba
r); | 428 bool canScrollX = scrollableArea->userInputScrollable(HorizontalScrollba
r); |
428 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar)
; | 429 bool canScrollY = scrollableArea->userInputScrollable(VerticalScrollbar)
; |
429 webLayer->setUserScrollable(canScrollX, canScrollY); | 430 webLayer->setUserScrollable(canScrollX, canScrollY); |
430 } | 431 } |
431 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea,
HorizontalScrollbar)) { | 432 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea,
HorizontalScrollbar)) { |
432 GraphicsLayer* horizontalScrollbarLayer = scrollableArea->layerForHorizo
ntalScrollbar(); | 433 GraphicsLayer* horizontalScrollbarLayer = scrollableArea->layerForHorizo
ntalScrollbar(); |
433 if (horizontalScrollbarLayer) | 434 if (horizontalScrollbarLayer) |
434 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay
er, containerLayer); | 435 setupScrollbarLayer(horizontalScrollbarLayer, scrollbarLayer, webLay
er, scrollbarContainerLayer); |
435 } | 436 } |
436 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea,
VerticalScrollbar)) { | 437 if (WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea,
VerticalScrollbar)) { |
437 GraphicsLayer* verticalScrollbarLayer = scrollableArea->layerForVertical
Scrollbar(); | 438 GraphicsLayer* verticalScrollbarLayer = scrollableArea->layerForVertical
Scrollbar(); |
| 439 |
438 if (verticalScrollbarLayer) | 440 if (verticalScrollbarLayer) |
439 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer
, containerLayer); | 441 setupScrollbarLayer(verticalScrollbarLayer, scrollbarLayer, webLayer
, scrollbarContainerLayer); |
440 } | 442 } |
441 | 443 |
442 // Update the viewport layer registration if the outer viewport may have cha
nged. | 444 // Update the viewport layer registration if the outer viewport may have cha
nged. |
443 if (m_page->settings().rootLayerScrolls() && isForRootLayer(scrollableArea)) | 445 if (m_page->settings().rootLayerScrolls() && isForRootLayer(scrollableArea)) |
444 m_page->chromeClient().registerViewportLayers(); | 446 m_page->chromeClient().registerViewportLayers(); |
445 | 447 |
446 scrollableArea->layerForScrollingDidChange(m_programmaticScrollAnimatorTimel
ine.get()); | 448 scrollableArea->layerForScrollingDidChange(m_programmaticScrollAnimatorTimel
ine.get()); |
447 | 449 |
448 return !!webLayer; | 450 return !!webLayer; |
449 } | 451 } |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 bool frameIsScrollable = frameView && frameView->isScrollable(); | 1078 bool frameIsScrollable = frameView && frameView->isScrollable(); |
1077 if (frameIsScrollable != m_wasFrameScrollable) | 1079 if (frameIsScrollable != m_wasFrameScrollable) |
1078 return true; | 1080 return true; |
1079 | 1081 |
1080 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) | 1082 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) |
1081 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); | 1083 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); |
1082 return false; | 1084 return false; |
1083 } | 1085 } |
1084 | 1086 |
1085 } // namespace blink | 1087 } // namespace blink |
OLD | NEW |