| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return graphicsLayer ? scrollingWebLayerForGraphicsLayer(graphicsLayer) : 0; | 81 return graphicsLayer ? scrollingWebLayerForGraphicsLayer(graphicsLayer) : 0; |
| 82 } | 82 } |
| 83 | 83 |
| 84 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) | 84 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) |
| 85 { | 85 { |
| 86 return adoptRef(new ScrollingCoordinator(page)); | 86 return adoptRef(new ScrollingCoordinator(page)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 ScrollingCoordinator::ScrollingCoordinator(Page* page) | 89 ScrollingCoordinator::ScrollingCoordinator(Page* page) |
| 90 : m_page(page) | 90 : m_page(page) |
| 91 , m_scrollGestureRegionIsDirty(false) | |
| 92 , m_touchEventTargetRectsAreDirty(false) | |
| 93 { | 91 { |
| 94 } | 92 } |
| 95 | 93 |
| 96 ScrollingCoordinator::~ScrollingCoordinator() | 94 ScrollingCoordinator::~ScrollingCoordinator() |
| 97 { | 95 { |
| 98 ASSERT(!m_page); | 96 ASSERT(!m_page); |
| 99 for (ScrollbarMap::iterator it = m_horizontalScrollbars.begin(); it != m_hor
izontalScrollbars.end(); ++it) | 97 for (ScrollbarMap::iterator it = m_horizontalScrollbars.begin(); it != m_hor
izontalScrollbars.end(); ++it) |
| 100 GraphicsLayer::unregisterContentsLayer(it->value->layer()); | 98 GraphicsLayer::unregisterContentsLayer(it->value->layer()); |
| 101 for (ScrollbarMap::iterator it = m_verticalScrollbars.begin(); it != m_verti
calScrollbars.end(); ++it) | 99 for (ScrollbarMap::iterator it = m_verticalScrollbars.begin(); it != m_verti
calScrollbars.end(); ++it) |
| 102 GraphicsLayer::unregisterContentsLayer(it->value->layer()); | 100 GraphicsLayer::unregisterContentsLayer(it->value->layer()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 { | 112 { |
| 115 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) { | 113 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) { |
| 116 Vector<IntRect> rects = region.rects(); | 114 Vector<IntRect> rects = region.rects(); |
| 117 WebVector<WebRect> webRects(rects.size()); | 115 WebVector<WebRect> webRects(rects.size()); |
| 118 for (size_t i = 0; i < rects.size(); ++i) | 116 for (size_t i = 0; i < rects.size(); ++i) |
| 119 webRects[i] = rects[i]; | 117 webRects[i] = rects[i]; |
| 120 scrollLayer->setNonFastScrollableRegion(webRects); | 118 scrollLayer->setNonFastScrollableRegion(webRects); |
| 121 } | 119 } |
| 122 } | 120 } |
| 123 | 121 |
| 124 void ScrollingCoordinator::notifyLayoutUpdated() | 122 void ScrollingCoordinator::frameViewLayoutUpdated(FrameView* frameView) |
| 125 { | 123 { |
| 126 // These computations need to happen after compositing is updated. | 124 TRACE_EVENT0("input", "ScrollingCoordinator::frameViewLayoutUpdated"); |
| 127 m_scrollGestureRegionIsDirty = true; | |
| 128 m_touchEventTargetRectsAreDirty = true; | |
| 129 } | |
| 130 | 125 |
| 131 void ScrollingCoordinator::updateAfterCompositingChange() | 126 // Compute the region of the page where we can't handle scroll gestures and
mousewheel events |
| 132 { | 127 // on the impl thread. This currently includes: |
| 133 TRACE_EVENT0("input", "ScrollingCoordinator::updateAfterCompositingChange"); | 128 // 1. All scrollable areas, such as subframes, overflow divs and list boxes,
whose composited |
| 129 // scrolling are not enabled. We need to do this even if the frame view whos
e layout was updated |
| 130 // is not the main frame. |
| 131 // 2. Resize control areas, e.g. the small rect at the right bottom of div/t
extarea/iframe when |
| 132 // CSS property "resize" is enabled. |
| 133 // 3. Plugin areas. |
| 134 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandleScro
llGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); |
| 135 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGestureOnMa
inThreadRegion); |
| 134 | 136 |
| 135 if (m_scrollGestureRegionIsDirty) { | 137 if (touchHitTestingEnabled()) { |
| 136 // Compute the region of the page where we can't handle scroll gestures
and mousewheel events | 138 LayerHitTestRects touchEventTargetRects; |
| 137 // on the impl thread. This currently includes: | 139 computeTouchEventTargetRects(touchEventTargetRects); |
| 138 // 1. All scrollable areas, such as subframes, overflow divs and list bo
xes, whose composited | 140 setTouchEventTargetRects(touchEventTargetRects); |
| 139 // scrolling are not enabled. We need to do this even if the frame view
whose layout was updated | |
| 140 // is not the main frame. | |
| 141 // 2. Resize control areas, e.g. the small rect at the right bottom of d
iv/textarea/iframe when | |
| 142 // CSS property "resize" is enabled. | |
| 143 // 3. Plugin areas. | |
| 144 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandle
ScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); | |
| 145 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture
OnMainThreadRegion); | |
| 146 m_scrollGestureRegionIsDirty = false; | |
| 147 } | 141 } |
| 148 | 142 |
| 149 if (m_touchEventTargetRectsAreDirty) { | 143 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(frameView)) |
| 150 updateTouchEventTargetRectsIfNeeded(); | 144 scrollLayer->setBounds(frameView->contentsSize()); |
| 151 m_touchEventTargetRectsAreDirty = false; | |
| 152 } | |
| 153 | |
| 154 const FrameTree& tree = m_page->mainFrame()->tree(); | |
| 155 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { | |
| 156 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->vi
ew())) | |
| 157 scrollLayer->setBounds(child->view()->contentsSize()); | |
| 158 } | |
| 159 } | 145 } |
| 160 | 146 |
| 161 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
er* layer, bool enable) | 147 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
er* layer, bool enable) |
| 162 { | 148 { |
| 163 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) | 149 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) |
| 164 scrollableLayer->setIsContainerForFixedPositionLayers(enable); | 150 scrollableLayer->setIsContainerForFixedPositionLayers(enable); |
| 165 } | 151 } |
| 166 | 152 |
| 167 static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, Graphics
Layer* except) | 153 static void clearPositionConstraintExceptForLayer(GraphicsLayer* layer, Graphics
Layer* except) |
| 168 { | 154 { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // Now walk the layer projecting rects while maintaining a RenderGeometryMap | 460 // Now walk the layer projecting rects while maintaining a RenderGeometryMap |
| 475 MapCoordinatesFlags flags = UseTransforms; | 461 MapCoordinatesFlags flags = UseTransforms; |
| 476 if (touchHandlerInChildFrame) | 462 if (touchHandlerInChildFrame) |
| 477 flags |= TraverseDocumentBoundaries; | 463 flags |= TraverseDocumentBoundaries; |
| 478 RenderGeometryMap geometryMap(flags); | 464 RenderGeometryMap geometryMap(flags); |
| 479 LayerFrameMap layerChildFrameMap; | 465 LayerFrameMap layerChildFrameMap; |
| 480 makeLayerChildFrameMap(mainFrame, &layerChildFrameMap); | 466 makeLayerChildFrameMap(mainFrame, &layerChildFrameMap); |
| 481 convertLayerRectsToEnclosingCompositedLayerRecursive(mainFrame->contentRende
rer()->layer(), layerRects, compositorRects, geometryMap, layersWithRects, layer
ChildFrameMap); | 467 convertLayerRectsToEnclosingCompositedLayerRecursive(mainFrame->contentRende
rer()->layer(), layerRects, compositorRects, geometryMap, layersWithRects, layer
ChildFrameMap); |
| 482 } | 468 } |
| 483 | 469 |
| 484 void ScrollingCoordinator::updateTouchEventTargetRectsIfNeeded() | |
| 485 { | |
| 486 TRACE_EVENT0("input", "ScrollingCoordinator::updateTouchEventTargetRectsIfNe
eded"); | |
| 487 | |
| 488 if (!touchHitTestingEnabled()) | |
| 489 return; | |
| 490 | |
| 491 LayerHitTestRects touchEventTargetRects; | |
| 492 computeTouchEventTargetRects(touchEventTargetRects); | |
| 493 setTouchEventTargetRects(touchEventTargetRects); | |
| 494 } | |
| 495 | |
| 496 // Note that in principle this could be called more often than computeTouchEvent
TargetRects, for | 470 // Note that in principle this could be called more often than computeTouchEvent
TargetRects, for |
| 497 // example during a non-composited scroll (although that's not yet implemented -
crbug.com/261307). | 471 // example during a non-composited scroll (although that's not yet implemented -
crbug.com/261307). |
| 498 void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& lay
erRects) | 472 void ScrollingCoordinator::setTouchEventTargetRects(const LayerHitTestRects& lay
erRects) |
| 499 { | 473 { |
| 500 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects"); | 474 TRACE_EVENT0("input", "ScrollingCoordinator::setTouchEventTargetRects"); |
| 501 | 475 |
| 502 LayerHitTestRects compositorRects; | 476 LayerHitTestRects compositorRects; |
| 503 convertLayerRectsToEnclosingCompositedLayer(m_page->mainFrame(), layerRects,
compositorRects); | 477 convertLayerRectsToEnclosingCompositedLayer(m_page->mainFrame(), layerRects,
compositorRects); |
| 504 | 478 |
| 505 HashSet<const RenderLayer*> oldLayersWithTouchRects; | 479 HashSet<const RenderLayer*> oldLayersWithTouchRects; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 534 | 508 |
| 535 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*) | 509 void ScrollingCoordinator::touchEventTargetRectsDidChange(const Document*) |
| 536 { | 510 { |
| 537 if (!touchHitTestingEnabled()) | 511 if (!touchHitTestingEnabled()) |
| 538 return; | 512 return; |
| 539 | 513 |
| 540 // Wait until after layout to update. | 514 // Wait until after layout to update. |
| 541 if (m_page->mainFrame()->view()->needsLayout()) | 515 if (m_page->mainFrame()->view()->needsLayout()) |
| 542 return; | 516 return; |
| 543 | 517 |
| 544 // FIXME: scheduleAnimation() is just a method of forcing the compositor to
realize that it | 518 TRACE_EVENT0("input", "ScrollingCoordinator::touchEventTargetRectsDidChange"
); |
| 545 // needs to commit here. We should expose a cleaner API for this. | |
| 546 RenderView* renderView = m_page->mainFrame()->contentRenderer(); | |
| 547 if (renderView && renderView->compositor() && renderView->compositor()->inCo
mpositingMode()) | |
| 548 m_page->mainFrame()->view()->scheduleAnimation(); | |
| 549 | 519 |
| 550 m_touchEventTargetRectsAreDirty = true; | 520 LayerHitTestRects touchEventTargetRects; |
| 521 computeTouchEventTargetRects(touchEventTargetRects); |
| 522 setTouchEventTargetRects(touchEventTargetRects); |
| 551 } | 523 } |
| 552 | 524 |
| 553 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* chi
ld, RenderLayer* parent) | 525 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* chi
ld, RenderLayer* parent) |
| 554 { | 526 { |
| 555 WebLayer* scrollParentWebLayer = 0; | 527 WebLayer* scrollParentWebLayer = 0; |
| 556 if (parent && parent->compositedLayerMapping()) | 528 if (parent && parent->compositedLayerMapping()) |
| 557 scrollParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->composi
tedLayerMapping()->parentForSublayers()); | 529 scrollParentWebLayer = scrollingWebLayerForGraphicsLayer(parent->composi
tedLayerMapping()->parentForSublayers()); |
| 558 | 530 |
| 559 child->setScrollParent(scrollParentWebLayer); | 531 child->setScrollParent(scrollParentWebLayer); |
| 560 } | 532 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 } | 772 } |
| 801 | 773 |
| 802 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) | 774 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) |
| 803 { | 775 { |
| 804 ASSERT(isMainThread()); | 776 ASSERT(isMainThread()); |
| 805 ASSERT(m_page); | 777 ASSERT(m_page); |
| 806 | 778 |
| 807 if (!coordinatesScrollingForFrameView(frameView)) | 779 if (!coordinatesScrollingForFrameView(frameView)) |
| 808 return; | 780 return; |
| 809 | 781 |
| 810 notifyLayoutUpdated(); | 782 frameViewLayoutUpdated(frameView); |
| 811 recomputeWheelEventHandlerCountForFrameView(frameView); | 783 recomputeWheelEventHandlerCountForFrameView(frameView); |
| 812 updateShouldUpdateScrollLayerPositionOnMainThread(); | 784 updateShouldUpdateScrollLayerPositionOnMainThread(); |
| 813 } | 785 } |
| 814 | 786 |
| 815 #if OS(MACOSX) | 787 #if OS(MACOSX) |
| 816 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) | 788 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) |
| 817 { | 789 { |
| 818 ASSERT(isMainThread()); | 790 ASSERT(isMainThread()); |
| 819 | 791 |
| 820 if (!m_page) | 792 if (!m_page) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 stringBuilder.resize(stringBuilder.length() - 2); | 859 stringBuilder.resize(stringBuilder.length() - 2); |
| 888 return stringBuilder.toString(); | 860 return stringBuilder.toString(); |
| 889 } | 861 } |
| 890 | 862 |
| 891 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 863 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
| 892 { | 864 { |
| 893 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); | 865 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); |
| 894 } | 866 } |
| 895 | 867 |
| 896 } // namespace WebCore | 868 } // namespace WebCore |
| OLD | NEW |