зеркало из https://github.com/mozilla/pjs.git
fix for 46287 (<frame scrolling=no> breaks window.scroll and html anchors). r=evaughan, sr=hyatt
This commit is contained in:
Родитель
2e4c2f30de
Коммит
0394710c89
|
@ -18,7 +18,7 @@
|
||||||
* Rights Reserved.
|
* Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
* Dan Rosen <dr@netscape.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nsCSSFrameConstructor.h"
|
#include "nsCSSFrameConstructor.h"
|
||||||
|
@ -3779,11 +3779,14 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
// Only need to create a scroll frame/view for cases 2 and 3.
|
// Only need to create a scroll frame/view for cases 2 and 3.
|
||||||
// Currently OVERFLOW_SCROLL isn't honored, as
|
// Currently OVERFLOW_SCROLL isn't honored, as
|
||||||
// scrollportview::SetScrollPref is not implemented.
|
// scrollportview::SetScrollPref is not implemented.
|
||||||
|
PRBool isXUL = PR_FALSE;
|
||||||
|
|
||||||
#ifdef INCLUDE_XUL
|
#ifdef INCLUDE_XUL
|
||||||
PRInt32 nameSpaceID; // Never create scrollbars for XUL documents
|
PRInt32 nameSpaceID; // Never create scrollbars for XUL documents
|
||||||
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
|
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
|
||||||
nameSpaceID == nsXULAtoms::nameSpaceID) {
|
nameSpaceID == nsXULAtoms::nameSpaceID) {
|
||||||
isScrollable = PR_FALSE;
|
isScrollable = PR_FALSE;
|
||||||
|
isXUL = PR_TRUE;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -3818,10 +3821,14 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
|
|
||||||
nsIFrame* parentFrame = viewportFrame;
|
nsIFrame* parentFrame = viewportFrame;
|
||||||
|
|
||||||
// It should be scrollable.. and it also can not be paginated
|
// If paginated, make sure we don't put scrollbars in
|
||||||
if (isScrollable && !isPaginated) {
|
if (isPaginated)
|
||||||
|
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
||||||
|
viewportPseudoStyle, PR_FALSE,
|
||||||
|
getter_AddRefs(rootPseudoStyle));
|
||||||
|
else if (isScrollable) {
|
||||||
|
|
||||||
// built the frame. We give it the content we are wrapping which is the document,
|
// Build the frame. We give it the content we are wrapping which is the document,
|
||||||
// the root frame, the parent view port frame, and we should get back the new
|
// the root frame, the parent view port frame, and we should get back the new
|
||||||
// frame and the scrollable view if one was created.
|
// frame and the scrollable view if one was created.
|
||||||
|
|
||||||
|
@ -3851,29 +3858,72 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
newScrollableFrame);
|
newScrollableFrame);
|
||||||
|
|
||||||
// Inform the view manager about the root scrollable view
|
// Inform the view manager about the root scrollable view
|
||||||
// get the scrolling view
|
|
||||||
nsIView* view = nsnull;
|
nsIView* view = nsnull;
|
||||||
newScrollableFrame->GetView(aPresContext, &view);
|
newScrollableFrame->GetView(aPresContext, &view);
|
||||||
nsIScrollableView* scrollableView;
|
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
|
||||||
view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView);
|
|
||||||
|
nsCOMPtr<nsIScrollableView>
|
||||||
|
scrollableView(do_QueryInterface(view));
|
||||||
|
NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
viewManager->SetRootScrollableView(scrollableView);
|
viewManager->SetRootScrollableView(scrollableView);
|
||||||
parentFrame = newScrollableFrame;
|
parentFrame = newScrollableFrame;
|
||||||
|
|
||||||
// if gfx scrollbars store them
|
// if gfx scrollbars store them
|
||||||
if (HasGfxScrollbars()) {
|
if (HasGfxScrollbars())
|
||||||
mGfxScrollFrame = newFrame;
|
mGfxScrollFrame = newFrame;
|
||||||
} else {
|
else
|
||||||
mGfxScrollFrame = nsnull;
|
mGfxScrollFrame = nsnull;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
// If no scrollbars and xul, don't build a scrollframe at all.
|
||||||
|
if (isXUL) {
|
||||||
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
||||||
viewportPseudoStyle,
|
viewportPseudoStyle, PR_FALSE,
|
||||||
PR_FALSE,
|
|
||||||
getter_AddRefs(rootPseudoStyle));
|
getter_AddRefs(rootPseudoStyle));
|
||||||
|
} else {
|
||||||
|
// if HTML the always create a scrollframe so anchors work. That way you can scroll to
|
||||||
|
// anchors even if we don't have scrollbars.
|
||||||
|
|
||||||
|
// create a style context for the scrollport of the viewport
|
||||||
|
nsCOMPtr<nsIStyleContext> scrollPseudoStyle;
|
||||||
|
aPresContext->ResolvePseudoStyleContextFor(nsnull,
|
||||||
|
nsLayoutAtoms::scrolledContentPseudo,
|
||||||
|
viewportPseudoStyle, PR_FALSE,
|
||||||
|
getter_AddRefs(scrollPseudoStyle));
|
||||||
|
|
||||||
|
// create scrollframe
|
||||||
|
nsIFrame* scrollFrame = nsnull;
|
||||||
|
NS_NewScrollPortFrame(aPresShell, &scrollFrame);
|
||||||
|
NS_ENSURE_TRUE(scrollFrame, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
scrollFrame->Init(aPresContext, nsnull, parentFrame, scrollPseudoStyle, nsnull);
|
||||||
|
|
||||||
|
// resolve a new style for the root frame
|
||||||
|
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
||||||
|
scrollPseudoStyle, PR_FALSE,
|
||||||
|
getter_AddRefs(rootPseudoStyle));
|
||||||
|
|
||||||
|
// Inform the view manager about the root scrollable view
|
||||||
|
nsIView* view = nsnull;
|
||||||
|
scrollFrame->GetView(aPresContext, &view);
|
||||||
|
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIScrollableView>
|
||||||
|
scrollableView(do_QueryInterface(view));
|
||||||
|
NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
viewManager->SetRootScrollableView(scrollableView);
|
||||||
|
|
||||||
|
parentFrame = scrollFrame;
|
||||||
|
newFrame = scrollFrame;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rootFrame->Init(aPresContext, nsnull, parentFrame, rootPseudoStyle, nsnull);
|
rootFrame->Init(aPresContext, nsnull, parentFrame, rootPseudoStyle, nsnull);
|
||||||
|
|
||||||
|
if (!isPaginated) {
|
||||||
if (isScrollable) {
|
if (isScrollable) {
|
||||||
FinishBuildingScrollFrame(aPresContext,
|
FinishBuildingScrollFrame(aPresContext,
|
||||||
state,
|
state,
|
||||||
|
@ -3884,9 +3934,12 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
|
|
||||||
// set the primary frame to the root frame
|
// set the primary frame to the root frame
|
||||||
state.mFrameManager->SetPrimaryFrameFor(aDocElement, rootFrame);
|
state.mFrameManager->SetPrimaryFrameFor(aDocElement, rootFrame);
|
||||||
|
} else { // if not scrollable
|
||||||
|
if (!isXUL) { // if not XUL
|
||||||
|
parentFrame->SetInitialChildList(aPresContext, nsnull, rootFrame);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (isPaginated) {
|
} else { // paginated
|
||||||
// Create the first page
|
// Create the first page
|
||||||
nsIFrame* pageFrame;
|
nsIFrame* pageFrame;
|
||||||
NS_NewPageFrame(aPresShell, &pageFrame);
|
NS_NewPageFrame(aPresShell, &pageFrame);
|
||||||
|
@ -5957,7 +6010,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell,
|
||||||
BuildGfxScrollFrame(aPresShell, aPresContext, aState, aContent, aDocument, aParentFrame,
|
BuildGfxScrollFrame(aPresShell, aPresContext, aState, aContent, aDocument, aParentFrame,
|
||||||
contentStyle, aIsRoot, gfxScrollFrame, anonymousItems, aScrollPortFrame);
|
contentStyle, aIsRoot, gfxScrollFrame, anonymousItems, aScrollPortFrame);
|
||||||
|
|
||||||
scrollFrame = anonymousItems.childList;
|
scrollFrame = anonymousItems.childList; // get the scrollport from the anonymous list
|
||||||
parentFrame = gfxScrollFrame;
|
parentFrame = gfxScrollFrame;
|
||||||
aNewFrame = gfxScrollFrame;
|
aNewFrame = gfxScrollFrame;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* Rights Reserved.
|
* Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
* Dan Rosen <dr@netscape.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nsCSSFrameConstructor.h"
|
#include "nsCSSFrameConstructor.h"
|
||||||
|
@ -3779,11 +3779,14 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
// Only need to create a scroll frame/view for cases 2 and 3.
|
// Only need to create a scroll frame/view for cases 2 and 3.
|
||||||
// Currently OVERFLOW_SCROLL isn't honored, as
|
// Currently OVERFLOW_SCROLL isn't honored, as
|
||||||
// scrollportview::SetScrollPref is not implemented.
|
// scrollportview::SetScrollPref is not implemented.
|
||||||
|
PRBool isXUL = PR_FALSE;
|
||||||
|
|
||||||
#ifdef INCLUDE_XUL
|
#ifdef INCLUDE_XUL
|
||||||
PRInt32 nameSpaceID; // Never create scrollbars for XUL documents
|
PRInt32 nameSpaceID; // Never create scrollbars for XUL documents
|
||||||
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
|
if (NS_SUCCEEDED(aDocElement->GetNameSpaceID(nameSpaceID)) &&
|
||||||
nameSpaceID == nsXULAtoms::nameSpaceID) {
|
nameSpaceID == nsXULAtoms::nameSpaceID) {
|
||||||
isScrollable = PR_FALSE;
|
isScrollable = PR_FALSE;
|
||||||
|
isXUL = PR_TRUE;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -3818,10 +3821,14 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
|
|
||||||
nsIFrame* parentFrame = viewportFrame;
|
nsIFrame* parentFrame = viewportFrame;
|
||||||
|
|
||||||
// It should be scrollable.. and it also can not be paginated
|
// If paginated, make sure we don't put scrollbars in
|
||||||
if (isScrollable && !isPaginated) {
|
if (isPaginated)
|
||||||
|
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
||||||
|
viewportPseudoStyle, PR_FALSE,
|
||||||
|
getter_AddRefs(rootPseudoStyle));
|
||||||
|
else if (isScrollable) {
|
||||||
|
|
||||||
// built the frame. We give it the content we are wrapping which is the document,
|
// Build the frame. We give it the content we are wrapping which is the document,
|
||||||
// the root frame, the parent view port frame, and we should get back the new
|
// the root frame, the parent view port frame, and we should get back the new
|
||||||
// frame and the scrollable view if one was created.
|
// frame and the scrollable view if one was created.
|
||||||
|
|
||||||
|
@ -3851,29 +3858,72 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
newScrollableFrame);
|
newScrollableFrame);
|
||||||
|
|
||||||
// Inform the view manager about the root scrollable view
|
// Inform the view manager about the root scrollable view
|
||||||
// get the scrolling view
|
|
||||||
nsIView* view = nsnull;
|
nsIView* view = nsnull;
|
||||||
newScrollableFrame->GetView(aPresContext, &view);
|
newScrollableFrame->GetView(aPresContext, &view);
|
||||||
nsIScrollableView* scrollableView;
|
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
|
||||||
view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView);
|
|
||||||
|
nsCOMPtr<nsIScrollableView>
|
||||||
|
scrollableView(do_QueryInterface(view));
|
||||||
|
NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
viewManager->SetRootScrollableView(scrollableView);
|
viewManager->SetRootScrollableView(scrollableView);
|
||||||
parentFrame = newScrollableFrame;
|
parentFrame = newScrollableFrame;
|
||||||
|
|
||||||
// if gfx scrollbars store them
|
// if gfx scrollbars store them
|
||||||
if (HasGfxScrollbars()) {
|
if (HasGfxScrollbars())
|
||||||
mGfxScrollFrame = newFrame;
|
mGfxScrollFrame = newFrame;
|
||||||
} else {
|
else
|
||||||
mGfxScrollFrame = nsnull;
|
mGfxScrollFrame = nsnull;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
// If no scrollbars and xul, don't build a scrollframe at all.
|
||||||
|
if (isXUL) {
|
||||||
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
||||||
viewportPseudoStyle,
|
viewportPseudoStyle, PR_FALSE,
|
||||||
PR_FALSE,
|
|
||||||
getter_AddRefs(rootPseudoStyle));
|
getter_AddRefs(rootPseudoStyle));
|
||||||
|
} else {
|
||||||
|
// if HTML the always create a scrollframe so anchors work. That way you can scroll to
|
||||||
|
// anchors even if we don't have scrollbars.
|
||||||
|
|
||||||
|
// create a style context for the scrollport of the viewport
|
||||||
|
nsCOMPtr<nsIStyleContext> scrollPseudoStyle;
|
||||||
|
aPresContext->ResolvePseudoStyleContextFor(nsnull,
|
||||||
|
nsLayoutAtoms::scrolledContentPseudo,
|
||||||
|
viewportPseudoStyle, PR_FALSE,
|
||||||
|
getter_AddRefs(scrollPseudoStyle));
|
||||||
|
|
||||||
|
// create scrollframe
|
||||||
|
nsIFrame* scrollFrame = nsnull;
|
||||||
|
NS_NewScrollPortFrame(aPresShell, &scrollFrame);
|
||||||
|
NS_ENSURE_TRUE(scrollFrame, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
scrollFrame->Init(aPresContext, nsnull, parentFrame, scrollPseudoStyle, nsnull);
|
||||||
|
|
||||||
|
// resolve a new style for the root frame
|
||||||
|
aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo,
|
||||||
|
scrollPseudoStyle, PR_FALSE,
|
||||||
|
getter_AddRefs(rootPseudoStyle));
|
||||||
|
|
||||||
|
// Inform the view manager about the root scrollable view
|
||||||
|
nsIView* view = nsnull;
|
||||||
|
scrollFrame->GetView(aPresContext, &view);
|
||||||
|
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIScrollableView>
|
||||||
|
scrollableView(do_QueryInterface(view));
|
||||||
|
NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
viewManager->SetRootScrollableView(scrollableView);
|
||||||
|
|
||||||
|
parentFrame = scrollFrame;
|
||||||
|
newFrame = scrollFrame;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
rootFrame->Init(aPresContext, nsnull, parentFrame, rootPseudoStyle, nsnull);
|
rootFrame->Init(aPresContext, nsnull, parentFrame, rootPseudoStyle, nsnull);
|
||||||
|
|
||||||
|
if (!isPaginated) {
|
||||||
if (isScrollable) {
|
if (isScrollable) {
|
||||||
FinishBuildingScrollFrame(aPresContext,
|
FinishBuildingScrollFrame(aPresContext,
|
||||||
state,
|
state,
|
||||||
|
@ -3884,9 +3934,12 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
|
||||||
|
|
||||||
// set the primary frame to the root frame
|
// set the primary frame to the root frame
|
||||||
state.mFrameManager->SetPrimaryFrameFor(aDocElement, rootFrame);
|
state.mFrameManager->SetPrimaryFrameFor(aDocElement, rootFrame);
|
||||||
|
} else { // if not scrollable
|
||||||
|
if (!isXUL) { // if not XUL
|
||||||
|
parentFrame->SetInitialChildList(aPresContext, nsnull, rootFrame);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (isPaginated) {
|
} else { // paginated
|
||||||
// Create the first page
|
// Create the first page
|
||||||
nsIFrame* pageFrame;
|
nsIFrame* pageFrame;
|
||||||
NS_NewPageFrame(aPresShell, &pageFrame);
|
NS_NewPageFrame(aPresShell, &pageFrame);
|
||||||
|
@ -5957,7 +6010,7 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresShell,
|
||||||
BuildGfxScrollFrame(aPresShell, aPresContext, aState, aContent, aDocument, aParentFrame,
|
BuildGfxScrollFrame(aPresShell, aPresContext, aState, aContent, aDocument, aParentFrame,
|
||||||
contentStyle, aIsRoot, gfxScrollFrame, anonymousItems, aScrollPortFrame);
|
contentStyle, aIsRoot, gfxScrollFrame, anonymousItems, aScrollPortFrame);
|
||||||
|
|
||||||
scrollFrame = anonymousItems.childList;
|
scrollFrame = anonymousItems.childList; // get the scrollport from the anonymous list
|
||||||
parentFrame = gfxScrollFrame;
|
parentFrame = gfxScrollFrame;
|
||||||
aNewFrame = gfxScrollFrame;
|
aNewFrame = gfxScrollFrame;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче