Backout 54c4f2ff78e3 (bug 807075) for Windows compilation errors
authorEd Morley <emorley@mozilla.com>
Wed, 14 Nov 2012 16:45:28 +0000
changeset 113239 a6305a66f8c1b5efda5ba0bb19111040fdd40b5a
parent 113238 f0a74ea50bc49875b2141a5bf54f3b316596c951
child 113240 11b76ebcd3c280a5a7b10fd904988f64ba453a7a
push id18027
push useremorley@mozilla.com
push dateWed, 14 Nov 2012 16:45:44 +0000
treeherdermozilla-inbound@a6305a66f8c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs807075
milestone19.0a1
backs out54c4f2ff78e3d4c2c261ea70333d8527ee68e23f
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
Backout 54c4f2ff78e3 (bug 807075) for Windows compilation errors
accessible/src/html/HTMLFormControlAccessible.cpp
content/base/src/nsGenericElement.cpp
content/base/src/nsGenericElement.h
content/base/src/nsObjectLoadingContent.h
content/base/src/nsStyledElement.cpp
content/base/src/nsStyledElement.h
content/canvas/src/CanvasUtils.cpp
content/html/content/public/nsHTMLAudioElement.h
content/html/content/public/nsHTMLCanvasElement.h
content/html/content/public/nsHTMLVideoElement.h
content/html/content/src/Makefile.in
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
content/html/content/src/nsHTMLAnchorElement.cpp
content/html/content/src/nsHTMLAreaElement.cpp
content/html/content/src/nsHTMLBRElement.cpp
content/html/content/src/nsHTMLBodyElement.cpp
content/html/content/src/nsHTMLButtonElement.cpp
content/html/content/src/nsHTMLDataListElement.cpp
content/html/content/src/nsHTMLDivElement.cpp
content/html/content/src/nsHTMLDivElement.h
content/html/content/src/nsHTMLElement.cpp
content/html/content/src/nsHTMLFieldSetElement.h
content/html/content/src/nsHTMLFontElement.cpp
content/html/content/src/nsHTMLFormElement.h
content/html/content/src/nsHTMLFrameElement.cpp
content/html/content/src/nsHTMLFrameSetElement.h
content/html/content/src/nsHTMLHRElement.cpp
content/html/content/src/nsHTMLHeadingElement.cpp
content/html/content/src/nsHTMLIFrameElement.h
content/html/content/src/nsHTMLImageElement.h
content/html/content/src/nsHTMLInputElement.cpp
content/html/content/src/nsHTMLInputElement.h
content/html/content/src/nsHTMLLIElement.cpp
content/html/content/src/nsHTMLLabelElement.h
content/html/content/src/nsHTMLLegendElement.h
content/html/content/src/nsHTMLLinkElement.cpp
content/html/content/src/nsHTMLMapElement.cpp
content/html/content/src/nsHTMLMenuElement.h
content/html/content/src/nsHTMLMenuItemElement.h
content/html/content/src/nsHTMLMetaElement.cpp
content/html/content/src/nsHTMLMeterElement.cpp
content/html/content/src/nsHTMLModElement.cpp
content/html/content/src/nsHTMLOListElement.cpp
content/html/content/src/nsHTMLObjectElement.cpp
content/html/content/src/nsHTMLOptGroupElement.h
content/html/content/src/nsHTMLOptionElement.h
content/html/content/src/nsHTMLOutputElement.cpp
content/html/content/src/nsHTMLParagraphElement.cpp
content/html/content/src/nsHTMLPreElement.cpp
content/html/content/src/nsHTMLProgressElement.cpp
content/html/content/src/nsHTMLScriptElement.cpp
content/html/content/src/nsHTMLSelectElement.cpp
content/html/content/src/nsHTMLSelectElement.h
content/html/content/src/nsHTMLSharedElement.cpp
content/html/content/src/nsHTMLSharedObjectElement.cpp
content/html/content/src/nsHTMLSourceElement.cpp
content/html/content/src/nsHTMLSpanElement.cpp
content/html/content/src/nsHTMLStyleElement.cpp
content/html/content/src/nsHTMLTableCaptionElement.cpp
content/html/content/src/nsHTMLTableCellElement.cpp
content/html/content/src/nsHTMLTableColElement.cpp
content/html/content/src/nsHTMLTableElement.h
content/html/content/src/nsHTMLTableRowElement.cpp
content/html/content/src/nsHTMLTableSectionElement.cpp
content/html/content/src/nsHTMLTextAreaElement.cpp
content/html/content/src/nsHTMLTitleElement.cpp
content/html/content/src/nsHTMLUnknownElement.cpp
content/html/content/src/nsHTMLUnknownElement.h
content/svg/content/src/nsSVGStylableElement.h
dom/interfaces/html/nsIDOMHTMLElement.idl
dom/webidl/HTMLDivElement.webidl
dom/webidl/HTMLElement.webidl
js/xpconnect/src/dom_quickstubs.qsconf
js/xpconnect/src/nsDOMQS.h
--- a/accessible/src/html/HTMLFormControlAccessible.cpp
+++ b/accessible/src/html/HTMLFormControlAccessible.cpp
@@ -470,17 +470,17 @@ HTMLTextFieldAccessible::GetActionName(u
 }
 
 NS_IMETHODIMP
 HTMLTextFieldAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex == 0) {
     nsHTMLInputElement* element = nsHTMLInputElement::FromContent(mContent);
     if (element)
-      return element->Focus();
+      return element->DOMFocus();
 
     return NS_ERROR_FAILURE;
   }
   return NS_ERROR_INVALID_ARG;
 }
 
 already_AddRefed<nsIEditor>
 HTMLTextFieldAccessible::GetEditor() const
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -483,40 +483,39 @@ nsGenericElement::GetElementsByTagName(c
 
 nsIFrame*
 nsGenericElement::GetStyledFrame()
 {
   nsIFrame *frame = GetPrimaryFrame(Flush_Layout);
   return frame ? nsLayoutUtils::GetStyleFrame(frame) : nullptr;
 }
 
-nsGenericElement*
-nsGenericElement::GetOffsetRect(nsRect& aRect)
+void
+nsGenericElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
 {
+  *aOffsetParent = nullptr;
   aRect = nsRect();
 
   nsIFrame* frame = GetStyledFrame();
   if (!frame) {
-    return nullptr;
+    return;
   }
 
   nsPoint origin = frame->GetPosition();
   aRect.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
   aRect.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
 
   // Get the union of all rectangles in this and continuation frames.
   // It doesn't really matter what we use as aRelativeTo here, since
   // we only care about the size. Using 'parent' might make things
   // a bit faster by speeding up the internal GetOffsetTo operations.
   nsIFrame* parent = frame->GetParent() ? frame->GetParent() : frame;
   nsRect rcFrame = nsLayoutUtils::GetAllInFlowRectsUnion(frame, parent);
   aRect.width = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.width);
   aRect.height = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.height);
