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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 return ProcessingInstruction::create(*this, target, data); | 943 return ProcessingInstruction::create(*this, target, data); |
944 } | 944 } |
945 | 945 |
946 PassRefPtrWillBeRawPtr<Text> Document::createEditingTextNode(const String& text) | 946 PassRefPtrWillBeRawPtr<Text> Document::createEditingTextNode(const String& text) |
947 { | 947 { |
948 return Text::createEditingText(*this, text); | 948 return Text::createEditingText(*this, text); |
949 } | 949 } |
950 | 950 |
951 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, Pass
RefPtrWillBeRawPtr<ContainerNode> newContainerNode, ExceptionState& exceptionSta
te) | 951 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, Pass
RefPtrWillBeRawPtr<ContainerNode> newContainerNode, ExceptionState& exceptionSta
te) |
952 { | 952 { |
953 for (Node* oldChild = oldContainerNode->firstChild(); oldChild; oldChild = o
ldChild->nextSibling()) { | 953 for (Node& oldChild : NodeTraversal::childrenOf(*oldContainerNode)) { |
954 RefPtrWillBeRawPtr<Node> newChild = importNode(oldChild, true, exception
State); | 954 RefPtrWillBeRawPtr<Node> newChild = importNode(&oldChild, true, exceptio
nState); |
955 if (exceptionState.hadException()) | 955 if (exceptionState.hadException()) |
956 return false; | 956 return false; |
957 newContainerNode->appendChild(newChild.release(), exceptionState); | 957 newContainerNode->appendChild(newChild.release(), exceptionState); |
958 if (exceptionState.hadException()) | 958 if (exceptionState.hadException()) |
959 return false; | 959 return false; |
960 } | 960 } |
961 | 961 |
962 return true; | 962 return true; |
963 } | 963 } |
964 | 964 |
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2816 ASSERT(!m_elemSheet->contents()->ruleCount()); | 2816 ASSERT(!m_elemSheet->contents()->ruleCount()); |
2817 bool usesRemUnits = m_elemSheet->contents()->usesRemUnits(); | 2817 bool usesRemUnits = m_elemSheet->contents()->usesRemUnits(); |
2818 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); | 2818 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); |
2819 // FIXME: So we are not really the parser. The right fix is to eliminate
the element sheet completely. | 2819 // FIXME: So we are not really the parser. The right fix is to eliminate
the element sheet completely. |
2820 m_elemSheet->contents()->parserSetUsesRemUnits(usesRemUnits); | 2820 m_elemSheet->contents()->parserSetUsesRemUnits(usesRemUnits); |
2821 } | 2821 } |
2822 | 2822 |
2823 if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) { | 2823 if (!equalIgnoringFragmentIdentifier(oldBaseURL, m_baseURL)) { |
2824 // Base URL change changes any relative visited links. | 2824 // Base URL change changes any relative visited links. |
2825 // FIXME: There are other URLs in the tree that would need to be re-eval
uated on dynamic base URL change. Style should be invalidated too. | 2825 // FIXME: There are other URLs in the tree that would need to be re-eval
uated on dynamic base URL change. Style should be invalidated too. |
2826 for (HTMLAnchorElement* anchor = Traversal<HTMLAnchorElement>::firstWith
in(*this); anchor; anchor = Traversal<HTMLAnchorElement>::next(*anchor)) | 2826 for (HTMLAnchorElement& anchor : Traversal<HTMLAnchorElement>::fromNext(
*this)) |
2827 anchor->invalidateCachedVisitedLinkHash(); | 2827 anchor.invalidateCachedVisitedLinkHash(); |
2828 } | 2828 } |
2829 } | 2829 } |
2830 | 2830 |
2831 void Document::setBaseURLOverride(const KURL& url) | 2831 void Document::setBaseURLOverride(const KURL& url) |
2832 { | 2832 { |
2833 m_baseURLOverride = url; | 2833 m_baseURLOverride = url; |
2834 updateBaseURL(); | 2834 updateBaseURL(); |
2835 } | 2835 } |
2836 | 2836 |
2837 void Document::processBaseElement() | 2837 void Document::processBaseElement() |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3241 case DOCUMENT_NODE: | 3241 case DOCUMENT_NODE: |
3242 case TEXT_NODE: | 3242 case TEXT_NODE: |
3243 return false; | 3243 return false; |
3244 case COMMENT_NODE: | 3244 case COMMENT_NODE: |
3245 case PROCESSING_INSTRUCTION_NODE: | 3245 case PROCESSING_INSTRUCTION_NODE: |
3246 return true; | 3246 return true; |
3247 case DOCUMENT_TYPE_NODE: | 3247 case DOCUMENT_TYPE_NODE: |
3248 case ELEMENT_NODE: | 3248 case ELEMENT_NODE: |
3249 // Documents may contain no more than one of each of these. | 3249 // Documents may contain no more than one of each of these. |
3250 // (One Element and one DocumentType.) | 3250 // (One Element and one DocumentType.) |
3251 for (Node* c = firstChild(); c; c = c->nextSibling()) | 3251 for (Node& c : NodeTraversal::childrenOf(*this)) |
3252 if (c->nodeType() == type) | 3252 if (c.nodeType() == type) |
3253 return false; | 3253 return false; |
3254 return true; | 3254 return true; |
3255 } | 3255 } |
3256 return false; | 3256 return false; |
3257 } | 3257 } |
3258 | 3258 |
3259 bool Document::canReplaceChild(const Node& newChild, const Node& oldChild) const | 3259 bool Document::canReplaceChild(const Node& newChild, const Node& oldChild) const |
3260 { | 3260 { |
3261 if (oldChild.nodeType() == newChild.nodeType()) | 3261 if (oldChild.nodeType() == newChild.nodeType()) |
3262 return true; | 3262 return true; |
3263 | 3263 |
3264 int numDoctypes = 0; | 3264 int numDoctypes = 0; |
3265 int numElements = 0; | 3265 int numElements = 0; |
3266 | 3266 |
3267 // First, check how many doctypes and elements we have, not counting | 3267 // First, check how many doctypes and elements we have, not counting |
3268 // the child we're about to remove. | 3268 // the child we're about to remove. |
3269 for (Node* c = firstChild(); c; c = c->nextSibling()) { | 3269 for (Node& c : NodeTraversal::childrenOf(*this)) { |
3270 if (c == oldChild) | 3270 if (c == oldChild) |
3271 continue; | 3271 continue; |
3272 | 3272 |
3273 switch (c->nodeType()) { | 3273 switch (c.nodeType()) { |
3274 case DOCUMENT_TYPE_NODE: | 3274 case DOCUMENT_TYPE_NODE: |
3275 numDoctypes++; | 3275 numDoctypes++; |
3276 break; | 3276 break; |
3277 case ELEMENT_NODE: | 3277 case ELEMENT_NODE: |
3278 numElements++; | 3278 numElements++; |
3279 break; | 3279 break; |
3280 default: | 3280 default: |
3281 break; | 3281 break; |
3282 } | 3282 } |
3283 } | 3283 } |
3284 | 3284 |
3285 // Then, see how many doctypes and elements might be added by the new child. | 3285 // Then, see how many doctypes and elements might be added by the new child. |
3286 if (newChild.isDocumentFragment()) { | 3286 if (newChild.isDocumentFragment()) { |
3287 for (Node* c = toDocumentFragment(newChild).firstChild(); c; c = c->next
Sibling()) { | 3287 for (Node& c : NodeTraversal::childrenOf(toDocumentFragment(newChild)))
{ |
3288 switch (c->nodeType()) { | 3288 switch (c.nodeType()) { |
3289 case ATTRIBUTE_NODE: | 3289 case ATTRIBUTE_NODE: |
3290 case CDATA_SECTION_NODE: | 3290 case CDATA_SECTION_NODE: |
3291 case DOCUMENT_FRAGMENT_NODE: | 3291 case DOCUMENT_FRAGMENT_NODE: |
3292 case DOCUMENT_NODE: | 3292 case DOCUMENT_NODE: |
3293 case TEXT_NODE: | 3293 case TEXT_NODE: |
3294 return false; | 3294 return false; |
3295 case COMMENT_NODE: | 3295 case COMMENT_NODE: |
3296 case PROCESSING_INSTRUCTION_NODE: | 3296 case PROCESSING_INSTRUCTION_NODE: |
3297 break; | 3297 break; |
3298 case DOCUMENT_TYPE_NODE: | 3298 case DOCUMENT_TYPE_NODE: |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3751 { | 3751 { |
3752 EventDispatchForbiddenScope assertNoEventDispatch; | 3752 EventDispatchForbiddenScope assertNoEventDispatch; |
3753 if (!m_ranges.isEmpty()) { | 3753 if (!m_ranges.isEmpty()) { |
3754 AttachedRangeSet::const_iterator end = m_ranges.end(); | 3754 AttachedRangeSet::const_iterator end = m_ranges.end(); |
3755 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end;
++it) | 3755 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end;
++it) |
3756 (*it)->nodeChildrenWillBeRemoved(container); | 3756 (*it)->nodeChildrenWillBeRemoved(container); |
3757 } | 3757 } |
3758 | 3758 |
3759 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod
eIteratorsEnd = m_nodeIterators.end(); | 3759 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod
eIteratorsEnd = m_nodeIterators.end(); |
3760 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato
r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) { | 3760 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato
r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) { |
3761 for (Node* n = container.firstChild(); n; n = n->nextSibling()) | 3761 for (Node& n : NodeTraversal::childrenOf(container)) |
3762 (*it)->nodeWillBeRemoved(*n); | 3762 (*it)->nodeWillBeRemoved(n); |
3763 } | 3763 } |
3764 | 3764 |
3765 if (LocalFrame* frame = this->frame()) { | 3765 if (LocalFrame* frame = this->frame()) { |
3766 for (Node* n = container.firstChild(); n; n = n->nextSibling()) { | 3766 for (Node& n : NodeTraversal::childrenOf(container)) { |
3767 frame->eventHandler().nodeWillBeRemoved(*n); | 3767 frame->eventHandler().nodeWillBeRemoved(n); |
3768 frame->selection().nodeWillBeRemoved(*n); | 3768 frame->selection().nodeWillBeRemoved(n); |
3769 frame->page()->dragCaretController().nodeWillBeRemoved(*n); | 3769 frame->page()->dragCaretController().nodeWillBeRemoved(n); |
3770 } | 3770 } |
3771 } | 3771 } |
3772 } | 3772 } |
3773 | 3773 |
3774 void Document::nodeWillBeRemoved(Node& n) | 3774 void Document::nodeWillBeRemoved(Node& n) |
3775 { | 3775 { |
3776 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod
eIteratorsEnd = m_nodeIterators.end(); | 3776 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod
eIteratorsEnd = m_nodeIterators.end(); |
3777 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato
r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) | 3777 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato
r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) |
3778 (*it)->nodeWillBeRemoved(n); | 3778 (*it)->nodeWillBeRemoved(n); |
3779 | 3779 |
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5854 using namespace blink; | 5854 using namespace blink; |
5855 void showLiveDocumentInstances() | 5855 void showLiveDocumentInstances() |
5856 { | 5856 { |
5857 WeakDocumentSet& set = liveDocumentSet(); | 5857 WeakDocumentSet& set = liveDocumentSet(); |
5858 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5858 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5859 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 5859 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
5860 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 5860 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
5861 } | 5861 } |
5862 } | 5862 } |
5863 #endif | 5863 #endif |
OLD | NEW |