Skip to content

Commit ee6c63b

Browse files
committed
make scrollTop/scrollLeft match reality; that of Firefox / IE
1 parent 33da8f9 commit ee6c63b

2 files changed

Lines changed: 158 additions & 55 deletions

File tree

cssom-view/Overview.html

Lines changed: 88 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -889,30 +889,61 @@ <h3 id=scroll-attributes><span class=secno>5.2. </span>The <code
889889
title="">scrollWidth</code>, and <code title="">scrollHeight</code>
890890
attributes</h3>
891891

892-
<p>The <dfn id=dom-element-scrolltop><code>scrollTop</code></dfn>
893-
attribute, when called on element <var>A</var>, <em class=ct>must</em>
894-
return the value that is the result of running the following algorithm:
892+
<p>The <dfn id=dom-element-scrolltop><code>scrollTop</code></dfn> attribute
893+
<em class=ct>must</em> return the result of running these steps:
895894

896895
<ol>
897896
<li>
898-
<p>If <var>A</var> does not have an associated CSS layout box return zero
899-
and stop this algorithm.
897+
<p>If the element does not have any associated CSS layout box or the
898+
element is the root element and the <a
899+
href="#document"><code>Document</code></a> is in <span>quirks
900+
mode</span> return zero and terminate these steps.
901+
902+
<li>
903+
<p>If the element is the root element return the value of <a
904+
href="#dom-window-pageyoffset"><code>pageYOffset</code></a>.
905+
906+
<li>
907+
<p>If the element is <a href="#the-html-body-element">the HTML
908+
<code>body</code> element</a>, the <a
909+
href="#document"><code>Document</code></a> is in <span>quirks
910+
mode</span>, and the element does not have any overflow, return the
911+
value of <a href="#dom-window-pageyoffset"><code>pageYOffset</code></a>.
900912

901913
<li>
902914
<p>Return the y-coordinate of the <a href="#content">content</a> at the
903915
alignment point with the top of the <a href="#content-edge">content
904-
edge</a> of <var>A</var>.
916+
edge</a> of the element.
905917
</ol>
906918

907919
<p>When setting the <a
908-
href="#dom-element-scrolltop"><code>scrollTop</code></a> attribute to <var
909-
title="">y</var> on element <var>A</var>, user agents <em
910-
class=ct>must</em> run the following algorithm:
920+
href="#dom-element-scrolltop"><code>scrollTop</code></a> attribute these
921+
steps <em class=ct>must</em> be run:
911922

912923
<ol>
913924
<li>
914-
<p>If <var>A</var> does not have an associated CSS layout box or vertical
915-
overflow stop this algorithm.
925+
<p>Let <var title="">y</var> be the given value.
926+
927+
<li>
928+
<p>If the element does not have any associated CSS layout box, the
929+
element is the root element and the <a
930+
href="#document"><code>Document</code></a> is in <span>quirks
931+
mode</span>, or the element has no overflow, terminate these steps.
932+
933+
<li>
934+
<p>If the element is the root element invoke <a
935+
href="#dom-window-screen"><code
936+
title=dom-Window-screen>screen()</code></a> with zero as first argument
937+
and <var title="">y</var> as second.
938+
939+
<li>
940+
<p>If the element is <a href="#the-html-body-element">the HTML
941+
<code>body</code> element</a>, the <a
942+
href="#document"><code>Document</code></a> is in <span>quirks
943+
mode</span>, and the element does not have any vertical overflow, invoke
944+
<a href="#dom-window-screen"><code
945+
title=dom-Window-screen>screen()</code></a> with zero as first argument
946+
and <var title="">y</var> as second.
916947

917948
<li>
918949
<p>If <var title="">y</var> is infinite or NaN stop this algorithm.</p>
@@ -928,33 +959,64 @@ <h3 id=scroll-attributes><span class=secno>5.2. </span>The <code
928959
<li>
929960
<p>Align <a href="#content">content</a> y-coordinate <var
930961
title="">y</var> with the top of the <a href="#content-edge">content
931-
edge</a> of <var>A</var>.
962+
edge</a> of the element.
932963
</ol>
933964

934965
<p>The <dfn id=dom-element-scrollleft><code>scrollLeft</code></dfn>
935-
attribute, when called on element <var>A</var>, <em class=ct>must</em>
936-
return the value that is the result of running the following algorithm:
966+
attribute <em class=ct>must</em> return the result of running these steps:
937967

938968
<ol>
939969
<li>
940-
<p>If <var>A</var> does not have an associated CSS layout box return zero
941-
and stop this algorithm.
970+
<p>If the element does not have any associated CSS layout box or the
971+
element is the root element and the <a
972+
href="#document"><code>Document</code></a> is in <span>quirks
973+
mode</span> return zero and terminate these steps.
974+
975+
<li>
976+
<p>If the element is the root element return the value of <a
977+
href="#dom-window-pagexoffset"><code>pageXOffset</code></a>.
978+
979+
<li>
980+
<p>If the element is <a href="#the-html-body-element">the HTML
981+
<code>body</code> element</a>, the <a
982+
href="#document"><code>Document</code></a> is in <span>quirks
983+
mode</span>, and the element does not have any overflow, return the
984+
value of <a href="#dom-window-pagexoffset"><code>pageXOffset</code></a>.
942985

