Chromium Code Reviews| 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..bc71d1768bd0e7d7e78362cc3a8b5fe7a3652274 100644 |
| --- a/third_party/WebKit/Source/core/layout/TextAutosizer.h |
| +++ b/third_party/WebKit/Source/core/layout/TextAutosizer.h |
| @@ -74,6 +74,8 @@ class CORE_EXPORT TextAutosizer final |
| bool pageNeedsAutosizing() const; |
| + void textAutosizingNewTextAdded(unsigned, unsigned); |
|
skobes
2016/11/09 03:11:39
"textAutosizing" is redundant here, just call it n
cathiechentx
2016/11/09 12:58:46
Done.
|
| + |
| DECLARE_TRACE(); |
| class LayoutScope { |
| @@ -152,11 +154,17 @@ class CORE_EXPORT TextAutosizer final |
| explicit Supercluster(const BlockSet* roots) |
| : m_roots(roots), |
| m_hasEnoughTextToAutosize(UnknownAmountOfText), |
| - m_multiplier(0) {} |
| + m_multiplier(0), |
| + m_minTextLengthToAutosize(0), |
| + m_containingTextlength(0), |
| + m_hasAddedToCheckSet(false) {} |
| const BlockSet* const m_roots; |
| HasEnoughTextToAutosize m_hasEnoughTextToAutosize; |
| float m_multiplier; |
| + unsigned m_minTextLengthToAutosize; |
| + unsigned m_containingTextlength; |
| + bool m_hasAddedToCheckSet; |
| }; |
| struct Cluster { |
| @@ -210,8 +218,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. |
| @@ -225,15 +233,23 @@ class CORE_EXPORT TextAutosizer final |
| bool remove(const LayoutObject*); |
| Fingerprint get(const LayoutObject*); |
| BlockSet* getTentativeClusterRoots(Fingerprint); |
| + Supercluster* getSupercluster(const 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 |
| + // cluster root. Clusters whose roots share the same fingerprint use the |
|
skobes
2016/11/09 03:11:39
It looks like the map key is now the Fingerprint.
cathiechentx
2016/11/09 12:58:46
Done.
|
| + // same multiplier. |
| + SuperclusterMap m_superclusters; |
| #if ENABLE(ASSERT) |
| void assertMapsAreConsistent(); |
| #endif |
| @@ -279,14 +295,14 @@ class CORE_EXPORT TextAutosizer final |
| 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 computeFingerprint(const LayoutObject*); |
| Cluster* maybeCreateCluster(const LayoutBlock*); |
| - Supercluster* getSupercluster(const LayoutBlock*); |
| float clusterMultiplier(Cluster*); |
| float superclusterMultiplier(Cluster*); |
| // A cluster's width provider is typically the deepest block containing all |
| @@ -294,7 +310,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,6 +337,8 @@ class CORE_EXPORT TextAutosizer final |
| #ifdef AUTOSIZING_DOM_DEBUG_INFO |
| void writeClusterDebugInfo(Cluster*); |
| #endif |
| + void checkConsistent(); |
| + bool isParentClusterReliable(Cluster*); |
| Member<const Document> m_document; |
| const LayoutBlock* m_firstBlockToBeginLayout; |
| @@ -330,13 +348,12 @@ class CORE_EXPORT TextAutosizer final |
| BlockSet 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; |