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

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

Issue 135733002: [FastTextAutosizer] Incorporate accessibility and device scale factors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update after reviewer comments Created 6 years, 11 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') | no next file » | 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 bf82866dd4c6c5918ce90c9c94da296b1b6b6c7e..94afe2061edc83d08c33ac53df3c42fda5761c6a 100644
--- a/Source/core/rendering/FastTextAutosizer.cpp
+++ b/Source/core/rendering/FastTextAutosizer.cpp
@@ -47,6 +47,9 @@ namespace WebCore {
FastTextAutosizer::FastTextAutosizer(Document* document)
: m_document(document)
+#ifndef NDEBUG
+ , m_renderViewInfoPrepared(false)
+#endif
{
}
@@ -76,7 +79,7 @@ void FastTextAutosizer::beginLayout(RenderBlock* block)
return;
if (block->isRenderView())
- prepareWindowInfo(toRenderView(block));
+ prepareRenderViewInfo(toRenderView(block));
if (shouldBeClusterRoot(block))
m_clusterStack.append(getOrCreateCluster(block));
@@ -118,7 +121,7 @@ bool FastTextAutosizer::enabled()
&& m_document->page();
}
-void FastTextAutosizer::prepareWindowInfo(RenderView* renderView)
+void FastTextAutosizer::prepareRenderViewInfo(RenderView* renderView)
{
bool horizontalWritingMode = isHorizontalWritingMode(renderView->style()->writingMode());
@@ -130,6 +133,16 @@ void FastTextAutosizer::prepareWindowInfo(RenderView* renderView)
IntSize layoutSize = m_document->page()->mainFrame()->view()->layoutSize();
m_layoutWidth = horizontalWritingMode ? layoutSize.width() : layoutSize.height();
+
+ // Compute the base font scale multiplier based on device and accessibility settings.
+ m_baseMultiplier = m_document->settings()->accessibilityFontScaleFactor();
+ // If the page has a meta viewport or @viewport, don't apply the device scale adjustment.
+ const ViewportDescription& viewportDescription = m_document->page()->mainFrame()->document()->viewportDescription();
+ if (!viewportDescription.isSpecifiedByAuthor())
+ m_baseMultiplier *= m_document->settings()->deviceScaleAdjustment();
+#ifndef NDEBUG
+ m_renderViewInfoPrepared = true;
+#endif
}
bool FastTextAutosizer::shouldBeClusterRoot(RenderBlock* block)
@@ -213,12 +226,14 @@ RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks)
float FastTextAutosizer::computeMultiplier(RenderBlock* block)
{
+#ifndef NDEBUG
+ ASSERT(m_renderViewInfoPrepared);
+#endif
// Block width, in CSS pixels.
float blockWidth = block->contentLogicalWidth();
- // FIXME(crbug.com/333124): incorporate font scale factor.
- // FIXME(crbug.com/333124): incorporate device scale adjustment.
- return max(min(blockWidth, (float) m_layoutWidth) / m_windowWidth, 1.0f);
+ float multiplier = min(blockWidth, static_cast<float>(m_layoutWidth)) / m_windowWidth;
+ return max(m_baseMultiplier * multiplier, 1.0f);
}
void FastTextAutosizer::applyMultiplier(RenderObject* renderer, float multiplier)
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698