blob: 29c4a3fae5b4e99b0f1cc3fd6a449a418e769183 [file] [log] [blame]
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef FontSizeFunctions_h
#define FontSizeFunctions_h
#include "core/CSSValueKeywords.h"
#include "platform/wtf/Allocator.h"
namespace blink {
class Document;
enum ApplyMinimumFontSize {
kDoNotApplyMinimumForFontSize,
kApplyMinimumForFontSize
};
class FontSizeFunctions {
STATIC_ONLY(FontSizeFunctions);
public:
static float GetComputedSizeFromSpecifiedSize(
const Document*,
float zoom_factor,
bool is_absolute_size,
float specified_size,
ApplyMinimumFontSize = kApplyMinimumForFontSize);
// Given a CSS keyword in the range (xx-small to -webkit-xxx-large), this
// function returns
// values from '1' to '8'.
static unsigned KeywordSize(CSSValueID value_id) {
DCHECK(IsValidValueID(value_id));
return value_id - CSSValueXxSmall + 1;
}
static bool IsValidValueID(CSSValueID value_id) {
return value_id >= CSSValueXxSmall && value_id <= CSSValueWebkitXxxLarge;
}
static CSSValueID InitialValueID() { return CSSValueMedium; }
static unsigned InitialKeywordSize() { return KeywordSize(InitialValueID()); }
// Given a keyword size in the range (1 to 8), this function will return
// the correct font size scaled relative to the user's default (4).
static float FontSizeForKeyword(const Document*,
unsigned keyword,
bool is_monospace);
// Given a font size in pixel, this function will return legacy font size
// between 1 and 7.
static int LegacyFontSize(const Document*,
int pixel_font_size,
bool is_monospace);
};
} // namespace blink
#endif // FontSizeFunctions_h