Changeset 194421 in webkit


Ignore:
Timestamp:
Dec 25, 2015 9:28:15 PM (8 years ago)
Author:
Alan Bujtas
Message:

Subpixel rendering: Add subpixel support for outline.
https://bugs.webkit.org/show_bug.cgi?id=152560

Source/WebCore:

Reviewed by Simon Fraser.

This patch adds support for subpixel outline-width/outline-offset.

Test: fast/borders/hidpi-outline-hairline-painting.html

  • css/CSSPropertyNames.in:
  • page/animation/CSSPropertyAnimation.cpp:

(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/mac/GraphicsContextMac.mm:

(WebCore::GraphicsContext::drawFocusRing):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::computeMaxOutlineSize):
(WebCore::RenderElement::paintOutline):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::paintAreaElementFocusRing):

  • rendering/RenderInline.cpp:

(WebCore::RenderInline::paintOutlineForLine):

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::adjustRectForOutlineAndShadow):

  • rendering/RenderView.cpp:

(WebCore::RenderView::setMaximalOutlineSize):

  • rendering/RenderView.h:
  • rendering/style/OutlineValue.h:

(WebCore::OutlineValue::offset):
(WebCore::OutlineValue::OutlineValue): Deleted.

  • rendering/style/RenderStyle.h:

LayoutTests:

Unable to ref-test other outline types.

