| 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, 2013 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
| 18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
| 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "sky/engine/config.h" | 23 #include "sky/engine/config.h" |
| 24 #include "sky/engine/core/dom/ContainerNode.h" | 24 #include "sky/engine/core/dom/ContainerNode.h" |
| 25 | 25 |
| 26 #include "sky/engine/bindings/core/v8/ExceptionState.h" | 26 #include "sky/engine/bindings2/exception_state.h" |
| 27 #include "sky/engine/core/dom/ChildListMutationScope.h" | 27 #include "sky/engine/core/dom/ChildListMutationScope.h" |
| 28 #include "sky/engine/core/dom/ElementTraversal.h" | 28 #include "sky/engine/core/dom/ElementTraversal.h" |
| 29 #include "sky/engine/core/dom/ExceptionCode.h" | 29 #include "sky/engine/core/dom/ExceptionCode.h" |
| 30 #include "sky/engine/core/dom/NodeRareData.h" | 30 #include "sky/engine/core/dom/NodeRareData.h" |
| 31 #include "sky/engine/core/dom/NodeRenderStyle.h" | 31 #include "sky/engine/core/dom/NodeRenderStyle.h" |
| 32 #include "sky/engine/core/dom/NodeTraversal.h" | 32 #include "sky/engine/core/dom/NodeTraversal.h" |
| 33 #include "sky/engine/core/dom/SelectorQuery.h" | 33 #include "sky/engine/core/dom/SelectorQuery.h" |
| 34 #include "sky/engine/core/dom/StaticNodeList.h" | 34 #include "sky/engine/core/dom/StaticNodeList.h" |
| 35 #include "sky/engine/core/dom/StyleEngine.h" | 35 #include "sky/engine/core/dom/StyleEngine.h" |
| 36 #include "sky/engine/core/dom/shadow/ElementShadow.h" | 36 #include "sky/engine/core/dom/shadow/ElementShadow.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 bool ContainerNode::containsConsideringHostElements(const Node& newChild) const | 76 bool ContainerNode::containsConsideringHostElements(const Node& newChild) const |
| 77 { | 77 { |
| 78 if (isInShadowTree() || document().isTemplateDocument()) | 78 if (isInShadowTree() || document().isTemplateDocument()) |
| 79 return newChild.containsIncludingHostElements(*this); | 79 return newChild.containsIncludingHostElements(*this); |
| 80 return newChild.contains(this); | 80 return newChild.contains(this); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ContainerNode::checkAcceptChildType(const Node* newChild, ExceptionState& e
xceptionState) const | 83 void ContainerNode::checkAcceptChildType(const Node* newChild, ExceptionState& e
xceptionState) const |
| 84 { | 84 { |
| 85 if (!newChild) { | 85 if (!newChild) { |
| 86 exceptionState.throwDOMException(NotFoundError, "The new child element i
s null."); | 86 exceptionState.ThrowDOMException(NotFoundError, "The new child element i
s null."); |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (newChild->isTreeScope()) { | 90 if (newChild->isTreeScope()) { |
| 91 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type '
" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + node
Name() + "'."); | 91 exceptionState.ThrowDOMException(HierarchyRequestError, "Nodes of type '
" + newChild->nodeName() + "' may not be inserted inside nodes of type '" + node
Name() + "'."); |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ContainerNode::checkAcceptChildHierarchy(const Node& newChild, const Node*
oldChild, ExceptionState& exceptionState) const | 96 void ContainerNode::checkAcceptChildHierarchy(const Node& newChild, const Node*
oldChild, ExceptionState& exceptionState) const |
| 97 { | 97 { |
| 98 if (containsConsideringHostElements(newChild)) { | 98 if (containsConsideringHostElements(newChild)) { |
| 99 exceptionState.throwDOMException(HierarchyRequestError, "The new child e
lement contains the parent."); | 99 exceptionState.ThrowDOMException(HierarchyRequestError, "The new child e
lement contains the parent."); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // TODO(esprehn): Remove this, sky should allow multiple top level elements. | 103 // TODO(esprehn): Remove this, sky should allow multiple top level elements. |
| 104 if (isDocumentNode()) { | 104 if (isDocumentNode()) { |
| 105 unsigned elementCount = 0; | 105 unsigned elementCount = 0; |
| 106 if (newChild.isElementNode()) { | 106 if (newChild.isElementNode()) { |
| 107 elementCount = 1; | 107 elementCount = 1; |
| 108 } else if (newChild.isDocumentFragment()) { | 108 } else if (newChild.isDocumentFragment()) { |
| 109 for (Element* element = ElementTraversal::firstChild(newChild); elem
ent; element = ElementTraversal::nextSibling(*element)) | 109 for (Element* element = ElementTraversal::firstChild(newChild); elem
ent; element = ElementTraversal::nextSibling(*element)) |
| 110 ++elementCount; | 110 ++elementCount; |
| 111 } | 111 } |
| 112 if (elementCount > 1 || ((!oldChild || !oldChild->isElementNode()) && el
ementCount && document().documentElement())) { | 112 if (elementCount > 1 || ((!oldChild || !oldChild->isElementNode()) && el
ementCount && document().documentElement())) { |
| 113 exceptionState.throwDOMException(HierarchyRequestError, "Document ca
n only contain one Element."); | 113 exceptionState.ThrowDOMException(HierarchyRequestError, "Document ca
n only contain one Element."); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 PassRefPtr<Node> ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* re
fChild, ExceptionState& exceptionState) | 119 PassRefPtr<Node> ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* re
fChild, ExceptionState& exceptionState) |
| 120 { | 120 { |
| 121 // Check that this node is not "floating". | 121 // Check that this node is not "floating". |
| 122 // If it is, it can be deleted as a side effect of sending mutation events. | 122 // If it is, it can be deleted as a side effect of sending mutation events. |
| 123 ASSERT(refCount() || parentOrShadowHostNode()); | 123 ASSERT(refCount() || parentOrShadowHostNode()); |
| 124 | 124 |
| 125 RefPtr<Node> protect(this); | 125 RefPtr<Node> protect(this); |
| 126 | 126 |
| 127 // insertBefore(node, 0) is equivalent to appendChild(node) | 127 // insertBefore(node, 0) is equivalent to appendChild(node) |
| 128 if (!refChild) { | 128 if (!refChild) { |
| 129 return appendChild(newChild, exceptionState); | 129 return appendChild(newChild, exceptionState); |
| 130 } | 130 } |
| 131 | 131 |
| 132 checkAcceptChildType(newChild.get(), exceptionState); | 132 checkAcceptChildType(newChild.get(), exceptionState); |
| 133 if (exceptionState.hadException()) | 133 if (exceptionState.had_exception()) |
| 134 return nullptr; | 134 return nullptr; |
| 135 | 135 |
| 136 checkAcceptChildHierarchy(*newChild, 0, exceptionState); | 136 checkAcceptChildHierarchy(*newChild, 0, exceptionState); |
| 137 if (exceptionState.hadException()) | 137 if (exceptionState.had_exception()) |
| 138 return nullptr; | 138 return nullptr; |
| 139 | 139 |
| 140 ASSERT(newChild); | 140 ASSERT(newChild); |
| 141 | 141 |
| 142 // NotFoundError: Raised if refChild is not a child of this node | 142 // NotFoundError: Raised if refChild is not a child of this node |
| 143 if (refChild->parentNode() != this) { | 143 if (refChild->parentNode() != this) { |
| 144 exceptionState.throwDOMException(NotFoundError, "The node before which t
he new node is to be inserted is not a child of this node."); | 144 exceptionState.ThrowDOMException(NotFoundError, "The node before which t
he new node is to be inserted is not a child of this node."); |
| 145 return nullptr; | 145 return nullptr; |
| 146 } | 146 } |
| 147 | 147 |
| 148 // nothing to do | 148 // nothing to do |
| 149 if (refChild->previousSibling() == newChild || refChild == newChild) | 149 if (refChild->previousSibling() == newChild || refChild == newChild) |
| 150 return newChild; | 150 return newChild; |
| 151 | 151 |
| 152 RefPtr<Node> next = refChild; | 152 RefPtr<Node> next = refChild; |
| 153 | 153 |
| 154 NodeVector targets; | 154 NodeVector targets; |
| 155 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); | 155 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); |
| 156 if (exceptionState.hadException()) | 156 if (exceptionState.had_exception()) |
| 157 return nullptr; | 157 return nullptr; |
| 158 if (targets.isEmpty()) | 158 if (targets.isEmpty()) |
| 159 return newChild; | 159 return newChild; |
| 160 | 160 |
| 161 // Must check this again beacuse focus events might run synchronously when | 161 // Must check this again beacuse focus events might run synchronously when |
| 162 // removing children. | 162 // removing children. |
| 163 checkAcceptChildHierarchy(*newChild, 0, exceptionState); | 163 checkAcceptChildHierarchy(*newChild, 0, exceptionState); |
| 164 if (exceptionState.hadException()) | 164 if (exceptionState.had_exception()) |
| 165 return nullptr; | 165 return nullptr; |
| 166 | 166 |
| 167 ChildListMutationScope mutation(*this); | 167 ChildListMutationScope mutation(*this); |
| 168 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { | 168 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { |
| 169 ASSERT(*it); | 169 ASSERT(*it); |
| 170 Node& child = **it; | 170 Node& child = **it; |
| 171 | 171 |
| 172 // Due to arbitrary code running in response to a DOM mutation event it'
s | 172 // Due to arbitrary code running in response to a DOM mutation event it'
s |
| 173 // possible that "next" is no longer a child of "this". | 173 // possible that "next" is no longer a child of "this". |
| 174 // It's also possible that "child" has been inserted elsewhere. | 174 // It's also possible that "child" has been inserted elsewhere. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Check that this node is not "floating". | 233 // Check that this node is not "floating". |
| 234 // If it is, it can be deleted as a side effect of sending mutation events. | 234 // If it is, it can be deleted as a side effect of sending mutation events. |
| 235 ASSERT(refCount() || parentOrShadowHostNode()); | 235 ASSERT(refCount() || parentOrShadowHostNode()); |
| 236 | 236 |
| 237 RefPtr<Node> protect(this); | 237 RefPtr<Node> protect(this); |
| 238 | 238 |
| 239 if (oldChild == newChild) // nothing to do | 239 if (oldChild == newChild) // nothing to do |
| 240 return oldChild; | 240 return oldChild; |
| 241 | 241 |
| 242 if (!oldChild) { | 242 if (!oldChild) { |
| 243 exceptionState.throwDOMException(NotFoundError, "The node to be replaced
is null."); | 243 exceptionState.ThrowDOMException(NotFoundError, "The node to be replaced
is null."); |
| 244 return nullptr; | 244 return nullptr; |
| 245 } | 245 } |
| 246 | 246 |
| 247 RefPtr<Node> child = oldChild; | 247 RefPtr<Node> child = oldChild; |
| 248 | 248 |
| 249 checkAcceptChildType(newChild.get(), exceptionState); | 249 checkAcceptChildType(newChild.get(), exceptionState); |
| 250 if (exceptionState.hadException()) | 250 if (exceptionState.had_exception()) |
| 251 return nullptr; | 251 return nullptr; |
| 252 | 252 |
| 253 checkAcceptChildHierarchy(*newChild, child.get(), exceptionState); | 253 checkAcceptChildHierarchy(*newChild, child.get(), exceptionState); |
| 254 if (exceptionState.hadException()) | 254 if (exceptionState.had_exception()) |
| 255 return nullptr; | 255 return nullptr; |
| 256 | 256 |
| 257 // NotFoundError: Raised if oldChild is not a child of this node. | 257 // NotFoundError: Raised if oldChild is not a child of this node. |
| 258 if (child->parentNode() != this) { | 258 if (child->parentNode() != this) { |
| 259 exceptionState.throwDOMException(NotFoundError, "The node to be replaced
is not a child of this node."); | 259 exceptionState.ThrowDOMException(NotFoundError, "The node to be replaced
is not a child of this node."); |
| 260 return nullptr; | 260 return nullptr; |
| 261 } | 261 } |
| 262 | 262 |
| 263 ChildListMutationScope mutation(*this); | 263 ChildListMutationScope mutation(*this); |
| 264 | 264 |
| 265 RefPtr<Node> next = child->nextSibling(); | 265 RefPtr<Node> next = child->nextSibling(); |
| 266 | 266 |
| 267 // Remove the node we're replacing | 267 // Remove the node we're replacing |
| 268 removeChild(child, exceptionState); | 268 removeChild(child, exceptionState); |
| 269 if (exceptionState.hadException()) | 269 if (exceptionState.had_exception()) |
| 270 return nullptr; | 270 return nullptr; |
| 271 | 271 |
| 272 if (next && (next->previousSibling() == newChild || next == newChild)) // no
thing to do | 272 if (next && (next->previousSibling() == newChild || next == newChild)) // no
thing to do |
| 273 return child; | 273 return child; |
| 274 | 274 |
| 275 NodeVector targets; | 275 NodeVector targets; |
| 276 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); | 276 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); |
| 277 if (exceptionState.hadException()) | 277 if (exceptionState.had_exception()) |
| 278 return nullptr; | 278 return nullptr; |
| 279 | 279 |
| 280 // Must check this again beacuse focus events might run synchronously when | 280 // Must check this again beacuse focus events might run synchronously when |
| 281 // removing children. | 281 // removing children. |
| 282 checkAcceptChildHierarchy(*newChild, child.get(),exceptionState); | 282 checkAcceptChildHierarchy(*newChild, child.get(),exceptionState); |
| 283 if (exceptionState.hadException()) | 283 if (exceptionState.had_exception()) |
| 284 return nullptr; | 284 return nullptr; |
| 285 | 285 |
| 286 // Add the new child(ren) | 286 // Add the new child(ren) |
| 287 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { | 287 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { |
| 288 ASSERT(*it); | 288 ASSERT(*it); |
| 289 Node& child = **it; | 289 Node& child = **it; |
| 290 | 290 |
| 291 // Due to arbitrary code running in response to a DOM mutation event it'
s | 291 // Due to arbitrary code running in response to a DOM mutation event it'
s |
| 292 // possible that "next" is no longer a child of "this". | 292 // possible that "next" is no longer a child of "this". |
| 293 // It's also possible that "child" has been inserted elsewhere. | 293 // It's also possible that "child" has been inserted elsewhere. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 ASSERT(refCount() || parentOrShadowHostNode()); | 407 ASSERT(refCount() || parentOrShadowHostNode()); |
| 408 | 408 |
| 409 RefPtr<Node> protect(this); | 409 RefPtr<Node> protect(this); |
| 410 RefPtr<Node> child = oldChild; | 410 RefPtr<Node> child = oldChild; |
| 411 | 411 |
| 412 document().removeFocusedElementOfSubtree(child.get()); | 412 document().removeFocusedElementOfSubtree(child.get()); |
| 413 | 413 |
| 414 // Events fired when blurring currently focused node might have moved this | 414 // Events fired when blurring currently focused node might have moved this |
| 415 // child into a different parent. | 415 // child into a different parent. |
| 416 if (child->parentNode() != this) { | 416 if (child->parentNode() != this) { |
| 417 exceptionState.throwDOMException(NotFoundError, "The node to be removed
is no longer a child of this node. Perhaps it was moved in a 'blur' event handle
r?"); | 417 exceptionState.ThrowDOMException(NotFoundError, "The node to be removed
is no longer a child of this node. Perhaps it was moved in a 'blur' event handle
r?"); |
| 418 return nullptr; | 418 return nullptr; |
| 419 } | 419 } |
| 420 | 420 |
| 421 willRemoveChild(*child); | 421 willRemoveChild(*child); |
| 422 | 422 |
| 423 // Mutation events might have moved this child into a different parent. | 423 // Mutation events might have moved this child into a different parent. |
| 424 if (child->parentNode() != this) { | 424 if (child->parentNode() != this) { |
| 425 exceptionState.throwDOMException(NotFoundError, "The node to be removed
is no longer a child of this node. Perhaps it was moved in response to a mutatio
n?"); | 425 exceptionState.ThrowDOMException(NotFoundError, "The node to be removed
is no longer a child of this node. Perhaps it was moved in response to a mutatio
n?"); |
| 426 return nullptr; | 426 return nullptr; |
| 427 } | 427 } |
| 428 | 428 |
| 429 Node* prev = child->previousSibling(); | 429 Node* prev = child->previousSibling(); |
| 430 Node* next = child->nextSibling(); | 430 Node* next = child->nextSibling(); |
| 431 removeBetween(prev, next, *child); | 431 removeBetween(prev, next, *child); |
| 432 notifyNodeRemoved(*child); | 432 notifyNodeRemoved(*child); |
| 433 childrenChanged(ChildrenChange::forRemoval(*child, ChildrenChangeSourceAPI))
; | 433 childrenChanged(ChildrenChange::forRemoval(*child, ChildrenChangeSourceAPI))
; |
| 434 | 434 |
| 435 return child; | 435 return child; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 510 |
| 511 PassRefPtr<Node> ContainerNode::appendChild(PassRefPtr<Node> newChild, Exception
State& exceptionState) | 511 PassRefPtr<Node> ContainerNode::appendChild(PassRefPtr<Node> newChild, Exception
State& exceptionState) |
| 512 { | 512 { |
| 513 RefPtr<ContainerNode> protect(this); | 513 RefPtr<ContainerNode> protect(this); |
| 514 | 514 |
| 515 // Check that this node is not "floating". | 515 // Check that this node is not "floating". |
| 516 // If it is, it can be deleted as a side effect of sending mutation events. | 516 // If it is, it can be deleted as a side effect of sending mutation events. |
| 517 ASSERT(refCount() || parentOrShadowHostNode()); | 517 ASSERT(refCount() || parentOrShadowHostNode()); |
| 518 | 518 |
| 519 checkAcceptChildType(newChild.get(), exceptionState); | 519 checkAcceptChildType(newChild.get(), exceptionState); |
| 520 if (exceptionState.hadException()) | 520 if (exceptionState.had_exception()) |
| 521 return nullptr; | 521 return nullptr; |
| 522 | 522 |
| 523 checkAcceptChildHierarchy(*newChild, 0, exceptionState); | 523 checkAcceptChildHierarchy(*newChild, 0, exceptionState); |
| 524 if (exceptionState.hadException()) | 524 if (exceptionState.had_exception()) |
| 525 return nullptr; | 525 return nullptr; |
| 526 | 526 |
| 527 ASSERT(newChild); | 527 ASSERT(newChild); |
| 528 | 528 |
| 529 if (newChild == m_lastChild) // nothing to do | 529 if (newChild == m_lastChild) // nothing to do |
| 530 return newChild; | 530 return newChild; |
| 531 | 531 |
| 532 NodeVector targets; | 532 NodeVector targets; |
| 533 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); | 533 collectChildrenAndRemoveFromOldParent(*newChild, targets, exceptionState); |
| 534 if (exceptionState.hadException()) | 534 if (exceptionState.had_exception()) |
| 535 return nullptr; | 535 return nullptr; |
| 536 | 536 |
| 537 if (targets.isEmpty()) | 537 if (targets.isEmpty()) |
| 538 return newChild; | 538 return newChild; |
| 539 | 539 |
| 540 // Must check this again beacuse focus events might run synchronously when | 540 // Must check this again beacuse focus events might run synchronously when |
| 541 // removing children. | 541 // removing children. |
| 542 checkAcceptChildHierarchy(*newChild, 0, exceptionState); | 542 checkAcceptChildHierarchy(*newChild, 0, exceptionState); |
| 543 if (exceptionState.hadException()) | 543 if (exceptionState.had_exception()) |
| 544 return nullptr; | 544 return nullptr; |
| 545 | 545 |
| 546 // Now actually add the child(ren) | 546 // Now actually add the child(ren) |
| 547 ChildListMutationScope mutation(*this); | 547 ChildListMutationScope mutation(*this); |
| 548 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { | 548 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { |
| 549 ASSERT(*it); | 549 ASSERT(*it); |
| 550 Node& child = **it; | 550 Node& child = **it; |
| 551 | 551 |
| 552 // If the child has a parent again, just stop what we're doing, because | 552 // If the child has a parent again, just stop what we're doing, because |
| 553 // that means someone is doing something with DOM mutation -- can't re-p
arent | 553 // that means someone is doing something with DOM mutation -- can't re-p
arent |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 document().updateRangesAfterChildrenChanged(this); | 659 document().updateRangesAfterChildrenChanged(this); |
| 660 if (change.isChildInsertion() && !childNeedsStyleRecalc()) { | 660 if (change.isChildInsertion() && !childNeedsStyleRecalc()) { |
| 661 setChildNeedsStyleRecalc(); | 661 setChildNeedsStyleRecalc(); |
| 662 markAncestorsWithChildNeedsStyleRecalc(); | 662 markAncestorsWithChildNeedsStyleRecalc(); |
| 663 } | 663 } |
| 664 } | 664 } |
| 665 | 665 |
| 666 void ContainerNode::cloneChildNodes(ContainerNode *clone) | 666 void ContainerNode::cloneChildNodes(ContainerNode *clone) |
| 667 { | 667 { |
| 668 TrackExceptionState exceptionState; | 668 TrackExceptionState exceptionState; |
| 669 for (Node* n = firstChild(); n && !exceptionState.hadException(); n = n->nex
tSibling()) | 669 for (Node* n = firstChild(); n && !exceptionState.had_exception(); n = n->ne
xtSibling()) |
| 670 clone->appendChild(n->cloneNode(true), exceptionState); | 670 clone->appendChild(n->cloneNode(true), exceptionState); |
| 671 } | 671 } |
| 672 | 672 |
| 673 | 673 |
| 674 bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const | 674 bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const |
| 675 { | 675 { |
| 676 if (!renderer()) | 676 if (!renderer()) |
| 677 return false; | 677 return false; |
| 678 // What is this code really trying to do? | 678 // What is this code really trying to do? |
| 679 RenderObject* o = renderer(); | 679 RenderObject* o = renderer(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 unsigned count = 0; | 874 unsigned count = 0; |
| 875 Node *n; | 875 Node *n; |
| 876 for (n = firstChild(); n; n = n->nextSibling()) | 876 for (n = firstChild(); n; n = n->nextSibling()) |
| 877 count++; | 877 count++; |
| 878 return count; | 878 return count; |
| 879 } | 879 } |
| 880 | 880 |
| 881 PassRefPtr<Element> ContainerNode::querySelector(const AtomicString& selectors,
ExceptionState& exceptionState) | 881 PassRefPtr<Element> ContainerNode::querySelector(const AtomicString& selectors,
ExceptionState& exceptionState) |
| 882 { | 882 { |
| 883 if (selectors.isEmpty()) { | 883 if (selectors.isEmpty()) { |
| 884 exceptionState.throwDOMException(SyntaxError, "The provided selector is
empty."); | 884 exceptionState.ThrowDOMException(SyntaxError, "The provided selector is
empty."); |
| 885 return nullptr; | 885 return nullptr; |
| 886 } | 886 } |
| 887 | 887 |
| 888 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors
, document(), exceptionState); | 888 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors
, document(), exceptionState); |
| 889 if (!selectorQuery) | 889 if (!selectorQuery) |
| 890 return nullptr; | 890 return nullptr; |
| 891 return selectorQuery->queryFirst(*this); | 891 return selectorQuery->queryFirst(*this); |
| 892 } | 892 } |
| 893 | 893 |
| 894 PassRefPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString
& selectors, ExceptionState& exceptionState) | 894 PassRefPtr<StaticElementList> ContainerNode::querySelectorAll(const AtomicString
& selectors, ExceptionState& exceptionState) |
| 895 { | 895 { |
| 896 if (selectors.isEmpty()) { | 896 if (selectors.isEmpty()) { |
| 897 exceptionState.throwDOMException(SyntaxError, "The provided selector is
empty."); | 897 exceptionState.ThrowDOMException(SyntaxError, "The provided selector is
empty."); |
| 898 return nullptr; | 898 return nullptr; |
| 899 } | 899 } |
| 900 | 900 |
| 901 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors
, document(), exceptionState); | 901 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors
, document(), exceptionState); |
| 902 if (!selectorQuery) | 902 if (!selectorQuery) |
| 903 return nullptr; | 903 return nullptr; |
| 904 | 904 |
| 905 return selectorQuery->queryAll(*this); | 905 return selectorQuery->queryAll(*this); |
| 906 } | 906 } |
| 907 | 907 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 return true; | 945 return true; |
| 946 | 946 |
| 947 if (node->isElementNode() && toElement(node)->shadow()) | 947 if (node->isElementNode() && toElement(node)->shadow()) |
| 948 return true; | 948 return true; |
| 949 | 949 |
| 950 return false; | 950 return false; |
| 951 } | 951 } |
| 952 #endif | 952 #endif |
| 953 | 953 |
| 954 } // namespace blink | 954 } // namespace blink |
| OLD | NEW |