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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 , m_lastMainThreadScrollingReasons(0) | 92 , m_lastMainThreadScrollingReasons(0) |
93 { | 93 { |
94 } | 94 } |
95 | 95 |
96 ScrollingCoordinator::~ScrollingCoordinator() | 96 ScrollingCoordinator::~ScrollingCoordinator() |
97 { | 97 { |
98 } | 98 } |
99 | 99 |
100 bool ScrollingCoordinator::touchHitTestingEnabled() const | 100 bool ScrollingCoordinator::touchHitTestingEnabled() const |
101 { | 101 { |
102 RenderView* contentRenderer = m_page->mainFrame()->contentRenderer(); | 102 if (!m_page->mainFrame()->isLocalFrame()) |
103 Settings* settings = m_page->mainFrame()->document()->settings(); | 103 return false; |
| 104 RenderView* contentRenderer = toLocalFrame(m_page->mainFrame())->contentRend
erer(); |
| 105 Settings* settings = m_page->mainFrame()->settings(); |
104 return RuntimeEnabledFeatures::touchEnabled() && settings->compositorTouchHi
tTesting() && contentRenderer && contentRenderer->usesCompositing(); | 106 return RuntimeEnabledFeatures::touchEnabled() && settings->compositorTouchHi
tTesting() && contentRenderer && contentRenderer->usesCompositing(); |
105 } | 107 } |
106 | 108 |
107 void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const
Region& region) | 109 void ScrollingCoordinator::setShouldHandleScrollGestureOnMainThreadRegion(const
Region& region) |
108 { | 110 { |
109 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) { | 111 if (!m_page->mainFrame()->isLocalFrame()) |
| 112 return; |
| 113 if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->vi
ew()->layerForScrolling())) { |
110 Vector<IntRect> rects = region.rects(); | 114 Vector<IntRect> rects = region.rects(); |
111 WebVector<WebRect> webRects(rects.size()); | 115 WebVector<WebRect> webRects(rects.size()); |
112 for (size_t i = 0; i < rects.size(); ++i) | 116 for (size_t i = 0; i < rects.size(); ++i) |
113 webRects[i] = rects[i]; | 117 webRects[i] = rects[i]; |
114 scrollLayer->setNonFastScrollableRegion(webRects); | 118 scrollLayer->setNonFastScrollableRegion(webRects); |
115 } | 119 } |
116 } | 120 } |
117 | 121 |
118 void ScrollingCoordinator::notifyLayoutUpdated() | 122 void ScrollingCoordinator::notifyLayoutUpdated() |
119 { | 123 { |
120 m_scrollGestureRegionIsDirty = true; | 124 m_scrollGestureRegionIsDirty = true; |
121 m_touchEventTargetRectsAreDirty = true; | 125 m_touchEventTargetRectsAreDirty = true; |
122 m_shouldScrollOnMainThreadDirty = true; | 126 m_shouldScrollOnMainThreadDirty = true; |
123 } | 127 } |
124 | 128 |
125 void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded() | 129 void ScrollingCoordinator::updateAfterCompositingChangeIfNeeded() |
126 { | 130 { |
| 131 // FIXME: This function has a lot of dependencies on main frame always being |
| 132 // local, so just early return if that's not the case. |
| 133 if (!m_page->mainFrame()->isLocalFrame()) |
| 134 return; |
| 135 |
127 if (!shouldUpdateAfterCompositingChange()) | 136 if (!shouldUpdateAfterCompositingChange()) |
128 return; | 137 return; |
129 | 138 |
130 TRACE_EVENT0("input", "ScrollingCoordinator::updateAfterCompositingChangeIfN
eeded"); | 139 TRACE_EVENT0("input", "ScrollingCoordinator::updateAfterCompositingChangeIfN
eeded"); |
131 | 140 |
132 if (m_scrollGestureRegionIsDirty) { | 141 if (m_scrollGestureRegionIsDirty) { |
133 // Compute the region of the page where we can't handle scroll gestures
and mousewheel events | 142 // Compute the region of the page where we can't handle scroll gestures
and mousewheel events |
134 // on the impl thread. This currently includes: | 143 // on the impl thread. This currently includes: |
135 // 1. All scrollable areas, such as subframes, overflow divs and list bo
xes, whose composited | 144 // 1. All scrollable areas, such as subframes, overflow divs and list bo
xes, whose composited |
136 // scrolling are not enabled. We need to do this even if the frame view
whose layout was updated | 145 // scrolling are not enabled. We need to do this even if the frame view
whose layout was updated |
137 // is not the main frame. | 146 // is not the main frame. |
138 // 2. Resize control areas, e.g. the small rect at the right bottom of d
iv/textarea/iframe when | 147 // 2. Resize control areas, e.g. the small rect at the right bottom of d
iv/textarea/iframe when |
139 // CSS property "resize" is enabled. | 148 // CSS property "resize" is enabled. |
140 // 3. Plugin areas. | 149 // 3. Plugin areas. |
141 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandle
ScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); | 150 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandle
ScrollGestureOnMainThreadRegion(toLocalFrame(m_page->mainFrame()), IntPoint()); |
142 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture
OnMainThreadRegion); | 151 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture
OnMainThreadRegion); |
143 m_scrollGestureRegionIsDirty = false; | 152 m_scrollGestureRegionIsDirty = false; |
144 } | 153 } |
145 | 154 |
146 if (m_touchEventTargetRectsAreDirty) { | 155 if (m_touchEventTargetRectsAreDirty) { |
147 updateTouchEventTargetRectsIfNeeded(); | 156 updateTouchEventTargetRectsIfNeeded(); |
148 m_touchEventTargetRectsAreDirty = false; | 157 m_touchEventTargetRectsAreDirty = false; |
149 } | 158 } |
150 | 159 |
151 FrameView* frameView = m_page->mainFrame()->view(); | 160 FrameView* frameView = toLocalFrame(m_page->mainFrame())->view(); |
152 bool frameIsScrollable = frameView && frameView->isScrollable(); | 161 bool frameIsScrollable = frameView && frameView->isScrollable(); |
153 if (m_shouldScrollOnMainThreadDirty || m_wasFrameScrollable != frameIsScroll
able) { | 162 if (m_shouldScrollOnMainThreadDirty || m_wasFrameScrollable != frameIsScroll
able) { |
154 setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReason
s()); | 163 setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReason
s()); |
155 m_shouldScrollOnMainThreadDirty = false; | 164 m_shouldScrollOnMainThreadDirty = false; |
156 } | 165 } |
157 m_wasFrameScrollable = frameIsScrollable; | 166 m_wasFrameScrollable = frameIsScrollable; |
158 | 167 |
159 // The mainFrame view doesn't get included in the FrameTree below, so we | 168 // The mainFrame view doesn't get included in the FrameTree below, so we |
160 // update its size separately. | 169 // update its size separately. |
161 if (WebLayer* scrollingWebLayer = frameView ? toWebLayer(frameView->layerFor
Scrolling()) : 0) { | 170 if (WebLayer* scrollingWebLayer = frameView ? toWebLayer(frameView->layerFor
Scrolling()) : 0) { |
162 scrollingWebLayer->setBounds(frameView->contentsSize()); | 171 scrollingWebLayer->setBounds(frameView->contentsSize()); |
163 // If there is a fullscreen element, set the scroll clip layer to 0 so m
ain frame won't scroll. | 172 // If there is a fullscreen element, set the scroll clip layer to 0 so m
ain frame won't scroll. |
164 Document* mainFrameDocument = m_page->mainFrame()->document(); | 173 Document* mainFrameDocument = toLocalFrame(m_page->mainFrame())->documen
t(); |
165 Element* fullscreenElement = FullscreenElementStack::fullscreenElementFr
om(*mainFrameDocument); | 174 Element* fullscreenElement = FullscreenElementStack::fullscreenElementFr
om(*mainFrameDocument); |
166 if (fullscreenElement && fullscreenElement != mainFrameDocument->documen
tElement()) | 175 if (fullscreenElement && fullscreenElement != mainFrameDocument->documen
tElement()) |
167 scrollingWebLayer->setScrollClipLayer(0); | 176 scrollingWebLayer->setScrollClipLayer(0); |
168 else | 177 else |
169 scrollingWebLayer->setScrollClipLayer(toWebLayer(frameView->layerFor
Container())); | 178 scrollingWebLayer->setScrollClipLayer(toWebLayer(frameView->layerFor
Container())); |
170 } | 179 } |
171 | 180 |
172 const FrameTree& tree = m_page->mainFrame()->tree(); | 181 const FrameTree& tree = m_page->mainFrame()->tree(); |
173 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { | 182 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { |
174 if (!child->isLocalFrame()) | 183 if (!child->isLocalFrame()) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 325 |
317 if (scrollbarGraphicsLayer) { | 326 if (scrollbarGraphicsLayer) { |
318 Scrollbar* scrollbar = orientation == HorizontalScrollbar ? scrollableAr
ea->horizontalScrollbar() : scrollableArea->verticalScrollbar(); | 327 Scrollbar* scrollbar = orientation == HorizontalScrollbar ? scrollableAr
ea->horizontalScrollbar() : scrollableArea->verticalScrollbar(); |
319 if (scrollbar->isCustomScrollbar()) { | 328 if (scrollbar->isCustomScrollbar()) { |
320 detachScrollbarLayer(scrollbarGraphicsLayer); | 329 detachScrollbarLayer(scrollbarGraphicsLayer); |
321 return; | 330 return; |
322 } | 331 } |
323 | 332 |
324 WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea,
orientation); | 333 WebScrollbarLayer* scrollbarLayer = getWebScrollbarLayer(scrollableArea,
orientation); |
325 if (!scrollbarLayer) { | 334 if (!scrollbarLayer) { |
326 Settings* settings = m_page->mainFrame()->document()->settings(); | 335 Settings* settings = m_page->mainFrame()->settings(); |
327 | 336 |
328 OwnPtr<WebScrollbarLayer> webScrollbarLayer; | 337 OwnPtr<WebScrollbarLayer> webScrollbarLayer; |
329 if (settings->useSolidColorScrollbars()) { | 338 if (settings->useSolidColorScrollbars()) { |
330 ASSERT(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); | 339 ASSERT(RuntimeEnabledFeatures::overlayScrollbarsEnabled()); |
331 webScrollbarLayer = createSolidColorScrollbarLayer(orientation,
scrollbar->theme()->thumbThickness(scrollbar), scrollbar->theme()->trackPosition
(scrollbar), scrollableArea->shouldPlaceVerticalScrollbarOnLeft()); | 340 webScrollbarLayer = createSolidColorScrollbarLayer(orientation,
scrollbar->theme()->thumbThickness(scrollbar), scrollbar->theme()->trackPosition
(scrollbar), scrollableArea->shouldPlaceVerticalScrollbarOnLeft()); |
332 } else { | 341 } else { |
333 webScrollbarLayer = createScrollbarLayer(scrollbar); | 342 webScrollbarLayer = createScrollbarLayer(scrollbar); |
334 } | 343 } |
335 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w
ebScrollbarLayer.release()); | 344 scrollbarLayer = addWebScrollbarLayer(scrollableArea, orientation, w
ebScrollbarLayer.release()); |
336 } | 345 } |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 | 612 |
604 // Ensure we have an entry for each composited layer that previously had rec
ts (so that old | 613 // Ensure we have an entry for each composited layer that previously had rec
ts (so that old |
605 // ones will get cleared out). Note that ideally we'd track this on Graphics
Layer instead of | 614 // ones will get cleared out). Note that ideally we'd track this on Graphics
Layer instead of |
606 // RenderLayer, but we have no good hook into the lifetime of a GraphicsLaye
r. | 615 // RenderLayer, but we have no good hook into the lifetime of a GraphicsLaye
r. |
607 for (HashSet<const RenderLayer*>::iterator it = oldLayersWithTouchRects.begi
n(); it != oldLayersWithTouchRects.end(); ++it) { | 616 for (HashSet<const RenderLayer*>::iterator it = oldLayersWithTouchRects.begi
n(); it != oldLayersWithTouchRects.end(); ++it) { |
608 if (!layerRects.contains(*it)) | 617 if (!layerRects.contains(*it)) |
609 layerRects.add(*it, Vector<LayoutRect>()); | 618 layerRects.add(*it, Vector<LayoutRect>()); |
610 } | 619 } |
611 | 620 |
612 GraphicsLayerHitTestRects graphicsLayerRects; | 621 GraphicsLayerHitTestRects graphicsLayerRects; |
613 projectRectsToGraphicsLayerSpace(m_page->mainFrame(), layerRects, graphicsLa
yerRects); | 622 projectRectsToGraphicsLayerSpace(toLocalFrame(m_page->mainFrame()), layerRec
ts, graphicsLayerRects); |
614 | 623 |
615 for (GraphicsLayerHitTestRects::const_iterator iter = graphicsLayerRects.beg
in(); iter != graphicsLayerRects.end(); ++iter) { | 624 for (GraphicsLayerHitTestRects::const_iterator iter = graphicsLayerRects.beg
in(); iter != graphicsLayerRects.end(); ++iter) { |
616 const GraphicsLayer* graphicsLayer = iter->key; | 625 const GraphicsLayer* graphicsLayer = iter->key; |
617 WebVector<WebRect> webRects(iter->value.size()); | 626 WebVector<WebRect> webRects(iter->value.size()); |
618 for (size_t i = 0; i < iter->value.size(); ++i) | 627 for (size_t i = 0; i < iter->value.size(); ++i) |
619 webRects[i] = enclosingIntRect(iter->value[i]); | 628 webRects[i] = enclosingIntRect(iter->value[i]); |
620 graphicsLayer->platformLayer()->setTouchEventHandlerRegion(webRects); | 629 graphicsLayer->platformLayer()->setTouchEventHandlerRegion(webRects); |
621 } | 630 } |
622 } | 631 } |
623 | 632 |
624 void ScrollingCoordinator::touchEventTargetRectsDidChange() | 633 void ScrollingCoordinator::touchEventTargetRectsDidChange() |
625 { | 634 { |
626 if (!touchHitTestingEnabled()) | 635 if (!touchHitTestingEnabled()) |
627 return; | 636 return; |
628 | 637 |
629 // Wait until after layout to update. | 638 // Wait until after layout to update. |
630 if (!m_page->mainFrame()->view() || m_page->mainFrame()->view()->needsLayout
()) | 639 if (!toLocalFrame(m_page->mainFrame())->view() || toLocalFrame(m_page->mainF
rame())->view()->needsLayout()) |
631 return; | 640 return; |
632 | 641 |
633 // FIXME: scheduleAnimation() is just a method of forcing the compositor to
realize that it | 642 // FIXME: scheduleAnimation() is just a method of forcing the compositor to
realize that it |
634 // needs to commit here. We should expose a cleaner API for this. | 643 // needs to commit here. We should expose a cleaner API for this. |
635 RenderView* renderView = m_page->mainFrame()->contentRenderer(); | 644 RenderView* renderView = toLocalFrame(m_page->mainFrame())->contentRenderer(
); |
636 if (renderView && renderView->compositor() && renderView->compositor()->stal
eInCompositingMode()) | 645 if (renderView && renderView->compositor() && renderView->compositor()->stal
eInCompositingMode()) |
637 m_page->mainFrame()->view()->scheduleAnimation(); | 646 toLocalFrame(m_page->mainFrame())->view()->scheduleAnimation(); |
638 | 647 |
639 m_touchEventTargetRectsAreDirty = true; | 648 m_touchEventTargetRectsAreDirty = true; |
640 } | 649 } |
641 | 650 |
642 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* chi
ld, RenderLayer* parent) | 651 void ScrollingCoordinator::updateScrollParentForGraphicsLayer(GraphicsLayer* chi
ld, RenderLayer* parent) |
643 { | 652 { |
644 WebLayer* scrollParentWebLayer = 0; | 653 WebLayer* scrollParentWebLayer = 0; |
645 if (parent && parent->hasCompositedLayerMapping()) | 654 if (parent && parent->hasCompositedLayerMapping()) |
646 scrollParentWebLayer = toWebLayer(parent->compositedLayerMapping()->pare
ntForSublayers()); | 655 scrollParentWebLayer = toWebLayer(parent->compositedLayerMapping()->pare
ntForSublayers()); |
647 | 656 |
(...skipping 11 matching lines...) Expand all Loading... |
659 | 668 |
660 void ScrollingCoordinator::willDestroyRenderLayer(RenderLayer* layer) | 669 void ScrollingCoordinator::willDestroyRenderLayer(RenderLayer* layer) |
661 { | 670 { |
662 m_layersWithTouchRects.remove(layer); | 671 m_layersWithTouchRects.remove(layer); |
663 } | 672 } |
664 | 673 |
665 void ScrollingCoordinator::updateHaveWheelEventHandlers() | 674 void ScrollingCoordinator::updateHaveWheelEventHandlers() |
666 { | 675 { |
667 ASSERT(isMainThread()); | 676 ASSERT(isMainThread()); |
668 ASSERT(m_page); | 677 ASSERT(m_page); |
669 if (!m_page->mainFrame()->view()) | 678 if (!m_page->mainFrame()->isLocalFrame() || !toLocalFrame(m_page->mainFrame(
))->view()) |
670 return; | 679 return; |
671 | 680 |
672 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) { | 681 if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->vi
ew()->layerForScrolling())) { |
673 bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventH
andlers(EventHandlerRegistry::WheelEvent); | 682 bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventH
andlers(EventHandlerRegistry::WheelEvent); |
674 scrollLayer->setHaveWheelEventHandlers(haveHandlers); | 683 scrollLayer->setHaveWheelEventHandlers(haveHandlers); |
675 } | 684 } |
676 } | 685 } |
677 | 686 |
678 void ScrollingCoordinator::updateHaveScrollEventHandlers() | 687 void ScrollingCoordinator::updateHaveScrollEventHandlers() |
679 { | 688 { |
680 ASSERT(isMainThread()); | 689 ASSERT(isMainThread()); |
681 ASSERT(m_page); | 690 ASSERT(m_page); |
682 if (!m_page->mainFrame()->view()) | 691 if (!m_page->mainFrame()->isLocalFrame() || !toLocalFrame(m_page->mainFrame(
))->view()) |
683 return; | 692 return; |
684 | 693 |
685 // Currently the compositor only cares whether there are scroll handlers any
where on the page | 694 // Currently the compositor only cares whether there are scroll handlers any
where on the page |
686 // instead on a per-layer basis. We therefore only update this information f
or the root | 695 // instead on a per-layer basis. We therefore only update this information f
or the root |
687 // scrolling layer. | 696 // scrolling layer. |
688 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) { | 697 if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->vi
ew()->layerForScrolling())) { |
689 bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventH
andlers(EventHandlerRegistry::ScrollEvent); | 698 bool haveHandlers = m_page->frameHost().eventHandlerRegistry().hasEventH
andlers(EventHandlerRegistry::ScrollEvent); |
690 scrollLayer->setHaveScrollEventHandlers(haveHandlers); | 699 scrollLayer->setHaveScrollEventHandlers(haveHandlers); |
691 } | 700 } |
692 } | 701 } |
693 | 702 |
694 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh
readScrollingReasons reasons) | 703 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh
readScrollingReasons reasons) |
695 { | 704 { |
696 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) { | 705 if (!m_page->mainFrame()->isLocalFrame()) |
| 706 return; |
| 707 if (WebLayer* scrollLayer = toWebLayer(toLocalFrame(m_page->mainFrame())->vi
ew()->layerForScrolling())) { |
697 m_lastMainThreadScrollingReasons = reasons; | 708 m_lastMainThreadScrollingReasons = reasons; |
698 scrollLayer->setShouldScrollOnMainThread(reasons); | 709 scrollLayer->setShouldScrollOnMainThread(reasons); |
699 } | 710 } |
700 } | 711 } |
701 | 712 |
702 void ScrollingCoordinator::willBeDestroyed() | 713 void ScrollingCoordinator::willBeDestroyed() |
703 { | 714 { |
704 ASSERT(m_page); | 715 ASSERT(m_page); |
705 m_page = 0; | 716 m_page = 0; |
706 for (ScrollbarMap::iterator it = m_horizontalScrollbars.begin(); it != m_hor
izontalScrollbars.end(); ++it) | 717 for (ScrollbarMap::iterator it = m_horizontalScrollbars.begin(); it != m_hor
izontalScrollbars.end(); ++it) |
707 GraphicsLayer::unregisterContentsLayer(it->value->layer()); | 718 GraphicsLayer::unregisterContentsLayer(it->value->layer()); |
708 for (ScrollbarMap::iterator it = m_verticalScrollbars.begin(); it != m_verti
calScrollbars.end(); ++it) | 719 for (ScrollbarMap::iterator it = m_verticalScrollbars.begin(); it != m_verti
calScrollbars.end(); ++it) |
709 GraphicsLayer::unregisterContentsLayer(it->value->layer()); | 720 GraphicsLayer::unregisterContentsLayer(it->value->layer()); |
710 } | 721 } |
711 | 722 |
712 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
) const | 723 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
) const |
713 { | 724 { |
714 ASSERT(isMainThread()); | 725 ASSERT(isMainThread()); |
715 ASSERT(m_page); | 726 ASSERT(m_page); |
716 | 727 |
717 // We currently only handle the main frame. | 728 // We currently only handle the main frame. |
718 if (&frameView->frame() != m_page->mainFrame()) | 729 if (&frameView->frame() != m_page->mainFrame()) |
719 return false; | 730 return false; |
720 | 731 |
| 732 // FIXME: And only if the main frame is not an OOPI. |
| 733 if (!m_page->mainFrame()->isLocalFrame()) |
| 734 return false; |
| 735 |
721 // We currently only support composited mode. | 736 // We currently only support composited mode. |
722 RenderView* renderView = m_page->mainFrame()->contentRenderer(); | 737 RenderView* renderView = toLocalFrame(m_page->mainFrame())->contentRenderer(
); |
723 if (!renderView) | 738 if (!renderView) |
724 return false; | 739 return false; |
725 return renderView->usesCompositing(); | 740 return renderView->usesCompositing(); |
726 } | 741 } |
727 | 742 |
728 Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion(
const LocalFrame* frame, const IntPoint& frameLocation) const | 743 Region ScrollingCoordinator::computeShouldHandleScrollGestureOnMainThreadRegion(
const LocalFrame* frame, const IntPoint& frameLocation) const |
729 { | 744 { |
730 Region shouldHandleScrollGestureOnMainThreadRegion; | 745 Region shouldHandleScrollGestureOnMainThreadRegion; |
731 FrameView* frameView = frame->view(); | 746 FrameView* frameView = frame->view(); |
732 if (!frameView) | 747 if (!frameView) |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 } | 860 } |
846 } | 861 } |
847 | 862 |
848 } | 863 } |
849 | 864 |
850 void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
) | 865 void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
) |
851 { | 866 { |
852 TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects"); | 867 TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects"); |
853 ASSERT(touchHitTestingEnabled()); | 868 ASSERT(touchHitTestingEnabled()); |
854 | 869 |
855 Document* document = m_page->mainFrame()->document(); | 870 Document* document = toLocalFrame(m_page->mainFrame())->document(); |
856 if (!document || !document->view()) | 871 if (!document || !document->view()) |
857 return; | 872 return; |
858 | 873 |
859 accumulateDocumentTouchEventTargetRects(rects, document); | 874 accumulateDocumentTouchEventTargetRects(rects, document); |
860 } | 875 } |
861 | 876 |
862 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* fr
ameView) | 877 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* fr
ameView) |
863 { | 878 { |
864 ASSERT(isMainThread()); | 879 ASSERT(isMainThread()); |
865 ASSERT(m_page); | 880 ASSERT(m_page); |
(...skipping 10 matching lines...) Expand all Loading... |
876 ASSERT(m_page); | 891 ASSERT(m_page); |
877 | 892 |
878 if (!coordinatesScrollingForFrameView(frameView)) | 893 if (!coordinatesScrollingForFrameView(frameView)) |
879 return; | 894 return; |
880 | 895 |
881 m_shouldScrollOnMainThreadDirty = true; | 896 m_shouldScrollOnMainThreadDirty = true; |
882 } | 897 } |
883 | 898 |
884 bool ScrollingCoordinator::isForMainFrame(ScrollableArea* scrollableArea) const | 899 bool ScrollingCoordinator::isForMainFrame(ScrollableArea* scrollableArea) const |
885 { | 900 { |
886 return scrollableArea == m_page->mainFrame()->view(); | 901 return m_page->mainFrame()->isLocalFrame() ? scrollableArea == toLocalFrame(
m_page->mainFrame())->view() : false; |
887 } | 902 } |
888 | 903 |
889 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) | 904 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) |
890 { | 905 { |
891 ASSERT(isMainThread()); | 906 ASSERT(isMainThread()); |
892 ASSERT(m_page); | 907 ASSERT(m_page); |
893 | 908 |
894 if (!coordinatesScrollingForFrameView(frameView)) | 909 if (!coordinatesScrollingForFrameView(frameView)) |
895 return; | 910 return; |
896 | 911 |
897 notifyLayoutUpdated(); | 912 notifyLayoutUpdated(); |
898 updateHaveWheelEventHandlers(); | 913 updateHaveWheelEventHandlers(); |
899 updateHaveScrollEventHandlers(); | 914 updateHaveScrollEventHandlers(); |
900 } | 915 } |
901 | 916 |
902 #if OS(MACOSX) | 917 #if OS(MACOSX) |
903 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) | 918 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) |
904 { | 919 { |
905 ASSERT(isMainThread()); | 920 ASSERT(isMainThread()); |
906 | 921 |
907 if (!m_page) | 922 if (!m_page) |
908 return; | 923 return; |
909 | 924 |
910 FrameView* frameView = m_page->mainFrame()->view(); | 925 FrameView* frameView = toLocalFrame(m_page->mainFrame())->view(); |
911 if (!frameView) | 926 if (!frameView) |
912 return; | 927 return; |
913 | 928 |
914 frameView->scrollAnimator()->handleWheelEventPhase(phase); | 929 frameView->scrollAnimator()->handleWheelEventPhase(phase); |
915 } | 930 } |
916 #endif | 931 #endif |
917 | 932 |
918 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
View* frameView) const | 933 bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(Frame
View* frameView) const |
919 { | 934 { |
920 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects =
frameView->viewportConstrainedObjects(); | 935 const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects =
frameView->viewportConstrainedObjects(); |
(...skipping 15 matching lines...) Expand all Loading... |
936 return true; | 951 return true; |
937 } | 952 } |
938 return false; | 953 return false; |
939 } | 954 } |
940 | 955 |
941 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co
nst | 956 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co
nst |
942 { | 957 { |
943 // The main thread scrolling reasons are applicable to scrolls of the main | 958 // The main thread scrolling reasons are applicable to scrolls of the main |
944 // frame. If it does not exist or if it is not scrollable, there is no | 959 // frame. If it does not exist or if it is not scrollable, there is no |
945 // reason to force main thread scrolling. | 960 // reason to force main thread scrolling. |
946 FrameView* frameView = m_page->mainFrame()->view(); | 961 if (!m_page->mainFrame()->isLocalFrame()) |
| 962 return static_cast<MainThreadScrollingReasons>(0); |
| 963 FrameView* frameView = toLocalFrame(m_page->mainFrame())->view(); |
947 if (!frameView) | 964 if (!frameView) |
948 return static_cast<MainThreadScrollingReasons>(0); | 965 return static_cast<MainThreadScrollingReasons>(0); |
949 | 966 |
950 MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrolling
Reasons)0; | 967 MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrolling
Reasons)0; |
951 | 968 |
952 if (frameView->hasSlowRepaintObjects()) | 969 if (frameView->hasSlowRepaintObjects()) |
953 mainThreadScrollingReasons |= HasSlowRepaintObjects; | 970 mainThreadScrollingReasons |= HasSlowRepaintObjects; |
954 if (hasVisibleSlowRepaintViewportConstrainedObjects(frameView)) | 971 if (hasVisibleSlowRepaintViewportConstrainedObjects(frameView)) |
955 mainThreadScrollingReasons |= HasNonLayerViewportConstrainedObjects; | 972 mainThreadScrollingReasons |= HasNonLayerViewportConstrainedObjects; |
956 | 973 |
(...skipping 11 matching lines...) Expand all Loading... |
968 if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects) | 985 if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects) |
969 stringBuilder.append("Has non-layer viewport-constrained objects, "); | 986 stringBuilder.append("Has non-layer viewport-constrained objects, "); |
970 | 987 |
971 if (stringBuilder.length()) | 988 if (stringBuilder.length()) |
972 stringBuilder.resize(stringBuilder.length() - 2); | 989 stringBuilder.resize(stringBuilder.length() - 2); |
973 return stringBuilder.toString(); | 990 return stringBuilder.toString(); |
974 } | 991 } |
975 | 992 |
976 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 993 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
977 { | 994 { |
978 ASSERT(m_page->mainFrame()->document()->lifecycle().state() >= DocumentLifec
ycle::CompositingClean); | 995 ASSERT(toLocalFrame(m_page->mainFrame())->document()->lifecycle().state() >=
DocumentLifecycle::CompositingClean); |
979 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); | 996 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); |
980 } | 997 } |
981 | 998 |
982 bool ScrollingCoordinator::frameViewIsDirty() const | 999 bool ScrollingCoordinator::frameViewIsDirty() const |
983 { | 1000 { |
984 FrameView* frameView = m_page->mainFrame()->view(); | 1001 FrameView* frameView = m_page->mainFrame()->isLocalFrame() ? toLocalFrame(m_
page->mainFrame())->view() : 0; |
985 bool frameIsScrollable = frameView && frameView->isScrollable(); | 1002 bool frameIsScrollable = frameView && frameView->isScrollable(); |
986 if (frameIsScrollable != m_wasFrameScrollable) | 1003 if (frameIsScrollable != m_wasFrameScrollable) |
987 return true; | 1004 return true; |
988 | 1005 |
989 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : 0) | 1006 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : 0) |
990 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds(
); | 1007 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds(
); |
991 return false; | 1008 return false; |
992 } | 1009 } |
993 | 1010 |
994 } // namespace WebCore | 1011 } // namespace WebCore |
OLD | NEW |