Chromium Code Reviews| 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 LayoutObject* renderer = m_data.m_rareData->layoutObject(); | 374 LayoutObject* renderer = m_data.m_rareData->layoutObject(); |
| 375 if (isElementNode()) | 375 if (isElementNode()) |
| 376 delete static_cast<ElementRareData*>(m_data.m_rareData); | 376 delete static_cast<ElementRareData*>(m_data.m_rareData); |
| 377 else | 377 else |
| 378 delete static_cast<NodeRareData*>(m_data.m_rareData); | 378 delete static_cast<NodeRareData*>(m_data.m_rareData); |
| 379 m_data.m_layoutObject = renderer; | 379 m_data.m_layoutObject = renderer; |
| 380 clearFlag(HasRareDataFlag); | 380 clearFlag(HasRareDataFlag); |
| 381 } | 381 } |
| 382 #endif | 382 #endif |
| 383 | 383 |
| 384 PassRefPtr<Node> Node::mutationMethodMacro(const Vector<NodeOrString>& nodes, Ex ceptionState& exceptionState) | |
|
philipj_slow
2015/04/29 13:16:57
If I'm not mistaken, this should be PassRefPtrWill
Paritosh Kumar
2015/06/08 12:21:24
Yes, This will be PassRefPtrWillBeRawPtr<Node> and
| |
| 385 { | |
| 386 RefPtr<Node> node; | |
| 387 if (nodes.size() == 1) { | |
| 388 if (nodes[0].isNode()) | |
| 389 node = nodes[0].getAsNode(); | |
| 390 else if (nodes[0].isString()) | |
| 391 node = Text::create(document(), nodes[0].getAsString()); | |
| 392 else | |
| 393 return nullptr; | |
|
philipj_slow
2015/04/29 13:16:57
This case should be unreachable.
Paritosh Kumar
2015/06/08 12:21:24
Yes, Removing it.
| |
| 394 } else { | |
| 395 node = DocumentFragment::create(document()); | |
|
philipj_slow
2015/04/29 13:16:57
This is what the spec says, but implementing it li
Paritosh Kumar
2015/06/08 12:21:24
I looked into this and found that we may use colle
| |
| 396 for (size_t i = 0; i < nodes.size(); ++i) { | |
|
philipj_slow
2015/04/29 13:16:57
Will a range-based for loop work here? for (NodeOr
Paritosh Kumar
2015/06/08 12:21:24
Yes, Done.
| |
| 397 if (nodes[i].isNode()) | |
| 398 node->appendChild(nodes[i].getAsNode(), exceptionState); | |
| 399 else | |
| 400 node->appendChild(Text::create(document(), nodes[i].getAsString( )), exceptionState); | |
| 401 if (exceptionState.hadException()) { | |
| 402 exceptionState.throwIfNeeded(); | |
|
philipj_slow
2015/04/29 13:16:57
This looks unusual, why throwIfNeeded() here? If w
Paritosh Kumar
2015/06/08 12:21:24
Done.
| |
| 403 return nullptr; | |
| 404 } | |
| 405 } | |
| 406 } | |
| 407 return node.release(); | |
| 408 } | |
| 409 | |
|
philipj_slow
2015/04/29 13:16:57
There's an extra blank line here.
Paritosh Kumar
2015/06/08 12:21:24
Done.
| |
| 410 | |
| 384 Node* Node::toNode() | 411 Node* Node::toNode() |
| 385 { | 412 { |
| 386 return this; | 413 return this; |
| 387 } | 414 } |
| 388 | 415 |
| 389 short Node::tabIndex() const | 416 short Node::tabIndex() const |
| 390 { | 417 { |
| 391 return 0; | 418 return 0; |
| 392 } | 419 } |
| 393 | 420 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 | 520 |
| 494 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC hild, ExceptionState& exceptionState) | 521 PassRefPtrWillBeRawPtr<Node> Node::appendChild(PassRefPtrWillBeRawPtr<Node> newC hild, ExceptionState& exceptionState) |
| 495 { | 522 { |
| 496 if (isContainerNode()) | 523 if (isContainerNode()) |
| 497 return toContainerNode(this)->appendChild(newChild, exceptionState); | 524 return toContainerNode(this)->appendChild(newChild, exceptionState); |
| 498 | 525 |
| 499 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); | 526 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); |
| 500 return nullptr; | 527 return nullptr; |
| 501 } | 528 } |
| 502 | 529 |
| 530 void Node::prepend(const Vector<NodeOrString>& nodes, ExceptionState& exceptionS tate) | |
| 531 { | |
| 532 RefPtr<Node> nodeToPrepend = mutationMethodMacro(nodes, exceptionState); | |
|
philipj_slow
2015/04/29 13:16:57
All of these will also need to use the Oilpan tran
Paritosh Kumar
2015/06/08 12:21:24
Done.
| |
| 533 this->insertBefore(nodeToPrepend, this->firstChild(), exceptionState); | |
|
philipj_slow
2015/04/29 13:16:57
In the spec none of these are expressed in terms o
| |
| 534 } | |
| 535 | |
| 536 void Node::append(const Vector<NodeOrString>& nodes, ExceptionState& exceptionSt ate) | |
| 537 { | |
| 538 RefPtr<Node> nodeToAppend = mutationMethodMacro(nodes, exceptionState); | |
| 539 this->appendChild(nodeToAppend, exceptionState); | |
| 540 } | |
| 541 | |
| 542 void Node::before(const Vector<NodeOrString>& nodes, ExceptionState& exceptionSt ate) | |
| 543 { | |
| 544 Node* parent = parentNode(); | |
| 545 if (!parent) | |
| 546 return; | |
| 547 RefPtr<Node> nodeToInsert = mutationMethodMacro(nodes, exceptionState); | |
| 548 parent->insertBefore(nodeToInsert, this, exceptionState); | |
| 549 } | |
| 550 | |
| 551 void Node::after(const Vector<NodeOrString>& nodes, ExceptionState& exceptionSta te) | |
| 552 { | |
| 553 Node* parent = parentNode(); | |
| 554 if (!parent) | |
| 555 return; | |
| 556 RefPtr<Node> nodeToInsert = mutationMethodMacro(nodes, exceptionState); | |
| 557 parent->insertBefore(nodeToInsert, this->nextSibling(), exceptionState); | |
| 558 } | |
| 559 | |
| 560 void Node::replaceWith(const Vector<NodeOrString>& nodes, ExceptionState& except ionState) | |
| 561 { | |
| 562 Node* parent = parentNode(); | |
| 563 if (!parent) | |
| 564 return; | |
| 565 RefPtr<Node> nodeToReplaceWith = mutationMethodMacro(nodes, exceptionState); | |
| 566 parent->replaceChild(nodeToReplaceWith, this, exceptionState); | |
| 567 } | |
| 568 | |
| 503 void Node::remove(ExceptionState& exceptionState) | 569 void Node::remove(ExceptionState& exceptionState) |
| 504 { | 570 { |
| 505 if (ContainerNode* parent = parentNode()) | 571 if (ContainerNode* parent = parentNode()) |
| 506 parent->removeChild(this, exceptionState); | 572 parent->removeChild(this, exceptionState); |
| 507 } | 573 } |
| 508 | 574 |
| 509 void Node::normalize() | 575 void Node::normalize() |
| 510 { | 576 { |
| 511 updateDistribution(); | 577 updateDistribution(); |
| 512 | 578 |
| (...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2501 node->showTreeForThis(); | 2567 node->showTreeForThis(); |
| 2502 } | 2568 } |
| 2503 | 2569 |
| 2504 void showNodePath(const blink::Node* node) | 2570 void showNodePath(const blink::Node* node) |
| 2505 { | 2571 { |
| 2506 if (node) | 2572 if (node) |
| 2507 node->showNodePathForThis(); | 2573 node->showNodePathForThis(); |
| 2508 } | 2574 } |
| 2509 | 2575 |
| 2510 #endif | 2576 #endif |
| OLD | NEW |