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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2299213003: Fix the inconsistent problem while the content of textNodes is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: using everHadLayout to determine if nodes are new Created 4 years, 1 month 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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 16 matching lines...) Expand all
27 #include "core/dom/AXObjectCache.h" 27 #include "core/dom/AXObjectCache.h"
28 #include "core/dom/Text.h" 28 #include "core/dom/Text.h"
29 #include "core/editing/VisiblePosition.h" 29 #include "core/editing/VisiblePosition.h"
30 #include "core/editing/iterators/TextIterator.h" 30 #include "core/editing/iterators/TextIterator.h"
31 #include "core/frame/FrameView.h" 31 #include "core/frame/FrameView.h"
32 #include "core/frame/Settings.h" 32 #include "core/frame/Settings.h"
33 #include "core/layout/LayoutBlock.h" 33 #include "core/layout/LayoutBlock.h"
34 #include "core/layout/LayoutTableCell.h" 34 #include "core/layout/LayoutTableCell.h"
35 #include "core/layout/LayoutTextCombine.h" 35 #include "core/layout/LayoutTextCombine.h"
36 #include "core/layout/LayoutView.h" 36 #include "core/layout/LayoutView.h"
37 #include "core/layout/TextAutosizer.h"
37 #include "core/layout/api/LineLayoutBox.h" 38 #include "core/layout/api/LineLayoutBox.h"
38 #include "core/layout/line/AbstractInlineTextBox.h" 39 #include "core/layout/line/AbstractInlineTextBox.h"
39 #include "core/layout/line/EllipsisBox.h" 40 #include "core/layout/line/EllipsisBox.h"
40 #include "core/layout/line/GlyphOverflow.h" 41 #include "core/layout/line/GlyphOverflow.h"
41 #include "core/layout/line/InlineTextBox.h" 42 #include "core/layout/line/InlineTextBox.h"
42 #include "platform/fonts/CharacterRange.h" 43 #include "platform/fonts/CharacterRange.h"
43 #include "platform/geometry/FloatQuad.h" 44 #include "platform/geometry/FloatQuad.h"
44 #include "platform/text/BidiResolver.h" 45 #include "platform/text/BidiResolver.h"
45 #include "platform/text/Character.h" 46 #include "platform/text/Character.h"
46 #include "platform/text/Hyphenation.h" 47 #include "platform/text/Hyphenation.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 const ComputedStyle& newStyle = styleRef(); 203 const ComputedStyle& newStyle = styleRef();
203 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE; 204 ETextTransform oldTransform = oldStyle ? oldStyle->textTransform() : TTNONE;
204 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE; 205 ETextSecurity oldSecurity = oldStyle ? oldStyle->textSecurity() : TSNONE;
205 if (oldTransform != newStyle.textTransform() || 206 if (oldTransform != newStyle.textTransform() ||
206 oldSecurity != newStyle.textSecurity()) 207 oldSecurity != newStyle.textSecurity())
207 transformText(); 208 transformText();
208 209
209 // This is an optimization that kicks off font load before layout. 210 // This is an optimization that kicks off font load before layout.
210 if (!text().containsOnlyWhitespace()) 211 if (!text().containsOnlyWhitespace())
211 newStyle.font().willUseFontData(text()); 212 newStyle.font().willUseFontData(text());
213
214 TextAutosizer* textAutosizer = document().textAutosizer();
215 if (!oldStyle && textAutosizer)
pdr. 2016/11/20 06:38:13 This approach of calling newNodeAdded for each nod
cathiechentx 2016/11/22 08:14:47 Actually this approach isn't as slow as it looks l
216 textAutosizer->newNodeAdded(this);
212 } 217 }
213 218
214 void LayoutText::removeAndDestroyTextBoxes() { 219 void LayoutText::removeAndDestroyTextBoxes() {
215 if (!documentBeingDestroyed()) { 220 if (!documentBeingDestroyed()) {
216 if (firstTextBox()) { 221 if (firstTextBox()) {
217 if (isBR()) { 222 if (isBR()) {
218 RootInlineBox* next = firstTextBox()->root().nextRootBox(); 223 RootInlineBox* next = firstTextBox()->root().nextRootBox();
219 if (next) 224 if (next)
220 next->markDirty(); 225 next->markDirty();
221 } 226 }
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 // LayoutObjectChildList::insertChildNode() fails to set true to owner. 1664 // LayoutObjectChildList::insertChildNode() fails to set true to owner.
1660 // To avoid that, we call setNeedsLayoutAndPrefWidthsRecalc() only if this 1665 // To avoid that, we call setNeedsLayoutAndPrefWidthsRecalc() only if this
1661 // LayoutText has parent. 1666 // LayoutText has parent.
1662 if (parent()) 1667 if (parent())
1663 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( 1668 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(
1664 LayoutInvalidationReason::TextChanged); 1669 LayoutInvalidationReason::TextChanged);
1665 m_knownToHaveNoOverflowAndNoFallbackFonts = false; 1670 m_knownToHaveNoOverflowAndNoFallbackFonts = false;
1666 1671
1667 if (AXObjectCache* cache = document().existingAXObjectCache()) 1672 if (AXObjectCache* cache = document().existingAXObjectCache())
1668 cache->textChanged(this); 1673 cache->textChanged(this);
1674
1675 TextAutosizer* textAutosizer = document().textAutosizer();
1676 if (textAutosizer)
1677 textAutosizer->newNodeAdded(this);
1669 } 1678 }
1670 1679
1671 void LayoutText::dirtyOrDeleteLineBoxesIfNeeded(bool fullLayout) { 1680 void LayoutText::dirtyOrDeleteLineBoxesIfNeeded(bool fullLayout) {
1672 if (fullLayout) 1681 if (fullLayout)
1673 deleteTextBoxes(); 1682 deleteTextBoxes();
1674 else if (!m_linesDirty) 1683 else if (!m_linesDirty)
1675 dirtyLineBoxes(); 1684 dirtyLineBoxes();
1676 m_linesDirty = false; 1685 m_linesDirty = false;
1677 } 1686 }
1678 1687
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 LayoutRect rect = LayoutRect( 1982 LayoutRect rect = LayoutRect(
1974 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); 1983 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height()));
1975 LayoutBlock* block = containingBlock(); 1984 LayoutBlock* block = containingBlock();
1976 if (block && hasTextBoxes()) 1985 if (block && hasTextBoxes())
1977 block->adjustChildDebugRect(rect); 1986 block->adjustChildDebugRect(rect);
1978 1987
1979 return rect; 1988 return rect;
1980 } 1989 }
1981 1990
1982 } // namespace blink 1991 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698