| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 if (isElementNode() && hasRareData()) | 589 if (isElementNode() && hasRareData()) |
| 590 toElement(*this).setAnimationStyleChange(false); | 590 toElement(*this).setAnimationStyleChange(false); |
| 591 } | 591 } |
| 592 | 592 |
| 593 bool Node::inActiveDocument() const | 593 bool Node::inActiveDocument() const |
| 594 { | 594 { |
| 595 return inDocument() && document().isActive(); | 595 return inDocument() && document().isActive(); |
| 596 } | 596 } |
| 597 | 597 |
| 598 Node* Node::focusDelegate() | |
| 599 { | |
| 600 return this; | |
| 601 } | |
| 602 | |
| 603 bool Node::shouldHaveFocusAppearance() const | |
| 604 { | |
| 605 ASSERT(focused()); | |
| 606 return true; | |
| 607 } | |
| 608 | |
| 609 bool Node::isInert() const | |
| 610 { | |
| 611 return false; | |
| 612 } | |
| 613 | |
| 614 unsigned Node::nodeIndex() const | 598 unsigned Node::nodeIndex() const |
| 615 { | 599 { |
| 616 Node *_tempNode = previousSibling(); | 600 Node *_tempNode = previousSibling(); |
| 617 unsigned count=0; | 601 unsigned count=0; |
| 618 for ( count=0; _tempNode; count++ ) | 602 for ( count=0; _tempNode; count++ ) |
| 619 _tempNode = _tempNode->previousSibling(); | 603 _tempNode = _tempNode->previousSibling(); |
| 620 return count; | 604 return count; |
| 621 } | 605 } |
| 622 | 606 |
| 623 bool Node::isDescendantOf(const Node *other) const | 607 bool Node::isDescendantOf(const Node *other) const |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 681 |
| 698 void Node::attach(const AttachContext&) | 682 void Node::attach(const AttachContext&) |
| 699 { | 683 { |
| 700 ASSERT(document().inStyleRecalc() || isDocumentNode()); | 684 ASSERT(document().inStyleRecalc() || isDocumentNode()); |
| 701 ASSERT(needsAttach()); | 685 ASSERT(needsAttach()); |
| 702 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende
rer()->isRenderView()))); | 686 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende
rer()->isRenderView()))); |
| 703 | 687 |
| 704 clearNeedsStyleRecalc(); | 688 clearNeedsStyleRecalc(); |
| 705 } | 689 } |
| 706 | 690 |
| 707 #if ENABLE(ASSERT) | |
| 708 static Node* detachingNode; | |
| 709 | |
| 710 bool Node::inDetach() const | |
| 711 { | |
| 712 return detachingNode == this; | |
| 713 } | |
| 714 #endif | |
| 715 | |
| 716 void Node::detach(const AttachContext& context) | 691 void Node::detach(const AttachContext& context) |
| 717 { | 692 { |
| 718 ASSERT(document().lifecycle().stateAllowsDetach()); | 693 ASSERT(document().lifecycle().stateAllowsDetach()); |
| 719 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); | 694 DocumentLifecycle::DetachScope willDetach(document().lifecycle()); |
| 720 | 695 |
| 721 #if ENABLE(ASSERT) | |
| 722 ASSERT(!detachingNode); | |
| 723 detachingNode = this; | |
| 724 #endif | |
| 725 | |
| 726 if (renderer()) | 696 if (renderer()) |
| 727 renderer()->destroyAndCleanupAnonymousWrappers(); | 697 renderer()->destroyAndCleanupAnonymousWrappers(); |
| 728 setRenderer(0); | 698 setRenderer(0); |
| 729 | 699 |
| 730 // Do not remove the element's hovered and active status | 700 // Do not remove the element's hovered and active status |
| 731 // if performing a reattach. | 701 // if performing a reattach. |
| 732 if (!context.performingReattach) { | 702 if (!context.performingReattach) { |
| 733 Document& doc = document(); | 703 Document& doc = document(); |
| 734 if (isUserActionElement()) { | 704 if (isUserActionElement()) { |
| 735 if (hovered()) | 705 if (hovered()) |
| 736 doc.hoveredNodeDetached(this); | 706 doc.hoveredNodeDetached(this); |
| 737 if (inActiveChain()) | 707 if (inActiveChain()) |
| 738 doc.activeChainNodeDetached(this); | 708 doc.activeChainNodeDetached(this); |
| 739 doc.userActionElements().didDetach(this); | 709 doc.userActionElements().didDetach(this); |
| 740 } | 710 } |
| 741 } | 711 } |
| 742 | 712 |
| 743 setStyleChange(NeedsReattachStyleChange); | 713 setStyleChange(NeedsReattachStyleChange); |
| 744 setChildNeedsStyleRecalc(); | 714 setChildNeedsStyleRecalc(); |
| 745 | |
| 746 #if ENABLE(ASSERT) | |
| 747 detachingNode = 0; | |
| 748 #endif | |
| 749 } | 715 } |
| 750 | 716 |
| 751 void Node::reattachWhitespaceSiblings(Text* start) | 717 void Node::reattachWhitespaceSiblings(Text* start) |
| 752 { | 718 { |
| 753 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { | 719 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { |
| 754 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace())
{ | 720 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace())
{ |
| 755 bool hadRenderer = !!sibling->renderer(); | 721 bool hadRenderer = !!sibling->renderer(); |
| 756 sibling->reattach(); | 722 sibling->reattach(); |
| 757 // If the reattach didn't toggle the visibility of the whitespace we
don't | 723 // If the reattach didn't toggle the visibility of the whitespace we
don't |
| 758 // need to continue reattaching siblings since they won't toggle vis
ibility | 724 // need to continue reattaching siblings since they won't toggle vis
ibility |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 } | 890 } |
| 925 | 891 |
| 926 // FIXME: End of obviously misplaced HTML editing functions. Try to move these
out of Node. | 892 // FIXME: End of obviously misplaced HTML editing functions. Try to move these
out of Node. |
| 927 | 893 |
| 928 Document* Node::ownerDocument() const | 894 Document* Node::ownerDocument() const |
| 929 { | 895 { |
| 930 Document* doc = &document(); | 896 Document* doc = &document(); |
| 931 return doc == this ? 0 : doc; | 897 return doc == this ? 0 : doc; |
| 932 } | 898 } |
| 933 | 899 |
| 934 bool Node::isEqualNode(Node* other) const | |
| 935 { | |
| 936 if (!other) | |
| 937 return false; | |
| 938 | |
| 939 NodeType nodeType = this->nodeType(); | |
| 940 if (nodeType != other->nodeType()) | |
| 941 return false; | |
| 942 | |
| 943 if (nodeName() != other->nodeName()) | |
| 944 return false; | |
| 945 | |
| 946 if (localName() != other->localName()) | |
| 947 return false; | |
| 948 | |
| 949 if (isElementNode() && !toElement(this)->hasEquivalentAttributes(toElement(o
ther))) | |
| 950 return false; | |
| 951 | |
| 952 Node* child = firstChild(); | |
| 953 Node* otherChild = other->firstChild(); | |
| 954 | |
| 955 while (child) { | |
| 956 if (!child->isEqualNode(otherChild)) | |
| 957 return false; | |
| 958 | |
| 959 child = child->nextSibling(); | |
| 960 otherChild = otherChild->nextSibling(); | |
| 961 } | |
| 962 | |
| 963 if (otherChild) | |
| 964 return false; | |
| 965 | |
| 966 return true; | |
| 967 } | |
| 968 | |
| 969 static void appendTextContent(const Node* node, bool convertBRsToNewlines, Strin
gBuilder& content) | 900 static void appendTextContent(const Node* node, bool convertBRsToNewlines, Strin
gBuilder& content) |
| 970 { | 901 { |
| 971 if (node->nodeType() == Node::TEXT_NODE) { | 902 if (node->nodeType() == Node::TEXT_NODE) { |
| 972 content.append(toCharacterData(node)->data()); | 903 content.append(toCharacterData(node)->data()); |
| 973 return; | 904 return; |
| 974 } | 905 } |
| 975 | 906 |
| 976 for (Node* child = toContainerNode(node)->firstChild(); child; child = child
->nextSibling()) { | 907 for (Node* child = toContainerNode(node)->firstChild(); child; child = child
->nextSibling()) { |
| 977 appendTextContent(child, convertBRsToNewlines, content); | 908 appendTextContent(child, convertBRsToNewlines, content); |
| 978 } | 909 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 } | 1260 } |
| 1330 } | 1261 } |
| 1331 | 1262 |
| 1332 if (HashSet<RawPtr<MutationObserverRegistration> >* transientRegistry = tran
sientMutationObserverRegistry()) { | 1263 if (HashSet<RawPtr<MutationObserverRegistration> >* transientRegistry = tran
sientMutationObserverRegistry()) { |
| 1333 for (HashSet<RawPtr<MutationObserverRegistration> >::iterator iter = tra
nsientRegistry->begin(); iter != transientRegistry->end(); ++iter) { | 1264 for (HashSet<RawPtr<MutationObserverRegistration> >::iterator iter = tra
nsientRegistry->begin(); iter != transientRegistry->end(); ++iter) { |
| 1334 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1265 document().addMutationObserverTypes((*iter)->mutationTypes()); |
| 1335 } | 1266 } |
| 1336 } | 1267 } |
| 1337 } | 1268 } |
| 1338 | 1269 |
| 1339 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) | |
| 1340 { | |
| 1341 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) | |
| 1342 return false; | |
| 1343 | |
| 1344 Document& document = targetNode->document(); | |
| 1345 document.addListenerTypeIfNeeded(eventType); | |
| 1346 | |
| 1347 return true; | |
| 1348 } | |
| 1349 | |
| 1350 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) | 1270 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) |
| 1351 { | 1271 { |
| 1352 return tryAddEventListener(this, eventType, listener, useCapture); | 1272 if (!EventTarget::addEventListener(eventType, listener, useCapture)) |
| 1353 } | 1273 return false; |
| 1354 | 1274 |
| 1355 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, PassRefPtr<EventListener> listener, bool useCapture) | 1275 document().addListenerTypeIfNeeded(eventType); |
| 1356 { | |
| 1357 return targetNode->EventTarget::removeEventListener(eventType, listener, use
Capture); | |
| 1358 } | |
| 1359 | 1276 |
| 1360 bool Node::removeEventListener(const AtomicString& eventType, PassRefPtr<EventLi
stener> listener, bool useCapture) | 1277 return true; |
| 1361 { | |
| 1362 return tryRemoveEventListener(this, eventType, listener, useCapture); | |
| 1363 } | |
| 1364 | |
| 1365 void Node::removeAllEventListeners() | |
| 1366 { | |
| 1367 EventTarget::removeAllEventListeners(); | |
| 1368 } | 1278 } |
| 1369 | 1279 |
| 1370 void Node::removeAllEventListenersRecursively() | 1280 void Node::removeAllEventListenersRecursively() |
| 1371 { | 1281 { |
| 1372 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 1282 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
| 1373 node->removeAllEventListeners(); | 1283 node->removeAllEventListeners(); |
| 1374 if (ShadowRoot* root = node->shadowRoot()) | 1284 if (ShadowRoot* root = node->shadowRoot()) |
| 1375 root->removeAllEventListenersRecursively(); | 1285 root->removeAllEventListenersRecursively(); |
| 1376 } | 1286 } |
| 1377 } | 1287 } |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 node->showTreeForThis(); | 1733 node->showTreeForThis(); |
| 1824 } | 1734 } |
| 1825 | 1735 |
| 1826 void showNodePath(const blink::Node* node) | 1736 void showNodePath(const blink::Node* node) |
| 1827 { | 1737 { |
| 1828 if (node) | 1738 if (node) |
| 1829 node->showNodePathForThis(); | 1739 node->showNodePathForThis(); |
| 1830 } | 1740 } |
| 1831 | 1741 |
| 1832 #endif | 1742 #endif |
| OLD | NEW |