diff --git a/layout/base/public/nsIScrollableFrame.h b/layout/base/public/nsIScrollableFrame.h index be4a2c7ad39..6907cae2854 100644 --- a/layout/base/public/nsIScrollableFrame.h +++ b/layout/base/public/nsIScrollableFrame.h @@ -105,6 +105,15 @@ 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 ed7acf3fd30..11575aa59f5 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -2996,6 +2996,16 @@ 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 f245c31ecf4..b70979481e2 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -64,6 +64,7 @@ #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" #include "nsITextControlFrame.h" +#include "nsIDOMHTMLTextAreaElement.h" #include "nsNodeInfoManager.h" #include "nsIURI.h" #include "nsGUIEvent.h" @@ -1136,6 +1137,8 @@ nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsBoxFrame* aOuter) mOuter(aOuter), mMaxElementWidth(0), mLastDir(-1), + mNeverHasVerticalScrollbar(PR_FALSE), + mNeverHasHorizontalScrollbar(PR_FALSE), mHasVerticalScrollbar(PR_FALSE), mHasHorizontalScrollbar(PR_FALSE), mFirstPass(PR_FALSE), @@ -1262,9 +1265,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr // allow scrollbars if this is the child of the viewport, because // we must be the scrollbars for the print preview window if (!parent || parent->GetType() != nsLayoutAtoms::viewportFrame) { - // If we just return early here, we'll never create content or - // frames an |mHScrollbarBox| and |mVScrollbarBox| will always be - // null. + mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE; return; } } @@ -1279,6 +1280,17 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr // Nothing to do. return; + // 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; + } + } + nsNodeInfoManager *nodeInfoManager = presContext->GetDocument()->NodeInfoManager(); nsCOMPtr nodeInfo; @@ -1549,7 +1561,7 @@ PRBool nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop, PRBool aHorizontal, PRBool aAdd) { if (aHorizontal) { - if (!mHScrollbarBox) + if (mNeverHasHorizontalScrollbar || !mHScrollbarBox) return PR_FALSE; nsSize hSize; @@ -1566,7 +1578,7 @@ nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScr return fit; } else { - if (!mVScrollbarBox) + if (mNeverHasVerticalScrollbar || !mVScrollbarBox) return PR_FALSE; nsSize vSize; diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index bf96f23316f..cd011bf3ff5 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -143,6 +143,9 @@ public: // value that indicates "not set") PRInt16 mLastDir; + PRPackedBool mNeverHasVerticalScrollbar; + PRPackedBool mNeverHasHorizontalScrollbar; + PRPackedBool mHasVerticalScrollbar; PRPackedBool mHasHorizontalScrollbar; PRPackedBool mFirstPass; @@ -241,6 +244,10 @@ 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, @@ -370,6 +377,10 @@ 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/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index be4a2c7ad39..6907cae2854 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -105,6 +105,15 @@ 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 f245c31ecf4..b70979481e2 100644 --- a/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/layout/html/base/src/nsGfxScrollFrame.cpp @@ -64,6 +64,7 @@ #include "nsIScrollbarFrame.h" #include "nsIScrollbarMediator.h" #include "nsITextControlFrame.h" +#include "nsIDOMHTMLTextAreaElement.h" #include "nsNodeInfoManager.h" #include "nsIURI.h" #include "nsGUIEvent.h" @@ -1136,6 +1137,8 @@ nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsBoxFrame* aOuter) mOuter(aOuter), mMaxElementWidth(0), mLastDir(-1), + mNeverHasVerticalScrollbar(PR_FALSE), + mNeverHasHorizontalScrollbar(PR_FALSE), mHasVerticalScrollbar(PR_FALSE), mHasHorizontalScrollbar(PR_FALSE), mFirstPass(PR_FALSE), @@ -1262,9 +1265,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr // allow scrollbars if this is the child of the viewport, because // we must be the scrollbars for the print preview window if (!parent || parent->GetType() != nsLayoutAtoms::viewportFrame) { - // If we just return early here, we'll never create content or - // frames an |mHScrollbarBox| and |mVScrollbarBox| will always be - // null. + mNeverHasVerticalScrollbar = mNeverHasHorizontalScrollbar = PR_TRUE; return; } } @@ -1279,6 +1280,17 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsISupportsArray& aAnonymousChildr // Nothing to do. return; + // 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; + } + } + nsNodeInfoManager *nodeInfoManager = presContext->GetDocument()->NodeInfoManager(); nsCOMPtr nodeInfo; @@ -1549,7 +1561,7 @@ PRBool nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop, PRBool aHorizontal, PRBool aAdd) { if (aHorizontal) { - if (!mHScrollbarBox) + if (mNeverHasHorizontalScrollbar || !mHScrollbarBox) return PR_FALSE; nsSize hSize; @@ -1566,7 +1578,7 @@ nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScr return fit; } else { - if (!mVScrollbarBox) + if (mNeverHasVerticalScrollbar || !mVScrollbarBox) return PR_FALSE; nsSize vSize; diff --git a/layout/html/base/src/nsGfxScrollFrame.h b/layout/html/base/src/nsGfxScrollFrame.h index bf96f23316f..cd011bf3ff5 100644 --- a/layout/html/base/src/nsGfxScrollFrame.h +++ b/layout/html/base/src/nsGfxScrollFrame.h @@ -143,6 +143,9 @@ public: // value that indicates "not set") PRInt16 mLastDir; + PRPackedBool mNeverHasVerticalScrollbar; + PRPackedBool mNeverHasHorizontalScrollbar; + PRPackedBool mHasVerticalScrollbar; PRPackedBool mHasHorizontalScrollbar; PRPackedBool mFirstPass; @@ -241,6 +244,10 @@ 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, @@ -370,6 +377,10 @@ 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 5c31b5c39d9..e23e8697c55 100644 --- a/layout/html/document/src/forms.css +++ b/layout/html/document/src/forms.css @@ -98,6 +98,10 @@ input { text-indent: 0; } +input > .anonymous-div { + white-space : nowrap; +} + textarea { margin: 1px 0 1px 0; border: 2px inset ThreeDFace; @@ -132,11 +136,6 @@ 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 ed7acf3fd30..11575aa59f5 100644 --- a/layout/html/forms/src/nsTextControlFrame.cpp +++ b/layout/html/forms/src/nsTextControlFrame.cpp @@ -2996,6 +2996,16 @@ 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 5c31b5c39d9..e23e8697c55 100644 --- a/layout/style/forms.css +++ b/layout/style/forms.css @@ -98,6 +98,10 @@ input { text-indent: 0; } +input > .anonymous-div { + white-space : nowrap; +} + textarea { margin: 1px 0 1px 0; border: 2px inset ThreeDFace; @@ -132,11 +136,6 @@ input > .anonymous-div { text-decoration: inherit; } -input > .anonymous-div { - white-space : nowrap; - overflow: hidden ! important; -} - select { margin: 0; border-color: ThreeDFace;