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

Unified Diff: third_party/WebKit/Source/core/layout/line/InlineIterator.h

Issue 2267363007: Loop instead of tail-recursion in adjustMidpointsAndAppendRunsForObjectIfNeeded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/line/InlineIterator.h
diff --git a/third_party/WebKit/Source/core/layout/line/InlineIterator.h b/third_party/WebKit/Source/core/layout/line/InlineIterator.h
index d35c070a081ff207a273b4b9949212cc75237be2..ace68b2111611df5542fb9c817a8207bd9567118 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineIterator.h
+++ b/third_party/WebKit/Source/core/layout/line/InlineIterator.h
@@ -690,40 +690,44 @@ static void adjustMidpointsAndAppendRunsForObjectIfNeeded(LineLayoutItem obj, un
if (start > end || LayoutBlockFlow::shouldSkipCreatingRunsForObject(obj))
return;
- LineMidpointState& lineMidpointState = resolver.midpointState();
- bool haveNextMidpoint = (lineMidpointState.currentMidpoint() < lineMidpointState.numMidpoints());
- InlineIterator nextMidpoint;
- if (haveNextMidpoint)
- nextMidpoint = lineMidpointState.midpoints()[lineMidpointState.currentMidpoint()];
- if (lineMidpointState.betweenMidpoints()) {
- if (!(haveNextMidpoint && nextMidpoint.getLineLayoutItem() == obj))
- return;
- // This is a new start point. Stop ignoring objects and
- // adjust our start.
- lineMidpointState.setBetweenMidpoints(false);
- start = nextMidpoint.offset();
- lineMidpointState.incrementCurrentMidpoint();
- if (start < end)
- return adjustMidpointsAndAppendRunsForObjectIfNeeded(obj, start, end, root, resolver, behavior, tracker);
- } else {
- if (!haveNextMidpoint || (obj != nextMidpoint.getLineLayoutItem())) {
- appendRunObjectIfNecessary(obj, start, end, root, resolver, behavior, tracker);
- return;
- }
-
- // An end midpoint has been encountered within our object. We
- // need to go ahead and append a run with our endpoint.
- if (nextMidpoint.offset() + 1 <= end) {
- lineMidpointState.setBetweenMidpoints(true);
+ for (;;) {
+ LineMidpointState& lineMidpointState = resolver.midpointState();
+ bool haveNextMidpoint = (lineMidpointState.currentMidpoint() < lineMidpointState.numMidpoints());
+ InlineIterator nextMidpoint;
+ if (haveNextMidpoint)
+ nextMidpoint = lineMidpointState.midpoints()[lineMidpointState.currentMidpoint()];
+ if (lineMidpointState.betweenMidpoints()) {
+ if (!(haveNextMidpoint && nextMidpoint.getLineLayoutItem() == obj))
+ return;
+ // This is a new start point. Stop ignoring objects and
+ // adjust our start.
+ lineMidpointState.setBetweenMidpoints(false);
+ start = nextMidpoint.offset();
lineMidpointState.incrementCurrentMidpoint();
- if (nextMidpoint.offset() != UINT_MAX) { // UINT_MAX means stop at the object and don't nclude any of it.
- if (nextMidpoint.offset() + 1 > start)
- appendRunObjectIfNecessary(obj, start, nextMidpoint.offset() + 1, root, resolver, behavior, tracker);
- return adjustMidpointsAndAppendRunsForObjectIfNeeded(obj, nextMidpoint.offset() + 1, end, root, resolver, behavior, tracker);
- }
+ if (start < end)
+ continue;
} else {
- appendRunObjectIfNecessary(obj, start, end, root, resolver, behavior, tracker);
+ if (!haveNextMidpoint || (obj != nextMidpoint.getLineLayoutItem())) {
+ appendRunObjectIfNecessary(obj, start, end, root, resolver, behavior, tracker);
+ return;
+ }
+
+ // An end midpoint has been encountered within our object. We
+ // need to go ahead and append a run with our endpoint.
+ if (nextMidpoint.offset() + 1 <= end) {
+ lineMidpointState.setBetweenMidpoints(true);
+ lineMidpointState.incrementCurrentMidpoint();
+ if (nextMidpoint.offset() != UINT_MAX) { // UINT_MAX means stop at the object and don't nclude any of it.
+ if (nextMidpoint.offset() + 1 > start)
+ appendRunObjectIfNecessary(obj, start, nextMidpoint.offset() + 1, root, resolver, behavior, tracker);
+ start = nextMidpoint.offset() + 1;
+ continue;
+ }
+ } else {
+ appendRunObjectIfNecessary(obj, start, end, root, resolver, behavior, tracker);
+ }
}
+ return;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698