Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 using blink::WebVector; | 67 using blink::WebVector; |
| 68 | 68 |
| 69 | 69 |
| 70 namespace WebCore { | 70 namespace WebCore { |
| 71 | 71 |
| 72 static WebLayer* scrollingWebLayerForGraphicsLayer(GraphicsLayer* layer) | 72 static WebLayer* scrollingWebLayerForGraphicsLayer(GraphicsLayer* layer) |
| 73 { | 73 { |
| 74 return layer->platformLayer(); | 74 return layer->platformLayer(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static bool frameViewCouldBeScrolledByImplThread(FrameView* frameView) | |
| 78 { | |
| 79 // A frame view will report that isScrollable is false if overflow is hidden , but it may still | |
| 80 // end up getting scrolled on the impl thread. | |
| 81 return frameView && frameView->hasOverflow() && frameView->isVisibleToHitTes ting(); | |
| 82 } | |
| 83 | |
| 77 WebLayer* ScrollingCoordinator::scrollingWebLayerForScrollableArea(ScrollableAre a* scrollableArea) | 84 WebLayer* ScrollingCoordinator::scrollingWebLayerForScrollableArea(ScrollableAre a* scrollableArea) |
| 78 { | 85 { |
| 79 GraphicsLayer* graphicsLayer = scrollLayerForScrollableArea(scrollableArea); | 86 GraphicsLayer* graphicsLayer = scrollLayerForScrollableArea(scrollableArea); |
| 80 return graphicsLayer ? scrollingWebLayerForGraphicsLayer(graphicsLayer) : 0; | 87 return graphicsLayer ? scrollingWebLayerForGraphicsLayer(graphicsLayer) : 0; |
| 81 } | 88 } |
| 82 | 89 |
| 83 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) | 90 PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) |
| 84 { | 91 { |
| 85 return adoptRef(new ScrollingCoordinator(page)); | 92 return adoptRef(new ScrollingCoordinator(page)); |
| 86 } | 93 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture OnMainThreadRegion); | 153 setShouldHandleScrollGestureOnMainThreadRegion(shouldHandleScrollGesture OnMainThreadRegion); |
| 147 m_scrollGestureRegionIsDirty = false; | 154 m_scrollGestureRegionIsDirty = false; |
| 148 } | 155 } |
| 149 | 156 |
| 150 if (m_touchEventTargetRectsAreDirty) { | 157 if (m_touchEventTargetRectsAreDirty) { |
| 151 updateTouchEventTargetRectsIfNeeded(); | 158 updateTouchEventTargetRectsIfNeeded(); |
| 152 m_touchEventTargetRectsAreDirty = false; | 159 m_touchEventTargetRectsAreDirty = false; |
| 153 } | 160 } |
| 154 | 161 |
| 155 FrameView* frameView = m_page->mainFrame()->view(); | 162 FrameView* frameView = m_page->mainFrame()->view(); |
| 156 bool frameIsScrollable = frameView && frameView->isScrollable(); | 163 bool frameIsScrollable = frameViewCouldBeScrolledByImplThread(frameView); |
| 157 if (m_wasFrameScrollable != frameIsScrollable) | 164 if (m_wasFrameScrollable != frameIsScrollable) |
| 158 updateShouldUpdateScrollLayerPositionOnMainThread(); | 165 updateShouldUpdateScrollLayerPositionOnMainThread(); |
| 159 m_wasFrameScrollable = frameIsScrollable; | 166 m_wasFrameScrollable = frameIsScrollable; |
| 160 | 167 |
| 161 const FrameTree& tree = m_page->mainFrame()->tree(); | 168 const FrameTree& tree = m_page->mainFrame()->tree(); |
| 162 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne xtSibling()) { | 169 for (const Frame* child = tree.firstChild(); child; child = child->tree().ne xtSibling()) { |
| 163 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->vi ew())) | 170 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(child->vi ew())) |
| 164 scrollLayer->setBounds(child->view()->contentsSize()); | 171 scrollLayer->setBounds(child->view()->contentsSize()); |
| 165 } | 172 } |
| 166 } | 173 } |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 { | 615 { |
| 609 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); | 616 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); |
| 610 } | 617 } |
| 611 | 618 |
| 612 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons reasons) | 619 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons reasons) |
| 613 { | 620 { |
| 614 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF rame()->view())) { | 621 if (WebLayer* scrollLayer = scrollingWebLayerForScrollableArea(m_page->mainF rame()->view())) { |
| 615 m_lastMainThreadScrollingReasons = reasons; | 622 m_lastMainThreadScrollingReasons = reasons; |
| 616 scrollLayer->setShouldScrollOnMainThread(reasons); | 623 scrollLayer->setShouldScrollOnMainThread(reasons); |
| 617 } | 624 } |
| 625 | |
| 626 // We may be ignoring main thread scrolling reasons if the main thread claim s it cannot be scrolled. Check for this case. | |
|
shawnsingh
2013/12/17 09:05:11
misplaced comment? or should this be labeled as a
| |
| 618 } | 627 } |
| 619 | 628 |
| 620 void ScrollingCoordinator::pageDestroyed() | 629 void ScrollingCoordinator::pageDestroyed() |
| 621 { | 630 { |
| 622 ASSERT(m_page); | 631 ASSERT(m_page); |
| 623 m_page = 0; | 632 m_page = 0; |
| 624 } | 633 } |
| 625 | 634 |
| 626 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView ) const | 635 bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView ) const |
| 627 { | 636 { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 } | 885 } |
| 877 return false; | 886 return false; |
| 878 } | 887 } |
| 879 | 888 |
| 880 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co nst | 889 MainThreadScrollingReasons ScrollingCoordinator::mainThreadScrollingReasons() co nst |
| 881 { | 890 { |
| 882 // The main thread scrolling reasons are applicable to scrolls of the main | 891 // The main thread scrolling reasons are applicable to scrolls of the main |
| 883 // frame. If it does not exist or if it is not scrollable, there is no | 892 // frame. If it does not exist or if it is not scrollable, there is no |
| 884 // reason to force main thread scrolling. | 893 // reason to force main thread scrolling. |
| 885 FrameView* frameView = m_page->mainFrame()->view(); | 894 FrameView* frameView = m_page->mainFrame()->view(); |
| 886 if (!frameView || !frameView->isScrollable()) | 895 if (!frameView || !frameViewCouldBeScrolledByImplThread(frameView)) |
| 887 return static_cast<MainThreadScrollingReasons>(0); | 896 return static_cast<MainThreadScrollingReasons>(0); |
| 888 | 897 |
| 889 MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrolling Reasons)0; | 898 MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrolling Reasons)0; |
| 890 | 899 |
| 891 if (frameView->hasSlowRepaintObjects()) | 900 if (frameView->hasSlowRepaintObjects()) |
| 892 mainThreadScrollingReasons |= HasSlowRepaintObjects; | 901 mainThreadScrollingReasons |= HasSlowRepaintObjects; |
| 893 if (hasVisibleSlowRepaintViewportConstrainedObjects(frameView)) | 902 if (hasVisibleSlowRepaintViewportConstrainedObjects(frameView)) |
| 894 mainThreadScrollingReasons |= HasNonLayerViewportConstrainedObjects; | 903 mainThreadScrollingReasons |= HasNonLayerViewportConstrainedObjects; |
| 895 | 904 |
| 896 return mainThreadScrollingReasons; | 905 return mainThreadScrollingReasons; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 918 } | 927 } |
| 919 | 928 |
| 920 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const | 929 String ScrollingCoordinator::mainThreadScrollingReasonsAsText() const |
| 921 { | 930 { |
| 922 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); | 931 return mainThreadScrollingReasonsAsText(m_lastMainThreadScrollingReasons); |
| 923 } | 932 } |
| 924 | 933 |
| 925 bool ScrollingCoordinator::frameViewIsScrollableIsDirty() const | 934 bool ScrollingCoordinator::frameViewIsScrollableIsDirty() const |
| 926 { | 935 { |
| 927 FrameView* frameView = m_page->mainFrame()->view(); | 936 FrameView* frameView = m_page->mainFrame()->view(); |
| 928 bool frameIsScrollable = frameView && frameView->isScrollable(); | 937 bool frameIsScrollable = frameViewCouldBeScrolledByImplThread(frameView); |
| 929 return frameIsScrollable != m_wasFrameScrollable; | 938 return frameIsScrollable != m_wasFrameScrollable; |
| 930 } | 939 } |
| 931 | 940 |
| 932 } // namespace WebCore | 941 } // namespace WebCore |
| OLD | NEW |