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

Side by Side Diff: sky/engine/core/events/EventPath.cpp

Issue 868133003: Remove touch events from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/events/EventPath.h ('k') | sky/engine/core/events/EventTypeNames.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 11 matching lines...) Expand all
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "sky/engine/config.h" 27 #include "sky/engine/config.h"
28 #include "sky/engine/core/events/EventPath.h" 28 #include "sky/engine/core/events/EventPath.h"
29 29
30 #include "gen/sky/core/EventNames.h" 30 #include "gen/sky/core/EventNames.h"
31 #include "sky/engine/core/dom/Document.h" 31 #include "sky/engine/core/dom/Document.h"
32 #include "sky/engine/core/dom/Touch.h"
33 #include "sky/engine/core/dom/TouchList.h"
34 #include "sky/engine/core/dom/shadow/InsertionPoint.h" 32 #include "sky/engine/core/dom/shadow/InsertionPoint.h"
35 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 33 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
36 #include "sky/engine/core/events/TouchEvent.h" 34 #include "sky/engine/core/events/Event.h"
37 #include "sky/engine/core/events/TouchEventContext.h"
38 35
39 namespace blink { 36 namespace blink {
40 37
41 EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) 38 EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode)
42 { 39 {
43 ASSERT(referenceNode); 40 ASSERT(referenceNode);
44 return referenceNode; 41 return referenceNode;
45 } 42 }
46 43
47 static inline bool shouldStopAtShadowRoot(Event& event, ShadowRoot& shadowRoot, EventTarget& target) 44 static inline bool shouldStopAtShadowRoot(Event& event, ShadowRoot& shadowRoot, EventTarget& target)
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 break; 263 break;
267 } 264 }
268 } else if (at(i).target() == at(i).relatedTarget()) { 265 } else if (at(i).target() == at(i).relatedTarget()) {
269 // Event dispatching should be stopped here. 266 // Event dispatching should be stopped here.
270 shrink(i); 267 shrink(i);
271 break; 268 break;
272 } 269 }
273 } 270 }
274 } 271 }
275 272
276 void EventPath::adjustForTouchEvent(Node* node, TouchEvent& touchEvent)
277 {
278 Vector<RawPtr<TouchList> > adjustedTouches;
279 Vector<RawPtr<TouchList> > adjustedTargetTouches;
280 Vector<RawPtr<TouchList> > adjustedChangedTouches;
281 Vector<RawPtr<TreeScope> > treeScopes;
282
283 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) {
284 TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->ensu reTouchEventContext();
285 adjustedTouches.append(&touchEventContext->touches());
286 adjustedTargetTouches.append(&touchEventContext->targetTouches());
287 adjustedChangedTouches.append(&touchEventContext->changedTouches());
288 treeScopes.append(&m_treeScopeEventContexts[i]->treeScope());
289 }
290
291 adjustTouchList(node, touchEvent.touches(), adjustedTouches, treeScopes);
292 adjustTouchList(node, touchEvent.targetTouches(), adjustedTargetTouches, tre eScopes);
293 adjustTouchList(node, touchEvent.changedTouches(), adjustedChangedTouches, t reeScopes);
294
295 #if ENABLE(ASSERT)
296 for (size_t i = 0; i < m_treeScopeEventContexts.size(); ++i) {
297 TreeScope& treeScope = m_treeScopeEventContexts[i]->treeScope();
298 TouchEventContext* touchEventContext = m_treeScopeEventContexts[i]->touc hEventContext();
299 checkReachability(treeScope, touchEventContext->touches());
300 checkReachability(treeScope, touchEventContext->targetTouches());
301 checkReachability(treeScope, touchEventContext->changedTouches());
302 }
303 #endif
304 }
305
306 void EventPath::adjustTouchList(const Node* node, const TouchList* touchList, Ve ctor<RawPtr<TouchList> > adjustedTouchList, const Vector<RawPtr<TreeScope> >& tr eeScopes)
307 {
308 if (!touchList)
309 return;
310 for (size_t i = 0; i < touchList->length(); ++i) {
311 const Touch& touch = *touchList->item(i);
312 RelatedTargetMap relatedNodeMap;
313 buildRelatedNodeMap(touch.target()->toNode(), relatedNodeMap);
314 for (size_t j = 0; j < treeScopes.size(); ++j) {
315 adjustedTouchList[j]->append(touch.cloneWithNewTarget(findRelatedNod e(treeScopes[j], relatedNodeMap)));
316 }
317 }
318 }
319
320 #if ENABLE(ASSERT)
321 void EventPath::checkReachability(TreeScope& treeScope, TouchList& touchList)
322 {
323 for (size_t i = 0; i < touchList.length(); ++i)
324 ASSERT(touchList.item(i)->target()->toNode()->treeScope().isInclusiveOld erSiblingShadowRootOrAncestorTreeScopeOf(treeScope));
325 }
326 #endif
327
328 } // namespace 273 } // namespace
OLDNEW
« no previous file with comments | « sky/engine/core/events/EventPath.h ('k') | sky/engine/core/events/EventTypeNames.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698