Changeset 161209 in webkit


Ignore:
Timestamp:
Jan 2, 2014 10:11:51 AM (10 years ago)
Author:
krit@webkit.org
Message:

Support <box> values computed style for 'clip-path' property
https://bugs.webkit.org/show_bug.cgi?id=126148

Reviewed by Simon Fraser.

Source/WebCore:

Calculate computed style for 'clip-path' property.

Updated tests to check for computed style.

  • css/BasicShapeFunctions.cpp: Add box value bounding-box.

(WebCore::valueForBox):
(WebCore::boxForValue):

  • css/CSSComputedStyleDeclaration.cpp: Return the computed style

for 'clip-path'.

(WebCore::ComputedStyleExtractor::propertyValue):

  • css/DeprecatedStyleBuilder.cpp: Create CSSValueLists for 'clip-th'.

(WebCore::ApplyPropertyClipPath::applyValue):

  • rendering/ClipPathOperation.h: Add bounding-box value.

(WebCore::ShapeClipPathOperation::pathForReferenceRect):
(WebCore::ShapeClipPathOperation::setReferenceBox):
(WebCore::ShapeClipPathOperation::referenceBox):
(WebCore::BoxClipPathOperation::create):
(WebCore::BoxClipPathOperation::pathForReferenceRect):
(WebCore::BoxClipPathOperation::referenceBox):
(WebCore::BoxClipPathOperation::BoxClipPathOperation):

  • rendering/shapes/ShapeInfo.h: Add bounding-box value.

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

  • rendering/style/BasicShapes.cpp: Add bounding-box value.

(WebCore::BasicShape::referenceBoxSize):

  • rendering/style/BasicShapes.h:

LayoutTests:

