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

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

Issue 2473743003: Call Element::rebuildLayoutTree from Document::updateStyle directly (Closed)
Patch Set: Make needsAttach() only check if getStyleChangeType flag is NeedsReattachStyleChange and add a Layo… Created 3 years, 9 months 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } 393 }
394 394
395 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { 395 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) {
396 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) { 396 if (LayoutTextItem layoutItem = LayoutTextItem(this->layoutObject())) {
397 if (change != NoChange || needsStyleRecalc()) 397 if (change != NoChange || needsStyleRecalc())
398 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this)); 398 layoutItem.setStyle(document().ensureStyleResolver().styleForText(this));
399 if (needsStyleRecalc()) 399 if (needsStyleRecalc())
400 layoutItem.setText(dataImpl()); 400 layoutItem.setText(dataImpl());
401 clearNeedsStyleRecalc(); 401 clearNeedsStyleRecalc();
402 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) { 402 } else if (needsStyleRecalc() || needsWhitespaceLayoutObject()) {
403 rebuildTextLayoutTree(nextTextSibling); 403 StyleReattachData styleReattachData;
404 styleReattachData.nextTextSibling = nextTextSibling;
405 document().addStyleReattachData(*this, styleReattachData);
406 setNeedsReattachLayoutTree();
404 } 407 }
405 } 408 }
406 409
407 void Text::rebuildTextLayoutTree(Text* nextTextSibling) { 410 void Text::rebuildTextLayoutTree() {
411 DCHECK(!childNeedsStyleRecalc());
412 DCHECK(needsReattachLayoutTree());
413 DCHECK(parentNode());
414
408 reattachLayoutTree(); 415 reattachLayoutTree();
409 if (layoutObject()) 416 if (layoutObject()) {
410 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 417 reattachWhitespaceSiblingsIfNeeded(
418 document().getStyleReattachData(*this).nextTextSibling);
419 }
411 clearNeedsReattachLayoutTree(); 420 clearNeedsReattachLayoutTree();
412 } 421 }
413 422
414 // 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
415 // 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.
416 bool Text::needsWhitespaceLayoutObject() { 425 bool Text::needsWhitespaceLayoutObject() {
417 DCHECK(!layoutObject()); 426 DCHECK(!layoutObject());
418 if (const ComputedStyle* style = parentComputedStyle()) 427 if (const ComputedStyle* style = parentComputedStyle())
419 return style->preserveNewline(); 428 return style->preserveNewline();
420 return false; 429 return false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 467
459 Text* Text::cloneWithData(const String& data) { 468 Text* Text::cloneWithData(const String& data) {
460 return create(document(), data); 469 return create(document(), data);
461 } 470 }
462 471
463 DEFINE_TRACE(Text) { 472 DEFINE_TRACE(Text) {
464 CharacterData::trace(visitor); 473 CharacterData::trace(visitor);
465 } 474 }
466 475
467 } // namespace blink 476 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Text.h ('k') | third_party/WebKit/Source/core/dom/shadow/ElementShadow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698