Fix for bug 815158 (Make HTMLElement.ontouch* work with tristate dom.w3c_touch_events.enabled). r=bz.
☠☠ backed out by 5de5d3950328 ☠ ☠
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 19 Nov 2012 11:59:13 +0100 (2012-11-19)
changeset 114277 0c2011091748a5b5c1d9a4dd8705727aff6525f2
parent 114276 9d70b44605083e84de6971479a151c1bb4532ddc
child 114278 8aa207f87eb6e4055c649ffcd2f6ceee7cc296c3
push id18660
push userpvanderbeken@mozilla.com
push dateTue, 27 Nov 2012 20:40:27 +0000 (2012-11-27)
treeherdermozilla-inbound@0c2011091748 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs815158
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Fix for bug 815158 (Make HTMLElement.ontouch* work with tristate dom.w3c_touch_events.enabled). r=bz.
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
dom/webidl/HTMLElement.webidl
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -95,16 +95,17 @@
 #include "HTMLPropertiesCollection.h"
 #include "nsVariant.h"
 #include "nsDOMSettableTokenList.h"
 #include "nsThreadUtils.h"
 #include "nsTextFragment.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/ErrorResult.h"
 #include "nsHTMLDocument.h"
+#include "nsDOMTouchEvent.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class nsINodeInfo;
 class nsIDOMNodeList;
 class nsRuleWalker;
 
@@ -2901,16 +2902,34 @@ nsGenericHTMLElement::GetContextMenu(nsI
 
 bool
 nsGenericHTMLElement::IsLabelable() const
 {
   return Tag() == nsGkAtoms::progress ||
          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)
   : nsGenericHTMLElement(aNodeInfo)
   , mForm(nullptr)
   , mFieldSet(nullptr)
 {
   // We should add the NS_EVENT_STATE_ENABLED bit here as needed, but
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -710,16 +710,18 @@ public:
 
   bool IsHidden() const
   {
     return HasAttr(kNameSpaceID_None, nsGkAtoms::hidden);
   }
 
   virtual bool IsLabelable() const;
 
+  static bool PrefEnabled();
+
 protected:
   /**
    * Add/remove this element to the documents name cache
    */
   void AddToNameTable(nsIAtom* aName) {
     NS_ASSERTION(HasName(), "Node doesn't have name?");
     nsIDocument* doc = GetCurrentDoc();
     if (doc && !IsInAnonymousSubtree()) {
--- a/dom/webidl/HTMLElement.webidl
+++ b/dom/webidl/HTMLElement.webidl
@@ -10,16 +10,17 @@
  * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 
 interface DOMStringMap;
 interface HTMLMenuElement;
 
+[PrefControlled]
 interface HTMLElement : Element {
   // metadata attributes
            attribute DOMString title;
            attribute DOMString lang;
   //         attribute boolean translate;
   [SetterThrows]
            attribute DOMString dir;
   readonly attribute DOMStringMap dataset;
@@ -195,27 +196,27 @@ interface HTMLElement : Element {
            attribute EventHandler onmozpointerlockchange;
   [SetterThrows]
            attribute EventHandler onmozpointerlockerror;
 
   // Mozilla specific stuff
   // FIXME Bug 810677 Move className from HTMLElement to Element
            attribute DOMString className;
 
-  [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]
            attribute EventHandler oncopy;
   [SetterThrows]
            attribute EventHandler oncut;
   [SetterThrows]
            attribute EventHandler onpaste;