Bug 130350 - [CSS Shapes] clamp RasterShape shapeMargin to reference box size
Summary: [CSS Shapes] clamp RasterShape shapeMargin to reference box size
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Hans Muller
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-17 10:26 PDT by Hans Muller
Modified: 2014-03-20 16:32 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.68 KB, patch)
2014-03-20 11:14 PDT, Hans Muller
dino: review-
Details | Formatted Diff | Diff
Patch (7.81 KB, patch)
2014-03-20 15:24 PDT, Hans Muller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hans Muller 2014-03-17 10:26:30 PDT
Image valued shapes are represented internally as a vector of above threshold horizontal "runs"; just the start,end column for the above threshold pixels on a row. The vector's size is currently the image's height plus the user supplied shapeMargin length.  The limiting case for the run-vector's size is just one above threshold pixel one the first or last image row. In that case the shapeMargin can be limited to the shape's reference box height, since the shape is clipped to the reference box after it's expanded by shapeMargin.

Currently shapeMargin is incorrectly clamped to the image size in RasterShape::marginIntervals()

int marginBoundaryRadius = std::min(clampToInteger(ceil(shapeMargin())), std::max(m_imageSize.width(), m_imageSize.height()));
Comment 1 Hans Muller 2014-03-17 10:51:35 PDT
Note also: once this is fixed, the m_imageSize member can be removed.
Comment 2 Hans Muller 2014-03-20 11:14:12 PDT
Created attachment 227304 [details]
Patch

Corrected the way the maximum shape-margin value was computed for image valued shapes. The limiting case is an image with just one above threshold pixel. The largest possible value for shapeMargin is the radius of a circle that encloses the size of the shape-outside element's margin-box, since the shape-outside's boundary is clipped to the margin-box. The radius is just sqrt(2) * the margin-box's largest dimension.

Also cleaned up up a few poorly named parameters.
Comment 3 Dean Jackson 2014-03-20 14:09:52 PDT
Comment on attachment 227304 [details]
Patch

You're missing ChangeLogs. Looks ok otherwise though.
Comment 4 Hans Muller 2014-03-20 15:24:16 PDT
Created attachment 227345 [details]
Patch

Added the ChangeLogs.  Sorry about that.
Comment 5 Dean Jackson 2014-03-20 15:43:29 PDT
Comment on attachment 227345 [details]
Patch

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

> Source/WebCore/rendering/shapes/Shape.h:71
> -    static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& drawRect, const LayoutRect& clipRect, WritingMode, Length margin, Length padding);
> +    static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& imageRect, const LayoutRect& marginRect, WritingMode, Length margin, Length padding);

Interesting that Shape.cpp already had that change.
Comment 6 Hans Muller 2014-03-20 15:53:20 PDT
(In reply to comment #5)
> (From update of attachment 227345 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=227345&action=review
> 
> > Source/WebCore/rendering/shapes/Shape.h:71
> > -    static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& drawRect, const LayoutRect& clipRect, WritingMode, Length margin, Length padding);
> > +    static PassOwnPtr<Shape> createRasterShape(Image*, float threshold, const LayoutRect& imageRect, const LayoutRect& marginRect, WritingMode, Length margin, Length padding);
> 
> Interesting that Shape.cpp already had that change.

Yes.  I had trouble deciding what to call this parameter and the code reflected as much. It's the rect that the overall shape is clipped to (so clipRect) and it's defined by the shape element's margin-box (so marginRect), which can be a little confusing since it's shape-margin that can grow the shape into the margin-box.  The names still aren't great, but now at least they're consistent.
Comment 7 WebKit Commit Bot 2014-03-20 16:32:22 PDT
Comment on attachment 227345 [details]
Patch

Clearing flags on attachment: 227345

Committed r166019: <http://trac.webkit.org/changeset/166019>
Comment 8 WebKit Commit Bot 2014-03-20 16:32:25 PDT
All reviewed patches have been landed.  Closing bug.