mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 915962 - Part 1: Allow pressing space to scroll the document if an editable element or form control is not focused; r=roc
This commit is contained in:
parent
ca5f98c8c9
commit
a4eed0c51a
@ -23,6 +23,7 @@
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIDOMHTMLInputElement.h"
|
||||
#include "nsFocusManager.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPIWindowRoot.h"
|
||||
@ -475,34 +476,17 @@ nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, nsIDOMEvent* aEv
|
||||
nsFocusManager::GetFocusedDescendant(windowToCheck, true, getter_AddRefs(focusedWindow));
|
||||
}
|
||||
|
||||
bool isLink = false;
|
||||
nsIContent *content = focusedContent;
|
||||
// If the focus is in an editable region, don't scroll.
|
||||
if (focusedContent->IsEditable()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if the focused element is a link then we do want space to
|
||||
// scroll down. The focused element may be an element in a link,
|
||||
// we need to check the parent node too. Only do this check if an
|
||||
// element is focused and has a parent.
|
||||
if (focusedContent && focusedContent->GetParent()) {
|
||||
while (content) {
|
||||
if (content->IsHTMLElement(nsGkAtoms::a)) {
|
||||
isLink = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (content->HasAttr(kNameSpaceID_XLink, nsGkAtoms::type)) {
|
||||
isLink = content->AttrValueIs(kNameSpaceID_XLink, nsGkAtoms::type,
|
||||
nsGkAtoms::simple, eCaseMatters);
|
||||
|
||||
if (isLink) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
content = content->GetParent();
|
||||
}
|
||||
|
||||
if (!isLink)
|
||||
// If the focus is in a form control, don't scroll.
|
||||
for (nsIContent* c = focusedContent; c; c = c->GetParent()) {
|
||||
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(c);
|
||||
if (formControl) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user