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

Side by Side Diff: Source/core/events/TreeScopeEventContext.cpp

Issue 849783002: Event.path should include Window (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: test expected update for http/tests/dom/crash-on-querying-event-path.html 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 | « Source/core/events/TreeScopeEventContext.h ('k') | no next file » | 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) 2014 Google Inc. All Rights Reserved. 2 * Copyright (C) 2014 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 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 16 matching lines...) Expand all
27 #include "config.h" 27 #include "config.h"
28 #include "core/events/TreeScopeEventContext.h" 28 #include "core/events/TreeScopeEventContext.h"
29 29
30 #include "core/dom/StaticNodeList.h" 30 #include "core/dom/StaticNodeList.h"
31 #include "core/dom/shadow/ShadowRoot.h" 31 #include "core/dom/shadow/ShadowRoot.h"
32 #include "core/events/EventPath.h" 32 #include "core/events/EventPath.h"
33 #include "core/events/TouchEventContext.h" 33 #include "core/events/TouchEventContext.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 PassRefPtrWillBeRawPtr<StaticNodeList> TreeScopeEventContext::ensureEventPath(Ev entPath& path) 37 WillBeHeapVector<RefPtrWillBeRawPtr<EventTarget>>& TreeScopeEventContext::ensure EventPath(EventPath& path)
38 { 38 {
39 if (m_eventPath) 39 if (m_eventPath)
40 return m_eventPath; 40 return *m_eventPath;
41 41
42 WillBeHeapVector<RefPtrWillBeMember<Node>> nodes; 42 m_eventPath = adoptPtrWillBeNoop(new WillBeHeapVector<RefPtrWillBeRawPtr<Eve ntTarget>>());
43 nodes.reserveInitialCapacity(path.size()); 43 LocalDOMWindow* window = path.windowEventContext().window();
44 m_eventPath->reserveCapacity(path.size() + window ? 1 : 0);
brucedawson 2015/01/21 19:20:48 This does not do what you think it does. The inte
44 for (size_t i = 0; i < path.size(); ++i) { 45 for (size_t i = 0; i < path.size(); ++i) {
45 Node& rootNode = path[i].treeScopeEventContext().rootNode(); 46 Node& rootNode = path[i].treeScopeEventContext().rootNode();
46 if (rootNode.isShadowRoot() && toShadowRoot(rootNode).type() == ShadowRo ot::AuthorShadowRoot) 47 if (rootNode.isShadowRoot() && toShadowRoot(rootNode).type() == ShadowRo ot::AuthorShadowRoot)
47 nodes.append(path[i].node()); 48 m_eventPath->append(path[i].node());
48 else if (path[i].treeScopeEventContext().isInclusiveAncestorOf(*this)) 49 else if (path[i].treeScopeEventContext().isInclusiveAncestorOf(*this))
49 nodes.append(path[i].node()); 50 m_eventPath->append(path[i].node());
50 } 51 }
51 m_eventPath = StaticNodeList::adopt(nodes); 52 if (window)
52 return m_eventPath; 53 m_eventPath->append(window);
54 return *m_eventPath;
53 } 55 }
54 56
55 TouchEventContext* TreeScopeEventContext::ensureTouchEventContext() 57 TouchEventContext* TreeScopeEventContext::ensureTouchEventContext()
56 { 58 {
57 if (!m_touchEventContext) 59 if (!m_touchEventContext)
58 m_touchEventContext = TouchEventContext::create(); 60 m_touchEventContext = TouchEventContext::create();
59 return m_touchEventContext.get(); 61 return m_touchEventContext.get();
60 } 62 }
61 63
62 PassRefPtrWillBeRawPtr<TreeScopeEventContext> TreeScopeEventContext::create(Tree Scope& treeScope) 64 PassRefPtrWillBeRawPtr<TreeScopeEventContext> TreeScopeEventContext::create(Tree Scope& treeScope)
(...skipping 27 matching lines...) Expand all
90 int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber) 92 int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber)
91 { 93 {
92 m_preOrder = orderNumber; 94 m_preOrder = orderNumber;
93 for (size_t i = 0; i < m_children.size(); ++i) 95 for (size_t i = 0; i < m_children.size(); ++i)
94 orderNumber = m_children[i]->calculatePrePostOrderNumber(orderNumber + 1 ); 96 orderNumber = m_children[i]->calculatePrePostOrderNumber(orderNumber + 1 );
95 m_postOrder = orderNumber + 1; 97 m_postOrder = orderNumber + 1;
96 return orderNumber + 1; 98 return orderNumber + 1;
97 } 99 }
98 100
99 } 101 }
OLDNEW
« no previous file with comments | « Source/core/events/TreeScopeEventContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698