Reviewed by Simon Fraser.

  • fast/borders/hidpi-outline-hairline-painting-expected.html: Added.
  • fast/borders/hidpi-outline-hairline-painting.html: Added.
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r194418 r194421  
     12015-12-25  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Add subpixel support for outline.
     4        https://bugs.webkit.org/show_bug.cgi?id=152560
     5
     6        Unable to ref-test other outline types.
     7
     8        Reviewed by Simon Fraser.
     9
     10        * fast/borders/hidpi-outline-hairline-painting-expected.html: Added.
     11        * fast/borders/hidpi-outline-hairline-painting.html: Added.
     12
    1132015-12-24  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r194420 r194421  
     12015-12-25  Zalan Bujtas  <zalan@apple.com>
     2
     3        Subpixel rendering: Add subpixel support for outline.
     4        https://bugs.webkit.org/show_bug.cgi?id=152560
     5
     6        Reviewed by Simon Fraser.
     7
     8        This patch adds support for subpixel outline-width/outline-offset.
     9
     10        Test: fast/borders/hidpi-outline-hairline-painting.html
     11
     12        * css/CSSPropertyNames.in:
     13        * page/animation/CSSPropertyAnimation.cpp:
     14        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
     15        * platform/graphics/GraphicsContext.h:
     16        * platform/graphics/mac/GraphicsContextMac.mm:
     17        (WebCore::GraphicsContext::drawFocusRing):
     18        * rendering/RenderElement.cpp:
     19        (WebCore::RenderElement::computeMaxOutlineSize):
     20        (WebCore::RenderElement::paintOutline):
     21        * rendering/RenderImage.cpp:
     22        (WebCore::RenderImage::paintAreaElementFocusRing):
     23        * rendering/RenderInline.cpp:
     24        (WebCore::RenderInline::paintOutlineForLine):
     25        * rendering/RenderObject.cpp:
     26        (WebCore::RenderObject::adjustRectForOutlineAndShadow):
     27        * rendering/RenderView.cpp:
     28        (WebCore::RenderView::setMaximalOutlineSize):
     29        * rendering/RenderView.h:
     30        * rendering/style/OutlineValue.h:
     31        (WebCore::OutlineValue::offset):
     32        (WebCore::OutlineValue::OutlineValue): Deleted.
     33        * rendering/style/RenderStyle.h:
     34
    1352015-12-25  Alexey Proskuryakov  <ap@apple.com>
    236
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r192992 r194421  
    278278outline [Longhands=outline-color|outline-style|outline-width]
    279279outline-color [VisitedLinkColorSupport, Initial=invalidColor]
    280 outline-offset [Converter=ComputedLength<int>]
     280outline-offset [Converter=ComputedLength<float>]
    281281outline-style [Custom=All]
    282 outline-width [Converter=LineWidth<unsigned short>]
     282outline-width [Converter=LineWidth<float>]
    283283overflow [Longhands=overflow-x|overflow-y]
    284284overflow-wrap
  • trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp

    r193610 r194421  
    12931293        new PropertyWrapper<short>(CSSPropertyWidows, &RenderStyle::widows, &RenderStyle::setWidows),
    12941294        new LengthPropertyWrapper<Length>(CSSPropertyLineHeight, &RenderStyle::specifiedLineHeight, &RenderStyle::setLineHeight),
    1295         new PropertyWrapper<int>(CSSPropertyOutlineOffset, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset),
    1296         new PropertyWrapper<unsigned short>(CSSPropertyOutlineWidth, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth),
     1295        new PropertyWrapper<float>(CSSPropertyOutlineOffset, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset),
     1296        new PropertyWrapper<float>(CSSPropertyOutlineWidth, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth),
    12971297        new PropertyWrapper<float>(CSSPropertyLetterSpacing, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing),
    12981298        new LengthPropertyWrapper<Length>(CSSPropertyWordSpacing, &RenderStyle::wordSpacing, &RenderStyle::setWordSpacing),
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r194025 r194421  
    390390#endif
    391391
    392     void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&);
    393     void drawFocusRing(const Path&, int width, int offset, const Color&);
     392    void drawFocusRing(const Vector<IntRect>&, float width, float offset, const Color&);
     393    void drawFocusRing(const Path&, float width, float offset, const Color&);
    394394#if PLATFORM(MAC)
    395     void drawFocusRing(const Vector<IntRect>&, int width, int offset, double timeOffset, bool& needsRedraw);
     395    void drawFocusRing(const Vector<IntRect>&, float width, float offset, double timeOffset, bool& needsRedraw);
    396396#endif
    397397
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r193743 r194421  
    523523}
    524524
    525 static inline void adjustFocusRingLineWidth(int& width)
     525static inline void adjustFocusRingLineWidth(float& width)
    526526{
    527527#if PLATFORM(GTK)
     
    541541}
    542542
    543 void GraphicsContext::drawFocusRing(const Path& path, int width, int /* offset */, const Color& color)
     543void GraphicsContext::drawFocusRing(const Path& path, float width, float /* offset */, const Color& color)
    544544{
    545545    // FIXME: We should draw paths that describe a rectangle with rounded corners
     
    559559}
    560560
    561 void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int /* offset */, const Color& color)
     561void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, float width, float /* offset */, const Color& color)
    562562{
    563563    if (paintingDisabled())
  • trunk/Source/WebCore/platform/graphics/mac/GraphicsContextMac.mm

    r192712 r194421  
    7373#endif // !PLATFORM(IOS)
    7474
    75 void GraphicsContext::drawFocusRing(const Path& path, int /* width */, int /* offset */, const Color&)
     75void GraphicsContext::drawFocusRing(const Path& path, float /* width */, float /* offset */, const Color&)
    7676{
    7777#if PLATFORM(MAC)
     
    8686
    8787#if PLATFORM(MAC)
    88 void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int, int offset, double timeOffset, bool& needsRedraw)
     88void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, float, float offset, double timeOffset, bool& needsRedraw)
    8989{
    9090    if (paintingDisabled())
     
    9999#endif
    100100
    101 void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int, int offset, const Color&)
     101void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, float, float offset, const Color&)
    102102{
    103103#if !PLATFORM(IOS)
  • trunk/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp

    r192140 r194421  
    131131}
    132132
    133 void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
     133void GraphicsContext::drawFocusRing(const Path& path, float width, float offset, const Color& color)
    134134{
    135135    // FIXME: implement
     
    138138// FIXME: This is nearly identical to the GraphicsContext::drawFocusRing function in GraphicsContextMac.mm.
    139139// The code could move to GraphicsContextCG.cpp and be shared.
    140 void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
     140void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, float width, float offset, const Color& color)
    141141{
    142142    if (paintingDisabled())
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r194418 r194421  
    378378    if (!style.outlineWidth())
    379379        return;
    380     int maxOutlineSize = style.outlineSize();
     380    float maxOutlineSize = style.outlineSize();
    381381    if (style.outlineStyleIsAuto())
    382382        maxOutlineSize = std::max(theme().platformFocusRingWidth() + style.outlineOffset(), maxOutlineSize);
     
    21082108
    21092109    RenderStyle& styleToUse = style();
    2110     LayoutUnit outlineWidth = styleToUse.outlineWidth();
    2111 
    2112     int outlineOffset = styleToUse.outlineOffset();
     2110    float outlineWidth = floorToDevicePixel(styleToUse.outlineWidth(), document().deviceScaleFactor());
     2111    float outlineOffset = floorToDevicePixel(styleToUse.outlineOffset(), document().deviceScaleFactor());
    21132112
    21142113    // Only paint the focus ring by hand if the theme isn't able to draw it.
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r192140 r194421  
    517517
    518518    RenderStyle* areaElementStyle = areaElement.computedStyle();
    519     unsigned short outlineWidth = areaElementStyle->outlineWidth();
     519    float outlineWidth = areaElementStyle->outlineWidth();
    520520    if (!outlineWidth)
    521521        return;
  • trunk/Source/WebCore/rendering/RenderInline.cpp

    r194016 r194421  
    16431643{
    16441644    const RenderStyle& styleToUse = style();
    1645     int outlineWidth = styleToUse.outlineWidth();
     1645    float outlineWidth = styleToUse.outlineWidth();
    16461646    EBorderStyle outlineStyle = styleToUse.outlineStyle();
    16471647
    16481648    bool antialias = shouldAntialiasLines(graphicsContext);
    16491649
    1650     int offset = style().outlineOffset();
     1650    float offset = style().outlineOffset();
    16511651
    16521652    LayoutRect box(LayoutPoint(paintOffset.x() + thisline.x() - offset, paintOffset.y() + thisline.y() - offset),
     
    16871687            FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth,
    16881688            pixelSnappedBox.y() - outlineWidth),
    1689             FloatPoint(std::min(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())),
     1689            FloatPoint(std::min<float>(pixelSnappedBox.maxX() + outlineWidth, (lastline.isEmpty() ? 1000000 : pixelSnappedLastLine.x())),
    16901690            pixelSnappedBox.y())),
    16911691            BSTop, outlineColor, outlineStyle,
     
    16961696    if (lastline.maxX() < thisline.maxX())
    16971697        drawLineForBoxSide(graphicsContext,
    1698             FloatRect(FloatPoint(std::max(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX(), pixelSnappedBox.x() - outlineWidth),
     1698            FloatRect(FloatPoint(std::max<float>(lastline.isEmpty() ? -1000000 : pixelSnappedLastLine.maxX(), pixelSnappedBox.x() - outlineWidth),
    16991699            pixelSnappedBox.y() - outlineWidth),
    17001700            FloatPoint(pixelSnappedBox.maxX() + outlineWidth,
     
    17201720            FloatRect(FloatPoint(pixelSnappedBox.x() - outlineWidth,
    17211721            pixelSnappedBox.maxY()),
    1722             FloatPoint(std::min(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000),
     1722            FloatPoint(std::min<float>(pixelSnappedBox.maxX() + outlineWidth, !nextline.isEmpty() ? pixelSnappedNextLine.x() + 1 : 1000000),
    17231723            pixelSnappedBox.maxY() + outlineWidth)),
    17241724            BSBottom, outlineColor, outlineStyle,
     
    17291729    if (nextline.maxX() < thisline.maxX())
    17301730        drawLineForBoxSide(graphicsContext,
    1731             FloatRect(FloatPoint(std::max(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth),
     1731            FloatRect(FloatPoint(std::max<float>(!nextline.isEmpty() ? pixelSnappedNextLine.maxX() : -1000000, pixelSnappedBox.x() - outlineWidth),
    17321732            pixelSnappedBox.maxY()),
    17331733            FloatPoint(pixelSnappedBox.maxX() + outlineWidth,
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r192966 r194421  
    19441944void RenderObject::adjustRectForOutlineAndShadow(LayoutRect& rect) const
    19451945{
    1946     int outlineSize = outlineStyleForRepaint().outlineSize();
     1946    float outlineSize = outlineStyleForRepaint().outlineSize();
    19471947    if (outlineStyleForRepaint().outlineStyleIsAuto())
    19481948        outlineSize = std::max(theme().platformFocusRingWidth() + outlineStyleForRepaint().outlineOffset(), outlineSize);
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r194155 r194421  
    827827// bounds when it changes.
    828828// FIXME: This is ugly; it would be nice to have a better way to do this.
    829 void RenderView::setMaximalOutlineSize(int outlineSize)
     829void RenderView::setMaximalOutlineSize(float outlineSize)
    830830{
    831831    if (outlineSize == m_maximalOutlineSize)
  • trunk/Source/WebCore/rendering/RenderView.h

    r192966 r194421  
    9999    virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const override;
    100100
    101     void setMaximalOutlineSize(int);
    102     int maximalOutlineSize() const { return m_maximalOutlineSize; }
     101    void setMaximalOutlineSize(float);
     102    float maximalOutlineSize() const { return m_maximalOutlineSize; }
    103103
    104104    LayoutRect viewRect() const;
     
    352352
    353353    // Used to inflate compositing layers and repaint rects.
    354     int m_maximalOutlineSize { 0 };
     354    float m_maximalOutlineSize { 0 };
    355355
    356356    bool shouldUsePrintingLayout() const;
  • trunk/Source/WebCore/rendering/style/OutlineValue.h

    r111076 r194421  
    3333friend class RenderStyle;
    3434public:
    35     OutlineValue()
    36         : m_offset(0)
    37     {
    38     }
    39    
    4035    bool operator==(const OutlineValue& o) const
    4136    {
     
    4843    }
    4944   
    50     int offset() const { return m_offset; }
     45    float offset() const { return m_offset; }
    5146    OutlineIsAuto isAuto() const { return static_cast<OutlineIsAuto>(m_isAuto); }
    5247
    5348private:
    54     int m_offset;
     49    float m_offset { 0 };
    5550};
    5651
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r192389 r194421  
    675675    float borderEndWidth() const;
    676676
    677     unsigned short outlineSize() const { return std::max(0, outlineWidth() + outlineOffset()); }
    678     unsigned short outlineWidth() const
     677    float outlineSize() const { return std::max<float>(0, outlineWidth() + outlineOffset()); }
     678    float outlineWidth() const
    679679    {
    680680        if (m_background->outline().style() == BNONE)
     
    888888    // CSS3 Getter Methods
    889889
    890     int outlineOffset() const
     890    float outlineOffset() const
    891891    {
    892892        if (m_background->outline().style() == BNONE)
     
    13261326    void setBorderBottomColor(const Color& v) { SET_BORDERVALUE_COLOR(surround, border.m_bottom, v); }
    13271327
    1328     void setOutlineWidth(unsigned short v) { SET_VAR(m_background, m_outline.m_width, v); }
     1328    void setOutlineWidth(float v) { SET_VAR(m_background, m_outline.m_width, v); }
    13291329    void setOutlineStyleIsAuto(OutlineIsAuto isAuto) { SET_VAR(m_background, m_outline.m_isAuto, isAuto); }
    13301330    void setOutlineStyle(EBorderStyle v) { SET_VAR(m_background, m_outline.m_style, v); }
     
    15001500
    15011501    // CSS3 Setters
    1502     void setOutlineOffset(int v) { SET_VAR(m_background, m_outline.m_offset, v); }
     1502    void setOutlineOffset(float v) { SET_VAR(m_background, m_outline.m_offset, v); }
    15031503    void setTextShadow(std::unique_ptr<ShadowData>, bool add = false);
    15041504    void setTextStrokeColor(const Color& c) { SET_VAR(rareInheritedData, textStrokeColor, c); }
     
    19231923    static float initialBorderWidth() { return 3; }
    19241924    static unsigned short initialColumnRuleWidth() { return 3; }
    1925     static unsigned short initialOutlineWidth() { return 3; }
     1925    static float initialOutlineWidth() { return 3; }
    19261926    static float initialLetterSpacing() { return 0; }
    19271927    static Length initialWordSpacing() { return Length(Fixed); }
     
    19561956    static float initialZoom() { return 1.0f; }
    19571957    static TextZoom initialTextZoom() { return TextZoomNormal; }
    1958     static int initialOutlineOffset() { return 0; }
     1958    static float initialOutlineOffset() { return 0; }
    19591959    static float initialOpacity() { return 1.0f; }
    19601960    static EBoxAlignment initialBoxAlign() { return BSTRETCH; }
Note: See TracChangeset for help on using the changeset viewer.