OLD | NEW |
---|---|
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 | 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights |
5 * reserved. | 5 * reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 | 279 |
280 // pre/pre-wrap/pre-line always make layoutObjects. | 280 // pre/pre-wrap/pre-line always make layoutObjects. |
281 if (style.preserveNewline()) | 281 if (style.preserveNewline()) |
282 return true; | 282 return true; |
283 | 283 |
284 // childNeedsDistributionRecalc() here is rare, only happens JS calling | 284 // childNeedsDistributionRecalc() here is rare, only happens JS calling |
285 // surroundContents() etc. from DOMNodeInsertedIntoDocument etc. | 285 // surroundContents() etc. from DOMNodeInsertedIntoDocument etc. |
286 if (document().childNeedsDistributionRecalc()) | 286 if (document().childNeedsDistributionRecalc()) |
287 return true; | 287 return true; |
288 | 288 |
289 // Avoiding creation of a layoutObject for the text node is a non-essential me mory optimization. | 289 // Avoiding creation of a layoutObject for the text node is a non-essential |
290 // So to avoid blowing up on very wide DOMs, we limit the number of siblings t o visit. | 290 // memory optimization. So to avoid blowing up on very wide DOMs, we limit |
291 // the number of siblings to visit. | |
291 unsigned maxSiblingsToVisit = 50; | 292 unsigned maxSiblingsToVisit = 50; |
292 | 293 |
293 const LayoutObject* prev = | 294 const LayoutObject* prev = |
294 LayoutTreeBuilderTraversal::previousSiblingLayoutObject( | 295 LayoutTreeBuilderTraversal::previousSiblingLayoutObject( |
295 *this, maxSiblingsToVisit); | 296 *this, maxSiblingsToVisit); |
296 if (prev && prev->isBR()) // <span><br/> <br/></span> | 297 if (prev && prev->isBR()) // <span><br/> <br/></span> |
297 return false; | 298 return false; |
298 | 299 |
299 if (parent.isLayoutInline()) { | 300 if (parent.isLayoutInline()) { |
300 // <span><div/> <div/></span> | 301 // <span><div/> <div/></span> |
301 if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned()) | 302 if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned()) |
302 return false; | 303 return false; |
303 } else { | 304 } else { |
304 if (parent.isLayoutBlock() && !parent.childrenInline() && | 305 if (parent.isLayoutBlock() && !parent.childrenInline() && |
305 (!prev || !prev->isInline())) | 306 (!prev || !prev->isInline())) |
306 return false; | 307 return false; |
307 | 308 |
308 // Avoiding creation of a layoutObject for the text node is a non-essential | |
309 // memory optimization. So to avoid blowing up on very wide DOMs, we limit | |
310 // the number of siblings to visit. | |
311 unsigned maxSiblingsToVisit = 50; | |
Nico
2016/10/06 15:21:04
It looks like https://codereview.chromium.org/2379
| |
312 | |
313 LayoutObject* first = parent.slowFirstChild(); | 309 LayoutObject* first = parent.slowFirstChild(); |
314 for (; first && first->isFloatingOrOutOfFlowPositioned() && | 310 for (; first && first->isFloatingOrOutOfFlowPositioned() && |
315 maxSiblingsToVisit; | 311 maxSiblingsToVisit; |
316 first = first->nextSibling(), --maxSiblingsToVisit) { | 312 first = first->nextSibling(), --maxSiblingsToVisit) { |
317 } | 313 } |
318 if (!first || first == layoutObject() || | 314 if (!first || first == layoutObject() || |
319 LayoutTreeBuilderTraversal::nextSiblingLayoutObject( | 315 LayoutTreeBuilderTraversal::nextSiblingLayoutObject( |
320 *this, maxSiblingsToVisit) == first) { | 316 *this, maxSiblingsToVisit) == first) { |
321 // If we're adding children to this flow our previous siblings are not in | 317 // If we're adding children to this flow our previous siblings are not in |
322 // the layout tree yet so we cannot know if we will be the first child in | 318 // the layout tree yet so we cannot know if we will be the first child in |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 | 445 |
450 Text* Text::cloneWithData(const String& data) { | 446 Text* Text::cloneWithData(const String& data) { |
451 return create(document(), data); | 447 return create(document(), data); |
452 } | 448 } |
453 | 449 |
454 DEFINE_TRACE(Text) { | 450 DEFINE_TRACE(Text) { |
455 CharacterData::trace(visitor); | 451 CharacterData::trace(visitor); |
456 } | 452 } |
457 | 453 |
458 } // namespace blink | 454 } // namespace blink |
OLD | NEW |