Bug 831780. Only count the broken-image placeholder in the visual overflow, not the scrollable overflow. r=mattwoodrow
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 17 Jan 2013 23:17:41 -0500
changeset 119232 f08762b3f956cdb1dc93b6a95c6144cb1ea96367
parent 119231 4a820e3c2b031f0cd3ae264cdf9c1b6caec43d93
child 119233 e082e9b65e53ee44ed5ea3a9e23ce29f64e9d203
push id24195
push userMs2ger@gmail.com
push dateSat, 19 Jan 2013 16:10:11 +0000
treeherdermozilla-central@02e12a80aef9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs831780
milestone21.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 831780. Only count the broken-image placeholder in the visual overflow, not the scrollable overflow. r=mattwoodrow
layout/generic/nsImageFrame.cpp
layout/generic/test/Makefile.in
layout/generic/test/test_bug831780.html
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -900,17 +900,22 @@ nsImageFrame::Reflow(nsPresContext*     
   if (loadStatus & imgIRequest::STATUS_SIZE_AVAILABLE) {
     haveSize = true;
   }
 
   if (!imageOK || !haveSize) {
     nsRect altFeedbackSize(0, 0,
                            nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+2*(ICON_PADDING+ALT_BORDER_WIDTH)),
                            nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+2*(ICON_PADDING+ALT_BORDER_WIDTH)));
-    aMetrics.mOverflowAreas.UnionAllWith(altFeedbackSize);
+    // We include the altFeedbackSize in our visual overflow, but not in our
+    // scrollable overflow, since it doesn't really need to be scrolled to
+    // outside the image.
+    MOZ_STATIC_ASSERT(eOverflowType_LENGTH == 2, "Unknown overflow types?");
+    nsRect& visualOverflow = aMetrics.VisualOverflow();
+    visualOverflow.UnionRect(visualOverflow, altFeedbackSize);
   }
   FinishAndStoreOverflow(&aMetrics);
 
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
                   ("exit nsImageFrame::Reflow: size=%d,%d",
                   aMetrics.width, aMetrics.height));
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
   return NS_OK;
--- a/layout/generic/test/Makefile.in
+++ b/layout/generic/test/Makefile.in
@@ -99,16 +99,17 @@ MOCHITEST_FILES = \
   test_bug719515.html \
   test_bug719518.html \
   test_bug719523.html \
   test_bug735641.html \
   test_bug748961.html \
   test_bug784410.html \
   test_bug785324.html \
   test_bug791616.html \
+  test_bug831780.html \
   $(NULL)
 
 MOCHITEST_CHROME_FILES = \
   frame_selection_underline.xhtml \
   frame_selection_underline-ref.xhtml \
   frame_selection_underline.css \
   test_selection_underline.html \
   test_bug632379.xul \
new file mode 100644
--- /dev/null
+++ b/layout/generic/test/test_bug831780.html
@@ -0,0 +1,32 @@
+<!-- Important: needs to be in quirks mode for the test to be meaningful -->
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=831780
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 831780</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=831780">Mozilla Bug 831780</a>
+<p id="display" style="width: 1px; height: 1px; overflow: hidden">
+  <!-- No src so it'll be a broken image, but that only happens in quirks
+       mode.  In standards mode the test would end up timing-dependent -->
+  <img style="width: 1px; height: 1px">
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+  <script type="application/javascript">
+
+  /** Test for Bug 831780 **/
+  is($("display").scrollWidth, 1, "scrollWidth should be 1");
+  is($("display").scrollHeight, 1, "scrollHeight should be 1");
+
+  </script>
+</body>
+</html>