| 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 12 matching lines...) Expand all Loading... |
| 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 "sky/engine/config.h" | 27 #include "sky/engine/config.h" |
| 28 #include "sky/engine/core/events/TreeScopeEventContext.h" | 28 #include "sky/engine/core/events/TreeScopeEventContext.h" |
| 29 | 29 |
| 30 #include "sky/engine/core/dom/StaticNodeList.h" | 30 #include "sky/engine/core/dom/StaticNodeList.h" |
| 31 #include "sky/engine/core/dom/shadow/ShadowRoot.h" | 31 #include "sky/engine/core/dom/shadow/ShadowRoot.h" |
| 32 #include "sky/engine/core/events/EventPath.h" | 32 #include "sky/engine/core/events/EventPath.h" |
| 33 #include "sky/engine/core/events/TouchEventContext.h" | |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 PassRefPtr<StaticNodeList> TreeScopeEventContext::ensureEventPath(EventPath& pat
h) | 36 PassRefPtr<StaticNodeList> TreeScopeEventContext::ensureEventPath(EventPath& pat
h) |
| 38 { | 37 { |
| 39 if (m_eventPath) | 38 if (m_eventPath) |
| 40 return m_eventPath; | 39 return m_eventPath; |
| 41 | 40 |
| 42 Vector<RefPtr<Node> > nodes; | 41 Vector<RefPtr<Node> > nodes; |
| 43 nodes.reserveInitialCapacity(path.size()); | 42 nodes.reserveInitialCapacity(path.size()); |
| 44 for (size_t i = 0; i < path.size(); ++i) { | 43 for (size_t i = 0; i < path.size(); ++i) { |
| 45 TreeScope& treeScope = path[i].treeScopeEventContext().treeScope(); | 44 TreeScope& treeScope = path[i].treeScopeEventContext().treeScope(); |
| 46 if (treeScope.rootNode().isShadowRoot()) | 45 if (treeScope.rootNode().isShadowRoot()) |
| 47 nodes.append(path[i].node()); | 46 nodes.append(path[i].node()); |
| 48 else if (path[i].treeScopeEventContext().isInclusiveAncestorOf(*this)) | 47 else if (path[i].treeScopeEventContext().isInclusiveAncestorOf(*this)) |
| 49 nodes.append(path[i].node()); | 48 nodes.append(path[i].node()); |
| 50 } | 49 } |
| 51 m_eventPath = StaticNodeList::adopt(nodes); | 50 m_eventPath = StaticNodeList::adopt(nodes); |
| 52 return m_eventPath; | 51 return m_eventPath; |
| 53 } | 52 } |
| 54 | 53 |
| 55 TouchEventContext* TreeScopeEventContext::ensureTouchEventContext() | |
| 56 { | |
| 57 if (!m_touchEventContext) | |
| 58 m_touchEventContext = TouchEventContext::create(); | |
| 59 return m_touchEventContext.get(); | |
| 60 } | |
| 61 | |
| 62 PassRefPtr<TreeScopeEventContext> TreeScopeEventContext::create(TreeScope& treeS
cope) | 54 PassRefPtr<TreeScopeEventContext> TreeScopeEventContext::create(TreeScope& treeS
cope) |
| 63 { | 55 { |
| 64 return adoptRef(new TreeScopeEventContext(treeScope)); | 56 return adoptRef(new TreeScopeEventContext(treeScope)); |
| 65 } | 57 } |
| 66 | 58 |
| 67 TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) | 59 TreeScopeEventContext::TreeScopeEventContext(TreeScope& treeScope) |
| 68 : m_treeScope(treeScope) | 60 : m_treeScope(treeScope) |
| 69 , m_preOrder(-1) | 61 , m_preOrder(-1) |
| 70 , m_postOrder(-1) | 62 , m_postOrder(-1) |
| 71 { | 63 { |
| 72 } | 64 } |
| 73 | 65 |
| 74 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext) | 66 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(TreeScopeEventContext) |
| 75 | 67 |
| 76 int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber) | 68 int TreeScopeEventContext::calculatePrePostOrderNumber(int orderNumber) |
| 77 { | 69 { |
| 78 m_preOrder = orderNumber; | 70 m_preOrder = orderNumber; |
| 79 for (size_t i = 0; i < m_children.size(); ++i) | 71 for (size_t i = 0; i < m_children.size(); ++i) |
| 80 orderNumber = m_children[i]->calculatePrePostOrderNumber(orderNumber + 1
); | 72 orderNumber = m_children[i]->calculatePrePostOrderNumber(orderNumber + 1
); |
| 81 m_postOrder = orderNumber + 1; | 73 m_postOrder = orderNumber + 1; |
| 82 return orderNumber + 1; | 74 return orderNumber + 1; |
| 83 } | 75 } |
| 84 | 76 |
| 85 } | 77 } |
| OLD | NEW |