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

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

Issue 54803003: Have Node::lastDescendant() return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Kill firstDescendant()! Created 7 years, 1 month 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
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/editing/DeleteSelectionCommand.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void Node::setNodeValue(const String&) 376 void Node::setNodeValue(const String&)
377 { 377 {
378 // By default, setting nodeValue has no effect. 378 // By default, setting nodeValue has no effect.
379 } 379 }
380 380
381 PassRefPtr<NodeList> Node::childNodes() 381 PassRefPtr<NodeList> Node::childNodes()
382 { 382 {
383 return ensureRareData().ensureNodeLists().ensureChildNodeList(this); 383 return ensureRareData().ensureNodeLists().ensureChildNodeList(this);
384 } 384 }
385 385
386 Node *Node::lastDescendant() const 386 Node& Node::lastDescendant() const
387 { 387 {
388 Node *n = const_cast<Node *>(this); 388 Node* n = const_cast<Node*>(this);
389 while (n && n->lastChild()) 389 while (n && n->lastChild())
390 n = n->lastChild(); 390 n = n->lastChild();
391 return n; 391 ASSERT(n);
392 } 392 return *n;
393
394 Node* Node::firstDescendant() const
395 {
396 Node *n = const_cast<Node *>(this);
397 while (n && n->firstChild())
398 n = n->firstChild();
399 return n;
400 } 393 }
401 394
402 Node* Node::pseudoAwarePreviousSibling() const 395 Node* Node::pseudoAwarePreviousSibling() const
403 { 396 {
404 if (parentElement() && !previousSibling()) { 397 if (parentElement() && !previousSibling()) {
405 Element* parent = parentElement(); 398 Element* parent = parentElement();
406 if (isAfterPseudoElement() && parent->lastChild()) 399 if (isAfterPseudoElement() && parent->lastChild())
407 return parent->lastChild(); 400 return parent->lastChild();
408 if (!isBeforePseudoElement()) 401 if (!isBeforePseudoElement())
409 return parent->pseudoElement(BEFORE); 402 return parent->pseudoElement(BEFORE);
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 node->showTreeForThis(); 2623 node->showTreeForThis();
2631 } 2624 }
2632 2625
2633 void showNodePath(const WebCore::Node* node) 2626 void showNodePath(const WebCore::Node* node)
2634 { 2627 {
2635 if (node) 2628 if (node)
2636 node->showNodePathForThis(); 2629 node->showNodePathForThis();
2637 } 2630 }
2638 2631
2639 #endif 2632 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/editing/DeleteSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698