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

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: 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
Index: Source/core/rendering/FastTextAutosizer.cpp
diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp
index bf82866dd4c6c5918ce90c9c94da296b1b6b6c7e..c1e46c40be4fbd87bce4defdbb78f07036925fc1 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,17 @@ void FastTextAutosizer::prepareWindowInfo(RenderView* renderView)
IntSize layoutSize = m_document->page()->mainFrame()->view()->layoutSize();
m_layoutWidth = horizontalWritingMode ? layoutSize.width() : layoutSize.height();
+
+ // Compute an additional multiplier based on device and accessibility settings.
+ m_additionalMultiplier = 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_additionalMultiplier *= m_document->settings()->deviceScaleAdjustment();
+
+#ifndef NDEBUG
+ m_renderViewInfoPrepared = true;
+#endif
}
bool FastTextAutosizer::shouldBeClusterRoot(RenderBlock* block)
@@ -213,12 +227,15 @@ 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, (float) m_layoutWidth) / m_windowWidth;
skobes 2014/01/13 19:10:13 I should have used static_cast<float> here, do you
pdr. 2014/01/13 19:49:12 Done.
+ return max(m_additionalMultiplier * multiplier, 1.0f);
}
void FastTextAutosizer::applyMultiplier(RenderObject* renderer, float multiplier)
« Source/core/rendering/FastTextAutosizer.h ('K') | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698