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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | 91 , m_scrollGestureRegionIsDirty(false) |
92 , m_touchEventTargetRectsAreDirty(false) | 92 , m_touchEventTargetRectsAreDirty(false) |
93 , m_wasFrameScrollable(false) | |
94 , m_lastMainThreadScrollingReasons(0) | |
95 { | 93 { |
96 } | 94 } |
97 | 95 |
98 ScrollingCoordinator::~ScrollingCoordinator() | 96 ScrollingCoordinator::~ScrollingCoordinator() |
99 { | 97 { |
100 ASSERT(!m_page); | 98 ASSERT(!m_page); |
101 for (ScrollbarMap::iterator it = m_horizontalScrollbars.begin(); it != m_hor
izontalScrollbars.end(); ++it) | 99 for (ScrollbarMap::iterator it = m_horizontalScrollbars.begin(); it != m_hor
izontalScrollbars.end(); ++it) |
102 GraphicsLayer::unregisterContentsLayer(it->value->layer()); | 100 GraphicsLayer::unregisterContentsLayer(it->value->layer()); |
103 for (ScrollbarMap::iterator it = m_verticalScrollbars.begin(); it != m_verti
calScrollbars.end(); ++it) | 101 for (ScrollbarMap::iterator it = m_verticalScrollbars.begin(); it != m_verti
calScrollbars.end(); ++it) |
104 GraphicsLayer::unregisterContentsLayer(it->value->layer()); | 102 GraphicsLayer::unregisterContentsLayer(it->value->layer()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandle
ScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); | 144 Region shouldHandleScrollGestureOnMainThreadRegion = computeShouldHandle
ScrollGestureOnMainThreadRegion(m_page->mainFrame(), IntPoint()); |
147 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture
OnMainThreadRegion); | 145 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture
OnMainThreadRegion); |
148 m_scrollGestureRegionIsDirty = false; | 146 m_scrollGestureRegionIsDirty = false; |
149 } | 147 } |
150 | 148 |
151 if (m_touchEventTargetRectsAreDirty) { | 149 if (m_touchEventTargetRectsAreDirty) { |
152 updateTouchEventTargetRectsIfNeeded(); | 150 updateTouchEventTargetRectsIfNeeded(); |
153 m_touchEventTargetRectsAreDirty = false; | 151 m_touchEventTargetRectsAreDirty = false; |
154 } | 152 } |
155 | 153 |
156 FrameView* frameView = m_page->mainFrame()->view(); | |
157 bool frameIsScrollable = frameView && frameView->isScrollable(); | |
158 if (m_wasFrameScrollable != frameIsScrollable) | |
159 updateShouldUpdateScrollLayerPositionOnMainThread(); | |
160 m_wasFrameScrollable = frameIsScrollable; | |
161 | |
162 const FrameTree& tree = m_page->mainFrame()->tree(); | 154 const FrameTree& tree = m_page->mainFrame()->tree(); |
163 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { | 155 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne
xtSibling()) { |
164 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->vi
ew())) | 156 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->vi
ew())) |
165 scrollLayer->setBounds(child->view()->contentsSize()); | 157 scrollLayer->setBounds(child->view()->contentsSize()); |
166 } | 158 } |
167 } | 159 } |
168 | 160 |
169 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
er* layer, bool enable) | 161 void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
er* layer, bool enable) |
170 { | 162 { |
171 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) | 163 if (WebLayer* scrollableLayer = scrollingWebLayerForGraphicsLayer(layer)) |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 586 } |
595 | 587 |
596 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView
* frameView) | 588 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView
* frameView) |
597 { | 589 { |
598 UNUSED_PARAM(frameView); | 590 UNUSED_PARAM(frameView); |
599 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); | 591 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); |
600 } | 592 } |
601 | 593 |
602 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh
readScrollingReasons reasons) | 594 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh
readScrollingReasons reasons) |
603 { | 595 { |
604 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) { | 596 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF
rame()->view())) |
605 m_lastMainThreadScrollingReasons = reasons; | |
606 scrollLayer->setShouldScrollOnMainThread(reasons); | 597 scrollLayer->setShouldScrollOnMainThread(reasons); |
607 } | |
608 } | 598 } |
609 | 599 |
610 void ScrollingCoordinator::pageDestroyed() | 600 void ScrollingCoordinator::pageDestroyed() |
611 { | 601 { |
612 ASSERT(m_page); | 602 ASSERT(m_page); |
613 m_page = 0; | 603 m_page = 0; |
614 } | 604 } |
615 | 605 |
616 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
) const | 606 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView
) const |
617 { | 607 { |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 // Composited layers that actually paint into their enclosing ancestor | 852 // Composited layers that actually paint into their enclosing ancestor |
863 // must also force main thread scrolling. | 853 // must also force main thread scrolling. |
864 if (layer->compositingState() == HasOwnBackingButPaintsIntoAncestor) | 854 if (layer->compositingState() == HasOwnBackingButPaintsIntoAncestor) |
865 return true; | 855 return true; |
866 } | 856 } |
867 return false; | 857 return false; |
868 } | 858 } |
869 | 859 |
870 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co
nst | 860 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co
nst |
871 { | 861 { |
872 // The main thread scrolling reasons are applicable to scrolls of the main | |
873 // frame. If it does not exist or if it is not scrollable, there is no | |
874 // reason to force main thread scrolling. | |
875 FrameView* frameView = m_page->mainFrame()->view(); | 862 FrameView* frameView = m_page->mainFrame()->view(); |
876 if (!frameView || !frameView->isScrollable()) | 863 if (!frameView) |
877 return static_cast<MainThreadScrollingReasons>(0); | 864 return static_cast<MainThreadScrollingReasons>(0); |
878 | 865 |
879 MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrolling
Reasons)0; | 866 MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrolling
Reasons)0; |
880 | 867 |
881 if (frameView->hasSlowRepaintObjects()) | 868 if (frameView->hasSlowRepaintObjects()) |
882 mainThreadScrollingReasons |= HasSlowRepaintObjects; | 869 mainThreadScrollingReasons |= HasSlowRepaintObjects; |
883 if (hasVisibleSlowRepaintViewportConstrainedObjects(frameView)) | 870 if (hasVisibleSlowRepaintViewportConstrainedObjects(frameView)) |
884 mainThreadScrollingReasons |= HasNonLayerViewportConstrainedObjects; | 871 mainThreadScrollingReasons |= HasNonLayerViewportConstrainedObjects; |
885 | 872 |
886 return mainThreadScrollingReasons; | 873 return mainThreadScrollingReasons; |
(...skipping 15 matching lines...) Expand all Loading... |
902 if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects) | 889 if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects) |
903 stringBuilder.append("Has non-layer viewport-constrained objects, "); | 890 stringBuilder.append("Has non-layer viewport-constrained objects, "); |
904 | 891 |
905 if (stringBuilder.length()) | 892 if (stringBuilder.length()) |
906 stringBuilder.resize(stringBuilder.length() - 2); | 893 stringBuilder.resize(stringBuilder.length() - 2); |
907 return stringBuilder.toString(); | 894 return stringBuilder.toString(); |
908 } | 895 } |
909 | 896 |
910 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 897 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
911 { | 898 { |
912 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); | 899 return mainThreadScrollingReasonsAsText(mainThreadScrollingReasons()); |
913 } | 900 } |
914 | 901 |
915 } // namespace WebCore | 902 } // namespace WebCore |
OLD | NEW |