| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 7 * |
| 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. |
| 12 * |
| 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. |
| 17 * |
| 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. |
| 22 * |
| 23 */ |
| 24 |
| 25 #include "core/dom/CombinedNodeTraversal.h" |
| 26 |
| 27 #include "core/dom/AssignedNodeTraversal.h" |
| 28 #include "core/dom/Element.h" |
| 29 #include "core/dom/ElementTraversal.h" |
| 30 #include "core/dom/NodeTraversal.h" |
| 31 #include "core/dom/shadow/ElementShadow.h" |
| 32 #include "core/dom/shadow/ShadowRoot.h" |
| 33 #include "core/html/HTMLSlotElement.h" |
| 34 |
| 35 namespace blink { |
| 36 CombinedNodeTraversal::CombinedNodeTraversal(const Node& start) |
| 37 : m_currentNode(const_cast<Node*>(&start)) |
| 38 , m_traversingAssignedNodes(AssignedNodeTraversal::isInAssignedScope(*m_curr
entNode)) |
| 39 { |
| 40 } |
| 41 |
| 42 Node* CombinedNodeTraversal::next() |
| 43 { |
| 44 if (m_traversingAssignedNodes) { |
| 45 m_currentNode = AssignedNodeTraversal::next(*m_currentNode); |
| 46 } else { |
| 47 m_currentNode = NodeTraversal::next(*m_currentNode); |
| 48 } |
| 49 return customReturnForNext(); |
| 50 } |
| 51 |
| 52 Node* CombinedNodeTraversal::previous() |
| 53 { |
| 54 if (m_traversingAssignedNodes) { |
| 55 m_currentNode = AssignedNodeTraversal::previous(*m_currentNode); |
| 56 } else { |
| 57 m_currentNode = NodeTraversal::previous(*m_currentNode); |
| 58 } |
| 59 return customReturnForPrevious(); |
| 60 } |
| 61 |
| 62 Node* CombinedNodeTraversal::customReturnForNext() |
| 63 { |
| 64 if (!m_currentNode) |
| 65 return nullptr; |
| 66 if (m_currentNode->isTextNode() || (!m_traversingAssignedNodes && AssignedNo
deTraversal::isInAssignedScope(*m_currentNode))) |
| 67 return next(); |
| 68 return m_currentNode.get(); |
| 69 } |
| 70 |
| 71 Node* CombinedNodeTraversal::customReturnForPrevious() |
| 72 { |
| 73 if (!m_currentNode) |
| 74 return nullptr; |
| 75 if (m_currentNode->isTextNode() || (!m_traversingAssignedNodes && AssignedNo
deTraversal::isInAssignedScope(*m_currentNode))) |
| 76 return previous(); |
| 77 return m_currentNode.get(); |
| 78 } |
| 79 |
| 80 } // namespace blink |
| OLD | NEW |