| 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..959d45a727f6c09658e1dcbbb06e4d3879e33334 100644
|
| --- a/third_party/WebKit/Source/core/layout/TextAutosizer.h
|
| +++ b/third_party/WebKit/Source/core/layout/TextAutosizer.h
|
| @@ -69,11 +69,13 @@ 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 newTextAdded(unsigned, unsigned);
|
| +
|
| DECLARE_TRACE();
|
|
|
| class LayoutScope {
|
| @@ -107,7 +109,8 @@ class CORE_EXPORT TextAutosizer final
|
| };
|
|
|
| private:
|
| - typedef HashSet<const LayoutBlock*> BlockSet;
|
| + typedef HashSet<LayoutBlock*> BlockSet;
|
| + typedef HashSet<const LayoutBlock*> ConstBlockSet;
|
|
|
| enum HasEnoughTextToAutosize {
|
| UnknownAmountOfText,
|
| @@ -152,11 +155,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;
|
| + const BlockSet* m_roots;
|
| HasEnoughTextToAutosize m_hasEnoughTextToAutosize;
|
| float m_multiplier;
|
| + unsigned m_minTextLengthToAutosize;
|
| + unsigned m_containingTextlength;
|
| + bool m_hasAddedToCheckSet;
|
| };
|
|
|
| struct Cluster {
|
| @@ -210,8 +219,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 +228,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 +289,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 +311,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 +338,23 @@ 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;
|
| #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;
|
|
|