Fix for bug 815158 (Make HTMLElement.ontouch* work with tristate dom.w3c_touch_events.enabled). r=bz.

--HG--
extra : rebase_source : 878d559d1a57ad69bdac7bea682ea344ecdea96a
This commit is contained in:
Peter Van der Beken 2012-11-19 11:59:13 +01:00
Родитель fcaf160cf1
Коммит ba333c8392
3 изменённых файлов: 28 добавлений и 6 удалений

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

@ -100,6 +100,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/ErrorResult.h"
#include "nsHTMLDocument.h"
#include "nsDOMTouchEvent.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -2906,6 +2907,24 @@ nsGenericHTMLElement::IsLabelable() const
Tag() == nsGkAtoms::meter;
}
// static
bool
nsGenericHTMLElement::PrefEnabled()
{
// This is a bit of a hack because we don't support non-bool prefs to enable
// properties. This function will be called every time a HTMLElement interface
// prototype object is created. The first time this is called we set a boolean
// pref (dom.w3c_touch_events.expose) which controls the touch event
// properties on HTMLElement.
static bool sDidSetPref = false;
if (!sDidSetPref) {
sDidSetPref = true;
Preferences::SetBool("dom.w3c_touch_events.expose",
nsDOMTouchEvent::PrefEnabled());
}
return true;
}
//----------------------------------------------------------------------
nsGenericHTMLFormElement::nsGenericHTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo)

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

@ -715,6 +715,8 @@ public:
virtual bool IsLabelable() const;
static bool PrefEnabled();
protected:
/**
* Add/remove this element to the documents name cache

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

@ -15,6 +15,7 @@
interface DOMStringMap;
interface HTMLMenuElement;
[PrefControlled]
interface HTMLElement : Element {
// metadata attributes
attribute DOMString title;
@ -207,17 +208,17 @@ interface HTMLElement : Element {
[SetterThrows]
attribute EventHandler onwheel;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchstart;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchend;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchmove;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchenter;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchleave;
[SetterThrows,Pref="dom.w3c_touch_events.enabled"]
[SetterThrows,Pref="dom.w3c_touch_events.expose"]
attribute EventHandler ontouchcancel;
[SetterThrows]