mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1168042, return a bool from PerformAccessKey indicating if focus was changed, r=masayuki
This commit is contained in:
parent
8a45064b49
commit
1df239e8f6
@ -40,8 +40,8 @@ enum nsLinkState {
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
{ 0x52cebfc8, 0x79ba, 0x4e38, \
|
||||
{ 0x8a, 0x4c, 0x7f, 0x9d, 0xb1, 0xa2, 0xb6, 0x1d } }
|
||||
{ 0x8e1bab9d, 0x8815, 0x4d2c, \
|
||||
{ 0xa2, 0x4d, 0x7a, 0xba, 0x52, 0x39, 0xdc, 0x22 } }
|
||||
|
||||
/**
|
||||
* A node of content in a document's content model. This interface
|
||||
@ -581,10 +581,12 @@ public:
|
||||
* @param aKeyCausesActivation - if true then element should be activated
|
||||
* @param aIsTrustedEvent - if true then event that is cause of accesskey
|
||||
* execution is trusted.
|
||||
* @return true if the focus was changed.
|
||||
*/
|
||||
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -218,18 +218,20 @@ HTMLLabelElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent)
|
||||
{
|
||||
if (!aKeyCausesActivation) {
|
||||
nsRefPtr<Element> element = GetLabeledElement();
|
||||
if (element)
|
||||
element->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
|
||||
if (element) {
|
||||
return element->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
|
||||
}
|
||||
} else {
|
||||
nsPresContext *presContext = GetPresContext(eForUncomposedDoc);
|
||||
if (!presContext)
|
||||
return;
|
||||
if (!presContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Click on it if the users prefs indicate to do so.
|
||||
WidgetMouseEvent event(aIsTrustedEvent, eMouseClick,
|
||||
@ -242,6 +244,8 @@ HTMLLabelElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
|
||||
&event);
|
||||
}
|
||||
|
||||
return aKeyCausesActivation;
|
||||
}
|
||||
|
||||
nsGenericHTMLElement*
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
// nsIContent
|
||||
virtual nsresult PostHandleEvent(
|
||||
EventChainPostVisitor& aVisitor) override;
|
||||
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) override;
|
||||
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
||||
|
||||
|
@ -128,13 +128,14 @@ HTMLLegendElement::Focus(ErrorResult& aError)
|
||||
getter_AddRefs(result));
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent)
|
||||
{
|
||||
// just use the same behaviour as the focus method
|
||||
ErrorResult rv;
|
||||
Focus(rv);
|
||||
return NS_SUCCEEDED(rv.StealNSResult());
|
||||
}
|
||||
|
||||
already_AddRefed<HTMLFormElement>
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
using nsGenericHTMLElement::Focus;
|
||||
virtual void Focus(ErrorResult& aError) override;
|
||||
|
||||
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) override;
|
||||
|
||||
// nsIContent
|
||||
|
@ -2739,18 +2739,24 @@ nsGenericHTMLElement::RegUnRegAccessKey(bool aDoReg)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent)
|
||||
{
|
||||
nsPresContext* presContext = GetPresContext(eForUncomposedDoc);
|
||||
if (!presContext)
|
||||
return;
|
||||
if (!presContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// It's hard to say what HTML4 wants us to do in all cases.
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
bool focused = true;
|
||||
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
fm->SetFocus(this, nsIFocusManager::FLAG_BYKEY);
|
||||
|
||||
// Return true if the element became the current focus within its window.
|
||||
nsPIDOMWindow* window = OwnerDoc()->GetWindow();
|
||||
focused = (window && window->GetFocusedNode());
|
||||
}
|
||||
|
||||
if (aKeyCausesActivation) {
|
||||
@ -2765,6 +2771,8 @@ nsGenericHTMLElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
|
||||
presContext, &event);
|
||||
}
|
||||
|
||||
return focused;
|
||||
}
|
||||
|
||||
const nsAttrName*
|
||||
|
@ -597,7 +597,7 @@ public:
|
||||
virtual bool IsHTMLFocusable(bool aWithMouse,
|
||||
bool *aIsFocusable,
|
||||
int32_t *aTabIndex);
|
||||
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) override;
|
||||
|
||||
/**
|
||||
|
@ -620,7 +620,7 @@ nsXULElement::IsFocusableInternal(int32_t *aTabIndex, bool aWithMouse)
|
||||
return shouldFocus;
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent)
|
||||
{
|
||||
@ -643,21 +643,24 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
// |element|, or clear it.
|
||||
content = do_QueryInterface(element);
|
||||
|
||||
if (!content)
|
||||
return;
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nsIFrame* frame = content->GetPrimaryFrame();
|
||||
if (!frame || !frame->IsVisibleConsideringAncestors())
|
||||
return;
|
||||
if (!frame || !frame->IsVisibleConsideringAncestors()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool focused = false;
|
||||
nsXULElement* elm = FromContent(content);
|
||||
if (elm) {
|
||||
// Define behavior for each type of XUL element.
|
||||
if (!content->IsXULElement(nsGkAtoms::toolbarbutton)) {
|
||||
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
|
||||
if (fm) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
nsCOMPtr<nsIDOMElement> elementToFocus;
|
||||
// for radio buttons, focus the radiogroup instead
|
||||
if (content->IsXULElement(nsGkAtoms::radio)) {
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> controlItem(do_QueryInterface(content));
|
||||
@ -667,14 +670,19 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
if (!disabled) {
|
||||
nsCOMPtr<nsIDOMXULSelectControlElement> selectControl;
|
||||
controlItem->GetControl(getter_AddRefs(selectControl));
|
||||
element = do_QueryInterface(selectControl);
|
||||
elementToFocus = do_QueryInterface(selectControl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
element = do_QueryInterface(content);
|
||||
elementToFocus = do_QueryInterface(content);
|
||||
}
|
||||
if (elementToFocus) {
|
||||
fm->SetFocus(elementToFocus, nsIFocusManager::FLAG_BYKEY);
|
||||
|
||||
// Return true if the element became focused.
|
||||
nsPIDOMWindow* window = OwnerDoc()->GetWindow();
|
||||
focused = (window && window->GetFocusedNode());
|
||||
}
|
||||
if (element)
|
||||
fm->SetFocus(element, nsIFocusManager::FLAG_BYKEY);
|
||||
}
|
||||
}
|
||||
if (aKeyCausesActivation &&
|
||||
@ -682,8 +690,10 @@ nsXULElement::PerformAccesskey(bool aKeyCausesActivation,
|
||||
elm->ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD);
|
||||
}
|
||||
} else {
|
||||
content->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
|
||||
return content->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
|
||||
}
|
||||
|
||||
return focused;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -399,7 +399,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void PerformAccesskey(bool aKeyCausesActivation,
|
||||
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
||||
bool aIsTrustedEvent) override;
|
||||
nsresult ClickWithInputSource(uint16_t aInputSource);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user