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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 | 374 |
375 if (layoutObjectIsNeeded == !!layoutObject()) | 375 if (layoutObjectIsNeeded == !!layoutObject()) |
376 return; | 376 return; |
377 | 377 |
378 // The following is almost the same as Node::reattachLayoutTree() except that | 378 // The following is almost the same as Node::reattachLayoutTree() except that |
379 // we create a layoutObject only if needed. Not calling reattachLayoutTree() | 379 // we create a layoutObject only if needed. Not calling reattachLayoutTree() |
380 // to avoid repeated calls to Text::textLayoutObjectIsNeeded(). | 380 // to avoid repeated calls to Text::textLayoutObjectIsNeeded(). |
381 AttachContext reattachContext(context); | 381 AttachContext reattachContext(context); |
382 reattachContext.performingReattach = true; | 382 reattachContext.performingReattach = true; |
383 | 383 |
384 if (getStyleChangeType() < NeedsReattachStyleChange) | 384 if (getStyleChangeType() <= SubtreeStyleChange) |
nainar
2016/11/29 06:13:39
Again this will always be true. Make it a no op? O
rune
2016/12/05 10:05:17
Replace with !needsReattachLayoutTree(), I think.
| |
385 detachLayoutTree(reattachContext); | 385 detachLayoutTree(reattachContext); |
386 if (layoutObjectIsNeeded) | 386 if (layoutObjectIsNeeded) |
387 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()) | 387 LayoutTreeBuilderForText(*this, layoutParent->layoutObject()) |
388 .createLayoutObject(); | 388 .createLayoutObject(); |
389 CharacterData::attachLayoutTree(reattachContext); | 389 CharacterData::attachLayoutTree(reattachContext); |
390 } | 390 } |
391 | 391 |
392 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { | 392 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { |
393 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { | 393 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { |
394 if (change != NoChange || needsStyleRecalc()) | 394 if (change != NoChange || needsStyleRecalc()) |
395 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); | 395 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); |
396 if (needsStyleRecalc()) | 396 if (needsStyleRecalc()) |
397 layoutItem.setText(dataImpl()); | 397 layoutItem.setText(dataImpl()); |
398 clearNeedsStyleRecalc(); | |
399 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { | 398 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { |
400 rebuildTextLayoutTree(nextTextSibling); | 399 StyleReattachData styleReattachData; |
400 styleReattachData.computedStyle = nullptr; | |
401 styleReattachData.nextTextSibling = nextTextSibling; | |
402 document().addStyleReattachData(*this, styleReattachData); | |
403 setNeedsReattachLayoutTree(); | |
401 } | 404 } |
405 clearNeedsStyleRecalc(); | |
402 } | 406 } |
403 | 407 |
404 void Text::rebuildTextLayoutTree(Text* nextTextSibling) { | 408 void Text::rebuildTextLayoutTree() { |
409 DCHECK(!needsStyleRecalc()); | |
410 DCHECK(!childNeedsStyleRecalc()); | |
411 DCHECK(needsReattachLayoutTree()); | |
412 | |
405 reattachLayoutTree(); | 413 reattachLayoutTree(); |
406 if (layoutObject()) | 414 if (layoutObject()) { |
407 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 415 reattachWhitespaceSiblingsIfNeeded( |
416 document().getStyleReattachData(*this).nextTextSibling); | |
417 } | |
408 clearNeedsReattachLayoutTree(); | 418 clearNeedsReattachLayoutTree(); |
409 } | 419 } |
410 | 420 |
411 // If a whitespace node had no layoutObject and goes through a recalcStyle it | 421 // If a whitespace node had no layoutObject and goes through a recalcStyle it |
412 // may need to create one if the parent style now has white-space: pre. | 422 // may need to create one if the parent style now has white-space: pre. |
413 bool Text::needsWhitespaceLayoutObject() { | 423 bool Text::needsWhitespaceLayoutObject() { |
414 DCHECK(!layoutObject()); | 424 DCHECK(!layoutObject()); |
415 if (const ComputedStyle* style = parentComputedStyle()) | 425 if (const ComputedStyle* style = parentComputedStyle()) |
416 return style->preserveNewline(); | 426 return style->preserveNewline(); |
417 return false; | 427 return false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 | 460 |
451 Text* Text::cloneWithData(const String& data) { | 461 Text* Text::cloneWithData(const String& data) { |
452 return create(document(), data); | 462 return create(document(), data); |
453 } | 463 } |
454 | 464 |
455 DEFINE_TRACE(Text) { | 465 DEFINE_TRACE(Text) { |
456 CharacterData::trace(visitor); | 466 CharacterData::trace(visitor); |
457 } | 467 } |
458 | 468 |
459 } // namespace blink | 469 } // namespace blink |
OLD | NEW |