зеркало из https://github.com/mozilla/gecko-dev.git
First checkin for bug 29800, preventing scrolling to content when focus
memory is resetting focus after deactivating and reactivating a window.
This commit is contained in:
Родитель
c77d373dbb
Коммит
eebb4fa07e
|
@ -412,6 +412,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
// Obtain focus info from the command dispatcher.
|
||||
commandDispatcher->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
commandDispatcher->GetFocusedElement(getter_AddRefs(focusedElement));
|
||||
|
||||
commandDispatcher->SetSuppressFocusScroll(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,6 +444,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
// Obtain focus info from the command dispatcher.
|
||||
commandDispatcher->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
commandDispatcher->GetFocusedElement(getter_AddRefs(focusedElement));
|
||||
|
||||
commandDispatcher->SetSuppressFocusScroll(PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +469,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
if (commandDispatcher) {
|
||||
commandDispatcher->SetActive(PR_TRUE);
|
||||
commandDispatcher->SetSuppressFocus(PR_FALSE); // Unsuppress and let the command dispatcher listen again.
|
||||
commandDispatcher->SetSuppressFocusScroll(PR_FALSE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1728,6 +1728,48 @@ NS_IMETHODIMP
|
|||
PresShell::ScrollFrameIntoView(nsIFrame *aFrame){
|
||||
if (!aFrame)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Before we scroll the frame into view, ask the command dispatcher
|
||||
// if we're resetting focus because a window just got an activate
|
||||
// event. If we are, we do not want to scroll the frame into view.
|
||||
// Example: The user clicks on an anchor, and then deactivates the
|
||||
// window. When they reactivate the window, the expected behavior
|
||||
// is not for the anchor link to scroll back into view. That is what
|
||||
// this check is preventing.
|
||||
// XXX: The dependency on the command dispatcher needs to be fixed.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
aFrame->GetContent(getter_AddRefs(content));
|
||||
if(content) {
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if(document){
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsIDOMWindow> rootWindow;
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(ourGlobal);
|
||||
if(ourWindow) {
|
||||
ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow));
|
||||
if(rootWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> rootDocument;
|
||||
rootWindow->GetDocument(getter_AddRefs(rootDocument));
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(rootDocument);
|
||||
if (xulDoc) {
|
||||
// See if we have a command dispatcher attached.
|
||||
xulDoc->GetCommandDispatcher(getter_AddRefs(commandDispatcher));
|
||||
if (commandDispatcher) {
|
||||
PRBool dontScroll;
|
||||
commandDispatcher->GetSuppressFocusScroll(&dontScroll);
|
||||
if(dontScroll)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsScrollingEnabled())
|
||||
return ScrollFrameIntoView(aFrame, NS_PRESSHELL_SCROLL_ANYWHERE,
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE);
|
||||
|
@ -2378,6 +2420,47 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
|||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Before we scroll the frame into view, ask the command dispatcher
|
||||
// if we're resetting focus because a window just got an activate
|
||||
// event. If we are, we do not want to scroll the frame into view.
|
||||
// Example: The user clicks on an anchor, and then deactivates the
|
||||
// window. When they reactivate the window, the expected behavior
|
||||
// is not for the anchor link to scroll back into view. That is what
|
||||
// this check is preventing.
|
||||
// XXX: The dependency on the command dispatcher needs to be fixed.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
aFrame->GetContent(getter_AddRefs(content));
|
||||
if(content) {
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if(document){
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsIDOMWindow> rootWindow;
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(ourGlobal);
|
||||
if(ourWindow) {
|
||||
ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow));
|
||||
if(rootWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> rootDocument;
|
||||
rootWindow->GetDocument(getter_AddRefs(rootDocument));
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(rootDocument);
|
||||
if (xulDoc) {
|
||||
// See if we have a command dispatcher attached.
|
||||
xulDoc->GetCommandDispatcher(getter_AddRefs(commandDispatcher));
|
||||
if (commandDispatcher) {
|
||||
PRBool dontScroll;
|
||||
commandDispatcher->GetSuppressFocusScroll(&dontScroll);
|
||||
if(dontScroll)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mViewManager) {
|
||||
// Get the viewport scroller
|
||||
nsIScrollableView* scrollingView;
|
||||
|
|
|
@ -412,6 +412,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
// Obtain focus info from the command dispatcher.
|
||||
commandDispatcher->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
commandDispatcher->GetFocusedElement(getter_AddRefs(focusedElement));
|
||||
|
||||
commandDispatcher->SetSuppressFocusScroll(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,6 +444,8 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
// Obtain focus info from the command dispatcher.
|
||||
commandDispatcher->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
commandDispatcher->GetFocusedElement(getter_AddRefs(focusedElement));
|
||||
|
||||
commandDispatcher->SetSuppressFocusScroll(PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +469,7 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
|||
if (commandDispatcher) {
|
||||
commandDispatcher->SetActive(PR_TRUE);
|
||||
commandDispatcher->SetSuppressFocus(PR_FALSE); // Unsuppress and let the command dispatcher listen again.
|
||||
commandDispatcher->SetSuppressFocusScroll(PR_FALSE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1728,6 +1728,48 @@ NS_IMETHODIMP
|
|||
PresShell::ScrollFrameIntoView(nsIFrame *aFrame){
|
||||
if (!aFrame)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Before we scroll the frame into view, ask the command dispatcher
|
||||
// if we're resetting focus because a window just got an activate
|
||||
// event. If we are, we do not want to scroll the frame into view.
|
||||
// Example: The user clicks on an anchor, and then deactivates the
|
||||
// window. When they reactivate the window, the expected behavior
|
||||
// is not for the anchor link to scroll back into view. That is what
|
||||
// this check is preventing.
|
||||
// XXX: The dependency on the command dispatcher needs to be fixed.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
aFrame->GetContent(getter_AddRefs(content));
|
||||
if(content) {
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if(document){
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsIDOMWindow> rootWindow;
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(ourGlobal);
|
||||
if(ourWindow) {
|
||||
ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow));
|
||||
if(rootWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> rootDocument;
|
||||
rootWindow->GetDocument(getter_AddRefs(rootDocument));
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(rootDocument);
|
||||
if (xulDoc) {
|
||||
// See if we have a command dispatcher attached.
|
||||
xulDoc->GetCommandDispatcher(getter_AddRefs(commandDispatcher));
|
||||
if (commandDispatcher) {
|
||||
PRBool dontScroll;
|
||||
commandDispatcher->GetSuppressFocusScroll(&dontScroll);
|
||||
if(dontScroll)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsScrollingEnabled())
|
||||
return ScrollFrameIntoView(aFrame, NS_PRESSHELL_SCROLL_ANYWHERE,
|
||||
NS_PRESSHELL_SCROLL_ANYWHERE);
|
||||
|
@ -2378,6 +2420,47 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
|
|||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// Before we scroll the frame into view, ask the command dispatcher
|
||||
// if we're resetting focus because a window just got an activate
|
||||
// event. If we are, we do not want to scroll the frame into view.
|
||||
// Example: The user clicks on an anchor, and then deactivates the
|
||||
// window. When they reactivate the window, the expected behavior
|
||||
// is not for the anchor link to scroll back into view. That is what
|
||||
// this check is preventing.
|
||||
// XXX: The dependency on the command dispatcher needs to be fixed.
|
||||
nsCOMPtr<nsIContent> content;
|
||||
aFrame->GetContent(getter_AddRefs(content));
|
||||
if(content) {
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
content->GetDocument(*getter_AddRefs(document));
|
||||
if(document){
|
||||
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
document->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
nsCOMPtr<nsIDOMWindow> rootWindow;
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_QueryInterface(ourGlobal);
|
||||
if(ourWindow) {
|
||||
ourWindow->GetPrivateRoot(getter_AddRefs(rootWindow));
|
||||
if(rootWindow) {
|
||||
nsCOMPtr<nsIDOMDocument> rootDocument;
|
||||
rootWindow->GetDocument(getter_AddRefs(rootDocument));
|
||||
|
||||
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(rootDocument);
|
||||
if (xulDoc) {
|
||||
// See if we have a command dispatcher attached.
|
||||
xulDoc->GetCommandDispatcher(getter_AddRefs(commandDispatcher));
|
||||
if (commandDispatcher) {
|
||||
PRBool dontScroll;
|
||||
commandDispatcher->GetSuppressFocusScroll(&dontScroll);
|
||||
if(dontScroll)
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mViewManager) {
|
||||
// Get the viewport scroller
|
||||
nsIScrollableView* scrollingView;
|
||||
|
|
Загрузка…
Ссылка в новой задаче