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

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

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T18:38:12 Created 4 years, 7 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const 458 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const
459 { 459 {
460 if (isPseudoElement()) 460 if (isPseudoElement())
461 return false; 461 return false;
462 462
463 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but 463 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but
464 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion 464 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
465 // would fire in the middle of Document::setFocusedNode(). 465 // would fire in the middle of Document::setFocusedNode().
466 466
467 for (const Node* node = this; node; node = node->parentNode()) { 467 for (const Node& node : NodeTraversal::inclusiveAncestorsOf(*this)) {
468 if ((node->isHTMLElement() || node->isDocumentNode()) && node->layoutObj ect()) { 468 if ((node.isHTMLElement() || node.isDocumentNode()) && node.layoutObject ()) {
469 // Elements with user-select: all style are considered atomic 469 // Elements with user-select: all style are considered atomic
470 // therefore non editable. 470 // therefore non editable.
471 if (nodeIsUserSelectAll(node) && treatment == UserSelectAllIsAlwaysN onEditable) 471 if (nodeIsUserSelectAll(&node) && treatment == UserSelectAllIsAlways NonEditable)
472 return false; 472 return false;
473 switch (node->layoutObject()->style()->userModify()) { 473 switch (node.layoutObject()->style()->userModify()) {
474 case READ_ONLY: 474 case READ_ONLY:
475 return false; 475 return false;
476 case READ_WRITE: 476 case READ_WRITE:
477 return true; 477 return true;
478 case READ_WRITE_PLAINTEXT_ONLY: 478 case READ_WRITE_PLAINTEXT_ONLY:
479 return editableLevel != RichlyEditable; 479 return editableLevel != RichlyEditable;
480 } 480 }
481 ASSERT_NOT_REACHED(); 481 ASSERT_NOT_REACHED();
482 return false; 482 return false;
483 } 483 }
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after
2332 2332
2333 void showNodePath(const blink::Node* node) 2333 void showNodePath(const blink::Node* node)
2334 { 2334 {
2335 if (node) 2335 if (node)
2336 node->showNodePathForThis(); 2336 node->showNodePathForThis();
2337 else 2337 else
2338 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2338 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2339 } 2339 }
2340 2340
2341 #endif 2341 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/NodeTraversal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698