Bug 1381615 - Remove unused fields from nsIDOMHTMLHRElement and nsIDOMHTMLOptGroupElement. r=bz draft
authorAndrew McCreight <continuation@gmail.com>
Mon, 17 Jul 2017 14:33:12 -0700
changeset 610078 1ccdd024770749db0cfb7a4994fc714fe87f9926
parent 610008 ac1f0bdffa77ff5d08f9ea58b6887d909b3fb088
child 637770 1f655909e9068f805ea2106145b837305aafc477
push id68792
push userbmo:continuation@gmail.com
push dateMon, 17 Jul 2017 23:14:24 +0000
reviewersbz
bugs1381615
milestone56.0a1
Bug 1381615 - Remove unused fields from nsIDOMHTMLHRElement and nsIDOMHTMLOptGroupElement. r=bz MozReview-Commit-ID: DSH3X3s1gsb
dom/html/HTMLHRElement.cpp
dom/html/HTMLHRElement.h
dom/html/HTMLOptGroupElement.cpp
dom/html/HTMLOptGroupElement.h
dom/interfaces/html/nsIDOMHTMLHRElement.idl
dom/interfaces/html/nsIDOMHTMLOptGroupElement.idl
layout/forms/nsListControlFrame.cpp
--- a/dom/html/HTMLHRElement.cpp
+++ b/dom/html/HTMLHRElement.cpp
@@ -22,22 +22,16 @@ HTMLHRElement::~HTMLHRElement()
 }
 
 NS_IMPL_ISUPPORTS_INHERITED(HTMLHRElement, nsGenericHTMLElement,
                             nsIDOMHTMLHRElement)
 
 NS_IMPL_ELEMENT_CLONE(HTMLHRElement)
 
 
-NS_IMPL_STRING_ATTR(HTMLHRElement, Align, align)
-NS_IMPL_BOOL_ATTR(HTMLHRElement, NoShade, noshade)
-NS_IMPL_STRING_ATTR(HTMLHRElement, Size, size)
-NS_IMPL_STRING_ATTR(HTMLHRElement, Width, width)
-NS_IMPL_STRING_ATTR(HTMLHRElement, Color, color)
-
 bool
 HTMLHRElement::ParseAttribute(int32_t aNamespaceID,
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult)
 {
   static const nsAttrValue::EnumTable kAlignTable[] = {
     { "left", NS_STYLE_TEXT_ALIGN_LEFT },
--- a/dom/html/HTMLHRElement.h
+++ b/dom/html/HTMLHRElement.h
@@ -34,43 +34,56 @@ public:
                               const nsAString& aValue,
                               nsAttrValue& aResult) override;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
                          bool aPreallocateChildren) const override;
 
   // WebIDL API
+  void GetAlign(nsAString& aValue) const
+  {
+    GetHTMLAttr(nsGkAtoms::align, aValue);
+  }
   void SetAlign(const nsAString& aAlign, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
   }
 
-  // The XPCOM GetColor is OK for us
+  void GetColor(nsAString& aValue) const
+  {
+    GetHTMLAttr(nsGkAtoms::color, aValue);
+  }
   void SetColor(const nsAString& aColor, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::color, aColor, aError);
   }
 
   bool NoShade() const
   {
    return GetBoolAttr(nsGkAtoms::noshade);
   }
   void SetNoShade(bool aNoShade, ErrorResult& aError)
   {
     SetHTMLBoolAttr(nsGkAtoms::noshade, aNoShade, aError);
   }
 
-  // The XPCOM GetSize is OK for us
+  void GetSize(nsAString& aValue) const
+  {
+    GetHTMLAttr(nsGkAtoms::size, aValue);
+  }
   void SetSize(const nsAString& aSize, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::size, aSize, aError);
   }
 
-  // The XPCOM GetWidth is OK for us
+  void GetWidth(nsAString& aValue) const
+  {
+    GetHTMLAttr(nsGkAtoms::width, aValue);
+  }
   void SetWidth(const nsAString& aWidth, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::width, aWidth, aError);
   }
 
 protected:
   virtual ~HTMLHRElement();
 
--- a/dom/html/HTMLOptGroupElement.cpp
+++ b/dom/html/HTMLOptGroupElement.cpp
@@ -38,20 +38,16 @@ HTMLOptGroupElement::~HTMLOptGroupElemen
 
 
 NS_IMPL_ISUPPORTS_INHERITED(HTMLOptGroupElement, nsGenericHTMLElement,
                             nsIDOMHTMLOptGroupElement)
 
 NS_IMPL_ELEMENT_CLONE(HTMLOptGroupElement)
 
 
