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 12 matching lines...) Expand all Loading... |
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/Node.h" | 32 #include "core/dom/Node.h" |
| 33 #include "core/dom/ScrollEventHandlerController.h" |
33 #include "core/dom/WheelController.h" | 34 #include "core/dom/WheelController.h" |
34 #include "core/html/HTMLElement.h" | 35 #include "core/html/HTMLElement.h" |
35 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
37 #include "core/page/Page.h" | 38 #include "core/page/Page.h" |
38 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
39 #include "platform/TraceEvent.h" | 40 #include "platform/TraceEvent.h" |
40 #include "platform/exported/WebScrollbarImpl.h" | 41 #include "platform/exported/WebScrollbarImpl.h" |
41 #include "platform/exported/WebScrollbarThemeGeometryNative.h" | 42 #include "platform/exported/WebScrollbarThemeGeometryNative.h" |
42 #include "platform/geometry/Region.h" | 43 #include "platform/geometry/Region.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 { | 617 { |
617 m_layersWithTouchRects.remove(layer); | 618 m_layersWithTouchRects.remove(layer); |
618 } | 619 } |
619 | 620 |
620 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) | 621 void ScrollingCoordinator::setWheelEventHandlerCount(unsigned count) |
621 { | 622 { |
622 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) | 623 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) |
623 scrollLayer->setHaveWheelEventHandlers(count > 0); | 624 scrollLayer->setHaveWheelEventHandlers(count > 0); |
624 } | 625 } |
625 | 626 |
| 627 void ScrollingCoordinator::setScrollEventHandlerCount(unsigned count) |
| 628 { |
| 629 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) |
| 630 scrollLayer->setHaveScrollEventHandlers(count > 0); |
| 631 } |
| 632 |
626 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView
*) | 633 void ScrollingCoordinator::recomputeWheelEventHandlerCountForFrameView(FrameView
*) |
627 { | 634 { |
628 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); | 635 setWheelEventHandlerCount(computeCurrentWheelEventHandlerCount()); |
629 } | 636 } |
630 | 637 |
| 638 void ScrollingCoordinator::recomputeScrollEventHandlerCountForFrameView(FrameVie
w*) |
| 639 { |
| 640 setScrollEventHandlerCount(computeCurrentScrollEventHandlerCount()); |
| 641 } |
| 642 |
631 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh
readScrollingReasons reasons) | 643 void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainTh
readScrollingReasons reasons) |
632 { | 644 { |
633 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) { | 645 if (WebLayer* scrollLayer = toWebLayer(m_page->mainFrame()->view()->layerFor
Scrolling())) { |
634 m_lastMainThreadScrollingReasons = reasons; | 646 m_lastMainThreadScrollingReasons = reasons; |
635 scrollLayer->setShouldScrollOnMainThread(reasons); | 647 scrollLayer->setShouldScrollOnMainThread(reasons); |
636 } | 648 } |
637 } | 649 } |
638 | 650 |
639 void ScrollingCoordinator::pageDestroyed() | 651 void ScrollingCoordinator::pageDestroyed() |
640 { | 652 { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 unsigned wheelEventHandlerCount = 0; | 802 unsigned wheelEventHandlerCount = 0; |
791 | 803 |
792 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { | 804 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { |
793 if (frame->document()) | 805 if (frame->document()) |
794 wheelEventHandlerCount += WheelController::from(*frame->document())-
>wheelEventHandlerCount(); | 806 wheelEventHandlerCount += WheelController::from(*frame->document())-
>wheelEventHandlerCount(); |
795 } | 807 } |
796 | 808 |
797 return wheelEventHandlerCount; | 809 return wheelEventHandlerCount; |
798 } | 810 } |
799 | 811 |
| 812 unsigned ScrollingCoordinator::computeCurrentScrollEventHandlerCount() |
| 813 { |
| 814 unsigned scrollEventHandlerCount = 0; |
| 815 |
| 816 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t
raverseNext()) { |
| 817 if (frame->document()) |
| 818 scrollEventHandlerCount += ScrollEventHandlerController::from(*frame
->document())->scrollEventHandlerCount(); |
| 819 } |
| 820 |
| 821 return scrollEventHandlerCount; |
| 822 } |
| 823 |
800 void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView* fra
meView) | 824 void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView* fra
meView) |
801 { | 825 { |
802 ASSERT(isMainThread()); | 826 ASSERT(isMainThread()); |
803 ASSERT(m_page); | 827 ASSERT(m_page); |
804 | 828 |
805 recomputeWheelEventHandlerCountForFrameView(frameView); | 829 recomputeWheelEventHandlerCountForFrameView(frameView); |
806 } | 830 } |
807 | 831 |
| 832 void ScrollingCoordinator::frameViewScrollEventHandlerCountChanged(FrameView* fr
ameView) |
| 833 { |
| 834 ASSERT(isMainThread()); |
| 835 ASSERT(m_page); |
| 836 |
| 837 recomputeScrollEventHandlerCountForFrameView(frameView); |
| 838 } |
| 839 |
808 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* fr
ameView) | 840 void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* fr
ameView) |
809 { | 841 { |
810 ASSERT(isMainThread()); | 842 ASSERT(isMainThread()); |
811 ASSERT(m_page); | 843 ASSERT(m_page); |
812 | 844 |
813 if (!coordinatesScrollingForFrameView(frameView)) | 845 if (!coordinatesScrollingForFrameView(frameView)) |
814 return; | 846 return; |
815 | 847 |
816 m_shouldScrollOnMainThreadDirty = true; | 848 m_shouldScrollOnMainThreadDirty = true; |
817 } | 849 } |
(...skipping 30 matching lines...) Expand all Loading... |
848 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) | 880 void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView) |
849 { | 881 { |
850 ASSERT(isMainThread()); | 882 ASSERT(isMainThread()); |
851 ASSERT(m_page); | 883 ASSERT(m_page); |
852 | 884 |
853 if (!coordinatesScrollingForFrameView(frameView)) | 885 if (!coordinatesScrollingForFrameView(frameView)) |
854 return; | 886 return; |
855 | 887 |
856 notifyLayoutUpdated(); | 888 notifyLayoutUpdated(); |
857 recomputeWheelEventHandlerCountForFrameView(frameView); | 889 recomputeWheelEventHandlerCountForFrameView(frameView); |
| 890 recomputeScrollEventHandlerCountForFrameView(frameView); |
858 } | 891 } |
859 | 892 |
860 #if OS(MACOSX) | 893 #if OS(MACOSX) |
861 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) | 894 void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) |
862 { | 895 { |
863 ASSERT(isMainThread()); | 896 ASSERT(isMainThread()); |
864 | 897 |
865 if (!m_page) | 898 if (!m_page) |
866 return; | 899 return; |
867 | 900 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 bool frameIsScrollable = frameView && frameView->isScrollable(); | 976 bool frameIsScrollable = frameView && frameView->isScrollable(); |
944 if (frameIsScrollable != m_wasFrameScrollable) | 977 if (frameIsScrollable != m_wasFrameScrollable) |
945 return true; | 978 return true; |
946 | 979 |
947 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : 0) | 980 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : 0) |
948 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds(
); | 981 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds(
); |
949 return false; | 982 return false; |
950 } | 983 } |
951 | 984 |
952 } // namespace WebCore | 985 } // namespace WebCore |
OLD | NEW |