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

Unified Diff: Source/core/rendering/FastTextAutosizer.cpp

Issue 180743004: Disable FTA when max multiplier is 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months 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
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/FastTextAutosizer.cpp
diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp
index 7d9c5172dc9c58b62cd208684b087fa016f9e9ae..c8db110d20b0ed7514dfefe6a1618077b31d535a 100644
--- a/Source/core/rendering/FastTextAutosizer.cpp
+++ b/Source/core/rendering/FastTextAutosizer.cpp
@@ -63,6 +63,7 @@ FastTextAutosizer::FastTextAutosizer(const Document* document)
, m_frameWidth(0)
, m_layoutWidth(0)
, m_baseMultiplier(0)
+ , m_maxMultiplier(0)
, m_firstBlock(0)
#ifndef NDEBUG
, m_renderViewInfoPrepared(false)
@@ -121,7 +122,6 @@ void FastTextAutosizer::beginLayout(RenderBlock* block)
#endif
if (!m_firstBlock) {
- prepareRenderViewInfo();
prepareClusterStack(block->parent());
m_firstBlock = block;
pdr. 2014/02/28 22:13:33 Can we move m_firstBlock = block above prepareClus
skobes 2014/03/01 01:45:38 Done, but prepareClusterStack doesn't call isInLay
} else if (block == currentCluster()->m_root) {
@@ -140,6 +140,11 @@ void FastTextAutosizer::beginLayout(RenderBlock* block)
inflate(block);
}
+bool FastTextAutosizer::isInLayout() const
+{
+ return !!m_firstBlock;
+}
+
void FastTextAutosizer::inflateListItem(RenderListItem* listItem, RenderListMarker* listItemMarker)
{
if (!enabled())
@@ -229,14 +234,29 @@ void FastTextAutosizer::inflate(RenderBlock* block)
bool FastTextAutosizer::enabled()
{
- if (!m_document->settings() || !m_document->page() || m_document->printing())
+ if (!m_document->settings()
+ || !m_document->page()
+ || m_document->printing()
+ || !m_document->settings()->textAutosizingEnabled())
return false;
- return m_document->settings()->textAutosizingEnabled();
+ if (!m_maxMultiplier)
+ updateRenderViewInfo();
+
+ if (m_maxMultiplier == 1.0f)
+ return false;
+
+ return true;
}
-void FastTextAutosizer::prepareRenderViewInfo()
+void FastTextAutosizer::updateRenderViewInfo()
{
+ if (!m_document->settings()
+ || !m_document->page()
+ || m_document->printing()
+ || !m_document->settings()->textAutosizingEnabled())
+ return;
+
RenderView* renderView = toRenderView(m_document->renderer());
bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()->writingMode());
@@ -257,6 +277,9 @@ void FastTextAutosizer::prepareRenderViewInfo()
float deviceScaleAdjustment = m_document->settings()->deviceScaleAdjustment();
m_baseMultiplier *= deviceScaleAdjustment;
}
+ m_maxMultiplier = m_frameWidth ? max(m_baseMultiplier *
pdr. 2014/02/28 22:13:33 m_maxMultiplier is never actually used as a float.
skobes 2014/03/01 01:45:38 Replaced with an enum.
+ (static_cast<float>(m_layoutWidth) / m_frameWidth), 1.0f) : 1.0f;
+
#ifndef NDEBUG
m_renderViewInfoPrepared = true;
#endif
@@ -518,7 +541,7 @@ float FastTextAutosizer::multiplierFromBlock(const RenderBlock* block)
// Block width, in CSS pixels.
float blockWidth = widthFromBlock(block);
- float multiplier = min(blockWidth, static_cast<float>(m_layoutWidth)) / m_frameWidth;
+ float multiplier = m_frameWidth ? min(blockWidth, static_cast<float>(m_layoutWidth)) / m_frameWidth : 1.0f;
return max(m_baseMultiplier * multiplier, 1.0f);
}
@@ -703,4 +726,25 @@ RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO
return current->nextInPreOrderAfterChildren(stayWithin);
}
+FastTextAutosizer::LayoutScope::LayoutScope(RenderBlock* block)
+ : m_textAutosizer(block->document().fastTextAutosizer())
+ , m_block(block)
+{
+ if (m_textAutosizer) {
+ if (!m_textAutosizer->isInLayout())
+ m_textAutosizer->updateRenderViewInfo();
+
+ if (m_textAutosizer->enabled())
+ m_textAutosizer->beginLayout(m_block);
+ else
+ m_textAutosizer = 0;
+ }
+}
+
+FastTextAutosizer::LayoutScope::~LayoutScope()
+{
+ if (m_textAutosizer)
+ m_textAutosizer->endLayout(m_block);
+}
+
} // namespace WebCore
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | Source/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698