Chromium Code Reviews| 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. | |
| 290 // So to avoid blowing up on very wide DOMs, we limit the number of siblings t o visit. | |
| 291 unsigned maxSiblingsToVisit = 50; | |
| 292 | |
| 289 const LayoutObject* prev = | 293 const LayoutObject* prev = |
| 290 LayoutTreeBuilderTraversal::previousSiblingLayoutObject(*this); | 294 LayoutTreeBuilderTraversal::previousSiblingLayoutObject( |
| 295 *this, maxSiblingsToVisit); | |
| 291 if (prev && prev->isBR()) // <span><br/> <br/></span> | 296 if (prev && prev->isBR()) // <span><br/> <br/></span> |
| 292 return false; | 297 return false; |
| 293 | 298 |
| 294 if (parent.isLayoutInline()) { | 299 if (parent.isLayoutInline()) { |
| 295 // <span><div/> <div/></span> | 300 // <span><div/> <div/></span> |
| 296 if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned()) | 301 if (prev && !prev->isInline() && !prev->isOutOfFlowPositioned()) |
| 297 return false; | 302 return false; |
| 298 } else { | 303 } else { |
| 299 if (parent.isLayoutBlock() && !parent.childrenInline() && | 304 if (parent.isLayoutBlock() && !parent.childrenInline() && |
| 300 (!prev || !prev->isInline())) | 305 (!prev || !prev->isInline())) |
| 301 return false; | 306 return false; |
| 302 | 307 |
| 303 // Avoiding creation of a layoutObject for the text node is a non-essential | 308 // Avoiding creation of a layoutObject for the text node is a non-essential |
| 304 // memory optimization. So to avoid blowing up on very wide DOMs, we limit | 309 // memory optimization. So to avoid blowing up on very wide DOMs, we limit |
| 305 // the number of siblings to visit. | 310 // the number of siblings to visit. |
| 306 unsigned maxSiblingsToVisit = 50; | 311 unsigned maxSiblingsToVisit = 50; |
|
Nico
2016/10/06 15:13:45
did you mean to delete this here? (i'll send a cl
kojii
2016/10/07 03:22:54
Looks like a merge failure, PS3 removed this but n
| |
| 307 | 312 |
| 308 LayoutObject* first = parent.slowFirstChild(); | 313 LayoutObject* first = parent.slowFirstChild(); |
| 309 while (first && first->isFloatingOrOutOfFlowPositioned() && | 314 for (; first && first->isFloatingOrOutOfFlowPositioned() && |
| 310 maxSiblingsToVisit--) | 315 maxSiblingsToVisit; |
| 311 first = first->nextSibling(); | 316 first = first->nextSibling(), --maxSiblingsToVisit) { |
| 317 } | |
| 312 if (!first || first == layoutObject() || | 318 if (!first || first == layoutObject() || |
| 313 LayoutTreeBuilderTraversal::nextSiblingLayoutObject(*this) == first) { | 319 LayoutTreeBuilderTraversal::nextSiblingLayoutObject( |
| 320 *this, maxSiblingsToVisit) == first) { | |
| 314 // If we're adding children to this flow our previous siblings are not in | 321 // If we're adding children to this flow our previous siblings are not in |
| 315 // the layout tree yet so we cannot know if we will be the first child in | 322 // the layout tree yet so we cannot know if we will be the first child in |
| 316 // the line and collapse away. We have to assume we need a layout object. | 323 // the line and collapse away. We have to assume we need a layout object. |
| 317 Node* firstChildNode = | 324 Node* firstChildNode = |
| 318 parent.node() ? LayoutTreeBuilderTraversal::firstChild(*parent.node()) | 325 parent.node() ? LayoutTreeBuilderTraversal::firstChild(*parent.node()) |
| 319 : nullptr; | 326 : nullptr; |
| 320 if (first && first == layoutObject() && firstChildNode && | 327 if (first && first == layoutObject() && firstChildNode && |
| 321 !firstChildNode->layoutObject()) | 328 !firstChildNode->layoutObject()) |
| 322 return true; | 329 return true; |
| 323 | 330 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 | 449 |
| 443 Text* Text::cloneWithData(const String& data) { | 450 Text* Text::cloneWithData(const String& data) { |
| 444 return create(document(), data); | 451 return create(document(), data); |
| 445 } | 452 } |
| 446 | 453 |
| 447 DEFINE_TRACE(Text) { | 454 DEFINE_TRACE(Text) { |
| 448 CharacterData::trace(visitor); | 455 CharacterData::trace(visitor); |
| 449 } | 456 } |
| 450 | 457 |
| 451 } // namespace blink | 458 } // namespace blink |
| OLD | NEW |