Test computed style of 'clip-path' property.

  • fast/masking/parsing-clip-path-shape.html:
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r161195 r161209  
     12014-01-02  Dirk Schulze  <krit@webkit.org>
     2
     3        Support <box> values computed style for 'clip-path' property
     4        https://bugs.webkit.org/show_bug.cgi?id=126148
     5
     6        Reviewed by Simon Fraser.
     7
     8        Test computed style of 'clip-path' property.
     9
     10        * fast/masking/parsing-clip-path-shape.html:
     11
    1122014-01-01  Antti Koivisto  <antti@apple.com>
    213
  • trunk/LayoutTests/fast/masking/parsing-clip-path-shape-expected.txt

    r161067 r161209  
    5959PASS innerStyle("-webkit-clip-path", "border-box circle(50% at 50% 50%)") is "border-box circle(50% at 50% 50%)"
    6060PASS innerStyle("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box") is "circle(50% at 50% 50%) bounding-box"
     61PASS computedStyle("-webkit-clip-path", "content-box") is "content-box"
     62PASS computedStyle("-webkit-clip-path", "padding-box") is "padding-box"
     63PASS computedStyle("-webkit-clip-path", "border-box") is "border-box"
     64PASS computedStyle("-webkit-clip-path", "margin-box") is "margin-box"
     65PASS computedStyle("-webkit-clip-path", "bounding-box") is "bounding-box"
     66PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) content-box") is "circle(50% at 50% 50%) content-box"
     67PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) padding-box") is "circle(50% at 50% 50%) padding-box"
     68PASS computedStyle("-webkit-clip-path", "margin-box circle(50% at 50% 50%)") is "circle(50% at 50% 50%) margin-box"
     69PASS computedStyle("-webkit-clip-path", "border-box circle(50% at 50% 50%)") is "circle(50% at 50% 50%) border-box"
     70PASS computedStyle("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box") is "circle(50% at 50% 50%) bounding-box"
    6171PASS innerStyle("-webkit-clip-path", "circle(1px, 1px, 1)") is null
    6272PASS computedStyle("-webkit-clip-path", "circle(1px, 1px, 1)") is "none"
  • trunk/LayoutTests/fast/masking/parsing-clip-path-shape.html

    r161067 r161209  
    119119testInner("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box", "circle(50% at 50% 50%) bounding-box");
    120120
     121testComputed("-webkit-clip-path", "content-box", "content-box");
     122testComputed("-webkit-clip-path", "padding-box", "padding-box");
     123testComputed("-webkit-clip-path", "border-box", "border-box");
     124testComputed("-webkit-clip-path", "margin-box", "margin-box");
     125testComputed("-webkit-clip-path", "bounding-box", "bounding-box");
     126testComputed("-webkit-clip-path", "circle(50% at 50% 50%) content-box", "circle(50% at 50% 50%) content-box");
     127testComputed("-webkit-clip-path", "circle(50% at 50% 50%) padding-box", "circle(50% at 50% 50%) padding-box");
     128testComputed("-webkit-clip-path", "margin-box circle(50% at 50% 50%)", "circle(50% at 50% 50%) margin-box");
     129testComputed("-webkit-clip-path", "border-box circle(50% at 50% 50%)", "circle(50% at 50% 50%) border-box");
     130testComputed("-webkit-clip-path", "circle(50% at 50% 50%) bounding-box", "circle(50% at 50% 50%) bounding-box");
     131
    121132// reject non-lengths
    122133negativeTest("-webkit-clip-path", "circle(1px, 1px, 1)");
  • trunk/Source/WebCore/ChangeLog

    r161208 r161209  
     12014-01-02  Dirk Schulze  <krit@webkit.org>
     2
     3        Support <box> values computed style for 'clip-path' property
     4        https://bugs.webkit.org/show_bug.cgi?id=126148
     5
     6        Reviewed by Simon Fraser.
     7
     8        Calculate computed style for 'clip-path' property.
     9
     10        Updated tests to check for computed style.
     11
     12        * css/BasicShapeFunctions.cpp: Add box value bounding-box.
     13        (WebCore::valueForBox):
     14        (WebCore::boxForValue):
     15        * css/CSSComputedStyleDeclaration.cpp: Return the computed style
     16            for 'clip-path'.
     17        (WebCore::ComputedStyleExtractor::propertyValue):
     18        * css/DeprecatedStyleBuilder.cpp: Create CSSValueLists for 'clip-th'.
     19        (WebCore::ApplyPropertyClipPath::applyValue):
     20        * rendering/ClipPathOperation.h: Add bounding-box value.
     21        (WebCore::ShapeClipPathOperation::pathForReferenceRect):
     22        (WebCore::ShapeClipPathOperation::setReferenceBox):
     23        (WebCore::ShapeClipPathOperation::referenceBox):
     24        (WebCore::BoxClipPathOperation::create):
     25        (WebCore::BoxClipPathOperation::pathForReferenceRect):
     26        (WebCore::BoxClipPathOperation::referenceBox):
     27        (WebCore::BoxClipPathOperation::BoxClipPathOperation):
     28        * rendering/shapes/ShapeInfo.h: Add bounding-box value.
     29        (WebCore::ShapeInfo::setShapeSize):
     30        (WebCore::ShapeInfo::logicalTopOffset):
     31        (WebCore::ShapeInfo::logicalLeftOffset):
     32        * rendering/style/BasicShapes.cpp: Add bounding-box value.
     33        (WebCore::BasicShape::referenceBoxSize):
     34        * rendering/style/BasicShapes.h:
     35
    1362014-01-02  Antti Koivisto  <antti@apple.com>
    237
  • trunk/Source/WebCore/css/BasicShapeFunctions.cpp

    r160176 r161209  
    5151    case BasicShape::MarginBox:
    5252        return cssValuePool().createIdentifierValue(CSSValueMarginBox);
     53    case BasicShape::BoundingBox:
     54        return cssValuePool().createIdentifierValue(CSSValueBoundingBox);
    5355    case BasicShape::None:
    5456        return nullptr;
     
    7274    case CSSValueMarginBox:
    7375        return BasicShape::MarginBox;
     76    case CSSValueBoundingBox:
     77        return BasicShape::BoundingBox;
    7478    default:
    7579        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r160908 r161209  
    55 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
    66 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
     7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
    78 *
    89 * This library is free software; you can redistribute it and/or
     
    28602861        case CSSPropertyCounterReset:
    28612862            return counterToCSSValue(style.get(), propertyID);
    2862         case CSSPropertyWebkitClipPath:
    2863             if (ClipPathOperation* operation = style->clipPath()) {
    2864                 if (operation->type() == ClipPathOperation::SHAPE)
    2865                     return valueForBasicShape(style.get(), static_cast<ShapeClipPathOperation*>(operation)->basicShape());
     2863        case CSSPropertyWebkitClipPath: {
     2864            ClipPathOperation* operation = style->clipPath();
     2865            if (!operation)
     2866                return cssValuePool().createIdentifierValue(CSSValueNone);
    28662867#if ENABLE(SVG)
    2867                 if (operation->type() == ClipPathOperation::REFERENCE) {
    2868                     ReferenceClipPathOperation* referenceOperation = static_cast<ReferenceClipPathOperation*>(operation);
    2869                     return CSSPrimitiveValue::create(referenceOperation->url(), CSSPrimitiveValue::CSS_URI);
    2870                 }
    2871 #endif
     2868            if (operation->type() == ClipPathOperation::Reference) {
     2869                ReferenceClipPathOperation& referenceOperation = toReferenceClipPathOperation(*operation);
     2870                return CSSPrimitiveValue::create(referenceOperation.url(), CSSPrimitiveValue::CSS_URI);
    28722871            }
    2873             return cssValuePool().createIdentifierValue(CSSValueNone);
     2872#endif
     2873            RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     2874            if (operation->type() == ClipPathOperation::Shape) {
     2875                ShapeClipPathOperation& shapeOperation = toShapeClipPathOperation(*operation);
     2876                list->append(valueForBasicShape(style.get(), shapeOperation.basicShape()));
     2877                if (shapeOperation.referenceBox() != BasicShape::ReferenceBox::None)
     2878                    list->append(valueForBox(shapeOperation.referenceBox()));
     2879            }
     2880            if (operation->type() == ClipPathOperation::Box) {
     2881                BoxClipPathOperation& boxOperation = toBoxClipPathOperation(*operation);
     2882                list->append(valueForBox(boxOperation.referenceBox()));
     2883            }
     2884            return list.release();
     2885        }
    28742886#if ENABLE(CSS_REGIONS)
    28752887        case CSSPropertyWebkitFlowInto:
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r161067 r161209  
    22 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 * Copyright (C) 2013 Apple Inc. All rights reserved.
     4 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    20632064        if (!value->isValueList())
    20642065            return;
     2066        BasicShape::ReferenceBox referenceBox = BasicShape::ReferenceBox::None;
     2067        RefPtr<ClipPathOperation> operation;
    20652068        auto& valueList = toCSSValueList(*value);
    20662069        for (unsigned i = 0; i < valueList.length(); ++i) {
    2067             // FIXME: <box> values are not supported yet.
    2068             // https://bugs.webkit.org/show_bug.cgi?id=126148
    20692070            auto& primitiveValue = toCSSPrimitiveValue(*valueList.itemWithoutBoundsCheck(i));
    2070             if (!primitiveValue.isShape())
    2071                 continue;
    2072             setValue(styleResolver->style(), ShapeClipPathOperation::create(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue.getShapeValue())));
    2073             break;
    2074         }
     2071            if (primitiveValue.isShape() && !operation)
     2072                operation = ShapeClipPathOperation::create(basicShapeForValue(styleResolver->style(), styleResolver->rootElementStyle(), primitiveValue.getShapeValue()));
     2073            else if ((primitiveValue.getValueID() == CSSValueContentBox
     2074                || primitiveValue.getValueID() == CSSValueBorderBox
     2075                || primitiveValue.getValueID() == CSSValuePaddingBox
     2076                || primitiveValue.getValueID() == CSSValueMarginBox
     2077                || primitiveValue.getValueID() == CSSValueBoundingBox)
     2078                && referenceBox == BasicShape::ReferenceBox::None)
     2079                referenceBox = boxForValue(&primitiveValue);
     2080            else
     2081                return;
     2082        }
     2083        if (!operation) {
     2084            if (referenceBox == BasicShape::ReferenceBox::None)
     2085                return;
     2086            operation = BoxClipPathOperation::create(referenceBox);
     2087        } else
     2088            toShapeClipPathOperation(operation.get())->setReferenceBox(referenceBox);
     2089        setValue(styleResolver->style(), operation.release());
    20752090    }
    20762091    static PropertyHandler createHandler()
  • trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp

    r161106 r161209  
    132132
    133133    // Other clip-path operations than BasicShapes can not be animated.
    134     if (from->type() != ClipPathOperation::SHAPE || to->type() != ClipPathOperation::SHAPE)
     134    if (from->type() != ClipPathOperation::Shape || to->type() != ClipPathOperation::Shape)
    135135        return to;
    136136
  • trunk/Source/WebCore/rendering/ClipPathOperation.h

    r157823 r161209  
    11/*
    2  * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
     2 * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4343public:
    4444    enum OperationType {
    45         REFERENCE,
    46         SHAPE
     45        Reference,
     46        Shape,
     47        Box
    4748    };
    4849
     
    8485
    8586    ReferenceClipPathOperation(const String& url, const String& fragment)
    86         : ClipPathOperation(REFERENCE)
     87        : ClipPathOperation(Reference)
    8788        , m_url(url)
    8889        , m_fragment(fragment)
     
    103104    const BasicShape* basicShape() const { return m_shape.get(); }
    104105    WindRule windRule() const { return m_shape->windRule(); }
    105     const Path& path(const FloatRect& boundingRect)
     106    const Path pathForReferenceRect(const FloatRect& boundingRect) const
    106107    {
    107108        ASSERT(m_shape);
    108         m_path.clear();
    109         m_path = adoptPtr(new Path);
    110         m_shape->path(*m_path, boundingRect);
    111         return *m_path;
     109        // FIXME: Make clipping path from basic-shapes relative to <box> value.
     110        // https://bugs.webkit.org/show_bug.cgi?id=126206
     111        Path path;
     112        m_shape->path(path, boundingRect);
     113        return path;
    112114    }
     115
     116    void setReferenceBox(BasicShape::ReferenceBox referenceBox) { m_referenceBox = referenceBox; }
     117    BasicShape::ReferenceBox referenceBox() const { return m_referenceBox; }
    113118
    114119private:
     
    122127
    123128    explicit ShapeClipPathOperation(PassRefPtr<BasicShape> shape)
    124         : ClipPathOperation(SHAPE)
     129        : ClipPathOperation(Shape)
    125130        , m_shape(shape)
     131        , m_referenceBox(BasicShape::ReferenceBox::None)
    126132    {
    127133    }
    128134
    129135    RefPtr<BasicShape> m_shape;
    130     OwnPtr<Path> m_path;
     136    BasicShape::ReferenceBox m_referenceBox;
    131137};
    132 }
     138
     139class BoxClipPathOperation : public ClipPathOperation {
     140public:
     141    static PassRefPtr<BoxClipPathOperation> create(BasicShape::ReferenceBox referenceBox)
     142    {
     143        return adoptRef(new BoxClipPathOperation(referenceBox));
     144    }
     145
     146    const Path pathForReferenceRect(const FloatRect&) const
     147    {
     148        Path path;
     149        // FIXME: Create clipping path from <box>.
     150        // https://bugs.webkit.org/show_bug.cgi?id=126205
     151        return path;
     152    }
     153    BasicShape::ReferenceBox referenceBox() const { return m_referenceBox; }
     154
     155private:
     156    virtual bool operator==(const ClipPathOperation& o) const OVERRIDE
     157    {
     158        if (!isSameType(o))
     159            return false;
     160        const BoxClipPathOperation* other = static_cast<const BoxClipPathOperation*>(&o);
     161        return m_referenceBox == other->m_referenceBox;
     162    }
     163
     164    explicit BoxClipPathOperation(BasicShape::ReferenceBox referenceBox)
     165        : ClipPathOperation(Box)
     166        , m_referenceBox(referenceBox)
     167    {
     168    }
     169
     170    BasicShape::ReferenceBox m_referenceBox;
     171};
     172
     173#define CLIP_PATH_OPERATION_CASTS(ToValueTypeName, predicate) \
     174    TYPE_CASTS_BASE(ToValueTypeName, ClipPathOperation, operation, operation->type() == ClipPathOperation::predicate, operation.type() == ClipPathOperation::predicate)
     175
     176CLIP_PATH_OPERATION_CASTS(ReferenceClipPathOperation, Reference)
     177CLIP_PATH_OPERATION_CASTS(ShapeClipPathOperation, Shape)
     178CLIP_PATH_OPERATION_CASTS(BoxClipPathOperation, Box)
     179
     180} // namespace WebCore
    133181
    134182#endif // ClipPathOperation_h
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r161153 r161209  
    39173917
    39183918    ASSERT(style.clipPath());
    3919     if (style.clipPath()->type() == ClipPathOperation::SHAPE) {
     3919    if (style.clipPath()->type() == ClipPathOperation::Shape) {
    39203920        ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(style.clipPath());
    39213921
     
    39263926
    39273927        context->save();
    3928         context->clipPath(clipPath->path(rootRelativeBounds), clipPath->windRule());
     3928        context->clipPath(clipPath->pathForReferenceRect(rootRelativeBounds), clipPath->windRule());
    39293929        return true;
    39303930    }
    39313931
    39323932#if ENABLE(SVG)
    3933     if (style.clipPath()->type() == ClipPathOperation::REFERENCE) {
     3933    if (style.clipPath()->type() == ClipPathOperation::Reference) {
    39343934        ReferenceClipPathOperation* referenceClipPathOperation = static_cast<ReferenceClipPathOperation*>(style.clipPath());
    39353935        Element* element = renderer().document().getElementById(referenceClipPathOperation->fragment());
  • trunk/Source/WebCore/rendering/shapes/ShapeInfo.h

    r160243 r161209  
    9090            logicalWidth -= m_renderer.borderAndPaddingLogicalWidth();
    9191            break;
     92        case BasicShape::BoundingBox:
    9293        case BasicShape::None:
    9394            ASSERT_NOT_REACHED();
     
    176177        case BasicShape::PaddingBox: return m_renderer.borderBefore();
    177178        case BasicShape::ContentBox: return m_renderer.borderAndPaddingBefore();
     179        case BasicShape::BoundingBox: break;
    178180        case BasicShape::None: break;
    179181        }
     
    192194        case BasicShape::PaddingBox: return m_renderer.borderStart();
    193195        case BasicShape::ContentBox: return m_renderer.borderAndPaddingStart();
     196        case BasicShape::BoundingBox: break;
    194197        case BasicShape::None: break;
    195198        }
  • trunk/Source/WebCore/rendering/style/BasicShapes.cpp

    r160770 r161209  
    8787        return FloatSize(renderer.marginLeft() + renderer.width() + renderer.marginRight(),
    8888            renderer.marginTop() + renderer.height() + renderer.marginBottom());
     89    case BoundingBox:
     90        break;
    8991    }
    9092
  • trunk/Source/WebCore/rendering/style/BasicShapes.h

    r160770 r161209  
    6464        PaddingBox,
    6565        BorderBox,
    66         MarginBox
     66        MarginBox,
     67        BoundingBox
    6768    };
    6869
  • trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp

    r160615 r161209  
    124124
    125125    ClipPathOperation* clipPathOperation = style.clipPath();
    126     if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::SHAPE) {
     126    if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::Shape) {
    127127        ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(clipPathOperation);
    128         m_paintInfo->context->clipPath(clipPath->path(renderer.objectBoundingBox()), clipPath->windRule());
     128        m_paintInfo->context->clipPath(clipPath->pathForReferenceRect(renderer.objectBoundingBox()), clipPath->windRule());
    129129    }
    130130
Note: See TracChangeset for help on using the changeset viewer.