-
-  return nullptr;
 }
 
 nsIntSize
 nsGenericElement::GetPaddingRectSize()
 {
   nsIFrame* frame = GetStyledFrame();
   if (!frame) {
     return nsIntSize(0, 0);
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -663,22 +663,22 @@ protected:
 
   /**
    * Internal hook for converting an attribute name-string to an atomized name
    */
   virtual const nsAttrName* InternalGetExistingAttrNameFromQName(const nsAString& aStr) const;
 
   /**
    * Retrieve the rectangle for the offsetX properties, which
-   * are coordinates relative to the returned element.
+   * are coordinates relative to the returned aOffsetParent.
    *
    * @param aRect offset rectangle
    * @param aOffsetParent offset parent
    */
-  virtual nsGenericElement* GetOffsetRect(nsRect& aRect);
+  virtual void GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent);
 
   /**
    * Retrieve the size of the padding rect of this element.
    *
    * @param aSize the size of the padding rect
    */
   nsIntSize GetPaddingRectSize();
 
--- a/content/base/src/nsObjectLoadingContent.h
+++ b/content/base/src/nsObjectLoadingContent.h
@@ -101,17 +101,17 @@ class nsObjectLoadingContent : public ns
     NS_DECL_NSICHANNELEVENTSINK
 
     /**
      * Object state. This is a bitmask of NS_EVENT_STATEs epresenting the
      * current state of the object.
      */
     nsEventStates ObjectState() const;
 
-    ObjectType Type() const { return mType; }
+    ObjectType Type() { return mType; }
 
     void SetIsNetworkCreated(bool aNetworkCreated)
     {
       mNetworkCreated = aNetworkCreated;
     }
 
     /**
      * Immediately instantiate a plugin instance. This is a no-op if
--- a/content/base/src/nsStyledElement.cpp
+++ b/content/base/src/nsStyledElement.cpp
@@ -186,17 +186,17 @@ nsStyledElementNotElementCSSInlineStyle:
   }
 
   return nullptr;
 }
 
 // ---------------------------------------------------------------
 // Others and helpers
 
-nsICSSDeclaration*
+nsIDOMCSSStyleDeclaration*
 nsStyledElementNotElementCSSInlineStyle::GetStyle(nsresult* retval)
 {
   nsGenericElement::nsDOMSlots *slots = DOMSlots();
 
   if (!slots->mStyle) {
     // Just in case...
     ReparseStyleAttribute(true);
 
--- a/content/base/src/nsStyledElement.h
+++ b/content/base/src/nsStyledElement.h
@@ -45,17 +45,17 @@ public:
                                       const nsAString* aSerialized,
                                       bool aNotify);
 
   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                              bool aNotify);
   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                                 const nsAttrValue* aValue, bool aNotify);
 
-  nsICSSDeclaration* GetStyle(nsresult* retval);
+  nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval);
 
 protected:
 
   /**
    * Parse a style attr value into a CSS rulestruct (or, if there is no
    * document, leave it as a string) and return as nsAttrValue.
    *
    * @param aValue the value to parse
--- a/content/canvas/src/CanvasUtils.cpp
+++ b/content/canvas/src/CanvasUtils.cpp
@@ -8,17 +8,16 @@
 
 #include "prprf.h"
 
 #include "nsIServiceManager.h"
 
 #include "nsIConsoleService.h"
 #include "nsIDOMCanvasRenderingContext2D.h"
 #include "nsICanvasRenderingContextInternal.h"
-#include "nsIHTMLCollection.h"
 #include "nsHTMLCanvasElement.h"
 #include "nsIPrincipal.h"
 
 #include "nsGfxCIID.h"
 
 #include "nsTArray.h"
 
 #include "CanvasUtils.h"
--- a/content/html/content/public/nsHTMLAudioElement.h
+++ b/content/html/content/public/nsHTMLAudioElement.h
@@ -26,17 +26,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsHTMLMediaElement::)
 
   // nsIDOMHTMLMediaElement
   using nsHTMLMediaElement::GetPaused;
   NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(nsHTMLMediaElement::)
 
   // nsIDOMHTMLAudioElement
   NS_DECL_NSIDOMHTMLAUDIOELEMENT
 
--- a/content/html/content/public/nsHTMLCanvasElement.h
+++ b/content/html/content/public/nsHTMLCanvasElement.h
@@ -53,17 +53,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLCanvasElement
   NS_DECL_NSIDOMHTMLCANVASELEMENT
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLCanvasElement,
                                            nsGenericHTMLElement)
 
--- a/content/html/content/public/nsHTMLVideoElement.h
+++ b/content/html/content/public/nsHTMLVideoElement.h
@@ -23,17 +23,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsHTMLMediaElement::)
 
   // nsIDOMHTMLMediaElement
   using nsHTMLMediaElement::GetPaused;
   NS_FORWARD_NSIDOMHTMLMEDIAELEMENT(nsHTMLMediaElement::)
 
   // nsIDOMHTMLVideoElement
   NS_DECL_NSIDOMHTMLVIDEOELEMENT
 
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -104,17 +104,16 @@ endif
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 
 INCLUDES	+= \
-		-I$(srcdir)/../../document/src \
 		-I$(srcdir)/../../../base/src \
 		-I$(srcdir)/../../../events/src \
 		-I$(srcdir)/../../../xbl/src \
 		-I$(srcdir)/../../../xul/content/src \
 		-I$(srcdir)/../../../../layout/forms \
 		-I$(srcdir)/../../../../layout/style \
 		-I$(srcdir)/../../../../layout/tables \
 		-I$(srcdir)/../../../../layout/xul/base/src \
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -93,17 +93,16 @@
 
 #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"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::directionality;
 
 class nsINodeInfo;
 class nsIDOMNodeList;
 class nsRuleWalker;
@@ -228,19 +227,21 @@ class nsGenericHTMLElementTearoff : publ
   }
 
   virtual ~nsGenericHTMLElementTearoff()
   {
   }
 
   NS_IMETHOD GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
   {
-    mozilla::ErrorResult rv;
-    NS_IF_ADDREF(*aStyle = mElement->GetStyle(rv));
-    return rv.ErrorCode();
+    nsresult rv;
+    *aStyle = mElement->GetStyle(&rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ADDREF(*aStyle);
+    return NS_OK;
   }
 
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGenericHTMLElementTearoff,
                                            nsIDOMElementCSSInlineStyle)
 
 private:
   nsRefPtr<nsGenericHTMLElement> mElement;
 };
@@ -251,16 +252,18 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeneri
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGenericHTMLElementTearoff)
 
 NS_INTERFACE_TABLE_HEAD(nsGenericHTMLElementTearoff)
   NS_INTERFACE_TABLE_INHERITED1(nsGenericHTMLElementTearoff,
                                 nsIDOMElementCSSInlineStyle)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsGenericHTMLElementTearoff)
 NS_INTERFACE_MAP_END_AGGREGATED(mElement)
 
+NS_IMPL_BOOL_ATTR(nsGenericHTMLElement, Hidden, hidden)
+
 nsresult
 nsGenericHTMLElement::DOMQueryInterface(nsIDOMHTMLElement *aElement,
                                         REFNSIID aIID, void **aInstancePtr)
 {
   NS_PRECONDITION(aInstancePtr, "null out param");
 
   nsresult rv = NS_ERROR_FAILURE;
 
@@ -341,87 +344,151 @@ nsGenericHTMLElement::ClearDataset()
 
   NS_ASSERTION(slots && slots->mDataset,
                "Slots should exist and dataset should not be null.");
   slots->mDataset = nullptr;
 
   return NS_OK;
 }
 
+// Implementation for nsIDOMHTMLElement
+nsresult
+nsGenericHTMLElement::GetId(nsAString& aId)
+{
+  GetAttr(kNameSpaceID_None, nsGkAtoms::id, aId);
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetId(const nsAString& aId)
+{
+  SetAttr(kNameSpaceID_None, nsGkAtoms::id, aId, true);
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::GetTitle(nsAString& aTitle)
+{
+  GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle);
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetTitle(const nsAString& aTitle)
+{
+  SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true);
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::GetLang(nsAString& aLang)
+{
+  GetAttr(kNameSpaceID_None, nsGkAtoms::lang, aLang);
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetLang(const nsAString& aLang)
+{
+  SetAttr(kNameSpaceID_None, nsGkAtoms::lang, aLang, true);
+  return NS_OK;
+}
+
 static const nsAttrValue::EnumTable kDirTable[] = {
   { "ltr", NS_STYLE_DIRECTION_LTR },
   { "rtl", NS_STYLE_DIRECTION_RTL },
   { 0 }
 };
 
-void
+NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsGenericHTMLElement, Dir, dir, NULL)
+
+nsresult
+nsGenericHTMLElement::GetClassName(nsAString& aClassName)
+{
+  GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName);
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetClassName(const nsAString& aClassName)
+{
+  SetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName, true);
+  return NS_OK;
+}
+
+NS_IMPL_STRING_ATTR(nsGenericHTMLElement, AccessKey, accesskey)
+
+NS_IMETHODIMP
 nsGenericHTMLElement::GetAccessKeyLabel(nsAString& aLabel)
 {
   nsPresContext *presContext = GetPresContext();
 
   if (presContext) {
     nsAutoString suffix;
     GetAccessKey(suffix);
     if (!suffix.IsEmpty() && 
         presContext->EventStateManager()->GetAccessKeyLabelPrefix(aLabel)) {
       aLabel.Append(suffix);
     }
   }
+
+  return NS_OK;
 }
 
 static bool IS_TABLE_CELL(nsIAtom* frameType) {
   return nsGkAtoms::tableCellFrame == frameType ||
     nsGkAtoms::bcTableCellFrame == frameType;
 }
 
 static bool
 IsOffsetParent(nsIFrame* aFrame)
 {
   nsIAtom* frameType = aFrame->GetType();
   return (IS_TABLE_CELL(frameType) ||
           frameType == nsGkAtoms::tableFrame);
 }
 
-nsGenericElement*
-nsGenericHTMLElement::GetOffsetRect(nsRect& aRect)
+void
+nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
 {
+  *aOffsetParent = nullptr;
   aRect = nsRect();
 
   nsIFrame* frame = GetStyledFrame();
   if (!frame) {
-    return nullptr;
+    return;
   }
 
   nsIFrame* parent = frame->GetParent();
   nsPoint origin(0, 0);
 
   if (parent && parent->GetType() == nsGkAtoms::tableOuterFrame &&
       frame->GetType() == nsGkAtoms::tableFrame) {
     origin = parent->GetPositionIgnoringScrolling();
     parent = parent->GetParent();
   }
 
-  nsIContent* offsetParent = nullptr;
   Element* docElement = GetCurrentDoc()->GetRootElement();
   nsIContent* content = frame->GetContent();
 
   if (content && (content->IsHTML(nsGkAtoms::body) || content == docElement)) {
     parent = frame;
   }
   else {
     const bool isPositioned = frame->IsPositioned();
     const bool isAbsolutelyPositioned = frame->IsAbsolutelyPositioned();
     origin += frame->GetPositionIgnoringScrolling();
 
     for ( ; parent ; parent = parent->GetParent()) {
       content = parent->GetContent();
 
       // Stop at the first ancestor that is positioned.
       if (parent->IsPositioned()) {
-        offsetParent = content;
+        *aOffsetParent = content;
+        NS_IF_ADDREF(*aOffsetParent);
         break;
       }
 
       // Add the parent's origin to our own to get to the
       // right coordinate system.
       const bool isOffsetParent = !isPositioned && IsOffsetParent(parent);
       if (!isAbsolutelyPositioned && !isOffsetParent) {
         origin += parent->GetPositionIgnoringScrolling();
@@ -431,35 +498,40 @@ nsGenericHTMLElement::GetOffsetRect(nsRe
         // If we've hit the document element, break here.
         if (content == docElement) {
           break;
         }
 
         // Break if the ancestor frame type makes it suitable as offset parent
         // and this element is *not* positioned or if we found the body element.
         if (isOffsetParent || content->IsHTML(nsGkAtoms::body)) {
-          offsetParent = content;
+          *aOffsetParent = content;
+          NS_ADDREF(*aOffsetParent);
           break;
         }
       }
     }
 
-    if (isAbsolutelyPositioned && !offsetParent) {
+    if (isAbsolutelyPositioned && !*aOffsetParent) {
       // If this element is absolutely positioned, but we don't have
       // an offset parent it means this element is an absolutely
       // positioned child that's not nested inside another positioned
       // element, in this case the element's frame's parent is the
       // frame for the HTML element so we fail to find the body in the
       // parent chain. We want the offset parent in this case to be
       // the body, so we just get the body element from the document.
 
       nsCOMPtr<nsIDOMHTMLDocument> html_doc(do_QueryInterface(GetCurrentDoc()));
 
       if (html_doc) {
-        offsetParent = static_cast<nsHTMLDocument*>(html_doc.get())->GetBody();
+        nsCOMPtr<nsIDOMHTMLElement> html_element;
+        html_doc->GetBody(getter_AddRefs(html_element));
+        if (html_element) {
+          CallQueryInterface(html_element, aOffsetParent);
+        }
       }
     }
   }
 
   // Subtract the parent border unless it uses border-box sizing.
   if (parent &&
       parent->GetStylePosition()->mBoxSizing != NS_STYLE_BOX_SIZING_BORDER) {
     const nsStyleBorder* border = parent->GetStyleBorder();
@@ -475,20 +547,80 @@ nsGenericHTMLElement::GetOffsetRect(nsRe
   aRect.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
 
   // Get the union of all rectangles in this and continuation frames.
   // It doesn't really matter what we use as aRelativeTo here, since
   // we only care about the size. We just have to use something non-null.
   nsRect rcFrame = nsLayoutUtils::GetAllInFlowRectsUnion(frame, frame);
   aRect.width = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.width);
   aRect.height = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.height);
-
-  return offsetParent ?
-         static_cast<nsGenericElement*>(offsetParent->AsElement()) :
-         nullptr;
+}
+
+nsresult
+nsGenericHTMLElement::GetOffsetTop(int32_t* aOffsetTop)
+{
+  nsRect rcFrame;
+  nsCOMPtr<nsIContent> parent;
+  GetOffsetRect(rcFrame, getter_AddRefs(parent));
+
+  *aOffsetTop = rcFrame.y;
+
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::GetOffsetLeft(int32_t* aOffsetLeft)
+{
+  nsRect rcFrame;
+  nsCOMPtr<nsIContent> parent;
+  GetOffsetRect(rcFrame, getter_AddRefs(parent));
+
+  *aOffsetLeft = rcFrame.x;
+
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::GetOffsetWidth(int32_t* aOffsetWidth)
+{
+  nsRect rcFrame;
+  nsCOMPtr<nsIContent> parent;
+  GetOffsetRect(rcFrame, getter_AddRefs(parent));
+
+  *aOffsetWidth = rcFrame.width;
+
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::GetOffsetHeight(int32_t* aOffsetHeight)
+{
+  nsRect rcFrame;
+  nsCOMPtr<nsIContent> parent;
+  GetOffsetRect(rcFrame, getter_AddRefs(parent));
+
+  *aOffsetHeight = rcFrame.height;
+
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::GetOffsetParent(nsIDOMElement** aOffsetParent)
+{
+  nsRect rcFrame;
+  nsCOMPtr<nsIContent> parent;
+  GetOffsetRect(rcFrame, getter_AddRefs(parent));
+
+  if (parent) {
+    CallQueryInterface(parent, aOffsetParent);
+  } else {
+    *aOffsetParent = nullptr;
+  }
+
+  return NS_OK;
 }
 
 // Try to keep the size of StringBuilder close to a jemalloc bucket size.
 #define STRING_BUFFER_UNITS 1020
 
 class StringBuilder
 {
 private:
@@ -1153,20 +1285,19 @@ nsGenericHTMLElement::GetMarkup(bool aIn
 }
 
 void
 nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML, ErrorResult& aError)
 {
   aError = GetMarkup(false, aInnerHTML);
 }
 
-void
-nsGenericHTMLElement::GetOuterHTML(nsAString& aOuterHTML, ErrorResult& aError)
-{
-  aError = GetMarkup(true, aOuterHTML);
+NS_IMETHODIMP
+nsGenericHTMLElement::GetOuterHTML(nsAString& aOuterHTML) {
+  return GetMarkup(true, aOuterHTML);
 }
 
 void
 nsGenericHTMLElement::FireMutationEventsForDirectParsing(nsIDocument* aDoc,
                                                          nsIContent* aDest,
                                                          int32_t aOldChildCount)
 {
   // Fire mutation events. Optimize for the case when there are no listeners
@@ -1235,59 +1366,56 @@ nsGenericHTMLElement::SetInnerHTML(const
       nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
 
       static_cast<nsINode*>(this)->AppendChild(*fragment, aError);
       mb.NodesAdded();
     }
   }
 }
 
-void
-nsGenericHTMLElement::SetOuterHTML(const nsAString& aOuterHTML,
-                                   ErrorResult& aError)
+NS_IMETHODIMP
+nsGenericHTMLElement::SetOuterHTML(const nsAString& aOuterHTML)
 {
   nsCOMPtr<nsINode> parent = GetParentNode();
   if (!parent) {
-    return;
+    return NS_OK;
   }
 
   if (parent->NodeType() == nsIDOMNode::DOCUMENT_NODE) {
-    aError.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
-    return;
+    return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
   }
 
   if (OwnerDoc()->IsHTML()) {
     nsIAtom* localName;
     int32_t namespaceID;
     if (parent->IsElement()) {
       localName = static_cast<nsIContent*>(parent.get())->Tag();
       namespaceID = static_cast<nsIContent*>(parent.get())->GetNameSpaceID();
     } else {
       NS_ASSERTION(parent->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE,
         "How come the parent isn't a document, a fragment or an element?");
       localName = nsGkAtoms::body;
       namespaceID = kNameSpaceID_XHTML;
     }
     nsCOMPtr<nsIDOMDocumentFragment> df;
-    aError = NS_NewDocumentFragment(getter_AddRefs(df),
-                                    OwnerDoc()->NodeInfoManager());
-    if (aError.Failed()) {
-      return;
-    }
+    nsresult rv = NS_NewDocumentFragment(getter_AddRefs(df),
+                                         OwnerDoc()->NodeInfoManager());
+    NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIContent> fragment = do_QueryInterface(df);
     nsContentUtils::ParseFragmentHTML(aOuterHTML,
                                       fragment,
                                       localName,
                                       namespaceID,
                                       OwnerDoc()->GetCompatibilityMode() ==
                                         eCompatibility_NavQuirks,
                                       true);
     nsAutoMutationBatch mb(parent, true, false);
-    parent->ReplaceChild(*fragment, *this, aError);
-    return;
+    ErrorResult error;
+    parent->ReplaceChild(*fragment, *this, error);
+    return error.ErrorCode();
   }
 
   nsCOMPtr<nsINode> context;
   if (parent->IsElement()) {
     context = parent;
   } else {
     NS_ASSERTION(parent->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE,
       "How come the parent isn't a document, a fragment or an element?");
@@ -1295,197 +1423,219 @@ nsGenericHTMLElement::SetOuterHTML(const
       OwnerDoc()->NodeInfoManager()->GetNodeInfo(nsGkAtoms::body,
                                                  nullptr,
                                                  kNameSpaceID_XHTML,
                                                  nsIDOMNode::ELEMENT_NODE);
     context = NS_NewHTMLBodyElement(info.forget(), FROM_PARSER_FRAGMENT);
   }
 
   nsCOMPtr<nsIDOMDocumentFragment> df;
-  aError = nsContentUtils::CreateContextualFragment(context,
-                                                    aOuterHTML,
-                                                    true,
-                                                    getter_AddRefs(df));
-  if (aError.Failed()) {
-    return;
-  }
+  nsresult rv = nsContentUtils::CreateContextualFragment(context,
+                                                         aOuterHTML,
+                                                         true,
+                                                         getter_AddRefs(df));
+  NS_ENSURE_SUCCESS(rv, rv);
   nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
   nsAutoMutationBatch mb(parent, true, false);
-  parent->ReplaceChild(*fragment, *this, aError);
+  ErrorResult error;
+  parent->ReplaceChild(*fragment, *this, error);
+  return error.ErrorCode();
 }
 
 enum nsAdjacentPosition {
   eBeforeBegin,
   eAfterBegin,
   eBeforeEnd,
   eAfterEnd
 };
 
 NS_IMETHODIMP
 nsGenericHTMLElement::InsertAdjacentHTML(const nsAString& aPosition,
                                          const nsAString& aText)
 {
-  ErrorResult rv;
-  InsertAdjacentHTML(aPosition, aText, rv);
-  return rv.ErrorCode();
-}
-
-void
-nsGenericHTMLElement::InsertAdjacentHTML(const nsAString& aPosition,
-                                         const nsAString& aText,
-                                         ErrorResult& aError)
-{
   nsAdjacentPosition position;
   if (aPosition.LowerCaseEqualsLiteral("beforebegin")) {
     position = eBeforeBegin;
   } else if (aPosition.LowerCaseEqualsLiteral("afterbegin")) {
     position = eAfterBegin;
   } else if (aPosition.LowerCaseEqualsLiteral("beforeend")) {
     position = eBeforeEnd;
   } else if (aPosition.LowerCaseEqualsLiteral("afterend")) {
     position = eAfterEnd;
   } else {
-    aError.Throw(NS_ERROR_DOM_SYNTAX_ERR);
-    return;
+    return NS_ERROR_DOM_SYNTAX_ERR;
   }
 
   nsCOMPtr<nsIContent> destination;
   if (position == eBeforeBegin || position == eAfterEnd) {
     destination = GetParent();
     if (!destination) {
-      aError.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
-      return;
+      return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
     }
   } else {
     destination = this;
   }
 
   nsIDocument* doc = OwnerDoc();
 
   // Needed when insertAdjacentHTML is used in combination with contenteditable
   mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
   nsAutoScriptLoaderDisabler sld(doc);
   
   // Batch possible DOMSubtreeModified events.
   mozAutoSubtreeModified subtree(doc, nullptr);
 
+  nsresult rv;
   // Parse directly into destination if possible
   if (doc->IsHTML() && !OwnerDoc()->MayHaveDOMMutationObservers() &&
       (position == eBeforeEnd ||
        (position == eAfterEnd && !GetNextSibling()) ||
        (position == eAfterBegin && !GetFirstChild()))) {
     int32_t oldChildCount = destination->GetChildCount();
     int32_t contextNs = destination->GetNameSpaceID();
     nsIAtom* contextLocal = destination->Tag();
     if (contextLocal == nsGkAtoms::html && contextNs == kNameSpaceID_XHTML) {
       // For compat with IE6 through IE9. Willful violation of HTML5 as of
       // 2011-04-06. CreateContextualFragment does the same already.
       // Spec bug: http://www.w3.org/Bugs/Public/show_bug.cgi?id=12434
       contextLocal = nsGkAtoms::body;
     }
-    aError = nsContentUtils::ParseFragmentHTML(aText,
-                                               destination,
-                                               contextLocal,
-                                               contextNs,
-                                               doc->GetCompatibilityMode() ==
-                                                 eCompatibility_NavQuirks,
-                                               true);
+    rv = nsContentUtils::ParseFragmentHTML(aText,
+                                           destination,
+                                           contextLocal,
+                                           contextNs,
+                                           doc->GetCompatibilityMode() ==
+                                             eCompatibility_NavQuirks,
+                                           true);
     // HTML5 parser has notified, but not fired mutation events.
     FireMutationEventsForDirectParsing(doc, destination, oldChildCount);
-    return;
+    return rv;
   }
 
   // couldn't parse directly
   nsCOMPtr<nsIDOMDocumentFragment> df;
-  aError = nsContentUtils::CreateContextualFragment(destination,
-                                                    aText,
-                                                    true,
-                                                    getter_AddRefs(df));
-  if (aError.Failed()) {
-    return;
-  }
-
+  rv = nsContentUtils::CreateContextualFragment(destination,
+                                                aText,
+                                                true,
+                                                getter_AddRefs(df));
   nsCOMPtr<nsINode> fragment = do_QueryInterface(df);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   // Suppress assertion about node removal mutation events that can't have
   // listeners anyway, because no one has had the chance to register mutation
   // listeners on the fragment that comes from the parser.
   nsAutoScriptBlockerSuppressNodeRemoved scriptBlocker;
 
+  ErrorResult error;
   nsAutoMutationBatch mb(destination, true, false);
   switch (position) {
     case eBeforeBegin:
-      destination->InsertBefore(*fragment, this, aError);
+      destination->InsertBefore(*fragment, this, error);
       break;
     case eAfterBegin:
-      static_cast<nsINode*>(this)->InsertBefore(*fragment, GetFirstChild(),
-                                                aError);
+      static_cast<nsINode*>(this)->InsertBefore(*fragment, GetFirstChild(), error);
       break;
     case eBeforeEnd:
-      static_cast<nsINode*>(this)->AppendChild(*fragment, aError);
+      static_cast<nsINode*>(this)->AppendChild(*fragment, error);
       break;
     case eAfterEnd:
-      destination->InsertBefore(*fragment, GetNextSibling(), aError);
+      destination->InsertBefore(*fragment, GetNextSibling(), error);
       break;
   }
+  return error.ErrorCode();
 }
 
-bool
-nsGenericHTMLElement::Spellcheck()
+nsresult
+nsGenericHTMLElement::ScrollIntoView(bool aTop, uint8_t optional_argc)
 {
+  if (!optional_argc) {
+    aTop = true;
+  }
+
+  nsGenericElement::ScrollIntoView(aTop);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGenericHTMLElement::GetSpellcheck(bool* aSpellcheck)
+{
+  NS_ENSURE_ARG_POINTER(aSpellcheck);
+  *aSpellcheck = false;              // Default answer is to not spellcheck
+
   // Has the state has been explicitly set?
   nsIContent* node;
   for (node = this; node; node = node->GetParent()) {
     if (node->IsHTML()) {
       static nsIContent::AttrValuesArray strings[] =
         {&nsGkAtoms::_true, &nsGkAtoms::_false, nullptr};
       switch (node->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::spellcheck,
                                     strings, eCaseMatters)) {
         case 0:                         // spellcheck = "true"
-          return true;
+          *aSpellcheck = true;
+          // Fall through
         case 1:                         // spellcheck = "false"
-          return false;
+          return NS_OK;
       }
     }
   }
 
   // Is this a chrome element?
   if (nsContentUtils::IsChromeDoc(OwnerDoc())) {
-    return false;                       // Not spellchecked by default
+    return NS_OK;                       // Not spellchecked by default
   }
 
   if (IsCurrentBodyElement()) {
     nsCOMPtr<nsIHTMLDocument> doc = do_QueryInterface(GetCurrentDoc());
-    return doc && doc->IsEditingOn();
+    if (doc) {
+      *aSpellcheck = doc->IsEditingOn();
+    }
+
+    return NS_OK;
   }
 
   // Is this element editable?
   nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(this);
   if (!formControl) {
-    return false;                       // Not spellchecked by default
+    return NS_OK;                       // Not spellchecked by default
   }
 
   // Is this a multiline plaintext input?
   int32_t controlType = formControl->GetType();
   if (controlType == NS_FORM_TEXTAREA) {
-    return true;             // Spellchecked by default
+    *aSpellcheck = true;             // Spellchecked by default
+    return NS_OK;
   }
 
   // Is this anything other than an input text?
   // Other inputs are not spellchecked.
   if (controlType != NS_FORM_INPUT_TEXT) {
-    return false;                       // Not spellchecked by default
+    return NS_OK;                       // Not spellchecked by default
   }
 
   // Does the user want input text spellchecked by default?
   // NOTE: Do not reflect a pref value of 0 back to the DOM getter.
   // The web page should not know if the user has disabled spellchecking.
   // We'll catch this in the editor itself.
   int32_t spellcheckLevel = Preferences::GetInt("layout.spellcheckDefault", 1);
-  return spellcheckLevel == 2;           // "Spellcheck multi- and single-line"
+  if (spellcheckLevel == 2) {           // "Spellcheck multi- and single-line"
+    *aSpellcheck = true;             // Spellchecked by default
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGenericHTMLElement::SetSpellcheck(bool aSpellcheck)
+{
+  if (aSpellcheck) {
+    return SetAttrHelper(nsGkAtoms::spellcheck, NS_LITERAL_STRING("true"));
+  }
+
+  return SetAttrHelper(nsGkAtoms::spellcheck, NS_LITERAL_STRING("false"));
 }
 
 bool
 nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc)
 {
   return aDoc && aDoc->GetCompatibilityMode() == eCompatibility_NavQuirks;
 }
 
@@ -2724,36 +2874,36 @@ nsresult
 nsGenericHTMLElement::SetDoubleAttr(nsIAtom* aAttr, double aValue)
 {
   nsAutoString value;
   value.AppendFloat(aValue);
 
   return SetAttr(kNameSpaceID_None, aAttr, value, true);
 }
 
-void
-nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr,
-                                 nsAString& aResult) const
+nsresult
+nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult)
 {
   nsCOMPtr<nsIURI> uri;
   bool hadAttr = GetURIAttr(aAttr, aBaseAttr, getter_AddRefs(uri));
   if (!hadAttr) {
     aResult.Truncate();
-    return;
+    return NS_OK;
   }
 
   if (!uri) {
     // Just return the attr value
     GetAttr(kNameSpaceID_None, aAttr, aResult);
-    return;
+    return NS_OK;
   }
 
   nsAutoCString spec;
   uri->GetSpec(spec);
   CopyUTF8toUTF16(spec, aResult);
+  return NS_OK;
 }
 
 bool
 nsGenericHTMLElement::GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsIURI** aURI) const
 {
   *aURI = nullptr;
 
   const nsAttrValue* attr = mAttrsAndChildren.GetAttr(aAttr);
@@ -2827,50 +2977,116 @@ nsGenericHTMLElement::GetURIListAttr(nsI
       if (iter >= end)
         break;
     }
   }
 
   return NS_OK;
 }
 
-void
+nsresult
 nsGenericHTMLElement::GetEnumAttr(nsIAtom* aAttr,
                                   const char* aDefault,
-                                  nsAString& aResult) const
+                                  nsAString& aResult)
 {
   const nsAttrValue* attrVal = mAttrsAndChildren.GetAttr(aAttr);
 
   aResult.Truncate();
 
   if (attrVal && attrVal->Type() == nsAttrValue::eEnum) {
     attrVal->GetEnumString(aResult, true);
   } else if (aDefault) {
     AppendASCIItoUTF16(nsDependentCString(aDefault), aResult);
   }
+
+  return NS_OK;
 }
 
-nsHTMLMenuElement*
-nsGenericHTMLElement::GetContextMenu() const
+nsresult
+nsGenericHTMLElement::GetContentEditable(nsAString& aContentEditable)
+{
+  ContentEditableTristate value = GetContentEditableValue();
+
+  if (value == eTrue) {
+    aContentEditable.AssignLiteral("true");
+  }
+  else if (value == eFalse) {
+    aContentEditable.AssignLiteral("false");
+  }
+  else {
+    aContentEditable.AssignLiteral("inherit");
+  }
+
+  return NS_OK;
+}
+
+nsresult
+nsGenericHTMLElement::SetContentEditable(const nsAString& aContentEditable)
 {
-  nsAutoString value;
-  GetHTMLAttr(nsGkAtoms::contextmenu, value);
-  if (!value.IsEmpty()) {
-    nsIDocument* doc = GetCurrentDoc();
-    if (doc) {
-      return nsHTMLMenuElement::FromContentOrNull(doc->GetElementById(value));
+  if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "inherit")) {
+    UnsetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, true);
+
+    return NS_OK;
+  }
+
+  if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "true")) {
+    SetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, NS_LITERAL_STRING("true"), true);
+    
+    return NS_OK;
+  }
+  
+  if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "false")) {
+    SetAttr(kNameSpaceID_None, nsGkAtoms::contenteditable, NS_LITERAL_STRING("false"), true);
+
+    return NS_OK;
+  }
+
+  return NS_ERROR_DOM_SYNTAX_ERR;
+}
+
+nsresult
+nsGenericHTMLElement::GetIsContentEditable(bool* aContentEditable)
+{
+  NS_ENSURE_ARG_POINTER(aContentEditable);
+
+  for (nsIContent* node = this; node; node = node->GetParent()) {
+    nsGenericHTMLElement* element = FromContent(node);
+    if (element) {
+      ContentEditableTristate value = element->GetContentEditableValue();
+      if (value != eInherit) {
+        *aContentEditable = value == eTrue;
+        return NS_OK;
+      }
     }
   }
-  return nullptr;
+
+  *aContentEditable = false;
+  return NS_OK;
 }
 
-void
-nsGenericHTMLElement::GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu) const
+nsresult
+nsGenericHTMLElement::GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu)
 {
-  NS_IF_ADDREF(*aContextMenu = GetContextMenu());
+  *aContextMenu = nullptr;
+
+  nsAutoString value;
+  GetAttr(kNameSpaceID_None, nsGkAtoms::contextmenu, value);
+
+  if (value.IsEmpty()) {
+    return NS_OK;
+  }
+
+  nsIDocument* doc = GetCurrentDoc();
+  if (doc) {
+    nsRefPtr<nsHTMLMenuElement> element =
+      nsHTMLMenuElement::FromContentOrNull(doc->GetElementById(value));
+    element.forget(aContextMenu);
+  }
+
+  return NS_OK;
 }
 
 bool
 nsGenericHTMLElement::IsLabelable() const
 {
   return Tag() == nsGkAtoms::progress ||
          Tag() == nsGkAtoms::meter;
 }
@@ -3533,33 +3749,31 @@ nsGenericHTMLFormElement::IsLabelable() 
          // type == NS_FORM_KEYGEN ||
          type == NS_FORM_OUTPUT ||
          type == NS_FORM_SELECT ||
          type == NS_FORM_TEXTAREA;
 }
 
 //----------------------------------------------------------------------
 
-void
-nsGenericHTMLElement::Blur(mozilla::ErrorResult& aError)
+nsresult
+nsGenericHTMLElement::Blur()
 {
   if (!ShouldBlur(this)) {
-    return;
+    return NS_OK;
   }
 
   nsIDocument* doc = GetCurrentDoc();
   if (!doc) {
-    return;
+    return NS_OK;
   }
 
   nsIDOMWindow* win = doc->GetWindow();
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
-  if (win && fm) {
-    aError = fm->ClearFocus(win);
-  }
+  return (win && fm) ? fm->ClearFocus(win) : NS_OK;
 }
 
 void
 nsGenericHTMLElement::Focus(ErrorResult& aError)
 {
   nsIFocusManager* fm = nsFocusManager::GetFocusManager();
   if (fm) {
     nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(this);
@@ -3611,17 +3825,18 @@ nsGenericHTMLElement::IsHTMLFocusable(bo
       *aTabIndex = -1;
     }
 
     *aIsFocusable = false;
 
     return true;
   }
 
-  int32_t tabIndex = TabIndex();
+  int32_t tabIndex = 0;   // Default value for non HTML elements with -moz-user-focus
+  GetTabIndex(&tabIndex);
 
   bool override, disabled = false;
   if (IsEditableRoot()) {
     // Editable roots should always be focusable.
     override = true;
 
     // Ignore the disabled attribute in editable contentEditable/designMode
     // roots.
@@ -3886,84 +4101,73 @@ nsGenericHTMLElement::ChangeEditableStat
 
   // MakeContentDescendantsEditable is going to call ContentStateChanged for
   // this element and all descendants if editable state has changed.
   // We might as well wrap it all in one script blocker.
   nsAutoScriptBlocker scriptBlocker;
   MakeContentDescendantsEditable(this, document);
 }
 
+NS_IMPL_BOOL_ATTR(nsGenericHTMLElement, ItemScope, itemscope)
+NS_IMPL_URI_ATTR(nsGenericHTMLElement, ItemId, itemid)
+
 JS::Value
 nsGenericHTMLElement::GetItemValue(JSContext* aCx, JSObject* aScope,
-                                   ErrorResult& aError)
+                                   ErrorResult& error)
 {
   if (!HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop)) {
     return JS::NullValue();
   }
 
-  if (ItemScope()) {
+  bool itemScope;
+  GetItemScope(&itemScope);
+  if (itemScope) {
     JS::Value v;
     if (!mozilla::dom::WrapObject(aCx, aScope, this, &v)) {
-      aError.Throw(NS_ERROR_FAILURE);
+      error.Throw(NS_ERROR_FAILURE);
       return JS::UndefinedValue();
     }
     return v;
   }
 
   nsString string;
   GetItemValueText(string);
   JS::Value v;
   if (!xpc::NonVoidStringToJsval(aCx, string, &v)) {
-    aError.Throw(NS_ERROR_FAILURE);
+    error.Throw(NS_ERROR_FAILURE);
     return JS::UndefinedValue();
   }
   return v;
 }
 
 NS_IMETHODIMP
 nsGenericHTMLElement::GetItemValue(nsIVariant** aValue)
 {
   nsCOMPtr<nsIWritableVariant> out = new nsVariant();
 
   if (!HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop)) {
     out->SetAsEmpty();
     out.forget(aValue);
     return NS_OK;
   }
 
-  if (ItemScope()) {
+  bool itemScope;
+  GetItemScope(&itemScope);
+  if (itemScope) {
     out->SetAsISupports(static_cast<nsISupports*>(this));
   } else {
     nsAutoString string;
     GetItemValueText(string);
     out->SetAsAString(string);
   }
 
   out.forget(aValue);
   return NS_OK;
 }
 
-void
-nsGenericHTMLElement::SetItemValue(JSContext* aCx, JS::Value aValue,
-                                   ErrorResult& aError)
-{
-  if (!HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop) ||
-      HasAttr(kNameSpaceID_None, nsGkAtoms::itemscope)) {
-    aError.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
-    return;
-  }
-
-  FakeDependentString string;
-  if (!ConvertJSValueToString(aCx, aValue, &aValue, eStringify, eStringify, string)) {
-    aError.Throw(NS_ERROR_UNEXPECTED);
-    return;
-  }
-  SetItemValueText(string);
-}
-
 NS_IMETHODIMP
 nsGenericHTMLElement::SetItemValue(nsIVariant* aValue)
 {
   if (!HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop) ||
       HasAttr(kNameSpaceID_None, nsGkAtoms::itemscope)) {
     return NS_ERROR_DOM_INVALID_ACCESS_ERR;
   }
 
@@ -4006,60 +4210,94 @@ nsGenericHTMLElement::GetTokenList(nsIAt
   if (!list) {
     list = new nsDOMSettableTokenList(this, aAtom);
     NS_ADDREF(list);
     SetProperty(aAtom, list, nsDOMSettableTokenListPropertyDestructor);
   }                       
   return list;
 }  
 
-void
-nsGenericHTMLElement::GetTokenList(nsIAtom* aAtom, nsIVariant** aResult)
+NS_IMETHODIMP
+nsGenericHTMLElement::GetItemRef(nsIVariant** aResult)
+{
+  nsIDOMDOMSettableTokenList* itemRef = GetTokenList(nsGkAtoms::itemref);
+  nsCOMPtr<nsIWritableVariant> out = new nsVariant();
+  out->SetAsInterface(NS_GET_IID(nsIDOMDOMSettableTokenList), itemRef);
+  out.forget(aResult);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGenericHTMLElement::SetItemRef(nsIVariant* aValue)
 {
-  nsIDOMDOMSettableTokenList* itemType = GetTokenList(aAtom);
+  nsDOMSettableTokenList* itemRef = GetTokenList(nsGkAtoms::itemref);
+  nsAutoString string;
+  aValue->GetAsAString(string);
+  return itemRef->SetValue(string);
+}
+
+NS_IMETHODIMP
+nsGenericHTMLElement::GetItemProp(nsIVariant** aResult)
+{
+  nsIDOMDOMSettableTokenList* itemProp = GetTokenList(nsGkAtoms::itemprop);
+  nsCOMPtr<nsIWritableVariant> out = new nsVariant();
+  out->SetAsInterface(NS_GET_IID(nsIDOMDOMSettableTokenList), itemProp);
+  out.forget(aResult);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGenericHTMLElement::SetItemProp(nsIVariant* aValue)
+{
+  nsDOMSettableTokenList* itemProp = GetTokenList(nsGkAtoms::itemprop);
+  nsAutoString string;
+  aValue->GetAsAString(string);
+  return itemProp->SetValue(string);
+}
+
+NS_IMETHODIMP
+nsGenericHTMLElement::GetItemType(nsIVariant** aResult)
+{
+  nsIDOMDOMSettableTokenList* itemType = GetTokenList(nsGkAtoms::itemtype);
   nsCOMPtr<nsIWritableVariant> out = new nsVariant();
   out->SetAsInterface(NS_GET_IID(nsIDOMDOMSettableTokenList), itemType);
   out.forget(aResult);
+  return NS_OK;
 }
 
-nsresult
-nsGenericHTMLElement::SetTokenList(nsIAtom* aAtom, nsIVariant* aValue)
+NS_IMETHODIMP
+nsGenericHTMLElement::SetItemType(nsIVariant* aValue)
 {
-  nsDOMSettableTokenList* itemType = GetTokenList(aAtom);
+  nsDOMSettableTokenList* itemType = GetTokenList(nsGkAtoms::itemtype);
   nsAutoString string;
   aValue->GetAsAString(string);
   return itemType->SetValue(string);
 }
 
 static void
 HTMLPropertiesCollectionDestructor(void *aObject, nsIAtom *aProperty,
                                    void *aPropertyValue, void *aData)
 {
   HTMLPropertiesCollection* properties = 
     static_cast<HTMLPropertiesCollection*>(aPropertyValue);
   NS_IF_RELEASE(properties);
 }
 
-HTMLPropertiesCollection*
-nsGenericHTMLElement::Properties()
+NS_IMETHODIMP
+nsGenericHTMLElement::GetProperties(nsIDOMHTMLPropertiesCollection** aReturn)
 {
   HTMLPropertiesCollection* properties = 
     static_cast<HTMLPropertiesCollection*>(GetProperty(nsGkAtoms::microdataProperties));
   if (!properties) {
      properties = new HTMLPropertiesCollection(this);
      NS_ADDREF(properties);
      SetProperty(nsGkAtoms::microdataProperties, properties, HTMLPropertiesCollectionDestructor);
   }
-  return properties;
-}
-
-void
-nsGenericHTMLElement::GetProperties(nsIDOMHTMLPropertiesCollection** aProperties)
-{
-  NS_ADDREF(*aProperties = Properties());
+  NS_ADDREF(*aReturn = properties);
+  return NS_OK;
 }
 
 nsSize
 nsGenericHTMLElement::GetWidthHeightForImage(imgIRequest *aImageRequest)
 {
   nsSize size(0,0);
 
   nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -8,47 +8,38 @@
 
 #include "nsMappedAttributeElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsINameSpaceManager.h"  // for kNameSpaceID_None
 #include "nsIFormControl.h"
 #include "nsGkAtoms.h"
 #include "nsContentCreatorFunctions.h"
 #include "mozilla/ErrorResult.h"
-#include "nsContentUtils.h"
-#include "nsIDOMHTMLMenuElement.h"
 
 class nsIDOMAttr;
 class nsIDOMEventListener;
 class nsIDOMNodeList;
 class nsIFrame;
 class nsIStyleRule;
 class nsChildContentList;
 class nsDOMCSSDeclaration;
-class nsHTMLMenuElement;
 class nsIDOMCSSStyleDeclaration;
 class nsIURI;
 class nsIFormControlFrame;
 class nsIForm;
 class nsPresState;
 class nsILayoutHistoryState;
 class nsIEditor;
 struct nsRect;
 struct nsSize;
 class nsHTMLFormElement;
 class nsIDOMHTMLMenuElement;
 class nsIDOMHTMLCollection;
 class nsDOMSettableTokenList;
 class nsIDOMHTMLPropertiesCollection;
-class nsIDOMDOMStringMap;
-namespace mozilla {
-namespace dom {
-class HTMLPropertiesCollection;
-}
-}
 
 typedef nsMappedAttributeElement nsGenericHTMLElementBase;
 
 /**
  * A common superclass for HTML elements
  */
 class nsGenericHTMLElement : public nsGenericHTMLElementBase
 {
@@ -73,250 +64,159 @@ public:
    * @see nsGenericHTMLElementTearoff
    */
   nsresult DOMQueryInterface(nsIDOMHTMLElement *aElement, REFNSIID aIID,
                              void **aInstancePtr);
 
   // From nsGenericElement
   nsresult CopyInnerTo(nsGenericElement* aDest);
 
-  void GetTitle(nsAString& aTitle) const
-  {
-    GetHTMLAttr(nsGkAtoms::title, aTitle);
-  }
-  void SetTitle(const nsAString& aTitle)
-  {
-    SetHTMLAttr(nsGkAtoms::title, aTitle);
-  }
-  void GetLang(nsAString& aLang) const
-  {
-    GetHTMLAttr(nsGkAtoms::lang, aLang);
-  }
-  void SetLang(const nsAString& aLang)
-  {
-    SetHTMLAttr(nsGkAtoms::lang, aLang);
-  }
-  void GetDir(nsAString& aDir) const
-  {
-    GetHTMLEnumAttr(nsGkAtoms::dir, aDir);
-  }
-  void SetDir(const nsAString& aDir, mozilla::ErrorResult& aError)
-  {
-    SetHTMLAttr(nsGkAtoms::dir, aDir, aError);
-  }
-  already_AddRefed<nsDOMStringMap> Dataset();
-  bool ItemScope() const
-  {
-    return GetBoolAttr(nsGkAtoms::itemscope);
-  }
-  void SetItemScope(bool aItemScope, mozilla::ErrorResult& aError)
-  {
-    SetHTMLBoolAttr(nsGkAtoms::itemscope, aItemScope, aError);
-  }
-  nsDOMSettableTokenList* ItemType()
-  {
-    return GetTokenList(nsGkAtoms::itemtype);
-  }
-  void GetItemId(nsAString& aItemId) const
-  {
-    GetHTMLURIAttr(nsGkAtoms::itemid, aItemId);
-  }
-  void SetItemId(const nsAString& aItemID, mozilla::ErrorResult& aError)
-  {
-    SetHTMLAttr(nsGkAtoms::itemid, aItemID, aError);
-  }
-  nsDOMSettableTokenList* ItemRef()
-  {
-    return GetTokenList(nsGkAtoms::itemref);
-  }
-  nsDOMSettableTokenList* ItemProp()
-  {
-    return GetTokenList(nsGkAtoms::itemprop);
-  }
-  mozilla::dom::HTMLPropertiesCollection* Properties();
-  JS::Value GetItemValue(JSContext* aCx, JSObject* aScope,
-                         mozilla::ErrorResult& aError);
-  JS::Value GetItemValue(JSContext* aCx, mozilla::ErrorResult& aError)
-  {
-    return GetItemValue(aCx, GetWrapperPreserveColor(), aError);
-  }
-  void SetItemValue(JSContext* aCx, JS::Value aValue,
-                    mozilla::ErrorResult& aError);
-  bool Hidden() const
-  {
-    return GetBoolAttr(nsGkAtoms::hidden);
-  }
-  void SetHidden(bool aHidden, mozilla::ErrorResult& aError)
-  {
-    SetHTMLBoolAttr(nsGkAtoms::hidden, aHidden, aError);
-  }
+  // WebIDL HTMLElement
   virtual void Click();
   virtual int32_t TabIndexDefault()
   {
     return -1;
   }
   int32_t TabIndex()
   {
     return GetIntAttr(nsGkAtoms::tabindex, TabIndexDefault());
   }
   void SetTabIndex(int32_t aTabIndex, mozilla::ErrorResult& aError)
   {
-    SetHTMLIntAttr(nsGkAtoms::tabindex, aTabIndex, aError);
+    aError = SetIntAttr(nsGkAtoms::tabindex, aTabIndex);
   }
   virtual void Focus(mozilla::ErrorResult& aError);
-  void Blur(mozilla::ErrorResult& aError);
-  void GetAccessKey(nsAString& aAccessKey) const
-  {
-    GetHTMLAttr(nsGkAtoms::accesskey, aAccessKey);
-  }
-  void SetAccessKey(const nsAString& aAccessKey, mozilla::ErrorResult& aError)
-  {
-    SetHTMLAttr(nsGkAtoms::accesskey, aAccessKey, aError);
-  }
-  void GetAccessKeyLabel(nsAString& aAccessKeyLabel);
   virtual bool Draggable() const
   {
     return AttrValueIs(kNameSpaceID_None, nsGkAtoms::draggable,
                        nsGkAtoms::_true, eIgnoreCase);
   }
   void SetDraggable(bool aDraggable, mozilla::ErrorResult& aError)
   {
-    SetHTMLAttr(nsGkAtoms::draggable,
-                aDraggable ? NS_LITERAL_STRING("true")
-                           : NS_LITERAL_STRING("false"),
-                aError);
-  }
-  void GetContentEditable(nsAString& aContentEditable) const
-  {
-    ContentEditableTristate value = GetContentEditableValue();
-    if (value == eTrue) {
-      aContentEditable.AssignLiteral("true");
-    } else if (value == eFalse) {
-      aContentEditable.AssignLiteral("false");
-    } else {
-      aContentEditable.AssignLiteral("inherit");
-    }
-  }
-  void SetContentEditable(const nsAString& aContentEditable,
-                          mozilla::ErrorResult& aError)
-  {
-    if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "inherit")) {
-      UnsetHTMLAttr(nsGkAtoms::contenteditable, aError);
-    } else if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "true")) {
-      SetHTMLAttr(nsGkAtoms::contenteditable, NS_LITERAL_STRING("true"), aError);
-    } else if (nsContentUtils::EqualsLiteralIgnoreASCIICase(aContentEditable, "false")) {
-      SetHTMLAttr(nsGkAtoms::contenteditable, NS_LITERAL_STRING("false"), aError);
-    } else {
-      aError.Throw(NS_ERROR_DOM_SYNTAX_ERR);
-    }
+    aError = SetAttrHelper(nsGkAtoms::draggable,
+                           aDraggable ? NS_LITERAL_STRING("true")
+                                      : NS_LITERAL_STRING("false"));
   }
