| OLD | NEW |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 = settings->minimumFontSize(); | 61 int minSize = 0; |
| 62 int minLogicalSize = settings->minimumLogicalFontSize(); | 62 int minLogicalSize = 0; |
| 63 float zoomedSize = specifiedSize * zoomFactor; | 63 float zoomedSize = specifiedSize * zoomFactor; |
| 64 | 64 |
| 65 // Apply the hard minimum first. We only apply the hard minimum if after zoo
ming we're still too small. | 65 // Apply the hard minimum first. We only apply the hard minimum if after zoo
ming we're still too small. |
| 66 if (zoomedSize < minSize) | 66 if (zoomedSize < minSize) |
| 67 zoomedSize = minSize; | 67 zoomedSize = minSize; |
| 68 | 68 |
| 69 // Now apply the "smart minimum." This minimum is also only applied if we're
still too small | 69 // 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 | 70 // 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 | 71 // 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. | 72 // doing so won't disrupt the layout. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 return 1.0f; | 119 return 1.0f; |
| 120 | 120 |
| 121 int mediumSize = 0; | 121 int mediumSize = 0; |
| 122 int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumS
ize); | 122 int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumS
ize); |
| 123 if (row >= 0) { | 123 if (row >= 0) { |
| 124 int col = (keyword - CSSValueXxSmall); | 124 int col = (keyword - CSSValueXxSmall); |
| 125 return strictFontSizeTable[row][col]; | 125 return strictFontSizeTable[row][col]; |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Value is outside the range of the table. Apply the scale factor instead. | 128 // Value is outside the range of the table. Apply the scale factor instead. |
| 129 float minLogicalSize = std::max(settings->minimumLogicalFontSize(), 1); | 129 float minLogicalSize = 1; |
| 130 return std::max(fontSizeFactors[keyword - CSSValueXxSmall] * mediumSize, min
LogicalSize); | 130 return std::max(fontSizeFactors[keyword - CSSValueXxSmall] * mediumSize, min
LogicalSize); |
| 131 } | 131 } |
| 132 | 132 |
| 133 | 133 |
| 134 | 134 |
| 135 template<typename T> | 135 template<typename T> |
| 136 static int findNearestLegacyFontSize(int pixelFontSize, const T* table, int mult
iplier) | 136 static int findNearestLegacyFontSize(int pixelFontSize, const T* table, int mult
iplier) |
| 137 { | 137 { |
| 138 // Ignore table[0] because xx-small does not correspond to any legacy font s
ize. | 138 // Ignore table[0] because xx-small does not correspond to any legacy font s
ize. |
| 139 for (int i = 1; i < totalKeywords - 1; i++) { | 139 for (int i = 1; i < totalKeywords - 1; i++) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 151 | 151 |
| 152 int mediumSize = 0; | 152 int mediumSize = 0; |
| 153 int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumS
ize); | 153 int row = rowFromMediumFontSizeInRange(settings, fixedPitchFontType, mediumS
ize); |
| 154 if (row >= 0) | 154 if (row >= 0) |
| 155 return findNearestLegacyFontSize<int>(pixelFontSize, strictFontSizeTable
[row], 1); | 155 return findNearestLegacyFontSize<int>(pixelFontSize, strictFontSizeTable
[row], 1); |
| 156 | 156 |
| 157 return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, medi
umSize); | 157 return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, medi
umSize); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace blink | 160 } // namespace blink |
| OLD | NEW |