| 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 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 593 |
| 594 // Remove empty text nodes. | 594 // Remove empty text nodes. |
| 595 if (!nextText->length()) { | 595 if (!nextText->length()) { |
| 596 nextText->remove(IGNORE_EXCEPTION); | 596 nextText->remove(IGNORE_EXCEPTION); |
| 597 continue; | 597 continue; |
| 598 } | 598 } |
| 599 | 599 |
| 600 // Both non-empty text nodes. Merge them. | 600 // Both non-empty text nodes. Merge them. |
| 601 unsigned offset = text->length(); | 601 unsigned offset = text->length(); |
| 602 text->appendData(nextText->data()); | 602 text->appendData(nextText->data()); |
| 603 document()->textNodesMerged(nextText.get(), offset); | 603 document().textNodesMerged(nextText.get(), offset); |
| 604 nextText->remove(IGNORE_EXCEPTION); | 604 nextText->remove(IGNORE_EXCEPTION); |
| 605 } | 605 } |
| 606 | 606 |
| 607 node = NodeTraversal::nextPostOrder(node.get()); | 607 node = NodeTraversal::nextPostOrder(node.get()); |
| 608 } | 608 } |
| 609 } | 609 } |
| 610 | 610 |
| 611 const AtomicString& Node::prefix() const | 611 const AtomicString& Node::prefix() const |
| 612 { | 612 { |
| 613 // For nodes other than elements and attributes, the prefix is always null | 613 // For nodes other than elements and attributes, the prefix is always null |
| (...skipping 13 matching lines...) Expand all Loading... |
| 627 return nullAtom; | 627 return nullAtom; |
| 628 } | 628 } |
| 629 | 629 |
| 630 const AtomicString& Node::namespaceURI() const | 630 const AtomicString& Node::namespaceURI() const |
| 631 { | 631 { |
| 632 return nullAtom; | 632 return nullAtom; |
| 633 } | 633 } |
| 634 | 634 |
| 635 bool Node::isContentEditable(UserSelectAllTreatment treatment) | 635 bool Node::isContentEditable(UserSelectAllTreatment treatment) |
| 636 { | 636 { |
| 637 document()->updateStyleIfNeeded(); | 637 document().updateStyleIfNeeded(); |
| 638 return rendererIsEditable(Editable, treatment); | 638 return rendererIsEditable(Editable, treatment); |
| 639 } | 639 } |
| 640 | 640 |
| 641 bool Node::isContentRichlyEditable() | 641 bool Node::isContentRichlyEditable() |
| 642 { | 642 { |
| 643 document()->updateStyleIfNeeded(); | 643 document().updateStyleIfNeeded(); |
| 644 return rendererIsEditable(RichlyEditable, UserSelectAllIsAlwaysNonEditable); | 644 return rendererIsEditable(RichlyEditable, UserSelectAllIsAlwaysNonEditable); |
| 645 } | 645 } |
| 646 | 646 |
| 647 bool Node::rendererIsEditable(EditableLevel editableLevel, UserSelectAllTreatmen
t treatment) const | 647 bool Node::rendererIsEditable(EditableLevel editableLevel, UserSelectAllTreatmen
t treatment) const |
| 648 { | 648 { |
| 649 if (isPseudoElement()) | 649 if (isPseudoElement()) |
| 650 return false; | 650 return false; |
| 651 | 651 |
| 652 // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but | 652 // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but |
| 653 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion | 653 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion |
| (...skipping 23 matching lines...) Expand all Loading... |
| 677 | 677 |
| 678 bool Node::isEditableToAccessibility(EditableLevel editableLevel) const | 678 bool Node::isEditableToAccessibility(EditableLevel editableLevel) const |
| 679 { | 679 { |
| 680 if (rendererIsEditable(editableLevel)) | 680 if (rendererIsEditable(editableLevel)) |
| 681 return true; | 681 return true; |
| 682 | 682 |
| 683 // FIXME: Respect editableLevel for ARIA editable elements. | 683 // FIXME: Respect editableLevel for ARIA editable elements. |
| 684 if (editableLevel == RichlyEditable) | 684 if (editableLevel == RichlyEditable) |
| 685 return false; | 685 return false; |
| 686 | 686 |
| 687 ASSERT(document()); | |
| 688 ASSERT(AXObjectCache::accessibilityEnabled()); | 687 ASSERT(AXObjectCache::accessibilityEnabled()); |
| 689 ASSERT(document()->existingAXObjectCache()); | 688 ASSERT(document().existingAXObjectCache()); |
| 690 | 689 |
| 691 if (AXObjectCache* cache = document()->existingAXObjectCache()) | 690 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 692 return cache->rootAXEditableElement(this); | 691 return cache->rootAXEditableElement(this); |
| 693 | 692 |
| 694 return false; | 693 return false; |
| 695 } | 694 } |
| 696 | 695 |
| 697 bool Node::shouldUseInputMethod() | 696 bool Node::shouldUseInputMethod() |
| 698 { | 697 { |
| 699 return isContentEditable(UserSelectAllIsAlwaysNonEditable); | 698 return isContentEditable(UserSelectAllIsAlwaysNonEditable); |
| 700 } | 699 } |
| 701 | 700 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 | 784 |
| 786 void Node::setIsLink(bool isLink) | 785 void Node::setIsLink(bool isLink) |
| 787 { | 786 { |
| 788 setFlag(isLink && !SVGImage::isInSVGImage(toElement(this)), IsLinkFlag); | 787 setFlag(isLink && !SVGImage::isInSVGImage(toElement(this)), IsLinkFlag); |
| 789 } | 788 } |
| 790 | 789 |
| 791 void Node::markAncestorsWithChildNeedsDistributionRecalc() | 790 void Node::markAncestorsWithChildNeedsDistributionRecalc() |
| 792 { | 791 { |
| 793 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) | 792 for (Node* node = this; node && !node->childNeedsDistributionRecalc(); node
= node->parentOrShadowHostNode()) |
| 794 node->setChildNeedsDistributionRecalc(); | 793 node->setChildNeedsDistributionRecalc(); |
| 795 if (document()->childNeedsDistributionRecalc()) | 794 if (document().childNeedsDistributionRecalc()) |
| 796 document()->scheduleStyleRecalc(); | 795 document().scheduleStyleRecalc(); |
| 797 } | 796 } |
| 798 | 797 |
| 799 inline void Node::setStyleChange(StyleChangeType changeType) | 798 inline void Node::setStyleChange(StyleChangeType changeType) |
| 800 { | 799 { |
| 801 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; | 800 m_nodeFlags = (m_nodeFlags & ~StyleChangeMask) | changeType; |
| 802 } | 801 } |
| 803 | 802 |
| 804 inline void Node::markAncestorsWithChildNeedsStyleRecalc() | 803 inline void Node::markAncestorsWithChildNeedsStyleRecalc() |
| 805 { | 804 { |
| 806 for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRe
calc(); p = p->parentOrShadowHostNode()) | 805 for (ContainerNode* p = parentOrShadowHostNode(); p && !p->childNeedsStyleRe
calc(); p = p->parentOrShadowHostNode()) |
| 807 p->setChildNeedsStyleRecalc(); | 806 p->setChildNeedsStyleRecalc(); |
| 808 | 807 |
| 809 if (document()->needsStyleRecalc() || document()->childNeedsStyleRecalc()) | 808 if (document().needsStyleRecalc() || document().childNeedsStyleRecalc()) |
| 810 document()->scheduleStyleRecalc(); | 809 document().scheduleStyleRecalc(); |
| 811 } | 810 } |
| 812 | 811 |
| 813 void Node::refEventTarget() | 812 void Node::refEventTarget() |
| 814 { | 813 { |
| 815 ref(); | 814 ref(); |
| 816 } | 815 } |
| 817 | 816 |
| 818 void Node::derefEventTarget() | 817 void Node::derefEventTarget() |
| 819 { | 818 { |
| 820 deref(); | 819 deref(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 } | 857 } |
| 859 | 858 |
| 860 bool Node::shouldHaveFocusAppearance() const | 859 bool Node::shouldHaveFocusAppearance() const |
| 861 { | 860 { |
| 862 ASSERT(focused()); | 861 ASSERT(focused()); |
| 863 return true; | 862 return true; |
| 864 } | 863 } |
| 865 | 864 |
| 866 bool Node::isInert() const | 865 bool Node::isInert() const |
| 867 { | 866 { |
| 868 const HTMLDialogElement* dialog = document()->activeModalDialog(); | 867 const HTMLDialogElement* dialog = document().activeModalDialog(); |
| 869 if (dialog && !containsIncludingShadowDOM(dialog) && !dialog->containsInclud
ingShadowDOM(this)) | 868 if (dialog && !containsIncludingShadowDOM(dialog) && !dialog->containsInclud
ingShadowDOM(this)) |
| 870 return true; | 869 return true; |
| 871 return document()->ownerElement() && document()->ownerElement()->isInert(); | 870 return document().ownerElement() && document().ownerElement()->isInert(); |
| 872 } | 871 } |
| 873 | 872 |
| 874 unsigned Node::nodeIndex() const | 873 unsigned Node::nodeIndex() const |
| 875 { | 874 { |
| 876 Node *_tempNode = previousSibling(); | 875 Node *_tempNode = previousSibling(); |
| 877 unsigned count=0; | 876 unsigned count=0; |
| 878 for ( count=0; _tempNode; count++ ) | 877 for ( count=0; _tempNode; count++ ) |
| 879 _tempNode = _tempNode->previousSibling(); | 878 _tempNode = _tempNode->previousSibling(); |
| 880 return count; | 879 return count; |
| 881 } | 880 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 { | 917 { |
| 919 if (hasRareData() && (!attrName || isAttributeNode())) { | 918 if (hasRareData() && (!attrName || isAttributeNode())) { |
| 920 if (NodeListsNodeData* lists = rareData()->nodeLists()) | 919 if (NodeListsNodeData* lists = rareData()->nodeLists()) |
| 921 lists->clearChildNodeListCache(); | 920 lists->clearChildNodeListCache(); |
| 922 } | 921 } |
| 923 | 922 |
| 924 // Modifications to attributes that are not associated with an Element can't
invalidate NodeList caches. | 923 // Modifications to attributes that are not associated with an Element can't
invalidate NodeList caches. |
| 925 if (attrName && !attributeOwnerElement) | 924 if (attrName && !attributeOwnerElement) |
| 926 return; | 925 return; |
| 927 | 926 |
| 928 if (!document()->shouldInvalidateNodeListCaches(attrName)) | 927 if (!document().shouldInvalidateNodeListCaches(attrName)) |
| 929 return; | 928 return; |
| 930 | 929 |
| 931 document()->invalidateNodeListCaches(attrName); | 930 document().invalidateNodeListCaches(attrName); |
| 932 | 931 |
| 933 for (Node* node = this; node; node = node->parentNode()) { | 932 for (Node* node = this; node; node = node->parentNode()) { |
| 934 if (!node->hasRareData()) | 933 if (!node->hasRareData()) |
| 935 continue; | 934 continue; |
| 936 NodeRareData* data = node->rareData(); | 935 NodeRareData* data = node->rareData(); |
| 937 if (data->nodeLists()) | 936 if (data->nodeLists()) |
| 938 data->nodeLists()->invalidateCaches(attrName); | 937 data->nodeLists()->invalidateCaches(attrName); |
| 939 } | 938 } |
| 940 } | 939 } |
| 941 | 940 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 } | 993 } |
| 995 | 994 |
| 996 bool Node::containsIncludingShadowDOM(const Node* node) const | 995 bool Node::containsIncludingShadowDOM(const Node* node) const |
| 997 { | 996 { |
| 998 if (!node) | 997 if (!node) |
| 999 return false; | 998 return false; |
| 1000 | 999 |
| 1001 if (this == node) | 1000 if (this == node) |
| 1002 return true; | 1001 return true; |
| 1003 | 1002 |
| 1004 if (document() != node->document()) | 1003 if (&document() != &node->document()) |
| 1005 return false; | 1004 return false; |
| 1006 | 1005 |
| 1007 if (inDocument() != node->inDocument()) | 1006 if (inDocument() != node->inDocument()) |
| 1008 return false; | 1007 return false; |
| 1009 | 1008 |
| 1010 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildNodes
(); | 1009 bool hasChildren = isContainerNode() && toContainerNode(this)->hasChildNodes
(); |
| 1011 bool hasShadow = isElementNode() && toElement(this)->shadow(); | 1010 bool hasShadow = isElementNode() && toElement(this)->shadow(); |
| 1012 if (!hasChildren && !hasShadow) | 1011 if (!hasChildren && !hasShadow) |
| 1013 return false; | 1012 return false; |
| 1014 | 1013 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 // FIXME: innerHTML and editing should also lazyAttach. | 1055 // FIXME: innerHTML and editing should also lazyAttach. |
| 1057 if (node->attached()) | 1056 if (node->attached()) |
| 1058 node->detach(context); | 1057 node->detach(context); |
| 1059 node = NodeTraversal::nextSkippingChildren(node, root); | 1058 node = NodeTraversal::nextSkippingChildren(node, root); |
| 1060 } | 1059 } |
| 1061 } | 1060 } |
| 1062 | 1061 |
| 1063 void Node::reattach(const AttachContext& context) | 1062 void Node::reattach(const AttachContext& context) |
| 1064 { | 1063 { |
| 1065 // FIXME: Text::updateTextRenderer calls reattach outside a style recalc. | 1064 // FIXME: Text::updateTextRenderer calls reattach outside a style recalc. |
| 1066 ASSERT(document()->inStyleRecalc() || isTextNode()); | 1065 ASSERT(document().inStyleRecalc() || isTextNode()); |
| 1067 AttachContext reattachContext(context); | 1066 AttachContext reattachContext(context); |
| 1068 reattachContext.performingReattach = true; | 1067 reattachContext.performingReattach = true; |
| 1069 | 1068 |
| 1070 detachNode(this, reattachContext); | 1069 detachNode(this, reattachContext); |
| 1071 attach(reattachContext); | 1070 attach(reattachContext); |
| 1072 } | 1071 } |
| 1073 | 1072 |
| 1074 void Node::attach(const AttachContext&) | 1073 void Node::attach(const AttachContext&) |
| 1075 { | 1074 { |
| 1076 ASSERT(!attached()); | 1075 ASSERT(!attached()); |
| 1077 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende
rer()->isRenderView()))); | 1076 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende
rer()->isRenderView()))); |
| 1078 | 1077 |
| 1079 // If this node got a renderer it may be the previousRenderer() of sibling t
ext nodes and thus affect the | 1078 // If this node got a renderer it may be the previousRenderer() of sibling t
ext nodes and thus affect the |
| 1080 // result of Text::textRendererIsNeeded() for those nodes. | 1079 // result of Text::textRendererIsNeeded() for those nodes. |
| 1081 // FIXME: This loop is no longer required once we lazy attach all the time. | 1080 // FIXME: This loop is no longer required once we lazy attach all the time. |
| 1082 if (renderer() && !document()->inStyleRecalc()) { | 1081 if (renderer() && !document().inStyleRecalc()) { |
| 1083 for (Node* next = nextSibling(); next; next = next->nextSibling()) { | 1082 for (Node* next = nextSibling(); next; next = next->nextSibling()) { |
| 1084 if (next->renderer()) | 1083 if (next->renderer()) |
| 1085 break; | 1084 break; |
| 1086 if (!next->attached()) | 1085 if (!next->attached()) |
| 1087 break; // Assume this means none of the following siblings are a
ttached. | 1086 break; // Assume this means none of the following siblings are a
ttached. |
| 1088 if (!next->isTextNode()) | 1087 if (!next->isTextNode()) |
| 1089 continue; | 1088 continue; |
| 1090 ASSERT(!next->renderer()); | 1089 ASSERT(!next->renderer()); |
| 1091 toText(next)->reattach(); | 1090 toText(next)->reattach(); |
| 1092 // If we again decided not to create a renderer for next, we can bai
l out the loop, | 1091 // If we again decided not to create a renderer for next, we can bai
l out the loop, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1122 detachingNode = this; | 1121 detachingNode = this; |
| 1123 #endif | 1122 #endif |
| 1124 | 1123 |
| 1125 if (renderer()) | 1124 if (renderer()) |
| 1126 renderer()->destroyAndCleanupAnonymousWrappers(); | 1125 renderer()->destroyAndCleanupAnonymousWrappers(); |
| 1127 setRenderer(0); | 1126 setRenderer(0); |
| 1128 | 1127 |
| 1129 // Do not remove the element's hovered and active status | 1128 // Do not remove the element's hovered and active status |
| 1130 // if performing a reattach. | 1129 // if performing a reattach. |
| 1131 if (!context.performingReattach) { | 1130 if (!context.performingReattach) { |
| 1132 Document* doc = document(); | 1131 Document& doc = document(); |
| 1133 if (isUserActionElement()) { | 1132 if (isUserActionElement()) { |
| 1134 if (hovered()) | 1133 if (hovered()) |
| 1135 doc->hoveredNodeDetached(this); | 1134 doc.hoveredNodeDetached(this); |
| 1136 if (inActiveChain()) | 1135 if (inActiveChain()) |
| 1137 doc->activeChainNodeDetached(this); | 1136 doc.activeChainNodeDetached(this); |
| 1138 doc->userActionElements().didDetach(this); | 1137 doc.userActionElements().didDetach(this); |
| 1139 } | 1138 } |
| 1140 } | 1139 } |
| 1141 | 1140 |
| 1142 clearAttached(); | 1141 clearAttached(); |
| 1143 | 1142 |
| 1144 #ifndef NDEBUG | 1143 #ifndef NDEBUG |
| 1145 detachingNode = 0; | 1144 detachingNode = 0; |
| 1146 #endif | 1145 #endif |
| 1147 } | 1146 } |
| 1148 | 1147 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 // We allow selections to begin within an element that has -webkit-user-
select: none set, | 1221 // We allow selections to begin within an element that has -webkit-user-
select: none set, |
| 1223 // but if the element is draggable then dragging should take priority ov
er selection. | 1222 // but if the element is draggable then dragging should take priority ov
er selection. |
| 1224 if (style->userDrag() == DRAG_ELEMENT && style->userSelect() == SELECT_N
ONE) | 1223 if (style->userDrag() == DRAG_ELEMENT && style->userSelect() == SELECT_N
ONE) |
| 1225 return false; | 1224 return false; |
| 1226 } | 1225 } |
| 1227 return parentOrShadowHostNode() ? parentOrShadowHostNode()->canStartSelectio
n() : true; | 1226 return parentOrShadowHostNode() ? parentOrShadowHostNode()->canStartSelectio
n() : true; |
| 1228 } | 1227 } |
| 1229 | 1228 |
| 1230 bool Node::isRegisteredWithNamedFlow() const | 1229 bool Node::isRegisteredWithNamedFlow() const |
| 1231 { | 1230 { |
| 1232 return document()->renderView()->flowThreadController()->isContentNodeRegist
eredWithAnyNamedFlow(this); | 1231 return document().renderView()->flowThreadController()->isContentNodeRegiste
redWithAnyNamedFlow(this); |
| 1233 } | 1232 } |
| 1234 | 1233 |
| 1235 Element* Node::shadowHost() const | 1234 Element* Node::shadowHost() const |
| 1236 { | 1235 { |
| 1237 if (ShadowRoot* root = containingShadowRoot()) | 1236 if (ShadowRoot* root = containingShadowRoot()) |
| 1238 return root->host(); | 1237 return root->host(); |
| 1239 return 0; | 1238 return 0; |
| 1240 } | 1239 } |
| 1241 | 1240 |
| 1242 Node* Node::deprecatedShadowAncestorNode() const | 1241 Node* Node::deprecatedShadowAncestorNode() const |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 | 1311 |
| 1313 bool Node::isRootEditableElement() const | 1312 bool Node::isRootEditableElement() const |
| 1314 { | 1313 { |
| 1315 return rendererIsEditable() && isElementNode() && (!parentNode() || !parentN
ode()->rendererIsEditable() | 1314 return rendererIsEditable() && isElementNode() && (!parentNode() || !parentN
ode()->rendererIsEditable() |
| 1316 || !parentNode()->isElementNode() || hasTagName(bodyTag)); | 1315 || !parentNode()->isElementNode() || hasTagName(bodyTag)); |
| 1317 } | 1316 } |
| 1318 | 1317 |
| 1319 Element* Node::rootEditableElement(EditableType editableType) const | 1318 Element* Node::rootEditableElement(EditableType editableType) const |
| 1320 { | 1319 { |
| 1321 if (editableType == HasEditableAXRole) { | 1320 if (editableType == HasEditableAXRole) { |
| 1322 if (AXObjectCache* cache = document()->existingAXObjectCache()) | 1321 if (AXObjectCache* cache = document().existingAXObjectCache()) |
| 1323 return const_cast<Element*>(cache->rootAXEditableElement(this)); | 1322 return const_cast<Element*>(cache->rootAXEditableElement(this)); |
| 1324 } | 1323 } |
| 1325 | 1324 |
| 1326 return rootEditableElement(); | 1325 return rootEditableElement(); |
| 1327 } | 1326 } |
| 1328 | 1327 |
| 1329 Element* Node::rootEditableElement() const | 1328 Element* Node::rootEditableElement() const |
| 1330 { | 1329 { |
| 1331 Element* result = 0; | 1330 Element* result = 0; |
| 1332 for (Node* n = const_cast<Node*>(this); n && n->rendererIsEditable(); n = n-
>parentNode()) { | 1331 for (Node* n = const_cast<Node*>(this); n && n->rendererIsEditable(); n = n-
>parentNode()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1343 return n ? enclosingBlockFlowElement() == n->enclosingBlockFlowElement() : f
alse; | 1342 return n ? enclosingBlockFlowElement() == n->enclosingBlockFlowElement() : f
alse; |
| 1344 } | 1343 } |
| 1345 | 1344 |
| 1346 // FIXME: End of obviously misplaced HTML editing functions. Try to move these
out of Node. | 1345 // FIXME: End of obviously misplaced HTML editing functions. Try to move these
out of Node. |
| 1347 | 1346 |
| 1348 PassRefPtr<NodeList> Node::getElementsByTagName(const AtomicString& localName) | 1347 PassRefPtr<NodeList> Node::getElementsByTagName(const AtomicString& localName) |
| 1349 { | 1348 { |
| 1350 if (localName.isNull()) | 1349 if (localName.isNull()) |
| 1351 return 0; | 1350 return 0; |
| 1352 | 1351 |
| 1353 if (document()->isHTMLDocument()) | 1352 if (document().isHTMLDocument()) |
| 1354 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLT
agNodeList>(this, HTMLTagNodeListType, localName); | 1353 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLT
agNodeList>(this, HTMLTagNodeListType, localName); |
| 1355 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<TagNodeLi
st>(this, TagNodeListType, localName); | 1354 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<TagNodeLi
st>(this, TagNodeListType, localName); |
| 1356 } | 1355 } |
| 1357 | 1356 |
| 1358 PassRefPtr<NodeList> Node::getElementsByTagNameNS(const AtomicString& namespaceU
RI, const AtomicString& localName) | 1357 PassRefPtr<NodeList> Node::getElementsByTagNameNS(const AtomicString& namespaceU
RI, const AtomicString& localName) |
| 1359 { | 1358 { |
| 1360 if (localName.isNull()) | 1359 if (localName.isNull()) |
| 1361 return 0; | 1360 return 0; |
| 1362 | 1361 |
| 1363 if (namespaceURI == starAtom) | 1362 if (namespaceURI == starAtom) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1382 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<RadioNode
List>(this, RadioNodeListType, name); | 1381 return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<RadioNode
List>(this, RadioNodeListType, name); |
| 1383 } | 1382 } |
| 1384 | 1383 |
| 1385 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception
State& es) | 1384 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception
State& es) |
| 1386 { | 1385 { |
| 1387 if (selectors.isEmpty()) { | 1386 if (selectors.isEmpty()) { |
| 1388 es.throwDOMException(SyntaxError); | 1387 es.throwDOMException(SyntaxError); |
| 1389 return 0; | 1388 return 0; |
| 1390 } | 1389 } |
| 1391 | 1390 |
| 1392 SelectorQuery* selectorQuery = document()->selectorQueryCache()->add(selecto
rs, document(), es); | 1391 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
s, &document(), es); |
| 1393 if (!selectorQuery) | 1392 if (!selectorQuery) |
| 1394 return 0; | 1393 return 0; |
| 1395 return selectorQuery->queryFirst(this); | 1394 return selectorQuery->queryFirst(this); |
| 1396 } | 1395 } |
| 1397 | 1396 |
| 1398 PassRefPtr<NodeList> Node::querySelectorAll(const AtomicString& selectors, Excep
tionState& es) | 1397 PassRefPtr<NodeList> Node::querySelectorAll(const AtomicString& selectors, Excep
tionState& es) |
| 1399 { | 1398 { |
| 1400 if (selectors.isEmpty()) { | 1399 if (selectors.isEmpty()) { |
| 1401 es.throwDOMException(SyntaxError); | 1400 es.throwDOMException(SyntaxError); |
| 1402 return 0; | 1401 return 0; |
| 1403 } | 1402 } |
| 1404 | 1403 |
| 1405 SelectorQuery* selectorQuery = document()->selectorQueryCache()->add(selecto
rs, document(), es); | 1404 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector
s, &document(), es); |
| 1406 if (!selectorQuery) | 1405 if (!selectorQuery) |
| 1407 return 0; | 1406 return 0; |
| 1408 return selectorQuery->queryAll(this); | 1407 return selectorQuery->queryAll(this); |
| 1409 } | 1408 } |
| 1410 | 1409 |
| 1411 Document* Node::ownerDocument() const | 1410 Document* Node::ownerDocument() const |
| 1412 { | 1411 { |
| 1413 Document* doc = document(); | 1412 Document* doc = &document(); |
| 1414 return doc == this ? 0 : doc; | 1413 return doc == this ? 0 : doc; |
| 1415 } | 1414 } |
| 1416 | 1415 |
| 1417 KURL Node::baseURI() const | 1416 KURL Node::baseURI() const |
| 1418 { | 1417 { |
| 1419 return parentNode() ? parentNode()->baseURI() : KURL(); | 1418 return parentNode() ? parentNode()->baseURI() : KURL(); |
| 1420 } | 1419 } |
| 1421 | 1420 |
| 1422 bool Node::isEqualNode(Node* other) const | 1421 bool Node::isEqualNode(Node* other) const |
| 1423 { | 1422 { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 setNodeValue(text); | 1702 setNodeValue(text); |
| 1704 return; | 1703 return; |
| 1705 case ELEMENT_NODE: | 1704 case ELEMENT_NODE: |
| 1706 case ATTRIBUTE_NODE: | 1705 case ATTRIBUTE_NODE: |
| 1707 case ENTITY_NODE: | 1706 case ENTITY_NODE: |
| 1708 case DOCUMENT_FRAGMENT_NODE: { | 1707 case DOCUMENT_FRAGMENT_NODE: { |
| 1709 RefPtr<ContainerNode> container = toContainerNode(this); | 1708 RefPtr<ContainerNode> container = toContainerNode(this); |
| 1710 ChildListMutationScope mutation(this); | 1709 ChildListMutationScope mutation(this); |
| 1711 container->removeChildren(); | 1710 container->removeChildren(); |
| 1712 if (!text.isEmpty()) | 1711 if (!text.isEmpty()) |
| 1713 container->appendChild(document()->createTextNode(text), es); | 1712 container->appendChild(document().createTextNode(text), es); |
| 1714 return; | 1713 return; |
| 1715 } | 1714 } |
| 1716 case DOCUMENT_NODE: | 1715 case DOCUMENT_NODE: |
| 1717 case DOCUMENT_TYPE_NODE: | 1716 case DOCUMENT_TYPE_NODE: |
| 1718 case NOTATION_NODE: | 1717 case NOTATION_NODE: |
| 1719 case XPATH_NAMESPACE_NODE: | 1718 case XPATH_NAMESPACE_NODE: |
| 1720 // Do nothing. | 1719 // Do nothing. |
| 1721 return; | 1720 return; |
| 1722 } | 1721 } |
| 1723 ASSERT_NOT_REACHED(); | 1722 ASSERT_NOT_REACHED(); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 result = "<none>"; | 2052 result = "<none>"; |
| 2054 else | 2053 else |
| 2055 result = s; | 2054 result = s; |
| 2056 | 2055 |
| 2057 strncpy(buffer, result.utf8().data(), length - 1); | 2056 strncpy(buffer, result.utf8().data(), length - 1); |
| 2058 } | 2057 } |
| 2059 | 2058 |
| 2060 static ContainerNode* parentOrShadowHostOrFrameOwner(const Node* node) | 2059 static ContainerNode* parentOrShadowHostOrFrameOwner(const Node* node) |
| 2061 { | 2060 { |
| 2062 ContainerNode* parent = node->parentOrShadowHostNode(); | 2061 ContainerNode* parent = node->parentOrShadowHostNode(); |
| 2063 if (!parent && node->document()->frame()) | 2062 if (!parent && node->document().frame()) |
| 2064 parent = node->document()->frame()->ownerElement(); | 2063 parent = node->document().frame()->ownerElement(); |
| 2065 return parent; | 2064 return parent; |
| 2066 } | 2065 } |
| 2067 | 2066 |
| 2068 static void showSubTreeAcrossFrame(const Node* node, const Node* markedNode, con
st String& indent) | 2067 static void showSubTreeAcrossFrame(const Node* node, const Node* markedNode, con
st String& indent) |
| 2069 { | 2068 { |
| 2070 if (node == markedNode) | 2069 if (node == markedNode) |
| 2071 fputs("*", stderr); | 2070 fputs("*", stderr); |
| 2072 fputs(indent.utf8().data(), stderr); | 2071 fputs(indent.utf8().data(), stderr); |
| 2073 node->showNode(); | 2072 node->showNode(); |
| 2074 if (node->isShadowRoot()) { | 2073 if (node->isShadowRoot()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 return 0; | 2126 return 0; |
| 2128 } | 2127 } |
| 2129 | 2128 |
| 2130 const AtomicString& Node::interfaceName() const | 2129 const AtomicString& Node::interfaceName() const |
| 2131 { | 2130 { |
| 2132 return eventNames().interfaceForNode; | 2131 return eventNames().interfaceForNode; |
| 2133 } | 2132 } |
| 2134 | 2133 |
| 2135 ScriptExecutionContext* Node::scriptExecutionContext() const | 2134 ScriptExecutionContext* Node::scriptExecutionContext() const |
| 2136 { | 2135 { |
| 2137 return document(); | 2136 return &document(); |
| 2138 } | 2137 } |
| 2139 | 2138 |
| 2140 void Node::didMoveToNewDocument(Document* oldDocument) | 2139 void Node::didMoveToNewDocument(Document* oldDocument) |
| 2141 { | 2140 { |
| 2142 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument); | 2141 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument); |
| 2143 | 2142 |
| 2144 if (const EventTargetData* eventTargetData = this->eventTargetData()) { | 2143 if (const EventTargetData* eventTargetData = this->eventTargetData()) { |
| 2145 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; | 2144 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; |
| 2146 if (!listenerMap.isEmpty()) { | 2145 if (!listenerMap.isEmpty()) { |
| 2147 Vector<AtomicString> types = listenerMap.eventTypes(); | 2146 Vector<AtomicString> types = listenerMap.eventTypes(); |
| 2148 for (unsigned i = 0; i < types.size(); ++i) | 2147 for (unsigned i = 0; i < types.size(); ++i) |
| 2149 document()->addListenerTypeIfNeeded(types[i]); | 2148 document().addListenerTypeIfNeeded(types[i]); |
| 2150 } | 2149 } |
| 2151 } | 2150 } |
| 2152 | 2151 |
| 2153 if (AXObjectCache::accessibilityEnabled() && oldDocument) | 2152 if (AXObjectCache::accessibilityEnabled() && oldDocument) |
| 2154 if (AXObjectCache* cache = oldDocument->existingAXObjectCache()) | 2153 if (AXObjectCache* cache = oldDocument->existingAXObjectCache()) |
| 2155 cache->remove(this); | 2154 cache->remove(this); |
| 2156 | 2155 |
| 2157 const EventListenerVector& mousewheelListeners = getEventListeners(eventName
s().mousewheelEvent); | 2156 const EventListenerVector& mousewheelListeners = getEventListeners(eventName
s().mousewheelEvent); |
| 2158 for (size_t i = 0; i < mousewheelListeners.size(); ++i) { | 2157 for (size_t i = 0; i < mousewheelListeners.size(); ++i) { |
| 2159 oldDocument->didRemoveWheelEventHandler(); | 2158 oldDocument->didRemoveWheelEventHandler(); |
| 2160 document()->didAddWheelEventHandler(); | 2159 document().didAddWheelEventHandler(); |
| 2161 } | 2160 } |
| 2162 | 2161 |
| 2163 const EventListenerVector& wheelListeners = getEventListeners(eventNames().w
heelEvent); | 2162 const EventListenerVector& wheelListeners = getEventListeners(eventNames().w
heelEvent); |
| 2164 for (size_t i = 0; i < wheelListeners.size(); ++i) { | 2163 for (size_t i = 0; i < wheelListeners.size(); ++i) { |
| 2165 oldDocument->didRemoveWheelEventHandler(); | 2164 oldDocument->didRemoveWheelEventHandler(); |
| 2166 document()->didAddWheelEventHandler(); | 2165 document().didAddWheelEventHandler(); |
| 2167 } | 2166 } |
| 2168 | 2167 |
| 2169 if (const TouchEventTargetSet* touchHandlers = oldDocument ? oldDocument->to
uchEventTargets() : 0) { | 2168 if (const TouchEventTargetSet* touchHandlers = oldDocument ? oldDocument->to
uchEventTargets() : 0) { |
| 2170 while (touchHandlers->contains(this)) { | 2169 while (touchHandlers->contains(this)) { |
| 2171 oldDocument->didRemoveTouchEventHandler(this); | 2170 oldDocument->didRemoveTouchEventHandler(this); |
| 2172 document()->didAddTouchEventHandler(this); | 2171 document().didAddTouchEventHandler(this); |
| 2173 } | 2172 } |
| 2174 } | 2173 } |
| 2175 | 2174 |
| 2176 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv
erRegistry()) { | 2175 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv
erRegistry()) { |
| 2177 for (size_t i = 0; i < registry->size(); ++i) { | 2176 for (size_t i = 0; i < registry->size(); ++i) { |
| 2178 document()->addMutationObserverTypes(registry->at(i)->mutationTypes(
)); | 2177 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
| 2179 } | 2178 } |
| 2180 } | 2179 } |
| 2181 | 2180 |
| 2182 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut
ationObserverRegistry()) { | 2181 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut
ationObserverRegistry()) { |
| 2183 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe
gistry->begin(); iter != transientRegistry->end(); ++iter) { | 2182 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe
gistry->begin(); iter != transientRegistry->end(); ++iter) { |
| 2184 document()->addMutationObserverTypes((*iter)->mutationTypes()); | 2183 document().addMutationObserverTypes((*iter)->mutationTypes()); |
| 2185 } | 2184 } |
| 2186 } | 2185 } |
| 2187 } | 2186 } |
| 2188 | 2187 |
| 2189 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) | 2188 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) |
| 2190 { | 2189 { |
| 2191 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) | 2190 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) |
| 2192 return false; | 2191 return false; |
| 2193 | 2192 |
| 2194 Document* document = targetNode->document(); | 2193 Document& document = targetNode->document(); |
| 2195 document->addListenerTypeIfNeeded(eventType); | 2194 document.addListenerTypeIfNeeded(eventType); |
| 2196 if (eventType == eventNames().wheelEvent || eventType == eventNames().mousew
heelEvent) | 2195 if (eventType == eventNames().wheelEvent || eventType == eventNames().mousew
heelEvent) |
| 2197 document->didAddWheelEventHandler(); | 2196 document.didAddWheelEventHandler(); |
| 2198 else if (eventNames().isTouchEventType(eventType)) | 2197 else if (eventNames().isTouchEventType(eventType)) |
| 2199 document->didAddTouchEventHandler(targetNode); | 2198 document.didAddTouchEventHandler(targetNode); |
| 2200 | 2199 |
| 2201 return true; | 2200 return true; |
| 2202 } | 2201 } |
| 2203 | 2202 |
| 2204 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) | 2203 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) |
| 2205 { | 2204 { |
| 2206 return tryAddEventListener(this, eventType, listener, useCapture); | 2205 return tryAddEventListener(this, eventType, listener, useCapture); |
| 2207 } | 2206 } |
| 2208 | 2207 |
| 2209 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) | 2208 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) |
| 2210 { | 2209 { |
| 2211 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) | 2210 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) |
| 2212 return false; | 2211 return false; |
| 2213 | 2212 |
| 2214 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of | 2213 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of |
| 2215 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 | 2214 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 |
| 2216 Document* document = targetNode->document(); | 2215 Document& document = targetNode->document(); |
| 2217 if (eventType == eventNames().wheelEvent || eventType == eventNames().mousew
heelEvent) | 2216 if (eventType == eventNames().wheelEvent || eventType == eventNames().mousew
heelEvent) |
| 2218 document->didRemoveWheelEventHandler(); | 2217 document.didRemoveWheelEventHandler(); |
| 2219 else if (eventNames().isTouchEventType(eventType)) | 2218 else if (eventNames().isTouchEventType(eventType)) |
| 2220 document->didRemoveTouchEventHandler(targetNode); | 2219 document.didRemoveTouchEventHandler(targetNode); |
| 2221 | 2220 |
| 2222 return true; | 2221 return true; |
| 2223 } | 2222 } |
| 2224 | 2223 |
| 2225 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) | 2224 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) |
| 2226 { | 2225 { |
| 2227 return tryRemoveEventListener(this, eventType, listener, useCapture); | 2226 return tryRemoveEventListener(this, eventType, listener, useCapture); |
| 2228 } | 2227 } |
| 2229 | 2228 |
| 2230 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; | 2229 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2311 registration = registry[i].get(); | 2310 registration = registry[i].get(); |
| 2312 registration->resetObservation(options, attributeFilter); | 2311 registration->resetObservation(options, attributeFilter); |
| 2313 } | 2312 } |
| 2314 } | 2313 } |
| 2315 | 2314 |
| 2316 if (!registration) { | 2315 if (!registration) { |
| 2317 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); | 2316 registry.append(MutationObserverRegistration::create(observer, this, opt
ions, attributeFilter)); |
| 2318 registration = registry.last().get(); | 2317 registration = registry.last().get(); |
| 2319 } | 2318 } |
| 2320 | 2319 |
| 2321 document()->addMutationObserverTypes(registration->mutationTypes()); | 2320 document().addMutationObserverTypes(registration->mutationTypes()); |
| 2322 } | 2321 } |
| 2323 | 2322 |
| 2324 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) | 2323 void Node::unregisterMutationObserver(MutationObserverRegistration* registration
) |
| 2325 { | 2324 { |
| 2326 Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRe
gistry(); | 2325 Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRe
gistry(); |
| 2327 ASSERT(registry); | 2326 ASSERT(registry); |
| 2328 if (!registry) | 2327 if (!registry) |
| 2329 return; | 2328 return; |
| 2330 | 2329 |
| 2331 size_t index = registry->find(registration); | 2330 size_t index = registry->find(registration); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2351 ASSERT(transientRegistry); | 2350 ASSERT(transientRegistry); |
| 2352 if (!transientRegistry) | 2351 if (!transientRegistry) |
| 2353 return; | 2352 return; |
| 2354 | 2353 |
| 2355 ASSERT(transientRegistry->contains(registration)); | 2354 ASSERT(transientRegistry->contains(registration)); |
| 2356 transientRegistry->remove(registration); | 2355 transientRegistry->remove(registration); |
| 2357 } | 2356 } |
| 2358 | 2357 |
| 2359 void Node::notifyMutationObserversNodeWillDetach() | 2358 void Node::notifyMutationObserversNodeWillDetach() |
| 2360 { | 2359 { |
| 2361 if (!document()->hasMutationObservers()) | 2360 if (!document().hasMutationObservers()) |
| 2362 return; | 2361 return; |
| 2363 | 2362 |
| 2364 for (Node* node = parentNode(); node; node = node->parentNode()) { | 2363 for (Node* node = parentNode(); node; node = node->parentNode()) { |
| 2365 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = node->muta
tionObserverRegistry()) { | 2364 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = node->muta
tionObserverRegistry()) { |
| 2366 const size_t size = registry->size(); | 2365 const size_t size = registry->size(); |
| 2367 for (size_t i = 0; i < size; ++i) | 2366 for (size_t i = 0; i < size; ++i) |
| 2368 registry->at(i)->observedSubtreeNodeWillDetach(this); | 2367 registry->at(i)->observedSubtreeNodeWillDetach(this); |
| 2369 } | 2368 } |
| 2370 | 2369 |
| 2371 if (HashSet<MutationObserverRegistration*>* transientRegistry = node->tr
ansientMutationObserverRegistry()) { | 2370 if (HashSet<MutationObserverRegistration*>* transientRegistry = node->tr
ansientMutationObserverRegistry()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2405 return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(ev
ent)); | 2404 return EventDispatcher::dispatchEvent(this, EventDispatchMediator::create(ev
ent)); |
| 2406 } | 2405 } |
| 2407 | 2406 |
| 2408 void Node::dispatchSubtreeModifiedEvent() | 2407 void Node::dispatchSubtreeModifiedEvent() |
| 2409 { | 2408 { |
| 2410 if (isInShadowTree()) | 2409 if (isInShadowTree()) |
| 2411 return; | 2410 return; |
| 2412 | 2411 |
| 2413 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 2412 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
| 2414 | 2413 |
| 2415 if (!document()->hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) | 2414 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) |
| 2416 return; | 2415 return; |
| 2417 | 2416 |
| 2418 dispatchScopedEvent(MutationEvent::create(eventNames().DOMSubtreeModifiedEve
nt, true)); | 2417 dispatchScopedEvent(MutationEvent::create(eventNames().DOMSubtreeModifiedEve
nt, true)); |
| 2419 } | 2418 } |
| 2420 | 2419 |
| 2421 bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEven
t) | 2420 bool Node::dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEven
t) |
| 2422 { | 2421 { |
| 2423 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 2422 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); |
| 2424 RefPtr<UIEvent> event = UIEvent::create(eventNames().DOMActivateEvent, true,
true, document()->defaultView(), detail); | 2423 RefPtr<UIEvent> event = UIEvent::create(eventNames().DOMActivateEvent, true,
true, document().defaultView(), detail); |
| 2425 event->setUnderlyingEvent(underlyingEvent); | 2424 event->setUnderlyingEvent(underlyingEvent); |
| 2426 dispatchScopedEvent(event); | 2425 dispatchScopedEvent(event); |
| 2427 return event->defaultHandled(); | 2426 return event->defaultHandled(); |
| 2428 } | 2427 } |
| 2429 | 2428 |
| 2430 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event) | 2429 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event) |
| 2431 { | 2430 { |
| 2432 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::c
reate(KeyboardEvent::create(event, document()->defaultView()))); | 2431 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::c
reate(KeyboardEvent::create(event, document().defaultView()))); |
| 2433 } | 2432 } |
| 2434 | 2433 |
| 2435 bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicStrin
g& eventType, | 2434 bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicStrin
g& eventType, |
| 2436 int detail, Node* relatedTarget) | 2435 int detail, Node* relatedTarget) |
| 2437 { | 2436 { |
| 2438 return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::crea
te(MouseEvent::create(eventType, document()->defaultView(), event, detail, relat
edTarget))); | 2437 return EventDispatcher::dispatchEvent(this, MouseEventDispatchMediator::crea
te(MouseEvent::create(eventType, document().defaultView(), event, detail, relate
dTarget))); |
| 2439 } | 2438 } |
| 2440 | 2439 |
| 2441 bool Node::dispatchGestureEvent(const PlatformGestureEvent& event) | 2440 bool Node::dispatchGestureEvent(const PlatformGestureEvent& event) |
| 2442 { | 2441 { |
| 2443 RefPtr<GestureEvent> gestureEvent = GestureEvent::create(document()->default
View(), event); | 2442 RefPtr<GestureEvent> gestureEvent = GestureEvent::create(document().defaultV
iew(), event); |
| 2444 if (!gestureEvent.get()) | 2443 if (!gestureEvent.get()) |
| 2445 return false; | 2444 return false; |
| 2446 return EventDispatcher::dispatchEvent(this, GestureEventDispatchMediator::cr
eate(gestureEvent)); | 2445 return EventDispatcher::dispatchEvent(this, GestureEventDispatchMediator::cr
eate(gestureEvent)); |
| 2447 } | 2446 } |
| 2448 | 2447 |
| 2449 bool Node::dispatchTouchEvent(PassRefPtr<TouchEvent> event) | 2448 bool Node::dispatchTouchEvent(PassRefPtr<TouchEvent> event) |
| 2450 { | 2449 { |
| 2451 return EventDispatcher::dispatchEvent(this, TouchEventDispatchMediator::crea
te(event)); | 2450 return EventDispatcher::dispatchEvent(this, TouchEventDispatchMediator::crea
te(event)); |
| 2452 } | 2451 } |
| 2453 | 2452 |
| 2454 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions, SimulatedClickVisualOptions visualOptions) | 2453 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve
ntOptions eventOptions, SimulatedClickVisualOptions visualOptions) |
| 2455 { | 2454 { |
| 2456 EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions,
visualOptions); | 2455 EventDispatcher::dispatchSimulatedClick(this, underlyingEvent, eventOptions,
visualOptions); |
| 2457 } | 2456 } |
| 2458 | 2457 |
| 2459 bool Node::dispatchBeforeLoadEvent(const String& sourceURL) | 2458 bool Node::dispatchBeforeLoadEvent(const String& sourceURL) |
| 2460 { | 2459 { |
| 2461 if (!document()->hasListenerType(Document::BEFORELOAD_LISTENER)) | 2460 if (!document().hasListenerType(Document::BEFORELOAD_LISTENER)) |
| 2462 return true; | 2461 return true; |
| 2463 | 2462 |
| 2464 RefPtr<Node> protector(this); | 2463 RefPtr<Node> protector(this); |
| 2465 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; | 2464 RefPtr<BeforeLoadEvent> beforeLoadEvent = BeforeLoadEvent::create(sourceURL)
; |
| 2466 dispatchEvent(beforeLoadEvent.get()); | 2465 dispatchEvent(beforeLoadEvent.get()); |
| 2467 return !beforeLoadEvent->defaultPrevented(); | 2466 return !beforeLoadEvent->defaultPrevented(); |
| 2468 } | 2467 } |
| 2469 | 2468 |
| 2470 bool Node::dispatchWheelEvent(const PlatformWheelEvent& event) | 2469 bool Node::dispatchWheelEvent(const PlatformWheelEvent& event) |
| 2471 { | 2470 { |
| 2472 return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::crea
te(event, document()->defaultView())); | 2471 return EventDispatcher::dispatchEvent(this, WheelEventDispatchMediator::crea
te(event, document().defaultView())); |
| 2473 } | 2472 } |
| 2474 | 2473 |
| 2475 void Node::dispatchChangeEvent() | 2474 void Node::dispatchChangeEvent() |
| 2476 { | 2475 { |
| 2477 dispatchScopedEvent(Event::createBubble(eventNames().changeEvent)); | 2476 dispatchScopedEvent(Event::createBubble(eventNames().changeEvent)); |
| 2478 } | 2477 } |
| 2479 | 2478 |
| 2480 void Node::dispatchInputEvent() | 2479 void Node::dispatchInputEvent() |
| 2481 { | 2480 { |
| 2482 dispatchScopedEvent(Event::createBubble(eventNames().inputEvent)); | 2481 dispatchScopedEvent(Event::createBubble(eventNames().inputEvent)); |
| 2483 } | 2482 } |
| 2484 | 2483 |
| 2485 void Node::defaultEventHandler(Event* event) | 2484 void Node::defaultEventHandler(Event* event) |
| 2486 { | 2485 { |
| 2487 if (event->target() != this) | 2486 if (event->target() != this) |
| 2488 return; | 2487 return; |
| 2489 const AtomicString& eventType = event->type(); | 2488 const AtomicString& eventType = event->type(); |
| 2490 if (eventType == eventNames().keydownEvent || eventType == eventNames().keyp
ressEvent) { | 2489 if (eventType == eventNames().keydownEvent || eventType == eventNames().keyp
ressEvent) { |
| 2491 if (event->isKeyboardEvent()) { | 2490 if (event->isKeyboardEvent()) { |
| 2492 if (Frame* frame = document()->frame()) | 2491 if (Frame* frame = document().frame()) |
| 2493 frame->eventHandler()->defaultKeyboardEventHandler(toKeyboardEve
nt(event)); | 2492 frame->eventHandler()->defaultKeyboardEventHandler(toKeyboardEve
nt(event)); |
| 2494 } | 2493 } |
| 2495 } else if (eventType == eventNames().clickEvent) { | 2494 } else if (eventType == eventNames().clickEvent) { |
| 2496 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail()
: 0; | 2495 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail()
: 0; |
| 2497 if (dispatchDOMActivateEvent(detail, event)) | 2496 if (dispatchDOMActivateEvent(detail, event)) |
| 2498 event->setDefaultHandled(); | 2497 event->setDefaultHandled(); |
| 2499 } else if (eventType == eventNames().contextmenuEvent) { | 2498 } else if (eventType == eventNames().contextmenuEvent) { |
| 2500 if (Page* page = document()->page()) | 2499 if (Page* page = document().page()) |
| 2501 page->contextMenuController().handleContextMenuEvent(event); | 2500 page->contextMenuController().handleContextMenuEvent(event); |
| 2502 } else if (eventType == eventNames().textInputEvent) { | 2501 } else if (eventType == eventNames().textInputEvent) { |
| 2503 if (event->hasInterface(eventNames().interfaceForTextEvent)) | 2502 if (event->hasInterface(eventNames().interfaceForTextEvent)) |
| 2504 if (Frame* frame = document()->frame()) | 2503 if (Frame* frame = document().frame()) |
| 2505 frame->eventHandler()->defaultTextInputEventHandler(static_cast<
TextEvent*>(event)); | 2504 frame->eventHandler()->defaultTextInputEventHandler(static_cast<
TextEvent*>(event)); |
| 2506 #if OS(WINDOWS) | 2505 #if OS(WINDOWS) |
| 2507 } else if (eventType == eventNames().mousedownEvent && event->isMouseEvent()
) { | 2506 } else if (eventType == eventNames().mousedownEvent && event->isMouseEvent()
) { |
| 2508 MouseEvent* mouseEvent = toMouseEvent(event); | 2507 MouseEvent* mouseEvent = toMouseEvent(event); |
| 2509 if (mouseEvent->button() == MiddleButton) { | 2508 if (mouseEvent->button() == MiddleButton) { |
| 2510 if (enclosingLinkEventParentOrSelf()) | 2509 if (enclosingLinkEventParentOrSelf()) |
| 2511 return; | 2510 return; |
| 2512 | 2511 |
| 2513 RenderObject* renderer = this->renderer(); | 2512 RenderObject* renderer = this->renderer(); |
| 2514 while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->ca
nBeScrolledAndHasScrollableArea())) | 2513 while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->ca
nBeScrolledAndHasScrollableArea())) |
| 2515 renderer = renderer->parent(); | 2514 renderer = renderer->parent(); |
| 2516 | 2515 |
| 2517 if (renderer) { | 2516 if (renderer) { |
| 2518 if (Frame* frame = document()->frame()) | 2517 if (Frame* frame = document().frame()) |
| 2519 frame->eventHandler()->startPanScrolling(renderer); | 2518 frame->eventHandler()->startPanScrolling(renderer); |
| 2520 } | 2519 } |
| 2521 } | 2520 } |
| 2522 #endif | 2521 #endif |
| 2523 } else if ((eventType == eventNames().wheelEvent || eventType == eventNames(
).mousewheelEvent) && event->hasInterface(eventNames().interfaceForWheelEvent))
{ | 2522 } else if ((eventType == eventNames().wheelEvent || eventType == eventNames(
).mousewheelEvent) && event->hasInterface(eventNames().interfaceForWheelEvent))
{ |
| 2524 WheelEvent* wheelEvent = static_cast<WheelEvent*>(event); | 2523 WheelEvent* wheelEvent = static_cast<WheelEvent*>(event); |
| 2525 | 2524 |
| 2526 // If we don't have a renderer, send the wheel event to the first node w
e find with a renderer. | 2525 // If we don't have a renderer, send the wheel event to the first node w
e find with a renderer. |
| 2527 // This is needed for <option> and <optgroup> elements so that <select>s
get a wheel scroll. | 2526 // This is needed for <option> and <optgroup> elements so that <select>s
get a wheel scroll. |
| 2528 Node* startNode = this; | 2527 Node* startNode = this; |
| 2529 while (startNode && !startNode->renderer()) | 2528 while (startNode && !startNode->renderer()) |
| 2530 startNode = startNode->parentOrShadowHostNode(); | 2529 startNode = startNode->parentOrShadowHostNode(); |
| 2531 | 2530 |
| 2532 if (startNode && startNode->renderer()) | 2531 if (startNode && startNode->renderer()) |
| 2533 if (Frame* frame = document()->frame()) | 2532 if (Frame* frame = document().frame()) |
| 2534 frame->eventHandler()->defaultWheelEventHandler(startNode, wheel
Event); | 2533 frame->eventHandler()->defaultWheelEventHandler(startNode, wheel
Event); |
| 2535 } else if (event->type() == eventNames().webkitEditableContentChangedEvent)
{ | 2534 } else if (event->type() == eventNames().webkitEditableContentChangedEvent)
{ |
| 2536 dispatchInputEvent(); | 2535 dispatchInputEvent(); |
| 2537 } | 2536 } |
| 2538 } | 2537 } |
| 2539 | 2538 |
| 2540 void Node::willCallDefaultEventHandler(const Event&) | 2539 void Node::willCallDefaultEventHandler(const Event&) |
| 2541 { | 2540 { |
| 2542 } | 2541 } |
| 2543 | 2542 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2600 } | 2599 } |
| 2601 | 2600 |
| 2602 #ifndef NDEBUG | 2601 #ifndef NDEBUG |
| 2603 m_deletionHasBegun = true; | 2602 m_deletionHasBegun = true; |
| 2604 #endif | 2603 #endif |
| 2605 delete this; | 2604 delete this; |
| 2606 } | 2605 } |
| 2607 | 2606 |
| 2608 void Node::textRects(Vector<IntRect>& rects) const | 2607 void Node::textRects(Vector<IntRect>& rects) const |
| 2609 { | 2608 { |
| 2610 RefPtr<Range> range = Range::create(document()); | 2609 RefPtr<Range> range = Range::create(&document()); |
| 2611 range->selectNodeContents(const_cast<Node*>(this), IGNORE_EXCEPTION); | 2610 range->selectNodeContents(const_cast<Node*>(this), IGNORE_EXCEPTION); |
| 2612 range->textRects(rects); | 2611 range->textRects(rects); |
| 2613 } | 2612 } |
| 2614 | 2613 |
| 2615 unsigned Node::connectedSubframeCount() const | 2614 unsigned Node::connectedSubframeCount() const |
| 2616 { | 2615 { |
| 2617 return hasRareData() ? rareData()->connectedSubframeCount() : 0; | 2616 return hasRareData() ? rareData()->connectedSubframeCount() : 0; |
| 2618 } | 2617 } |
| 2619 | 2618 |
| 2620 void Node::incrementConnectedSubframeCount(unsigned amount) | 2619 void Node::incrementConnectedSubframeCount(unsigned amount) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2645 | 2644 |
| 2646 if (!count) | 2645 if (!count) |
| 2647 return; | 2646 return; |
| 2648 | 2647 |
| 2649 for (Node* node = parentOrShadowHostNode(); node; node = node->parentOrShado
wHostNode()) | 2648 for (Node* node = parentOrShadowHostNode(); node; node = node->parentOrShado
wHostNode()) |
| 2650 node->incrementConnectedSubframeCount(count); | 2649 node->incrementConnectedSubframeCount(count); |
| 2651 } | 2650 } |
| 2652 | 2651 |
| 2653 PassRefPtr<NodeList> Node::getDestinationInsertionPoints() | 2652 PassRefPtr<NodeList> Node::getDestinationInsertionPoints() |
| 2654 { | 2653 { |
| 2655 document()->updateDistributionForNodeIfNeeded(this); | 2654 document().updateDistributionForNodeIfNeeded(this); |
| 2656 Vector<InsertionPoint*, 8> insertionPoints; | 2655 Vector<InsertionPoint*, 8> insertionPoints; |
| 2657 collectInsertionPointsWhereNodeIsDistributed(this, insertionPoints); | 2656 collectInsertionPointsWhereNodeIsDistributed(this, insertionPoints); |
| 2658 Vector<RefPtr<Node> > filteredInsertionPoints; | 2657 Vector<RefPtr<Node> > filteredInsertionPoints; |
| 2659 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 2658 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 2660 InsertionPoint* insertionPoint = insertionPoints[i]; | 2659 InsertionPoint* insertionPoint = insertionPoints[i]; |
| 2661 ASSERT(insertionPoint->containingShadowRoot()); | 2660 ASSERT(insertionPoint->containingShadowRoot()); |
| 2662 if (insertionPoint->containingShadowRoot()->type() != ShadowRoot::UserAg
entShadowRoot) | 2661 if (insertionPoint->containingShadowRoot()->type() != ShadowRoot::UserAg
entShadowRoot) |
| 2663 filteredInsertionPoints.append(insertionPoint); | 2662 filteredInsertionPoints.append(insertionPoint); |
| 2664 } | 2663 } |
| 2665 return StaticNodeList::adopt(filteredInsertionPoints); | 2664 return StaticNodeList::adopt(filteredInsertionPoints); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2682 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 2681 for (Node* child = firstChild(); child; child = child->nextSibling()) { |
| 2683 if (child->hasTagName(HTMLNames::styleTag) && toHTMLStyleElement(child)-
>isRegisteredAsScoped()) | 2682 if (child->hasTagName(HTMLNames::styleTag) && toHTMLStyleElement(child)-
>isRegisteredAsScoped()) |
| 2684 count++; | 2683 count++; |
| 2685 } | 2684 } |
| 2686 | 2685 |
| 2687 return count; | 2686 return count; |
| 2688 } | 2687 } |
| 2689 | 2688 |
| 2690 void Node::setFocus(bool flag) | 2689 void Node::setFocus(bool flag) |
| 2691 { | 2690 { |
| 2692 document()->userActionElements().setFocused(this, flag); | 2691 document().userActionElements().setFocused(this, flag); |
| 2693 } | 2692 } |
| 2694 | 2693 |
| 2695 void Node::setActive(bool flag, bool) | 2694 void Node::setActive(bool flag, bool) |
| 2696 { | 2695 { |
| 2697 document()->userActionElements().setActive(this, flag); | 2696 document().userActionElements().setActive(this, flag); |
| 2698 } | 2697 } |
| 2699 | 2698 |
| 2700 void Node::setHovered(bool flag) | 2699 void Node::setHovered(bool flag) |
| 2701 { | 2700 { |
| 2702 document()->userActionElements().setHovered(this, flag); | 2701 document().userActionElements().setHovered(this, flag); |
| 2703 } | 2702 } |
| 2704 | 2703 |
| 2705 bool Node::isUserActionElementActive() const | 2704 bool Node::isUserActionElementActive() const |
| 2706 { | 2705 { |
| 2707 ASSERT(isUserActionElement()); | 2706 ASSERT(isUserActionElement()); |
| 2708 return document()->userActionElements().isActive(this); | 2707 return document().userActionElements().isActive(this); |
| 2709 } | 2708 } |
| 2710 | 2709 |
| 2711 bool Node::isUserActionElementInActiveChain() const | 2710 bool Node::isUserActionElementInActiveChain() const |
| 2712 { | 2711 { |
| 2713 ASSERT(isUserActionElement()); | 2712 ASSERT(isUserActionElement()); |
| 2714 return document()->userActionElements().isInActiveChain(this); | 2713 return document().userActionElements().isInActiveChain(this); |
| 2715 } | 2714 } |
| 2716 | 2715 |
| 2717 bool Node::isUserActionElementHovered() const | 2716 bool Node::isUserActionElementHovered() const |
| 2718 { | 2717 { |
| 2719 ASSERT(isUserActionElement()); | 2718 ASSERT(isUserActionElement()); |
| 2720 return document()->userActionElements().isHovered(this); | 2719 return document().userActionElements().isHovered(this); |
| 2721 } | 2720 } |
| 2722 | 2721 |
| 2723 bool Node::isUserActionElementFocused() const | 2722 bool Node::isUserActionElementFocused() const |
| 2724 { | 2723 { |
| 2725 ASSERT(isUserActionElement()); | 2724 ASSERT(isUserActionElement()); |
| 2726 return document()->userActionElements().isFocused(this); | 2725 return document().userActionElements().isFocused(this); |
| 2727 } | 2726 } |
| 2728 | 2727 |
| 2729 void Node::setCustomElementState(CustomElementState newState) | 2728 void Node::setCustomElementState(CustomElementState newState) |
| 2730 { | 2729 { |
| 2731 CustomElementState oldState = customElementState(); | 2730 CustomElementState oldState = customElementState(); |
| 2732 | 2731 |
| 2733 switch (newState) { | 2732 switch (newState) { |
| 2734 case NotCustomElement: | 2733 case NotCustomElement: |
| 2735 ASSERT_NOT_REACHED(); // Everything starts in this state | 2734 ASSERT_NOT_REACHED(); // Everything starts in this state |
| 2736 return; | 2735 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2766 node->showTreeForThis(); | 2765 node->showTreeForThis(); |
| 2767 } | 2766 } |
| 2768 | 2767 |
| 2769 void showNodePath(const WebCore::Node* node) | 2768 void showNodePath(const WebCore::Node* node) |
| 2770 { | 2769 { |
| 2771 if (node) | 2770 if (node) |
| 2772 node->showNodePathForThis(); | 2771 node->showNodePathForThis(); |
| 2773 } | 2772 } |
| 2774 | 2773 |
| 2775 #endif | 2774 #endif |
| OLD | NEW |