-  bool IsContentEditable()
-  {
-    for (nsIContent* node = this; node; node = node->GetParent()) {
-      nsGenericHTMLElement* element = FromContent(node);
-      if (element) {
-        ContentEditableTristate value = element->GetContentEditableValue();
-        if (value != eInherit) {
-          return value == eTrue;
-        }
-      }
-    }
-    return false;
-  }
-  nsHTMLMenuElement* GetContextMenu() const;
-  bool Spellcheck();
-  void SetSpellcheck(bool aSpellcheck, mozilla::ErrorResult& aError)
-  {
-    SetHTMLAttr(nsGkAtoms::spellcheck,
-                aSpellcheck ? NS_LITERAL_STRING("true")
-                            : NS_LITERAL_STRING("false"),
-                aError);
-  }
-  nsICSSDeclaration* GetStyle(mozilla::ErrorResult& aError)
-  {
-    nsresult rv;
-    nsICSSDeclaration* style = nsMappedAttributeElement::GetStyle(&rv);
-    if (NS_FAILED(rv)) {
-      aError.Throw(rv);
-    }
-    return style;
-  }
-  void GetClassName(nsAString& aClassName)
-  {
-    GetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName);
-  }
-  void SetClassName(const nsAString& aClassName)
-  {
-    SetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName, true);
-  }
+
   virtual void GetInnerHTML(nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError);
   virtual void SetInnerHTML(const nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError);
