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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 LayoutObject* layoutObject = m_data.m_rareData->layoutObject(); | 375 LayoutObject* layoutObject = m_data.m_rareData->layoutObject(); |
376 if (isElementNode()) | 376 if (isElementNode()) |
377 delete static_cast<ElementRareData*>(m_data.m_rareData); | 377 delete static_cast<ElementRareData*>(m_data.m_rareData); |
378 else | 378 else |
379 delete static_cast<NodeRareData*>(m_data.m_rareData); | 379 delete static_cast<NodeRareData*>(m_data.m_rareData); |
380 m_data.m_layoutObject = layoutObject; | 380 m_data.m_layoutObject = layoutObject; |
381 clearFlag(HasRareDataFlag); | 381 clearFlag(HasRareDataFlag); |
382 } | 382 } |
383 #endif | 383 #endif |
384 | 384 |
385 PassRefPtrWillBeRawPtr<Node> Node::mutationMethodMacro(const HeapVector<NodeOrSt ring>& nodes, ExceptionState& exceptionState) | |
386 { | |
387 RefPtrWillBeRawPtr<Node> node; | |
388 if (nodes.size() == 1) { | |
389 if (nodes[0].isNode()) | |
390 node = nodes[0].getAsNode(); | |
391 else | |
392 node = Text::create(document(), nodes[0].getAsString()); | |
393 } else { | |
394 node = DocumentFragment::create(document()); | |
395 for (const NodeOrString& nodeOrString : nodes) { | |
396 if (nodeOrString.isNode()) | |
397 node->appendChild(nodeOrString.getAsNode(), exceptionState); | |
398 else | |
399 node->appendChild(Text::create(document(), nodeOrString.getAsStr ing()), exceptionState); | |
400 if (exceptionState.hadException()) { | |
401 exceptionState.throwDOMException(exceptionState.code(), exceptio nState.message()); | |
philipj_slow
2015/06/08 12:49:20
Is there any condition under which this exception
| |
402 return nullptr; | |
403 } | |
404 } | |
405 } | |
406 return node.release(); | |
407 } | |
408 | |
385 Node* Node::toNode() | 409 Node* Node::toNode() |
386 { | 410 { |
387 return this; | 411 return this; |
388 } | 412 } |
389 | 413 |
390 short Node::tabIndex() const | 414 short Node::tabIndex() const |
391 { | 415 { |
392 return 0; | 416 return 0; |
393 } | 417 } |
394 | 418 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 518 |
495 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC hild, ExceptionState& exceptionState) | 519 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC hild, ExceptionState& exceptionState) |
496 { | 520 { |
497 if (isContainerNode()) | 521 if (isContainerNode()) |
498 return toContainerNode(this)->appendChild(newChild, exceptionState); | 522 return toContainerNode(this)->appendChild(newChild, exceptionState); |
499 | 523 |
500 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); | 524 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); |
501 return nullptr; | 525 return nullptr; |
502 } | 526 } |
503 | 527 |
528 void Node::prepend(const HeapVector<NodeOrString>& nodes, ExceptionState& except ionState) | |
529 { | |
530 RefPtrWillBeRawPtr<Node> nodeToPrepend = mutationMethodMacro(nodes, exceptio nState); | |
531 this->insertBefore(nodeToPrepend, this->firstChild(), exceptionState); | |
532 } | |
533 | |
534 void Node::append(const HeapVector<NodeOrString>& nodes, ExceptionState& excepti onState) | |
535 { | |
536 RefPtrWillBeRawPtr<Node> nodeToAppend = mutationMethodMacro(nodes, exception State); | |
537 this->appendChild(nodeToAppend, exceptionState); | |
538 } | |
539 | |
540 void Node::before(const HeapVector<NodeOrString>& nodes, ExceptionState& excepti onState) | |
541 { | |
542 Node* parent = parentNode(); | |
543 if (!parent) | |
544 return; | |
545 RefPtrWillBeRawPtr<Node> nodeToInsert = mutationMethodMacro(nodes, exception State); | |
546 parent->insertBefore(nodeToInsert, this, exceptionState); | |
547 } | |
548 | |
549 void Node::after(const HeapVector<NodeOrString>& nodes, ExceptionState& exceptio nState) | |
550 { | |
551 Node* parent = parentNode(); | |
552 if (!parent) | |
553 return; | |
554 RefPtrWillBeRawPtr<Node> nodeToInsert = mutationMethodMacro(nodes, exception State); | |
555 parent->insertBefore(nodeToInsert, this->nextSibling(), exceptionState); | |
556 } | |
557 | |
558 void Node::replaceWith(const HeapVector<NodeOrString>& nodes, ExceptionState& ex ceptionState) | |
559 { | |
560 Node* parent = parentNode(); | |
561 if (!parent) | |
562 return; | |
563 RefPtrWillBeRawPtr<Node> nodeToReplaceWith = mutationMethodMacro(nodes, exce ptionState); | |
564 parent->replaceChild(nodeToReplaceWith, this, exceptionState); | |
565 } | |
566 | |
504 void Node::remove(ExceptionState& exceptionState) | 567 void Node::remove(ExceptionState& exceptionState) |
505 { | 568 { |
506 if (ContainerNode* parent = parentNode()) | 569 if (ContainerNode* parent = parentNode()) |
507 parent->removeChild(this, exceptionState); | 570 parent->removeChild(this, exceptionState); |
508 } | 571 } |
509 | 572 |
510 void Node::normalize() | 573 void Node::normalize() |
511 { | 574 { |
512 updateDistribution(); | 575 updateDistribution(); |
513 | 576 |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2502 | 2565 |
2503 void showNodePath(const blink::Node* node) | 2566 void showNodePath(const blink::Node* node) |
2504 { | 2567 { |
2505 if (node) | 2568 if (node) |
2506 node->showNodePathForThis(); | 2569 node->showNodePathForThis(); |
2507 else | 2570 else |
2508 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2571 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
2509 } | 2572 } |
2510 | 2573 |
2511 #endif | 2574 #endif |
OLD | NEW |