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

Unified 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: add layout test cases and fix format issues 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutText.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutText.cpp b/third_party/WebKit/Source/core/layout/LayoutText.cpp
index a9c752da008b776c0b185fa9edad9f12291e07f9..8f5411e2ca86274528b340436591eda272b33200 100644
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp
@@ -34,6 +34,7 @@
#include "core/layout/LayoutTableCell.h"
#include "core/layout/LayoutTextCombine.h"
#include "core/layout/LayoutView.h"
+#include "core/layout/TextAutosizer.h"
#include "core/layout/api/LineLayoutBox.h"
#include "core/layout/line/AbstractInlineTextBox.h"
#include "core/layout/line/EllipsisBox.h"
@@ -209,6 +210,14 @@ void LayoutText::styleDidChange(StyleDifference diff,
// This is an optimization that kicks off font load before layout.
if (!text().containsOnlyWhitespace())
newStyle.font().willUseFontData(text());
+
+ TextAutosizer* textAutosizer = document().textAutosizer();
+ unsigned newAddedTextLength = text().stripWhiteSpace().length();
+ if (!oldStyle && textAutosizer && newAddedTextLength > 0 &&
skobes 2016/11/09 03:11:39 Why do we check !oldStyle here?
cathiechentx 2016/11/09 12:58:46 We only keep a count of new created/added text. "!
+ newStyle.textAutosizingFingerPrint() != 0) {
+ textAutosizer->textAutosizingNewTextAdded(
+ newStyle.textAutosizingFingerPrint(), newAddedTextLength);
skobes 2016/11/09 03:11:39 Can we just pass the LayoutText* and have TextAuto
cathiechentx 2016/11/09 12:58:46 yes, passing the LayoutText* is more elegant, and
+ }
}
void LayoutText::removeAndDestroyTextBoxes() {
@@ -1654,6 +1663,8 @@ void LayoutText::setText(PassRefPtr<StringImpl> text, bool force) {
if (!force && equal(m_text.impl(), text.get()))
return;
+ int newAddedTextLength =
+ text->stripWhiteSpace()->length() - m_text.stripWhiteSpace().length();
setTextInternal(std::move(text));
// If preferredLogicalWidthsDirty() of an orphan child is true,
// LayoutObjectChildList::insertChildNode() fails to set true to owner.
@@ -1664,6 +1675,13 @@ void LayoutText::setText(PassRefPtr<StringImpl> text, bool force) {
LayoutInvalidationReason::TextChanged);
m_knownToHaveNoOverflowAndNoFallbackFonts = false;
+ TextAutosizer* textAutosizer = document().textAutosizer();
+ if (textAutosizer && style() && newAddedTextLength > 0 &&
+ style()->textAutosizingFingerPrint() != 0) {
+ textAutosizer->textAutosizingNewTextAdded(
+ style()->textAutosizingFingerPrint(), (unsigned)newAddedTextLength);
+ }
+
if (AXObjectCache* cache = document().existingAXObjectCache())
cache->textChanged(this);
}

Powered by Google App Engine
This is Rietveld 408576698