| 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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 if (current == this) | 745 if (current == this) |
| 746 return true; | 746 return true; |
| 747 if (current->isDocumentFragment() && toDocumentFragment(current)->isTemp
lateContent()) | 747 if (current->isDocumentFragment() && toDocumentFragment(current)->isTemp
lateContent()) |
| 748 current = static_cast<const TemplateContentDocumentFragment*>(curren
t)->host(); | 748 current = static_cast<const TemplateContentDocumentFragment*>(curren
t)->host(); |
| 749 else | 749 else |
| 750 current = current->parentOrShadowHostNode(); | 750 current = current->parentOrShadowHostNode(); |
| 751 } while (current); | 751 } while (current); |
| 752 return false; | 752 return false; |
| 753 } | 753 } |
| 754 | 754 |
| 755 Node* Node::commonAncestor(const Node& other, Node* (*parent)(const Node&)) | |
| 756 { | |
| 757 if (this == other) | |
| 758 return this; | |
| 759 if (document() != other.document()) | |
| 760 return 0; | |
| 761 int thisDepth = 0; | |
| 762 for (Node* node = this; node; node = parent(*node)) { | |
| 763 if (node == &other) | |
| 764 return node; | |
| 765 thisDepth++; | |
| 766 } | |
| 767 int otherDepth = 0; | |
| 768 for (const Node* node = &other; node; node = parent(*node)) { | |
| 769 if (node == this) | |
| 770 return this; | |
| 771 otherDepth++; | |
| 772 } | |
| 773 Node* thisIterator = this; | |
| 774 const Node* otherIterator = &other; | |
| 775 if (thisDepth > otherDepth) { | |
| 776 for (int i = thisDepth; i > otherDepth; --i) | |
| 777 thisIterator = parent(*thisIterator); | |
| 778 } else if (otherDepth > thisDepth) { | |
| 779 for (int i = otherDepth; i > thisDepth; --i) | |
| 780 otherIterator = parent(*otherIterator); | |
| 781 } | |
| 782 while (thisIterator) { | |
| 783 if (thisIterator == otherIterator) | |
| 784 return thisIterator; | |
| 785 thisIterator = parent(*thisIterator); | |
| 786 otherIterator = parent(*otherIterator); | |
| 787 } | |
| 788 ASSERT(!otherIterator); | |
| 789 return 0; | |
| 790 } | |
| 791 | |
| 792 void Node::reattach(const AttachContext& context) | 755 void Node::reattach(const AttachContext& context) |
| 793 { | 756 { |
| 794 AttachContext reattachContext(context); | 757 AttachContext reattachContext(context); |
| 795 reattachContext.performingReattach = true; | 758 reattachContext.performingReattach = true; |
| 796 | 759 |
| 797 // We only need to detach if the node has already been through attach(). | 760 // We only need to detach if the node has already been through attach(). |
| 798 if (styleChangeType() < NeedsReattachStyleChange) | 761 if (styleChangeType() < NeedsReattachStyleChange) |
| 799 detach(reattachContext); | 762 detach(reattachContext); |
| 800 attach(reattachContext); | 763 attach(reattachContext); |
| 801 } | 764 } |
| (...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 node->showTreeForThis(); | 1958 node->showTreeForThis(); |
| 1996 } | 1959 } |
| 1997 | 1960 |
| 1998 void showNodePath(const blink::Node* node) | 1961 void showNodePath(const blink::Node* node) |
| 1999 { | 1962 { |
| 2000 if (node) | 1963 if (node) |
| 2001 node->showNodePathForThis(); | 1964 node->showNodePathForThis(); |
| 2002 } | 1965 } |
| 2003 | 1966 |
| 2004 #endif | 1967 #endif |
| OLD | NEW |