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

Side by Side Diff: sky/engine/core/css/FontSize.cpp

Issue 711203002: Remove zoom() and effectiveZoom(). (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « sky/engine/core/css/FontSize.h ('k') | sky/engine/core/css/resolver/AnimatedStyleBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 17 matching lines...) Expand all
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/css/FontSize.h" 30 #include "core/css/FontSize.h"
31 31
32 #include "core/CSSValueKeywords.h" 32 #include "core/CSSValueKeywords.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/frame/Settings.h" 34 #include "core/frame/Settings.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 float FontSize::getComputedSizeFromSpecifiedSize(const Document* document, float zoomFactor, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize useSmartMinimumForFontSize) 38 float FontSize::getComputedSizeFromSpecifiedSize(const Document* document, bool isAbsoluteSize, float specifiedSize, ESmartMinimumForFontSize useSmartMinimumFor FontSize)
39 { 39 {
40 // Text with a 0px font size should not be visible and therefore needs to be 40 // Text with a 0px font size should not be visible and therefore needs to be
41 // exempt from minimum font size rules. Acid3 relies on this for pixel-perfe ct 41 // exempt from minimum font size rules. Acid3 relies on this for pixel-perfe ct
42 // rendering. This is also compatible with other browsers that have minimum 42 // rendering. This is also compatible with other browsers that have minimum
43 // font size settings (e.g. Firefox). 43 // font size settings (e.g. Firefox).
44 if (fabsf(specifiedSize) < std::numeric_limits<float>::epsilon()) 44 if (fabsf(specifiedSize) < std::numeric_limits<float>::epsilon())
45 return 0.0f; 45 return 0.0f;
46 46
47 // We support two types of minimum font size. The first is a hard override t hat applies to 47 // We support two types of minimum font size. The first is a hard override t hat applies to
48 // all fonts. This is "minSize." The second type of minimum font size is a " smart minimum" 48 // all fonts. This is "minSize." The second type of minimum font size is a " smart minimum"
49 // that is applied only when the Web page can't know what size it really ask ed for, e.g., 49 // that is applied only when the Web page can't know what size it really ask ed for, e.g.,
50 // when it uses logical sizes like "small" or expresses the font-size as a p ercentage of 50 // when it uses logical sizes like "small" or expresses the font-size as a p ercentage of
51 // the user's default font setting. 51 // the user's default font setting.
52 52
53 // With the smart minimum, we never want to get smaller than the minimum fon t size to keep fonts readable. 53 // With the smart minimum, we never want to get smaller than the minimum fon t size to keep fonts readable.
54 // However we always allow the page to set an explicit pixel size that is sm aller, 54 // However we always allow the page to set an explicit pixel size that is sm aller,
55 // since sites will mis-render otherwise (e.g., http://www.gamespot.com with a 9px minimum). 55 // since sites will mis-render otherwise (e.g., http://www.gamespot.com with a 9px minimum).
56 56
57 Settings* settings = document->settings(); 57 Settings* settings = document->settings();
58 if (!settings) 58 if (!settings)
59 return 1.0f; 59 return 1.0f;
60 60
61 int minSize = 0; 61 int minSize = 0;
62 int minLogicalSize = 0; 62 int minLogicalSize = 0;
63 float zoomedSize = specifiedSize * zoomFactor;
64 63
65 // Apply the hard minimum first. We only apply the hard minimum if after zoo ming we're still too small. 64 // Apply the hard minimum first. We only apply the hard minimum if after zoo ming we're still too small.
66 if (zoomedSize < minSize) 65 if (specifiedSize < minSize)
67 zoomedSize = minSize; 66 specifiedSize = minSize;
68 67
69 // Now apply the "smart minimum." This minimum is also only applied if we're still too small 68 // Now apply the "smart minimum." This minimum is also only applied if we're still too small
70 // after zooming. The font size must either be relative to the user default or the original size 69 // after zooming. The font size must either be relative to the user default or the original size
71 // must have been acceptable. In other words, we only apply the smart minimu m whenever we're positive 70 // must have been acceptable. In other words, we only apply the smart minimu m whenever we're positive
72 // doing so won't disrupt the layout. 71 // doing so won't disrupt the layout.
73 if (useSmartMinimumForFontSize && zoomedSize < minLogicalSize && (specifiedS ize >= minLogicalSize || !isAbsoluteSize)) 72 if (useSmartMinimumForFontSize && specifiedSize < minLogicalSize && (specifi edSize >= minLogicalSize || !isAbsoluteSize))
74 zoomedSize = minLogicalSize; 73 specifiedSize = minLogicalSize;
75 74
76 // Also clamp to a reasonable maximum to prevent insane font sizes from caus ing crashes on various 75 // Also clamp to a reasonable maximum to prevent insane font sizes from caus ing crashes on various
77 // platforms (I'm looking at you, Windows.) 76 // platforms (I'm looking at you, Windows.)
78 return std::min(maximumAllowedFontSize, zoomedSize); 77 return std::min(maximumAllowedFontSize, specifiedSize);
79 } 78 }
80 79
81 const int fontSizeTableMax = 16; 80 const int fontSizeTableMax = 16;
82 const int fontSizeTableMin = 9; 81 const int fontSizeTableMin = 9;
83 const int totalKeywords = 8; 82 const int totalKeywords = 8;
84 83
85 // Strict mode table matches MacIE and Mozilla's settings exactly. 84 // Strict mode table matches MacIE and Mozilla's settings exactly.
86 static const int strictFontSizeTable[fontSizeTableMax - fontSizeTableMin + 1][to talKeywords] = 85 static const int strictFontSizeTable[fontSizeTableMax - fontSizeTableMin + 1][to talKeywords] =
87 { 86 {
88 { 9, 9, 9, 9, 11, 14, 18, 27 }, 87 { 9, 9, 9, 9, 11, 14, 18, 27 },
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 150
152 int mediumSize = 0; 151 int mediumSize = 0;
153 int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumS ize); 152 int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumS ize);
154 if (row >= 0) 153 if (row >= 0)
155 return findNearestLegacyFontSize<int>(pixelFontSize, strictFontSizeTable [row], 1); 154 return findNearestLegacyFontSize<int>(pixelFontSize, strictFontSizeTable [row], 1);
156 155
157 return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, medi umSize); 156 return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, medi umSize);
158 } 157 }
159 158
160 } // namespace blink 159 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/FontSize.h ('k') | sky/engine/core/css/resolver/AnimatedStyleBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698