diff options
| author | mmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | 2014-01-08 22:22:50 +0000 |
|---|---|---|
| committer | Julien Brianceau <jbriance@cisco.com> | 2014-06-23 15:29:39 +0200 |
| commit | cfd683d676c2d0b8645725065628f120d3ef27aa (patch) | |
| tree | 5fee767126e3d760dce981a0d2fe3830076e0bd9 /Source | |
| parent | 907ef525390e28dd2524b918e9cb7a0e64e9ee3a (diff) | |
| download | qtwebkit-cfd683d676c2d0b8645725065628f120d3ef27aa.tar.gz | |
A fractional value of the css letter-spacing property is not rendered as expected
https://bugs.webkit.org/show_bug.cgi?id=20606
Reviewed by Simon Fraser.
Source/WebCore:
This turns on fractional letter-spacing and word-spacing CSS values.
It is taken mostly from Blink r153727 and iOS. Updating the relevant
types is all that is necessary
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* platform/graphics/Font.cpp:
(WebCore::Font::Font):
(WebCore::Font::width):
* platform/graphics/Font.h:
(WebCore::Font::wordSpacing):
(WebCore::Font::letterSpacing):
(WebCore::Font::setWordSpacing):
(WebCore::Font::setLetterSpacing):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::wordSpacing):
(WebCore::RenderStyle::letterSpacing):
(WebCore::RenderStyle::setWordSpacing):
(WebCore::RenderStyle::setLetterSpacing):
* rendering/style/RenderStyle.h:
Change-Id: I49cedbf555426f3fae3fe58ec4eb25569d358997
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161521 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/WebCore/css/DeprecatedStyleBuilder.cpp | 4 | ||||
| -rw-r--r-- | Source/WebCore/page/animation/CSSPropertyAnimation.cpp | 4 | ||||
| -rw-r--r-- | Source/WebCore/platform/graphics/Font.cpp | 4 | ||||
| -rw-r--r-- | Source/WebCore/platform/graphics/Font.h | 14 | ||||
| -rw-r--r-- | Source/WebCore/rendering/style/RenderStyle.cpp | 8 | ||||
| -rw-r--r-- | Source/WebCore/rendering/style/RenderStyle.h | 11 |
6 files changed, 23 insertions, 22 deletions
diff --git a/Source/WebCore/css/DeprecatedStyleBuilder.cpp b/Source/WebCore/css/DeprecatedStyleBuilder.cpp index 03900b088..68bb3bcb7 100644 --- a/Source/WebCore/css/DeprecatedStyleBuilder.cpp +++ b/Source/WebCore/css/DeprecatedStyleBuilder.cpp @@ -2152,7 +2152,7 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder() setPropertyHandler(CSSPropertyImageResolution, ApplyPropertyImageResolution::createHandler()); #endif setPropertyHandler(CSSPropertyLeft, ApplyPropertyLength<&RenderStyle::left, &RenderStyle::setLeft, &RenderStyle::initialOffset, AutoEnabled>::createHandler()); - setPropertyHandler(CSSPropertyLetterSpacing, ApplyPropertyComputeLength<int, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler()); + setPropertyHandler(CSSPropertyLetterSpacing, ApplyPropertyComputeLength<float, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler()); setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler()); setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler()); setPropertyHandler(CSSPropertyListStylePosition, ApplyPropertyDefault<EListStylePosition, &RenderStyle::listStylePosition, EListStylePosition, &RenderStyle::setListStylePosition, EListStylePosition, &RenderStyle::initialListStylePosition>::createHandler()); @@ -2357,7 +2357,7 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder() setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler()); setPropertyHandler(CSSPropertyWidth, ApplyPropertyLength<&RenderStyle::width, &RenderStyle::setWidth, &RenderStyle::initialSize, AutoEnabled, LegacyIntrinsicEnabled, IntrinsicEnabled, NoneDisabled, UndefinedDisabled>::createHandler()); setPropertyHandler(CSSPropertyWordBreak, ApplyPropertyDefault<EWordBreak, &RenderStyle::wordBreak, EWordBreak, &RenderStyle::setWordBreak, EWordBreak, &RenderStyle::initialWordBreak>::createHandler()); - setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyComputeLength<int, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialLetterWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler()); + setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyComputeLength<float, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing, &RenderStyle::initialWordSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler()); // UAs must treat 'word-wrap' as an alternate name for the 'overflow-wrap' property. So using the same handlers. setPropertyHandler(CSSPropertyWordWrap, ApplyPropertyDefault<EOverflowWrap, &RenderStyle::overflowWrap, EOverflowWrap, &RenderStyle::setOverflowWrap, EOverflowWrap, &RenderStyle::initialOverflowWrap>::createHandler()); setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler()); diff --git a/Source/WebCore/page/animation/CSSPropertyAnimation.cpp b/Source/WebCore/page/animation/CSSPropertyAnimation.cpp index fca626f80..a3d8ef8c8 100644 --- a/Source/WebCore/page/animation/CSSPropertyAnimation.cpp +++ b/Source/WebCore/page/animation/CSSPropertyAnimation.cpp @@ -1129,8 +1129,8 @@ void CSSPropertyAnimation::ensurePropertyMap() gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyLineHeight, &RenderStyle::specifiedLineHeight, &RenderStyle::setLineHeight)); gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyOutlineOffset, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset)); gPropertyWrappers->append(new PropertyWrapper<unsigned short>(CSSPropertyOutlineWidth, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth)); - gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyLetterSpacing, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing)); - gPropertyWrappers->append(new PropertyWrapper<int>(CSSPropertyWordSpacing, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing)); + gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyLetterSpacing, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing)); + gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWordSpacing, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing)); gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyTextIndent, &RenderStyle::textIndent, &RenderStyle::setTextIndent)); gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitPerspective, &RenderStyle::perspective, &RenderStyle::setPerspective)); diff --git a/Source/WebCore/platform/graphics/Font.cpp b/Source/WebCore/platform/graphics/Font.cpp index c3cca6ee9..f58bcc843 100644 --- a/Source/WebCore/platform/graphics/Font.cpp +++ b/Source/WebCore/platform/graphics/Font.cpp @@ -77,7 +77,7 @@ Font::Font() { } -Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing) +Font::Font(const FontDescription& fd, float letterSpacing, float wordSpacing) : m_fontDescription(fd) , m_letterSpacing(letterSpacing) , m_wordSpacing(wordSpacing) @@ -297,7 +297,7 @@ float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo } bool hasKerningOrLigatures = typesettingFeatures() & (Kerning | Ligatures); - bool hasWordSpacingOrLetterSpacing = wordSpacing() | letterSpacing(); + bool hasWordSpacingOrLetterSpacing = wordSpacing() || letterSpacing(); float* cacheEntry = m_glyphs->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow); if (cacheEntry && !std::isnan(*cacheEntry)) return *cacheEntry; diff --git a/Source/WebCore/platform/graphics/Font.h b/Source/WebCore/platform/graphics/Font.h index 28d49b66a..08e0ad49a 100644 --- a/Source/WebCore/platform/graphics/Font.h +++ b/Source/WebCore/platform/graphics/Font.h @@ -85,7 +85,7 @@ struct GlyphOverflow { class Font { public: Font(); - Font(const FontDescription&, short letterSpacing, short wordSpacing); + Font(const FontDescription&, float letterSpacing, float wordSpacing); // This constructor is only used if the platform wants to start with a native font. Font(const FontPlatformData&, bool isPrinting, FontSmoothingMode = AutoSmoothing); ~Font(); @@ -119,10 +119,10 @@ public: bool isSmallCaps() const { return m_fontDescription.smallCaps(); } - short wordSpacing() const { return m_wordSpacing; } - short letterSpacing() const { return m_letterSpacing; } - void setWordSpacing(short s) { m_wordSpacing = s; } - void setLetterSpacing(short s) { m_letterSpacing = s; } + float wordSpacing() const { return m_wordSpacing; } + float letterSpacing() const { return m_letterSpacing; } + void setWordSpacing(float s) { m_wordSpacing = s; } + void setLetterSpacing(float s) { m_letterSpacing = s; } bool isFixedPitch() const; bool isPrinterFont() const { return m_fontDescription.usePrinterFont(); } @@ -307,8 +307,8 @@ private: FontDescription m_fontDescription; mutable RefPtr<FontGlyphs> m_glyphs; - short m_letterSpacing; - short m_wordSpacing; + float m_letterSpacing; + float m_wordSpacing; bool m_needsTranscoding; mutable unsigned m_typesettingFeatures : 2; // (TypesettingFeatures) Caches values computed from m_fontDescription. }; diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp index 3e5590c09..2d0bb3b90 100644 --- a/Source/WebCore/rendering/style/RenderStyle.cpp +++ b/Source/WebCore/rendering/style/RenderStyle.cpp @@ -1328,8 +1328,8 @@ float RenderStyle::specifiedFontSize() const { return fontDescription().specifie float RenderStyle::computedFontSize() const { return fontDescription().computedSize(); } int RenderStyle::fontSize() const { return inherited->font.pixelSize(); } -int RenderStyle::wordSpacing() const { return inherited->font.wordSpacing(); } -int RenderStyle::letterSpacing() const { return inherited->font.letterSpacing(); } +float RenderStyle::wordSpacing() const { return inherited->font.wordSpacing(); } +float RenderStyle::letterSpacing() const { return inherited->font.letterSpacing(); } bool RenderStyle::setFontDescription(const FontDescription& v) { @@ -1374,8 +1374,8 @@ int RenderStyle::computedLineHeight(RenderView* renderView) const return lh.value(); } -void RenderStyle::setWordSpacing(int v) { inherited.access()->font.setWordSpacing(v); } -void RenderStyle::setLetterSpacing(int v) { inherited.access()->font.setLetterSpacing(v); } +void RenderStyle::setWordSpacing(float v) { inherited.access()->font.setWordSpacing(v); } +void RenderStyle::setLetterSpacing(float v) { inherited.access()->font.setLetterSpacing(v); } void RenderStyle::setFontSize(float size) { diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h index 6a60d7a8a..289c36b49 100644 --- a/Source/WebCore/rendering/style/RenderStyle.h +++ b/Source/WebCore/rendering/style/RenderStyle.h @@ -579,8 +579,8 @@ public: #else TextDecorationStyle textDecorationStyle() const { return TextDecorationStyleSolid; } #endif // CSS3_TEXT - int wordSpacing() const; - int letterSpacing() const; + float wordSpacing() const; + float letterSpacing() const; float zoom() const { return visual->m_zoom; } float effectiveZoom() const { return rareInheritedData->m_effectiveZoom; } @@ -1167,8 +1167,8 @@ public: void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; } - void setWordSpacing(int); - void setLetterSpacing(int); + void setWordSpacing(float); + void setLetterSpacing(float); void clearBackgroundLayers() { m_background.access()->m_background = FillLayer(BackgroundFillLayer); } void inheritBackgroundLayers(const FillLayer& parent) { m_background.access()->m_background = parent; } @@ -1607,7 +1607,8 @@ public: static unsigned initialBorderWidth() { return 3; } static unsigned short initialColumnRuleWidth() { return 3; } static unsigned short initialOutlineWidth() { return 3; } - static int initialLetterWordSpacing() { return 0; } + static float initialLetterSpacing() { return 0; } + static float initialWordSpacing() { return 0; } static Length initialSize() { return Length(); } static Length initialMinSize() { return Length(Fixed); } static Length initialMaxSize() { return Length(Undefined); } |
