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(); |
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(!needsStyleRecalc()); |
| 412 DCHECK(!childNeedsStyleRecalc()); |
| 413 DCHECK(needsReattachLayoutTree()); |
| 414 DCHECK(parentNode()); |
| 415 |
404 reattachLayoutTree(); | 416 reattachLayoutTree(); |
405 if (layoutObject()) | 417 if (layoutObject()) { |
406 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 418 reattachWhitespaceSiblingsIfNeeded( |
| 419 document().getStyleReattachData(*this).nextTextSibling); |
| 420 } |
407 clearNeedsReattachLayoutTree(); | 421 clearNeedsReattachLayoutTree(); |
408 } | 422 } |
409 | 423 |
410 // If a whitespace node had no layoutObject and goes through a recalcStyle it | 424 // 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. | 425 // may need to create one if the parent style now has white-space: pre. |
412 bool Text::needsWhitespaceLayoutObject() { | 426 bool Text::needsWhitespaceLayoutObject() { |
413 DCHECK(!layoutObject()); | 427 DCHECK(!layoutObject()); |
414 if (const ComputedStyle* style = parentComputedStyle()) | 428 if (const ComputedStyle* style = parentComputedStyle()) |
415 return style->preserveNewline(); | 429 return style->preserveNewline(); |
416 return false; | 430 return false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 | 463 |
450 Text* Text::cloneWithData(const String& data) { | 464 Text* Text::cloneWithData(const String& data) { |
451 return create(document(), data); | 465 return create(document(), data); |
452 } | 466 } |
453 | 467 |
454 DEFINE_TRACE(Text) { | 468 DEFINE_TRACE(Text) { |
455 CharacterData::trace(visitor); | 469 CharacterData::trace(visitor); |
456 } | 470 } |
457 | 471 |
458 } // namespace blink | 472 } // namespace blink |
OLD | NEW |