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

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed)

Created:
4 years, 7 months ago by yosin_UTC9
Modified:
4 years, 7 months ago
Reviewers:
tkent, hayato
CC:
aboxhall, aboxhall+watch_chromium.org, blink-layers+watch_chromium.org, blink-reviews, blink-reviews-dom_chromium.org, blink-reviews-style_chromium.org, chromium-reviews, dglazkov+blink, dmazzoni, dmazzoni+watch_chromium.org, krit, dtseng+watch_chromium.org, eae+blinkwatch, f(malita), fs, gyuyoung2, haraken, je_julie, kenneth.christiansen, kouhei+svg_chromium.org, nektar+watch_chromium.org, nektarios, pdr+svgwatchlist_chromium.org, rwlbuis, Stephen Chennney, sof, yuzo+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop This patch introduces |NodeTraversal::ancestorsOf()| and |inclusiveAncestors()| to reduce source code size by common code pattern for ease of writing code in addition to |NodeTraversal::childrenOf()|[1], |NodeTraversal::descendansOf()| and so on. Before this patch, we should write: // Loop for ancestors for (Node* runner = node->parentNode(); runner; runner = runner->parentNode()) { ... } // Loop for ancestors or self for (Node* runner = node; runner; runner = runner->parentNode()) { ... } After this patch, you can write: for (Node& runner : NodeTraversal::ancestorsOf(*node)) { ... } for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { ... } [1] https://codereview.chromium.org/642973003 Introduce typed Node/Element iterators for range-based for loops of C++11 BUG=n/a TEST=n/a; no behavior changes Committed: https://crrev.com/95d6f1792e11fefa919d81d1ed7c0d233deafa76 Cr-Commit-Position: refs/heads/master@{#390895}

Patch Set 1 #

Patch Set 2 : 2016-04-28T16:44:17 #

Total comments: 5

Patch Set 3 : 2016-04-28T17:38:56 #

Patch Set 4 : 2016-04-28T17:43:11 Rename to inclusiveAncestorsOf and fix compilation error in EditingStyle.cpp #

Patch Set 5 : 2016-04-28T18:38:12 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+173 lines, -98 lines) Patch
M third_party/WebKit/Source/core/dom/Document.cpp View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Node.cpp View 1 2 3 4 1 chunk +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/dom/NodeTraversal.h View 1 2 3 4 4 chunks +40 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/NodeTraversal.cpp View 6 chunks +16 lines, -16 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Range.cpp View 1 2 3 4 2 chunks +7 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/editing/EditingStyle.cpp View 1 2 3 4 2 chunks +12 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/EditingUtilities.cpp View 1 2 3 4 4 chunks +17 lines, -13 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp View 2 chunks +10 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp View 1 2 3 4 1 chunk +5 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/FormatBlockCommand.cpp View 1 2 3 4 1 chunk +9 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.cpp View 1 2 3 4 2 chunks +6 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/page/SpatialNavigation.cpp View 2 chunks +6 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/page/TouchDisambiguation.cpp View 1 2 3 4 1 chunk +8 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp View 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/svg/SVGElement.cpp View 1 2 3 4 1 chunk +10 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp View 1 2 3 4 1 chunk +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/web/WebLocalFrameImpl.cpp View 1 2 3 4 1 chunk +12 lines, -10 lines 0 comments Download

Messages

Total messages: 27 (10 generated)
yosin_UTC9
PTAL
4 years, 7 months ago (2016-04-28 07:57:15 UTC) #5
tkent
Maybe hayato@ is a better reviewer for this.
4 years, 7 months ago (2016-04-28 08:08:44 UTC) #7
fs
https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h File third_party/WebKit/Source/core/dom/NodeTraversal.h (right): https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h#newcode106 third_party/WebKit/Source/core/dom/NodeTraversal.h:106: static TraversalRange<TraversalAncestorsOrSelfIterator<NodeTraversal>> ancestorsOrSelfOf(const Node*); Drive-by: ancestorsOrSelfOf is kind of ...
4 years, 7 months ago (2016-04-28 08:18:52 UTC) #8
hayato
https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h File third_party/WebKit/Source/core/dom/NodeTraversal.h (right): https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h#newcode236 third_party/WebKit/Source/core/dom/NodeTraversal.h:236: inline TraversalRange<TraversalAncestorsOrSelfIterator<NodeTraversal>> NodeTraversal::ancestorsOrSelfOf(const Node* node) It might be better ...
4 years, 7 months ago (2016-04-28 08:38:21 UTC) #9
yosin_UTC9
PTAL https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h File third_party/WebKit/Source/core/dom/NodeTraversal.h (right): https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h#newcode106 third_party/WebKit/Source/core/dom/NodeTraversal.h:106: static TraversalRange<TraversalAncestorsOrSelfIterator<NodeTraversal>> ancestorsOrSelfOf(const Node*); On 2016/04/28 at 08:18:52, ...
4 years, 7 months ago (2016-04-28 08:59:05 UTC) #10
yosin_UTC9
https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h File third_party/WebKit/Source/core/dom/NodeTraversal.h (right): https://codereview.chromium.org/1932523003/diff/20001/third_party/WebKit/Source/core/dom/NodeTraversal.h#newcode236 third_party/WebKit/Source/core/dom/NodeTraversal.h:236: inline TraversalRange<TraversalAncestorsOrSelfIterator<NodeTraversal>> NodeTraversal::ancestorsOrSelfOf(const Node* node) On 2016/04/28 at 08:59:04, ...
4 years, 7 months ago (2016-04-28 09:01:29 UTC) #11
hayato
I am aware that there are some places where we have to check null-ness. Actually, ...
4 years, 7 months ago (2016-04-28 09:15:15 UTC) #12
yosin_UTC9
PTAL - Get rid of pointer version of |inclusiveAncestorsOf()| - rewrite these call sites and ...
4 years, 7 months ago (2016-04-28 09:40:39 UTC) #13
hayato
lgtm
4 years, 7 months ago (2016-04-28 09:52:39 UTC) #14
hayato
Please update the description of the CL to reflect |inclusiveAncestorsOf|.
4 years, 7 months ago (2016-04-28 09:53:24 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1932523003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1932523003/80001
4 years, 7 months ago (2016-04-28 13:48:41 UTC) #18
yosin_UTC9
Kent-san, please review a file in Source/web in this patch. There is one file: Source/web/WebLocalFrameImpl.cpp ...
4 years, 7 months ago (2016-04-28 13:54:11 UTC) #19
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/174623)
4 years, 7 months ago (2016-04-28 14:01:50 UTC) #21
tkent
lgtm
4 years, 7 months ago (2016-05-02 04:11:36 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1932523003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1932523003/80001
4 years, 7 months ago (2016-05-02 04:11:51 UTC) #24
commit-bot: I haz the power
Committed patchset #5 (id:80001)
4 years, 7 months ago (2016-05-02 05:26:29 UTC) #25
commit-bot: I haz the power
4 years, 7 months ago (2016-05-02 05:28:14 UTC) #27
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/95d6f1792e11fefa919d81d1ed7c0d233deafa76
Cr-Commit-Position: refs/heads/master@{#390895}

Powered by Google App Engine
This is Rietveld 408576698