Changeset 214787 in webkit


Ignore:
Timestamp:
Apr 3, 2017 6:17:11 AM (7 years ago)
Author:
pvollan@apple.com
Message:

Implement stroke-miterlimit.
https://bugs.webkit.org/show_bug.cgi?id=169078

Reviewed by Dean Jackson.

Source/WebCore:

Support stroke-miterlimit for text rendering, see https://drafts.fxtf.org/paint/.

Tests: fast/css/stroke-miterlimit-default.html

fast/css/stroke-miterlimit-large.html
fast/css/stroke-miterlimit-zero.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/CSSProperties.json:
  • css/SVGCSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::svgPropertyValue):

  • rendering/TextPaintStyle.cpp:

(WebCore::computeTextPaintStyle):
(WebCore::updateGraphicsContext):

  • rendering/TextPaintStyle.h:
  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::diff):

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::strokeMiterLimit):
(WebCore::RenderStyle::setStrokeMiterLimit):
(WebCore::RenderStyle::initialStrokeMiterLimit):
(WebCore::RenderStyle::setStrokeDashOffset):

  • rendering/style/RenderStyleConstants.cpp:
  • rendering/style/RenderStyleConstants.h:
  • rendering/style/SVGRenderStyle.cpp:

(WebCore::SVGRenderStyle::diff):

  • rendering/style/SVGRenderStyle.h:

(WebCore::SVGRenderStyle::initialStrokeDashArray):
(WebCore::SVGRenderStyle::strokeDashArray):
(WebCore::SVGRenderStyle::initialStrokeMiterLimit): Deleted.
(WebCore::SVGRenderStyle::strokeMiterLimit): Deleted.
(WebCore::SVGRenderStyle::setStrokeMiterLimit): Deleted.

  • rendering/style/SVGRenderStyleDefs.cpp:

(WebCore::StyleStrokeData::StyleStrokeData):
(WebCore::StyleStrokeData::operator==):

  • rendering/style/SVGRenderStyleDefs.h:
  • rendering/style/StyleRareInheritedData.cpp:

(WebCore::StyleRareInheritedData::StyleRareInheritedData):
(WebCore::StyleRareInheritedData::operator==):

  • rendering/style/StyleRareInheritedData.h:
  • rendering/svg/RenderSVGShape.cpp:

(WebCore::RenderSVGShape::hasSmoothStroke):

  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::SVGRenderSupport::applyStrokeStyleToContext):

  • rendering/svg/SVGRenderTreeAsText.cpp:

(WebCore::writeStyle):

LayoutTests:

  • fast/css/stroke-miterlimit-default-expected.html: Added.
  • fast/css/stroke-miterlimit-default.html: Added.
  • fast/css/stroke-miterlimit-large-expected-mismatch.html: Added.
  • fast/css/stroke-miterlimit-large.html: Added.
  • fast/css/stroke-miterlimit-zero-expected-mismatch.html: Added.
  • fast/css/stroke-miterlimit-zero.html: Added.
