From 94d94c566e7a426095794f0b8c4eb70094487518 Mon Sep 17 00:00:00 2001 From: "hwaara%chello.se" Date: Mon, 3 Dec 2001 23:36:40 +0000 Subject: [PATCH] #78365, make scrolling="off" and scrolling="on" work for frameset elements. r=fabian, sr=attinasi --- layout/generic/nsFrameFrame.cpp | 43 ++++++++++++----------- layout/html/document/src/nsFrameFrame.cpp | 43 ++++++++++++----------- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index 35f51a38d526..9f010109d7d8 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -21,6 +21,7 @@ * * Contributor(s): * Travis Bogard + * Håkan Waara * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -249,7 +250,7 @@ public: NS_IMETHOD GetParentContent(nsIContent*& aContent); PRBool GetURL(nsIContent* aContent, nsString& aResult); PRBool GetName(nsIContent* aContent, nsString& aResult); - PRInt32 GetScrolling(nsIContent* aContent, PRBool aStandardMode); + PRInt32 GetScrolling(nsIContent* aContent); nsFrameborder GetFrameBorder(PRBool aStandardMode); PRInt32 GetMarginWidth(nsIPresContext* aPresContext, nsIContent* aContent); PRInt32 GetMarginHeight(nsIPresContext* aPresContext, nsIContent* aContent); @@ -732,31 +733,33 @@ PRBool nsHTMLFrameInnerFrame::GetName(nsIContent* aContent, nsString& aResult) return PR_FALSE; } -PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStandardMode) +PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent) { PRInt32 returnValue = -1; nsresult rv = NS_OK; nsCOMPtr content = do_QueryInterface(mContent, &rv); + if (NS_SUCCEEDED(rv) && content) { nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value)) { if (eHTMLUnit_Enumerated == value.GetUnit()) { - PRInt32 intValue; - intValue = value.GetIntValue(); - if (!aStandardMode) { - if ((NS_STYLE_FRAME_ON == intValue) || (NS_STYLE_FRAME_SCROLL == intValue)) { + switch (value.GetIntValue()) { + case NS_STYLE_FRAME_ON: + case NS_STYLE_FRAME_SCROLL: + case NS_STYLE_FRAME_YES: returnValue = NS_STYLE_OVERFLOW_SCROLL; - } else if ((NS_STYLE_FRAME_OFF == intValue) || (NS_STYLE_FRAME_NOSCROLL == intValue)) { + break; + + case NS_STYLE_FRAME_OFF: + case NS_STYLE_FRAME_NOSCROLL: + case NS_STYLE_FRAME_NO: returnValue = NS_STYLE_OVERFLOW_HIDDEN; - } - } else { - if (NS_STYLE_FRAME_YES == intValue) { - returnValue = NS_STYLE_OVERFLOW_SCROLL; - } else if (NS_STYLE_FRAME_NO == intValue) { - returnValue = NS_STYLE_OVERFLOW_HIDDEN; - } else if (NS_STYLE_FRAME_AUTO == intValue) { + break; + + case NS_STYLE_FRAME_AUTO: + default: returnValue = NS_STYLE_OVERFLOW_AUTO; - } + break; } } } @@ -766,7 +769,6 @@ PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStanda GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display)); if (display->mOverflow) returnValue = display->mOverflow; - } return returnValue; } @@ -1042,17 +1044,16 @@ nsHTMLFrameInnerFrame::CreateDocShell(nsIPresContext* aPresContext) // pass along marginwidth, marginheight, scrolling so sub document can use it docShell->SetMarginWidth(GetMarginWidth(aPresContext, parentContent)); docShell->SetMarginHeight(GetMarginHeight(aPresContext, parentContent)); - nsCompatibility mode; - aPresContext->GetCompatibilityMode(&mode); + // Current and initial scrolling is set so that all succeeding docs // will use the scrolling value set here, regardless if scrolling is // set by viewing a particular document (e.g. XUL turns off scrolling) nsCOMPtr scrollableContainer(do_QueryInterface(mSubShell)); if (scrollableContainer) { scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, - GetScrolling(parentContent, mode)); + GetScrolling(parentContent)); scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, - GetScrolling(parentContent, mode)); + GetScrolling(parentContent)); } nsCOMPtr docShellAsItem(do_QueryInterface(mSubShell)); diff --git a/layout/html/document/src/nsFrameFrame.cpp b/layout/html/document/src/nsFrameFrame.cpp index 35f51a38d526..9f010109d7d8 100644 --- a/layout/html/document/src/nsFrameFrame.cpp +++ b/layout/html/document/src/nsFrameFrame.cpp @@ -21,6 +21,7 @@ * * Contributor(s): * Travis Bogard + * Håkan Waara * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -249,7 +250,7 @@ public: NS_IMETHOD GetParentContent(nsIContent*& aContent); PRBool GetURL(nsIContent* aContent, nsString& aResult); PRBool GetName(nsIContent* aContent, nsString& aResult); - PRInt32 GetScrolling(nsIContent* aContent, PRBool aStandardMode); + PRInt32 GetScrolling(nsIContent* aContent); nsFrameborder GetFrameBorder(PRBool aStandardMode); PRInt32 GetMarginWidth(nsIPresContext* aPresContext, nsIContent* aContent); PRInt32 GetMarginHeight(nsIPresContext* aPresContext, nsIContent* aContent); @@ -732,31 +733,33 @@ PRBool nsHTMLFrameInnerFrame::GetName(nsIContent* aContent, nsString& aResult) return PR_FALSE; } -PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStandardMode) +PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent) { PRInt32 returnValue = -1; nsresult rv = NS_OK; nsCOMPtr content = do_QueryInterface(mContent, &rv); + if (NS_SUCCEEDED(rv) && content) { nsHTMLValue value; - if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value))) { + if (NS_CONTENT_ATTR_HAS_VALUE == content->GetHTMLAttribute(nsHTMLAtoms::scrolling, value)) { if (eHTMLUnit_Enumerated == value.GetUnit()) { - PRInt32 intValue; - intValue = value.GetIntValue(); - if (!aStandardMode) { - if ((NS_STYLE_FRAME_ON == intValue) || (NS_STYLE_FRAME_SCROLL == intValue)) { + switch (value.GetIntValue()) { + case NS_STYLE_FRAME_ON: + case NS_STYLE_FRAME_SCROLL: + case NS_STYLE_FRAME_YES: returnValue = NS_STYLE_OVERFLOW_SCROLL; - } else if ((NS_STYLE_FRAME_OFF == intValue) || (NS_STYLE_FRAME_NOSCROLL == intValue)) { + break; + + case NS_STYLE_FRAME_OFF: + case NS_STYLE_FRAME_NOSCROLL: + case NS_STYLE_FRAME_NO: returnValue = NS_STYLE_OVERFLOW_HIDDEN; - } - } else { - if (NS_STYLE_FRAME_YES == intValue) { - returnValue = NS_STYLE_OVERFLOW_SCROLL; - } else if (NS_STYLE_FRAME_NO == intValue) { - returnValue = NS_STYLE_OVERFLOW_HIDDEN; - } else if (NS_STYLE_FRAME_AUTO == intValue) { + break; + + case NS_STYLE_FRAME_AUTO: + default: returnValue = NS_STYLE_OVERFLOW_AUTO; - } + break; } } } @@ -766,7 +769,6 @@ PRInt32 nsHTMLFrameInnerFrame::GetScrolling(nsIContent* aContent, PRBool aStanda GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)display)); if (display->mOverflow) returnValue = display->mOverflow; - } return returnValue; } @@ -1042,17 +1044,16 @@ nsHTMLFrameInnerFrame::CreateDocShell(nsIPresContext* aPresContext) // pass along marginwidth, marginheight, scrolling so sub document can use it docShell->SetMarginWidth(GetMarginWidth(aPresContext, parentContent)); docShell->SetMarginHeight(GetMarginHeight(aPresContext, parentContent)); - nsCompatibility mode; - aPresContext->GetCompatibilityMode(&mode); + // Current and initial scrolling is set so that all succeeding docs // will use the scrolling value set here, regardless if scrolling is // set by viewing a particular document (e.g. XUL turns off scrolling) nsCOMPtr scrollableContainer(do_QueryInterface(mSubShell)); if (scrollableContainer) { scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, - GetScrolling(parentContent, mode)); + GetScrolling(parentContent)); scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, - GetScrolling(parentContent, mode)); + GetScrolling(parentContent)); } nsCOMPtr docShellAsItem(do_QueryInterface(mSubShell));