943986
<li>
944987
<p>Return the x-coordinate of the <a href="#content">content</a> at the
945988
alignment point with the left of the <a href="#content-edge">content
946-
edge</a> of <var>A</var>.
989+
edge</a> of the element.
947990
</ol>
948991

949992
<p>When setting the <a
950-
href="#dom-element-scrollleft"><code>scrollLeft</code></a> attribute to
951-
<var title="">x</var> on element <var>A</var>, user agents <em
952-
class=ct>must</em> run the following algorithm:
993+
href="#dom-element-scrollleft"><code>scrollLeft</code></a> attribute these
994+
steps <em class=ct>must</em> be run:
953995

954996
<ol>
955997
<li>
956-
<p>If <var>A</var> does not have an associated CSS layout box or
957-
horizontal overflow stop this algorithm.
998+
<p>Let <var title="">x</var> be the given value.
999+
1000+
<li>
1001+
<p>If the element does not have any associated CSS layout box, the
1002+
element is the root element and the <a
1003+
href="#document"><code>Document</code></a> is in <span>quirks
1004+
mode</span>, or the element has no overflow, terminate these steps.
1005+
1006+
<li>
1007+
<p>If the element is the root element invoke <a
1008+
href="#dom-window-screen"><code
1009+
title=dom-Window-screen>screen()</code></a> with <var title="">x</var>
1010+
as first argument and zero as second.
1011+
1012+
<li>
1013+
<p>If the element is <a href="#the-html-body-element">the HTML
1014+
<code>body</code> element</a>, the <a
1015+
href="#document"><code>Document</code></a> is in <span>quirks
1016+
mode</span>, and the element does not have any vertical overflow, invoke
1017+
<a href="#dom-window-screen"><code
1018+
title=dom-Window-screen>screen()</code></a> with <var title="">x</var>
1019+
as first argument and zero as second.
9581020

9591021
<li>
9601022
<p>If <var title="">x</var> is infinite or NaN stop this algorithm.</p>
@@ -1001,8 +1063,8 @@ <h3 id=scroll-attributes><span class=secno>5.2. </span>The <code
10011063

10021064
<ol>
10031065
<li>
1004-
<p>If <var>A</var> does not have an associated CSS layout box return zero
1005-
and stop this algorithm.
1066+
<p>If <var>A</var> does not have any associated CSS layout box return
1067+
zero and terminate these steps.
10061068

10071069
<li>
10081070
<p>Return the computed value of the <code>padding-left</code> property of
@@ -1017,8 +1079,8 @@ <h3 id=scroll-attributes><span class=secno>5.2. </span>The <code
10171079

10181080
<ol>
10191081
<li>
1020-
<p>If <var>A</var> does not have an associated CSS layout box return zero
1021-
and stop this algorithm.
1082+
<p>If <var>A</var> does not have any associated CSS layout box return
1083+
zero and stop this algorithm.
10221084

10231085
<li>
10241086
<p>Return the computed value of the <code>padding-top</code> property of

cssom-view/Overview.src.html

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -710,27 +710,47 @@ <h3 id="scroll-attributes">The <code title="">scrollTop</code>,
710710
<code title="">scrollHeight</code> attributes</h3>
711711

712712
<p>The <dfn id="dom-element-scrolltop"><code>scrollTop</code></dfn>
713-
attribute, when called on element <var>A</var>, <em class="ct">must</em>
714-
return the value that is the result of running the following
715-
algorithm:</p>
713+
attribute <em class="ct">must</em> return the result of running these
714+
steps:</p>
716715

717716
<ol>
718-
<li><p>If <var>A</var> does not have an associated CSS layout box return
719-
zero and stop this algorithm.</p></li>
717+
<li><p>If the element does not have any associated CSS layout box or the
718+
element is the root element and the <code>Document</code> is in
719+
<span>quirks mode</span> return zero and terminate these steps.</p></li>
720+
721+
<li><p>If the element is the root element return the value of
722+
<code>pageYOffset</code>.</p></li>
723+
724+
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
725+
the <code>Document</code> is in <span>quirks mode</span>, and the element
726+
does not have any overflow, return the value of
727+
<code>pageYOffset</code>.</p></li>
720728

721729
<li><p>Return the y-coordinate of the <span>content</span> at the
722-
alignment point with the top of the <span>content edge</span> of
723-
<var>A</var>.</p></li>
730+
alignment point with the top of the <span>content edge</span> of the
731+
element.</p></li>
724732
</ol>
725733

726-
<p>When setting the <code>scrollTop</code> attribute to
727-
<var title="">y</var> on element <var>A</var>, user agents
728-
<em class="ct">must</em> run the
729-
following algorithm:</p>
734+
<p>When setting the <code>scrollTop</code> attribute these steps
735+
<em class="ct">must</em> be run:</p>
730736

