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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 821 |
822 const FrameTree& tree = frame->tree(); | 822 const FrameTree& tree = frame->tree(); |
823 for (Frame* subFrame = tree.firstChild(); subFrame; subFrame = subFrame->tre
e().nextSibling()) { | 823 for (Frame* subFrame = tree.firstChild(); subFrame; subFrame = subFrame->tre
e().nextSibling()) { |
824 if (subFrame->isLocalFrame()) | 824 if (subFrame->isLocalFrame()) |
825 shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandl
eScrollGestureOnMainThreadRegion(toLocalFrame(subFrame), offset)); | 825 shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandl
eScrollGestureOnMainThreadRegion(toLocalFrame(subFrame), offset)); |
826 } | 826 } |
827 | 827 |
828 return shouldHandleScrollGestureOnMainThreadRegion; | 828 return shouldHandleScrollGestureOnMainThreadRegion; |
829 } | 829 } |
830 | 830 |
831 static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, co
nst Document* document) | 831 static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, co
nst Document* document, EventHandlerRegistry::EventHandlerClass touchHandlerClas
s) |
832 { | 832 { |
833 ASSERT(document); | 833 ASSERT(document); |
834 const EventTargetSet* targets = document->frameHost()->eventHandlerRegistry(
).eventHandlerTargets(EventHandlerRegistry::TouchEvent); | 834 const EventTargetSet* targets = document->frameHost()->eventHandlerRegistry(
).eventHandlerTargets(touchHandlerClass); |
835 if (!targets) | 835 if (!targets) |
836 return; | 836 return; |
837 | 837 |
838 // If there's a handler on the window, document, html or body element (fairl
y common in practice), | 838 // If there's a handler on the window, document, html or body element (fairl
y common in practice), |
839 // then we can quickly mark the entire document and skip looking at any othe
r handlers. | 839 // then we can quickly mark the entire document and skip looking at any othe
r handlers. |
840 // Note that technically a handler on the body doesn't cover the whole docum
ent, but it's | 840 // Note that technically a handler on the body doesn't cover the whole docum
ent, but it's |
841 // reasonable to be conservative and report the whole document anyway. | 841 // reasonable to be conservative and report the whole document anyway. |
842 // | 842 // |
843 // Fullscreen HTML5 video when OverlayFullscreenVideo is enabled is implemen
ted by replacing the | 843 // Fullscreen HTML5 video when OverlayFullscreenVideo is enabled is implemen
ted by replacing the |
844 // root cc::layer with the video layer so doing this optimization causes the
compositor to think | 844 // root cc::layer with the video layer so doing this optimization causes the
compositor to think |
(...skipping 16 matching lines...) Expand all Loading... |
861 Node* node = target->toNode(); | 861 Node* node = target->toNode(); |
862 if (!node || !node->inDocument()) | 862 if (!node || !node->inDocument()) |
863 continue; | 863 continue; |
864 | 864 |
865 // If the document belongs to an invisible subframe it does not have a c
omposited layer | 865 // If the document belongs to an invisible subframe it does not have a c
omposited layer |
866 // and should be skipped. | 866 // and should be skipped. |
867 if (node->document().isInInvisibleSubframe()) | 867 if (node->document().isInInvisibleSubframe()) |
868 continue; | 868 continue; |
869 | 869 |
870 if (node->isDocumentNode() && node != document) { | 870 if (node->isDocumentNode() && node != document) { |
871 accumulateDocumentTouchEventTargetRects(rects, toDocument(node)); | 871 accumulateDocumentTouchEventTargetRects(rects, toDocument(node), tou
chHandlerClass); |
872 } else if (LayoutObject* layoutObject = node->layoutObject()) { | 872 } else if (LayoutObject* layoutObject = node->layoutObject()) { |
873 // If the set also contains one of our ancestor nodes then processin
g | 873 // If the set already contains this node or one of our ancestor node
s then processing |
874 // this node would be redundant. | 874 // this node would be redundant. |
875 bool hasTouchEventTargetAncestor = false; | 875 bool rectsAlreadyIncluded = false; |
876 for (Node* ancestor = node->parentNode(); ancestor && !hasTouchEvent
TargetAncestor; ancestor = ancestor->parentNode()) { | 876 for (Node* ancestor = node; ancestor && !rectsAlreadyIncluded; ances
tor = ancestor->parentNode()) { |
877 if (targets->contains(ancestor)) | 877 if (targets->contains(ancestor)) |
878 hasTouchEventTargetAncestor = true; | 878 rectsAlreadyIncluded = true; |
879 } | 879 } |
880 if (!hasTouchEventTargetAncestor) { | 880 if (!rectsAlreadyIncluded) { |
881 // Walk up the tree to the outermost non-composited scrollable l
ayer. | 881 // Walk up the tree to the outermost non-composited scrollable l
ayer. |
882 DeprecatedPaintLayer* enclosingNonCompositedScrollLayer = nullpt
r; | 882 DeprecatedPaintLayer* enclosingNonCompositedScrollLayer = nullpt
r; |
883 for (DeprecatedPaintLayer* parent = layoutObject->enclosingLayer
(); parent && parent->compositingState() == NotComposited; parent = parent->pare
nt()) { | 883 for (DeprecatedPaintLayer* parent = layoutObject->enclosingLayer
(); parent && parent->compositingState() == NotComposited; parent = parent->pare
nt()) { |
884 if (parent->scrollsOverflow()) | 884 if (parent->scrollsOverflow()) |
885 enclosingNonCompositedScrollLayer = parent; | 885 enclosingNonCompositedScrollLayer = parent; |
886 } | 886 } |
887 | 887 |
888 // Report the whole non-composited scroll layer as a touch hit r
ect because any | 888 // Report the whole non-composited scroll layer as a touch hit r
ect because any |
889 // rects inside of it may move around relative to their enclosin
g composited layer | 889 // rects inside of it may move around relative to their enclosin
g composited layer |
890 // without causing the rects to be recomputed. Non-composited sc
rolling occurs on | 890 // without causing the rects to be recomputed. Non-composited sc
rolling occurs on |
891 // the main thread, so we're not getting much benefit from compo
sitor touch hit | 891 // the main thread, so we're not getting much benefit from compo
sitor touch hit |
892 // testing in this case anyway. | 892 // testing in this case anyway. |
893 if (enclosingNonCompositedScrollLayer) | 893 if (enclosingNonCompositedScrollLayer) |
894 enclosingNonCompositedScrollLayer->computeSelfHitTestRects(r
ects); | 894 enclosingNonCompositedScrollLayer->computeSelfHitTestRects(r
ects); |
895 | 895 |
896 layoutObject->computeLayerHitTestRects(rects); | 896 layoutObject->computeLayerHitTestRects(rects); |
897 } | 897 } |
898 } | 898 } |
899 } | 899 } |
900 } | 900 } |
901 | 901 |
| 902 static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, co
nst Document* document) |
| 903 { |
| 904 accumulateDocumentTouchEventTargetRects(rects, document, EventHandlerRegistr
y::TouchEvent); |
| 905 accumulateDocumentTouchEventTargetRects(rects, document, EventHandlerRegistr
y::TouchMoveEvent); |
| 906 } |
| 907 |
902 void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
) | 908 void ScrollingCoordinator::computeTouchEventTargetRects(LayerHitTestRects& rects
) |
903 { | 909 { |
904 TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects"); | 910 TRACE_EVENT0("input", "ScrollingCoordinator::computeTouchEventTargetRects"); |
905 ASSERT(RuntimeEnabledFeatures::touchEnabled()); | 911 ASSERT(RuntimeEnabledFeatures::touchEnabled()); |
906 | 912 |
907 Document* document = m_page->deprecatedLocalMainFrame()->document(); | 913 Document* document = m_page->deprecatedLocalMainFrame()->document(); |
908 if (!document || !document->view()) | 914 if (!document || !document->view()) |
909 return; | 915 return; |
910 | 916 |
911 accumulateDocumentTouchEventTargetRects(rects, document); | 917 accumulateDocumentTouchEventTargetRects(rects, document); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 bool frameIsScrollable = frameView && frameView->isScrollable(); | 1089 bool frameIsScrollable = frameView && frameView->isScrollable(); |
1084 if (frameIsScrollable != m_wasFrameScrollable) | 1090 if (frameIsScrollable != m_wasFrameScrollable) |
1085 return true; | 1091 return true; |
1086 | 1092 |
1087 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) | 1093 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll
ing()) : nullptr) |
1088 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); | 1094 return WebSize(frameView->contentsSize()) != scrollLayer->bounds(); |
1089 return false; | 1095 return false; |
1090 } | 1096 } |
1091 | 1097 |
1092 } // namespace blink | 1098 } // namespace blink |
OLD | NEW |