https://bugs.webkit.org/show_bug.cgi?id=76033
Reviewed by Darin Adler.
Source/WebCore:
Tests: fast/text/font-kerning-expected.html
fast/text/font-kerning.html
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added code to handle
font-kerning.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Ditto.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added mapping from FontDescription::Kerning.
(WebCore::CSSPrimitiveValue::operator FontDescription::Kerning): Added mapping to
FontDescription::Kerning.
* css/CSSProperty.cpp:
(WebCore::CSSProperty::isInheritedProperty): Added font-kerning to the set of inherited
properties.
* css/CSSPropertyNames.in: Added -webkit-font-kerning.
* css/CSSStyleApplyProperty.cpp:
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): Added a handler for font-kerning.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyDeclaration): Updated for the number of properties that
affect the font.
* platform/graphics/Font.h:
(WebCore::Font::typesettingFeatures): Changed to enable kerning if font-kerning is set to
normal, disable it if font-kerning is set to none, and leave it to the default (determined
by the text-rendering property) if font-kerning is set to auto.
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::FontDescription): Added a Kerning enum.
(WebCore::FontDescription::kerning): Added this getter.
(WebCore::FontDescription::setKerning): Added this setter.
(WebCore::FontDescription::operator==): Updated to compare the m_kerning member.
LayoutTests:
* fast/css/getComputedStyle/computed-style-expected.txt:
* fast/text/font-kerning-expected.html: Added.
* fast/text/font-kerning.html: Added.
* platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* platform/chromium-win/svg/css/getComputedStyle-basic-expected.txt:
* platform/gtk/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* platform/qt/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* svg/css/getComputedStyle-basic-expected.txt:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104678
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-11 Dan Bernstein <mitz@apple.com>
+
+ <rdar://problem/10674686> Implement the font-kerning CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=76033
+
+ Reviewed by Darin Adler.
+
+ * fast/css/getComputedStyle/computed-style-expected.txt:
+ * fast/text/font-kerning-expected.html: Added.
+ * fast/text/font-kerning.html: Added.
+ * platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+ * platform/chromium-win/svg/css/getComputedStyle-basic-expected.txt:
+ * platform/gtk/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+ * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+ * platform/qt/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+ * svg/css/getComputedStyle-basic-expected.txt:
+
2012-01-10 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r104263 and r104381.
-webkit-flex-direction: row;
-webkit-flex-flow: row nowrap;
-webkit-flex-wrap: nowrap;
+-webkit-font-kerning: auto;
-webkit-font-smoothing: auto;
-webkit-highlight: none;
-webkit-hyphenate-character: auto;
--- /dev/null
+<style>
+ .kerned { text-rendering: optimizelegibility; }
+</style>
+<body style="font-size: 36px;">
+ <div>AVAVAVAV</div>
+ <div>AVAVAVAV</div>
+ <div class="kerned">AVAVAVAV</div>
+ <div>AVAVAVAV</div>
+ <div class="kerned">AVAVAVAV</div>
+ <div class="kerned">AVAVAVAV</div>
+</body>
--- /dev/null
+<style>
+ .kerning-none { -webkit-font-kerning: none; }
+ .kerning-auto { -webkit-font-kerning: auto; }
+ .kerning-normal { -webkit-font-kerning: normal; }
+</style>
+<body style="font-size: 36px;">
+ <div>
+ <div class="kerning-none">AVAVAVAV</div>
+ <div class="kerning-auto">AVAVAVAV</div>
+ <div class="kerning-normal">AVAVAVAV</div>
+ </div>
+ <div style="text-rendering: optimizelegibility">
+ <div class="kerning-none">AVAVAVAV</div>
+ <div class="kerning-auto">AVAVAVAV</div>
+ <div class="kerning-normal">AVAVAVAV</div>
+ </div>
+</body>
-webkit-flex-direction: row
-webkit-flex-flow: row nowrap
-webkit-flex-wrap: nowrap
+ -webkit-font-kerning: auto
-webkit-font-smoothing: auto
-webkit-highlight: none
-webkit-hyphenate-character: auto
rect: style.getPropertyCSSValue(-webkit-flex-flow) : [object CSSValueList]
rect: style.getPropertyValue(-webkit-flex-wrap) : nowrap
rect: style.getPropertyCSSValue(-webkit-flex-wrap) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-font-kerning) : auto
+rect: style.getPropertyCSSValue(-webkit-font-kerning) : [object CSSPrimitiveValue]
rect: style.getPropertyValue(-webkit-font-smoothing) : auto
rect: style.getPropertyCSSValue(-webkit-font-smoothing) : [object CSSPrimitiveValue]
rect: style.getPropertyValue(-webkit-highlight) : none
g: style.getPropertyCSSValue(-webkit-flex-flow) : [object CSSValueList]
g: style.getPropertyValue(-webkit-flex-wrap) : nowrap
g: style.getPropertyCSSValue(-webkit-flex-wrap) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-font-kerning) : auto
+g: style.getPropertyCSSValue(-webkit-font-kerning) : [object CSSPrimitiveValue]
g: style.getPropertyValue(-webkit-font-smoothing) : auto
g: style.getPropertyCSSValue(-webkit-font-smoothing) : [object CSSPrimitiveValue]
g: style.getPropertyValue(-webkit-highlight) : none
-webkit-flex-direction: row
-webkit-flex-flow: row nowrap
-webkit-flex-wrap: nowrap
+ -webkit-font-kerning: auto
-webkit-font-smoothing: auto
-webkit-highlight: none
-webkit-hyphenate-character: auto
-webkit-flex-direction: row
-webkit-flex-flow: row nowrap
-webkit-flex-wrap: nowrap
+ -webkit-font-kerning: auto
-webkit-font-smoothing: auto
-webkit-highlight: none
-webkit-hyphenate-character: auto
-webkit-flex-direction: row
-webkit-flex-flow: row nowrap
-webkit-flex-wrap: nowrap
+ -webkit-font-kerning: auto
-webkit-font-smoothing: auto
-webkit-highlight: none
-webkit-hyphenate-character: auto
+2012-01-11 Dan Bernstein <mitz@apple.com>
+
+ <rdar://problem/10674686> Implement the font-kerning CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=76033
+
+ Reviewed by Darin Adler.
+
+ Tests: fast/text/font-kerning-expected.html
+ fast/text/font-kerning.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added code to handle
+ font-kerning.
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseValue): Ditto.
+ * css/CSSPrimitiveValueMappings.h:
+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added mapping from FontDescription::Kerning.
+ (WebCore::CSSPrimitiveValue::operator FontDescription::Kerning): Added mapping to
+ FontDescription::Kerning.
+ * css/CSSProperty.cpp:
+ (WebCore::CSSProperty::isInheritedProperty): Added font-kerning to the set of inherited
+ properties.
+ * css/CSSPropertyNames.in: Added -webkit-font-kerning.
+ * css/CSSStyleApplyProperty.cpp:
+ (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): Added a handler for font-kerning.
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::applyDeclaration): Updated for the number of properties that
+ affect the font.
+ * platform/graphics/Font.h:
+ (WebCore::Font::typesettingFeatures): Changed to enable kerning if font-kerning is set to
+ normal, disable it if font-kerning is set to none, and leave it to the default (determined
+ by the text-rendering property) if font-kerning is set to auto.
+ * platform/graphics/FontDescription.h:
+ (WebCore::FontDescription::FontDescription): Added a Kerning enum.
+ (WebCore::FontDescription::kerning): Added this getter.
+ (WebCore::FontDescription::setKerning): Added this setter.
+ (WebCore::FontDescription::operator==): Updated to compare the m_kerning member.
+
2012-01-10 Ryosuke Niwa <rniwa@webkit.org>
Build fix. Forgot to revert Node.h.
CSSPropertyWebkitFlexDirection,
CSSPropertyWebkitFlexFlow,
CSSPropertyWebkitFlexWrap,
+ CSSPropertyWebkitFontKerning,
CSSPropertyWebkitFontSmoothing,
#if ENABLE(CSS_GRID_LAYOUT)
CSSPropertyWebkitGridColumns,
return cssValuePool->createValue(style->matchNearestMailBlockquoteColor());
case CSSPropertyResize:
return cssValuePool->createValue(style->resize());
+ case CSSPropertyWebkitFontKerning:
+ return cssValuePool->createValue(style->fontDescription().kerning());
case CSSPropertyWebkitFontSmoothing:
return cssValuePool->createValue(style->fontDescription().fontSmoothing());
case CSSPropertyZIndex:
return parseFontFeatureSettings(important);
break;
+ case CSSPropertyWebkitFontKerning:
+ if (id == CSSValueAuto || id == CSSValueNormal || id == CSSValueNone)
+ validPrimitive = true;
+ break;
+
case CSSPropertyWebkitWrapShapeInside:
case CSSPropertyWebkitWrapShapeOutside:
if (id == CSSValueAuto)
}
}
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontDescription::Kerning kerning)
+ : CSSValue(PrimitiveClass)
+{
+ m_primitiveUnitType = CSS_IDENT;
+ switch (kerning) {
+ case FontDescription::AutoKerning:
+ m_value.ident = CSSValueAuto;
+ return;
+ case FontDescription::NormalKerning:
+ m_value.ident = CSSValueNormal;
+ return;
+ case FontDescription::NoneKerning:
+ m_value.ident = CSSValueNone;
+ return;
+ }
+
+ ASSERT_NOT_REACHED();
+ m_value.ident = CSSValueAuto;
+}
+
+template<> inline CSSPrimitiveValue::operator FontDescription::Kerning() const
+{
+ switch (m_value.ident) {
+ case CSSValueAuto:
+ return FontDescription::AutoKerning;
+ case CSSValueNormal:
+ return FontDescription::NormalKerning;
+ case CSSValueNone:
+ return FontDescription::NoneKerning;
+ }
+
+ ASSERT_NOT_REACHED();
+ return FontDescription::AutoKerning;
+}
+
template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmoothingMode smoothing)
: CSSValue(PrimitiveClass)
{
case CSSPropertyWebkitBoxDirection:
case CSSPropertyWebkitColorCorrection:
case CSSPropertyWebkitFontFeatureSettings:
+ case CSSPropertyWebkitFontKerning:
case CSSPropertyWebkitFontSmoothing:
case CSSPropertyWebkitLocale:
case CSSPropertyWebkitHighlight:
font-weight
text-rendering
-webkit-font-feature-settings
+-webkit-font-kerning
-webkit-font-smoothing
-webkit-locale
-webkit-text-orientation
setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
+ setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont<FontDescription::Kerning, &FontDescription::kerning, &FontDescription::setKerning, FontDescription::AutoKerning>::createHandler());
setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
setPropertyHandler(CSSPropertyWebkitTextOrientation, ApplyPropertyFont<TextOrientation, &FontDescription::textOrientation, &FontDescription::setTextOrientation, TextOrientationVerticalRight>::createHandler());
setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
int property = current.id();
if (applyFirst) {
COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property);
- COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 16, CSS_zoom_is_end_of_first_prop_range);
+ COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 17, CSS_zoom_is_end_of_first_prop_range);
COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom);
// give special priority to font-xxx, color properties, etc
if (property > CSSPropertyLineHeight)
TypesettingFeatures typesettingFeatures() const
{
TextRenderingMode textRenderingMode = m_fontDescription.textRenderingMode();
- return textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? Kerning | Ligatures : 0;
+ TypesettingFeatures features = textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? Kerning | Ligatures : 0;
+
+ switch (m_fontDescription.kerning()) {
+ case FontDescription::NoneKerning:
+ features &= ~Kerning;
+ break;
+ case FontDescription::NormalKerning:
+ features |= Kerning;
+ break;
+ case FontDescription::AutoKerning:
+ break;
+ }
+
+ return features;
}
FontFamily& firstFamily() { return m_fontDescription.firstFamily(); }
enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFamily,
MonospaceFamily, CursiveFamily, FantasyFamily, PictographFamily };
+ enum Kerning { AutoKerning, NormalKerning, NoneKerning };
+
FontDescription()
: m_specifiedSize(0)
, m_computedSize(0)
, m_genericFamily(NoFamily)
, m_usePrinterFont(false)
, m_renderingMode(NormalRenderingMode)
+ , m_kerning(AutoKerning)
, m_keywordSize(0)
, m_fontSmoothing(AutoSmoothing)
, m_textRendering(AutoTextRendering)
// only use fixed default size when there is only one font family, and that family is "monospace"
bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && !family().next() && family().family() == monospaceFamily; }
FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
+ Kerning kerning() const { return static_cast<Kerning>(m_kerning); }
unsigned keywordSize() const { return m_keywordSize; }
FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMode>(m_fontSmoothing); }
TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); }
void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
#endif
void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
+ void setKerning(Kerning kerning) { m_kerning = kerning; }
void setKeywordSize(unsigned s) { m_keywordSize = s; }
void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; }
void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; }
bool m_usePrinterFont : 1;
unsigned m_renderingMode : 1; // Used to switch between CG and GDI text on Windows.
+ unsigned m_kerning : 2; // Kerning
unsigned m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium). If so,
// then we can accurately translate across different generic families to adjust for different preference settings
&& m_genericFamily == other.m_genericFamily
&& m_usePrinterFont == other.m_usePrinterFont
&& m_renderingMode == other.m_renderingMode
+ && m_kerning == other.m_kerning
&& m_keywordSize == other.m_keywordSize
&& m_fontSmoothing == other.m_fontSmoothing
&& m_textRendering == other.m_textRendering