New issue
Advanced search Search tips

Issue 891282 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Oct 8
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac , Fuchsia
Pri: 3
Type: Bug



Sign in to add a comment

[css-scroll-snap] scroll-snap-align keywords should not be reversed

Project Member Reported by ericwilligers@chromium.org, Oct 2

Issue description

If scroll-snap-align is set to "start end", Blink serializes the specified value as "start end" but the computed value is incorrectly reported as "end start"

Spec:
https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-snap-align

Test case:
http://jsfiddle.net/ericwilligers/sqjtx3vr/

 
Labels: Hotlist-GoodFirstBug
The problem appears to be that the two fields are swapped in

https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/properties/computed_style_utils.cc?l=2042&gsn=ValueForScrollSnapAlign
CSSValue* ComputedStyleUtils::ValueForScrollSnapAlign(
    const ScrollSnapAlign& align,
    const ComputedStyle& style) {
  return CSSValuePair::Create(
      CSSIdentifierValue::Create(align.alignment_inline),
      CSSIdentifierValue::Create(align.alignment_block),
      CSSValuePair::kDropIdenticalValues);
}

https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-snap-align
"The two values specify the snapping alignment in the block axis and inline axis, respectively."


Some possible additional cleanups for subsequent CLs:


https://cs.chromium.org/chromium/src/cc/input/scroll_snap_data.h?type=cs&q=ScrollSnapAlign&g=0&l=72

For consistency the fields and constructor arguments could have block before inline:

ScrollSnapAlign(SnapAlignment i, SnapAlignment b)
This constructor appears to only be called in tests.


https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/properties/longhands/scroll_snap_align_custom.cc

The local variables don't need to be swapped but they could be renamed.

x_id and x_value could be replaced with
CSSValue* block_value = CSSPropertyParserHelpers::ConsumeIdent<CSSValueNone, CSSValueStart, CSSValueEnd, CSSValueCenter>(range);
if (!block_value)
  return null_ptr;

Similarly, y_id and y_value could be replaced with
CSSValue* inline_value = CSSPropertyParserHelpers::ConsumeIdent<CSSValueNone, CSSValueStart, CSSValueEnd, CSSValueCenter>(range);
if (!inline_value)
  return null_ptr;


Comment 2 Deleted

If anybody wants to take a look at this, please do.
This should be straightforward if a new contributor, student or intern wants to take it on.
@ericwilligers@chromium.org
I am working on this issue and I checked that it works fine with my patch.
I will send a CL ASAP.

test.png
130 KB View Download
Status: Started (was: Untriaged)
Project Member

Comment 8 by bugdroid1@chromium.org, Oct 8

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a31d6d6cf095f81e5a14c4845d2cddff92e539f9

commit a31d6d6cf095f81e5a14c4845d2cddff92e539f9
Author: Dong-hee Na <donghee.na92@gmail.com>
Date: Mon Oct 08 23:47:52 2018

css-scroll-snap: scroll-snap-align keywords should not be reversed

According to spec, if two values specified for the ScrollSnapAlign
these values should be set as the block axis and inline axis respectively.
But the current implementation does not follow this so it should be updated.

refernce: https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-snap-align
Bug:  891282 
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Id765b44c86ce4f2aeb5e85ec74f83a36cc282196
Reviewed-on: https://chromium-review.googlesource.com/c/1267055
Reviewed-by: David Bokan <bokan@chromium.org>
Reviewed-by: Eric Willigers <ericwilligers@chromium.org>
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597735}
[modify] https://crrev.com/a31d6d6cf095f81e5a14c4845d2cddff92e539f9/cc/input/scroll_snap_data.h
[modify] https://crrev.com/a31d6d6cf095f81e5a14c4845d2cddff92e539f9/cc/input/scroll_snap_data_unittest.cc
[modify] https://crrev.com/a31d6d6cf095f81e5a14c4845d2cddff92e539f9/third_party/WebKit/LayoutTests/external/wpt/css/css-scroll-snap/inheritance-expected.txt
[modify] https://crrev.com/a31d6d6cf095f81e5a14c4845d2cddff92e539f9/third_party/blink/renderer/core/css/properties/computed_style_utils.cc
[modify] https://crrev.com/a31d6d6cf095f81e5a14c4845d2cddff92e539f9/third_party/blink/renderer/core/css/properties/longhands/scroll_snap_align_custom.cc
[modify] https://crrev.com/a31d6d6cf095f81e5a14c4845d2cddff92e539f9/third_party/blink/renderer/core/page/scrolling/snap_coordinator_test.cc

Owner: ericwilligers@chromium.org
Status: Fixed (was: Started)
Fixed by donghee.na92@gmail.com

Sign in to add a comment