Changeset 167518 in webkit


Ignore:
Timestamp:
Apr 18, 2014 4:30:58 PM (10 years ago)
Author:
hmuller@adobe.com
Message:

[CSS Shapes] Add parsing support for gradients
https://bugs.webkit.org/show_bug.cgi?id=131444

Reviewed by Bem Jones-Bey.

Source/WebCore:
Added support for shape-outside gradient values.

Test: fast/shapes/shape-outside-floats/shape-outside-linear-gradient.html

  • css/DeprecatedStyleBuilder.cpp:

(WebCore::ApplyPropertyShape::applyValue): Accept generated images as shape-outside values.

  • rendering/shapes/ShapeOutsideInfo.cpp:

(WebCore::checkShapeImageOrigin): Generated images get a pass, others do not.
(WebCore::getShapeImageAndRect): Use StyleImage::image() to get a generated image.
(WebCore::ShapeOutsideInfo::isEnabledFor):

  • rendering/style/ShapeValue.h:

(WebCore::ShapeValue::isImageValid): Generated images are always considered valid.

LayoutTests:

  • fast/shapes/parsing/parsing-shape-outside-expected.txt:
  • fast/shapes/parsing/parsing-test-utils.js:
  • fast/shapes/shape-outside-floats/shape-outside-linear-gradient-expected.html: Added.
  • fast/shapes/shape-outside-floats/shape-outside-linear-gradient.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r167506 r167518  
     12014-04-18  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Shapes] Add parsing support for gradients
     4        https://bugs.webkit.org/show_bug.cgi?id=131444
     5
     6        Reviewed by Bem Jones-Bey.
     7
     8        * fast/shapes/parsing/parsing-shape-outside-expected.txt:
     9        * fast/shapes/parsing/parsing-test-utils.js:
     10        * fast/shapes/shape-outside-floats/shape-outside-linear-gradient-expected.html: Added.
     11        * fast/shapes/shape-outside-floats/shape-outside-linear-gradient.html: Added.
     12
    1132014-04-18  Alexey Proskuryakov  <ap@apple.com>
    214
  • trunk/LayoutTests/fast/shapes/parsing/parsing-shape-outside-expected.txt

    r167132 r167518  
    168168PASS getCSSText("-webkit-shape-outside", "margin-box polygon(nonzero, 0px 0px, 10px 10px, 10px 0px)") is "margin-box polygon(0px 0px, 10px 10px, 10px 0px)"
    169169PASS getComputedStyleValue("-webkit-shape-outside", "margin-box polygon(nonzero, 0px 0px, 10px 10px, 10px 0px)") is "polygon(0px 0px, 10px 10px, 10px 0px) margin-box"
     170PASS getCSSText("-webkit-shape-outside", "linear-gradient(to right, red, blue)") is "linear-gradient(to right, red, blue)"
     171PASS getComputedStyleValue("-webkit-shape-outside", "linear-gradient(to right, red, blue)") is "linear-gradient(to right, red, blue)"
     172PASS getCSSText("-webkit-shape-outside", "radial-gradient(at 10px 20px, red 0%, blue 50%, green 95%)") is "radial-gradient(at 10px 20px, red 0%, blue 50%, green 95%)"
     173PASS getComputedStyleValue("-webkit-shape-outside", "radial-gradient(at 10px 20px, red 0%, blue 50%, green 95%)") is "radial-gradient(at 10px 20px, red 0%, blue 50%, green 95%)"
    170174PASS removeBaseURL(getCSSText("-webkit-shape-outside", "url('image')")) is "url(image)"
    171175PASS removeBaseURL(getComputedStyleValue("-webkit-shape-outside", "url('image')")) is "url(image)"
  • trunk/LayoutTests/fast/shapes/parsing/parsing-test-utils.js

    r167132 r167518  
    9595    ["padding-box polygon(nonzero, 0px 0px, 10px 10px, 10px 0px)", "padding-box polygon(0px 0px, 10px 10px, 10px 0px)", "polygon(0px 0px, 10px 10px, 10px 0px) padding-box"],
    9696    ["border-box polygon(nonzero, 0px 0px, 10px 10px, 10px 0px)", "border-box polygon(0px 0px, 10px 10px, 10px 0px)", "polygon(0px 0px, 10px 10px, 10px 0px) border-box"],
    97     ["margin-box polygon(nonzero, 0px 0px, 10px 10px, 10px 0px)", "margin-box polygon(0px 0px, 10px 10px, 10px 0px)", "polygon(0px 0px, 10px 10px, 10px 0px) margin-box"]
     97    ["margin-box polygon(nonzero, 0px 0px, 10px 10px, 10px 0px)", "margin-box polygon(0px 0px, 10px 10px, 10px 0px)", "polygon(0px 0px, 10px 10px, 10px 0px) margin-box"],
     98
     99    "linear-gradient(to right, red, blue)",
     100    "radial-gradient(at 10px 20px, red 0%, blue 50%, green 95%)"
    98101];
    99102
  • trunk/Source/WebCore/ChangeLog

    r167517 r167518  
     12014-04-18  Hans Muller  <hmuller@adobe.com>
     2
     3        [CSS Shapes] Add parsing support for gradients
     4        https://bugs.webkit.org/show_bug.cgi?id=131444
     5
     6        Reviewed by Bem Jones-Bey.
     7
     8        Added support for shape-outside gradient values.
     9
     10        Test: fast/shapes/shape-outside-floats/shape-outside-linear-gradient.html
     11
     12        * css/DeprecatedStyleBuilder.cpp:
     13        (WebCore::ApplyPropertyShape::applyValue): Accept generated images as shape-outside values.
     14        * rendering/shapes/ShapeOutsideInfo.cpp:
     15        (WebCore::checkShapeImageOrigin): Generated images get a pass, others do not.
     16        (WebCore::getShapeImageAndRect): Use StyleImage::image() to get a generated image.
     17        (WebCore::ShapeOutsideInfo::isEnabledFor):
     18        * rendering/style/ShapeValue.h:
     19        (WebCore::ShapeValue::isImageValid): Generated images are always considered valid.
     20
    1212014-04-18  Brady Eidson  <beidson@apple.com>
    222
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r167448 r167518  
    21792179            if (primitiveValue->getValueID() == CSSValueAuto)
    21802180                setValue(styleResolver->style(), 0);
    2181         } else if (value->isImageValue() || value->isImageSetValue()) {
     2181        } else if (value->isImageValue() || value->isImageGeneratorValue() || value->isImageSetValue()) {
    21822182            RefPtr<ShapeValue> shape = ShapeValue::createImageValue(styleResolver->styleImage(property, value));
    21832183            setValue(styleResolver->style(), shape.release());
  • trunk/Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp

    r166797 r167518  
    121121}
    122122
    123 static inline bool checkShapeImageOrigin(Document& document, CachedImage& cachedImage)
    124 {
     123static inline bool checkShapeImageOrigin(Document& document, const StyleImage& styleImage)
     124{
     125    if (styleImage.isGeneratedImage())
     126        return true;
     127
     128    ASSERT(styleImage.cachedImage());
     129    CachedImage& cachedImage = *(styleImage.cachedImage());
    125130    if (cachedImage.isOriginClean(document.securityOrigin()))
    126131        return true;
     
    141146    styleImage->setContainerSizeForRenderer(&renderBox, imageSize, renderBox.style().effectiveZoom());
    142147
    143     image = styleImage->cachedImage()->imageForRenderer(&renderBox);
     148    image = nullptr;
     149    if (styleImage->isCachedImage() || styleImage->isCachedImageSet())
     150        image = styleImage->cachedImage()->imageForRenderer(&renderBox);
     151    else if (styleImage->isGeneratedImage())
     152        image = styleImage->image(const_cast<RenderBox*>(&renderBox), imageSize).get();
     153
    144154    if (renderBox.isRenderImage())
    145155        rect = toRenderImage(&renderBox)->replacedContentRect(renderBox.intrinsicSize());
     
    294304    switch (shapeValue->type()) {
    295305    case ShapeValue::Shape: return shapeValue->shape();
    296     case ShapeValue::Image: return shapeValue->isImageValid() && checkShapeImageOrigin(box.document(), *(shapeValue->image()->cachedImage()));
     306    case ShapeValue::Image: return shapeValue->isImageValid() && checkShapeImageOrigin(box.document(), *(shapeValue->image()));
    297307    case ShapeValue::Box: return true;
    298308    }
  • trunk/Source/WebCore/rendering/style/ShapeValue.h

    r166786 r167518  
    6868
    6969    StyleImage* image() const { return m_image.get(); }
    70     bool isImageValid() const { return image() && image()->cachedImage() && image()->cachedImage()->hasImage(); }
     70
     71    bool isImageValid() const
     72    {
     73        if (!image())
     74            return false;
     75        if (image()->isCachedImage() || image()->isCachedImageSet())
     76            return image()->cachedImage() && image()->cachedImage()->hasImage();
     77        return image()->isGeneratedImage();
     78    }
     79
    7180    void setImage(PassRefPtr<StyleImage> image)
    7281    {
Note: See TracChangeset for help on using the changeset viewer.