Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 1642503002: Implement Node.treeRoot (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 return last; 443 return last;
444 last = currentElement->lastChild(); 444 last = currentElement->lastChild();
445 if (!last) 445 if (!last)
446 last = currentElement->pseudoElement(BEFORE); 446 last = currentElement->pseudoElement(BEFORE);
447 return last; 447 return last;
448 } 448 }
449 449
450 return lastChild(); 450 return lastChild();
451 } 451 }
452 452
453 Node* Node::treeRoot()
454 {
455 Node* node = this;
456 while (!isTreeScopeRoot(node)) {
kochi 2016/01/27 09:18:50 style nit: if the loop body is one-liner, you have
kochi 2016/01/27 09:18:50 You can get its treeroot by treeScope().rootNode()
yuzuchan 2016/01/28 06:23:56 Done.
yuzuchan 2016/01/28 06:23:56 Done.
457 node = node->parentNode();
kochi 2016/01/27 09:18:50 This doesn't work for detached tree (i.e. not in d
yuzuchan 2016/01/28 06:23:56 Done.
458 }
459 return node;
460 }
461
453 PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> new Child, Node* refChild, ExceptionState& exceptionState) 462 PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> new Child, Node* refChild, ExceptionState& exceptionState)
454 { 463 {
455 if (isContainerNode()) 464 if (isContainerNode())
456 return toContainerNode(this)->insertBefore(newChild, refChild, exception State); 465 return toContainerNode(this)->insertBefore(newChild, refChild, exception State);
457 466
458 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); 467 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method.");
459 return nullptr; 468 return nullptr;
460 } 469 }
461 470
462 PassRefPtrWillBeRawPtr<Node> Node::replaceChild(PassRefPtrWillBeRawPtr<Node> new Child, PassRefPtrWillBeRawPtr<Node> oldChild, ExceptionState& exceptionState) 471 PassRefPtrWillBeRawPtr<Node> Node::replaceChild(PassRefPtrWillBeRawPtr<Node> new Child, PassRefPtrWillBeRawPtr<Node> oldChild, ExceptionState& exceptionState)
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 2412
2404 void showNodePath(const blink::Node* node) 2413 void showNodePath(const blink::Node* node)
2405 { 2414 {
2406 if (node) 2415 if (node)
2407 node->showNodePathForThis(); 2416 node->showNodePathForThis();
2408 else 2417 else
2409 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2418 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2410 } 2419 }
2411 2420
2412 #endif 2421 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698