Bug 820891 part 3. Make scroll* properties for tables work with the table wrapper box, not the table box. r=dholbert
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 10 Jul 2018 09:28:11 -0700
changeset 425632 0f9af414e717ed0a9ff6bee79b098a2d6febaa54
parent 425631 d891c10133eac2d225b9f09115a09bccb95709bf
child 425654 fdb4ed369d2e00935c8bc3bcefd547f4cda44525
push id105119
push userbzbarsky@mozilla.com
push dateTue, 10 Jul 2018 16:28:29 +0000
treeherdermozilla-inbound@0f9af414e717 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs820891
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 820891 part 3. Make scroll* properties for tables work with the table wrapper box, not the table box. r=dholbert
dom/base/Element.cpp
dom/base/Element.h
dom/html/test/test_bug375003-1.html
dom/html/test/test_bug375003-2.html
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/cssom-view/table-scroll-props.html
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -653,23 +653,16 @@ Element::GetAttributeNames(nsTArray<nsSt
 }
 
 already_AddRefed<nsIHTMLCollection>
 Element::GetElementsByTagName(const nsAString& aLocalName)
 {
   return NS_GetContentList(this, kNameSpaceID_Unknown, aLocalName);
 }
 
-nsIFrame*
-Element::GetStyledFrame()
-{
-  nsIFrame *frame = GetPrimaryFrame(FlushType::Layout);
-  return frame ? nsLayoutUtils::GetStyleFrame(frame) : nullptr;
-}
-
 nsIScrollableFrame*
 Element::GetScrollFrame(nsIFrame **aFrame, FlushType aFlushType)
 {
   // it isn't clear what to return for SVG nodes, so just return nothing
   if (IsSVGElement()) {
     if (aFrame) {
       *aFrame = nullptr;
     }
@@ -999,39 +992,41 @@ static nsSize GetScrollRectSizeForOverfl
 }
 
 int32_t
 Element::ScrollHeight()
 {
   if (IsSVGElement())
     return 0;
 
-  nsIScrollableFrame* sf = GetScrollFrame();
+  nsIFrame* frame;
+  nsIScrollableFrame* sf = GetScrollFrame(&frame);
   nscoord height;
   if (sf) {
     height = sf->GetScrollRange().Height() + sf->GetScrollPortRect().Height();
   } else {
-    height = GetScrollRectSizeForOverflowVisibleFrame(GetStyledFrame()).height;
+    height = GetScrollRectSizeForOverflowVisibleFrame(frame).height;
   }
 
   return nsPresContext::AppUnitsToIntCSSPixels(height);
 }
 
 int32_t
 Element::ScrollWidth()
 {
   if (IsSVGElement())
     return 0;
 
-  nsIScrollableFrame* sf = GetScrollFrame();
+  nsIFrame* frame;
+  nsIScrollableFrame* sf = GetScrollFrame(&frame);
   nscoord width;
   if (sf) {
     width = sf->GetScrollRange().Width() + sf->GetScrollPortRect().Width();
   } else {
-    width = GetScrollRectSizeForOverflowVisibleFrame(GetStyledFrame()).width;
+    width = GetScrollRectSizeForOverflowVisibleFrame(frame).width;
   }
 
   return nsPresContext::AppUnitsToIntCSSPixels(width);
 }
 
 nsRect
 Element::GetClientAreaRect()
 {
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1908,18 +1908,16 @@ protected:
    * Internal hook for converting an attribute name-string to nsAttrName in
    * case there is such existing attribute. aNameToUse can be passed to get
    * name which was used for looking for the attribute (lowercase in HTML).
    */
   const nsAttrName*
   InternalGetAttrNameFromQName(const nsAString& aStr,
                                nsAutoString* aNameToUse = nullptr) const;
 
-  nsIFrame* GetStyledFrame();
-
   virtual Element* GetNameSpaceElement() override
   {
     return this;
   }
 
   Attr* GetAttributeNodeNSInternal(const nsAString& aNamespaceURI,
                                    const nsAString& aLocalName);
 
--- a/dom/html/test/test_bug375003-1.html
+++ b/dom/html/test/test_bug375003-1.html
@@ -39,57 +39,57 @@ function t3(id,c,o,s,pid) {
   is(p.id, pid, id+".offsetParent");
 }
 
 function run_test() {
    t3('span1',[0,0,20,20],[12,12,20,20],[0,0,20,20],'td1');
    t3('td1'  ,[1,1,69,44],[16,16,71,46],[0,0,69,46],'table1');
    t3('tr1'  ,[0,0,71,46],[16,16,71,46],[0,0,71,44],'table1');
    t3('span2',[10,0,20,20],[27,12,30,20],[0,0,20,20],'td2');
-   t3('table1',[0,0,103,131],[10,10,103,131],[0,0,85,50],'body');
+   t3('table1',[0,0,103,131],[10,10,103,131],[0,0,103,131],'body');
    t3('div1',[10,10,-1,131],[0,0,-1,151],[0,0,-1,85],'body');
 
    t3('span2b',[10,0,20,20],[25,-1,30,20],[0,0,20,20],'body');
    // XXX not sure how to make reliable cross-platform tests for replaced-inline, inline
    // t3('span2c',[10,2,18,2],[25,-1,30,6],[0,0,30,20],'body');
    // t3('span2d',[0,0,0,0],[25,-1,10,19],[0,0,10,20],'body');
 
    t3('span3' ,[0,0,20,20],[15,0,20,20],[0,0,20,20],'td3');
    t3('td3'   ,[0,0,35,20],[0,0,35,20],[0,0,35,20],'table3');
    t3('tr3'  ,[0,0,35,20],[0,0,35,20],[0,0,35,22],'table3');
    t3('span4' ,[0,0,20,20],[0,0,20,20],[0,0,20,20],'td4');
-   t3('table3',[0,0,35,40],[0,0,35,40],[0,0,35,50],'div3');
+   t3('table3',[0,0,35,40],[0,0,35,40],[0,0,35,40],'div3');
    t3('div3',[10,10,-1,40],[0,151,-1,60],[0,0,-1,70],'body');
 
    t3('span5' ,[0,0,20,20],[1,1,20,20],[0,0,20,20],'td5');
    t3('td5'   ,[7,7,22,22],[2,2,36,36],[0,0,22,36],'table5');
    t3('tr5'  ,[0,0,36,36],[2,2,36,36],[0,0,36,22],'table5');
    t3('span6' ,[0,0,20,20],[20,58,20,20],[0,0,20,20],'div5');
    t3('table5',[0,0,40,78],[0,0,40,78],[0,0,40,78],'div5');
    t3('div5',[10,10,-1,78],[0,211,-1,98],[0,0,-1,70],'body');
 
    t3('span7' ,[0,0,20,20],[1,1,20,20],[0,0,20,20],'td7');
    t3('td7'   ,[1,1,37,22],[9,9,39,24],[0,0,37,22],'table7');
    t3('tr7'  ,[0,0,39,24],[9,9,39,24],[0,0,39,22],'table7');
    t3('span8' ,[0,0,20,20],[26,37,20,20],[0,0,20,20],'table7');
-   t3('table7',[0,0,57,68],[10,319,57,68],[0,0,43,50],'body');
+   t3('table7',[0,0,57,68],[10,319,57,68],[0,0,57,68],'body');
    t3('div7',[10,10,-1,68],[0,309,-1,88],[0,0,-1,70],'body');
 
    t3('span9' ,[0,0,20,20],[1,1,20,20],[0,0,20,20],'td9');
    t3('td9'   ,[1,1,22,22],[15,15,24,24],[0,0,22,24],'table9');
    t3('tr9'  ,[0,0,24,24],[15,15,24,24],[0,0,24,22],'table9');
    t3('span10' ,[0,0,20,20],[17,43,20,20],[0,0,20,20],'table9');
-   t3('table9',[0,0,54,60],[10,407,54,60],[0,0,28,50],'body');
+   t3('table9',[0,0,54,60],[10,407,54,60],[0,0,54,60],'body');
    t3('div9',[10,10,-1,0],[0,397,-1,20],[0,0,-1,70],'body');
 
    t3('span11' ,[0,0,20,20],[1,1,20,20],[0,0,20,20],'td11');
    t3('td11'   ,[0,0,22,22],[2,2,22,22],[0,0,22,22],'table11');
    t3('tr11'  ,[0,0,22,22],[2,2,22,22],[0,0,22,22],'table11');
    t3('span12' ,[0,0,20,20],[28,454,20,20],[0,0,20,20],'body');
-   t3('table11',[0,0,26,30],[10,427,26,30],[0,0,26,50],'body');
+   t3('table11',[0,0,26,30],[10,427,26,30],[0,0,26,30],'body');
    t3('div11',[10,10,-1,30],[0,417,-1,50],[0,0,-1,70],'body');
 }
 </script>
 </head>
 <body id="body">
 
 <div id="content">
 <div id="div1" style="border:10px solid black">
--- a/dom/html/test/test_bug375003-2.html
+++ b/dom/html/test/test_bug375003-2.html
@@ -63,19 +63,19 @@ function t3(id,c,o,s,pid) {
   is(p.id, pid, id+".offsetParent");
 }
 
 function run_test() {
    // XXX how test clientWidth/clientHeight (the -1 below) in cross-platform manner
    // without hard-coding the scrollbar width?
    t3('div1',[20,20,-1,-1],[10,10,200,160],[0,0,230,20],'body');
    t3('abs1',[20,20,-1,-1],[500,170,200,160],[0,0,230,20],'body');
-   t3('table1',[0,0,306,306],[10,170,306,306],[0,0,266,20],'body');
+   t3('table1',[0,0,306,306],[10,170,306,306],[0,0,306,306],'body');
    t3('table2',[0,0,206,206],[0,0,206,206],[0,0,206,20],'table2parent');
-   t3('table3',[0,0,228,228],[0,0,228,228],[0,0,208,228],'table3parent');
+   t3('table3',[0,0,228,228],[0,0,228,228],[0,0,228,228],'table3parent');
    t3('table3parent',[0,0,228,228],[300,100,228,228],[0,0,228,228],'body');
 }
 </script>
 
 </head>
 <body id="body">
 <div id="content">
 <div id="div1parent">
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -324867,16 +324867,22 @@
     ]
    ],
    "css/cssom-view/table-offset-props.html": [
     [
      "/css/cssom-view/table-offset-props.html",
      {}
     ]
    ],
