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

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: Add if case for detached tree 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 if (this->inDocument() || this->isInShadowTree())
kochi 2016/01/28 06:46:11 You can combine this 2 conditions into isInTreeSco
yuzuchan 2016/02/01 04:59:54 Done.
456 return &this->treeScope().rootNode();
kochi 2016/01/28 06:46:11 You can omit 'this->'.
yuzuchan 2016/02/01 04:59:54 Done.
457 Node* node = this;
458 while (node->parentNode())
459 node = node->parentNode();
460 return node;
461 }
462
453 PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> new Child, Node* refChild, ExceptionState& exceptionState) 463 PassRefPtrWillBeRawPtr<Node> Node::insertBefore(PassRefPtrWillBeRawPtr<Node> new Child, Node* refChild, ExceptionState& exceptionState)
454 { 464 {
455 if (isContainerNode()) 465 if (isContainerNode())
456 return toContainerNode(this)->insertBefore(newChild, refChild, exception State); 466 return toContainerNode(this)->insertBefore(newChild, refChild, exception State);
457 467
458 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method."); 468 exceptionState.throwDOMException(HierarchyRequestError, "This node type does not support this method.");
459 return nullptr; 469 return nullptr;
460 } 470 }
461 471
462 PassRefPtrWillBeRawPtr<Node> Node::replaceChild(PassRefPtrWillBeRawPtr<Node> new Child, PassRefPtrWillBeRawPtr<Node> oldChild, ExceptionState& exceptionState) 472 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 2413
2404 void showNodePath(const blink::Node* node) 2414 void showNodePath(const blink::Node* node)
2405 { 2415 {
2406 if (node) 2416 if (node)
2407 node->showNodePathForThis(); 2417 node->showNodePathForThis();
2408 else 2418 else
2409 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2419 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2410 } 2420 }
2411 2421
2412 #endif 2422 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698