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

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

Issue 15871005: Avoid N^2 walk placing renderers when building the render tree (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding a mitigation for the perf regression to Element::recalcStyle. Created 7 years, 5 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
« no previous file with comments | « Source/core/dom/ScriptElement.cpp ('k') | Source/core/dom/shadow/ShadowRoot.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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool onlyWS = containsOnlyWhitespace(); 209 bool onlyWS = containsOnlyWhitespace();
210 if (!onlyWS) 210 if (!onlyWS)
211 return true; 211 return true;
212 212
213 RenderObject* parent = context.parentRenderer(); 213 RenderObject* parent = context.parentRenderer();
214 if (parent->isTable() || parent->isTableRow() || parent->isTableSection() || parent->isRenderTableCol() || parent->isFrameSet()) 214 if (parent->isTable() || parent->isTableRow() || parent->isTableSection() || parent->isRenderTableCol() || parent->isFrameSet())
215 return false; 215 return false;
216 216
217 if (context.style()->preserveNewline()) // pre/pre-wrap/pre-line always make renderers. 217 if (context.style()->preserveNewline()) // pre/pre-wrap/pre-line always make renderers.
218 return true; 218 return true;
219 219
220 // FIXME: We should resolve this function's dependencies on next and previou s renderers
221 // lazily to avoid potentially N^2 walks through the DOM.
220 RenderObject* prev = context.previousRenderer(); 222 RenderObject* prev = context.previousRenderer();
221 if (prev && prev->isBR()) // <span><br/> <br/></span> 223 if (prev && prev->isBR()) // <span><br/> <br/></span>
222 return false; 224 return false;
223 225
224 if (parent->isRenderInline()) { 226 if (parent->isRenderInline()) {
225 // <span><div/> <div/></span> 227 // <span><div/> <div/></span>
226 if (prev && !prev->isInline()) 228 if (prev && !prev->isInline())
227 return false; 229 return false;
228 } else { 230 } else {
229 if (parent->isRenderBlock() && !parent->childrenInline() && (!prev || !p rev->isInline())) 231 if (parent->isRenderBlock() && !parent->childrenInline() && (!prev || !p rev->isInline()))
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 result.appendLiteral("; "); 343 result.appendLiteral("; ");
342 result.appendLiteral("value="); 344 result.appendLiteral("value=");
343 result.append(s); 345 result.append(s);
344 } 346 }
345 347
346 strncpy(buffer, result.toString().utf8().data(), length - 1); 348 strncpy(buffer, result.toString().utf8().data(), length - 1);
347 } 349 }
348 #endif 350 #endif
349 351
350 } // namespace WebCore 352 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptElement.cpp ('k') | Source/core/dom/shadow/ShadowRoot.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698