Re: [cssom-view] behavior of document.body.scrollTop

Mike Sherov
Chief Technologist
SNAP Interactive, Inc. | Ticker: STVI
http://snap-interactive.com | http://ayi.com

> On Oct 9, 2013, at 5:13 AM, Simon Pieters <simonp@opera.com> wrote:
>
>> On Wed, 09 Oct 2013 04:55:14 +0200, Mike Sherov <mike.sherov@gmail.com> wrote:
>>
>> A recent change in Blink attempted to correct the behavior of
>> document.documentElement.scrollTop and document.body.scrollTop to match the
>> spec and the other browsers:
>>
>> http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop
>>
>> However, it seems that the spec may inadvertently underdefine setter
>> behavior on document.body.scrollTop when NOT in quirks mode. This has
>> caused Blink to maintain the old, possibly incorrect behavior:
>> https://codereview.chromium.org/26489005/
>>
>> The spec *seems* to indicate that document.body.scrollTop SHOULD NOT be a
>> no-op in standards mode. If this is the intention, thank Blink is correct
>> in reverting and the other browsers are wrong.
>>
>> However, I believe the intent is that document.body.scrollTop SHOULD be a
>> no-op in standards mode (which matches other browsers. Read these steps
>> carefully... nothing prevents document.body.scrollTop from getting to step
>> 6 in standards mode, and I believe it a spec bug, not the intention:
>
> If the body element is scrollable, why shouldn't you scroll it?
>
> http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2558
>
> Gecko does this, and it matches the spec, AFAICT.
>
> Blink appears to scroll the viewport, but that's not what the spec says.

I see. The difference being that in step 4 & 5, scroll() is invoked,
which scrolls the viewport, whereas in step 6, the body element itself
is scrolled (but only if it has vertical overflow, obviously). Am I
understanding that correctly?

Thanks for clearing that up. I'll forward this along back to the Blink team.

>
>> When setting the
>> scrollTop<http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop>
>> attribute
>> these steps must be run:
>>
>>   1.
>>
>>   If the given value is a
>> ScrollOptionsVertical<http://dev.w3.org/csswg/cssom-view/#scrolloptionsvertical>
>> object,
>>   and the ydictionary member is not present, abort these steps.
>>   2.
>>
>>   If the given value is a
>> ScrollOptionsVertical<http://dev.w3.org/csswg/cssom-view/#scrolloptionsvertical>
>> object,
>>   let y be the value of the y dictionary member. Otherwise, let y be the
>>   given value.
>>   3.
>>
>>   If the element does not have any associated CSS layout
>> box<http://dev.w3.org/csswg/cssom-view/#css-layout-box>,
>>   the element is the root element and the
>> Document<http://dom.spec.whatwg.org/#document> is
>>   in quirks mode <http://dom.spec.whatwg.org/#concept-document-quirks>, or
>>   the element has no associated scrolling
>> box<http://dev.w3.org/csswg/cssom-view/#scrolling-box>,
>>   or the element has no overflow, terminate these steps.
>>   4.
>>
>>   If the element is the root element invoke
>> scroll()<http://dev.w3.org/csswg/cssom-view/#dom-window-scroll>
>>    with scrollX <http://dev.w3.org/csswg/cssom-view/#dom-window-scrollx>as
>>   first argument and y as second, and, if the given value is a
>>   ScrollOptionsVertical<http://dev.w3.org/csswg/cssom-view/#scrolloptionsvertical>
>> object,
>>   the given value as the third argument.
>>   5.
>>
>>   If the element is the HTML body
>> element<http://dev.w3.org/csswg/cssom-view/#the-html-body-element>,
>>   the Document <http://dom.spec.whatwg.org/#document> is inquirks
>> mode<http://dom.spec.whatwg.org/#concept-document-quirks>,
>>   and the element does not have any vertical overflow, invoke
>> scroll()<http://dev.w3.org/csswg/cssom-view/#dom-window-scroll>
>>    with scrollX <http://dev.w3.org/csswg/cssom-view/#dom-window-scrollx> as
>>   first argument and y as second, and, if the given value is a
>>   ScrollOptionsVertical<http://dev.w3.org/csswg/cssom-view/#scrolloptionsvertical>
>> object,
>>   the given value as the third argument.
>>   6.
>>
>>   Scroll the element<http://dev.w3.org/csswg/cssom-view/#scroll-an-element>
>>    to scrollLeft<http://dev.w3.org/csswg/cssom-view/#dom-element-scrollleft>
>>   ,y, with the scroll behavior being the value of the behavior dictionary
>>   member if the given value is a
>> ScrollOptionsVertical<http://dev.w3.org/csswg/cssom-view/#scrolloptionsvertical>
>> object,
>>   or auto otherwise.
>>
>> Some clarification would be greatly appreciated!
>>
>> Mike Sherov
>> Chief Technologist
>> SNAP Interactive, Inc. | Ticker: STVI
>> http://snap-interactive.com | http://ayi.com
>
>
> --
> Simon Pieters
> Opera Software

Received on Wednesday, 9 October 2013 11:17:42 UTC