Bug 835981 part 4. Change nsXULElement::ClickWithInputSource to return void and switch consumers of nsIDOMXULElement::Click to nsXULElement. r=peterv

This commit is contained in:
Boris Zbarsky 2017-02-02 10:32:58 -05:00
Родитель acd21dac48
Коммит e57875aac9
6 изменённых файлов: 24 добавлений и 19 удалений

Просмотреть файл

@ -15,6 +15,9 @@
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIDOMXULRelatedElement.h"
#include "nsXULElement.h"
#include "mozilla/dom/BindingDeclarations.h"
using namespace mozilla::a11y;
@ -48,9 +51,10 @@ bool
XULTabAccessible::DoAction(uint8_t index)
{
if (index == eAction_Switch) {
nsCOMPtr<nsIDOMXULElement> tab(do_QueryInterface(mContent));
// XXXbz Could this just FromContent?
RefPtr<nsXULElement> tab = nsXULElement::FromContentOrNull(mContent);
if (tab) {
tab->Click();
tab->Click(mozilla::dom::CallerType::System);
return true;
}
}

Просмотреть файл

@ -24,6 +24,8 @@ LOCAL_INCLUDES += [
'/accessible/generic',
'/accessible/html',
'/accessible/xpcom',
'/dom/base',
'/dom/xul',
'/layout/generic',
'/layout/xul',
'/layout/xul/tree',

Просмотреть файл

@ -68,7 +68,6 @@ interface nsIDOMXULElement : nsIDOMElement
void focus();
void blur();
void click();
nsIDOMNodeList getElementsByAttribute(in DOMString name,
in DOMString value);

Просмотреть файл

@ -100,7 +100,7 @@ interface XULElement : Element {
void focus();
[Throws]
void blur();
[Throws]
[NeedsCallerType]
void click();
void doCommand();

Просмотреть файл

@ -1755,23 +1755,18 @@ nsXULElement::Blur()
return rv.StealNSResult();
}
NS_IMETHODIMP
nsXULElement::Click()
void
nsXULElement::Click(CallerType aCallerType)
{
return ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN, /* aIsTrusted = */ true);
ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN,
aCallerType == CallerType::System);
}
void
nsXULElement::Click(ErrorResult& rv)
{
rv = ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN, nsContentUtils::IsCallerChrome());
}
nsresult
nsXULElement::ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent)
{
if (BoolAttrIsTrue(nsGkAtoms::disabled))
return NS_OK;
return;
nsCOMPtr<nsIDocument> doc = GetComposedDoc(); // Strong just in case
if (doc) {
@ -1807,13 +1802,13 @@ nsXULElement::ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent)
// If the click has been prevented, lets skip the command call
// this is how a physical click works
if (status == nsEventStatus_eConsumeNoDefault) {
return NS_OK;
return;
}
}
}
// oncommand is fired when an element is clicked...
return DoCommand();
DoCommand();
}
void

Просмотреть файл

@ -31,7 +31,11 @@
#include "nsGkAtoms.h"
#include "nsStyledElement.h"
#include "nsIFrameLoader.h"
#include "nsFrameLoader.h"
#include "nsFrameLoader.h" // Needed because we return an
// already_AddRefed<nsFrameLoader> where bindings
// want an already_AddRefed<nsIFrameLoader> and hence
// bindings need to know that the former can cast to
// the latter.
#include "mozilla/dom/DOMRect.h"
#include "mozilla/dom/Element.h"
@ -54,6 +58,7 @@ class StyleRule;
namespace dom {
class BoxObject;
class HTMLIFrameElement;
enum class CallerType : uint32_t;
} // namespace dom
} // namespace mozilla
@ -376,7 +381,7 @@ public:
virtual bool PerformAccesskey(bool aKeyCausesActivation,
bool aIsTrustedEvent) override;
nsresult ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent);
void ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent);
virtual nsIContent *GetBindingParent() const override;
virtual bool IsNodeOfType(uint32_t aFlags) const override;
@ -563,7 +568,7 @@ public:
already_AddRefed<nsIRDFResource> GetResource(mozilla::ErrorResult& rv);
nsIControllers* GetControllers(mozilla::ErrorResult& rv);
already_AddRefed<mozilla::dom::BoxObject> GetBoxObject(mozilla::ErrorResult& rv);
void Click(mozilla::ErrorResult& rv);
void Click(mozilla::dom::CallerType aCallerType);
void DoCommand();
already_AddRefed<nsINodeList>
GetElementsByAttribute(const nsAString& aAttribute,