Changeset 163764 in webkit


Ignore:
Timestamp:
Feb 9, 2014 10:02:42 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

-webkit-clip-path should support fill, stroke, view-box keywords
https://bugs.webkit.org/show_bug.cgi?id=128393

Source/WebCore:

Patch by Dirk Schulze <dschulze@chromium.org> on 2014-02-09
Reviewed by Dean Jackson.

CSS Masking uses the keywords fill, stroke and view-box for SVG shapes.
This patch updates the parser, style resolver and SVG implementation of
the prefixed clip-path property.

Remove the unexposed and obsolete keyword bounding-box.

Tests: svg/clip-path/clip-path-shape-fill-expected.svg

svg/clip-path/clip-path-shape-fill.svg
svg/clip-path/clip-path-shape-stroke-expected.svg
svg/clip-path/clip-path-shape-stroke.svg
svg/clip-path/clip-path-shape-view-box-expected.svg
svg/clip-path/clip-path-shape-view-box.svg

  • css/CSSParser.cpp: Parse fill, stroke, view-box. Remove bounding-box.

(WebCore::isBoxValue):

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator LayoutBox):

  • css/CSSValueKeywords.in:
  • css/DeprecatedStyleBuilder.cpp:

(WebCore::ApplyPropertyClipPath::applyValue):

  • rendering/RenderLayer.cpp:

(WebCore::computeReferenceBox):

  • rendering/shapes/ShapeInfo.h:

(WebCore::ShapeInfo::setShapeSize):
(WebCore::ShapeInfo::logicalTopOffset):
(WebCore::ShapeInfo::logicalLeftOffset):

  • rendering/style/RenderStyleConstants.h:
  • rendering/svg/SVGRenderingContext.cpp: Use different reference boxes per keyword.

(WebCore::SVGRenderingContext::prepareToRenderSVGContent):

LayoutTests:

Patch by Dirk Schulze <krit@webkit.org> on 2014-02-09
Reviewed by Dean Jackson.

Update or add new tests for changed clip-path keywords.

  • css3/masking/clip-path-circle-bounding-box.html: Removed.
  • fast/masking/parsing-clip-path-shape.html:
  • platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png: Removed.
  • platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt: Removed.
  • svg/clip-path/clip-path-shape-fill-expected.svg: Added.
  • svg/clip-path/clip-path-shape-fill.svg: Added.
  • svg/clip-path/clip-path-shape-stroke-expected.svg: Added.
  • svg/clip-path/clip-path-shape-stroke.svg: Added.
  • svg/clip-path/clip-path-shape-view-box-expected.svg: Added.
  • svg/clip-path/clip-path-shape-view-box.svg: Added.
