Bug 1432977 part 3. Remove nsIDOMHTMLElement's offsetWidth/Height attributes. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 29 Jan 2018 23:40:11 -0500
changeset 748744 c1deaf1c9d505039a3ad7bf295d0a80a0d798dd0
parent 748743 b99a55d47c97b9735dad72c782155b5b2a3d93e8
child 748745 e8d6e35f38a79effea655ba3aecb173a067bf5dc
push id97228
push usersfraser@mozilla.com
push dateTue, 30 Jan 2018 10:21:04 +0000
reviewersmccr8
bugs1432977
milestone60.0a1
Bug 1432977 part 3. Remove nsIDOMHTMLElement's offsetWidth/Height attributes. r=mccr8 MozReview-Commit-ID: EoSwBkeGj60
dom/html/nsGenericHTMLElement.h
dom/interfaces/html/nsIDOMHTMLElement.idl
editor/libeditor/HTMLAnonymousNodeEditor.cpp
editor/libeditor/HTMLInlineTableEditor.cpp
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -264,28 +264,16 @@ public:
   /**
    * Get width and height, using given image request if attributes are unset.
    * Pass a reference to the image request, since the method may change the
    * value and we want to use the updated value.
    */
   MOZ_CAN_RUN_SCRIPT
   nsSize GetWidthHeightForImage(RefPtr<imgRequestProxy>& aImageRequest);
 
-  // XPIDL methods
-  NS_IMETHOD GetOffsetWidth(int32_t* aOffsetWidth) final override {
-    *aOffsetWidth = OffsetWidth();
-    return NS_OK;
-  }
-  NS_IMETHOD GetOffsetHeight(int32_t* aOffsetHeight) final override {
-    *aOffsetHeight = OffsetHeight();
-    return NS_OK;
-  }
-
-  using nsGenericHTMLElementBase::GetOwnerDocument;
-
   virtual nsIDOMNode* AsDOMNode() override { return this; }
 
 public:
   // Implementation for nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers) override;
   virtual void UnbindFromTree(bool aDeep = true,
--- a/dom/interfaces/html/nsIDOMHTMLElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLElement.idl
@@ -1,28 +1,22 @@
 /* -*- 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 "nsIDOMElement.idl"
-#include "nsIVariant.idl"
-
-interface nsIDOMHTMLMenuElement;
 
 /**
  * The nsIDOMHTMLElement interface is the primary [X]HTML element
  * interface. It represents a single [X]HTML element in the document
  * tree.
  *
  * 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/
  */
 [uuid(b0c42392-d0e7-4f6a-beb5-a698ce648945)]
 interface nsIDOMHTMLElement : nsIDOMElement
 {
-  // CSSOM View
-  readonly attribute long             offsetWidth;
-  readonly attribute long             offsetHeight;
 };
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -8,23 +8,23 @@
 #include "mozilla/dom/CSSPrimitiveValueBinding.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/mozalloc.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsComputedDOMStyle.h"
 #include "nsDebug.h"
 #include "nsError.h"
+#include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsAtom.h"
 #include "nsIContent.h"
 #include "nsID.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEventTarget.h"
-#include "nsIDOMHTMLElement.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsIDocumentObserver.h"
 #include "nsIHTMLAbsPosEditor.h"
 #include "nsIHTMLInlineTableEditor.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsStubMutationObserver.h"
@@ -517,26 +517,25 @@ HTMLEditor::GetPositionAndDimensions(Ele
     aX = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("left")) +
          aMarginLeft + aBorderLeft;
     aY = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("top")) +
          aMarginTop + aBorderTop;
     aW = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("width"));
     aH = GetCSSFloatValue(cssDecl, NS_LITERAL_STRING("height"));
   } else {
     mResizedObjectIsAbsolutelyPositioned = false;
-    nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(&aElement);
+    RefPtr<nsGenericHTMLElement> htmlElement =
+      nsGenericHTMLElement::FromContent(&aElement);
     if (!htmlElement) {
       return NS_ERROR_NULL_POINTER;
     }
     GetElementOrigin(aElement, aX, aY);
 
-    if (NS_WARN_IF(NS_FAILED(htmlElement->GetOffsetWidth(&aW))) ||
-        NS_WARN_IF(NS_FAILED(htmlElement->GetOffsetHeight(&aH)))) {
-      return NS_ERROR_FAILURE;
-    }
+    aW = htmlElement->OffsetWidth();
+    aH = htmlElement->OffsetHeight();
 
     aBorderLeft = 0;
     aBorderTop  = 0;
     aMarginLeft = 0;
     aMarginTop = 0;
   }
   return NS_OK;
 }
--- a/editor/libeditor/HTMLInlineTableEditor.cpp
+++ b/editor/libeditor/HTMLInlineTableEditor.cpp
@@ -5,20 +5,20 @@
 #include "mozilla/HTMLEditor.h"
 
 #include "HTMLEditUtils.h"
 #include "mozilla/dom/Element.h"
 #include "nsAString.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsError.h"
+#include "nsGenericHTMLElement.h"
 #include "nsIContent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMEventTarget.h"
-#include "nsIDOMHTMLElement.h"
 #include "nsIDOMNode.h"
 #include "nsIHTMLObjectResizer.h"
 #include "nsIPresShell.h"
 #include "nsLiteralString.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 #include "nscore.h"
 
@@ -199,35 +199,34 @@ HTMLEditor::RemoveMouseClickListener(Ele
 
 NS_IMETHODIMP
 HTMLEditor::RefreshInlineTableEditingUI()
 {
   if (!mInlineEditedCell) {
    return NS_OK;
   }
 
-  nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(mInlineEditedCell);
+  RefPtr<nsGenericHTMLElement> htmlElement =
+    nsGenericHTMLElement::FromContent(mInlineEditedCell);
   if (!htmlElement) {
     return NS_ERROR_NULL_POINTER;
   }
 
   int32_t xCell, yCell, wCell, hCell;
   GetElementOrigin(*mInlineEditedCell, xCell, yCell);
 
-  nsresult rv = htmlElement->GetOffsetWidth(&wCell);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = htmlElement->GetOffsetHeight(&hCell);
-  NS_ENSURE_SUCCESS(rv, rv);
+  wCell = htmlElement->OffsetWidth();
+  hCell = htmlElement->OffsetHeight();
 
   int32_t xHoriz = xCell + wCell/2;
   int32_t yVert  = yCell + hCell/2;
 
   RefPtr<Element> tableElement = GetEnclosingTable(mInlineEditedCell);
   int32_t rowCount, colCount;
-  rv = GetTableSize(tableElement, &rowCount, &colCount);
+  nsresult rv = GetTableSize(tableElement, &rowCount, &colCount);
   NS_ENSURE_SUCCESS(rv, rv);
 
   SetAnonymousElementPosition(xHoriz-10, yCell-7,  mAddColumnBeforeButton);
 #ifdef DISABLE_TABLE_DELETION
   if (colCount== 1) {
     mRemoveColumnButton->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                                  NS_LITERAL_STRING("hidden"), true);
   } else {