Bug 539356 - Part 27 - Make nsImageFrame's overflow include the AltFeedback image if it will use one. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 29 Aug 2012 17:48:44 +1200
changeset 108389 226afc8b39b0f6aa461f4f75edd601a7631ed7cd
parent 108388 625343f34ca2b6450a9ca698a22074a60851b429
child 108390 7b06b79fe138c8a298b1523bbd2c7bd4f123ad2c
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersroc
bugs539356
milestone18.0a1
Bug 539356 - Part 27 - Make nsImageFrame's overflow include the AltFeedback image if it will use one. r=roc
layout/generic/nsImageFrame.cpp
layout/reftests/bugs/482659-1a.html
layout/reftests/bugs/482659-1b.html
layout/reftests/bugs/482659-1c.html
layout/reftests/bugs/482659-1d.html
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -860,16 +860,31 @@ nsImageFrame::Reflow(nsPresContext*     
       aMetrics.height > aReflowState.availableHeight) { 
     // our desired height was greater than 0, so to avoid infinite
     // splitting, use 1 pixel as the min
     aMetrics.height = NS_MAX(nsPresContext::CSSPixelsToAppUnits(1), aReflowState.availableHeight);
     aStatus = NS_FRAME_NOT_COMPLETE;
   }
 
   aMetrics.SetOverflowAreasToDesiredBounds();
+  nsEventStates contentState = mContent->AsElement()->State();
+  bool imageOK = IMAGE_OK(contentState, true);
+
+  // Determine if the size is available
+  bool haveSize = false;
+  if (loadStatus & imgIRequest::STATUS_SIZE_AVAILABLE) {
+    haveSize = true;
+  }
+
+  if (!imageOK || !haveSize) {
+    nsRect altFeedbackSize(0, 0,
+                           2*(nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH)),
+                           2*(nsPresContext::CSSPixelsToAppUnits(ICON_SIZE+ICON_PADDING+ALT_BORDER_WIDTH)));
+    aMetrics.mOverflowAreas.UnionAllWith(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/reftests/bugs/482659-1a.html
+++ b/layout/reftests/bugs/482659-1a.html
@@ -1,16 +1,17 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <head>
     <script>
-      window.onload = function() {
+      function doTest() {
         window.frames[0].document.body.innerHTML =
           "<img src='passouter.png' " +
           "onload='window.parent.document.documentElement.className = &quot;&quot;'>";
       }
+      document.addEventListener("MozReftestInvalidate", doTest, false);
     </script>
   </head>
   <body>
     <iframe></iframe>
   </body>
 </html>
   
--- a/layout/reftests/bugs/482659-1b.html
+++ b/layout/reftests/bugs/482659-1b.html
@@ -1,16 +1,17 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <head>
     <script>
-      window.onload = function() {
+      function doTest() {
         window.frames[0].document.body.innerHTML =
           "<img src='passouter.png' " +
           "onload='window.parent.document.documentElement.className = &quot;&quot;'>";
       }
+      document.addEventListener("MozReftestInvalidate", doTest, false);
     </script>
   </head>
   <body>
     <iframe src="about:blank"></iframe>
   </body>
 </html>
   
--- a/layout/reftests/bugs/482659-1c.html
+++ b/layout/reftests/bugs/482659-1c.html
@@ -1,25 +1,26 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <head>
     <script>
-      window.onload = function() {
+      function doTest() {
         window.frames[0].location =
           'javascript:document.write(""); document.close(); ' +
           'parent.continueTest();'
       }
 
       function continueTest() {
         // Do this part async just in case
         setTimeout(function() {
           window.frames[0].document.body.innerHTML =
             "<img src='passouter.png' " +
             "onload='window.parent.document.documentElement.className = &quot;&quot;'>";
                                                                                         }, 0);
       }
+      document.addEventListener("MozReftestInvalidate", doTest, false);
     </script>
   </head>
   <body>
     <iframe></iframe>
   </body>
 </html>
   
--- a/layout/reftests/bugs/482659-1d.html
+++ b/layout/reftests/bugs/482659-1d.html
@@ -1,25 +1,26 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <head>
     <script>
-      window.onload = function() {
+      function doTest() {
         window.frames[0].location =
           'javascript:document.write(""); document.close(); ' +
           'parent.continueTest();'
       }
 
       function continueTest() {
         // Do this part async just in case
         setTimeout(function() {
           window.frames[0].document.body.innerHTML =
             "<img src='passouter.png' " +
             "onload='window.parent.document.documentElement.className = &quot;&quot;'>";
                                                                                         }, 0);
       }
+      document.addEventListener("MozReftestInvalidate", doTest, false);
     </script>
   </head>
   <body>
     <iframe src="about:blank"></iframe>
   </body>
 </html>