Bug 131444

Summary: [CSS Shapes] Add support for shape-outside gradient values
Product: WebKit Reporter: Zoltan Horvath <zoltan>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, giles_joplin, glenn, gyuyoung.kim, kondapallykalyan, macpherson, menard, syoichi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 124173    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Zoltan Horvath 2014-04-09 11:00:12 PDT
As the CSS Shapes Level 1 spec says [1] shape-outside can take image values. Image values can be gradients [2]. Thus we need to add support for gradients [3].

[1] http://www.w3.org/TR/2014/CR-css-shapes-1-20140320/#shapes-from-image
[2] http://www.w3.org/TR/css3-images/#image-type
[3] http://www.w3.org/TR/css3-images/#gradients
Comment 1 Hans Muller 2014-04-17 10:53:07 PDT
Created attachment 229558 [details]
Patch

Added support for shape-outside gradient values.
Comment 2 WebKit Commit Bot 2014-04-17 10:54:26 PDT
Attachment 229558 [details] did not pass style-queue:


ERROR: Source/WebCore/rendering/style/ShapeValue.h:71:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:151:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 2 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Hans Muller 2014-04-17 11:06:52 PDT
Created attachment 229561 [details]
Patch

Fixed some styleOs.
Comment 4 Hans Muller 2014-04-17 14:29:31 PDT
Created attachment 229578 [details]
Patch

Removed a spurious ShapeOutsideInfo.cpp include.
Comment 5 Bem Jones-Bey 2014-04-18 11:54:18 PDT
Comment on attachment 229578 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229578&action=review

> Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:123
> +static inline bool checkShapeImageOrigin(Document& document, const ShapeValue& shapeValue)

Why take a ShapeValue instead of a StyleImage?

> Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:128
> +    CachedImage& cachedImage = *(shapeValue.image()->cachedImage());

I'd ASSERT(shapeValue.image()->cachedImage()) first, just to be safe.

> Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:151
> +        image = styleImage->image(const_cast<RenderBox*>(&renderBox), imageSize).get();

The const_cast makes me very uncomfortable. There isn't a better way to do this? Maybe we need to refactor StyleImage so it can take a const?
Comment 6 Hans Muller 2014-04-18 12:24:14 PDT
(In reply to comment #5)
> (From update of attachment 229578 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=229578&action=review
> 
> > Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:123
> > +static inline bool checkShapeImageOrigin(Document& document, const ShapeValue& shapeValue)
> 
> Why take a ShapeValue instead of a StyleImage?

I've changed the parameter to StyleImage*.


> > Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:128
> > +    CachedImage& cachedImage = *(shapeValue.image()->cachedImage());
> 
> I'd ASSERT(shapeValue.image()->cachedImage()) first, just to be safe.

OK.

> 
> > Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:151
> > +        image = styleImage->image(const_cast<RenderBox*>(&renderBox), imageSize).get();
> 
> The const_cast makes me very uncomfortable. There isn't a better way to do this? Maybe we need to refactor StyleImage so it can take a const?

I did take a shot at that. The overall change would be much bigger than this patch.  There are about 10 classes that implement this image() method and in some cases the not-const RenderElement is passed along to other methods.  If it's worth tracking down the complete transitive closure of the change, it might be better to do it as a separate patch.
Comment 7 Hans Muller 2014-04-18 12:29:31 PDT
Created attachment 229662 [details]
Patch

Made the suggested changes.
Comment 8 Bem Jones-Bey 2014-04-18 13:55:42 PDT
Comment on attachment 229662 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=229662&action=review

> Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:125
> +    ASSERT(styleImage);

if this can't be null, why not pass a reference? (even better, can it be a const ref?)

> Source/WebCore/rendering/shapes/ShapeOutsideInfo.cpp:153
> +        image = styleImage->image(const_cast<RenderBox*>(&renderBox), imageSize).get();

It would be nice to see a follow-up patch that removes the need for the const_cast here.
Comment 9 Hans Muller 2014-04-18 15:30:09 PDT
Created attachment 229682 [details]
Patch

I've made the checkShapeImageOrigin() StyleImage* parameter a const StyleImage&.

I'll attempt to make this StyleImage function's RenderElement* parameter, const RenderElement*, in a separate patch:

    virtual PassRefPtr<Image> image(RenderElement*, const FloatSize&) const = 0;
Comment 10 Bem Jones-Bey 2014-04-18 15:48:59 PDT
Comment on attachment 229682 [details]
Patch

r=me
Comment 11 WebKit Commit Bot 2014-04-18 16:31:26 PDT
Comment on attachment 229682 [details]
Patch

Clearing flags on attachment: 229682

Committed r167518: <http://trac.webkit.org/changeset/167518>
Comment 12 WebKit Commit Bot 2014-04-18 16:31:31 PDT
All reviewed patches have been landed.  Closing bug.