-  void GetOuterHTML(nsAString& aOuterHTML, mozilla::ErrorResult& aError);
-  void SetOuterHTML(const nsAString& aOuterHTML, mozilla::ErrorResult& aError);
-  void InsertAdjacentHTML(const nsAString& aPosition, const nsAString& aText,
-                          mozilla::ErrorResult& aError);
-  nsGenericElement* GetOffsetParent()
-  {
-    nsRect rcFrame;
-    return GetOffsetRect(rcFrame);
-  }
-  int32_t OffsetTop()
-  {
-    nsRect rcFrame;
-    GetOffsetRect(rcFrame);
-
-    return rcFrame.y;
-  }
-  int32_t OffsetLeft()
-  {
-    nsRect rcFrame;
-    GetOffsetRect(rcFrame);
-
-    return rcFrame.x;
-  }
-  int32_t OffsetWidth()
-  {
-    nsRect rcFrame;
-    GetOffsetRect(rcFrame);
-
-    return rcFrame.width;
-  }
-  int32_t OffsetHeight()
-  {
-    nsRect rcFrame;
-    GetOffsetRect(rcFrame);
-
-    return rcFrame.height;
-  }
 
   // nsIDOMHTMLElement methods. Note that these are non-virtual
   // methods, implementations are expected to forward calls to these
   // methods.
+  nsresult GetId(nsAString& aId);
+  nsresult SetId(const nsAString& aId);
+  nsresult GetTitle(nsAString& aTitle);
+  nsresult SetTitle(const nsAString& aTitle);
+  nsresult GetLang(nsAString& aLang);
+  nsresult SetLang(const nsAString& aLang);
+  NS_IMETHOD GetDir(nsAString& aDir);
+  NS_IMETHOD SetDir(const nsAString& aDir);
+  nsresult GetClassName(nsAString& aClassName);
+  nsresult SetClassName(const nsAString& aClassName);
+
+  nsresult DOMClick()
+  {
+    Click();
+    return NS_OK;
+  }
+  nsresult GetTabIndex(int32_t* aTabIndex)
+  {
+    *aTabIndex = TabIndex();
+    return NS_OK;
+  }
+  nsresult SetTabIndex(int32_t aTabIndex)
+  {
+    mozilla::ErrorResult rv;
+    SetTabIndex(aTabIndex, rv);
+    return rv.ErrorCode();
+  }
+  nsresult DOMFocus() {
+    mozilla::ErrorResult rv;
+    Focus(rv);
+    return rv.ErrorCode();
+  }
+  nsresult GetDraggable(bool* aDraggable)
+  {
+    *aDraggable = Draggable();
+    return NS_OK;
+  }
+  nsresult SetDraggable(bool aDraggable)
+  {
+    mozilla::ErrorResult rv;
+    SetDraggable(aDraggable, rv);
+    return rv.ErrorCode();
+  }
+
+  nsresult GetDOMInnerHTML(nsAString& aInnerHTML)
+  {
+    mozilla::ErrorResult rv;
+    GetInnerHTML(aInnerHTML, rv);
+    return rv.ErrorCode();
+  }
+  nsresult SetDOMInnerHTML(const nsAString& aInnerHTML)
+  {
+    mozilla::ErrorResult rv;
+    SetInnerHTML(aInnerHTML, rv);
+    return rv.ErrorCode();
+  }
+
+  nsresult GetOffsetTop(int32_t* aOffsetTop);
+  nsresult GetOffsetLeft(int32_t* aOffsetLeft);
+  nsresult GetOffsetWidth(int32_t* aOffsetWidth);
+  nsresult GetOffsetHeight(int32_t* aOffsetHeight);
+  nsresult GetOffsetParent(nsIDOMElement** aOffsetParent);
+  NS_IMETHOD GetOuterHTML(nsAString& aOuterHTML);
+  NS_IMETHOD SetOuterHTML(const nsAString& aOuterHTML);
   NS_IMETHOD InsertAdjacentHTML(const nsAString& aPosition,
                                 const nsAString& aText);
+  nsresult ScrollIntoView(bool aTop, uint8_t optional_argc);
+  // Declare Blur(), GetHidden(), SetHidden(), GetSpellcheck(), and
+  // SetSpellcheck() such that classes that inherit interfaces with those
+  // methods properly override them.
+  NS_IMETHOD Blur();
+  NS_IMETHOD GetHidden(bool* aHidden);
+  NS_IMETHOD SetHidden(bool aHidden);
+  NS_IMETHOD GetSpellcheck(bool* aSpellcheck);
+  NS_IMETHOD SetSpellcheck(bool aSpellcheck);
+  NS_IMETHOD GetItemScope(bool* aItemScope);
+  NS_IMETHOD SetItemScope(bool aItemScope);
   NS_IMETHOD GetItemValue(nsIVariant** aValue);
+  JS::Value GetItemValue(JSContext* aCx, JSObject* aScope,
+                         mozilla::ErrorResult& error);
   NS_IMETHOD SetItemValue(nsIVariant* aValue);
 protected:
-  void GetProperties(nsIDOMHTMLPropertiesCollection** aProperties);
-  void GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu) const;
-
   // These methods are used to implement element-specific behavior of Get/SetItemValue
   // when an element has @itemprop but no @itemscope.
   virtual void GetItemValueText(nsAString& text);
   virtual void SetItemValueText(const nsAString& text);
   nsDOMSettableTokenList* GetTokenList(nsIAtom* aAtom);
-  void GetTokenList(nsIAtom* aAtom, nsIVariant** aResult);
-  nsresult SetTokenList(nsIAtom* aAtom, nsIVariant* aValue);
 public:
+  NS_IMETHOD GetItemType(nsIVariant** aType);
+  NS_IMETHOD SetItemType(nsIVariant* aType);
+  NS_IMETHOD GetItemId(nsAString& aId);
+  NS_IMETHOD SetItemId(const nsAString& aId);
+  NS_IMETHOD GetItemRef(nsIVariant** aRef);
+  NS_IMETHOD SetItemRef(nsIVariant* aValue);
+  NS_IMETHOD GetItemProp(nsIVariant** aProp);
+  NS_IMETHOD SetItemProp(nsIVariant* aValue);
+  NS_IMETHOD GetProperties(nsIDOMHTMLPropertiesCollection** aReturn);
+  NS_IMETHOD GetAccessKey(nsAString &aAccessKey);
+  NS_IMETHOD SetAccessKey(const nsAString& aAccessKey);
+  NS_IMETHOD GetAccessKeyLabel(nsAString& aLabel);
+  nsresult GetContentEditable(nsAString& aContentEditable);
+  nsresult GetIsContentEditable(bool* aContentEditable);
   nsresult SetContentEditable(const nsAString &aContentEditable);
   nsresult GetDataset(nsISupports** aDataset);
+  already_AddRefed<nsDOMStringMap> Dataset();
   // Callback for destructor of of dataset to ensure to null out weak pointer.
   nsresult ClearDataset();
+  nsresult GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu);
 
   /**
    * Get width and height, using given image request if attributes are unset.
    */
   nsSize GetWidthHeightForImage(imgIRequest *aImageRequest);
 
 protected:
   nsresult GetMarkup(bool aIncludeSelf, nsAString& aMarkup);
@@ -686,17 +586,17 @@ public:
    * URIs in the attribute against the baseuri of the element. If the attribute
    * isn't a relative URI the value of the attribute is returned as is. Only
    * works for attributes in null namespace.
    *
    * @param aAttr      name of attribute.
    * @param aBaseAttr  name of base attribute.
    * @param aResult    result value [out]
    */
-  NS_HIDDEN_(void) GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult) const;
+  NS_HIDDEN_(nsresult) GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsAString& aResult);
 
   /**
    * Gets the absolute URI values of an attribute, by resolving any relative
    * URIs in the attribute against the baseuri of the element. If a substring
    * isn't a relative URI, the substring is returned as is. Only works for
    * attributes in null namespace.
    */
   bool GetURIAttr(nsIAtom* aAttr, nsIAtom* aBaseAttr, nsIURI** aURI) const;