731737
<ol>
732-
<li><p>If <var>A</var> does not have an associated CSS layout box or
733-
vertical overflow stop this algorithm.</p></li>
738+
<li><p>Let <var title="">y</var> be the given value.</p></li>
739+
740+
<li><p>If the element does not have any associated CSS layout box, the
741+
element is the root element and the <code>Document</code> is in
742+
<span>quirks mode</span>, or the element has no overflow, terminate these
743+
steps.</p></li>
744+
745+
<li><p>If the element is the root element invoke
746+
<code title="dom-Window-screen">screen()</code> with zero as first
747+
argument and <var title="">y</var> as second.</p></li>
748+
749+
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
750+
the <code>Document</code> is in <span>quirks mode</span>, and the element
751+
does not have any vertical overflow, invoke
752+
<code title="dom-Window-screen">screen()</code> with zero as first
753+
argument and <var title="">y</var> as second.</p></li>
734754

735755
<li><p>If <var title="">y</var> is infinite or NaN stop this
736756
algorithm.</p>
@@ -741,30 +761,51 @@ <h3 id="scroll-attributes">The <code title="">scrollTop</code>,
741761
<li><p>If <var title="">y</var> is negative let it be zero.</p></li>
742762

743763
<li><p>Align <span>content</span> y-coordinate <var title="">y</var> with
744-
the top of the <span>content edge</span> of <var>A</var>.</p></li>
764+
the top of the <span>content edge</span> of the element.</p></li>
745765
</ol>
746766

747767
<p>The <dfn id="dom-element-scrollleft"><code>scrollLeft</code></dfn>
748-
attribute, when called on element <var>A</var>,
749-
<em class="ct">must</em> return the value that is the result of running the
750-
following algorithm:</p>
768+
attribute <em class="ct">must</em> return the result of running these
769+
steps:</p>
751770

752771
<ol>
753-
<li><p>If <var>A</var> does not have an associated CSS layout box return
754-
zero and stop this algorithm.</p></li>
772+
<li><p>If the element does not have any associated CSS layout box or the
773+
element is the root element and the <code>Document</code> is in
774+
<span>quirks mode</span> return zero and terminate these steps.</p></li>
775+
776+
<li><p>If the element is the root element return the value of
777+
<code>pageXOffset</code>.</p></li>
778+
779+
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
780+
the <code>Document</code> is in <span>quirks mode</span>, and the element
781+
does not have any overflow, return the value of
782+
<code>pageXOffset</code>.</p></li>
755783

756784
<li><p>Return the x-coordinate of the <span>content</span> at the
757-
alignment point with the left of the <span>content edge</span> of
758-
<var>A</var>.</p></li>
785+
alignment point with the left of the <span>content edge</span> of the
786+
element.</p></li>
759787
</ol>
760788

761-
<p>When setting the <code>scrollLeft</code> attribute to <var title="">x</var>
762-
on element <var>A</var>, user agents <em class="ct">must</em> run the
763-
following algorithm:</p>
789+
<p>When setting the <code>scrollLeft</code> attribute these steps
790+
<em class="ct">must</em> be run:</p>
764791

765792
<ol>
766-
<li><p>If <var>A</var> does not have an associated CSS layout box or
767-
horizontal overflow stop this algorithm.</p></li>
793+
<li><p>Let <var title="">x</var> be the given value.</p></li>
794+
795+
<li><p>If the element does not have any associated CSS layout box, the
796+
element is the root element and the <code>Document</code> is in
797+
<span>quirks mode</span>, or the element has no overflow, terminate these
798+
steps.</p></li>
799+
800+
<li><p>If the element is the root element invoke
801+
<code title="dom-Window-screen">screen()</code> with
802+
<var title="">x</var> as first argument and zero as second.</p></li>
803+
804+
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
805+
the <code>Document</code> is in <span>quirks mode</span>, and the element
806+
does not have any vertical overflow, invoke
807+
<code title="dom-Window-screen">screen()</code> with
808+
<var title="">x</var> as first argument and zero as second.</p></li>
768809

769810
<li><p>If <var title="">x</var> is infinite or NaN stop this
770811
algorithm.</p>
@@ -806,8 +847,8 @@ <h3 id="scroll-attributes">The <code title="">scrollTop</code>,
806847
algorithm:</p>
807848

808849
<ol>
809-
<li><p>If <var>A</var> does not have an associated CSS layout box return
810-
zero and stop this algorithm.</p></li>
850+
<li><p>If <var>A</var> does not have any associated CSS layout box return
851+
zero and terminate these steps.</p></li>
811852

812853
<li><p>Return the computed value of the <code>padding-left</code> property
813854
of <var>A</var>, plus the computed value of the <code>padding-right</code>
@@ -821,7 +862,7 @@ <h3 id="scroll-attributes">The <code title="">scrollTop</code>,
821862
algorithm:</p>
822863

823864
<ol>
824-
<li><p>If <var>A</var> does not have an associated CSS layout box return
865+
<li><p>If <var>A</var> does not have any associated CSS layout box return
825866
zero and stop this algorithm.</p></li>
826867

827868
<li><p>Return the computed value of the <code>padding-top</code> property

0 commit comments

Comments
 (0)