OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 if (current == this) | 988 if (current == this) |
989 return true; | 989 return true; |
990 if (current->isDocumentFragment() && toDocumentFragment(current)->isTemp
lateContent()) | 990 if (current->isDocumentFragment() && toDocumentFragment(current)->isTemp
lateContent()) |
991 current = static_cast<const TemplateContentDocumentFragment*>(curren
t)->host(); | 991 current = static_cast<const TemplateContentDocumentFragment*>(curren
t)->host(); |
992 else | 992 else |
993 current = current->parentOrShadowHostNode(); | 993 current = current->parentOrShadowHostNode(); |
994 } while (current); | 994 } while (current); |
995 return false; | 995 return false; |
996 } | 996 } |
997 | 997 |
998 Node* Node::commonAncestorOverShadowBoundary(const Node& other) | 998 Node* Node::commonAncestor(const Node& other, Node* (*parent)(const Node&)) |
999 { | 999 { |
1000 if (this == other) | 1000 if (this == other) |
1001 return this; | 1001 return this; |
1002 if (document() != other.document()) | 1002 if (document() != other.document()) |
1003 return 0; | 1003 return 0; |
1004 int thisDepth = 0; | 1004 int thisDepth = 0; |
1005 for (Node* node = this; node; node = node->parentOrShadowHostNode()) { | 1005 for (Node* node = this; node; node = parent(*node)) { |
1006 if (node == &other) | 1006 if (node == &other) |
1007 return node; | 1007 return node; |
1008 thisDepth++; | 1008 thisDepth++; |
1009 } | 1009 } |
1010 int otherDepth = 0; | 1010 int otherDepth = 0; |
1011 for (const Node* node = &other; node; node = node->parentOrShadowHostNode())
{ | 1011 for (const Node* node = &other; node; node = parent(*node)) { |
1012 if (node == this) | 1012 if (node == this) |
1013 return this; | 1013 return this; |
1014 otherDepth++; | 1014 otherDepth++; |
1015 } | 1015 } |
1016 Node* thisIterator = this; | 1016 Node* thisIterator = this; |
1017 const Node* otherIterator = &other; | 1017 const Node* otherIterator = &other; |
1018 if (thisDepth > otherDepth) { | 1018 if (thisDepth > otherDepth) { |
1019 for (int i = thisDepth; i > otherDepth; --i) | 1019 for (int i = thisDepth; i > otherDepth; --i) |
1020 thisIterator = thisIterator->parentOrShadowHostNode(); | 1020 thisIterator = parent(*thisIterator); |
1021 } else if (otherDepth > thisDepth) { | 1021 } else if (otherDepth > thisDepth) { |
1022 for (int i = otherDepth; i > thisDepth; --i) | 1022 for (int i = otherDepth; i > thisDepth; --i) |
1023 otherIterator = otherIterator->parentOrShadowHostNode(); | 1023 otherIterator = parent(*otherIterator); |
1024 } | 1024 } |
1025 while (thisIterator) { | 1025 while (thisIterator) { |
1026 if (thisIterator == otherIterator) | 1026 if (thisIterator == otherIterator) |
1027 return thisIterator; | 1027 return thisIterator; |
1028 thisIterator = thisIterator->parentOrShadowHostNode(); | 1028 thisIterator = parent(*thisIterator); |
1029 otherIterator = otherIterator->parentOrShadowHostNode(); | 1029 otherIterator = parent(*otherIterator); |
1030 } | 1030 } |
1031 ASSERT(!otherIterator); | 1031 ASSERT(!otherIterator); |
1032 return 0; | 1032 return 0; |
1033 } | 1033 } |
1034 | 1034 |
1035 void Node::reattach(const AttachContext& context) | 1035 void Node::reattach(const AttachContext& context) |
1036 { | 1036 { |
1037 AttachContext reattachContext(context); | 1037 AttachContext reattachContext(context); |
1038 reattachContext.performingReattach = true; | 1038 reattachContext.performingReattach = true; |
1039 | 1039 |
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 node->showTreeForThis(); | 2737 node->showTreeForThis(); |
2738 } | 2738 } |
2739 | 2739 |
2740 void showNodePath(const WebCore::Node* node) | 2740 void showNodePath(const WebCore::Node* node) |
2741 { | 2741 { |
2742 if (node) | 2742 if (node) |
2743 node->showNodePathForThis(); | 2743 node->showNodePathForThis(); |
2744 } | 2744 } |
2745 | 2745 |
2746 #endif | 2746 #endif |
OLD | NEW |