Bug 142411 - CSS scroll-snap-destination and scroll-snap-coordinate are not honoring position values
Summary: CSS scroll-snap-destination and scroll-snap-coordinate are not honoring posit...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks: 134283
  Show dependency treegraph
 
Reported: 2015-03-06 14:16 PST by Brent Fulgham
Modified: 2015-03-10 16:20 PDT (History)
2 users (show)

See Also:


Attachments
Patch (34.79 KB, patch)
2015-03-09 17:12 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (49.35 KB, patch)
2015-03-10 13:59 PDT, Brent Fulgham
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2015-03-06 14:16:22 PST
The CSS specification for "scroll-snap-coordinate" and "scroll-snap-destination" (see <http://dev.w3.org/csswg/css-snappoints/#propdef-scroll-snap-coordinate> and <http://dev.w3.org/csswg/css-snappoints/#propdef-scroll-snap-destination>) state that the value of these properties are <position>.

This means the following are allowed:
<position> = [
    [ left | center | right | top | bottom | <percentage> | <length> ]
|
    [ left | center | right | <percentage> | <length> ]
    [ top | center | bottom | <percentage> | <length> ]
|
    [ center | [ left | right ] [ <percentage> | <length> ]? ] &&
    [ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]

We currently only support percentage and length values.
Comment 1 Radar WebKit Bug Importer 2015-03-06 14:17:53 PST
<rdar://problem/20076426>
Comment 2 Brent Fulgham 2015-03-09 17:12:22 PDT
Created attachment 248294 [details]
Patch
Comment 3 Simon Fraser (smfr) 2015-03-09 18:34:35 PDT
Comment on attachment 248294 [details]
Patch

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

> Source/WebCore/css/CSSParser.cpp:3358
> +    if (xAxisValue.id == CSSValueLeft || xAxisValue.id == CSSValueCenter || xAxisValue.id == CSSValueRight) {
> +        int percent = 0;
> +        if (xAxisValue.id == CSSValueRight)
> +            percent = 100;
> +        else if (xAxisValue.id == CSSValueCenter)
> +            percent = 50;
> +        cssValueX = cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCENTAGE);
> +    } else {
> +        ValueWithCalculation valueXWithCalculation(xAxisValue);
> +        if (!validateUnit(valueXWithCalculation, FPercent | FLength))
> +            return false;
> +        cssValueX = createPrimitiveNumericValue(valueXWithCalculation);
> +    }
> +
> +    if (yAxisValue.id == CSSValueTop || yAxisValue.id == CSSValueBottom || yAxisValue.id == CSSValueCenter) {
> +        int percent = 0;
> +        if (yAxisValue.id == CSSValueBottom)
> +            percent = 100;
> +        else if (yAxisValue.id == CSSValueCenter)
> +            percent = 50;
> +        cssValueY = cssValuePool().createValue(percent, CSSPrimitiveValue::CSS_PERCENTAGE);
> +    } else {
> +        ValueWithCalculation valueYWithCalculation(yAxisValue);
> +        if (!validateUnit(valueYWithCalculation, FPercent | FLength))
> +            return false;
> +        cssValueY = createPrimitiveNumericValue(valueYWithCalculation);
> +    }

Can't we share code with other things that take positions?

> WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme:215
> +      <MacroExpansion>
> +         <BuildableReference
> +            BuildableIdentifier = "primary"
> +            BlueprintIdentifier = "14F271BD18EA3963008C152F"
> +            BuildableName = "libbmalloc.a"
> +            BlueprintName = "bmalloc"
> +            ReferencedContainer = "container:Source/bmalloc/bmalloc.xcodeproj">
> +         </BuildableReference>
> +      </MacroExpansion>

You shouldn't commit changes to this file.

> LayoutTests/css3/scroll-snap/scroll-snap-position-values.html:24
> +            .noInitial {
> +                -webkit-scroll-snap-type: mandatory;
> +                -webkit-scroll-snap-points-x: repeat(100%);
> +                -webkit-scroll-snap-points-y: repeat(100%);

You should test that -webkit-calc() works in these properties too.
Comment 4 Brent Fulgham 2015-03-10 13:59:03 PDT
Created attachment 248355 [details]
Patch
Comment 5 Simon Fraser (smfr) 2015-03-10 14:49:49 PDT
Comment on attachment 248355 [details]
Patch

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

> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1113
> +    list.get().append(zoomAdjustedPixelValueForLength(destination.width(), &style));
> +    list.get().append(zoomAdjustedPixelValueForLength(destination.height(), &style));

This change makes me think you should test span points under page zoom.

> Source/WebCore/css/LengthRepeat.h:45
> -    static PassRefPtr<LengthRepeat> create(PassRefPtr<CSSPrimitiveValue> interval) { return adoptRef(new LengthRepeat(interval)); }
> +    static PassRefPtr<LengthRepeat> create(PassRefPtr<CSSValue> interval) { return adoptRef(new LengthRepeat(interval)); }
>  
>      PassRefPtr<LengthRepeat> cloneForCSSOM() const { return create(interval()); }
>  
> -    CSSPrimitiveValue* interval() const { return m_interval.get(); }
> +    CSSValue* interval() const { return m_interval.get(); }
>  
> -    void setInterval(PassRefPtr<CSSPrimitiveValue> interval) { m_interval = interval; }
> +    void setInterval(PassRefPtr<CSSValue> interval) { m_interval = interval; }

This change isn't explained in the changelog.
Comment 6 Brent Fulgham 2015-03-10 16:20:05 PDT
Committed r181352: <http://trac.webkit.org/changeset/181352>