Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: Source/core/page/scrolling/ScrollingCoordinator.cpp

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Refactoring WIP. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 11 matching lines...) Expand all
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 27
28 #include "core/page/scrolling/ScrollingCoordinator.h" 28 #include "core/page/scrolling/ScrollingCoordinator.h"
29 29
30 #include "RuntimeEnabledFeatures.h" 30 #include "RuntimeEnabledFeatures.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/EventHandlerRegistry.h"
32 #include "core/dom/Node.h" 33 #include "core/dom/Node.h"
33 #include "core/dom/WheelController.h"
34 #include "core/html/HTMLElement.h" 34 #include "core/html/HTMLElement.h"
35 #include "core/frame/FrameView.h" 35 #include "core/frame/FrameView.h"
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/page/Page.h" 37 #include "core/page/Page.h"
38 #include "core/frame/Settings.h" 38 #include "core/frame/Settings.h"
39 #include "platform/TraceEvent.h" 39 #include "platform/TraceEvent.h"
40 #include "platform/exported/WebScrollbarImpl.h" 40 #include "platform/exported/WebScrollbarImpl.h"
41 #include "platform/exported/WebScrollbarThemeGeometryNative.h" 41 #include "platform/exported/WebScrollbarThemeGeometryNative.h"
42 #include "platform/geometry/Region.h" 42 #include "platform/geometry/Region.h"
43 #include "platform/geometry/TransformState.h" 43 #include "platform/geometry/TransformState.h"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 { 616 {
617 m_layersWithTouchRects.remove(layer); 617 m_layersWithTouchRects.remove(layer);
618 } 618 }
619 619
620 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) 620 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count)
621 { 621 {
622 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor Scrolling())) 622 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor Scrolling()))
623 scrollLayer->setHaveWheelEventHandlers(count > 0); 623 scrollLayer->setHaveWheelEventHandlers(count > 0);
624 } 624 }
625 625
626 void ScrollingCoordinator::setScrollEventHandlerCount(unsigned count)
627 {
628 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor Scrolling()))
629 scrollLayer->setHaveScrollEventHandlers(count > 0);
630 }
631
626 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView *) 632 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView *)
627 { 633 {
628 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); 634 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount());
629 } 635 }
630 636
637 void ScrollingCoordinator::recomputeScrollEventHandlerCountForFrameView(FrameVie w*)
Rick Byers 2014/03/24 14:27:59 What you're doing here seems conceptually similar
638 {
639 setScrollEventHandlerCount(computeCurrentScrollEventHandlerCount());
640 }
641
631 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons reasons) 642 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh readScrollingReasons reasons)
632 { 643 {
633 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor Scrolling())) { 644 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor Scrolling())) {
634 m_lastMainThreadScrollingReasons = reasons; 645 m_lastMainThreadScrollingReasons = reasons;
635 scrollLayer->setShouldScrollOnMainThread(reasons); 646 scrollLayer->setShouldScrollOnMainThread(reasons);
636 } 647 }
637 } 648 }
638 649
639 void ScrollingCoordinator::pageDestroyed() 650 void ScrollingCoordinator::pageDestroyed()
640 { 651 {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 795
785 accumulateDocumentTouchEventTargetRects(rects, document); 796 accumulateDocumentTouchEventTargetRects(rects, document);
786 } 797 }
787 798
788 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount() 799 unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount()
789 { 800 {
790 unsigned wheelEventHandlerCount = 0; 801 unsigned wheelEventHandlerCount = 0;
791 802
792 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t raverseNext()) { 803 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t raverseNext()) {
793 if (frame->document()) 804 if (frame->document())
794 wheelEventHandlerCount += WheelController::from(*frame->document())- >wheelEventHandlerCount(); 805 wheelEventHandlerCount += EventHandlerRegistry::from(*frame->documen t())->wheelEventHandlerCount();
795 } 806 }
796 807
797 return wheelEventHandlerCount; 808 return wheelEventHandlerCount;
798 } 809 }
799 810
811 unsigned ScrollingCoordinator::computeCurrentScrollEventHandlerCount()
812 {
813 unsigned scrollEventHandlerCount = 0;
814
815 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t raverseNext()) {
816 if (frame->document())
817 scrollEventHandlerCount += EventHandlerRegistry::from(*frame->docume nt())->scrollEventHandlerCount();
818 }
819
820 return scrollEventHandlerCount;
821 }
822
800 void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView* fra meView) 823 void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView* fra meView)
801 { 824 {
802 ASSERT(isMainThread()); 825 ASSERT(isMainThread());
803 ASSERT(m_page); 826 ASSERT(m_page);
804 827
805 recomputeWheelEventHandlerCountForFrameView(frameView); 828 recomputeWheelEventHandlerCountForFrameView(frameView);
806 } 829 }
807 830
831 void ScrollingCoordinator::frameViewScrollEventHandlerCountChanged(FrameView* fr ameView)
832 {
833 ASSERT(isMainThread());
834 ASSERT(m_page);
835
836 recomputeScrollEventHandlerCountForFrameView(frameView);
837 }
838
808 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* fr ameView) 839 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* fr ameView)
809 { 840 {
810 ASSERT(isMainThread()); 841 ASSERT(isMainThread());
811 ASSERT(m_page); 842 ASSERT(m_page);
812 843
813 if (!coordinatesScrollingForFrameView(frameView)) 844 if (!coordinatesScrollingForFrameView(frameView))
814 return; 845 return;
815 846
816 m_shouldScrollOnMainThreadDirty = true; 847 m_shouldScrollOnMainThreadDirty = true;
817 } 848 }
(...skipping 30 matching lines...) Expand all
848 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) 879 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
849 { 880 {
850 ASSERT(isMainThread()); 881 ASSERT(isMainThread());
851 ASSERT(m_page); 882 ASSERT(m_page);
852 883
853 if (!coordinatesScrollingForFrameView(frameView)) 884 if (!coordinatesScrollingForFrameView(frameView))
854 return; 885 return;
855 886
856 notifyLayoutUpdated(); 887 notifyLayoutUpdated();
857 recomputeWheelEventHandlerCountForFrameView(frameView); 888 recomputeWheelEventHandlerCountForFrameView(frameView);
889 recomputeScrollEventHandlerCountForFrameView(frameView);
858 } 890 }
859 891
860 #if OS(MACOSX) 892 #if OS(MACOSX)
861 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) 893 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
862 { 894 {
863 ASSERT(isMainThread()); 895 ASSERT(isMainThread());
864 896
865 if (!m_page) 897 if (!m_page)
866 return; 898 return;
867 899
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 bool frameIsScrollable = frameView && frameView->isScrollable(); 975 bool frameIsScrollable = frameView && frameView->isScrollable();
944 if (frameIsScrollable != m_wasFrameScrollable) 976 if (frameIsScrollable != m_wasFrameScrollable)
945 return true; 977 return true;
946 978
947 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : 0) 979 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : 0)
948 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds( ); 980 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds( );
949 return false; 981 return false;
950 } 982 }
951 983
952 } // namespace WebCore 984 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698