Bug 1677642 - Add a wpt testing an empty box doesn't contribute to parent's scrollable overflow area. r=emilio
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 20 Nov 2020 01:13:05 +0000
changeset 558133 ccf878a677f004ca9ef357cc1d7b0a83111813f5
parent 558132 e675571f2d9a4c940a9d31eaab3bd87a3390205d
child 558134 6846280ac5a01635bbf9a70820a6e0066145e7c4
push id131413
push useraethanyc@gmail.com
push dateFri, 20 Nov 2020 01:43:03 +0000
treeherderautoland@ccf878a677f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1677642
milestone85.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 1677642 - Add a wpt testing an empty box doesn't contribute to parent's scrollable overflow area. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D97513
layout/generic/ReflowOutput.cpp
layout/generic/nsIFrame.cpp
testing/web-platform/tests/css/css-overflow/overflow-empty-child-box.html
--- a/layout/generic/ReflowOutput.cpp
+++ b/layout/generic/ReflowOutput.cpp
@@ -7,26 +7,22 @@
 /* struct containing the output from nsIFrame::Reflow */
 
 #include "mozilla/ReflowOutput.h"
 #include "mozilla/ReflowInput.h"
 
 namespace mozilla {
 
 void OverflowAreas::UnionWith(const OverflowAreas& aOther) {
-  // Bug 1677642: We should probably change scrollable overflow to use
-  // UnionRectEdges (but leave ink overflow using UnionRect)
   InkOverflow().UnionRect(InkOverflow(), aOther.InkOverflow());
   ScrollableOverflow().UnionRect(ScrollableOverflow(),
                                  aOther.ScrollableOverflow());
 }
 
 void OverflowAreas::UnionAllWith(const nsRect& aRect) {
-  // Bug 1677642: We should probably change scrollable overflow to use
-  // UnionRectEdges (but leave ink overflow using UnionRect).
   InkOverflow().UnionRect(InkOverflow(), aRect);
   ScrollableOverflow().UnionRect(ScrollableOverflow(), aRect);
 }
 
 void OverflowAreas::SetAllTo(const nsRect& aRect) {
   InkOverflow() = aRect;
   ScrollableOverflow() = aRect;
 }
--- a/layout/generic/nsIFrame.cpp
+++ b/layout/generic/nsIFrame.cpp
@@ -9551,18 +9551,16 @@ bool nsIFrame::FinishAndStoreOverflow(Ov
   // Overflow area must always include the frame's top-left and bottom-right,
   // even if the frame rect is empty (so we can scroll to those positions).
   // Pending a real fix for bug 426879, don't do this for inline frames
   // with zero width.
   // Do not do this for SVG either, since it will usually massively increase
   // the area unnecessarily.
   if ((aNewSize.width != 0 || !IsInlineFrame()) &&
       !HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) {
-    // Bug 1677642: We should probably call OverflowArea::UnionAllWith() once
-    // the scrollable overflow is using UnionEdges.
     for (const auto otype : AllOverflowTypes()) {
       nsRect& o = aOverflowAreas.Overflow(otype);
       o.UnionRectEdges(o, bounds);
     }
   }
 
   // Note that StyleOverflow::Clip doesn't clip the frame
   // background, so we add theme background overflow here so it's not clipped.
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-overflow/overflow-empty-child-box.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+  <meta charset="utf-8">
+  <title>CSS Overflow Test: Testing an empty child box and its container's scrollable overflow area</title>
+  <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com">
+  <link rel="author" title="Mozilla" href="https://www.mozilla.org/">
+  <link rel="help" href="https://drafts.csswg.org/css-overflow-3/#scrollable">
+  <meta name="assert" content="This test verifies that an empty child box shouldn't contribute to its parents scrollable overflow area.">
+
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
+  <script src="/resources/check-layout-th.js"></script>
+
+  <style>
+  .container {
+    border: 1px solid black;
+    width: 200px;
+    height: 100px;
+  }
+
+  .empty {
+    position: relative;
+    width: 0px;
+    height: 0px;
+    left: 500px;
+    top: 300px;
+    box-shadow: 0 0 0 10px blue;
+  }
+  </style>
+
+  <body onload="checkLayout('.container')">
+    <p>You should see no scrollbars in these container because an empty child
+    box shouldn't contribute to its parents scrollable overflow area. </p>
+
+    <div class="container" style="overflow: visible"
+         data-expected-scroll-width="200" data-expected-scroll-height="100">
+      <div class="empty"></div>
+    </div>
+
+    <div class="container" style="overflow: auto"
+         data-expected-scroll-width="200" data-expected-scroll-height="100">
+      <div class="empty"></div>
+    </div>
+
+    <div class="container" style="overflow: hidden"
+         data-expected-scroll-width="200" data-expected-scroll-height="100">
+      <div class="empty"></div>
+    </div>
+
+    <div class="container" style="overflow: clip"
+         data-expected-scroll-width="200" data-expected-scroll-height="100">
+      <div class="empty"></div>
+    </div>
+  </body>
+</html>