From 462cb0cabd17e48e06afb66a8737e730ad83eaa9 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Fri, 3 Sep 2004 23:22:15 +0000 Subject: [PATCH] Land bug 72747 in pieces: use CSS instead of C++ to ensure single line text inputs don't have scrollbars. b=72747 r+sr=roc --- layout/base/public/nsIScrollableFrame.h | 9 --------- layout/forms/nsTextControlFrame.cpp | 12 +----------- layout/generic/nsGfxScrollFrame.cpp | 12 ------------ layout/generic/nsIScrollableFrame.h | 9 --------- layout/html/base/src/nsGfxScrollFrame.cpp | 12 ------------ layout/html/base/src/nsGfxScrollFrame.h | 8 -------- layout/html/document/src/forms.css | 9 +++++---- layout/html/forms/src/nsTextControlFrame.cpp | 12 +----------- layout/style/forms.css | 9 +++++---- 9 files changed, 12 insertions(+), 80 deletions(-) diff --git a/layout/base/public/nsIScrollableFrame.h b/layout/base/public/nsIScrollableFrame.h index 6907cae2854..be4a2c7ad39 100644 --- a/layout/base/public/nsIScrollableFrame.h +++ b/layout/base/public/nsIScrollableFrame.h @@ -105,15 +105,6 @@ public: NS_IMETHOD GetScrollableView(nsPresContext* aContext, nsIScrollableView** aResult)=0; - - /** - * Set information about whether the vertical and horizontal scrollbars - * are currently visible - */ - NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext, - PRBool aVerticalVisible, - PRBool aHorizontalVisible) = 0; - NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult) = 0; NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext, diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 602a168a2be..ed7acf3fd30 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1876,7 +1876,7 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext, // make sure the the form registers itself on the initial/first reflow if (mState & NS_FRAME_FIRST_REFLOW) { - nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE); + nsFormControlFrame::RegUnRegAccessKey(aPresContext, this, PR_TRUE); mNotifyOnInput = PR_TRUE;//its ok to notify now. all has been prepared. } @@ -2996,16 +2996,6 @@ nsTextControlFrame::SetInitialChildList(nsPresContext* aPresContext, // than descending from the root frame of the frame hierarchy. first->AddStateBits(NS_FRAME_REFLOW_ROOT); -//we must turn off scrollbars for singleline text controls - if (IsSingleLineTextControl()) - { - nsIScrollableFrame *scrollableFrame = nsnull; - if (first) - first->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void **) &scrollableFrame); - if (scrollableFrame) - scrollableFrame->SetScrollbarVisibility(aPresContext,PR_FALSE,PR_FALSE); - } - //register keylistener nsCOMPtr erP; if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index c52956cad79..9066b3af5c8 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -64,7 +64,6 @@ #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" #include "nsITextControlFrame.h" -#include "nsIDOMHTMLTextAreaElement.h" #include "nsNodeInfoManager.h" #include "nsIURI.h" #include "nsGUIEvent.h" @@ -1275,17 +1274,6 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr if (shell) document = shell->GetDocument(); - // The anonymous
used by never gets scrollbars. - nsCOMPtr textFrame(do_QueryInterface(parent)); - if (textFrame) { - // Make sure we are not a text area. - nsCOMPtr textAreaElement(do_QueryInterface(parent->GetContent())); - if (!textAreaElement) { - mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE; - return; - } - } - // create horizontal scrollbar if (!document) { return; diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index 6907cae2854..be4a2c7ad39 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -105,15 +105,6 @@ public: NS_IMETHOD GetScrollableView(nsPresContext* aContext, nsIScrollableView** aResult)=0; - - /** - * Set information about whether the vertical and horizontal scrollbars - * are currently visible - */ - NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext, - PRBool aVerticalVisible, - PRBool aHorizontalVisible) = 0; - NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult) = 0; NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext, diff --git a/layout/html/base/src/nsGfxScrollFrame.cpp b/layout/html/base/src/nsGfxScrollFrame.cpp index c52956cad79..9066b3af5c8 100644 --- a/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/layout/html/base/src/nsGfxScrollFrame.cpp @@ -64,7 +64,6 @@ #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" #include "nsITextControlFrame.h" -#include "nsIDOMHTMLTextAreaElement.h" #include "nsNodeInfoManager.h" #include "nsIURI.h" #include "nsGUIEvent.h" @@ -1275,17 +1274,6 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr if (shell) document = shell->GetDocument(); - // The anonymous
used by never gets scrollbars. - nsCOMPtr textFrame(do_QueryInterface(parent)); - if (textFrame) { - // Make sure we are not a text area. - nsCOMPtr textAreaElement(do_QueryInterface(parent->GetContent())); - if (!textAreaElement) { - mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE; - return; - } - } - // create horizontal scrollbar if (!document) { return; diff --git a/layout/html/base/src/nsGfxScrollFrame.h b/layout/html/base/src/nsGfxScrollFrame.h index cd011bf3ff5..a1dc81372aa 100644 --- a/layout/html/base/src/nsGfxScrollFrame.h +++ b/layout/html/base/src/nsGfxScrollFrame.h @@ -244,10 +244,6 @@ public: NS_IMETHOD GetScrollPosition(nsPresContext* aContext, nscoord &aX, nscoord& aY) const; NS_IMETHOD ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags); - NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext, - PRBool aVerticalVisible, - PRBool aHorizontalVisible); - NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult); NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext, @@ -377,10 +373,6 @@ public: NS_IMETHOD GetScrollPosition(nsPresContext* aContext, nscoord &aX, nscoord& aY) const; NS_IMETHOD ScrollTo(nsPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags); - NS_IMETHOD SetScrollbarVisibility(nsPresContext* aPresContext, - PRBool aVerticalVisible, - PRBool aHorizontalVisible); - NS_IMETHOD GetScrollbarBox(PRBool aVertical, nsIBox** aResult); NS_IMETHOD CurPosAttributeChanged(nsPresContext* aPresContext, diff --git a/layout/html/document/src/forms.css b/layout/html/document/src/forms.css index e23e8697c55..5c31b5c39d9 100644 --- a/layout/html/document/src/forms.css +++ b/layout/html/document/src/forms.css @@ -98,10 +98,6 @@ input { text-indent: 0; } -input > .anonymous-div { - white-space : nowrap; -} - textarea { margin: 1px 0 1px 0; border: 2px inset ThreeDFace; @@ -136,6 +132,11 @@ input > .anonymous-div { text-decoration: inherit; } +input > .anonymous-div { + white-space : nowrap; + overflow: hidden ! important; +} + select { margin: 0; border-color: ThreeDFace; diff --git a/layout/html/forms/src/nsTextControlFrame.cpp b/layout/html/forms/src/nsTextControlFrame.cpp index 602a168a2be..ed7acf3fd30 100644 --- a/layout/html/forms/src/nsTextControlFrame.cpp +++ b/layout/html/forms/src/nsTextControlFrame.cpp @@ -1876,7 +1876,7 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext, // make sure the the form registers itself on the initial/first reflow if (mState & NS_FRAME_FIRST_REFLOW) { - nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE); + nsFormControlFrame::RegUnRegAccessKey(aPresContext, this, PR_TRUE); mNotifyOnInput = PR_TRUE;//its ok to notify now. all has been prepared. } @@ -2996,16 +2996,6 @@ nsTextControlFrame::SetInitialChildList(nsPresContext* aPresContext, // than descending from the root frame of the frame hierarchy. first->AddStateBits(NS_FRAME_REFLOW_ROOT); -//we must turn off scrollbars for singleline text controls - if (IsSingleLineTextControl()) - { - nsIScrollableFrame *scrollableFrame = nsnull; - if (first) - first->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void **) &scrollableFrame); - if (scrollableFrame) - scrollableFrame->SetScrollbarVisibility(aPresContext,PR_FALSE,PR_FALSE); - } - //register keylistener nsCOMPtr erP; if (NS_SUCCEEDED(mContent->QueryInterface(NS_GET_IID(nsIDOMEventReceiver), getter_AddRefs(erP))) && erP) diff --git a/layout/style/forms.css b/layout/style/forms.css index e23e8697c55..5c31b5c39d9 100644 --- a/layout/style/forms.css +++ b/layout/style/forms.css @@ -98,10 +98,6 @@ input { text-indent: 0; } -input > .anonymous-div { - white-space : nowrap; -} - textarea { margin: 1px 0 1px 0; border: 2px inset ThreeDFace; @@ -136,6 +132,11 @@ input > .anonymous-div { text-decoration: inherit; } +input > .anonymous-div { + white-space : nowrap; + overflow: hidden ! important; +} + select { margin: 0; border-color: ThreeDFace;