Changeset 107168 in webkit
- Timestamp:
- Feb 8, 2012, 7:02:25 PM (15 years ago)
- Location:
- trunk/Source
- Files:
-
- 13 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/FrameView.cpp (modified) (1 diff)
-
WebCore/page/FrameView.h (modified) (1 diff)
-
WebCore/rendering/RenderLayer.cpp (modified) (1 diff)
-
WebCore/rendering/RenderLayer.h (modified) (1 diff)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/UIProcess/WebPageProxy.cpp (modified) (2 diffs)
-
WebKit2/UIProcess/WebPageProxy.h (modified) (2 diffs)
-
WebKit2/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
WebKit2/WebProcess/WebPage/WebPage.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r107162 r107168 1 2012-02-08 Anders Carlsson <andersca@apple.com> 2 3 Don't use the wheel event handler count to track if a page has horizontal scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=78192 5 6 Reviewed by Andreas Kling. 7 8 Stop calling Document::didAddWheelEventHandler and Document::didRemoveWheelEventHandler when 9 adding and removing scrollbars. 10 11 * page/FrameView.cpp: 12 * page/FrameView.h: 13 (FrameView): 14 * rendering/RenderLayer.cpp: 15 * rendering/RenderLayer.h: 16 1 17 2012-02-08 Igor Oliveira <igor.o@sisa.samsung.com> 2 18 -
trunk/Source/WebCore/page/FrameView.cpp
r107102 r107168 322 322 } 323 323 324 void FrameView::didAddHorizontalScrollbar(Scrollbar* scrollbar)325 {326 if (m_frame && m_frame->document())327 m_frame->document()->didAddWheelEventHandler();328 ScrollView::didAddHorizontalScrollbar(scrollbar);329 }330 331 void FrameView::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)332 {333 ScrollView::willRemoveHorizontalScrollbar(scrollbar);334 // FIXME: maybe need a separate ScrollableArea::didRemoveHorizontalScrollbar callback?335 if (m_frame && m_frame->document())336 m_frame->document()->didRemoveWheelEventHandler();337 }338 339 324 void FrameView::recalculateScrollbarOverlayStyle() 340 325 { -
trunk/Source/WebCore/page/FrameView.h
r107001 r107168 87 87 88 88 virtual bool avoidScrollbarCreation() const; 89 virtual void didAddHorizontalScrollbar(Scrollbar*);90 virtual void willRemoveHorizontalScrollbar(Scrollbar*);91 89 92 90 virtual void setContentsSize(const IntSize&); -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r107072 r107168 2062 2062 } 2063 2063 2064 void RenderLayer::didAddHorizontalScrollbar(Scrollbar* scrollbar)2065 {2066 m_renderer->document()->didAddWheelEventHandler();2067 ScrollableArea::didAddHorizontalScrollbar(scrollbar);2068 }2069 2070 void RenderLayer::willRemoveHorizontalScrollbar(Scrollbar* scrollbar)2071 {2072 ScrollableArea::willRemoveHorizontalScrollbar(scrollbar);2073 // FIXME: maybe need a separate ScrollableArea::didRemoveHorizontalScrollbar callback?2074 m_renderer->document()->didRemoveWheelEventHandler();2075 }2076 2077 2064 void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar) 2078 2065 { -
trunk/Source/WebCore/rendering/RenderLayer.h
r107032 r107168 313 313 bool allowsScrolling() const; // Returns true if at least one scrollbar is visible and enabled. 314 314 bool hasScrollbars() const { return m_hBar || m_vBar; } 315 virtual void didAddHorizontalScrollbar(Scrollbar*);316 virtual void willRemoveHorizontalScrollbar(Scrollbar*);317 315 void setHasHorizontalScrollbar(bool); 318 316 void setHasVerticalScrollbar(bool); -
trunk/Source/WebKit2/ChangeLog
r107101 r107168 1 2012-02-08 Anders Carlsson <andersca@apple.com> 2 3 Don't use the wheel event handler count to track if a page has horizontal scrollbars 4 https://bugs.webkit.org/show_bug.cgi?id=78192 5 6 Reviewed by Andreas Kling. 7 8 Prior to this change, we were incrementing and decrementing the wheel event handler count 9 whenever a scrollable area gained or lost a horizontal scrollbar, so we could use the count 10 to determine if Safari can handle horizontal wheel events directly or whether they have to be sent 11 to the web process first. 12 13 What this meant was that whenever a page had horizontal scrollbars we'd have to send all scroll wheel events 14 to the main thread instead of the scrolling thread, regardless of whether there were any wheel event handlers. 15 16 After this change, we traverse the tree of scrollable areas after every layout and check if any of them 17 have a horizontal scrollbar. (We still also check if there are wheel event handlers). 18 19 If traversing the tree after every layout is deemed to slow we can go back to caching the number of horizontal scrollbars 20 in a page, but the number of subframes in a page is usually very small and the number of other scrollable areas is even smaller. 21 22 * UIProcess/WebPageProxy.cpp: 23 (WebKit::WebPageProxy::WebPageProxy): 24 (WebKit::WebPageProxy::willHandleHorizontalScrollEvents): 25 * UIProcess/WebPageProxy.h: 26 (WebKit::WebPageProxy::setCanShortCircuitHorizontalWheelEvents): 27 (WebPageProxy): 28 * UIProcess/WebPageProxy.messages.in: 29 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 30 (WebKit::WebChromeClient::numWheelEventHandlersChanged): 31 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: 32 (WebKit::WebFrameLoaderClient::dispatchDidLayout): 33 * WebProcess/WebPage/WebPage.cpp: 34 (WebKit::WebPage::WebPage): 35 (WebKit::WebPage::numWheelEventHandlersChanged): 36 (WebKit): 37 (WebKit::hasEnabledHorizontalScrollbar): 38 (WebKit::pageContainsAnyHorizontalScrollbars): 39 (WebKit::WebPage::recomputeShortCircuitHorizontalWheelEventsState): 40 * WebProcess/WebPage/WebPage.h: 41 (WebPage): 42 1 43 2012-02-08 Sheriff Bot <webkit.review.bot@gmail.com> 2 44 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r107068 r107168 196 196 , m_mainFrameHasHorizontalScrollbar(false) 197 197 , m_mainFrameHasVerticalScrollbar(false) 198 , m_canShortCircuitHorizontalWheelEvents(true) 198 199 , m_mainFrameIsPinnedToLeftSide(false) 199 200 , m_mainFrameIsPinnedToRightSide(false) … … 3457 3458 bool WebPageProxy::willHandleHorizontalScrollEvents() const 3458 3459 { 3459 return m_wheelEventHandlerCount > 0;3460 return !m_canShortCircuitHorizontalWheelEvents; 3460 3461 } 3461 3462 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r107068 r107168 720 720 void didChangePageCount(unsigned); 721 721 void didFailToInitializePlugin(const String& mimeType); 722 void numWheelEventHandlersChanged(unsigned count) { m_wheelEventHandlerCount = count; }722 void setCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents) { m_canShortCircuitHorizontalWheelEvents = canShortCircuitHorizontalWheelEvents; } 723 723 724 724 void reattachToWebProcess(); … … 1010 1010 bool m_mainFrameHasHorizontalScrollbar; 1011 1011 bool m_mainFrameHasVerticalScrollbar; 1012 int m_wheelEventHandlerCount; 1012 1013 // Whether horizontal wheel events can be handled directly for swiping purposes. 1014 bool m_canShortCircuitHorizontalWheelEvents; 1013 1015 1014 1016 bool m_mainFrameIsPinnedToLeftSide; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r107068 r107168 67 67 DidChangePageCount(unsigned pageCount); 68 68 DidFailToInitializePlugin(WTF::String mimeType) 69 NumWheelEventHandlersChanged(unsigned count)69 SetCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents) 70 70 71 71 #if USE(TILED_BACKING_STORE) -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
r103565 r107168 781 781 void WebChromeClient::numWheelEventHandlersChanged(unsigned count) 782 782 { 783 m_page-> send(Messages::WebPageProxy::NumWheelEventHandlersChanged(count));783 m_page->numWheelEventHandlersChanged(count); 784 784 } 785 785 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r106761 r107168 578 578 webPage->injectedBundleLoaderClient().didLayoutForFrame(webPage, m_frame); 579 579 580 webPage->recomputeShortCircuitHorizontalWheelEventsState(); 581 580 582 // NOTE: Unlike the other layout notifications, this does not notify the 581 583 // the UIProcess for every call. -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r106875 r107168 207 207 , m_cachedMainFrameIsPinnedToLeftSide(false) 208 208 , m_cachedMainFrameIsPinnedToRightSide(false) 209 , m_canShortCircuitHorizontalWheelEvents(false) 210 , m_numWheelEventHandlers(0) 209 211 , m_cachedPageCount(0) 210 212 , m_isShowingContextMenu(false) … … 3001 3003 } 3002 3004 3005 void WebPage::numWheelEventHandlersChanged(unsigned numWheelEventHandlers) 3006 { 3007 if (m_numWheelEventHandlers == numWheelEventHandlers) 3008 return; 3009 3010 m_numWheelEventHandlers = numWheelEventHandlers; 3011 recomputeShortCircuitHorizontalWheelEventsState(); 3012 } 3013 3014 static bool hasEnabledHorizontalScrollbar(ScrollableArea* scrollableArea) 3015 { 3016 if (Scrollbar* scrollbar = scrollableArea->horizontalScrollbar()) 3017 return scrollbar->enabled(); 3018 3019 return false; 3020 } 3021 3022 static bool pageContainsAnyHorizontalScrollbars(Frame* mainFrame) 3023 { 3024 if (FrameView* frameView = mainFrame->view()) { 3025 if (hasEnabledHorizontalScrollbar(frameView)) 3026 return true; 3027 } 3028 3029 for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext()) { 3030 FrameView* frameView = frame->view(); 3031 if (!frameView) 3032 continue; 3033 3034 const HashSet<ScrollableArea*>* scrollableAreas = frameView->scrollableAreas(); 3035 if (!scrollableAreas) 3036 continue; 3037 3038 for (HashSet<ScrollableArea*>::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) { 3039 ScrollableArea* scrollableArea = *it; 3040 ASSERT(scrollableArea->isOnActivePage()); 3041 3042 if (hasEnabledHorizontalScrollbar(scrollableArea)) 3043 return true; 3044 } 3045 } 3046 3047 return false; 3048 } 3049 3050 void WebPage::recomputeShortCircuitHorizontalWheelEventsState() 3051 { 3052 bool canShortCircuitHorizontalWheelEvents = !m_numWheelEventHandlers; 3053 3054 if (canShortCircuitHorizontalWheelEvents) { 3055 // Check if we have any horizontal scroll bars on the page. 3056 if (pageContainsAnyHorizontalScrollbars(mainFrame())) 3057 canShortCircuitHorizontalWheelEvents = false; 3058 } 3059 3060 if (m_canShortCircuitHorizontalWheelEvents == canShortCircuitHorizontalWheelEvents) 3061 return; 3062 3063 m_canShortCircuitHorizontalWheelEvents = canShortCircuitHorizontalWheelEvents; 3064 send(Messages::WebPageProxy::SetCanShortCircuitHorizontalWheelEvents(m_canShortCircuitHorizontalWheelEvents)); 3065 } 3066 3003 3067 Frame* WebPage::mainFrame() const 3004 3068 { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r106800 r107168 501 501 #endif 502 502 503 void numWheelEventHandlersChanged(unsigned); 504 void recomputeShortCircuitHorizontalWheelEventsState(); 505 503 506 private: 504 507 WebPage(uint64_t pageID, const WebPageCreationParameters&); … … 757 760 bool m_cachedMainFrameIsPinnedToLeftSide; 758 761 bool m_cachedMainFrameIsPinnedToRightSide; 762 bool m_canShortCircuitHorizontalWheelEvents; 763 unsigned m_numWheelEventHandlers; 759 764 760 765 unsigned m_cachedPageCount;
Note:
See TracChangeset
for help on using the changeset viewer.