Commit 58ca670d authored by skobes@chromium.org's avatar skobes@chromium.org

Make cluster creation independent of fingerprinting. Keep track of current

cluster during layout without walking up the tree.

BUG=302005

Review URL: https://codereview.chromium.org/101543009

git-svn-id: svn://svn.chromium.org/blink/trunk@164800 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d8e32d0b
......@@ -848,6 +848,31 @@ crbug.com/322782 virtual/fasttextautosizing/fast/text-autosizing/oscillation-jav
crbug.com/322782 virtual/fasttextautosizing/fast/text-autosizing/wide-child.html [ ImageOnlyFailure ]
crbug.com/322782 virtual/fasttextautosizing/fast/text-autosizing/wide-in-narrow-overflow-scroll.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/cluster-with-narrow-lca-and-cluster.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/cluster-with-narrow-lca.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-and-overflow-hidden-ancestor.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-height-ancestor.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-maxheight-ancestor.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-maxheight.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-percent-maxheight.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-percent-of-viewport-maxheight.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/constrained-within-overflow-ancestor.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/form-controls-autosizing-button-input-elements.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/form-controls-autosizing-checkbox-input-element.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/form-controls-autosizing-radio-input-element.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/form-controls-autosizing-select-element.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/form-controls-autosizing-textfield-input-elements.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/hackernews-comments.html [ NeedsRebaseline ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/header-li-links-autosizing.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/header-links-autosizing-different-fontsize.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/header-links-autosizing.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/nested-em-line-height.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/positioned-out-of-flow.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/resize-window.html [ Failure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/span-child.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/unwrappable-blocks.html [ ImageOnlyFailure ]
crbug.com/302005 virtual/fasttextautosizing/fast/text-autosizing/unwrappable-inlines.html [ ImageOnlyFailure ]
# FIXME(crbug.com/329904): Remove these when hash-based autosizer is deemed fast enough, aka second pass optimization.
crbug.com/329904 fast/text-autosizing/forum-comments-autosizing.html [ ImageOnlyFailure ]
......
......@@ -866,9 +866,6 @@ void FrameView::performPreLayoutTasks()
// the layout beats any sort of style recalc update that needs to occur.
TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleUpdate, true);
document->updateStyleIfNeeded();
if (FastTextAutosizer* textAutosizer = document->fastTextAutosizer())
textAutosizer->prepareForLayout();
}
void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLayout)
......
......@@ -58,51 +58,68 @@ public:
return adoptPtr(new FastTextAutosizer(document));
}
void prepareForLayout();
void record(RenderBlock*);
void destroy(RenderBlock*);
void beginLayout(RenderBlock*);
void inflate(RenderBlock*);
void endLayout(RenderBlock*);
private:
// FIXME(crbug.com/327811): make a proper API for this class.
struct Cluster {
explicit Cluster(AtomicString fingerprint)
: m_fingerprint(fingerprint)
, m_multiplier(0)
explicit Cluster(RenderBlock* root, float multiplier)
: m_root(root)
, m_multiplier(multiplier)
{
}
AtomicString m_fingerprint;
WTF::HashSet<RenderBlock*> m_blocks;
RenderBlock* m_root;
float m_multiplier;
const RenderObject* m_clusterRoot;
void addBlock(RenderBlock* block)
{
m_blocks.add(block);
setNeedsClusterRecalc();
}
};
void setNeedsClusterRecalc() { m_multiplier = 0; m_clusterRoot = 0; }
bool needsClusterRecalc() const { return !m_clusterRoot || m_multiplier <= 0; }
typedef WTF::HashSet<RenderBlock*> BlockSet;
typedef WTF::HashMap<RenderBlock*, OwnPtr<Cluster> > ClusterMap;
typedef WTF::Vector<Cluster*> ClusterStack;
// Fingerprints are computed during style recalc, for (some subset of)
// blocks that will become cluster roots.
class FingerprintMapper {
public:
void add(RenderBlock*, AtomicString);
void remove(RenderBlock*);
AtomicString get(RenderBlock*);
BlockSet& getBlocks(AtomicString);
private:
typedef WTF::HashMap<RenderBlock*, AtomicString> FingerprintMap;
typedef WTF::HashMap<AtomicString, OwnPtr<BlockSet> > ReverseFingerprintMap;
FingerprintMap m_fingerprints;
ReverseFingerprintMap m_blocksForFingerprint;
};
explicit FastTextAutosizer(Document*);
bool updateWindowWidth();
AtomicString fingerprint(const RenderBlock*);
void recalcClusterIfNeeded(Cluster*);
int m_windowWidth;
bool enabled();
void prepareWindowInfo(RenderView*);
bool shouldBeClusterRoot(RenderBlock*);
bool clusterWantsAutosizing(RenderBlock*);
AtomicString computeFingerprint(RenderBlock*);
Cluster* getOrCreateCluster(RenderBlock*);
Cluster* createCluster(RenderBlock*);
Cluster* addSupercluster(AtomicString, RenderBlock*);
RenderBlock* deepestCommonAncestor(BlockSet&);
float computeMultiplier(RenderBlock*);
void applyMultiplier(RenderObject*, float);
Document* m_document;
typedef WTF::HashMap<const RenderBlock*, Cluster*> BlockToClusterMap;
typedef WTF::HashMap<AtomicString, OwnPtr<Cluster> > FingerprintToClusterMap;
BlockToClusterMap m_clusterForBlock;
FingerprintToClusterMap m_clusterForFingerprint;
int m_windowWidth; // Frame width in density-independent pixels (DIPs).
int m_layoutWidth; // Layout width in CSS pixels.
// 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.
ClusterMap m_clusters;
ClusterStack m_clusterStack;
FingerprintMapper m_fingerprintMapper;
};
} // namespace WebCore
......
......@@ -33,6 +33,7 @@
#include "core/accessibility/AXObjectCache.h"
#include "core/frame/FrameView.h"
#include "core/rendering/FastTextAutosizer.h"
#include "core/rendering/HitTestLocation.h"
#include "core/rendering/LayoutRectRecorder.h"
#include "core/rendering/LayoutRepainter.h"
......@@ -302,6 +303,10 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
LayoutUnit previousHeight = logicalHeight();
setLogicalHeight(beforeEdge);
FastTextAutosizer* textAutosizer = document().fastTextAutosizer();
if (textAutosizer)
textAutosizer->beginLayout(this);
m_repaintLogicalTop = 0;
m_repaintLogicalBottom = 0;
LayoutUnit maxFloatLogicalBottom = 0;
......@@ -312,6 +317,9 @@ void RenderBlockFlow::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalH
else
layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom, layoutScope, beforeEdge, afterEdge);
if (textAutosizer)
textAutosizer->endLayout(this);
if (frameView()->partialLayout().isStopping()) {
statePusher.pop();
return;
......
......@@ -525,6 +525,7 @@ bool TextAutosizer::isIndependentDescendant(const RenderBlock* renderer)
// from the box's parent (we want to avoid having significantly different
// width blocks within a cluster, since the narrower blocks would end up
// larger than would otherwise be necessary).
RenderBlock* containingBlock = renderer->containingBlock();
return renderer->isRenderView()
|| renderer->isFloating()
|| renderer->isOutOfFlowPositioned()
......@@ -532,7 +533,7 @@ bool TextAutosizer::isIndependentDescendant(const RenderBlock* renderer)
|| renderer->isTableCaption()
|| renderer->isFlexibleBoxIncludingDeprecated()
|| renderer->hasColumns()
|| renderer->containingBlock()->isHorizontalWritingMode() != renderer->isHorizontalWritingMode()
|| (containingBlock && containingBlock->isHorizontalWritingMode() != renderer->isHorizontalWritingMode())
|| renderer->style()->isDisplayReplacedType()
|| renderer->isTextArea()
|| renderer->style()->userModify() != READ_ONLY;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment