| Index: Source/core/css/FontSize.cpp
|
| diff --git a/Source/core/css/FontSize.cpp b/Source/core/css/FontSize.cpp
|
| index 6c1b53c528205b776fb8ad2348efd357c0cf083e..4eab99cfceb2a32b96af4e0585e76751a9d23288 100644
|
| --- a/Source/core/css/FontSize.cpp
|
| +++ b/Source/core/css/FontSize.cpp
|
| @@ -120,17 +120,25 @@ static const int strictFontSizeTable[fontSizeTableMax - fontSizeTableMin + 1][to
|
| // factors for each keyword value.
|
| static const float fontSizeFactors[totalKeywords] = { 0.60f, 0.75f, 0.89f, 1.0f, 1.2f, 1.5f, 2.0f, 3.0f };
|
|
|
| -float FontSize::fontSizeForKeyword(const Document* document, int keyword, bool shouldUseFixedDefaultSize)
|
| +static int inline rowFromMediumFontSizeInRange(const Settings* settings, bool quirksMode, FixedPitchFontType fixedPitchFontType, int& mediumSize)
|
| {
|
| + mediumSize = fixedPitchFontType == FixedPitchFont ? settings->defaultFixedFontSize() : settings->defaultFontSize();
|
| + if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax)
|
| + return mediumSize - fontSizeTableMin;
|
| + return -1;
|
| +}
|
| +
|
| +float FontSize::fontSizeForKeyword(const Document* document, CSSValueID keyword, FixedPitchFontType fixedPitchFontType)
|
| +{
|
| + ASSERT(keyword >= CSSValueXxSmall && keyword <= CSSValueWebkitXxxLarge);
|
| const Settings* settings = document->settings();
|
| if (!settings)
|
| return 1.0f;
|
|
|
| bool quirksMode = document->inQuirksMode();
|
| - int mediumSize = shouldUseFixedDefaultSize ? settings->defaultFixedFontSize() : settings->defaultFontSize();
|
| - if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax) {
|
| - // Look up the entry in the table.
|
| - int row = mediumSize - fontSizeTableMin;
|
| + int mediumSize = 0;
|
| + int row = rowFromMediumFontSizeInRange(settings, quirksMode, fixedPitchFontType, mediumSize);
|
| + if (row >= 0) {
|
| int col = (keyword - CSSValueXxSmall);
|
| return quirksMode ? quirksFontSizeTable[row][col] : strictFontSizeTable[row][col];
|
| }
|
| @@ -153,18 +161,17 @@ static int findNearestLegacyFontSize(int pixelFontSize, const T* table, int mult
|
| return totalKeywords - 1;
|
| }
|
|
|
| -int FontSize::legacyFontSize(const Document* document, int pixelFontSize, bool shouldUseFixedDefaultSize)
|
| +int FontSize::legacyFontSize(const Document* document, int pixelFontSize, FixedPitchFontType fixedPitchFontType)
|
| {
|
| const Settings* settings = document->settings();
|
| if (!settings)
|
| return 1;
|
|
|
| bool quirksMode = document->inQuirksMode();
|
| - int mediumSize = shouldUseFixedDefaultSize ? settings->defaultFixedFontSize() : settings->defaultFontSize();
|
| - if (mediumSize >= fontSizeTableMin && mediumSize <= fontSizeTableMax) {
|
| - int row = mediumSize - fontSizeTableMin;
|
| + int mediumSize = 0;
|
| + int row = rowFromMediumFontSizeInRange(settings, quirksMode, fixedPitchFontType, mediumSize);
|
| + if (row >= 0)
|
| return findNearestLegacyFontSize<int>(pixelFontSize, quirksMode ? quirksFontSizeTable[row] : strictFontSizeTable[row], 1);
|
| - }
|
|
|
| return findNearestLegacyFontSize<float>(pixelFontSize, fontSizeFactors, mediumSize);
|
| }
|
|
|