Location:
trunk
Files:
6 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214731 r214787  
     12017-04-03  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Implement stroke-miterlimit.
     4        https://bugs.webkit.org/show_bug.cgi?id=169078
     5
     6        Reviewed by Dean Jackson.
     7
     8        * fast/css/stroke-miterlimit-default-expected.html: Added.
     9        * fast/css/stroke-miterlimit-default.html: Added.
     10        * fast/css/stroke-miterlimit-large-expected-mismatch.html: Added.
     11        * fast/css/stroke-miterlimit-large.html: Added.
     12        * fast/css/stroke-miterlimit-zero-expected-mismatch.html: Added.
     13        * fast/css/stroke-miterlimit-zero.html: Added.
     14
    1152017-04-02  Alexey Proskuryakov  <ap@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r214772 r214787  
     12017-04-03  Per Arne Vollan  <pvollan@apple.com>
     2
     3        Implement stroke-miterlimit.
     4        https://bugs.webkit.org/show_bug.cgi?id=169078
     5
     6        Reviewed by Dean Jackson.
     7
     8        Support stroke-miterlimit for text rendering, see https://drafts.fxtf.org/paint/.
     9
     10        Tests: fast/css/stroke-miterlimit-default.html
     11               fast/css/stroke-miterlimit-large.html
     12               fast/css/stroke-miterlimit-zero.html
     13
     14        * css/CSSComputedStyleDeclaration.cpp:
     15        (WebCore::ComputedStyleExtractor::propertyValue):
     16        * css/CSSProperties.json:
     17        * css/SVGCSSComputedStyleDeclaration.cpp:
     18        (WebCore::ComputedStyleExtractor::svgPropertyValue):
     19        * rendering/TextPaintStyle.cpp:
     20        (WebCore::computeTextPaintStyle):
     21        (WebCore::updateGraphicsContext):
     22        * rendering/TextPaintStyle.h:
     23        * rendering/style/RenderStyle.cpp:
     24        (WebCore::RenderStyle::diff):
     25        * rendering/style/RenderStyle.h:
     26        (WebCore::RenderStyle::strokeMiterLimit):
     27        (WebCore::RenderStyle::setStrokeMiterLimit):
     28        (WebCore::RenderStyle::initialStrokeMiterLimit):
     29        (WebCore::RenderStyle::setStrokeDashOffset):
     30        * rendering/style/RenderStyleConstants.cpp:
     31        * rendering/style/RenderStyleConstants.h:
     32        * rendering/style/SVGRenderStyle.cpp:
     33        (WebCore::SVGRenderStyle::diff):
     34        * rendering/style/SVGRenderStyle.h:
     35        (WebCore::SVGRenderStyle::initialStrokeDashArray):
     36        (WebCore::SVGRenderStyle::strokeDashArray):
     37        (WebCore::SVGRenderStyle::initialStrokeMiterLimit): Deleted.
     38        (WebCore::SVGRenderStyle::strokeMiterLimit): Deleted.
     39        (WebCore::SVGRenderStyle::setStrokeMiterLimit): Deleted.
     40        * rendering/style/SVGRenderStyleDefs.cpp:
     41        (WebCore::StyleStrokeData::StyleStrokeData):
     42        (WebCore::StyleStrokeData::operator==):
     43        * rendering/style/SVGRenderStyleDefs.h:
     44        * rendering/style/StyleRareInheritedData.cpp:
     45        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     46        (WebCore::StyleRareInheritedData::operator==):
     47        * rendering/style/StyleRareInheritedData.h:
     48        * rendering/svg/RenderSVGShape.cpp:
     49        (WebCore::RenderSVGShape::hasSmoothStroke):
     50        * rendering/svg/SVGRenderSupport.cpp:
     51        (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
     52        * rendering/svg/SVGRenderTreeAsText.cpp:
     53        (WebCore::writeStyle):
     54
    1552017-04-03  Alejandro G. Castro  <alex@igalia.com>
    256
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r214624 r214787  
    39183918        case CSSPropertyStrokeWidth:
    39193919            return zoomAdjustedPixelValueForLength(style->strokeWidth(), *style);
     3920        case CSSPropertyStrokeMiterlimit:
     3921            return CSSPrimitiveValue::create(style->strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER);
    39203922
    39213923        /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
     
    40194021        case CSSPropertyStroke:
    40204022        case CSSPropertyStrokeDasharray:
    4021         case CSSPropertyStrokeMiterlimit:
    40224023        case CSSPropertyStrokeOpacity:
    40234024        case CSSPropertyAlignmentBaseline:
  • trunk/Source/WebCore/css/CSSProperties.json

    r214364 r214787  
    30243024            "codegen-properties": {
    30253025                "name-for-methods": "StrokeMiterLimit",
    3026                 "converter": "Number<float>",
    3027                 "svg": true
     3026                "converter": "Number<float>"
    30283027            },
    30293028            "specification": {
  • trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp

    r212562 r214787  
    114114        case CSSPropertyShapeRendering:
    115115            return CSSPrimitiveValue::create(svgStyle.shapeRendering());
    116         case CSSPropertyStrokeMiterlimit:
    117             return CSSPrimitiveValue::create(svgStyle.strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER);
    118116        case CSSPropertyStrokeOpacity:
    119117            return CSSPrimitiveValue::create(svgStyle.strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER);
  • trunk/Source/WebCore/rendering/TextPaintStyle.cpp

    r213634 r214787  
    7373    paintStyle.lineJoin = lineStyle.joinStyle();
    7474    paintStyle.lineCap = lineStyle.capStyle();
     75    paintStyle.miterLimit = lineStyle.strokeMiterLimit();
    7576   
    7677    if (paintInfo.forceTextColor()) {
     
    201202        context.setLineJoin(paintStyle.lineJoin);
    202203        context.setLineCap(paintStyle.lineCap);
    203     }
    204 }
    205 
    206 }
     204        if (paintStyle.lineJoin == MiterJoin)
     205            context.setMiterLimit(paintStyle.miterLimit);
     206    }
     207}
     208
     209}
  • trunk/Source/WebCore/rendering/TextPaintStyle.h

    r213614 r214787  
    5353    LineJoin lineJoin { MiterJoin };
    5454    LineCap lineCap { ButtCap };
     55    float miterLimit { defaultMiterLimit };
    5556};
    5657
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r214435 r214787  
    643643        if (textStrokeWidth() != other.textStrokeWidth())
    644644            return true;
     645       
     646        // These properties affect the cached stroke bounding box rects.
     647        if (m_rareInheritedData->capStyle != other.m_rareInheritedData->capStyle
     648            || m_rareInheritedData->joinStyle != other.m_rareInheritedData->joinStyle
     649            || m_rareInheritedData->strokeWidth != other.m_rareInheritedData->strokeWidth
     650            || m_rareInheritedData->miterLimit != other.m_rareInheritedData->miterLimit)
     651            return true;
    645652    }
    646653
     
    910917            return svgChange;
    911918    }
    912 
    913     // These properties affect the cached stroke bounding box rects.
    914     if (m_rareInheritedData->capStyle != other.m_rareInheritedData->capStyle
    915         || m_rareInheritedData->joinStyle != other.m_rareInheritedData->joinStyle
    916         || m_rareInheritedData->strokeWidth != other.m_rareInheritedData->strokeWidth)
    917         return StyleDifferenceLayout;
    918919
    919920    if (changeRequiresLayout(other, changedContextSensitiveProperties))
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r214435 r214787  
    12461246#endif
    12471247
    1248     // Support for paint-order, stroke-linecap, and stroke-linejoin from https://drafts.fxtf.org/paint/.
     1248    // Support for paint-order, stroke-linecap, stroke-linejoin, and stroke-miterlimit from https://drafts.fxtf.org/paint/.
    12491249    void setPaintOrder(PaintOrder order) { SET_VAR(m_rareInheritedData, paintOrder, static_cast<unsigned>(order)); }
    12501250    PaintOrder paintOrder() const { return static_cast<PaintOrder>(m_rareInheritedData->paintOrder); }
     
    12691269    bool hasPositiveStrokeWidth() const;
    12701270   
    1271    
     1271    float strokeMiterLimit() const { return m_rareInheritedData->miterLimit; }
     1272    void setStrokeMiterLimit(float f) { SET_VAR(m_rareInheritedData, miterLimit, f); }
     1273    static float initialStrokeMiterLimit() { return defaultMiterLimit; }
     1274
     1275
    12721276    const SVGRenderStyle& svgStyle() const { return m_svgStyle; }
    12731277    SVGRenderStyle& accessSVGStyle() { return m_svgStyle.access(); }
     
    12881292    const Length& strokeDashOffset() const { return svgStyle().strokeDashOffset(); }
    12891293    void setStrokeDashOffset(Length&& d) { accessSVGStyle().setStrokeDashOffset(WTFMove(d)); }
    1290     float strokeMiterLimit() const { return svgStyle().strokeMiterLimit(); }
    1291     void setStrokeMiterLimit(float f) { accessSVGStyle().setStrokeMiterLimit(f); }
    12921294
    12931295    const Length& cx() const { return svgStyle().cx(); }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.cpp

    r196960 r214787  
    102102}
    103103
     104const float defaultMiterLimit = 4;
     105
    104106} // namespace WebCore
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r212808 r214787  
    744744};
    745745
     746extern const float defaultMiterLimit;
     747
    746748} // namespace WebCore
  • trunk/Source/WebCore/rendering/style/SVGRenderStyle.cpp

    r212562 r214787  
    189189            || m_strokeData->paintColor != other.m_strokeData->paintColor
    190190            || m_strokeData->paintUri != other.m_strokeData->paintUri
    191             || m_strokeData->miterLimit != other.m_strokeData->miterLimit
    192191            || m_strokeData->dashArray != other.m_strokeData->dashArray
    193192            || m_strokeData->dashOffset != other.m_strokeData->dashOffset
  • trunk/Source/WebCore/rendering/style/SVGRenderStyle.h

    r212562 r214787  
    7272    static String initialStrokePaintUri() { return String(); }
    7373    static Vector<SVGLengthValue> initialStrokeDashArray() { return { }; }
    74     static float initialStrokeMiterLimit() { return 4; }
    7574    static float initialStopOpacity() { return 1; }
    7675    static Color initialStopColor() { return Color(0, 0, 0); }
     
    117116
    118117    void setStrokeDashArray(const Vector<SVGLengthValue>&);
    119     void setStrokeMiterLimit(float);
    120118    void setStrokeDashOffset(const Length&);
    121119    void setKerning(const SVGLengthValue&);
     
    162160    const String& strokePaintUri() const { return m_strokeData->paintUri; }
    163161    Vector<SVGLengthValue> strokeDashArray() const { return m_strokeData->dashArray; }
    164     float strokeMiterLimit() const { return m_strokeData->miterLimit; }
    165162    const Length& strokeDashOffset() const { return m_strokeData->dashOffset; }
    166163    SVGLengthValue kerning() const { return m_textData->kerning; }
     
    375372}
    376373
    377 inline void SVGRenderStyle::setStrokeMiterLimit(float limit)
    378 {
    379     if (!(m_strokeData->miterLimit == limit))
    380         m_strokeData.access().miterLimit = limit;
    381 }
    382 
    383374inline void SVGRenderStyle::setStrokeDashOffset(const Length& offset)
    384375{
  • trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp

    r212562 r214787  
    7777StyleStrokeData::StyleStrokeData()
    7878    : opacity(SVGRenderStyle::initialStrokeOpacity())
    79     , miterLimit(SVGRenderStyle::initialStrokeMiterLimit())
    8079    , dashOffset(RenderStyle::initialZeroLength())
    8180    , dashArray(SVGRenderStyle::initialStrokeDashArray())
     
    9291    : RefCounted<StyleStrokeData>()
    9392    , opacity(other.opacity)
    94     , miterLimit(other.miterLimit)
    9593    , dashOffset(other.dashOffset)
    9694    , dashArray(other.dashArray)
     
    112110{
    113111    return opacity == other.opacity
    114         && miterLimit == other.miterLimit
    115112        && dashOffset == other.dashOffset
    116113        && dashArray == other.dashArray
  • trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h

    r212808 r214787  
    138138
    139139        float opacity;
    140         float miterLimit;
    141140
    142141        Length dashOffset;
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp

    r213634 r214787  
    131131    , hasSetStrokeWidth(false)
    132132    , strokeWidth(RenderStyle::initialOneLength())
     133    , miterLimit(RenderStyle::initialStrokeMiterLimit())
    133134    , hyphenationLimitBefore(-1)
    134135    , hyphenationLimitAfter(-1)
     
    218219    , hasSetStrokeWidth(o.hasSetStrokeWidth)
    219220    , strokeWidth(o.strokeWidth)
     221    , miterLimit(o.miterLimit)
    220222    , hyphenationString(o.hyphenationString)
    221223    , hyphenationLimitBefore(o.hyphenationLimitBefore)
     
    329331        && hasSetStrokeWidth == o.hasSetStrokeWidth
    330332        && strokeWidth == o.strokeWidth
     333        && miterLimit == o.miterLimit
    331334        && customProperties == o.customProperties
    332335        && arePointingToEqualData(listStyleImage, o.listStyleImage);
  • trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h

    r213634 r214787  
    142142    unsigned hasSetStrokeWidth : 1;
    143143    Length strokeWidth;   
     144    float miterLimit;
    144145
    145146    AtomicString hyphenationString;
  • trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp

    r212808 r214787  
    446446    const SVGRenderStyle& svgStyle = style().svgStyle();
    447447    return svgStyle.strokeDashArray().isEmpty()
    448         && svgStyle.strokeMiterLimit() == svgStyle.initialStrokeMiterLimit()
     448        && style().strokeMiterLimit() == style().initialStrokeMiterLimit()
    449449        && style().joinStyle() == style().initialJoinStyle()
    450450        && style().capStyle() == style().initialCapStyle();
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp

    r212562 r214787  
    432432    context->setLineJoin(style.joinStyle());
    433433    if (style.joinStyle() == MiterJoin)
    434         context->setMiterLimit(svgStyle.strokeMiterLimit());
     434        context->setMiterLimit(style.strokeMiterLimit());
    435435
    436436    const Vector<SVGLengthValue>& dashes = svgStyle.strokeDashArray();
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

    r212562 r214787  
    197197            writeIfNotDefault(ts, "opacity", svgStyle.strokeOpacity(), 1.0f);
    198198            writeIfNotDefault(ts, "stroke width", strokeWidth, 1.0);
    199             writeIfNotDefault(ts, "miter limit", svgStyle.strokeMiterLimit(), 4.0f);
     199            writeIfNotDefault(ts, "miter limit", style.strokeMiterLimit(), 4.0f);
    200200            writeIfNotDefault(ts, "line cap", style.capStyle(), ButtCap);
    201201            writeIfNotDefault(ts, "line join", style.joinStyle(), MiterJoin);
Note: See TracChangeset for help on using the changeset viewer.