OLD | NEW |
---|---|
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 10 matching lines...) Expand all Loading... | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 * | 24 * |
25 */ | 25 */ |
26 | 26 |
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" | |
32 #include "core/events/EventPath.h" | |
31 #include "core/events/TouchEventContext.h" | 33 #include "core/events/TouchEventContext.h" |
32 | 34 |
33 namespace WebCore { | 35 namespace WebCore { |
34 | 36 |
35 void TreeScopeEventContext::adoptEventPath(Vector<RefPtr<Node> >& nodes) | 37 PassRefPtr<NodeList> TreeScopeEventContext::ensureEventPath(EventPath& path) |
36 { | 38 { |
39 if (m_eventPath) | |
40 return m_eventPath; | |
41 | |
42 Vector<RefPtr<Node> > nodes; | |
43 nodes.reserveInitialCapacity(path.size()); | |
44 for (size_t i = 0; i < path.size(); ++i) { | |
45 if (path[i].treeScopeEventContext()->isInclusiveAncestorOf(*this)) | |
46 nodes.append(path[i].node()); | |
47 } | |
37 m_eventPath = StaticNodeList::adopt(nodes); | 48 m_eventPath = StaticNodeList::adopt(nodes); |
49 return m_eventPath; | |
38 } | 50 } |
39 | 51 |
40 TouchEventContext* TreeScopeEventContext::ensureTouchEventContext() | 52 TouchEventContext* TreeScopeEventContext::ensureTouchEventContext() |
41 { | 53 { |
42 if (!m_touchEventContext) | 54 if (!m_touchEventContext) |
43 m_touchEventContext = TouchEventContext::create(); | 55 m_touchEventContext = TouchEventContext::create(); |
44 return m_touchEventContext.get(); | 56 return m_touchEventContext.get(); |
45 } | 57 } |
46 | 58 |
47 PassRefPtr<TreeScopeEventContext> TreeScopeEventContext::create(TreeScope& treeS cope) | 59 PassRefPtr<TreeScopeEventContext> TreeScopeEventContext::create(TreeScope& treeS cope) |
48 { | 60 { |
49 return adoptRef(new TreeScopeEventContext(treeScope)); | 61 return adoptRef(new TreeScopeEventContext(treeScope)); |
50 } | 62 } |
51 | 63 |
52 TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) | 64 TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) |
53 : m_treeScope(treeScope) | 65 : m_treeScope(treeScope) |
66 , m_preVisit(-1) | |
67 , m_postVisit(-1) | |
54 { | 68 { |
55 } | 69 } |
56 | 70 |
57 TreeScopeEventContext::~TreeScopeEventContext() | 71 TreeScopeEventContext::~TreeScopeEventContext() |
58 { | 72 { |
59 } | 73 } |
60 | 74 |
75 int TreeScopeEventContext::numberByDepthFirstSearch(int number) | |
76 { | |
77 m_preVisit = number; | |
78 for (size_t i = 0; i < m_children.size(); ++i) { | |
esprehn
2014/03/11 01:23:11
extra braces
hayato
2014/03/11 05:54:04
Done.
| |
79 number = m_children[i]->numberByDepthFirstSearch(number + 1); | |
80 } | |
81 m_postVisit = number + 1; | |
esprehn
2014/03/11 01:23:11
Why do you need postVisit? Can't you just do lastC
hayato
2014/03/11 05:54:04
The reason is that the spec requires pre-calculati
| |
82 return number + 1; | |
61 } | 83 } |
84 | |
85 } | |
OLD | NEW |