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

Unified Diff: third_party/WebKit/Source/core/layout/TextAutosizer.h

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/TextAutosizer.h
diff --git a/third_party/WebKit/Source/core/layout/TextAutosizer.h b/third_party/WebKit/Source/core/layout/TextAutosizer.h
index 35d93fcbc9c3c103440f25cbe88a7d84388262f8..84c9a0242e4967bab8e8bce58654744d22fa95e7 100644
--- a/third_party/WebKit/Source/core/layout/TextAutosizer.h
+++ b/third_party/WebKit/Source/core/layout/TextAutosizer.h
@@ -69,10 +69,11 @@ class CORE_EXPORT TextAutosizer final
void updatePageInfoInAllFrames();
void updatePageInfo();
- void record(const LayoutBlock*);
- void destroy(const LayoutBlock*);
+ void record(LayoutBlock*);
+ void destroy(LayoutBlock*);
bool pageNeedsAutosizing() const;
+ void newNodeAdded(LayoutObject*);
DECLARE_TRACE();
@@ -107,7 +108,8 @@ class CORE_EXPORT TextAutosizer final
};
private:
- typedef HashSet<const LayoutBlock*> BlockSet;
+ typedef HashSet<LayoutBlock*> BlockSet;
+ typedef HashSet<const LayoutBlock*> ConstBlockSet;
enum HasEnoughTextToAutosize {
UnknownAmountOfText,
@@ -154,7 +156,7 @@ class CORE_EXPORT TextAutosizer final
m_hasEnoughTextToAutosize(UnknownAmountOfText),
m_multiplier(0) {}
- const BlockSet* const m_roots;
+ const BlockSet* m_roots;
HasEnoughTextToAutosize m_hasEnoughTextToAutosize;
float m_multiplier;
};
@@ -210,8 +212,8 @@ class CORE_EXPORT TextAutosizer final
"sizeof(FingerprintSourceData) must be a multiple of UChar");
typedef unsigned Fingerprint;
- typedef HashMap<Fingerprint, std::unique_ptr<Supercluster>> SuperclusterMap;
typedef Vector<std::unique_ptr<Cluster>> ClusterStack;
+ typedef HashSet<Fingerprint> FingerprintSet;
// Fingerprints are computed during style recalc, for (some subset of)
// blocks that will become cluster roots.
@@ -219,21 +221,29 @@ class CORE_EXPORT TextAutosizer final
DISALLOW_NEW();
public:
- void add(const LayoutObject*, Fingerprint);
- void addTentativeClusterRoot(const LayoutBlock*, Fingerprint);
+ void add(LayoutObject*, Fingerprint);
+ void addTentativeClusterRoot(LayoutBlock*, Fingerprint);
// Returns true if any BlockSet was modified or freed by the removal.
- bool remove(const LayoutObject*);
+ bool remove(LayoutObject*);
Fingerprint get(const LayoutObject*);
BlockSet* getTentativeClusterRoots(Fingerprint);
+ Supercluster* getSupercluster(LayoutBlock*);
+ Supercluster* getSuperclusterByFingerprint(const Fingerprint);
bool hasFingerprints() const { return !m_fingerprints.isEmpty(); }
private:
typedef HashMap<const LayoutObject*, Fingerprint> FingerprintMap;
typedef HashMap<Fingerprint, std::unique_ptr<BlockSet>>
ReverseFingerprintMap;
+ typedef HashMap<Fingerprint, std::unique_ptr<Supercluster>> SuperclusterMap;
FingerprintMap m_fingerprints;
ReverseFingerprintMap m_blocksForFingerprint;
+ // Make superclusters across layouts.
+ // Clusters are created and destroyed during layout. The map key is the
+ // fingerprint. Clusters whose roots share the same fingerprint use the
+ // same multiplier.
+ SuperclusterMap m_superclusters;
#if ENABLE(ASSERT)
void assertMapsAreConsistent();
#endif
@@ -272,21 +282,21 @@ class CORE_EXPORT TextAutosizer final
IntSize windowSize() const;
void setAllTextNeedsLayout();
void resetMultipliers();
- BeginLayoutBehavior prepareForLayout(const LayoutBlock*);
- void prepareClusterStack(const LayoutObject*);
+ BeginLayoutBehavior prepareForLayout(LayoutBlock*);
+ void prepareClusterStack(LayoutObject*);
bool clusterHasEnoughTextToAutosize(
Cluster*,
const LayoutBlock* widthProvider = nullptr);
bool superclusterHasEnoughTextToAutosize(
Supercluster*,
- const LayoutBlock* widthProvider = nullptr);
+ const LayoutBlock* widthProvider = nullptr,
+ bool skipLayoutedNodes = false);
bool clusterWouldHaveEnoughTextToAutosize(
const LayoutBlock* root,
const LayoutBlock* widthProvider = nullptr);
- Fingerprint getFingerprint(const LayoutObject*);
+ Fingerprint getFingerprint(LayoutObject*);
Fingerprint computeFingerprint(const LayoutObject*);
- Cluster* maybeCreateCluster(const LayoutBlock*);
- Supercluster* getSupercluster(const LayoutBlock*);
+ Cluster* maybeCreateCluster(LayoutBlock*);
float clusterMultiplier(Cluster*);
float superclusterMultiplier(Cluster*);
// A cluster's width provider is typically the deepest block containing all
@@ -294,7 +304,7 @@ class CORE_EXPORT TextAutosizer final
// table itself for width.
const LayoutBlock* clusterWidthProvider(const LayoutBlock*) const;
const LayoutBlock* maxClusterWidthProvider(
- const Supercluster*,
+ Supercluster*,
const LayoutBlock* currentRoot) const;
// Typically this returns a block's computed width. In the case of tables
// layout, this width is not yet known so the fixed width is used if it's
@@ -321,22 +331,24 @@ class CORE_EXPORT TextAutosizer final
#ifdef AUTOSIZING_DOM_DEBUG_INFO
void writeClusterDebugInfo(Cluster*);
#endif
+ void checkConsistent();
+ bool isParentClusterReliable(Cluster*);
+ void needCheckConsistent(LayoutBlock*);
Member<const Document> m_document;
const LayoutBlock* m_firstBlockToBeginLayout;
#if ENABLE(ASSERT)
// Used to ensure we don't compute properties of a block before beginLayout()
// is called on it.
- BlockSet m_blocksThatHaveBegunLayout;
+ ConstBlockSet m_blocksThatHaveBegunLayout;
#endif
- // Clusters are created and destroyed during layout. The map key is the
- // cluster root. Clusters whose roots share the same fingerprint use the
- // same multiplier.
- SuperclusterMap m_superclusters;
ClusterStack m_clusterStack;
FingerprintMapper m_fingerprintMapper;
Vector<RefPtr<ComputedStyle>> m_stylesRetainedDuringLayout;
+ // This fingerprint set keeps fingerprints of supercluster needed
+ // checkconsistent().
+ FingerprintSet m_fingerprintsNeedCheckConsistent;
// FIXME: All frames should share the same m_pageInfo instance.
PageInfo m_pageInfo;
bool m_updatePageInfoDeferred;

Powered by Google App Engine
This is Rietveld 408576698