Bug 1499947 - Part 1 - Remove XULProgressMeterAccessible and its base template class. r=Jamie
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Tue, 20 Nov 2018 14:10:38 +0000
changeset 503837 0f64862fa1c318d5efd7005a4fb45854351023c7
parent 503836 72521d6e680f7a0b0771d56867393ec1cadd5989
child 503838 82e8d51e41a5febd002c00fe1d33c282a58d48bb
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1499947
milestone65.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
Bug 1499947 - Part 1 - Remove XULProgressMeterAccessible and its base template class. r=Jamie Differential Revision: https://phabricator.services.mozilla.com/D12144
accessible/base/MarkupMap.h
accessible/base/Role.h
accessible/base/XULMap.h
accessible/generic/FormControlAccessible.cpp
accessible/generic/FormControlAccessible.h
accessible/html/HTMLFormControlAccessible.cpp
accessible/html/HTMLFormControlAccessible.h
accessible/interfaces/nsIAccessibleRole.idl
accessible/tests/mochitest/value/a11y.ini
accessible/tests/mochitest/value/test_progress.xul
accessible/xul/XULFormControlAccessible.h
--- a/accessible/base/MarkupMap.h
+++ b/accessible/base/MarkupMap.h
@@ -425,17 +425,17 @@ MARKUPMAP(
 
 MARKUPMAP(p,
           nullptr,
           roles::PARAGRAPH)
 
 MARKUPMAP(
   progress,
   [](Element* aElement, Accessible* aContext) -> Accessible* {
-     return new HTMLProgressMeterAccessible(aElement, aContext->Document());
+     return new HTMLProgressAccessible(aElement, aContext->Document());
   },
   0
 )
 
 MARKUPMAP(q,
           New_HyperText,
           0)
 
--- a/accessible/base/Role.h
+++ b/accessible/base/Role.h
@@ -314,17 +314,17 @@ enum Role {
 
   /**
    * Represents the calendar control.
    */
   DROPLIST = 47,
 
   /**
    * Represents a progress bar, dynamically showing the user the percent
-   * complete of an operation in progress. It is used for xul:progressmeter,
+   * complete of an operation in progress. It is used for html:progress,
    * role="progressbar".
    */
   PROGRESSBAR = 48,
 
   /**
    * Represents a dial or knob whose purpose is to allow a user to set a value.
    */
   DIAL = 49,
--- a/accessible/base/XULMap.h
+++ b/accessible/base/XULMap.h
@@ -14,17 +14,16 @@ XULMAP_TYPE(iframe, OuterDocAccessible)
 XULMAP_TYPE(listheader, XULColumAccessible)
 XULMAP_TYPE(menu, XULMenuitemAccessibleWrap)
 XULMAP_TYPE(menubar, XULMenubarAccessible)
 XULMAP_TYPE(menucaption, XULMenuitemAccessibleWrap)
 XULMAP_TYPE(menuitem, XULMenuitemAccessibleWrap)
 XULMAP_TYPE(menulist, XULComboboxAccessible)
 XULMAP_TYPE(menuseparator, XULMenuSeparatorAccessible)
 XULMAP_TYPE(notification, XULAlertAccessible)
-XULMAP_TYPE(progressmeter, XULProgressMeterAccessible)
 XULMAP_TYPE(radio, XULRadioButtonAccessible)
 XULMAP_TYPE(radiogroup, XULRadioGroupAccessible)
 XULMAP_TYPE(richlistbox, XULListboxAccessibleWrap)
 XULMAP_TYPE(richlistitem, XULListitemAccessible)
 XULMAP_TYPE(statusbar, XULStatusBarAccessible)
 XULMAP_TYPE(tab, XULTabAccessible)
 XULMAP_TYPE(tabpanels, XULTabpanelsAccessible)
 XULMAP_TYPE(tabs, XULTabsAccessible)
--- a/accessible/generic/FormControlAccessible.cpp
+++ b/accessible/generic/FormControlAccessible.cpp
@@ -9,146 +9,16 @@
 
 #include "mozilla/dom/HTMLInputElement.h"
 #include "mozilla/FloatingPoint.h"
 #include "Role.h"
 
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
-// ProgressMeterAccessible
-////////////////////////////////////////////////////////////////////////////////
-
-template class mozilla::a11y::ProgressMeterAccessible<1>;
-template class mozilla::a11y::ProgressMeterAccessible<100>;
-
-////////////////////////////////////////////////////////////////////////////////
-// Accessible
-
-template<int Max>
-role
-ProgressMeterAccessible<Max>::NativeRole() const
-{
-  return roles::PROGRESSBAR;
-}
-
-template<int Max>
-uint64_t
-ProgressMeterAccessible<Max>::NativeState() const
-{
-  uint64_t state = LeafAccessible::NativeState();
-
-  // An undetermined progressbar (i.e. without a value) has a mixed state.
-  nsAutoString attrValue;
-  mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue);
-
-  if (attrValue.IsEmpty())
-    state |= states::MIXED;
-
-  return state;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ProgressMeterAccessible<Max>: Widgets
-
-template<int Max>
-bool
-ProgressMeterAccessible<Max>::IsWidget() const
-{
-  return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ProgressMeterAccessible<Max>: Value
-
-template<int Max>
-void
-ProgressMeterAccessible<Max>::Value(nsString& aValue) const
-{
-  LeafAccessible::Value(aValue);
-  if (!aValue.IsEmpty())
-    return;
-
-  double maxValue = MaxValue();
-  if (IsNaN(maxValue) || maxValue == 0)
-    return;
-
-  double curValue = CurValue();
-  if (IsNaN(curValue))
-    return;
-
-  // Treat the current value bigger than maximum as 100%.
-  double percentValue = (curValue < maxValue) ?
-    (curValue / maxValue) * 100 : 100;
-
-  aValue.AppendFloat(percentValue);
-  aValue.Append('%');
-}
-
-template<int Max>
-double
-ProgressMeterAccessible<Max>::MaxValue() const
-{
-  double value = LeafAccessible::MaxValue();
-  if (!IsNaN(value))
-    return value;
-
-  nsAutoString strValue;
-  if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::max, strValue)) {
-    nsresult result = NS_OK;
-    value = strValue.ToDouble(&result);
-    if (NS_SUCCEEDED(result))
-      return value;
-  }
-
-  return Max;
-}
-
-template<int Max>
-double
-ProgressMeterAccessible<Max>::MinValue() const
-{
-  double value = LeafAccessible::MinValue();
-  return IsNaN(value) ? 0 : value;
-}
-
-template<int Max>
-double
-ProgressMeterAccessible<Max>::Step() const
-{
-  double value = LeafAccessible::Step();
-  return IsNaN(value) ? 0 : value;
-}
-
-template<int Max>
-double
-ProgressMeterAccessible<Max>::CurValue() const
-{
-  double value = LeafAccessible::CurValue();
-  if (!IsNaN(value))
-    return value;
-
-  nsAutoString attrValue;
-  if (!mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue))
-    return UnspecifiedNaN<double>();
-
-  nsresult error = NS_OK;
-  value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
-}
-
-template<int Max>
-bool
-ProgressMeterAccessible<Max>::SetCurValue(double aValue)
-{
-  return false; // progress meters are readonly.
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
 // CheckboxAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 role
 CheckboxAccessible::NativeRole() const
 {
   return roles::CHECKBUTTON;
 }
--- a/accessible/generic/FormControlAccessible.h
+++ b/accessible/generic/FormControlAccessible.h
@@ -7,51 +7,16 @@
 #define MOZILLA_A11Y_FormControlAccessible_H_
 
 #include "BaseAccessibles.h"
 
 namespace mozilla {
 namespace a11y {
 
 /**
-  * Generic class used for progress meters.
-  */
-template<int Max>
-class ProgressMeterAccessible : public LeafAccessible
-{
-public:
-  ProgressMeterAccessible(nsIContent* aContent, DocAccessible* aDoc) :
-    LeafAccessible(aContent, aDoc)
-  {
-    // Ignore 'ValueChange' DOM event in lieu of @value attribute change
-    // notifications.
-    mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent;
-    mType = eProgressType;
-  }
-
-  // Accessible
-  virtual void Value(nsString& aValue) const override;
-  virtual mozilla::a11y::role NativeRole() const override;
-  virtual uint64_t NativeState() const override;
-
-  // Value
-  virtual double MaxValue() const override;
-  virtual double MinValue() const override;
-  virtual double CurValue() const override;
-  virtual double Step() const override;
-  virtual bool SetCurValue(double aValue) override;
-
-  // Widgets
-  virtual bool IsWidget() const override;
-
-protected:
-  virtual ~ProgressMeterAccessible() {}
-};
-
-/**
  * Checkbox accessible.
  */
 class CheckboxAccessible : public LeafAccessible
 {
 
 public:
   enum { eAction_Click = 0 };
 
--- a/accessible/html/HTMLFormControlAccessible.cpp
+++ b/accessible/html/HTMLFormControlAccessible.cpp
@@ -800,8 +800,126 @@ HTMLFigcaptionAccessible::RelationByType
   if (figure &&
       figure->GetContent()->NodeInfo()->Equals(nsGkAtoms::figure,
                                                mContent->GetNameSpaceID())) {
     rel.AppendTarget(figure);
   }
 
   return rel;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+// HTMLProgressAccessible
+////////////////////////////////////////////////////////////////////////////////
+
+role
+HTMLProgressAccessible::NativeRole() const
+{
+  return roles::PROGRESSBAR;
+}
+
+uint64_t
+HTMLProgressAccessible::NativeState() const
+{
+  uint64_t state = LeafAccessible::NativeState();
+
+  // An undetermined progressbar (i.e. without a value) has a mixed state.
+  nsAutoString attrValue;
+  mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
+                                 attrValue);
+  if (attrValue.IsEmpty()) {
+    state |= states::MIXED;
+  }
+
+  return state;
+}
+
+bool
+HTMLProgressAccessible::IsWidget() const
+{
+  return true;
+}
+
+void
+HTMLProgressAccessible::Value(nsString& aValue) const
+{
+  LeafAccessible::Value(aValue);
+  if (!aValue.IsEmpty()) {
+    return;
+  }
+
+  double maxValue = MaxValue();
+  if (IsNaN(maxValue) || maxValue == 0) {
+    return;
+  }
+
+  double curValue = CurValue();
+  if (IsNaN(curValue)) {
+    return;
+  }
+
+  // Treat the current value bigger than maximum as 100%.
+  double percentValue = (curValue < maxValue) ? (curValue / maxValue) * 100
+                                              : 100;
+
+  aValue.AppendFloat(percentValue);
+  aValue.Append('%');
+}
+
+double
+HTMLProgressAccessible::MaxValue() const
+{
+  double value = LeafAccessible::MaxValue();
+  if (!IsNaN(value)) {
+    return value;
+  }
+
+  nsAutoString strValue;
+  if (mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::max,
+                                     strValue)) {
+    nsresult result = NS_OK;
+    value = strValue.ToDouble(&result);
+    if (NS_SUCCEEDED(result)) {
+      return value;
+    }
+  }
+
+  return 1;
+}
+
+double
+HTMLProgressAccessible::MinValue() const
+{
+  double value = LeafAccessible::MinValue();
+  return IsNaN(value) ? 0 : value;
+}
+
+double
+HTMLProgressAccessible::Step() const
+{
+  double value = LeafAccessible::Step();
+  return IsNaN(value) ? 0 : value;
+}
+
+double
+HTMLProgressAccessible::CurValue() const
+{
+  double value = LeafAccessible::CurValue();
+  if (!IsNaN(value)) {
+    return value;
+  }
+
+  nsAutoString attrValue;
+  if (!mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
+                                      attrValue)) {
+    return UnspecifiedNaN<double>();
+  }
+
+  nsresult error = NS_OK;
+  value = attrValue.ToDouble(&error);
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
+}
+
+bool
+HTMLProgressAccessible::SetCurValue(double aValue)
+{
+  return false; // progress meters are readonly.
+}
--- a/accessible/html/HTMLFormControlAccessible.h
+++ b/accessible/html/HTMLFormControlAccessible.h
@@ -9,21 +9,16 @@
 #include "FormControlAccessible.h"
 #include "HyperTextAccessibleWrap.h"
 
 namespace mozilla {
 class TextEditor;
 namespace a11y {
 
 /**
- * Accessible for HTML progress element.
- */
-typedef ProgressMeterAccessible<1> HTMLProgressMeterAccessible;
-
-/**
  * Accessible for HTML input@type="radio" element.
  */
 class HTMLRadioButtonAccessible : public RadioButtonAccessible
 {
 
 public:
   HTMLRadioButtonAccessible(nsIContent* aContent, DocAccessible* aDoc) :
     RadioButtonAccessible(aContent, aDoc)
@@ -265,12 +260,47 @@ public:
   // Accessible
   virtual nsAtom* LandmarkRole() const override;
   virtual a11y::role NativeRole() const override;
 
 protected:
   virtual ~HTMLFormAccessible() = default;
 };
 
+/**
+ * Accessible for HTML progress element.
+ */
+
+class HTMLProgressAccessible : public LeafAccessible
+{
+public:
+  HTMLProgressAccessible(nsIContent* aContent, DocAccessible* aDoc) :
+    LeafAccessible(aContent, aDoc)
+  {
+    // Ignore 'ValueChange' DOM event in lieu of @value attribute change
+    // notifications.
+    mStateFlags |= eHasNumericValue | eIgnoreDOMUIEvent;
+    mType = eProgressType;
+  }
+
+  // Accessible
+  virtual void Value(nsString& aValue) const override;
+  virtual mozilla::a11y::role NativeRole() const override;
+  virtual uint64_t NativeState() const override;
+
+  // Value
+  virtual double MaxValue() const override;
+  virtual double MinValue() const override;
+  virtual double CurValue() const override;
+  virtual double Step() const override;
+  virtual bool SetCurValue(double aValue) override;
+
+  // Widgets
+  virtual bool IsWidget() const override;
+
+protected:
+  virtual ~HTMLProgressAccessible() {}
+};
+
 } // namespace a11y
 } // namespace mozilla
 
 #endif
--- a/accessible/interfaces/nsIAccessibleRole.idl
+++ b/accessible/interfaces/nsIAccessibleRole.idl
@@ -307,17 +307,17 @@ interface nsIAccessibleRole : nsISupport
 
   /**
    * Represents the calendar control.
    */
   const unsigned long ROLE_DROPLIST = 47;
 
   /**
    * Represents a progress bar, dynamically showing the user the percent
-   * complete of an operation in progress. It is used for xul:progressmeter,
+   * complete of an operation in progress. It is used for html:progress,
    * role="progressbar".
    */
   const unsigned long ROLE_PROGRESSBAR = 48;
 
   /**
    * Represents a dial or knob whose purpose is to allow a user to set a value.
    */
   const unsigned long ROLE_DIAL = 49;
--- a/accessible/tests/mochitest/value/a11y.ini
+++ b/accessible/tests/mochitest/value/a11y.ini
@@ -1,9 +1,8 @@
 [DEFAULT]
 support-files =
   !/accessible/tests/mochitest/*.js
 
 [test_general.html]
 [test_number.html]
 [test_progress.html]
-[test_progress.xul]
 [test_range.html]
deleted file mode 100644
--- a/accessible/tests/mochitest/value/test_progress.xul
+++ /dev/null
@@ -1,68 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
-<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
-                 type="text/css"?>
-
-<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="XUL progressmeter tests">
-
-  <script type="application/javascript"
-          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
-
-  <script type="application/javascript"
-          src="../common.js" />
-  <script type="application/javascript"
-          src="../value.js" />
-
-  <script type="application/javascript">
-  <![CDATA[
-    function doTest()
-    {
-      // progressmeter
-      testValue("pm1", "50%", 50, 0, 100, 0);
-      testValue("pm2", "50%", 500, 0, 1000, 0);
-      testValue("pm3", "", 0, 0, 100, 0);
-      testValue("pm4", "", 0, 0, 100, 0);
-
-      // aria progressbar
-      testValue("ariapb1", "500", 500, 0, 1000, 0);
-      testValue("ariapb2", "", 0, 0, 0, 0);
-
-      SimpleTest.finish();
-    }
-
-    SimpleTest.waitForExplicitFinish();
-    addA11yLoadEvent(doTest);
-  ]]>
-  </script>
-
-  <hbox flex="1" style="overflow: auto;">
-    <body xmlns="http://www.w3.org/1999/xhtml">
-      <a target="_blank"
-         href="https://bugzilla.mozilla.org/show_bug.cgi?id=489551"
-         title="Values of sliders and progress bars in HTML 5 audio and video element's control sets are not percentages">
-        Mozilla Bug 489551
-      </a><br/>
-      <p id="display"></p>
-      <div id="content" style="display: none">
-      </div>
-      <pre id="test">
-      </pre>
-    </body>
-
-    <!-- progressmeter -->
-    <vbox>
-      <progressmeter id="pm1" value="50"/>
-      <progressmeter id="pm2" value="500" max="1000"/>
-      <progressmeter id="pm3"/>
-      <progressmeter id="pm4" mode="undetermined"/>
-    </vbox>
-
-    <!-- aria -->
-    <description id="ariapb1" role="progressbar"
-                 aria-valuenow="500" aria-valuemin="0" aria-valuemax="1000"/>
-    <description id="ariapb2" role="progressbar"/>
-  </hbox>
-
-</window>
-
--- a/accessible/xul/XULFormControlAccessible.h
+++ b/accessible/xul/XULFormControlAccessible.h
@@ -11,21 +11,16 @@
 #include "FormControlAccessible.h"
 #include "HyperTextAccessibleWrap.h"
 #include "XULSelectControlAccessible.h"
 
 namespace mozilla {
 namespace a11y {
 
 /**
- * Used for XUL progressmeter element.
- */
-typedef ProgressMeterAccessible<100> XULProgressMeterAccessible;
-
-/**
  * Used for XUL button.
  *
  * @note  Don't inherit from LeafAccessible - it doesn't allow children
  *         and a button can have a dropmarker child.
  */
 class XULButtonAccessible : public AccessibleWrap
 {
 public: