Bug 1348208 part 2 - Refactor nsImageFrame::ShouldCreateImageFrameFor a bit. r?dbaron draft
authorXidorn Quan <me@upsuper.org>
Mon, 20 Mar 2017 11:30:54 +1100
changeset 501342 5d65fc37426552d5701133a753e012396e980611
parent 501341 81fc42bbf88c1437ee4447e02a08e4f83e887272
child 501343 ff4aa66d039712fcefcaa8a1afca7af2306f4b29
push id49935
push userxquan@mozilla.com
push dateMon, 20 Mar 2017 00:42:21 +0000
reviewersdbaron
bugs1348208
milestone55.0a1
Bug 1348208 part 2 - Refactor nsImageFrame::ShouldCreateImageFrameFor a bit. r?dbaron MozReview-Commit-ID: IrYbo1N1unt
layout/generic/nsImageFrame.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -458,40 +458,35 @@ nsImageFrame::ShouldCreateImageFrameFor(
   //
   //  - if our "do not show placeholders" pref is set, skip the icon
   //  - else:
   //  - if there is a src attribute, there is no alt attribute,
   //    and this is not an <object> (which could not possibly have
   //    such an attribute), show an icon.
   //  - if QuirksMode, and the IMG has a size show an icon.
   //  - otherwise, skip the icon
-  bool useSizedBox;
-  
+
   if (gIconLoad && gIconLoad->mPrefForceInlineAltText) {
-    useSizedBox = false;
+    return false;
   }
-  else if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::src) &&
-           !aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::alt) &&
-           !aElement->IsHTMLElement(nsGkAtoms::object) &&
-           !aElement->IsHTMLElement(nsGkAtoms::input)) {
+  if (aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::src) &&
+      !aElement->HasAttr(kNameSpaceID_None, nsGkAtoms::alt) &&
+      !aElement->IsHTMLElement(nsGkAtoms::object) &&
+      !aElement->IsHTMLElement(nsGkAtoms::input)) {
     // Use a sized box if we have no alt text.  This means no alt attribute
     // and the node is not an object or an input (since those always have alt
     // text).
-    useSizedBox = true;
-  }
-  else if (aStyleContext->PresContext()->CompatibilityMode() !=
-           eCompatibility_NavQuirks) {
-    useSizedBox = false;
+    return true;
   }
-  else {
-    // check whether we have specified size
-    useSizedBox = HaveSpecifiedSize(aStyleContext->StylePosition());
+  if (aStyleContext->PresContext()->CompatibilityMode() !=
+      eCompatibility_NavQuirks) {
+    return false;
   }
-
-  return useSizedBox;
+  // check whether we have specified size
+  return HaveSpecifiedSize(aStyleContext->StylePosition());
 }
 
 nsresult
 nsImageFrame::Notify(imgIRequest* aRequest,
                      int32_t aType,
                      const nsIntRect* aRect)
 {
   if (aType == imgINotificationObserver::SIZE_AVAILABLE) {