diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index 69d92bc869c2..0c26ef1d049d 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -264,16 +264,18 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) float p2t; mPart->GetAttributeCount(attrCount); aPresContext->GetScaledPixelsToTwips(p2t); + nscoord bodyMarginWidth = -1; + nscoord bodyMarginHeight = -1; if (0 < attrCount) { // if marginwidth/marginheigth is set reflect them as 'margin' mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value); if (eHTMLUnit_Pixel == value.GetUnit()) { - nscoord marginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t); - if (marginWidth < 0) { - marginWidth = 0; + bodyMarginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + if (bodyMarginWidth < 0) { + bodyMarginWidth = 0; } - nsStyleCoord widthCoord(marginWidth); + nsStyleCoord widthCoord(bodyMarginWidth); styleSpacing->mMargin.SetLeft(widthCoord); styleSpacing->mMargin.SetRight(widthCoord); count++; @@ -281,12 +283,12 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value); if (eHTMLUnit_Pixel == value.GetUnit()) { - nscoord marginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t); - if (marginHeight < 0) { - marginHeight = 0; + bodyMarginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + if (bodyMarginHeight < 0) { + bodyMarginHeight = 0; } - nsStyleCoord heightCoord(marginHeight); + nsStyleCoord heightCoord(bodyMarginHeight); styleSpacing->mMargin.SetTop(heightCoord); styleSpacing->mMargin.SetBottom(heightCoord); count++; @@ -300,33 +302,53 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) } // XXX This is all pretty hokey... - if (count < 2) { - // if marginwidth or marginheight is set in the web shell reflect them - // as margin + + // if marginwidth or marginheight is set in the and not set in the + // reflect them as margin in the + if ((0 > bodyMarginWidth) || (0 > bodyMarginHeight)) { nsISupports* container; aPresContext->GetContainer(&container); if (nsnull != container) { + nsCompatibility mode; + aPresContext->GetCompatibilityMode(mode); nsIWebShell* webShell = nsnull; container->QueryInterface(kIWebShellIID, (void**) &webShell); if (nsnull != webShell) { - PRInt32 marginWidth, marginHeight; - webShell->GetMarginWidth(marginWidth); // -1 indicates not set - webShell->GetMarginHeight(marginHeight); // -1 indicates not set - if ((marginWidth >= 0) && (marginHeight < 0)) { // nav quirk - marginHeight = 0; + nscoord pixel = NSIntPixelsToTwips(1, p2t); + nscoord frameMarginWidth, frameMarginHeight; + webShell->GetMarginWidth(frameMarginWidth); // -1 indicates not set + webShell->GetMarginHeight(frameMarginHeight); + if ((frameMarginWidth >= 0) && (0 > bodyMarginWidth)) { // set in & not in + if (eCompatibility_NavQuirks == mode) { // allow 0 margins + if ((0 > bodyMarginHeight) && (0 > frameMarginHeight)) { // another nav quirk + frameMarginHeight = 0; + } + } else { // margins are at least 1 pixel + if (0 == frameMarginWidth) { + frameMarginWidth = pixel; + } + } } - if ((marginHeight >= 0) && (marginWidth < 0)) { // nav quirk - marginWidth = 0; + if ((frameMarginHeight >= 0) && (0 > bodyMarginHeight)) { // set in & not in + if (eCompatibility_NavQuirks == mode) { // allow 0 margins + if ((0 > bodyMarginWidth) && (0 > frameMarginWidth)) { // another nav quirk + frameMarginWidth = 0; + } + } else { // margins are at least 1 pixel + if (0 == frameMarginHeight) { + frameMarginHeight = pixel; + } + } } - if (marginWidth > 0) { - nsStyleCoord widthCoord(NSIntPixelsToTwips(marginWidth, p2t)); + if ((0 > bodyMarginWidth) && (frameMarginWidth >= 0)) { + nsStyleCoord widthCoord(frameMarginWidth); styleSpacing->mMargin.SetLeft(widthCoord); styleSpacing->mMargin.SetRight(widthCoord); } - if (marginHeight > 0) { - nsStyleCoord heightCoord(NSIntPixelsToTwips(marginHeight, p2t)); + if ((0 > bodyMarginHeight) && (frameMarginHeight >= 0)) { + nsStyleCoord heightCoord(frameMarginHeight); styleSpacing->mMargin.SetTop(heightCoord); styleSpacing->mMargin.SetBottom(heightCoord); } @@ -486,6 +508,7 @@ BodyFixupRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont NS_RELEASE(parentContext); } + return NS_OK; } diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index f6ca53424e4b..37d1ef99dbc6 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -1305,9 +1305,11 @@ HTMLContentSink::HTMLContentSink() gSinkLogModuleInfo = PR_NewLogModule("htmlcontentsink"); } #endif - mNotAtRef = PR_TRUE; - mParser = nsnull; + mNotAtRef = PR_TRUE; + mParser = nsnull; mDocumentBaseURL = nsnull; + mBody = nsnull; + mFrameset = nsnull; } HTMLContentSink::~HTMLContentSink() @@ -1915,10 +1917,25 @@ HTMLContentSink::StartLayout() } mLayoutStarted = PR_TRUE; - // If it's a frameset document then disable scrolling; otherwise, let the + // determine if this is a top level frameset + PRBool topLevelFrameset = PR_FALSE; + if (mFrameset && mWebShell) { + nsIWebShell* rootWebShell; + mWebShell->GetRootWebShell(rootWebShell); + if (mWebShell == rootWebShell) { + topLevelFrameset = PR_TRUE; + } + NS_IF_RELEASE(rootWebShell); + } + + // If it's a top level frameset document then disable scrolling; otherwise, let the // style dictate. We need to do this before the initial reflow... if (mWebShell) { - mWebShell->SetScrolling(mFrameset ? NS_STYLE_OVERFLOW_HIDDEN : -1); + if (topLevelFrameset) { + mWebShell->SetScrolling(NS_STYLE_OVERFLOW_HIDDEN); + } else if (mBody) { + // mWebShell->SetScrolling(-1); + } } PRInt32 i, ns = mDocument->GetNumberOfShells(); @@ -1953,15 +1970,6 @@ HTMLContentSink::StartLayout() if (rv == NS_OK) { mRef = new nsString(ref); } - PRBool topLevelFrameset = PR_FALSE; - if (mFrameset && mWebShell) { - nsIWebShell* rootWebShell; - mWebShell->GetRootWebShell(rootWebShell); - if (mWebShell == rootWebShell) { - topLevelFrameset = PR_TRUE; - } - NS_IF_RELEASE(rootWebShell); - } if ((nsnull != ref) || topLevelFrameset) { // XXX support more than one presentation-shell here diff --git a/content/html/style/src/nsHTMLStyleSheet.cpp b/content/html/style/src/nsHTMLStyleSheet.cpp index 90f93a6901b8..08b8fa8952d2 100644 --- a/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/content/html/style/src/nsHTMLStyleSheet.cpp @@ -1314,9 +1314,16 @@ HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext* aPresContext, break; default: - // XXX For the time being ignore everything else. We should deal with - // things like table cells and create anonymous frames... - break; + // For non table related frames (e.g. forms) make them children of the outer table frame + // XXX also need to deal with things like table cells and create anonymous frames... + nsIFrame* nonTableRelatedFrame; + nsIAtom* tag; + childContent->GetTag(tag); + ConstructFrameByTag(aPresContext, childContent, aNewFrame, tag, childStyleContext, + aAbsoluteItems, nonTableRelatedFrame); + childList->SetNextSibling(nonTableRelatedFrame); + NS_IF_RELEASE(tag); + break; } // If it's not a caption frame, then link the frame into the inner @@ -1482,12 +1489,11 @@ HTMLStyleSheetImpl::ConstructDocElementFrame(nsIPresContext* aPresContext, // Unless the 'overflow' policy forbids scrolling, wrap the frame in a // scroll frame. nsIFrame* scrollFrame = nsnull; - PRInt32 scrolling = -1; - const nsStyleDisplay* display = (const nsStyleDisplay*) - styleContext->GetStyleData(eStyleStruct_Display); - - // XXX Check the webshell and see if scrolling is enabled there. This needs - // to go away... + nsStyleDisplay* display = (nsStyleDisplay*) + styleContext->GetMutableStyleData(eStyleStruct_Display); + + // XXX This needs to go away... Yes, but where. + // Check the webshell and see if scrolling is enabled there. nsISupports* container; if (nsnull != aPresContext) { aPresContext->GetContainer(&container); @@ -1495,17 +1501,18 @@ HTMLStyleSheetImpl::ConstructDocElementFrame(nsIPresContext* aPresContext, nsIWebShell* webShell = nsnull; container->QueryInterface(kIWebShellIID, (void**) &webShell); if (nsnull != webShell) { + PRInt32 scrolling = -1; webShell->GetScrolling(scrolling); + if (-1 != scrolling) { + display->mOverflow = scrolling; + } NS_RELEASE(webShell); } NS_RELEASE(container); } } - if (-1 == scrolling) { - scrolling = display->mOverflow; - } - - if (NS_STYLE_OVERFLOW_HIDDEN != scrolling) { + + if (NS_STYLE_OVERFLOW_HIDDEN != display->mOverflow) { NS_NewScrollFrame(scrollFrame); scrollFrame->Init(*aPresContext, aDocElement, aRootFrame, styleContext); diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index 8818bbaa24f3..fdb777334555 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -298,6 +298,8 @@ public: nsresult DestroyPluginHost(void); protected: + void InitFrameData(); + PLEventQueue* mThreadEventQueue; nsIScriptGlobalObject *mScriptGlobal; nsIScriptContext* mScriptContext; @@ -434,9 +436,7 @@ nsWebShell::nsWebShell() mScrollPref = nsScrollPreference_kAuto; mScriptGlobal = nsnull; mScriptContext = nsnull; - mMarginWidth = -1; - mMarginHeight = -1; - mScrolling = -1; + InitFrameData(); } nsWebShell::~nsWebShell() @@ -466,6 +466,8 @@ nsWebShell::~nsWebShell() } NS_IF_RELEASE(mScriptContext); + InitFrameData(); + // XXX Because we hold references to the children and they hold references // to us we never get destroyed. See Destroy() instead... #if 0 @@ -483,6 +485,13 @@ nsWebShell::~nsWebShell() DestroyPluginHost(); } +void nsWebShell::InitFrameData() +{ + mMarginWidth = -1; + mMarginHeight = -1; + mScrolling = -1; +} + void nsWebShell::ReleaseChildren() { @@ -1200,6 +1209,13 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, nsURLReloadType aType, const PRUint32 aLocalIP) { + // if this is the top level web shell, initialize some things, in case the + // web shell is being recycled + nsIWebShell *rootWebShell; + GetRootWebShell(rootWebShell); + if (this == rootWebShell) { + InitFrameData(); + } return LoadURL(aURLSpec,"view",aPostData,aModifyHistory,aType, aLocalIP); } diff --git a/layout/html/content/src/nsHTMLBodyElement.cpp b/layout/html/content/src/nsHTMLBodyElement.cpp index 69d92bc869c2..0c26ef1d049d 100644 --- a/layout/html/content/src/nsHTMLBodyElement.cpp +++ b/layout/html/content/src/nsHTMLBodyElement.cpp @@ -264,16 +264,18 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) float p2t; mPart->GetAttributeCount(attrCount); aPresContext->GetScaledPixelsToTwips(p2t); + nscoord bodyMarginWidth = -1; + nscoord bodyMarginHeight = -1; if (0 < attrCount) { // if marginwidth/marginheigth is set reflect them as 'margin' mPart->GetHTMLAttribute(nsHTMLAtoms::marginwidth, value); if (eHTMLUnit_Pixel == value.GetUnit()) { - nscoord marginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t); - if (marginWidth < 0) { - marginWidth = 0; + bodyMarginWidth = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + if (bodyMarginWidth < 0) { + bodyMarginWidth = 0; } - nsStyleCoord widthCoord(marginWidth); + nsStyleCoord widthCoord(bodyMarginWidth); styleSpacing->mMargin.SetLeft(widthCoord); styleSpacing->mMargin.SetRight(widthCoord); count++; @@ -281,12 +283,12 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) mPart->GetHTMLAttribute(nsHTMLAtoms::marginheight, value); if (eHTMLUnit_Pixel == value.GetUnit()) { - nscoord marginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t); - if (marginHeight < 0) { - marginHeight = 0; + bodyMarginHeight = NSIntPixelsToTwips(value.GetPixelValue(), p2t); + if (bodyMarginHeight < 0) { + bodyMarginHeight = 0; } - nsStyleCoord heightCoord(marginHeight); + nsStyleCoord heightCoord(bodyMarginHeight); styleSpacing->mMargin.SetTop(heightCoord); styleSpacing->mMargin.SetBottom(heightCoord); count++; @@ -300,33 +302,53 @@ BodyRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresContext) } // XXX This is all pretty hokey... - if (count < 2) { - // if marginwidth or marginheight is set in the web shell reflect them - // as margin + + // if marginwidth or marginheight is set in the and not set in the + // reflect them as margin in the + if ((0 > bodyMarginWidth) || (0 > bodyMarginHeight)) { nsISupports* container; aPresContext->GetContainer(&container); if (nsnull != container) { + nsCompatibility mode; + aPresContext->GetCompatibilityMode(mode); nsIWebShell* webShell = nsnull; container->QueryInterface(kIWebShellIID, (void**) &webShell); if (nsnull != webShell) { - PRInt32 marginWidth, marginHeight; - webShell->GetMarginWidth(marginWidth); // -1 indicates not set - webShell->GetMarginHeight(marginHeight); // -1 indicates not set - if ((marginWidth >= 0) && (marginHeight < 0)) { // nav quirk - marginHeight = 0; + nscoord pixel = NSIntPixelsToTwips(1, p2t); + nscoord frameMarginWidth, frameMarginHeight; + webShell->GetMarginWidth(frameMarginWidth); // -1 indicates not set + webShell->GetMarginHeight(frameMarginHeight); + if ((frameMarginWidth >= 0) && (0 > bodyMarginWidth)) { // set in & not in + if (eCompatibility_NavQuirks == mode) { // allow 0 margins + if ((0 > bodyMarginHeight) && (0 > frameMarginHeight)) { // another nav quirk + frameMarginHeight = 0; + } + } else { // margins are at least 1 pixel + if (0 == frameMarginWidth) { + frameMarginWidth = pixel; + } + } } - if ((marginHeight >= 0) && (marginWidth < 0)) { // nav quirk - marginWidth = 0; + if ((frameMarginHeight >= 0) && (0 > bodyMarginHeight)) { // set in & not in + if (eCompatibility_NavQuirks == mode) { // allow 0 margins + if ((0 > bodyMarginWidth) && (0 > frameMarginWidth)) { // another nav quirk + frameMarginWidth = 0; + } + } else { // margins are at least 1 pixel + if (0 == frameMarginHeight) { + frameMarginHeight = pixel; + } + } } - if (marginWidth > 0) { - nsStyleCoord widthCoord(NSIntPixelsToTwips(marginWidth, p2t)); + if ((0 > bodyMarginWidth) && (frameMarginWidth >= 0)) { + nsStyleCoord widthCoord(frameMarginWidth); styleSpacing->mMargin.SetLeft(widthCoord); styleSpacing->mMargin.SetRight(widthCoord); } - if (marginHeight > 0) { - nsStyleCoord heightCoord(NSIntPixelsToTwips(marginHeight, p2t)); + if ((0 > bodyMarginHeight) && (frameMarginHeight >= 0)) { + nsStyleCoord heightCoord(frameMarginHeight); styleSpacing->mMargin.SetTop(heightCoord); styleSpacing->mMargin.SetBottom(heightCoord); } @@ -486,6 +508,7 @@ BodyFixupRule::MapStyleInto(nsIStyleContext* aContext, nsIPresContext* aPresCont NS_RELEASE(parentContext); } + return NS_OK; } diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp index f6ca53424e4b..37d1ef99dbc6 100644 --- a/layout/html/document/src/nsHTMLContentSink.cpp +++ b/layout/html/document/src/nsHTMLContentSink.cpp @@ -1305,9 +1305,11 @@ HTMLContentSink::HTMLContentSink() gSinkLogModuleInfo = PR_NewLogModule("htmlcontentsink"); } #endif - mNotAtRef = PR_TRUE; - mParser = nsnull; + mNotAtRef = PR_TRUE; + mParser = nsnull; mDocumentBaseURL = nsnull; + mBody = nsnull; + mFrameset = nsnull; } HTMLContentSink::~HTMLContentSink() @@ -1915,10 +1917,25 @@ HTMLContentSink::StartLayout() } mLayoutStarted = PR_TRUE; - // If it's a frameset document then disable scrolling; otherwise, let the + // determine if this is a top level frameset + PRBool topLevelFrameset = PR_FALSE; + if (mFrameset && mWebShell) { + nsIWebShell* rootWebShell; + mWebShell->GetRootWebShell(rootWebShell); + if (mWebShell == rootWebShell) { + topLevelFrameset = PR_TRUE; + } + NS_IF_RELEASE(rootWebShell); + } + + // If it's a top level frameset document then disable scrolling; otherwise, let the // style dictate. We need to do this before the initial reflow... if (mWebShell) { - mWebShell->SetScrolling(mFrameset ? NS_STYLE_OVERFLOW_HIDDEN : -1); + if (topLevelFrameset) { + mWebShell->SetScrolling(NS_STYLE_OVERFLOW_HIDDEN); + } else if (mBody) { + // mWebShell->SetScrolling(-1); + } } PRInt32 i, ns = mDocument->GetNumberOfShells(); @@ -1953,15 +1970,6 @@ HTMLContentSink::StartLayout() if (rv == NS_OK) { mRef = new nsString(ref); } - PRBool topLevelFrameset = PR_FALSE; - if (mFrameset && mWebShell) { - nsIWebShell* rootWebShell; - mWebShell->GetRootWebShell(rootWebShell); - if (mWebShell == rootWebShell) { - topLevelFrameset = PR_TRUE; - } - NS_IF_RELEASE(rootWebShell); - } if ((nsnull != ref) || topLevelFrameset) { // XXX support more than one presentation-shell here diff --git a/layout/html/style/src/nsHTMLStyleSheet.cpp b/layout/html/style/src/nsHTMLStyleSheet.cpp index 90f93a6901b8..08b8fa8952d2 100644 --- a/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -1314,9 +1314,16 @@ HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext* aPresContext, break; default: - // XXX For the time being ignore everything else. We should deal with - // things like table cells and create anonymous frames... - break; + // For non table related frames (e.g. forms) make them children of the outer table frame + // XXX also need to deal with things like table cells and create anonymous frames... + nsIFrame* nonTableRelatedFrame; + nsIAtom* tag; + childContent->GetTag(tag); + ConstructFrameByTag(aPresContext, childContent, aNewFrame, tag, childStyleContext, + aAbsoluteItems, nonTableRelatedFrame); + childList->SetNextSibling(nonTableRelatedFrame); + NS_IF_RELEASE(tag); + break; } // If it's not a caption frame, then link the frame into the inner @@ -1482,12 +1489,11 @@ HTMLStyleSheetImpl::ConstructDocElementFrame(nsIPresContext* aPresContext, // Unless the 'overflow' policy forbids scrolling, wrap the frame in a // scroll frame. nsIFrame* scrollFrame = nsnull; - PRInt32 scrolling = -1; - const nsStyleDisplay* display = (const nsStyleDisplay*) - styleContext->GetStyleData(eStyleStruct_Display); - - // XXX Check the webshell and see if scrolling is enabled there. This needs - // to go away... + nsStyleDisplay* display = (nsStyleDisplay*) + styleContext->GetMutableStyleData(eStyleStruct_Display); + + // XXX This needs to go away... Yes, but where. + // Check the webshell and see if scrolling is enabled there. nsISupports* container; if (nsnull != aPresContext) { aPresContext->GetContainer(&container); @@ -1495,17 +1501,18 @@ HTMLStyleSheetImpl::ConstructDocElementFrame(nsIPresContext* aPresContext, nsIWebShell* webShell = nsnull; container->QueryInterface(kIWebShellIID, (void**) &webShell); if (nsnull != webShell) { + PRInt32 scrolling = -1; webShell->GetScrolling(scrolling); + if (-1 != scrolling) { + display->mOverflow = scrolling; + } NS_RELEASE(webShell); } NS_RELEASE(container); } } - if (-1 == scrolling) { - scrolling = display->mOverflow; - } - - if (NS_STYLE_OVERFLOW_HIDDEN != scrolling) { + + if (NS_STYLE_OVERFLOW_HIDDEN != display->mOverflow) { NS_NewScrollFrame(scrollFrame); scrollFrame->Init(*aPresContext, aDocElement, aRootFrame, styleContext); diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 90f93a6901b8..08b8fa8952d2 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -1314,9 +1314,16 @@ HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext* aPresContext, break; default: - // XXX For the time being ignore everything else. We should deal with - // things like table cells and create anonymous frames... - break; + // For non table related frames (e.g. forms) make them children of the outer table frame + // XXX also need to deal with things like table cells and create anonymous frames... + nsIFrame* nonTableRelatedFrame; + nsIAtom* tag; + childContent->GetTag(tag); + ConstructFrameByTag(aPresContext, childContent, aNewFrame, tag, childStyleContext, + aAbsoluteItems, nonTableRelatedFrame); + childList->SetNextSibling(nonTableRelatedFrame); + NS_IF_RELEASE(tag); + break; } // If it's not a caption frame, then link the frame into the inner @@ -1482,12 +1489,11 @@ HTMLStyleSheetImpl::ConstructDocElementFrame(nsIPresContext* aPresContext, // Unless the 'overflow' policy forbids scrolling, wrap the frame in a // scroll frame. nsIFrame* scrollFrame = nsnull; - PRInt32 scrolling = -1; - const nsStyleDisplay* display = (const nsStyleDisplay*) - styleContext->GetStyleData(eStyleStruct_Display); - - // XXX Check the webshell and see if scrolling is enabled there. This needs - // to go away... + nsStyleDisplay* display = (nsStyleDisplay*) + styleContext->GetMutableStyleData(eStyleStruct_Display); + + // XXX This needs to go away... Yes, but where. + // Check the webshell and see if scrolling is enabled there. nsISupports* container; if (nsnull != aPresContext) { aPresContext->GetContainer(&container); @@ -1495,17 +1501,18 @@ HTMLStyleSheetImpl::ConstructDocElementFrame(nsIPresContext* aPresContext, nsIWebShell* webShell = nsnull; container->QueryInterface(kIWebShellIID, (void**) &webShell); if (nsnull != webShell) { + PRInt32 scrolling = -1; webShell->GetScrolling(scrolling); + if (-1 != scrolling) { + display->mOverflow = scrolling; + } NS_RELEASE(webShell); } NS_RELEASE(container); } } - if (-1 == scrolling) { - scrolling = display->mOverflow; - } - - if (NS_STYLE_OVERFLOW_HIDDEN != scrolling) { + + if (NS_STYLE_OVERFLOW_HIDDEN != display->mOverflow) { NS_NewScrollFrame(scrollFrame); scrollFrame->Init(*aPresContext, aDocElement, aRootFrame, styleContext); diff --git a/webshell/src/nsWebShell.cpp b/webshell/src/nsWebShell.cpp index 8818bbaa24f3..fdb777334555 100644 --- a/webshell/src/nsWebShell.cpp +++ b/webshell/src/nsWebShell.cpp @@ -298,6 +298,8 @@ public: nsresult DestroyPluginHost(void); protected: + void InitFrameData(); + PLEventQueue* mThreadEventQueue; nsIScriptGlobalObject *mScriptGlobal; nsIScriptContext* mScriptContext; @@ -434,9 +436,7 @@ nsWebShell::nsWebShell() mScrollPref = nsScrollPreference_kAuto; mScriptGlobal = nsnull; mScriptContext = nsnull; - mMarginWidth = -1; - mMarginHeight = -1; - mScrolling = -1; + InitFrameData(); } nsWebShell::~nsWebShell() @@ -466,6 +466,8 @@ nsWebShell::~nsWebShell() } NS_IF_RELEASE(mScriptContext); + InitFrameData(); + // XXX Because we hold references to the children and they hold references // to us we never get destroyed. See Destroy() instead... #if 0 @@ -483,6 +485,13 @@ nsWebShell::~nsWebShell() DestroyPluginHost(); } +void nsWebShell::InitFrameData() +{ + mMarginWidth = -1; + mMarginHeight = -1; + mScrolling = -1; +} + void nsWebShell::ReleaseChildren() { @@ -1200,6 +1209,13 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, nsURLReloadType aType, const PRUint32 aLocalIP) { + // if this is the top level web shell, initialize some things, in case the + // web shell is being recycled + nsIWebShell *rootWebShell; + GetRootWebShell(rootWebShell); + if (this == rootWebShell) { + InitFrameData(); + } return LoadURL(aURLSpec,"view",aPostData,aModifyHistory,aType, aLocalIP); }