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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 .createLayoutObject(); | 387 .createLayoutObject(); |
388 CharacterData::attachLayoutTree(reattachContext); | 388 CharacterData::attachLayoutTree(reattachContext); |
389 } | 389 } |
390 | 390 |
391 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { | 391 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { |
392 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { | 392 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { |
393 if (change != NoChange || needsStyleRecalc()) | 393 if (change != NoChange || needsStyleRecalc()) |
394 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); | 394 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); |
395 if (needsStyleRecalc()) | 395 if (needsStyleRecalc()) |
396 layoutItem.setText(dataImpl()); | 396 layoutItem.setText(dataImpl()); |
397 clearNeedsStyleRecalc(); | 397 // In case we don't perform rebuildTextLayoutTree we will never clear the |
398 // NeedsReattachLayoutTree flag which is set on the creation of each | |
399 // Node. Clear that here. | |
400 clearNeedsReattachLayoutTree(); | |
esprehn
2017/02/02 08:37:10
How was this bit set without ended up inside rebui
nainar
2017/02/02 23:13:06
It was set on the text node's creation because Nee
| |
398 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { | 401 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { |
399 rebuildTextLayoutTree(nextTextSibling); | 402 StyleReattachData styleReattachData; |
403 styleReattachData.nextTextSibling = nextTextSibling; | |
404 document().addStyleReattachData(*this, styleReattachData); | |
405 setNeedsReattachLayoutTree(); | |
400 } | 406 } |
407 clearNeedsStyleRecalc(); | |
401 } | 408 } |
402 | 409 |
403 void Text::rebuildTextLayoutTree(Text* nextTextSibling) { | 410 void Text::rebuildTextLayoutTree() { |
411 DCHECK(!childNeedsStyleRecalc()); | |
412 DCHECK(needsReattachLayoutTree()); | |
413 DCHECK(parentNode()); | |
414 | |
404 reattachLayoutTree(); | 415 reattachLayoutTree(); |
405 if (layoutObject()) | 416 if (layoutObject()) { |
406 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 417 reattachWhitespaceSiblingsIfNeeded( |
418 document().getStyleReattachData(*this).nextTextSibling); | |
419 } | |
407 clearNeedsReattachLayoutTree(); | 420 clearNeedsReattachLayoutTree(); |
408 } | 421 } |
409 | 422 |
410 // If a whitespace node had no layoutObject and goes through a recalcStyle it | 423 // If a whitespace node had no layoutObject and goes through a recalcStyle it |
411 // may need to create one if the parent style now has white-space: pre. | 424 // may need to create one if the parent style now has white-space: pre. |
412 bool Text::needsWhitespaceLayoutObject() { | 425 bool Text::needsWhitespaceLayoutObject() { |
413 DCHECK(!layoutObject()); | 426 DCHECK(!layoutObject()); |
414 if (const ComputedStyle* style = parentComputedStyle()) | 427 if (const ComputedStyle* style = parentComputedStyle()) |
415 return style->preserveNewline(); | 428 return style->preserveNewline(); |
416 return false; | 429 return false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 | 462 |
450 Text* Text::cloneWithData(const String& data) { | 463 Text* Text::cloneWithData(const String& data) { |
451 return create(document(), data); | 464 return create(document(), data); |
452 } | 465 } |
453 | 466 |
454 DEFINE_TRACE(Text) { | 467 DEFINE_TRACE(Text) { |
455 CharacterData::trace(visitor); | 468 CharacterData::trace(visitor); |
456 } | 469 } |
457 | 470 |
458 } // namespace blink | 471 } // namespace blink |
OLD | NEW |