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

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

Issue 2369963005: Avoid creating consecutive whitespace renderers. (Closed)
Patch Set: Rebased and manually fixed expectations Created 4 years, 2 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 * 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (style.preserveNewline()) 287 if (style.preserveNewline())
288 return true; 288 return true;
289 289
290 // childNeedsDistributionRecalc() here is rare, only happens JS calling surr oundContents() etc. from DOMNodeInsertedIntoDocument etc. 290 // childNeedsDistributionRecalc() here is rare, only happens JS calling surr oundContents() etc. from DOMNodeInsertedIntoDocument etc.
291 if (document().childNeedsDistributionRecalc()) 291 if (document().childNeedsDistributionRecalc())
292 return true; 292 return true;
293 293
294 const LayoutObject* prev = LayoutTreeBuilderTraversal::previousSiblingLayout Object(*this); 294 const LayoutObject* prev = LayoutTreeBuilderTraversal::previousSiblingLayout Object(*this);
295 if (prev && prev->isBR()) // <span><br/> <br/></span> 295 if (prev && prev->isBR()) // <span><br/> <br/></span>
296 return false; 296 return false;
297 if (prev && prev->isText() && prev->node()->isTextNode() && toText(prev->nod e())->containsOnlyWhitespace())
298 return false;
297 299
298 if (parent.isLayoutInline()) { 300 if (parent.isLayoutInline()) {
299 // <span><div/> <div/></span> 301 // <span><div/> <div/></span>
300 if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned()) 302 if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned())
301 return false; 303 return false;
302 } else { 304 } else {
303 if (parent.isLayoutBlock() && !parent.childrenInline() && (!prev || !pre v->isInline())) 305 if (parent.isLayoutBlock() && !parent.childrenInline() && (!prev || !pre v->isInline()))
304 return false; 306 return false;
305 307
306 // Avoiding creation of a layoutObject for the text node is a non-essent ial memory optimization. 308 // Avoiding creation of a layoutObject for the text node is a non-essent ial memory optimization.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 { 440 {
439 return create(document(), data); 441 return create(document(), data);
440 } 442 }
441 443
442 DEFINE_TRACE(Text) 444 DEFINE_TRACE(Text)
443 { 445 {
444 CharacterData::trace(visitor); 446 CharacterData::trace(visitor);
445 } 447 }
446 448
447 } // namespace blink 449 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698