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

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

Issue 2740823005: Track lastTextNode during rebuildLayoutTree. (Closed)
Patch Set: Missing reset of lastTextNode for elements. 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Text.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 if (getStyleChangeType() < NeedsReattachStyleChange) 385 if (getStyleChangeType() < NeedsReattachStyleChange)
386 detachLayoutTree(reattachContext); 386 detachLayoutTree(reattachContext);
387 if (layoutObjectIsNeeded) { 387 if (layoutObjectIsNeeded) {
388 LayoutTreeBuilderForText(*this, parentLayoutObject, 388 LayoutTreeBuilderForText(*this, parentLayoutObject,
389 styleParent->mutableComputedStyle()) 389 styleParent->mutableComputedStyle())
390 .createLayoutObject(); 390 .createLayoutObject();
391 } 391 }
392 CharacterData::attachLayoutTree(reattachContext); 392 CharacterData::attachLayoutTree(reattachContext);
393 } 393 }
394 394
395 void Text::recalcTextStyle(StyleRecalcChange change, Text* nextTextSibling) { 395 void Text::recalcTextStyle(StyleRecalcChange change) {
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 StyleReattachData styleReattachData;
404 styleReattachData.nextTextSibling = nextTextSibling;
405 document().addStyleReattachData(*this, styleReattachData);
406 setNeedsReattachLayoutTree(); 403 setNeedsReattachLayoutTree();
407 } 404 }
408 } 405 }
409 406
410 void Text::rebuildTextLayoutTree() { 407 void Text::rebuildTextLayoutTree(Text* nextTextSibling) {
411 DCHECK(!childNeedsStyleRecalc()); 408 DCHECK(!childNeedsStyleRecalc());
412 DCHECK(needsReattachLayoutTree()); 409 DCHECK(needsReattachLayoutTree());
413 DCHECK(parentNode()); 410 DCHECK(parentNode());
414 411
415 reattachLayoutTree(); 412 reattachLayoutTree();
416 if (layoutObject()) { 413 if (layoutObject())
417 reattachWhitespaceSiblingsIfNeeded( 414 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
418 document().getStyleReattachData(*this).nextTextSibling);
419 }
420 clearNeedsReattachLayoutTree(); 415 clearNeedsReattachLayoutTree();
421 } 416 }
422 417
423 // If a whitespace node had no layoutObject and goes through a recalcStyle it 418 // If a whitespace node had no layoutObject and goes through a recalcStyle it
424 // may need to create one if the parent style now has white-space: pre. 419 // may need to create one if the parent style now has white-space: pre.
425 bool Text::needsWhitespaceLayoutObject() { 420 bool Text::needsWhitespaceLayoutObject() {
426 DCHECK(!layoutObject()); 421 DCHECK(!layoutObject());
427 if (const ComputedStyle* style = parentComputedStyle()) 422 if (const ComputedStyle* style = parentComputedStyle())
428 return style->preserveNewline(); 423 return style->preserveNewline();
429 return false; 424 return false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 462
468 Text* Text::cloneWithData(const String& data) { 463 Text* Text::cloneWithData(const String& data) {
469 return create(document(), data); 464 return create(document(), data);
470 } 465 }
471 466
472 DEFINE_TRACE(Text) { 467 DEFINE_TRACE(Text) {
473 CharacterData::trace(visitor); 468 CharacterData::trace(visitor);
474 } 469 }
475 470
476 } // namespace blink 471 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Text.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698