@@ -780,57 +680,16 @@ protected:
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify);
 
   virtual nsEventListenerManager*
     GetEventListenerManagerForAttr(nsIAtom* aAttrName, bool* aDefer);
 
   virtual const nsAttrName* InternalGetExistingAttrNameFromQName(const nsAString& aStr) const;
 
-  void GetHTMLAttr(nsIAtom* aName, nsAString& aResult) const
-  {
-    GetAttr(kNameSpaceID_None, aName, aResult);
-  }
-  void GetHTMLEnumAttr(nsIAtom* aName, nsAString& aResult) const
-  {
-    GetEnumAttr(aName, nullptr, aResult);
-  }
-  void GetHTMLURIAttr(nsIAtom* aName, nsAString& aResult) const
-  {
-    GetURIAttr(aName, nullptr, aResult);
-  }
-
-  void SetHTMLAttr(nsIAtom* aName, const nsAString& aValue)
-  {
-    SetAttr(kNameSpaceID_None, aName, aValue, true);
-  }
-  void SetHTMLAttr(nsIAtom* aName, const nsAString& aValue, mozilla::ErrorResult& aError)
-  {
-    aError = SetAttr(kNameSpaceID_None, aName, aValue, true);
-  }
-  void UnsetHTMLAttr(nsIAtom* aName, mozilla::ErrorResult& aError)
-  {
-    aError = UnsetAttr(kNameSpaceID_None, aName, true);
-  }
-  void SetHTMLBoolAttr(nsIAtom* aName, bool aValue, mozilla::ErrorResult& aError)
-  {
-    if (aValue) {
-      SetHTMLAttr(aName, EmptyString(), aError);
-    } else {
-      UnsetHTMLAttr(aName, aError);
-    }
-  }
-  void SetHTMLIntAttr(nsIAtom* aName, int32_t aValue, mozilla::ErrorResult& aError)
-  {
-    nsAutoString value;
-    value.AppendInt(aValue);
-
-    SetHTMLAttr(aName, value, aError);
-  }
-
   /**
    * Helper method for NS_IMPL_STRING_ATTR macro.
    * Sets the value of an attribute, returns specified default value if the
    * attribute isn't set. Only works for attributes in null namespace.
    *
    * @param aAttr    name of attribute.
    * @param aDefault default-value to return if attribute isn't set.
    * @param aResult  result value [out]
@@ -931,37 +790,38 @@ protected:
    * Helper method for NS_IMPL_ENUM_ATTR_DEFAULT_VALUE.
    * Gets the enum value string of an attribute and using a default value if
    * the attribute is missing or the string is an invalid enum value.
    *
    * @param aType     the name of the attribute.
    * @param aDefault  the default value if the attribute is missing or invalid.
    * @param aResult   string corresponding to the value [out].
    */
-  NS_HIDDEN_(void) GetEnumAttr(nsIAtom* aAttr,
-                               const char* aDefault,
-                               nsAString& aResult) const;
+  NS_HIDDEN_(nsresult) GetEnumAttr(nsIAtom* aAttr,
+                                   const char* aDefault,
+                                   nsAString& aResult);
 
   /**
    * Locates the nsIEditor associated with this node.  In general this is
    * equivalent to GetEditorInternal(), but for designmode or contenteditable,
    * this may need to get an editor that's not actually on this element's
    * associated TextControlFrame.  This is used by the spellchecking routines
    * to get the editor affected by changing the spellcheck attribute on this
    * node.
    */
   virtual already_AddRefed<nsIEditor> GetAssociatedEditor();
 
   /**
    * Get the frame's offset information for offsetTop/Left/Width/Height.
-   * Returns the parent the offset is relative to.
    * @note This method flushes pending notifications (Flush_Layout).
    * @param aRect the offset information [OUT]
+   * @param aOffsetParent the parent the offset is relative to (offsetParent)
+   *        [OUT]
    */