+   "css/cssom-view/table-scroll-props.html": [
+    [
+     "/css/cssom-view/table-scroll-props.html",
+     {}
+    ]
+   ],
    "css/cssom-view/ttwf-js-cssomview-getclientrects-length.html": [
     [
      "/css/cssom-view/ttwf-js-cssomview-getclientrects-length.html",
      {}
     ]
    ],
    "css/cssom-view/window-interface.xht": [
     [
@@ -548812,16 +548818,20 @@
   "css/cssom-view/table-client-props.html": [
    "54115121d05823e9317f68de5fdad4a03b94bd19",
    "testharness"
   ],
   "css/cssom-view/table-offset-props.html": [
    "7327b44c0f8ed0c8ff2d4a36b89255eca85a064f",
    "testharness"
   ],
+  "css/cssom-view/table-scroll-props.html": [
+   "f8a18c1a89a24551113eebed4937729a5a581de8",
+   "testharness"
+  ],
   "css/cssom-view/ttwf-js-cssomview-getclientrects-length.html": [
    "7f3440e65abbe692e3c28f1f1d04671054ecc815",
    "testharness"
   ],
   "css/cssom-view/window-interface.xht": [
    "b51ac4828be890736faee8ce42fd95c4bbb844ef",
    "testharness"
   ],
copy from testing/web-platform/tests/css/cssom-view/table-client-props.html
copy to testing/web-platform/tests/css/cssom-view/table-scroll-props.html
--- a/testing/web-platform/tests/css/cssom-view/table-client-props.html
+++ b/testing/web-platform/tests/css/cssom-view/table-scroll-props.html
@@ -1,11 +1,11 @@
 <!doctype html>
 <meta charset=utf-8>
-<title>client* properties on tables</title>
+<title>scroll* properties on tables</title>
 <link rel="help" href="https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface">
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
 <div id="test-target" style="position: absolute"></div>
 <script>
   test(function() {
     // Each test consists of four elements: the markup to use, the expected
     // value of offsetWidth on the table, the expected value of offsetHeight
@@ -68,16 +68,16 @@
 
     function table() {
       return target().querySelector("table");
     }
 
     for (var t of tests) {
       test(function() {
         target().innerHTML = t[0];
-        assert_equals(table().clientWidth, t[1], t[3] + " clientWidth");
-        assert_equals(table().clientHeight, t[2], t[3] + " clientHeight");
-        assert_equals(table().clientLeft, 0, t[3] + " clientLeft");
-        assert_equals(table().clientTop, 0, t[3] + " clientTop");
+        assert_equals(table().scrollWidth, t[1], t[3] + " scrollWidth");
+        assert_equals(table().scrollHeight, t[2], t[3] + " scrollHeight");
+        assert_equals(table().scrollLeft, 0, t[3] + " scrollLeft");
+        assert_equals(table().scrollTop, 0, t[3] + " scrollTop");
       }, t[3]);
     }
   }, "Overall test to make sure there are no exceptions");
 </script>