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::nodeOrStringToNode(const NodeOrString& nodeOr String) | |
386 { | |
387 if (nodeOrString.isNode()) | |
388 return nodeOrString.getAsNode(); | |
389 return Text::create(document(), nodeOrString.getAsString()); | |
390 } | |
391 | |
392 PassRefPtrWillBeRawPtr<Node> Node::convertNodesIntoNode(const HeapVector<NodeOrS tring>& nodes) | |
393 { | |
394 RefPtrWillBeRawPtr<Node> node = nullptr; | |
395 if (nodes.size() == 1) { | |
396 node = nodeOrStringToNode(nodes[0]); | |
philipj_slow
2015/06/15 10:06:58
The spec is on this form, but would this be cleare
Paritosh Kumar
2015/06/23 13:32:09
Thanks. Done.
philipj_slow
2015/06/25 13:13:23
Looks good this way, thanks!
| |
397 } else { | |
398 node = DocumentFragment::create(document()); | |
399 for (const NodeOrString& nodeOrString : nodes) | |
400 node->appendChild(nodeOrStringToNode(nodeOrString), ASSERT_NO_EXCEPT ION); | |
401 } | |
402 return node.release(); | |
403 } | |
404 | |
385 Node* Node::toNode() | 405 Node* Node::toNode() |
386 { | 406 { |
387 return this; | 407 return this; |
388 } | 408 } |
389 | 409 |
390 short Node::tabIndex() const | 410 short Node::tabIndex() const |
391 { | 411 { |
392 return 0; | 412 return 0; |
393 } | 413 } |
394 | 414 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 514 |
495 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC hild, ExceptionState& exceptionState) | 515 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC hild, ExceptionState& exceptionState) |
496 { | 516 { |
497 if (isContainerNode()) | 517 if (isContainerNode()) |
498 return toContainerNode(this)->appendChild(newChild, exceptionState); | 518 return toContainerNode(this)->appendChild(newChild, exceptionState); |
499 | 519 |
500 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); | 520 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); |
501 return nullptr; | 521 return nullptr; |
502 } | 522 } |
503 | 523 |
524 void Node::prepend(const HeapVector<NodeOrString>& nodes, ExceptionState& except ionState) | |
525 { | |
526 RefPtrWillBeRawPtr<Node> nodeToPrepend = convertNodesIntoNode(nodes); | |
527 this->insertBefore(nodeToPrepend, this->firstChild(), exceptionState); | |
528 } | |
529 | |
530 void Node::append(const HeapVector<NodeOrString>& nodes, ExceptionState& excepti onState) | |
531 { | |
532 RefPtrWillBeRawPtr<Node> nodeToAppend = convertNodesIntoNode(nodes); | |
533 this->appendChild(nodeToAppend, exceptionState); | |
534 } | |
535 | |
536 void Node::before(const HeapVector<NodeOrString>& nodes, ExceptionState& excepti onState) | |
537 { | |
538 Node* parent = parentNode(); | |
539 if (!parent) | |
540 return; | |
541 RefPtrWillBeRawPtr<Node> nodeToInsert = convertNodesIntoNode(nodes); | |
542 parent->insertBefore(nodeToInsert, this, exceptionState); | |
543 } | |
544 | |
545 void Node::after(const HeapVector<NodeOrString>& nodes, ExceptionState& exceptio nState) | |
546 { | |
547 Node* parent = parentNode(); | |
548 if (!parent) | |
549 return; | |
550 RefPtrWillBeRawPtr<Node> nodeToInsert = convertNodesIntoNode(nodes); | |
551 parent->insertBefore(nodeToInsert, this->nextSibling(), exceptionState); | |
552 } | |
553 | |
554 void Node::replaceWith(const HeapVector<NodeOrString>& nodes, ExceptionState& ex ceptionState) | |
555 { | |
556 Node* parent = parentNode(); | |
557 if (!parent) | |
558 return; | |
559 RefPtrWillBeRawPtr<Node> nodeToReplaceWith = convertNodesIntoNode(nodes); | |
560 parent->replaceChild(nodeToReplaceWith, this, exceptionState); | |
561 } | |
562 | |
504 void Node::remove(ExceptionState& exceptionState) | 563 void Node::remove(ExceptionState& exceptionState) |
505 { | 564 { |
506 if (ContainerNode* parent = parentNode()) | 565 if (ContainerNode* parent = parentNode()) |
507 parent->removeChild(this, exceptionState); | 566 parent->removeChild(this, exceptionState); |
508 } | 567 } |
509 | 568 |
510 void Node::normalize() | 569 void Node::normalize() |
511 { | 570 { |
512 updateDistribution(); | 571 updateDistribution(); |
513 | 572 |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2502 | 2561 |
2503 void showNodePath(const blink::Node* node) | 2562 void showNodePath(const blink::Node* node) |
2504 { | 2563 { |
2505 if (node) | 2564 if (node) |
2506 node->showNodePathForThis(); | 2565 node->showNodePathForThis(); |
2507 else | 2566 else |
2508 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2567 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
2509 } | 2568 } |
2510 | 2569 |
2511 #endif | 2570 #endif |
OLD | NEW |