-  virtual nsGenericElement* GetOffsetRect(nsRect& aRect);
+  virtual void GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent);
 
   /**
    * Returns true if this is the current document's body element
    */
   bool IsCurrentBodyElement();
 
   /**
    * Ensures all editors associated with a subtree are synced, for purposes of
@@ -1305,31 +1165,29 @@ protected:
  * uses the generic GetAttr and SetAttr methods.  This macro is much
  * like the NS_IMPL_STRING_ATTR macro, except we make sure the URI is
  * absolute.
  */
 #define NS_IMPL_URI_ATTR(_class, _method, _atom)                    \
   NS_IMETHODIMP                                                     \
   _class::Get##_method(nsAString& aValue)                           \
   {                                                                 \
-    GetURIAttr(nsGkAtoms::_atom, nullptr, aValue);                  \
-    return NS_OK;                                                   \
+    return GetURIAttr(nsGkAtoms::_atom, nullptr, aValue);          \
   }                                                                 \
   NS_IMETHODIMP                                                     \
   _class::Set##_method(const nsAString& aValue)                     \
   {                                                                 \
     return SetAttrHelper(nsGkAtoms::_atom, aValue);               \
   }
 
 #define NS_IMPL_URI_ATTR_WITH_BASE(_class, _method, _atom, _base_atom)       \
   NS_IMETHODIMP                                                              \
   _class::Get##_method(nsAString& aValue)                                    \
   {                                                                          \
-    GetURIAttr(nsGkAtoms::_atom, nsGkAtoms::_base_atom, aValue);             \
-    return NS_OK;                                                            \
+    return GetURIAttr(nsGkAtoms::_atom, nsGkAtoms::_base_atom, aValue);  \
   }                                                                          \
   NS_IMETHODIMP                                                              \
   _class::Set##_method(const nsAString& aValue)                              \
   {                                                                          \
     return SetAttrHelper(nsGkAtoms::_atom, aValue);                        \
   }
 
 /**
@@ -1337,20 +1195,20 @@ protected:
  * attributes. It's very similar to NS_IMPL_URI_ATTR excepted that if the
  * content attribute is the empty string, the empty string is returned.
  */
 #define NS_IMPL_ACTION_ATTR(_class, _method, _atom)                 \
   NS_IMETHODIMP                                                     \
   _class::Get##_method(nsAString& aValue)                           \
   {                                                                 \
     GetAttr(kNameSpaceID_None, nsGkAtoms::_atom, aValue);           \
-    if (!aValue.IsEmpty()) {                                        \
-      GetURIAttr(nsGkAtoms::_atom, nullptr, aValue);                 \
+    if (aValue.IsEmpty()) {                                         \
+      return NS_OK;                                                 \
     }                                                               \
-    return NS_OK;                                                   \
+    return GetURIAttr(nsGkAtoms::_atom, nullptr, aValue);            \
   }                                                                 \
   NS_IMETHODIMP                                                     \
   _class::Set##_method(const nsAString& aValue)                     \
   {                                                                 \
     return SetAttrHelper(nsGkAtoms::_atom, aValue);                 \
   }
 
 /**
@@ -1383,18 +1241,17 @@ protected:
  * A macro to implement the getter and setter for a given content
  * property that needs to set an enumerated string. The method
  * uses a specific GetEnumAttr and the generic SetAttrHelper methods.
  */
 #define NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(_class, _method, _atom, _default) \
   NS_IMETHODIMP                                                           \
   _class::Get##_method(nsAString& aValue)                                 \
   {                                                                       \
-    GetEnumAttr(nsGkAtoms::_atom, _default, aValue);                      \
-    return NS_OK;                                                         \
+    return GetEnumAttr(nsGkAtoms::_atom, _default, aValue);               \
   }                                                                       \
   NS_IMETHODIMP                                                           \
   _class::Set##_method(const nsAString& aValue)                           \
   {                                                                       \
     return SetAttrHelper(nsGkAtoms::_atom, aValue);                       \
   }
 
 /**
@@ -1547,251 +1404,16 @@ protected:
     NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
     NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
     NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
     NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
     NS_INTERFACE_TABLE_ENTRY(_class, _i9)                                     \
     NS_INTERFACE_TABLE_ENTRY(_class, _i10)                                    \
   NS_OFFSET_AND_INTERFACE_TABLE_END
 
-#define NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC                                \
-  NS_IMETHOD GetId(nsAString& aId) MOZ_FINAL {                                 \
-    nsGenericElement::GetId(aId);                                              \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetId(const nsAString& aId) MOZ_FINAL {                           \
-    nsGenericElement::SetId(aId);                                              \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetTitle(nsAString& aTitle) MOZ_FINAL {                           \
-    nsGenericHTMLElement::GetTitle(aTitle);                                    \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetTitle(const nsAString& aTitle) MOZ_FINAL {                     \
-    nsGenericHTMLElement::SetTitle(aTitle);                                    \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetLang(nsAString& aLang) MOZ_FINAL {                             \
-    nsGenericHTMLElement::GetLang(aLang);                                      \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetLang(const nsAString& aLang) MOZ_FINAL {                       \
-    nsGenericHTMLElement::SetLang(aLang);                                      \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetDir(nsAString& aDir) MOZ_FINAL {                               \
-    nsGenericHTMLElement::GetDir(aDir);                                        \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetDir(const nsAString& aDir) MOZ_FINAL {                         \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetDir(aDir, rv);                                    \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetClassName(nsAString& aClassName) MOZ_FINAL {                   \
-    nsGenericHTMLElement::GetClassName(aClassName);                            \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetClassName(const nsAString& aClassName) MOZ_FINAL {             \
-    nsGenericHTMLElement::SetClassName(aClassName);                            \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetDataset(nsISupports** aDataset) MOZ_FINAL {                    \
-    return nsGenericHTMLElement::GetDataset(aDataset);                         \
-  }                                                                            \
-  NS_IMETHOD GetHidden(bool* aHidden) MOZ_FINAL {                              \
-    *aHidden = nsGenericHTMLElement::Hidden();                                 \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetHidden(bool aHidden) MOZ_FINAL {                               \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetHidden(aHidden, rv);                              \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD DOMBlur() MOZ_FINAL {                                             \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::Blur(rv);                                            \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetItemScope(bool* aItemScope) MOZ_FINAL {                        \
-    *aItemScope = nsGenericHTMLElement::ItemScope();                           \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetItemScope(bool aItemScope) MOZ_FINAL {                         \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetItemScope(aItemScope, rv);                        \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetItemType(nsIVariant** aType) MOZ_FINAL {                       \
-    GetTokenList(nsGkAtoms::itemtype, aType);                                  \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetItemType(nsIVariant* aType) MOZ_FINAL {                        \
-    return nsGenericHTMLElement::SetTokenList(nsGkAtoms::itemtype, aType);     \
-  }                                                                            \
-  NS_IMETHOD GetItemId(nsAString& aId) MOZ_FINAL {                             \
-    nsGenericHTMLElement::GetItemId(aId);                                      \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetItemId(const nsAString& aId) MOZ_FINAL {                       \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetItemId(aId, rv);                                  \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetProperties(nsIDOMHTMLPropertiesCollection** aReturn)           \
-      MOZ_FINAL {                                                              \
-    nsGenericHTMLElement::GetProperties(aReturn);                              \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetItemValue(nsIVariant** aValue) MOZ_FINAL {                     \
-    return nsGenericHTMLElement::GetItemValue(aValue);                         \
-  }                                                                            \
-  NS_IMETHOD SetItemValue(nsIVariant* aValue) MOZ_FINAL {                      \
-    return nsGenericHTMLElement::SetItemValue(aValue);                         \
-  }                                                                            \
-  NS_IMETHOD GetItemRef(nsIVariant** aRef) MOZ_FINAL {                         \
-    GetTokenList(nsGkAtoms::itemref, aRef);                                    \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetItemRef(nsIVariant* aRef) MOZ_FINAL {                          \
-    return nsGenericHTMLElement::SetTokenList(nsGkAtoms::itemref, aRef);       \
-  }                                                                            \
-  NS_IMETHOD GetItemProp(nsIVariant** aProp) MOZ_FINAL {                       \
-    GetTokenList(nsGkAtoms::itemprop, aProp);                                  \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetItemProp(nsIVariant* aProp) MOZ_FINAL {                        \
-    return nsGenericHTMLElement::SetTokenList(nsGkAtoms::itemprop, aProp);     \
-  }                                                                            \
-  NS_IMETHOD GetAccessKey(nsAString& aAccessKey) MOZ_FINAL {                   \
-    nsGenericHTMLElement::GetAccessKey(aAccessKey);                            \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetAccessKey(const nsAString& aAccessKey) MOZ_FINAL {             \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetAccessKey(aAccessKey, rv);                        \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetAccessKeyLabel(nsAString& aAccessKeyLabel) MOZ_FINAL {         \
-    nsGenericHTMLElement::GetAccessKeyLabel(aAccessKeyLabel);                  \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetDraggable(bool aDraggable) MOZ_FINAL {                         \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetDraggable(aDraggable, rv);                        \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetContentEditable(nsAString& aContentEditable) MOZ_FINAL {       \
-    nsGenericHTMLElement::GetContentEditable(aContentEditable);                \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetContentEditable(const nsAString& aContentEditable) MOZ_FINAL { \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetContentEditable(aContentEditable, rv);            \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetIsContentEditable(bool* aIsContentEditable) MOZ_FINAL {        \
-    *aIsContentEditable = nsGenericHTMLElement::IsContentEditable();           \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu) MOZ_FINAL {  \
-    nsGenericHTMLElement::GetContextMenu(aContextMenu);                        \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetSpellcheck(bool* aSpellcheck) MOZ_FINAL {                      \
-    *aSpellcheck = nsGenericHTMLElement::Spellcheck();                         \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD SetSpellcheck(bool aSpellcheck) MOZ_FINAL {                       \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetSpellcheck(aSpellcheck, rv);                      \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetOuterHTML(nsAString& aOuterHTML) MOZ_FINAL {                   \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::GetOuterHTML(aOuterHTML, rv);                        \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD SetOuterHTML(const nsAString& aOuterHTML) MOZ_FINAL {             \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetOuterHTML(aOuterHTML, rv);                        \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD InsertAdjacentHTML(const nsAString& position,                     \
-                                const nsAString& text) MOZ_FINAL {             \
-    return nsGenericHTMLElement::InsertAdjacentHTML(position, text);           \
-  }                                                                            \
-  NS_IMETHOD ScrollIntoView(bool top, uint8_t _argc) MOZ_FINAL {               \
-    if (!_argc) {                                                              \
-      top = true;                                                              \
-    }                                                                          \
-    nsGenericElement::ScrollIntoView(top);                                     \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetOffsetParent(nsIDOMElement** aOffsetParent) MOZ_FINAL {        \
-    nsGenericElement* offsetParent = nsGenericHTMLElement::GetOffsetParent();  \
-    if (!offsetParent) {                                                       \
-      *aOffsetParent = nullptr;                                                \
-      return NS_OK;                                                            \
-    }                                                                          \
-    return CallQueryInterface(offsetParent, aOffsetParent);                    \
-  }                                                                            \
-  NS_IMETHOD GetOffsetTop(int32_t* aOffsetTop) MOZ_FINAL {                     \
-    *aOffsetTop = nsGenericHTMLElement::OffsetTop();                           \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetOffsetLeft(int32_t* aOffsetLeft) MOZ_FINAL {                   \
-    *aOffsetLeft = nsGenericHTMLElement::OffsetLeft();                         \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetOffsetWidth(int32_t* aOffsetWidth) MOZ_FINAL {                 \
-    *aOffsetWidth = nsGenericHTMLElement::OffsetWidth();                       \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetOffsetHeight(int32_t* aOffsetHeight) MOZ_FINAL {               \
-    *aOffsetHeight = nsGenericHTMLElement::OffsetHeight();                     \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD DOMClick() MOZ_FINAL {                                            \
-    Click();                                                                   \
-    return NS_OK;                                                              \
-  }                                                                            \
-  NS_IMETHOD GetTabIndex(int32_t* aTabIndex) MOZ_FINAL {                       \
-    *aTabIndex = TabIndex();                                                   \
-    return NS_OK;                                                              \
-  }                                                                            \
-  using nsGenericHTMLElement::SetTabIndex;                                     \
-  NS_IMETHOD SetTabIndex(int32_t aTabIndex) MOZ_FINAL {                        \
-    mozilla::ErrorResult rv;                                                   \
-    nsGenericHTMLElement::SetTabIndex(aTabIndex, rv);                          \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  using nsGenericHTMLElement::Focus;                                           \
-  NS_IMETHOD Focus() MOZ_FINAL {                                               \
-    mozilla::ErrorResult rv;                                                   \
-    Focus(rv);                                                                 \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  NS_IMETHOD GetDraggable(bool* aDraggable) MOZ_FINAL {                        \
-    *aDraggable = Draggable();                                                 \
-    return NS_OK;                                                              \
-  }                                                                            \
-  using nsGenericHTMLElement::GetInnerHTML;                                    \
-  NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) MOZ_FINAL {                   \
-    mozilla::ErrorResult rv;                                                   \
-    GetInnerHTML(aInnerHTML, rv);                                              \
-    return rv.ErrorCode();                                                     \
-  }                                                                            \
-  using nsGenericHTMLElement::SetInnerHTML;                                    \
-  NS_IMETHOD SetInnerHTML(const nsAString& aInnerHTML) MOZ_FINAL {             \
-    mozilla::ErrorResult rv;                                                   \
-    SetInnerHTML(aInnerHTML, rv);                                              \
-    return rv.ErrorCode();                                                     \
-  }
-
 /**
  * A macro to declare the NS_NewHTMLXXXElement() functions.
  */
 #define NS_DECLARE_NS_NEW_HTML_ELEMENT(_elementName)                       \
 nsGenericHTMLElement*                                                      \
 NS_NewHTML##_elementName##Element(already_AddRefed<nsINodeInfo> aNodeInfo, \
                                   mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
 
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -36,18 +36,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
   virtual bool Draggable() const MOZ_OVERRIDE;
 
   // nsIDOMHTMLAnchorElement
   NS_DECL_NSIDOMHTMLANCHORELEMENT  
 
   // DOM memory reporter participant
   NS_DECL_SIZEOF_EXCLUDING_THIS
--- a/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/content/html/content/src/nsHTMLAreaElement.cpp
@@ -30,18 +30,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLAreaElement
   NS_DECL_NSIDOMHTMLAREAELEMENT
 
   // nsILink
   NS_IMETHOD LinkAdded() { return NS_OK; }
   NS_IMETHOD LinkRemoved() { return NS_OK; }
--- a/content/html/content/src/nsHTMLBRElement.cpp
+++ b/content/html/content/src/nsHTMLBRElement.cpp
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLBRElement
   NS_DECL_NSIDOMHTMLBRELEMENT    
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/content/html/content/src/nsHTMLBodyElement.cpp
@@ -63,17 +63,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLBodyElement
   NS_DECL_NSIDOMHTMLBODYELEMENT
 
   // Event listener stuff; we need to declare only the ones we need to
   // forward to window that don't come from nsIDOMHTMLBodyElement.
 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the shim */
 #define FORWARDED_EVENT(name_, id_, type_, struct_)               \
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -64,18 +64,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLButtonElement
   NS_DECL_NSIDOMHTMLBUTTONELEMENT
 
   // overriden nsIFormControl methods
   NS_IMETHOD_(uint32_t) GetType() const { return mType; }
   NS_IMETHOD Reset();
--- a/content/html/content/src/nsHTMLDataListElement.cpp
+++ b/content/html/content/src/nsHTMLDataListElement.cpp
@@ -23,17 +23,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLDataListElement
   NS_DECL_NSIDOMHTMLDATALISTELEMENT
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   // This function is used to generate the nsContentList (option elements).
   static bool MatchOptions(nsIContent* aContent, int32_t aNamespaceID,
--- a/content/html/content/src/nsHTMLDivElement.cpp
+++ b/content/html/content/src/nsHTMLDivElement.cpp
@@ -1,22 +1,59 @@
 /* -*- Mode: C++; 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 "mozilla/Util.h"
 
-#include "nsHTMLDivElement.h"
+#include "nsIDOMHTMLDivElement.h"
+#include "nsIDOMEventTarget.h"
 #include "nsGenericHTMLElement.h"
+#include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsMappedAttributes.h"
 
 using namespace mozilla;
 
+class nsHTMLDivElement : public nsGenericHTMLElement,
+                         public nsIDOMHTMLDivElement
+{
+public:
+  nsHTMLDivElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual ~nsHTMLDivElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE_TO_NSINODE
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLDivElement
+  NS_DECL_NSIDOMHTMLDIVELEMENT
+
+  virtual bool ParseAttribute(int32_t aNamespaceID,
+                                nsIAtom* aAttribute,
+                                const nsAString& aValue,
+                                nsAttrValue& aResult);
+  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
+  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+
+  virtual nsXPCClassInfo* GetClassInfo();
+  virtual nsIDOMNode* AsDOMNode() { return this; }
+};
+
+
 NS_IMPL_NS_NEW_HTML_ELEMENT(Div)
 
 
 nsHTMLDivElement::nsHTMLDivElement(already_AddRefed<nsINodeInfo> aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo)
 {
 }
 
@@ -35,16 +72,19 @@ NS_INTERFACE_TABLE_HEAD(nsHTMLDivElement
   NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLDivElement, nsIDOMHTMLDivElement)
   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLDivElement,
                                                nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLDivElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLDivElement)
 
 
+NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align)
+
+
 bool
 nsHTMLDivElement::ParseAttribute(int32_t aNamespaceID,
                                  nsIAtom* aAttribute,
                                  const nsAString& aValue,
                                  nsAttrValue& aResult)
 {
   if (aNamespaceID == kNameSpaceID_None) {
     if (mNodeInfo->Equals(nsGkAtoms::marquee)) {
deleted file mode 100644
--- a/content/html/content/src/nsHTMLDivElement.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* -*- Mode: C++; 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/. */
-#ifndef nsHTMLDivElement_h___
-#define nsHTMLDivElement_h___
-
-#include "nsGenericHTMLElement.h"
-#include "nsIDOMHTMLDivElement.h"
-
-class nsHTMLDivElement : public nsGenericHTMLElement,
-                         public nsIDOMHTMLDivElement
-{
-public:
-  nsHTMLDivElement(already_AddRefed<nsINodeInfo> aNodeInfo);
-  virtual ~nsHTMLDivElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
-  // nsIDOMHTMLDivElement
-  NS_IMETHOD GetAlign(nsAString& aAlign)
-  {
-    nsString align;
-    GetAlign(align);
-    aAlign = align;
-    return NS_OK;
-  }
-  NS_IMETHOD SetAlign(const nsAString& aAlign)
-  {
-    mozilla::ErrorResult rv;
-    SetAlign(aAlign, rv);
-    return rv.ErrorCode();
-  }
-
-  void GetAlign(nsString& aAlign)
-  {
-    GetHTMLAttr(nsGkAtoms::align, aAlign);
-  }
-  void SetAlign(const nsAString& aAlign, mozilla::ErrorResult& aError)
-  {
-    SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
-  }
-
-  virtual bool ParseAttribute(int32_t aNamespaceID,
-                                nsIAtom* aAttribute,
-                                const nsAString& aValue,
-                                nsAttrValue& aResult);
-  NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
-  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-#endif /* nsHTMLDivElement_h___ */
--- a/content/html/content/src/nsHTMLElement.cpp
+++ b/content/html/content/src/nsHTMLElement.cpp
@@ -23,18 +23,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual void GetInnerHTML(nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError) MOZ_OVERRIDE;
 
   nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
--- a/content/html/content/src/nsHTMLFieldSetElement.h
+++ b/content/html/content/src/nsHTMLFieldSetElement.h
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
 
   // nsIDOMHTMLFieldSetElement
   NS_DECL_NSIDOMHTMLFIELDSETELEMENT
 
   // nsIContent
   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                                 const nsAttrValue* aValue, bool aNotify);
--- a/content/html/content/src/nsHTMLFontElement.cpp
+++ b/content/html/content/src/nsHTMLFontElement.cpp
@@ -32,17 +32,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLFontElement
   NS_DECL_NSIDOMHTMLFONTELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLFormElement.h
+++ b/content/html/content/src/nsHTMLFormElement.h
@@ -41,17 +41,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLFormElement
   NS_DECL_NSIDOMHTMLFORMELEMENT
 
   // nsIWebProgressListener
   NS_DECL_NSIWEBPROGRESSLISTENER
 
   // nsIForm
--- a/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/content/html/content/src/nsHTMLFrameElement.cpp
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
 
   // nsIDOMHTMLFrameElement
   NS_DECL_NSIDOMHTMLFRAMEELEMENT
 
   // nsIContent
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
--- a/content/html/content/src/nsHTMLFrameSetElement.h
+++ b/content/html/content/src/nsHTMLFrameSetElement.h
@@ -54,17 +54,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLFrameSetElement
   NS_DECL_NSIDOMHTMLFRAMESETELEMENT
 
   // Event listener stuff; we need to declare only the ones we need to
   // forward to window that don't come from nsIDOMHTMLFrameSetElement.
 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the superclass */
 #define FORWARDED_EVENT(name_, id_, type_, struct_)                     \
--- a/content/html/content/src/nsHTMLHRElement.cpp
+++ b/content/html/content/src/nsHTMLHRElement.cpp
@@ -31,17 +31,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLHRElement
   NS_DECL_NSIDOMHTMLHRELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLHeadingElement.cpp
+++ b/content/html/content/src/nsHTMLHeadingElement.cpp
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLHeadingElement
   NS_DECL_NSIDOMHTMLHEADINGELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLIFrameElement.h
+++ b/content/html/content/src/nsHTMLIFrameElement.h
@@ -24,17 +24,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
 
   // nsIDOMHTMLIFrameElement
   NS_DECL_NSIDOMHTMLIFRAMEELEMENT
 
   // nsIDOMGetSVGDocument
   NS_DECL_NSIDOMGETSVGDOCUMENT
 
   // nsIContent
--- a/content/html/content/src/nsHTMLImageElement.h
+++ b/content/html/content/src/nsHTMLImageElement.h
@@ -25,18 +25,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual bool Draggable() const MOZ_OVERRIDE;
 
   // nsIDOMHTMLImageElement
   NS_DECL_NSIDOMHTMLIMAGEELEMENT
 
   // override from nsImageLoadingContent
   mozilla::CORSMode GetCORSMode();
 
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -2399,17 +2399,17 @@ nsHTMLInputElement::PostHandleEvent(nsEv
                 nsAutoString name;
                 GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
                 nsCOMPtr<nsIDOMHTMLInputElement> selectedRadioButton;
                 container->GetNextRadioButton(name, isMovingBack, this,
                                               getter_AddRefs(selectedRadioButton));
                 nsCOMPtr<nsIContent> radioContent =
                   do_QueryInterface(selectedRadioButton);
                 if (radioContent) {
-                  rv = selectedRadioButton->Focus();
+                  rv = selectedRadioButton->DOMFocus();
                   if (NS_SUCCEEDED(rv)) {
                     nsEventStatus status = nsEventStatus_eIgnore;
                     nsMouseEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent),
                                        NS_MOUSE_CLICK, nullptr,
                                        nsMouseEvent::eReal);
                     event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
                     rv = nsEventDispatcher::Dispatch(radioContent,
                                                      aVisitor.mPresContext,
--- a/content/html/content/src/nsHTMLInputElement.h
+++ b/content/html/content/src/nsHTMLInputElement.h
@@ -72,18 +72,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
   virtual void Click() MOZ_OVERRIDE;
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
   virtual void Focus(mozilla::ErrorResult& aError) MOZ_OVERRIDE;
 
   // nsIDOMHTMLInputElement
   NS_DECL_NSIDOMHTMLINPUTELEMENT
 
   // nsIPhonetic
--- a/content/html/content/src/nsHTMLLIElement.cpp
+++ b/content/html/content/src/nsHTMLLIElement.cpp
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLLIElement
   NS_DECL_NSIDOMHTMLLIELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLLabelElement.h
+++ b/content/html/content/src/nsHTMLLabelElement.h
@@ -29,18 +29,17 @@ public:
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLLabelElement
   NS_DECL_NSIDOMHTMLLABELELEMENT
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
   virtual void Focus(mozilla::ErrorResult& aError) MOZ_OVERRIDE;
 
   // nsIFormControl
   NS_IMETHOD_(uint32_t) GetType() const { return NS_FORM_LABEL; }
   NS_IMETHOD Reset();
   NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
 
   virtual bool IsDisabled() const { return false; }
--- a/content/html/content/src/nsHTMLLegendElement.h
+++ b/content/html/content/src/nsHTMLLegendElement.h
@@ -25,18 +25,17 @@ public:
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLLegendElement
   NS_DECL_NSIDOMHTMLLEGENDELEMENT
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual void Focus(mozilla::ErrorResult& aError) MOZ_OVERRIDE;
 
   virtual void PerformAccesskey(bool aKeyCausesActivation,
                                 bool aIsTrustedEvent);
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -47,17 +47,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLLinkElement
   NS_DECL_NSIDOMHTMLLINKELEMENT
 
   // DOM memory reporter participant
   NS_DECL_SIZEOF_EXCLUDING_THIS
 
   // nsILink
--- a/content/html/content/src/nsHTMLMapElement.cpp
+++ b/content/html/content/src/nsHTMLMapElement.cpp
@@ -22,17 +22,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLMapElement
   NS_DECL_NSIDOMHTMLMAPELEMENT
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLMapElement,
                                                      nsGenericHTMLElement)
--- a/content/html/content/src/nsHTMLMenuElement.h
+++ b/content/html/content/src/nsHTMLMenuElement.h
@@ -22,17 +22,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLMenuElement
   NS_DECL_NSIDOMHTMLMENUELEMENT
 
   // nsIHTMLMenu
   NS_DECL_NSIHTMLMENU
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
--- a/content/html/content/src/nsHTMLMenuItemElement.h
+++ b/content/html/content/src/nsHTMLMenuItemElement.h
@@ -25,17 +25,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLCommandElement
   NS_DECL_NSIDOMHTMLCOMMANDELEMENT
 
   // nsIDOMHTMLMenuItemElement
   NS_DECL_NSIDOMHTMLMENUITEMELEMENT
 
   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
--- a/content/html/content/src/nsHTMLMetaElement.cpp
+++ b/content/html/content/src/nsHTMLMetaElement.cpp
@@ -23,17 +23,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLMetaElement
   NS_DECL_NSIDOMHTMLMETAELEMENT
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent,
                               bool aCompileEventHandlers);
   virtual void UnbindFromTree(bool aDeep = true,
--- a/content/html/content/src/nsHTMLMeterElement.cpp
+++ b/content/html/content/src/nsHTMLMeterElement.cpp
@@ -23,17 +23,17 @@ public:
 
   /* nsIDOMNode */
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   /* nsIDOMElement */
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   /* nsIDOMHTMLElement */
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   /* nsIDOMHTMLMeterElement */
   NS_DECL_NSIDOMHTMLMETERELEMENT
 
   virtual nsEventStates IntrinsicState() const;
 
   nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
 
--- a/content/html/content/src/nsHTMLModElement.cpp
+++ b/content/html/content/src/nsHTMLModElement.cpp
@@ -21,17 +21,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLModElement
   NS_DECL_NSIDOMHTMLMODELEMENT
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
--- a/content/html/content/src/nsHTMLOListElement.cpp
+++ b/content/html/content/src/nsHTMLOListElement.cpp
@@ -32,17 +32,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLOListElement
   NS_DECL_NSIDOMHTMLOLISTELEMENT
 
   // nsIDOMHTMLDListElement
   // fully declared by NS_DECL_NSIDOMHTMLOLISTELEMENT
 
   // nsIDOMHTMLUListElement
--- a/content/html/content/src/nsHTMLObjectElement.cpp
+++ b/content/html/content/src/nsHTMLObjectElement.cpp
@@ -44,18 +44,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLObjectElement
   NS_DECL_NSIDOMHTMLOBJECTELEMENT
 
   // nsIDOMGetSVGDocument
   NS_DECL_NSIDOMGETSVGDOCUMENT
 
@@ -304,19 +303,18 @@ nsHTMLObjectElement::UnsetAttr(int32_t a
 bool
 nsHTMLObjectElement::IsFocusableForTabIndex()
 {
   nsIDocument* doc = GetCurrentDoc();
   if (!doc || doc->HasFlag(NODE_IS_EDITABLE)) {
     return false;
   }
 
-  return IsEditableRoot() ||
-         (Type() == eType_Document &&
-          nsContentUtils::IsSubDocumentTabbable(this));
+  return IsEditableRoot() || (Type() == eType_Document &&
+                              nsContentUtils::IsSubDocumentTabbable(this));
 }
 
 bool
 nsHTMLObjectElement::IsHTMLFocusable(bool aWithMouse,
                                      bool *aIsFocusable, int32_t *aTabIndex)
 {
   // TODO: this should probably be managed directly by IsHTMLFocusable.
   // See bug 597242.
--- a/content/html/content/src/nsHTMLOptGroupElement.h
+++ b/content/html/content/src/nsHTMLOptGroupElement.h
@@ -21,17 +21,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLOptGroupElement
   NS_DECL_NSIDOMHTMLOPTGROUPELEMENT
 
   // nsINode
   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
                                  bool aNotify);
   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify);
--- a/content/html/content/src/nsHTMLOptionElement.h
+++ b/content/html/content/src/nsHTMLOptionElement.h
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLOptionElement
   using nsGenericElement::SetText;
   using nsGenericElement::GetText;
   NS_DECL_NSIDOMHTMLOPTIONELEMENT
 
   bool Selected() const;
   bool DefaultSelected() const;
--- a/content/html/content/src/nsHTMLOutputElement.cpp
+++ b/content/html/content/src/nsHTMLOutputElement.cpp
@@ -30,17 +30,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
 
   // nsIDOMHTMLOutputElement
   NS_DECL_NSIDOMHTMLOUTPUTELEMENT
 
   // nsIFormControl
   NS_IMETHOD_(uint32_t) GetType() const { return NS_FORM_OUTPUT; }
   NS_IMETHOD Reset();
   NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
--- a/content/html/content/src/nsHTMLParagraphElement.cpp
+++ b/content/html/content/src/nsHTMLParagraphElement.cpp
@@ -29,17 +29,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLParagraphElement
   NS_DECL_NSIDOMHTMLPARAGRAPHELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLPreElement.cpp
+++ b/content/html/content/src/nsHTMLPreElement.cpp
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLPreElement
   NS_IMETHOD GetWidth(int32_t* aWidth);
   NS_IMETHOD SetWidth(int32_t aWidth);
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
--- a/content/html/content/src/nsHTMLProgressElement.cpp
+++ b/content/html/content/src/nsHTMLProgressElement.cpp
@@ -22,17 +22,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLProgressElement
   NS_DECL_NSIDOMHTMLPROGRESSELEMENT
 
   nsEventStates IntrinsicState() const;
 
   nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const;
 
--- a/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/content/html/content/src/nsHTMLScriptElement.cpp
@@ -44,18 +44,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual void GetInnerHTML(nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError) MOZ_OVERRIDE;
   virtual void SetInnerHTML(const nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError) MOZ_OVERRIDE;
 
   // nsIDOMHTMLScriptElement
   NS_DECL_NSIDOMHTMLSCRIPTELEMENT
 
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -592,87 +592,82 @@ nsHTMLSelectElement::GetSelectFrame()
 
   if (form_control_frame) {
     select_frame = do_QueryFrame(form_control_frame);
   }
 
   return select_frame;
 }
 
-void
-nsHTMLSelectElement::Add(nsGenericHTMLElement& aElement,
-                         nsGenericHTMLElement* aBefore,
-                         ErrorResult& aError)
+nsresult
+nsHTMLSelectElement::Add(nsIDOMHTMLElement* aElement,
+                         nsIDOMHTMLElement* aBefore)
 {
+  nsCOMPtr<nsIDOMNode> added;
   if (!aBefore) {
-    nsGenericHTMLElement::AppendChild(aElement, aError);
-    return;
+    return AppendChild(aElement, getter_AddRefs(added));
   }
 
   // Just in case we're not the parent, get the parent of the reference
   // element
-  nsINode* parent = aBefore->GetParentNode();
-  if (!nsContentUtils::ContentIsDescendantOf(parent, this)) {
+  nsCOMPtr<nsIDOMNode> parent;
+  aBefore->GetParentNode(getter_AddRefs(parent));
+  if (!parent) {
     // NOT_FOUND_ERR: Raised if before is not a descendant of the SELECT
     // element.
-    aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
-    return;
+    return NS_ERROR_DOM_NOT_FOUND_ERR;
+  }
+
+  nsCOMPtr<nsIDOMNode> ancestor(parent);
+  nsCOMPtr<nsIDOMNode> temp;
+  while (ancestor != static_cast<nsIDOMNode*>(this)) {
+    ancestor->GetParentNode(getter_AddRefs(temp));
+    if (!temp) {
+      // NOT_FOUND_ERR: Raised if before is not a descendant of the SELECT
+      // element.
+      return NS_ERROR_DOM_NOT_FOUND_ERR;
+    }
+    temp.swap(ancestor);
   }
 
   // If the before parameter is not null, we are equivalent to the
   // insertBefore method on the parent of before.
-  parent->InsertBefore(aElement, aBefore, aError);
+  return parent->InsertBefore(aElement, aBefore, getter_AddRefs(added));
 }
 
 NS_IMETHODIMP
 nsHTMLSelectElement::Add(nsIDOMHTMLElement* aElement,
                          nsIVariant* aBefore)
 {
   uint16_t dataType;
   nsresult rv = aBefore->GetDataType(&dataType);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIContent> element = do_QueryInterface(aElement);
-  nsGenericHTMLElement* htmlElement =
-    nsGenericHTMLElement::FromContentOrNull(element);
-  if (!htmlElement) {
-    return NS_ERROR_NULL_POINTER;
-  }
-
   // aBefore is omitted, undefined or null
   if (dataType == nsIDataType::VTYPE_EMPTY ||
       dataType == nsIDataType::VTYPE_VOID) {
-    ErrorResult error;
-    Add(*htmlElement, (nsGenericHTMLElement*)nullptr, error);
-    return error.ErrorCode();
+    return Add(aElement);
   }
 
   nsCOMPtr<nsISupports> supports;
   nsCOMPtr<nsIDOMHTMLElement> beforeElement;
 
   // whether aBefore is nsIDOMHTMLElement...
   if (NS_SUCCEEDED(aBefore->GetAsISupports(getter_AddRefs(supports)))) {
-    nsCOMPtr<nsIContent> beforeElement = do_QueryInterface(supports);
-    nsGenericHTMLElement* beforeHTMLElement =
-      nsGenericHTMLElement::FromContentOrNull(beforeElement);
+    beforeElement = do_QueryInterface(supports);
 
-    NS_ENSURE_TRUE(beforeHTMLElement, NS_ERROR_DOM_SYNTAX_ERR);
-
-    ErrorResult error;
-    Add(*htmlElement, beforeHTMLElement, error);
-    return error.ErrorCode();
+    NS_ENSURE_TRUE(beforeElement, NS_ERROR_DOM_SYNTAX_ERR);
+    return Add(aElement, beforeElement);
   }
 
   // otherwise, whether aBefore is long
   int32_t index;
   NS_ENSURE_SUCCESS(aBefore->GetAsInt32(&index), NS_ERROR_DOM_SYNTAX_ERR);
 
-  ErrorResult error;
-  Add(*htmlElement, index, error);
-  return error.ErrorCode();
+  return Add(aElement, index);
 }
 
 NS_IMETHODIMP
 nsHTMLSelectElement::Remove(int32_t aIndex)
 {
   nsCOMPtr<nsIDOMNode> option;
   Item(aIndex, getter_AddRefs(option));
 
--- a/content/html/content/src/nsHTMLSelectElement.h
+++ b/content/html/content/src/nsHTMLSelectElement.h
@@ -244,18 +244,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLSelectElement
   NS_DECL_NSIDOMHTMLSELECTELEMENT
 
   // nsIContent
   virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
   virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
@@ -400,26 +399,25 @@ public:
 
   // nsIConstraintValidation
   nsresult GetValidationMessage(nsAString& aValidationMessage,
                                 ValidityStateType aType);
 
   /**
    * Insert aElement before the node given by aBefore
    */
-  void Add(nsGenericHTMLElement& aElement, nsGenericHTMLElement* aBefore,
-           mozilla::ErrorResult& aError);
-  void Add(nsGenericHTMLElement& aElement, int32_t aIndex,
-           mozilla::ErrorResult& aError)
+  nsresult Add(nsIDOMHTMLElement* aElement, nsIDOMHTMLElement* aBefore = nullptr);
+  nsresult Add(nsIDOMHTMLElement* aElement, int32_t aIndex)
   {
     // If item index is out of range, insert to last.
     // (since beforeElement becomes null, it is inserted to last)
-    nsIContent* beforeContent = mOptions->GetElementAt(aIndex);
-    return Add(aElement, nsGenericHTMLElement::FromContentOrNull(beforeContent),
-               aError);
+    nsCOMPtr<nsIDOMHTMLElement> beforeElement =
+      do_QueryInterface(mOptions->GetElementAt(aIndex));
+
+    return Add(aElement, beforeElement);
   }
 
 protected:
   friend class nsSafeOptionListMutation;
 
   // Helper Methods
   /**
    * Check whether the option specified by the index is selected
@@ -657,27 +655,25 @@ protected:
   nsCOMPtr<nsSelectState> mRestoreState;
 };
 
 void
 nsHTMLOptionCollection::Add(const HTMLOptionOrOptGroupElement& aElement,
                             const Nullable<HTMLElementOrLong>& aBefore,
                             mozilla::ErrorResult& aError)
 {
-  nsGenericHTMLElement& element =
-    aElement.IsHTMLOptionElement() ?
-    static_cast<nsGenericHTMLElement&>(*aElement.GetAsHTMLOptionElement()) :
-    static_cast<nsGenericHTMLElement&>(*aElement.GetAsHTMLOptGroupElement());
+  nsIDOMHTMLElement* element;
+  if (aElement.IsHTMLOptionElement()) {
+    element = aElement.GetAsHTMLOptionElement();
+  } else {
+    element = aElement.GetAsHTMLOptGroupElement();
+  }
 
   if (aBefore.IsNull()) {
-    mSelect->Add(element, (nsGenericHTMLElement*)nullptr, aError);
+    aError = mSelect->Add(element, (nsIDOMHTMLElement*)nullptr);
   } else if (aBefore.Value().IsHTMLElement()) {
-    nsCOMPtr<nsIContent> content =
-      do_QueryInterface(aBefore.Value().GetAsHTMLElement());
-    nsGenericHTMLElement* before =
-      static_cast<nsGenericHTMLElement*>(content.get());
-    mSelect->Add(element, before, aError);
+    aError = mSelect->Add(element, aBefore.Value().GetAsHTMLElement());
   } else {
-    mSelect->Add(element, aBefore.Value().GetAsLong(), aError);
+    aError = mSelect->Add(element, aBefore.Value().GetAsLong());
   }
 }
 
 #endif
--- a/content/html/content/src/nsHTMLSharedElement.cpp
+++ b/content/html/content/src/nsHTMLSharedElement.cpp
@@ -42,17 +42,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLParamElement
   NS_DECL_NSIDOMHTMLPARAMELEMENT
 
   // nsIDOMHTMLBaseElement
   NS_DECL_NSIDOMHTMLBASEELEMENT
 
   // nsIDOMHTMLDirectoryElement
--- a/content/html/content/src/nsHTMLSharedObjectElement.cpp
+++ b/content/html/content/src/nsHTMLSharedObjectElement.cpp
@@ -39,18 +39,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLAppletElement
   NS_DECL_NSIDOMHTMLAPPLETELEMENT
 
   // Can't use macro for nsIDOMHTMLEmbedElement because it has conflicts with
   // NS_DECL_NSIDOMHTMLAPPLETELEMENT.
 
--- a/content/html/content/src/nsHTMLSourceElement.cpp
+++ b/content/html/content/src/nsHTMLSourceElement.cpp
@@ -26,17 +26,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLSourceElement
   NS_DECL_NSIDOMHTMLSOURCEELEMENT
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   // Override BindToTree() so that we can trigger a load when we add a
   // child source element.
--- a/content/html/content/src/nsHTMLSpanElement.cpp
+++ b/content/html/content/src/nsHTMLSpanElement.cpp
@@ -22,17 +22,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
 };
 
--- a/content/html/content/src/nsHTMLStyleElement.cpp
+++ b/content/html/content/src/nsHTMLStyleElement.cpp
@@ -39,18 +39,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
   virtual void GetInnerHTML(nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError) MOZ_OVERRIDE;
   virtual void SetInnerHTML(const nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError) MOZ_OVERRIDE;
 
   // nsIDOMHTMLStyleElement
   NS_DECL_NSIDOMHTMLSTYLEELEMENT
 
--- a/content/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/content/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -28,17 +28,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTableCaptionElement
   NS_DECL_NSIDOMHTMLTABLECAPTIONELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -34,17 +34,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTableCellElement
   NS_DECL_NSIDOMHTMLTABLECELLELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLTableColElement.cpp
+++ b/content/html/content/src/nsHTMLTableColElement.cpp
@@ -32,17 +32,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTableColElement
   NS_DECL_NSIDOMHTMLTABLECOLELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLTableElement.h
+++ b/content/html/content/src/nsHTMLTableElement.h
@@ -23,17 +23,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTableElement
   NS_DECL_NSIDOMHTMLTABLEELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -34,17 +34,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTableRowElement
   NS_DECL_NSIDOMHTMLTABLEROWELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -33,17 +33,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTableSectionElement
   NS_DECL_NSIDOMHTMLTABLESECTIONELEMENT
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                               nsIAtom* aAttribute,
                               const nsAString& aValue,
                               nsAttrValue& aResult);
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -72,18 +72,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFormElement::)
   virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
 
   // nsIDOMHTMLTextAreaElement
   NS_DECL_NSIDOMHTMLTEXTAREAELEMENT
 
   // nsIDOMNSEditableElement
   NS_IMETHOD GetEditor(nsIEditor** aEditor)
   {
--- a/content/html/content/src/nsHTMLTitleElement.cpp
+++ b/content/html/content/src/nsHTMLTitleElement.cpp
@@ -26,17 +26,17 @@ public:
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
 
   // nsIDOMElement
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
 
   // nsIDOMHTMLTitleElement
   NS_DECL_NSIDOMHTMLTITLEELEMENT
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
--- a/content/html/content/src/nsHTMLUnknownElement.cpp
+++ b/content/html/content/src/nsHTMLUnknownElement.cpp
@@ -1,19 +1,59 @@
 /* -*- Mode: C++; 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 "nsHTMLUnknownElement.h"
+#include "nsGenericHTMLElement.h"
+#include "nsIDOMHTMLUnknownElement.h"
+
+class nsHTMLUnknownElement : public nsGenericHTMLElement
+                           , public nsIDOMHTMLUnknownElement
+{
+public:
+  nsHTMLUnknownElement(already_AddRefed<nsINodeInfo> aNodeInfo);
+  virtual ~nsHTMLUnknownElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE_TO_NSINODE
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
+
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+
+  virtual nsXPCClassInfo* GetClassInfo();
+
+  virtual nsIDOMNode* AsDOMNode() { return this; }
+};
+
+
+NS_IMPL_NS_NEW_HTML_ELEMENT(Unknown)
+
+
+nsHTMLUnknownElement::nsHTMLUnknownElement(already_AddRefed<nsINodeInfo> aNodeInfo)
+  : nsGenericHTMLElement(aNodeInfo)
+{
+}
+
+nsHTMLUnknownElement::~nsHTMLUnknownElement()
+{
+}
+
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLUnknownElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLUnknownElement, nsGenericElement)
 
-NS_IMPL_NS_NEW_HTML_ELEMENT(Unknown)
 
 DOMCI_NODE_DATA(HTMLUnknownElement, nsHTMLUnknownElement)
 
 // QueryInterface implementation for nsHTMLUnknownElement
 NS_INTERFACE_TABLE_HEAD(nsHTMLUnknownElement)
   NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLUnknownElement,
                                    nsIDOMHTMLUnknownElement)
   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLUnknownElement,
deleted file mode 100644
--- a/content/html/content/src/nsHTMLUnknownElement.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; 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/. */
-#ifndef nsHTMLUnknownElement_h___
-#define nsHTMLUnknownElement_h___
-
-#include "nsGenericHTMLElement.h"
-#include "nsIDOMHTMLUnknownElement.h"
-
-class nsHTMLUnknownElement : public nsGenericHTMLElement
-                           , public nsIDOMHTMLUnknownElement
-{
-public:
-  nsHTMLUnknownElement(already_AddRefed<nsINodeInfo> aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
-  {
-  }
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE_TO_NSINODE
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-  virtual nsXPCClassInfo* GetClassInfo();
-
-  virtual nsIDOMNode* AsDOMNode() { return this; }
-};
-
-#endif /* nsHTMLUnknownElement_h___ */
--- a/content/svg/content/src/nsSVGStylableElement.h
+++ b/content/svg/content/src/nsSVGStylableElement.h
@@ -22,17 +22,17 @@ protected:
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIDOMSVGSTYLABLE
 
   // nsIContent
   virtual const nsAttrValue* DoGetClasses() const;
 
-  nsICSSDeclaration* GetStyle(nsresult* retval)
+  nsIDOMCSSStyleDeclaration* GetStyle(nsresult* retval)
   {
     return nsSVGStylableElementBase::GetStyle(retval);
   }
   virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute,
                               const nsAString& aValue, nsAttrValue& aResult);
   virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
                              bool aNotify);
 
--- a/dom/interfaces/html/nsIDOMHTMLElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLElement.idl
@@ -46,29 +46,30 @@ interface nsIDOMHTMLElement : nsIDOMElem
    * Indicates that the element is not yet, or is no longer, relevant.
    *
    * See <http://www.whatwg.org/html5/#the-hidden-attribute>.
    */
            attribute boolean          hidden;
   [binaryname(DOMClick)]
   void click();
            attribute long             tabIndex;
+  [binaryname(DOMFocus)]
   void focus();
-  [binaryname(DOMBlur)]
   void blur();
            attribute DOMString        accessKey;
   readonly attribute DOMString        accessKeyLabel;
            attribute boolean          draggable;
            attribute DOMString        contentEditable;
   readonly attribute boolean          isContentEditable;
   readonly attribute nsIDOMHTMLMenuElement contextMenu;
            attribute boolean          spellcheck;
 
 
   // DOM Parsing and Serialization
+  [binaryname(DOMInnerHTML)]
            attribute DOMString        innerHTML;
            attribute DOMString        outerHTML;
   void insertAdjacentHTML(in DOMString position,
                           in DOMString text);
 
 
   // CSSOM View
   [optional_argc] void scrollIntoView([optional] in boolean top);
deleted file mode 100644
--- a/dom/webidl/HTMLDivElement.webidl
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is
- * http://www.whatwg.org/specs/web-apps/current-work/
- *
- * © 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 HTMLDivElement : HTMLElement {/*};
-
-partial interface HTMLDivElement {
-*/
-  [SetterThrows]
-           attribute DOMString align;
-};
deleted file mode 100644
--- a/dom/webidl/HTMLElement.webidl
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is
- * http://www.whatwg.org/specs/web-apps/current-work/ and
- * http://dev.w3.org/csswg/cssom-view/
- *
- * © 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;
-
-interface HTMLElement : Element {
-  // metadata attributes
-           attribute DOMString title;
-           attribute DOMString lang;
-  //         attribute boolean translate;
-  [SetterThrows]
-           attribute DOMString dir;
-  readonly attribute DOMStringMap dataset;
-
-  // microdata 
-  [SetterThrows]
-           attribute boolean itemScope;
-  [PutForwards=value] readonly attribute DOMSettableTokenList itemType;
-  [SetterThrows]
-           attribute DOMString itemId;
-  [PutForwards=value] readonly attribute DOMSettableTokenList itemRef;
-  [PutForwards=value] readonly attribute DOMSettableTokenList itemProp;
-  readonly attribute HTMLPropertiesCollection properties;
-  [Throws]
-           attribute any itemValue;
-
-  // user interaction
-  [SetterThrows]
-           attribute boolean hidden;
-  void click();
-  [SetterThrows]
-           attribute long tabIndex;
-  [Throws]
-  void focus();
-  [Throws]
-  void blur();
-  [SetterThrows]
-           attribute DOMString accessKey;
-  readonly attribute DOMString accessKeyLabel;
-  [SetterThrows]
-           attribute boolean draggable;
-  //[PutForwards=value] readonly attribute DOMSettableTokenList dropzone;
-  [SetterThrows]
-           attribute DOMString contentEditable;
-  readonly attribute boolean isContentEditable;
-  readonly attribute HTMLMenuElement? contextMenu;
-  //[SetterThrows]
-  //         attribute HTMLMenuElement? contextMenu;
-  [SetterThrows]
-           attribute boolean spellcheck;
-
-  // command API
-  //readonly attribute DOMString? commandType;
-  //readonly attribute DOMString? commandLabel;
-  //readonly attribute DOMString? commandIcon;
-  //readonly attribute boolean? commandHidden;
-  //readonly attribute boolean? commandDisabled;
-  //readonly attribute boolean? commandChecked;
-
-  // styling
-  [Throws]
-  readonly attribute CSSStyleDeclaration style;
-
-  // event handler IDL attributes
-  [SetterThrows]
-           attribute EventHandler onabort;
-  [SetterThrows]
-           attribute EventHandler onblur;
-  //[SetterThrows]
-  //         attribute EventHandler oncancel;
-  [SetterThrows]
-           attribute EventHandler oncanplay;
-  [SetterThrows]
-           attribute EventHandler oncanplaythrough;
-  [SetterThrows]
-           attribute EventHandler onchange;
-  [SetterThrows]
-           attribute EventHandler onclick;
-  //[SetterThrows]
-  //         attribute EventHandler onclose;
-  [SetterThrows]
-           attribute EventHandler oncontextmenu;
-  //[SetterThrows]
-  //         attribute EventHandler oncuechange;
-  [SetterThrows]
-           attribute EventHandler ondblclick;
-  [SetterThrows]
-           attribute EventHandler ondrag;
-  [SetterThrows]
-           attribute EventHandler ondragend;
-  [SetterThrows]
-           attribute EventHandler ondragenter;
-  [SetterThrows]
-           attribute EventHandler ondragleave;
-  [SetterThrows]
-           attribute EventHandler ondragover;
-  [SetterThrows]
-           attribute EventHandler ondragstart;
-  [SetterThrows]
-           attribute EventHandler ondrop;
-  [SetterThrows]
-           attribute EventHandler ondurationchange;
-  [SetterThrows]
-           attribute EventHandler onemptied;
-  [SetterThrows]
-           attribute EventHandler onended;
-  // We think the spec is wrong here.
-  //         attribute OnErrorEventHandler onerror;
-  [SetterThrows]
-           attribute EventHandler onerror;
-  [SetterThrows]
-           attribute EventHandler onfocus;
-  [SetterThrows]
-           attribute EventHandler oninput;
-  [SetterThrows]
-           attribute EventHandler oninvalid;
-  [SetterThrows]
-           attribute EventHandler onkeydown;
-  [SetterThrows]
-           attribute EventHandler onkeypress;
-  [SetterThrows]
-           attribute EventHandler onkeyup;
-  [SetterThrows]
-           attribute EventHandler onload;
-  [SetterThrows]
-           attribute EventHandler onloadeddata;
-  [SetterThrows]
-           attribute EventHandler onloadedmetadata;
-  [SetterThrows]
-           attribute EventHandler onloadstart;
-  [SetterThrows]
-           attribute EventHandler onmousedown;
-  [SetterThrows]
-           attribute EventHandler onmousemove;
-  [SetterThrows]
-           attribute EventHandler onmouseout;
-  [SetterThrows]
-           attribute EventHandler onmouseover;
-  [SetterThrows]
-           attribute EventHandler onmouseup;
-  //[SetterThrows]
-  //         attribute EventHandler onmousewheel;
-  [SetterThrows]
-           attribute EventHandler onpause;
-  [SetterThrows]
-           attribute EventHandler onplay;
-  [SetterThrows]
-           attribute EventHandler onplaying;
-  [SetterThrows]
-           attribute EventHandler onprogress;
-  [SetterThrows]
-           attribute EventHandler onratechange;
-  [SetterThrows]
-           attribute EventHandler onreset;
-  [SetterThrows]
-           attribute EventHandler onscroll;
-  [SetterThrows]
-           attribute EventHandler onseeked;
-  [SetterThrows]
-           attribute EventHandler onseeking;
-  [SetterThrows]
-           attribute EventHandler onselect;
-  [SetterThrows]
-           attribute EventHandler onshow;
-  [SetterThrows]
-           attribute EventHandler onstalled;
-  [SetterThrows]
-           attribute EventHandler onsubmit;
-  [SetterThrows]
-           attribute EventHandler onsuspend;
-  [SetterThrows]
-           attribute EventHandler ontimeupdate;
-  [SetterThrows]
-           attribute EventHandler onvolumechange;
-  [SetterThrows]
-           attribute EventHandler onwaiting;
-
-  [SetterThrows]
-           attribute EventHandler onmozfullscreenchange;
-  [SetterThrows]
-           attribute EventHandler onmozfullscreenerror;
-  [SetterThrows]
-           attribute EventHandler onmozpointerlockchange;
-  [SetterThrows]
-           attribute EventHandler onmozpointerlockerror;
-
-  // Mozilla specific stuff
-  // FIXME Bug 810677 Move className from HTMLElement to Element
-           attribute DOMString className;
-
-  [SetterThrows,LenientThis]
-           attribute EventHandler onmouseenter;
-  [SetterThrows,LenientThis]
-           attribute EventHandler onmouseleave;
-  [SetterThrows]
-           attribute EventHandler onwheel;
-
-  [SetterThrows,Pref="dom.w3c_touch_events.enabled"]
-           attribute EventHandler ontouchstart;
-  [SetterThrows,Pref="dom.w3c_touch_events.enabled"]
-           attribute EventHandler ontouchend;
-  [SetterThrows,Pref="dom.w3c_touch_events.enabled"]
-           attribute EventHandler ontouchmove;
-  [SetterThrows,Pref="dom.w3c_touch_events.enabled"]
-           attribute EventHandler ontouchenter;
-  [SetterThrows,Pref="dom.w3c_touch_events.enabled"]
-           attribute EventHandler ontouchleave;
-  [SetterThrows,Pref="dom.w3c_touch_events.enabled"]
-           attribute EventHandler ontouchcancel;
-
-  [SetterThrows]
-           attribute EventHandler oncopy;
-  [SetterThrows]
-           attribute EventHandler oncut;
-  [SetterThrows]
-           attribute EventHandler onpaste;
-
-  // FIXME Bug 811701 Move innerHTML/outerHTML/insertAdjacentHTML from
-  //                  HTMLElement to Element
-  [Throws,TreatNullAs=EmptyString]
-  attribute DOMString innerHTML;
-  [Throws,TreatNullAs=EmptyString]
-  attribute DOMString outerHTML;
-  [Throws]
-  void insertAdjacentHTML(DOMString position, DOMString text);
-/*
-};
-
-// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-htmlelement-interface
-partial interface HTMLElement {
-*/
-  readonly attribute Element? offsetParent;
-  readonly attribute long offsetTop;
-  readonly attribute long offsetLeft;
-  readonly attribute long offsetWidth;
-  readonly attribute long offsetHeight;
-};
-
-interface HTMLUnknownElement : HTMLElement {};
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -475,20 +475,17 @@ customIncludes = [
     'nsDocument.h',
     'nsDOMTokenList.h',
     'nsGenericDOMDataNode.h',
     'nsGenericElement.h',
     'nsGenericHTMLElement.h',
     'nsSVGStylableElement.h',
     'nsHTMLDocument.h',
     'nsDOMQS.h',
-    'nsDOMStringMap.h',
-    'HTMLPropertiesCollection.h',
-    'nsHTMLMenuElement.h',
-    'nsICSSDeclaration.h'
+    'nsDOMStringMap.h'
     ]
 
 customReturnInterfaces = [
     'nsIDOMCanvasPattern',
     'nsIDOMCanvasGradient',
     ]
 
 nsIDOMNode_GetChildNodes_customMethodCallCode = """
@@ -831,17 +828,17 @@ customMethodCalls = {
         'canFail': False
         },
     'nsIDOMHTMLElement_SetTabIndex': {
         'thisType' : 'nsGenericHTMLElement',
         'code': '    mozilla::ErrorResult error;\n'
                 '    self->SetTabIndex(arg0, error);\n'
                 '    rv = error.ErrorCode();'
         },
-    'nsIDOMHTMLElement_Focus': {
+    'nsIDOMHTMLElement_DOMFocus': {
         'thisType' : 'nsGenericHTMLElement',
         'code': '    mozilla::ErrorResult error;\n'
                 '    self->Focus(error);\n'
                 '    rv = error.ErrorCode();'
         },
     'nsIDOMHTMLElement_GetDraggable': {
         'thisType' : 'nsGenericHTMLElement',
         'code': '    bool result = self->Draggable();',
@@ -877,17 +874,17 @@ customMethodCalls = {
                 '       don\'t actually implement GetStyle. */\n'
                 '    if (self->GetNameSpaceID() == kNameSpaceID_MathML)\n'
                 '      return xpc_qsThrow(cx, NS_ERROR_XPC_BAD_CONVERT_JS);\n'
                 '    nsIDOMCSSStyleDeclaration* result = '
                 'self->GetStyle(&rv);'
         },
     'nsIDOMSVGStylable_GetStyle': {
         'thisType': 'nsSVGStylableElement',
-        'code': '    nsICSSDeclaration* result = '
+        'code': '    nsIDOMCSSStyleDeclaration* result = '
                 'self->GetStyle(&rv);'
         },
     'nsIDOMDocument_': {
         'thisType': 'nsDocument'
         },
     'nsIDOMDocument_GetElementById': {
         'thisType': 'nsDocument',
         'code': '    mozilla::dom::Element *result = self->GetElementById(arg0);',
@@ -1035,178 +1032,16 @@ customMethodCalls = {
         'code': '    uint32_t result = self->ChildElementCount();',
         'canFail': False
         },
     'nsIDOMElement_GetChildElements' : {
         'thisType' : 'nsGenericElement',
         'code': '    nsIHTMLCollection* result = self->Children();',
         'canFail': False
         },
-    'nsIDOMHTMLElement_GetTitle': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetTitle': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetLang': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetLang': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetDir': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetDir': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetDir(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetItemScope': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    bool result = self->ItemScope();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetItemScope': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetItemScope(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetItemId': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetItemId': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetItemId(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetProperties': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    nsIDOMHTMLPropertiesCollection* result = self->Properties();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetHidden': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    bool result = self->Hidden();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetHidden': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetHidden(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetId': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetId': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetAccessKey': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetAccessKey': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetAccessKey(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetAccessKeyLabel': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetSpellcheck': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    bool result = self->Spellcheck();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetSpellcheck': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetSpellcheck(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetOuterHTML': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    nsString result;\n'
-                '    mozilla::ErrorResult error;\n'
-                '    self->GetOuterHTML(result, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_SetOuterHTML': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetOuterHTML(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetContentEditable': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetContentEditable': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::ErrorResult error;\n'
-                '    self->SetContentEditable(arg0, error);\n'
-                '    rv = error.ErrorCode();'
-        },
-    'nsIDOMHTMLElement_GetIsContentEditable': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    bool result = self->IsContentEditable();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetContextMenu': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    mozilla::dom::Element* result = self->GetContextMenu();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetOffsetParent': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    nsGenericElement* result = self->GetOffsetParent();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetOffsetTop': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    uint32_t result = self->OffsetTop();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetOffsetLeft': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    uint32_t result = self->OffsetLeft();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetOffsetWidth': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    uint32_t result = self->OffsetWidth();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetOffsetHeight': {
-        'thisType' : 'nsGenericHTMLElement',
-        'code': '    uint32_t result = self->OffsetHeight();',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_GetClassName': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
-    'nsIDOMHTMLElement_SetClassName': {
-        'thisType' : 'nsGenericHTMLElement',
-        'canFail': False
-        },
     'nsIDOMWindow_GetOnmouseenter' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
     'nsIDOMWindow_SetOnmouseenter' : {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
--- a/js/xpconnect/src/nsDOMQS.h
+++ b/js/xpconnect/src/nsDOMQS.h
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMQS_h__
 #define nsDOMQS_h__
 
 #include "nsDOMClassInfoID.h"
 #include "nsGenericHTMLElement.h"
 #include "nsHTMLCanvasElement.h"
-#include "nsHTMLDivElement.h"
 #include "nsHTMLImageElement.h"
 #include "nsHTMLOptionElement.h"
 #include "nsHTMLOptGroupElement.h"
 #include "nsHTMLVideoElement.h"
 #include "nsHTMLDocument.h"
 #include "nsICSSDeclaration.h"
 #include "nsSVGStylableElement.h"
 
@@ -150,17 +149,16 @@ xpc_qsUnwrapArg<_clazz>(JSContext *cx, j
 {                                                                             \
     nsISupports* argRef = static_cast<nsIContent*>(*ppArgRef);                \
     nsresult rv = xpc_qsUnwrapArg<_clazz>(cx, v, ppArg, &argRef, vp);         \
     *ppArgRef = static_cast<_clazz*>(static_cast<nsIContent*>(argRef));       \
     return rv;                                                                \
 }
 
 DEFINE_UNWRAP_CAST_HTML(canvas, nsHTMLCanvasElement)
-DEFINE_UNWRAP_CAST_HTML(div, nsHTMLDivElement)
 DEFINE_UNWRAP_CAST_HTML(img, nsHTMLImageElement)
 DEFINE_UNWRAP_CAST_HTML(optgroup, nsHTMLOptGroupElement)
 DEFINE_UNWRAP_CAST_HTML(option, nsHTMLOptionElement)
 DEFINE_UNWRAP_CAST_HTML(video, nsHTMLVideoElement)
 
 inline nsISupports*
 ToSupports(nsContentList *p)
 {