Bug 28670: Move scroll methods from webshell to docshell r=travis a=rickg
git-svn-id: svn://10.0.0.236/trunk@61848 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
62bf36964a
commit
8a83557c05
@ -93,6 +93,7 @@
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIScrollable.h"
|
||||
|
||||
#ifdef ALLOW_ASYNCH_STYLE_SHEETS
|
||||
const PRBool kBlock=PR_FALSE;
|
||||
@ -3023,11 +3024,19 @@ HTMLContentSink::StartLayout()
|
||||
mLastNotificationTime = PR_Now();
|
||||
|
||||
// If it's a frameset document then disable scrolling.
|
||||
// Scrolling was reset nsWebShell::LoadURL() by InitFrameData()
|
||||
// Else, reset scrolling to default settings for this shell.
|
||||
// This must happen before the initial reflow, when we create the root frame
|
||||
nsresult rv;
|
||||
if (mWebShell) {
|
||||
if (mFrameset) {
|
||||
mWebShell->SetScrolling(NS_STYLE_OVERFLOW_HIDDEN, PR_FALSE);
|
||||
}
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(mWebShell, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
if (mFrameset) {
|
||||
scrollableContainer->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
scrollableContainer->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
} else {
|
||||
scrollableContainer->ResetScrollbarPreferences();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
@ -3057,7 +3066,7 @@ HTMLContentSink::StartLayout()
|
||||
// frameset document, disable the scroll bars on the views.
|
||||
char* ref = nsnull; // init in case mDocumentURI is not a url
|
||||
nsIURL* url;
|
||||
nsresult rv = mDocumentURI->QueryInterface(NS_GET_IID(nsIURL), (void**)&url);
|
||||
rv = mDocumentURI->QueryInterface(NS_GET_IID(nsIURL), (void**)&url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = url->GetRef(&ref);
|
||||
NS_RELEASE(url);
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsPoint.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIGlobalHistory.h"
|
||||
@ -69,7 +70,9 @@ nsDocShell::nsDocShell() :
|
||||
mInitialPageLoad(PR_TRUE),
|
||||
mParent(nsnull),
|
||||
mTreeOwner(nsnull),
|
||||
mChromeEventHandler(nsnull)
|
||||
mChromeEventHandler(nsnull),
|
||||
mCurrentScrollbarPref(-1,-1),
|
||||
mDefaultScrollbarPref(-1,-1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
@ -270,8 +273,6 @@ nsDocShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode)
|
||||
doc->SetRootContent(rootContent);
|
||||
|
||||
// (6) reflow the document
|
||||
//XXX: SetScrolling doesn't make any sense
|
||||
//SetScrolling(-1, PR_FALSE);
|
||||
PRInt32 i;
|
||||
PRInt32 ns = doc->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++)
|
||||
@ -1575,41 +1576,109 @@ NS_IMETHODIMP nsDocShell::SetScrollRangeEx(PRInt32 minHorizontalPos,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
// Get scroll setting for this document only
|
||||
//
|
||||
// One important client is nsCSSFrameConstructor::ConstructRootFrame()
|
||||
NS_IMETHODIMP nsDocShell::GetCurrentScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32* scrollbarPref)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(scrollbarPref);
|
||||
switch(scrollOrientation) {
|
||||
case ScrollOrientation_X:
|
||||
*scrollbarPref = mCurrentScrollbarPref.x;
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIScrollableView> scrollView;
|
||||
NS_ENSURE_SUCCESS(GetRootScrollableView(getter_AddRefs(scrollView)),
|
||||
NS_ERROR_FAILURE);
|
||||
case ScrollOrientation_Y:
|
||||
*scrollbarPref = mCurrentScrollbarPref.y;
|
||||
return NS_OK;
|
||||
|
||||
// XXX This is all evil, we need to convert. We don't know our prefs
|
||||
// are the same as this interfaces.
|
||||
/* nsScrollPreference scrollPref;
|
||||
|
||||
NS_ENSURE_SUCCESS(scrollView->GetScrollPreference(scrollPref),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
*scrollbarPref = scrollPref; */
|
||||
|
||||
return NS_OK;
|
||||
default:
|
||||
NS_ENSURE_TRUE(PR_FALSE, NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
// This returns setting for all documents in this webshell
|
||||
NS_IMETHODIMP nsDocShell::GetDefaultScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32* scrollbarPref)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(scrollbarPref);
|
||||
switch(scrollOrientation) {
|
||||
case ScrollOrientation_X:
|
||||
*scrollbarPref = mDefaultScrollbarPref.x;
|
||||
return NS_OK;
|
||||
|
||||
case ScrollOrientation_Y:
|
||||
*scrollbarPref = mDefaultScrollbarPref.y;
|
||||
return NS_OK;
|
||||
|
||||
default:
|
||||
NS_ENSURE_TRUE(PR_FALSE, NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Set scrolling preference for this document only.
|
||||
//
|
||||
// There are three possible values stored in the shell:
|
||||
// 1) NS_STYLE_OVERFLOW_HIDDEN = no scrollbars
|
||||
// 2) NS_STYLE_OVERFLOW_AUTO = scrollbars appear if needed
|
||||
// 3) NS_STYLE_OVERFLOW_SCROLL = scrollbars always
|
||||
//
|
||||
// XXX Currently OVERFLOW_SCROLL isn't honored,
|
||||
// as it is not implemented by Gfx scrollbars
|
||||
// XXX setting has no effect after the root frame is created
|
||||
// as it is not implemented by Gfx scrollbars
|
||||
//
|
||||
// One important client is HTMLContentSink::StartLayout()
|
||||
NS_IMETHODIMP nsDocShell::SetCurrentScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32 scrollbarPref)
|
||||
{
|
||||
nsCOMPtr<nsIScrollableView> scrollView;
|
||||
NS_ENSURE_SUCCESS(GetRootScrollableView(getter_AddRefs(scrollView)),
|
||||
NS_ERROR_FAILURE);
|
||||
switch(scrollOrientation) {
|
||||
case ScrollOrientation_X:
|
||||
mCurrentScrollbarPref.x = scrollbarPref;
|
||||
return NS_OK;
|
||||
|
||||
// XXX This is evil. We should do a mapping, we don't know our prefs
|
||||
// are the same as this interface. In fact it doesn't compile
|
||||
/* nsScrollPreference scrollPref = scrollbarPref;
|
||||
NS_ENSURE_SUCCESS(scrollView->SetScrollPreference(scrollPref),
|
||||
NS_ERROR_FAILURE); */
|
||||
case ScrollOrientation_Y:
|
||||
mCurrentScrollbarPref.y = scrollbarPref;
|
||||
return NS_OK;
|
||||
|
||||
return NS_OK;
|
||||
default:
|
||||
NS_ENSURE_TRUE(PR_FALSE, NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Set scrolling preference for all documents in this shell
|
||||
// One important client is nsHTMLFrameInnerFrame::CreateWebShell()
|
||||
NS_IMETHODIMP nsDocShell::SetDefaultScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32 scrollbarPref)
|
||||
{
|
||||
switch(scrollOrientation) {
|
||||
case ScrollOrientation_X:
|
||||
mDefaultScrollbarPref.x = scrollbarPref;
|
||||
return NS_OK;
|
||||
|
||||
case ScrollOrientation_Y:
|
||||
mDefaultScrollbarPref.y = scrollbarPref;
|
||||
return NS_OK;
|
||||
|
||||
default:
|
||||
NS_ENSURE_TRUE(PR_FALSE, NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Reset 'current' scrollbar settings to 'default'.
|
||||
// This must be called before every document load or else
|
||||
// frameset scrollbar settings (e.g. <IFRAME SCROLLING="no">
|
||||
// will not be preserved.
|
||||
//
|
||||
// One important client is HTMLContentSink::StartLayout()
|
||||
NS_IMETHODIMP nsDocShell::ResetScrollbarPreferences()
|
||||
{
|
||||
mCurrentScrollbarPref = mDefaultScrollbarPref;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetScrollbarVisibility(PRBool* verticalVisible,
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsDSURIContentListener.h"
|
||||
#include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsISHistory.h"
|
||||
@ -191,6 +192,8 @@ protected:
|
||||
PRInt32 mMarginWidth;
|
||||
PRInt32 mMarginHeight;
|
||||
PRInt32 mItemType;
|
||||
nsPoint mCurrentScrollbarPref; // this document only
|
||||
nsPoint mDefaultScrollbarPref; // persistent across doc loads
|
||||
PRBool mUpdateHistoryOnLoad;
|
||||
PRBool mInitialPageLoad;
|
||||
|
||||
|
||||
@ -92,10 +92,16 @@ interface nsIScrollable : nsISupports
|
||||
const long Scrollbar_Always = 3;
|
||||
|
||||
/*
|
||||
Retrieves of Set the preferences for the scroll bar.
|
||||
Retrieves or Set the preferences for the scroll bar.
|
||||
current is 'scrolling preference for this document'
|
||||
default is 'scrolling preference for all documents in this shell'
|
||||
resetScrollbarPreferences resets current to default
|
||||
*/
|
||||
void getScrollbarPreferences(in long scrollOrientation, out long scrollbarPref);
|
||||
void setScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
|
||||
void getCurrentScrollbarPreferences(in long scrollOrientation, out long scrollbarPref);
|
||||
void setCurrentScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
|
||||
void getDefaultScrollbarPreferences(in long scrollOrientation, out long scrollbarPref);
|
||||
void setDefaultScrollbarPreferences(in long scrollOrientation, in long scrollbarPref);
|
||||
void resetScrollbarPreferences();
|
||||
|
||||
/*
|
||||
Get information about whether the vertical and horizontal scrollbars are
|
||||
|
||||
@ -215,7 +215,6 @@ public:
|
||||
// nsIWebShell
|
||||
NS_IMETHOD Init(nsNativeWidget aNativeParent,
|
||||
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
||||
nsScrollPreference aScrolling = nsScrollPreference_kAuto,
|
||||
PRBool aAllowPlugins = PR_TRUE,
|
||||
PRBool aIsSunkenBorder = PR_FALSE);
|
||||
NS_IMETHOD SetContainer(nsIWebShellContainer* aContainer);
|
||||
@ -235,9 +234,6 @@ public:
|
||||
NS_IMETHOD FindChildWithName(const PRUnichar* aName,
|
||||
nsIWebShell*& aResult);
|
||||
|
||||
NS_IMETHOD GetScrolling(PRInt32& aScrolling);
|
||||
NS_IMETHOD SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial = PR_TRUE);
|
||||
|
||||
// Document load api's
|
||||
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
|
||||
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
||||
@ -375,7 +371,7 @@ public:
|
||||
|
||||
protected:
|
||||
void GetRootWebShellEvenIfChrome(nsIWebShell** aResult);
|
||||
void InitFrameData(PRBool aCompleteInitScrolling);
|
||||
void InitFrameData();
|
||||
nsresult CheckForTrailingSlash(nsIURI* aURL);
|
||||
nsresult GetViewManager(nsIViewManager* *viewManager);
|
||||
nsresult InitDialogVars(void);
|
||||
@ -412,7 +408,6 @@ protected:
|
||||
|
||||
nsScrollPreference mScrollPref;
|
||||
|
||||
PRInt32 mScrolling[2];
|
||||
nsVoidArray mRefreshments;
|
||||
|
||||
eCharsetReloadState mCharsetReloadState;
|
||||
@ -585,7 +580,7 @@ nsWebShell::nsWebShell() : nsDocShell()
|
||||
mHistoryIndex = -1;
|
||||
mScrollPref = nsScrollPreference_kAuto;
|
||||
mThreadEventQueue = nsnull;
|
||||
InitFrameData(PR_TRUE);
|
||||
InitFrameData();
|
||||
mItemType = typeContent;
|
||||
mSHist = nsnull;
|
||||
mIsInSHist = PR_FALSE;
|
||||
@ -636,7 +631,7 @@ nsWebShell::~nsWebShell()
|
||||
mScriptContext = nsnull;
|
||||
}
|
||||
|
||||
InitFrameData(PR_TRUE);
|
||||
InitFrameData();
|
||||
|
||||
// Free up history memory
|
||||
PRInt32 i, n = mHistory.Count();
|
||||
@ -657,17 +652,10 @@ nsWebShell::~nsWebShell()
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsWebShell::InitFrameData(PRBool aCompleteInitScrolling)
|
||||
void nsWebShell::InitFrameData()
|
||||
{
|
||||
if (aCompleteInitScrolling) {
|
||||
mScrolling[0] = -1;
|
||||
mScrolling[1] = -1;
|
||||
SetMarginWidth(-1);
|
||||
SetMarginHeight(-1);
|
||||
}
|
||||
else {
|
||||
mScrolling[1] = mScrolling[0];
|
||||
}
|
||||
SetMarginWidth(-1);
|
||||
SetMarginHeight(-1);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -754,6 +742,7 @@ NS_INTERFACE_MAP_BEGIN(nsWebShell)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -959,7 +948,6 @@ nsWebShell::HandleUnknownContentType(nsIDocumentLoader* loader,
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::Init(nsNativeWidget aNativeParent,
|
||||
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
||||
nsScrollPreference aScrolling,
|
||||
PRBool aAllowPlugins,
|
||||
PRBool aIsSunkenBorder)
|
||||
{
|
||||
@ -990,8 +978,6 @@ nsWebShell::Init(nsNativeWidget aNativeParent,
|
||||
|
||||
CreatePluginHost(aAllowPlugins);
|
||||
|
||||
//mScrollPref = aScrolling;
|
||||
|
||||
WEB_TRACE(WEB_TRACE_CALLS,
|
||||
("nsWebShell::Init: this=%p", this));
|
||||
|
||||
@ -1306,24 +1292,6 @@ nsWebShell::FindChildWithName(const PRUnichar* aName1,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::GetScrolling(PRInt32& aScrolling)
|
||||
{
|
||||
aScrolling = mScrolling[1];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial)
|
||||
{
|
||||
mScrolling[1] = aScrolling;
|
||||
if (aSetCurrentAndInitial) {
|
||||
mScrolling[0] = aScrolling;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Document Load methods
|
||||
*/
|
||||
@ -1389,11 +1357,6 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
// Initialize margnwidth, marginheight. Put scrolling back the way it was
|
||||
// before the last document was loaded.
|
||||
|
||||
InitFrameData(PR_FALSE);
|
||||
|
||||
const char *cmd = mViewSource ? "view-source" : "view" ;
|
||||
|
||||
return LoadURL(aURLSpec, cmd, aPostDataStream,
|
||||
@ -3843,7 +3806,6 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
|
||||
rootContent->SetDocument(doc, PR_TRUE);
|
||||
|
||||
// (6) reflow the document
|
||||
InitFrameData(PR_FALSE); // Reset the scrolling state to initial
|
||||
PRInt32 i;
|
||||
PRInt32 ns = doc->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++)
|
||||
|
||||
@ -865,7 +865,7 @@ NS_IMETHODIMP nsWebBrowser::SetScrollRangeEx(PRInt32 minHorizontalPos,
|
||||
minVerticalPos, maxVerticalPos);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
NS_IMETHODIMP nsWebBrowser::GetCurrentScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32* scrollbarPref)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(scrollbarPref);
|
||||
@ -875,10 +875,23 @@ NS_IMETHODIMP nsWebBrowser::GetScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
|
||||
NS_ENSURE_TRUE(scroll, NS_ERROR_FAILURE);
|
||||
|
||||
return scroll->GetScrollbarPreferences(scrollOrientation, scrollbarPref);
|
||||
return scroll->GetCurrentScrollbarPreferences(scrollOrientation, scrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::SetScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
NS_IMETHODIMP nsWebBrowser::GetDefaultScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32* scrollbarPref)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(scrollbarPref);
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
nsCOMPtr<nsIScrollable> scroll(do_QueryInterface(mDocShell));
|
||||
|
||||
NS_ENSURE_TRUE(scroll, NS_ERROR_FAILURE);
|
||||
|
||||
return scroll->GetDefaultScrollbarPreferences(scrollOrientation, scrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::SetCurrentScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32 scrollbarPref)
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
@ -887,7 +900,30 @@ NS_IMETHODIMP nsWebBrowser::SetScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
|
||||
NS_ENSURE_TRUE(scroll, NS_ERROR_FAILURE);
|
||||
|
||||
return scroll->SetScrollbarPreferences(scrollOrientation, scrollbarPref);
|
||||
return scroll->SetCurrentScrollbarPreferences(scrollOrientation, scrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::SetDefaultScrollbarPreferences(PRInt32 scrollOrientation,
|
||||
PRInt32 scrollbarPref)
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
nsCOMPtr<nsIScrollable> scroll(do_QueryInterface(mDocShell));
|
||||
|
||||
NS_ENSURE_TRUE(scroll, NS_ERROR_FAILURE);
|
||||
|
||||
return scroll->SetDefaultScrollbarPreferences(scrollOrientation, scrollbarPref);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::ResetScrollbarPreferences()
|
||||
{
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
nsCOMPtr<nsIScrollable> scroll(do_QueryInterface(mDocShell));
|
||||
|
||||
NS_ENSURE_TRUE(scroll, NS_ERROR_FAILURE);
|
||||
|
||||
return scroll->ResetScrollbarPreferences();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebBrowser::GetScrollbarVisibility(PRBool* verticalVisible,
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
|
||||
class nsHTMLFrame;
|
||||
|
||||
@ -704,7 +705,12 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
|
||||
// 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)
|
||||
mWebShell->SetScrolling(GetScrolling(content, mode));
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(mWebShell, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, GetScrolling(content, mode));
|
||||
scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, GetScrolling(content, mode));
|
||||
}
|
||||
|
||||
nsString frameName;
|
||||
if (GetName(content, frameName)) {
|
||||
docShellAsItem->SetName(frameName.GetUnicode());
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIBox.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsIScrollable.h"
|
||||
|
||||
#undef NOISY_SECOND_REFLOW
|
||||
|
||||
@ -360,19 +361,21 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext)
|
||||
// has its scrolling set, use that value
|
||||
// XXX This is a huge hack, and we should not be checking the web shell's
|
||||
// scrolling preference...
|
||||
// This is needed to preserve iframe/frameset scrolling prefs between doc loads.
|
||||
nsIFrame* parentFrame = nsnull;
|
||||
GetParent(&parentFrame);
|
||||
nsIAtom* frameType = nsnull;
|
||||
parent->GetFrameType(&frameType);
|
||||
if (nsLayoutAtoms::viewportFrame == frameType) {
|
||||
nsCOMPtr<nsIAtom> frameType;
|
||||
parent->GetFrameType(getter_AddRefs(frameType));
|
||||
if (nsLayoutAtoms::viewportFrame == frameType.get()) {
|
||||
nsCOMPtr<nsISupports> container;
|
||||
rv = aPresContext->GetContainer(getter_AddRefs(container));
|
||||
if (NS_SUCCEEDED(rv) && container) {
|
||||
nsCOMPtr<nsIWebShell> webShell;
|
||||
rv = container->QueryInterface(kIWebShellIID, getter_AddRefs(webShell));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(container, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
PRInt32 scrolling = -1; // -1 indicates not set
|
||||
webShell->GetScrolling(scrolling);
|
||||
|
||||
// XXX We should get prefs for X and Y and deal with these independently!
|
||||
scrollableContainer->GetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y,&scrolling);
|
||||
if (-1 != scrolling) {
|
||||
if (NS_STYLE_OVERFLOW_SCROLL == scrolling) {
|
||||
scrollPref = nsScrollPreference_kAlwaysScroll;
|
||||
@ -383,7 +386,6 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_IF_RELEASE(frameType);
|
||||
scrollingView->SetScrollPreference(scrollPref);
|
||||
|
||||
// Set the scrolling view's insets to whatever our border is
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsIChromeEventHandler.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
|
||||
class nsHTMLFrame;
|
||||
|
||||
@ -704,7 +705,12 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
|
||||
// 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)
|
||||
mWebShell->SetScrolling(GetScrolling(content, mode));
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(mWebShell, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, GetScrolling(content, mode));
|
||||
scrollableContainer->SetDefaultScrollbarPreferences(nsIScrollable::ScrollOrientation_X, GetScrolling(content, mode));
|
||||
}
|
||||
|
||||
nsString frameName;
|
||||
if (GetName(content, frameName)) {
|
||||
docShellAsItem->SetName(frameName.GetUnicode());
|
||||
|
||||
@ -93,6 +93,7 @@
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIScrollable.h"
|
||||
|
||||
#ifdef ALLOW_ASYNCH_STYLE_SHEETS
|
||||
const PRBool kBlock=PR_FALSE;
|
||||
@ -3023,11 +3024,19 @@ HTMLContentSink::StartLayout()
|
||||
mLastNotificationTime = PR_Now();
|
||||
|
||||
// If it's a frameset document then disable scrolling.
|
||||
// Scrolling was reset nsWebShell::LoadURL() by InitFrameData()
|
||||
// Else, reset scrolling to default settings for this shell.
|
||||
// This must happen before the initial reflow, when we create the root frame
|
||||
nsresult rv;
|
||||
if (mWebShell) {
|
||||
if (mFrameset) {
|
||||
mWebShell->SetScrolling(NS_STYLE_OVERFLOW_HIDDEN, PR_FALSE);
|
||||
}
|
||||
nsCOMPtr<nsIScrollable> scrollableContainer = do_QueryInterface(mWebShell, &rv);
|
||||
if (NS_SUCCEEDED(rv) && scrollableContainer) {
|
||||
if (mFrameset) {
|
||||
scrollableContainer->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_Y, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
scrollableContainer->SetCurrentScrollbarPreferences(nsIScrollable::ScrollOrientation_X, NS_STYLE_OVERFLOW_HIDDEN);
|
||||
} else {
|
||||
scrollableContainer->ResetScrollbarPreferences();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, ns = mDocument->GetNumberOfShells();
|
||||
@ -3057,7 +3066,7 @@ HTMLContentSink::StartLayout()
|
||||
// frameset document, disable the scroll bars on the views.
|
||||
char* ref = nsnull; // init in case mDocumentURI is not a url
|
||||
nsIURL* url;
|
||||
nsresult rv = mDocumentURI->QueryInterface(NS_GET_IID(nsIURL), (void**)&url);
|
||||
rv = mDocumentURI->QueryInterface(NS_GET_IID(nsIURL), (void**)&url);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = url->GetRef(&ref);
|
||||
NS_RELEASE(url);
|
||||
|
||||
@ -120,7 +120,6 @@ public:
|
||||
*/
|
||||
NS_IMETHOD Init(nsNativeWidget aNativeParent,
|
||||
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
||||
nsScrollPreference aScrolling = nsScrollPreference_kAuto,
|
||||
PRBool aAllowPlugins = PR_TRUE,
|
||||
PRBool aIsSunkenBorder = PR_FALSE) = 0;
|
||||
|
||||
@ -316,11 +315,6 @@ public:
|
||||
// SetMenuBar
|
||||
// SetStatusBar
|
||||
|
||||
NS_IMETHOD SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial = PR_TRUE) = 0;
|
||||
NS_IMETHOD GetScrolling(PRInt32& aScrolling) = 0;
|
||||
|
||||
|
||||
|
||||
// XXX these are here until there a better way to pass along info to a sub doc
|
||||
NS_IMETHOD GetMarginWidth (PRInt32* aWidth) = 0;
|
||||
NS_IMETHOD SetMarginWidth (PRInt32 aWidth) = 0;
|
||||
|
||||
@ -215,7 +215,6 @@ public:
|
||||
// nsIWebShell
|
||||
NS_IMETHOD Init(nsNativeWidget aNativeParent,
|
||||
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
||||
nsScrollPreference aScrolling = nsScrollPreference_kAuto,
|
||||
PRBool aAllowPlugins = PR_TRUE,
|
||||
PRBool aIsSunkenBorder = PR_FALSE);
|
||||
NS_IMETHOD SetContainer(nsIWebShellContainer* aContainer);
|
||||
@ -235,9 +234,6 @@ public:
|
||||
NS_IMETHOD FindChildWithName(const PRUnichar* aName,
|
||||
nsIWebShell*& aResult);
|
||||
|
||||
NS_IMETHOD GetScrolling(PRInt32& aScrolling);
|
||||
NS_IMETHOD SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial = PR_TRUE);
|
||||
|
||||
// Document load api's
|
||||
NS_IMETHOD GetDocumentLoader(nsIDocumentLoader*& aResult);
|
||||
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
||||
@ -375,7 +371,7 @@ public:
|
||||
|
||||
protected:
|
||||
void GetRootWebShellEvenIfChrome(nsIWebShell** aResult);
|
||||
void InitFrameData(PRBool aCompleteInitScrolling);
|
||||
void InitFrameData();
|
||||
nsresult CheckForTrailingSlash(nsIURI* aURL);
|
||||
nsresult GetViewManager(nsIViewManager* *viewManager);
|
||||
nsresult InitDialogVars(void);
|
||||
@ -412,7 +408,6 @@ protected:
|
||||
|
||||
nsScrollPreference mScrollPref;
|
||||
|
||||
PRInt32 mScrolling[2];
|
||||
nsVoidArray mRefreshments;
|
||||
|
||||
eCharsetReloadState mCharsetReloadState;
|
||||
@ -585,7 +580,7 @@ nsWebShell::nsWebShell() : nsDocShell()
|
||||
mHistoryIndex = -1;
|
||||
mScrollPref = nsScrollPreference_kAuto;
|
||||
mThreadEventQueue = nsnull;
|
||||
InitFrameData(PR_TRUE);
|
||||
InitFrameData();
|
||||
mItemType = typeContent;
|
||||
mSHist = nsnull;
|
||||
mIsInSHist = PR_FALSE;
|
||||
@ -636,7 +631,7 @@ nsWebShell::~nsWebShell()
|
||||
mScriptContext = nsnull;
|
||||
}
|
||||
|
||||
InitFrameData(PR_TRUE);
|
||||
InitFrameData();
|
||||
|
||||
// Free up history memory
|
||||
PRInt32 i, n = mHistory.Count();
|
||||
@ -657,17 +652,10 @@ nsWebShell::~nsWebShell()
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsWebShell::InitFrameData(PRBool aCompleteInitScrolling)
|
||||
void nsWebShell::InitFrameData()
|
||||
{
|
||||
if (aCompleteInitScrolling) {
|
||||
mScrolling[0] = -1;
|
||||
mScrolling[1] = -1;
|
||||
SetMarginWidth(-1);
|
||||
SetMarginHeight(-1);
|
||||
}
|
||||
else {
|
||||
mScrolling[1] = mScrolling[0];
|
||||
}
|
||||
SetMarginWidth(-1);
|
||||
SetMarginHeight(-1);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -754,6 +742,7 @@ NS_INTERFACE_MAP_BEGIN(nsWebShell)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScrollable)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -959,7 +948,6 @@ nsWebShell::HandleUnknownContentType(nsIDocumentLoader* loader,
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::Init(nsNativeWidget aNativeParent,
|
||||
PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h,
|
||||
nsScrollPreference aScrolling,
|
||||
PRBool aAllowPlugins,
|
||||
PRBool aIsSunkenBorder)
|
||||
{
|
||||
@ -990,8 +978,6 @@ nsWebShell::Init(nsNativeWidget aNativeParent,
|
||||
|
||||
CreatePluginHost(aAllowPlugins);
|
||||
|
||||
//mScrollPref = aScrolling;
|
||||
|
||||
WEB_TRACE(WEB_TRACE_CALLS,
|
||||
("nsWebShell::Init: this=%p", this));
|
||||
|
||||
@ -1306,24 +1292,6 @@ nsWebShell::FindChildWithName(const PRUnichar* aName1,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::GetScrolling(PRInt32& aScrolling)
|
||||
{
|
||||
aScrolling = mScrolling[1];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::SetScrolling(PRInt32 aScrolling, PRBool aSetCurrentAndInitial)
|
||||
{
|
||||
mScrolling[1] = aScrolling;
|
||||
if (aSetCurrentAndInitial) {
|
||||
mScrolling[0] = aScrolling;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Document Load methods
|
||||
*/
|
||||
@ -1389,11 +1357,6 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
// Initialize margnwidth, marginheight. Put scrolling back the way it was
|
||||
// before the last document was loaded.
|
||||
|
||||
InitFrameData(PR_FALSE);
|
||||
|
||||
const char *cmd = mViewSource ? "view-source" : "view" ;
|
||||
|
||||
return LoadURL(aURLSpec, cmd, aPostDataStream,
|
||||
@ -3843,7 +3806,6 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
|
||||
rootContent->SetDocument(doc, PR_TRUE);
|
||||
|
||||
// (6) reflow the document
|
||||
InitFrameData(PR_FALSE); // Reset the scrolling state to initial
|
||||
PRInt32 i;
|
||||
PRInt32 ns = doc->GetNumberOfShells();
|
||||
for (i = 0; i < ns; i++)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user