Bug 1432944 part 8. Remove usage of nsIDOMElement::HasAttribute in editor code. r=m_kato
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 29 Jan 2018 23:27:59 -0500
changeset 748736 e7ad723a13ffdea0ced1ea4be9c4016420ddfcea
parent 748735 2b200ba1a37e77ad56184d9e1206129a5c5e684d
child 748737 a5250222f3d5e1c1a21990cef6735bd713ba7241
push id97228
push usersfraser@mozilla.com
push dateTue, 30 Jan 2018 10:21:04 +0000
reviewersm_kato
bugs1432944
milestone60.0a1
Bug 1432944 part 8. Remove usage of nsIDOMElement::HasAttribute in editor code. r=m_kato MozReview-Commit-ID: 926Dzqv7Oj4
editor/libeditor/HTMLEditorObjectResizer.cpp
--- a/editor/libeditor/HTMLEditorObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -519,39 +519,40 @@ HTMLEditor::StartResizing(nsIDOMElement*
 }
 
 nsresult
 HTMLEditor::OnMouseDown(int32_t aClientX,
                         int32_t aClientY,
                         nsIDOMElement* aTarget,
                         nsIDOMEvent* aEvent)
 {
-  bool anonElement = false;
-  if (aTarget && NS_SUCCEEDED(aTarget->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)))
-    // we caught a click on an anonymous element
-    if (anonElement) {
-      nsAutoString anonclass;
-      nsresult rv =
-        aTarget->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
-      NS_ENSURE_SUCCESS(rv, rv);
-      if (anonclass.EqualsLiteral("mozResizer")) {
-        // and that element is a resizer, let's start resizing!
-        aEvent->PreventDefault();
+  nsCOMPtr<Element> element = do_QueryInterface(aTarget);
+  NS_ENSURE_ARG_POINTER(element);
+
+  nsAutoString anonclass;
+  element->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass);
+
+  if (anonclass.EqualsLiteral("mozResizer")) {
+    // If we have an anonymous element and that element is a resizer,
+    // let's start resizing!
+    aEvent->PreventDefault();
 
-        mOriginalX = aClientX;
-        mOriginalY = aClientY;
-        return StartResizing(aTarget);
-      }
-      if (anonclass.EqualsLiteral("mozGrabber")) {
-        // and that element is a grabber, let's start moving the element!
-        mOriginalX = aClientX;
-        mOriginalY = aClientY;
-        return GrabberClicked();
-      }
-    }
+    mOriginalX = aClientX;
+    mOriginalY = aClientY;
+    return StartResizing(aTarget);
+  }
+
+  if (anonclass.EqualsLiteral("mozGrabber")) {
+    // If we have an anonymous element and that element is a grabber,
+    // let's start moving the element!
+    mOriginalX = aClientX;
+    mOriginalY = aClientY;
+    return GrabberClicked();
+  }
+
   return NS_OK;
 }
 
 nsresult
 HTMLEditor::OnMouseUp(int32_t aClientX,
                       int32_t aClientY,
                       nsIDOMElement* aTarget)
 {