Location:
trunk
Files:
6 added
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r163749 r163764  
     12014-02-09  Dirk Schulze  <krit@webkit.org>
     2
     3        -webkit-clip-path should support fill, stroke, view-box keywords
     4        https://bugs.webkit.org/show_bug.cgi?id=128393
     5
     6        Reviewed by Dean Jackson.
     7
     8        Update or add new tests for changed clip-path keywords.
     9
     10        * css3/masking/clip-path-circle-bounding-box.html: Removed.
     11        * fast/masking/parsing-clip-path-shape.html:
     12        * platform/mac/css3/masking/clip-path-circle-bounding-box-expected.png: Removed.
     13        * platform/mac/css3/masking/clip-path-circle-bounding-box-expected.txt: Removed.
     14        * svg/clip-path/clip-path-shape-fill-expected.svg: Added.
     15        * svg/clip-path/clip-path-shape-fill.svg: Added.
     16        * svg/clip-path/clip-path-shape-stroke-expected.svg: Added.
     17        * svg/clip-path/clip-path-shape-stroke.svg: Added.
     18        * svg/clip-path/clip-path-shape-view-box-expected.svg: Added.
     19        * svg/clip-path/clip-path-shape-view-box.svg: Added.
     20
    1212014-02-09  Carlos Garnacho  <carlosg@gnome.org>
    222
  • trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt

    r161209 r163764  
    5353PASS innerStyle("-webkit-clip-path", "border-box") is "border-box"
    5454PASS innerStyle("-webkit-clip-path", "margin-box") is "margin-box"
    55 PASS innerStyle("-webkit-clip-path", "bounding-box") is "bounding-box"
     55PASS innerStyle("-webkit-clip-path", "fill") is "fill"
     56PASS innerStyle("-webkit-clip-path", "stroke") is "stroke"
     57PASS innerStyle("-webkit-clip-path", "view-box") is "view-box"
    5658PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box") is "circle(50% at 50% 50%) content-box"
    5759PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) padding-box") is "circle(50% at 50% 50%) padding-box"
    5860PASS innerStyle("-webkit-clip-path", "margin-box circle(50% at 50% 50%)") is "margin-box circle(50% at 50% 50%)"
    5961PASS innerStyle("-webkit-clip-path", "border-box circle(50% at 50% 50%)") is "border-box circle(50% at 50% 50%)"
    60 PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box") is "circle(50% at 50% 50%) bounding-box"
     62PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) view-box") is "circle(50% at 50% 50%) view-box"
    6163PASS computedStyle("-webkit-clip-path", "content-box") is "content-box"
    6264PASS computedStyle("-webkit-clip-path", "padding-box") is "padding-box"
    6365PASS computedStyle("-webkit-clip-path", "border-box") is "border-box"
    6466PASS computedStyle("-webkit-clip-path", "margin-box") is "margin-box"
    65 PASS computedStyle("-webkit-clip-path", "bounding-box") is "bounding-box"
     67PASS computedStyle("-webkit-clip-path", "fill") is "fill"
     68PASS computedStyle("-webkit-clip-path", "stroke") is "stroke"
     69PASS computedStyle("-webkit-clip-path", "view-box") is "view-box"
    6670PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box") is "circle(50% at 50% 50%) content-box"
    6771PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) padding-box") is "circle(50% at 50% 50%) padding-box"
    6872PASS computedStyle("-webkit-clip-path", "margin-box circle(50% at 50% 50%)") is "circle(50% at 50% 50%) margin-box"
    6973PASS computedStyle("-webkit-clip-path", "border-box circle(50% at 50% 50%)") is "circle(50% at 50% 50%) border-box"
    70 PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box") is "circle(50% at 50% 50%) bounding-box"
     74PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) fill") is "circle(50% at 50% 50%) fill"
    7175PASS innerStyle("-webkit-clip-path", "circle(1px, 1px, 1)") is null
    7276PASS computedStyle("-webkit-clip-path", "circle(1px, 1px, 1)") is "none"
     
    101105PASS innerStyle("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is null
    102106PASS computedStyle("-webkit-clip-path", "rectangle(1cm, 1mm, 1in, -1px, 1pt, 1pc)") is "none"
    103 PASS innerStyle("-webkit-clip-path", "bounding-box circle(50% at 50% 50%) content-box") is null
    104 PASS computedStyle("-webkit-clip-path", "bounding-box circle(50% at 50% 50%) content-box") is "none"
     107PASS innerStyle("-webkit-clip-path", "fill circle(50% at 50% 50%) content-box") is null
     108PASS computedStyle("-webkit-clip-path", "fill circle(50% at 50% 50%) content-box") is "none"
    105109PASS innerStyle("-webkit-clip-path", "margin-box padding-box") is null
    106110PASS computedStyle("-webkit-clip-path", "margin-box padding-box") is "none"
    107111PASS innerStyle("-webkit-clip-path", "padding-box border-box circle(50% at 50% 50%)") is null
    108112PASS computedStyle("-webkit-clip-path", "padding-box border-box circle(50% at 50% 50%)") is "none"
    109 PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box bounding-box") is null
    110 PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box bounding-box") is "none"
     113PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box stroke") is null
     114PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box stroke") is "none"
    111115PASS innerStyle("-webkit-clip-path", "content-box margin-box padding-box") is null
    112116PASS computedStyle("-webkit-clip-path", "content-box margin-box padding-box") is "none"
  • trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html

    r161209 r163764  
    112112testInner("-webkit-clip-path", "border-box", "border-box");
    113113testInner("-webkit-clip-path", "margin-box", "margin-box");
    114 testInner("-webkit-clip-path", "bounding-box", "bounding-box");
     114testInner("-webkit-clip-path", "fill", "fill");
     115testInner("-webkit-clip-path", "stroke", "stroke");
     116testInner("-webkit-clip-path", "view-box", "view-box");
    115117testInner("-webkit-clip-path", "circle(50% at 50% 50%) content-box", "circle(50% at 50% 50%) content-box");
    116118testInner("-webkit-clip-path", "circle(50% at 50% 50%) padding-box", "circle(50% at 50% 50%) padding-box");
    117119testInner("-webkit-clip-path", "margin-box circle(50% at 50% 50%)", "margin-box circle(50% at 50% 50%)");
    118120testInner("-webkit-clip-path", "border-box circle(50% at 50% 50%)", "border-box circle(50% at 50% 50%)");
    119 testInner("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box", "circle(50% at 50% 50%) bounding-box");
     121testInner("-webkit-clip-path", "circle(50% at 50% 50%) view-box", "circle(50% at 50% 50%) view-box");
    120122
    121123testComputed("-webkit-clip-path", "content-box", "content-box");
     
    123125testComputed("-webkit-clip-path", "border-box", "border-box");
    124126testComputed("-webkit-clip-path", "margin-box", "margin-box");
    125 testComputed("-webkit-clip-path", "bounding-box", "bounding-box");
     127testComputed("-webkit-clip-path", "fill", "fill");
     128testComputed("-webkit-clip-path", "stroke", "stroke");
     129testComputed("-webkit-clip-path", "view-box", "view-box");
    126130testComputed("-webkit-clip-path", "circle(50% at 50% 50%) content-box", "circle(50% at 50% 50%) content-box");
    127131testComputed("-webkit-clip-path", "circle(50% at 50% 50%) padding-box", "circle(50% at 50% 50%) padding-box");
    128132testComputed("-webkit-clip-path", "margin-box circle(50% at 50% 50%)", "circle(50% at 50% 50%) margin-box");
    129133testComputed("-webkit-clip-path", "border-box circle(50% at 50% 50%)", "circle(50% at 50% 50%) border-box");
    130 testComputed("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box", "circle(50% at 50% 50%) bounding-box");
     134testComputed("-webkit-clip-path", "circle(50% at 50% 50%) fill", "circle(50% at 50% 50%) fill");
    131135
    132136// reject non-lengths
     
    154158
    155159// reject multiple <box> values
    156 negativeTest("-webkit-clip-path", "bounding-box circle(50% at 50% 50%) content-box");
     160negativeTest("-webkit-clip-path", "fill circle(50% at 50% 50%) content-box");
    157161negativeTest("-webkit-clip-path", "margin-box padding-box");
    158162negativeTest("-webkit-clip-path", "padding-box border-box circle(50% at 50% 50%)");
    159 negativeTest("-webkit-clip-path", "circle(50% at 50% 50%) content-box bounding-box");
     163negativeTest("-webkit-clip-path", "circle(50% at 50% 50%) content-box stroke");
    160164negativeTest("-webkit-clip-path", "content-box margin-box padding-box");
    161165negativeTest("-webkit-clip-path", "none content-box");
  • trunk/Source/WebCore/ChangeLog

    r163763 r163764  
     12014-02-09  Dirk Schulze  <dschulze@chromium.org>
     2
     3        -webkit-clip-path should support fill, stroke, view-box keywords
     4        https://bugs.webkit.org/show_bug.cgi?id=128393
     5
     6        Reviewed by Dean Jackson.
     7
     8        CSS Masking uses the keywords fill, stroke and view-box for SVG shapes.
     9        This patch updates the parser, style resolver and SVG implementation of
     10        the prefixed clip-path property.
     11
     12        Remove the unexposed and obsolete keyword bounding-box.
     13
     14        Tests: svg/clip-path/clip-path-shape-fill-expected.svg
     15               svg/clip-path/clip-path-shape-fill.svg
     16               svg/clip-path/clip-path-shape-stroke-expected.svg
     17               svg/clip-path/clip-path-shape-stroke.svg
     18               svg/clip-path/clip-path-shape-view-box-expected.svg
     19               svg/clip-path/clip-path-shape-view-box.svg
     20
     21        * css/CSSParser.cpp: Parse fill, stroke, view-box. Remove bounding-box.
     22        (WebCore::isBoxValue):
     23        * css/CSSPrimitiveValueMappings.h:
     24        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     25        (WebCore::CSSPrimitiveValue::operator LayoutBox):
     26        * css/CSSValueKeywords.in:
     27        * css/DeprecatedStyleBuilder.cpp:
     28        (WebCore::ApplyPropertyClipPath::applyValue):
     29        * rendering/RenderLayer.cpp:
     30        (WebCore::computeReferenceBox):
     31        * rendering/shapes/ShapeInfo.h:
     32        (WebCore::ShapeInfo::setShapeSize):
     33        (WebCore::ShapeInfo::logicalTopOffset):
     34        (WebCore::ShapeInfo::logicalLeftOffset):
     35        * rendering/style/RenderStyleConstants.h:
     36        * rendering/svg/SVGRenderingContext.cpp: Use different reference boxes per keyword.
     37        (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
     38
    1392014-02-09  Dean Jackson  <dino@apple.com>
    240
  • trunk/Source/WebCore/css/CSSParser.cpp

    r163747 r163764  
    58225822    case CSSValueMarginBox:
    58235823        return true;
    5824     case CSSValueBoundingBox:
     5824    case CSSValueFill:
     5825    case CSSValueStroke:
     5826    case CSSValueViewBox:
    58255827        return propId == CSSPropertyWebkitClipPath;
    58265828    default: break;
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r163560 r163764  
    51275127    m_primitiveUnitType = CSS_VALUE_ID;
    51285128    switch (layoutBox) {
    5129     case BoundingBox:
    5130         m_value.valueID = CSSValueBoundingBox;
    5131         break;
    51325129    case MarginBox:
    51335130        m_value.valueID = CSSValueMarginBox;
     
    51415138    case ContentBox:
    51425139        m_value.valueID = CSSValueContentBox;
     5140        break;
     5141    case Fill:
     5142        m_value.valueID = CSSValueFill;
     5143        break;
     5144    case Stroke:
     5145        m_value.valueID = CSSValueStroke;
     5146        break;
     5147    case ViewBox:
     5148        m_value.valueID = CSSValueViewBox;
    51435149        break;
    51445150    case BoxMissing:
     
    51525158{
    51535159    switch (getValueID()) {
    5154     case CSSValueBoundingBox:
    5155         return BoundingBox;
    51565160    case CSSValueMarginBox:
    51575161        return MarginBox;
     
    51625166    case CSSValueContentBox:
    51635167        return ContentBox;
     5168    // The following are used in an SVG context.
     5169    case CSSValueFill:
     5170        return Fill;
     5171    case CSSValueStroke:
     5172        return Stroke;
     5173    case CSSValueViewBox:
     5174        return ViewBox;
    51645175    default:
    51655176        break;
  • trunk/Source/WebCore/css/CSSValueKeywords.in

    r163560 r163764  
    746746
    747747// clip-path
    748 bounding-box
     748view-box
    749749
    750750//
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r163717 r163764  
    21402140                || primitiveValue.getValueID() == CSSValuePaddingBox
    21412141                || primitiveValue.getValueID() == CSSValueMarginBox
    2142                 || primitiveValue.getValueID() == CSSValueBoundingBox)
     2142                || primitiveValue.getValueID() == CSSValueFill
     2143                || primitiveValue.getValueID() == CSSValueStroke
     2144                || primitiveValue.getValueID() == CSSValueViewBox)
    21432145                && referenceBox == BoxMissing)
    21442146                referenceBox = LayoutBox(primitiveValue);
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r163703 r163764  
    37913791                referenceBox.moveBy(rootRelativeBounds.location());
    37923792                break;
     3793            // fill, stroke, view-box compute to border-box for HTML elements.
     3794            case Fill:
     3795            case Stroke:
     3796            case ViewBox:
    37933797            case BorderBox:
    37943798                referenceBox = box.borderBoxRect();
     
    37983802                // FIXME: Support margin-box. Use bounding client rect for now.
    37993803                // https://bugs.webkit.org/show_bug.cgi?id=127984
    3800             case BoundingBox:
    38013804            case BoxMissing:
    38023805                // FIXME: If no reference box was specified the spec demands to use
  • trunk/Source/WebCore/rendering/shapes/ShapeInfo.h

    r161569 r163764  
    9090            logicalWidth -= m_renderer.borderAndPaddingLogicalWidth();
    9191            break;
    92         case BoundingBox:
     92        case Fill:
     93        case Stroke:
     94        case ViewBox:
    9395        case BoxMissing:
    9496            ASSERT_NOT_REACHED();
     
    177179        case PaddingBox: return m_renderer.borderBefore();
    178180        case ContentBox: return m_renderer.borderAndPaddingBefore();
    179         case BoundingBox: break;
     181        case Fill: break;
     182        case Stroke: break;
     183        case ViewBox: break;
    180184        case BoxMissing: break;
    181185        }
     
    194198        case PaddingBox: return m_renderer.borderStart();
    195199        case ContentBox: return m_renderer.borderAndPaddingStart();
    196         case BoundingBox: break;
     200        case Fill: break;
     201        case Stroke: break;
     202        case ViewBox: break;
    197203        case BoxMissing: break;
    198204        }
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r163560 r163764  
    545545#endif
    546546
    547 enum LayoutBox { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, BoundingBox };
     547// Fill, Stroke, ViewBox are just used for SVG.
     548enum LayoutBox { BoxMissing = 0, MarginBox, BorderBox, PaddingBox, ContentBox, Fill, Stroke, ViewBox };
    548549
    549550} // namespace WebCore
  • trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp

    r163440 r163764  
    3636#include "RenderSVGResourceMasker.h"
    3737#include "RenderView.h"
     38#include "SVGLengthContext.h"
    3839#include "SVGResources.h"
    3940#include "SVGResourcesCache.h"
     
    122123    ClipPathOperation* clipPathOperation = style.clipPath();
    123124    if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::Shape) {
    124         ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(clipPathOperation);
    125         m_paintInfo->context->clipPath(clipPath->pathForReferenceRect(renderer.objectBoundingBox()), clipPath->windRule());
     125        ShapeClipPathOperation& clipPath = toShapeClipPathOperation(*clipPathOperation);
     126        FloatRect referenceBox;
     127        if (clipPath.referenceBox() == Stroke)
     128            // FIXME: strokeBoundingBox() takes dasharray into account but shouldn't.
     129            referenceBox = renderer.strokeBoundingBox();
     130        else if (clipPath.referenceBox() == ViewBox && renderer.element()) {
     131            FloatSize viewportSize;
     132            SVGLengthContext(toSVGElement(renderer.element())).determineViewport(viewportSize);
     133            referenceBox.setWidth(viewportSize.width());
     134            referenceBox.setHeight(viewportSize.height());
     135        } else
     136            referenceBox = renderer.objectBoundingBox();
     137        m_paintInfo->context->clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
    126138    }
    127139
Note: See TracChangeset for help on using the changeset viewer.