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

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

Issue 225903009: Migrate touch events to EventHandlerRegistry (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 years, 6 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 | Annotate | Revision Log
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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 if (subFrame->isLocalFrame()) 789 if (subFrame->isLocalFrame())
790 shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandl eScrollGestureOnMainThreadRegion(toLocalFrame(subFrame), offset)); 790 shouldHandleScrollGestureOnMainThreadRegion.unite(computeShouldHandl eScrollGestureOnMainThreadRegion(toLocalFrame(subFrame), offset));
791 } 791 }
792 792
793 return shouldHandleScrollGestureOnMainThreadRegion; 793 return shouldHandleScrollGestureOnMainThreadRegion;
794 } 794 }
795 795
796 static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, co nst Document* document) 796 static void accumulateDocumentTouchEventTargetRects(LayerHitTestRects& rects, co nst Document* document)
797 { 797 {
798 ASSERT(document); 798 ASSERT(document);
799 if (!document->touchEventTargets()) 799 const EventTargetSet* targets = document->frameHost()->eventHandlerRegistry( ).eventHandlerTargets(EventHandlerRegistry::TouchEvent);
800 if (!targets)
800 return; 801 return;
801 802
802 const TouchEventTargetSet* targets = document->touchEventTargets(); 803 // If there's a handler on the window, document, html or body element (fairl y common in practice),
803
804 // If there's a handler on the document, html or body element (fairly common in practice),
805 // then we can quickly mark the entire document and skip looking at any othe r handlers. 804 // then we can quickly mark the entire document and skip looking at any othe r handlers.
806 // Note that technically a handler on the body doesn't cover the whole docum ent, but it's 805 // Note that technically a handler on the body doesn't cover the whole docum ent, but it's
807 // reasonable to be conservative and report the whole document anyway. 806 // reasonable to be conservative and report the whole document anyway.
808 // 807 //
809 // Fullscreen HTML5 video when OverlayFullscreenVideo is enabled is implemen ted by replacing the 808 // Fullscreen HTML5 video when OverlayFullscreenVideo is enabled is implemen ted by replacing the
810 // root cc::layer with the video layer so doing this optimization causes the compositor to think 809 // root cc::layer with the video layer so doing this optimization causes the compositor to think
811 // that there are no handlers, therefore skip it. 810 // that there are no handlers, therefore skip it.
812 if (!document->renderView()->compositor()->inOverlayFullscreenVideo()) { 811 if (!document->renderView()->compositor()->inOverlayFullscreenVideo()) {
813 for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter ! = targets->end(); ++iter) { 812 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar gets->end(); ++iter) {
814 Node* target = iter->key; 813 EventTarget* target = iter->key;
815 if (target == document || target == document->documentElement() || t arget == document->body()) { 814 Node* node = target->toNode();
815 if (target->toDOMWindow() || node == document || node == document->d ocumentElement() || node == document->body()) {
816 if (RenderView* rendererView = document->renderView()) { 816 if (RenderView* rendererView = document->renderView()) {
817 rendererView->computeLayerHitTestRects(rects); 817 rendererView->computeLayerHitTestRects(rects);
818 } 818 }
819 return; 819 return;
820 } 820 }
821 } 821 }
822 } 822 }
823 823
824 for (TouchEventTargetSet::const_iterator iter = targets->begin(); iter != ta rgets->end(); ++iter) { 824 for (EventTargetSet::const_iterator iter = targets->begin(); iter != targets ->end(); ++iter) {
825 const Node* target = iter->key; 825 EventTarget* target = iter->key;
826 if (!target->inDocument()) 826 Node* node = target->toNode();
827 if (!node->inDocument())
Rick Byers 2014/06/19 17:10:36 I'd also check for null node here. There are a LO
Sami 2014/06/27 17:58:51 Well spotted, I'll add a fail-safe.
827 continue; 828 continue;
828 829
829 if (target->isDocumentNode() && target != document) { 830 if (node->isDocumentNode() && node != document) {
830 accumulateDocumentTouchEventTargetRects(rects, toDocument(target)); 831 accumulateDocumentTouchEventTargetRects(rects, toDocument(node));
831 } else if (RenderObject* renderer = target->renderer()) { 832 } else if (RenderObject* renderer = node->renderer()) {
832 // If the set also contains one of our ancestor nodes then processin g 833 // If the set also contains one of our ancestor nodes then processin g
833 // this node would be redundant. 834 // this node would be redundant.
834 bool hasTouchEventTargetAncestor = false; 835 bool hasTouchEventTargetAncestor = false;
835 for (Node* ancestor = target->parentNode(); ancestor && !hasTouchEve ntTargetAncestor; ancestor = ancestor->parentNode()) { 836 for (Node* ancestor = node->parentNode(); ancestor && !hasTouchEvent TargetAncestor; ancestor = ancestor->parentNode()) {
836 if (targets->contains(ancestor)) 837 if (targets->contains(ancestor))
837 hasTouchEventTargetAncestor = true; 838 hasTouchEventTargetAncestor = true;
838 } 839 }
839 if (!hasTouchEventTargetAncestor) { 840 if (!hasTouchEventTargetAncestor) {
840 // Walk up the tree to the outermost non-composited scrollable l ayer. 841 // Walk up the tree to the outermost non-composited scrollable l ayer.
841 RenderLayer* enclosingNonCompositedScrollLayer = 0; 842 RenderLayer* enclosingNonCompositedScrollLayer = 0;
842 for (RenderLayer* parent = renderer->enclosingLayer(); parent && parent->compositingState() == NotComposited; parent = parent->parent()) { 843 for (RenderLayer* parent = renderer->enclosingLayer(); parent && parent->compositingState() == NotComposited; parent = parent->parent()) {
843 if (parent->scrollsOverflow()) 844 if (parent->scrollsOverflow())
844 enclosingNonCompositedScrollLayer = parent; 845 enclosingNonCompositedScrollLayer = parent;
845 } 846 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 bool frameIsScrollable = frameView && frameView->isScrollable(); 1000 bool frameIsScrollable = frameView && frameView->isScrollable();
1000 if (frameIsScrollable != m_wasFrameScrollable) 1001 if (frameIsScrollable != m_wasFrameScrollable)
1001 return true; 1002 return true;
1002 1003
1003 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : 0) 1004 if (WebLayer* scrollLayer = frameView ? toWebLayer(frameView->layerForScroll ing()) : 0)
1004 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds( ); 1005 return blink::WebSize(frameView->contentsSize()) != scrollLayer->bounds( );
1005 return false; 1006 return false;
1006 } 1007 }
1007 1008
1008 } // namespace WebCore 1009 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698