Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: third_party/WebKit/Source/core/dom/Text.cpp

Issue 2473743003: Call Element::rebuildLayoutTree from Document::updateStyle directly (Closed)
Patch Set: FirstLetterPseudoElements are not being created Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 398 clearNeedsReattachLayoutTree();
nainar 2016/12/07 14:48:21 In case we don't perform rebuildTextLayoutTree we
Bugs Nash 2016/12/07 23:21:44 as above, if there is a need to explain the code i
nainar 2016/12/07 23:49:10 Done locally.
399 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { 399 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) {
400 rebuildTextLayoutTree(nextTextSibling); 400 StyleReattachData styleReattachData;
401 styleReattachData.computedStyle = nullptr;
402 styleReattachData.nextTextSibling = nextTextSibling;
403 document().addStyleReattachData(*this, styleReattachData);
404 setNeedsReattachLayoutTree();
401 } 405 }
406 clearNeedsStyleRecalc();
402 } 407 }
403 408
404 void Text::rebuildTextLayoutTree(Text* nextTextSibling) { 409 void Text::rebuildTextLayoutTree() {
410 DCHECK(!needsStyleRecalc());
411 DCHECK(!childNeedsStyleRecalc());
412 DCHECK(needsReattachLayoutTree());
413 DCHECK(parentNode());
414
405 reattachLayoutTree(); 415 reattachLayoutTree();
406 if (layoutObject()) 416 if (layoutObject()) {
407 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 417 reattachWhitespaceSiblingsIfNeeded(
418 document().getStyleReattachData(*this).nextTextSibling);
419 }
408 clearNeedsReattachLayoutTree(); 420 clearNeedsReattachLayoutTree();
409 } 421 }
410 422
411 // 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
412 // 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.
413 bool Text::needsWhitespaceLayoutObject() { 425 bool Text::needsWhitespaceLayoutObject() {
414 DCHECK(!layoutObject()); 426 DCHECK(!layoutObject());
415 if (const ComputedStyle* style = parentComputedStyle()) 427 if (const ComputedStyle* style = parentComputedStyle())
416 return style->preserveNewline(); 428 return style->preserveNewline();
417 return false; 429 return false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 462
451 Text* Text::cloneWithData(const String& data) { 463 Text* Text::cloneWithData(const String& data) {
452 return create(document(), data); 464 return create(document(), data);
453 } 465 }
454 466
455 DEFINE_TRACE(Text) { 467 DEFINE_TRACE(Text) {
456 CharacterData::trace(visitor); 468 CharacterData::trace(visitor);
457 } 469 }
458 470
459 } // namespace blink 471 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698