Bug 491180. <button> should not clip overflowing contents. r=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 22 Jul 2009 21:31:45 -0400
changeset 30586 12728e187734a0719d2c789b872fecbd393177d7
parent 30585 4a3ddae856c712c994985b3d3906fbd59efdfb72
child 30587 ea46b7fe632016fba2c0c579490f8dabfa0a9a0d
push idunknown
push userunknown
push dateunknown
reviewersroc
bugs491180
milestone1.9.2a1pre
Bug 491180. <button> should not clip overflowing contents. r=roc
layout/forms/nsGfxButtonControlFrame.h
layout/forms/nsHTMLButtonControlFrame.cpp
layout/forms/nsHTMLButtonControlFrame.h
layout/reftests/bugs/491180-1-ref.html
layout/reftests/bugs/491180-1.html
layout/reftests/bugs/491180-2-ref.html
layout/reftests/bugs/491180-2.html
layout/reftests/bugs/reftest.list
--- a/layout/forms/nsGfxButtonControlFrame.h
+++ b/layout/forms/nsGfxButtonControlFrame.h
@@ -95,16 +95,17 @@ public:
 
 protected:
   nsresult GetDefaultLabel(nsXPIDLString& aLabel);
 
   nsresult GetLabel(nsXPIDLString& aLabel);
 
   PRBool IsFileBrowseButton(PRInt32 type); // Browse button of file input
 
+  virtual PRBool IsInput() { return PR_TRUE; }
 private:
   nsSize mSuggestedSize;
   nsCOMPtr<nsIContent> mTextContent;
 };
 
 
 #endif
 
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -127,36 +127,16 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::
 #endif
 
 nsIAtom*
 nsHTMLButtonControlFrame::GetType() const
 {
   return nsGkAtoms::HTMLButtonControlFrame;
 }
 
-PRBool
-nsHTMLButtonControlFrame::IsReset(PRInt32 type)
-{
-  if (NS_FORM_BUTTON_RESET == type) {
-    return PR_TRUE;
-  } else {
-    return PR_FALSE;
-  }
-}
-
-PRBool
-nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
-{
-  if (NS_FORM_BUTTON_SUBMIT == type) {
-    return PR_TRUE;
-  } else {
-    return PR_FALSE;
-  }
-}
-
 void 
 nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
 {
 }
 
 NS_IMETHODIMP
 nsHTMLButtonControlFrame::HandleEvent(nsPresContext* aPresContext, 
                                       nsGUIEvent*     aEvent,
@@ -192,29 +172,29 @@ nsHTMLButtonControlFrame::BuildDisplayLi
                                DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT);
     NS_ENSURE_SUCCESS(rv, rv);
     // That should put the display items in set.Content()
   }
   
   // Put the foreground outline and focus rects on top of the children
   set.Content()->AppendToTop(&onTop);
 
-    // XXX This is temporary
-  // clips to its size minus the border 
-  // but the real problem is the FirstChild (the AreaFrame)
-  // isn't being constrained properly
-  // Bug #17474
-  nsMargin border = GetStyleBorder()->GetActualBorder();
-  nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
-  rect.Deflate(border);
+  // clips to our padding box for <input>s but not <button>s.
+  if (IsInput()) {
+    nsMargin border = GetStyleBorder()->GetActualBorder();
+    nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
+    rect.Deflate(border);
   
-  nsresult rv = OverflowClip(aBuilder, set, aLists, rect);
-  NS_ENSURE_SUCCESS(rv, rv);
+    nsresult rv = OverflowClip(aBuilder, set, aLists, rect);
+    NS_ENSURE_SUCCESS(rv, rv);
+  } else {
+    set.MoveTo(aLists);
+  }
   
-  rv = DisplayOutline(aBuilder, aLists);
+  nsresult rv = DisplayOutline(aBuilder, aLists);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // to draw border when selected in editor
   return DisplaySelectionOverlay(aBuilder, aLists);
 }
 
 nscoord
 nsHTMLButtonControlFrame::GetMinWidth(nsIRenderingContext* aRenderingContext)
--- a/layout/forms/nsHTMLButtonControlFrame.h
+++ b/layout/forms/nsHTMLButtonControlFrame.h
@@ -130,18 +130,17 @@ public:
 
   virtual PRBool IsFrameOfType(PRUint32 aFlags) const
   {
     return nsHTMLContainerFrame::IsFrameOfType(aFlags &
       ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
   }
 
 protected:
-  virtual PRBool IsReset(PRInt32 type);
-  virtual PRBool IsSubmit(PRInt32 type);
+  virtual PRBool IsInput() { return PR_FALSE; }
   void ReflowButtonContents(nsPresContext* aPresContext,
                             nsHTMLReflowMetrics& aDesiredSize,
                             const nsHTMLReflowState& aReflowState,
                             nsIFrame* aFirstKid,
                             nsMargin aFocusPadding,
                             nsReflowStatus& aStatus);
 
   PRIntn GetSkipSides() const;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/491180-1-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html>
+  <div style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 0; height: 0; font: inherit; padding: 1px 3px">
+    Some text <div style="background: green; width: 100px; height: 100px"></div>
+  </div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/491180-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+  <button style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 0; height: 0; font: inherit">
+    Some text <div style="background: green; width: 100px; height: 100px"></div>
+  </button>
+</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/491180-2-ref.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html>
+  <div style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 14px; font: inherit; padding: 1px 3px; white-space: pre; overflow: hidden">Some text</div>
+  </div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/491180-2.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html>
+  <input type="button" style="padding: 0; margin: 0; border: none; background: transparent; -moz-appearance: none; width: 20px; font: inherit" value="Some text">
+</div>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1240,22 +1240,24 @@ fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 
 == 486052-2f.html 486052-2-ref.html
 == 486052-2g.html 486052-2-ref.html
 == 486848-1.xul 486848-1-ref.xul
 == 487539-1.html about:blank
 == 488390-1.html 488390-1-ref.html
 == 488649-1.html 488649-1-ref.html
 == 488685-1.html 488685-1-ref.html
 fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs EXTEND_PAD on non-Mac for correct scaling behaviour
-== 492661-1.html 492661-1-ref.html
 == 490182-1a.html 490182-1-ref.html
 == 490182-1b.html 490182-1-ref.html
 == 490173-1.html 490173-1-ref.html
 == 490173-2.html 490173-2-ref.html
+== 491180-1.html 491180-1-ref.html
+== 491180-2.html 491180-2-ref.html
 == 491323-1.xul 491323-1-ref.xul
+== 492661-1.html 492661-1-ref.html
 == 493968-1.html 493968-1-ref.html
 == 494667-1.html 494667-1-ref.html
 == 494667-2.html 494667-2-ref.html
 == 495274-1.html 495274-1-ref.html
 == 495385-1a.html 495385-1-ref.html
 == 495385-1b.html 495385-1-ref.html
 == 495385-1c.html 495385-1-ref.html
 == 495385-1d.html 495385-1-ref.html