-NS_IMPL_BOOL_ATTR(HTMLOptGroupElement, Disabled, disabled)
-NS_IMPL_STRING_ATTR(HTMLOptGroupElement, Label, label)
-
-
 nsresult
 HTMLOptGroupElement::GetEventTargetParent(EventChainPreVisitor& aVisitor)
 {
   aVisitor.mCanHandle = false;
   // Do not process any DOM events if the element is disabled
   // XXXsmaug This is not the right thing to do. But what is?
   if (HasAttr(kNameSpaceID_None, nsGkAtoms::disabled)) {
     return NS_OK;
--- a/dom/html/HTMLOptGroupElement.h
+++ b/dom/html/HTMLOptGroupElement.h
@@ -58,17 +58,20 @@ public:
   {
     return GetBoolAttr(nsGkAtoms::disabled);
   }
   void SetDisabled(bool aValue, ErrorResult& aError)
   {
      SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aError);
   }
 
-  // The XPCOM GetLabel is OK for us
+  void GetLabel(nsAString& aValue) const
+  {
+    GetHTMLAttr(nsGkAtoms::label, aValue);
+  }
   void SetLabel(const nsAString& aLabel, ErrorResult& aError)
   {
     SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
   }
 
 protected:
   virtual ~HTMLOptGroupElement();
 
--- a/dom/interfaces/html/nsIDOMHTMLHRElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLHRElement.idl
@@ -1,27 +1,11 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsIDOMHTMLElement.idl"
-
-/**
- * The nsIDOMHTMLHRElement interface is the interface to a [X]HTML hr
- * element.
- *
- * This interface is trying to follow the DOM Level 2 HTML specification:
- * http://www.w3.org/TR/DOM-Level-2-HTML/
- *
- * with changes from the work-in-progress WHATWG HTML specification:
- * http://www.whatwg.org/specs/web-apps/current-work/
- */
+#include "nsISupports.idl"
 
 [uuid(30771953-b9f4-44de-b0fe-e490949af98b)]
 interface nsIDOMHTMLHRElement : nsISupports
 {
-           attribute DOMString        align;
-           attribute boolean          noShade;
-           attribute DOMString        size;
-           attribute DOMString        width;
-           attribute DOMString        color;
 };
--- a/dom/interfaces/html/nsIDOMHTMLOptGroupElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLOptGroupElement.idl
@@ -1,24 +1,11 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsIDOMHTMLElement.idl"
-
-/**
- * The nsIDOMHTMLOptGroupElement interface is the interface to a
- * [X]HTML optgroup element.
- *
- * This interface is trying to follow the DOM Level 2 HTML specification:
- * http://www.w3.org/TR/DOM-Level-2-HTML/
- *
- * with changes from the work-in-progress WHATWG HTML specification:
- * http://www.whatwg.org/specs/web-apps/current-work/
- */
+#include "nsISupports.idl"
 
 [uuid(6fa79f99-4ce4-4634-840a-867fcfb32dba)]
 interface nsIDOMHTMLOptGroupElement : nsISupports
 {
-           attribute boolean          disabled;
-           attribute DOMString        label;
 };
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -7,28 +7,28 @@
 #include "nsCOMPtr.h"
 #include "nsUnicharUtils.h"
 #include "nsListControlFrame.h"
 #include "nsFormControlFrame.h" // for COMPARE macro
 #include "nsGkAtoms.h"
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsComboboxControlFrame.h"
-#include "nsIDOMHTMLOptGroupElement.h"
 #include "nsIPresShell.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIXULRuntime.h"
 #include "nsFontMetrics.h"
 #include "nsIScrollableFrame.h"
 #include "nsCSSRendering.h"
 #include "nsIDOMEventListener.h"
 #include "nsLayoutUtils.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/dom/HTMLOptGroupElement.h"
 #include "mozilla/dom/HTMLOptionsCollection.h"
 #include "mozilla/dom/HTMLSelectElement.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEvents.h"
@@ -276,18 +276,17 @@ nsListControlFrame::AccessibleType()
 #endif
 
 static nscoord
 GetMaxOptionBSize(nsIFrame* aContainer, WritingMode aWM)
 {
   nscoord result = 0;
   for (nsIFrame* option : aContainer->PrincipalChildList()) {
     nscoord optionBSize;
-    if (nsCOMPtr<nsIDOMHTMLOptGroupElement>
-        (do_QueryInterface(option->GetContent()))) {
+    if (HTMLOptGroupElement::FromContent(option->GetContent())) {
       // An optgroup; drill through any scroll frame and recurse.  |frame| might
       // be null here though if |option| is an anonymous leaf frame of some sort.
       auto frame = option->GetContentInsertionFrame();
       optionBSize = frame ? GetMaxOptionBSize(frame, aWM) : 0;
     } else {
       // an option
       optionBSize = option->BSize(aWM);
     }
@@ -745,17 +744,18 @@ CountOptionsAndOptgroups(nsIFrame* aFram
   nsFrameList::Enumerator e(aFrame->PrincipalChildList());
   for (; !e.AtEnd(); e.Next()) {
     nsIFrame* child = e.get();
     nsIContent* content = child->GetContent();
     if (content) {
       if (content->IsHTMLElement(nsGkAtoms::option)) {
         ++count;
       } else {
-        nsCOMPtr<nsIDOMHTMLOptGroupElement> optgroup = do_QueryInterface(content);
+        RefPtr<HTMLOptGroupElement> optgroup =
+          HTMLOptGroupElement::FromContent(content);
         if (optgroup) {
           nsAutoString label;
           optgroup->GetLabel(label);
           if (label.Length() > 0) {
             ++count;
           }
           count += CountOptionsAndOptgroups(child);
         }