Bug 1519948, remove XUL box objects, r=bzbarsky
authorNeil Deakin <neil@mozilla.com>
Tue, 04 Jun 2019 12:45:55 -0400
changeset 476799 b915069eda81e654c2d40894acd0f9425f3627d3
parent 476798 b7b4ce10f4ee1dee68e1dad105648d6e132af1a6
child 476800 49fbf60f938d1db98987aef215ce819a3b90690f
push id113313
push userneil@mozilla.com
push dateTue, 04 Jun 2019 17:41:35 +0000
treeherdermozilla-inbound@b915069eda81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1519948
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519948, remove XUL box objects, r=bzbarsky
dom/base/Document.cpp
dom/base/Document.h
dom/base/Element.cpp
dom/base/FragmentOrElement.cpp
dom/base/nsINode.cpp
dom/base/nsNodeUtils.cpp
dom/canvas/test/webgl-conf/checkout/deqp/temp_externs/gecko_dom.js
dom/chrome-webidl/XULTreeElement.webidl
dom/webidl/BoxObject.webidl
dom/webidl/Document.webidl
dom/webidl/XULElement.webidl
dom/webidl/moz.build
dom/xul/XULDocument.cpp
dom/xul/nsXULElement.cpp
dom/xul/nsXULElement.h
layout/base/nsCSSFrameConstructor.cpp
layout/xul/BoxObject.cpp
layout/xul/BoxObject.h
layout/xul/moz.build
layout/xul/nsIBoxObject.idl
layout/xul/nsPIBoxObject.h
layout/xul/tree/nsTreeColumns.cpp
layout/xul/tree/nsTreeSelection.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -293,17 +293,16 @@
 #  include "mozilla/dom/XULPersist.h"
 #  include "nsIXULWindow.h"
 #  include "nsIChromeRegistry.h"
 #  include "nsXULPrototypeDocument.h"
 #  include "nsXULCommandDispatcher.h"
 #  include "nsXULPopupManager.h"
 #  include "nsIDocShellTreeOwner.h"
 #endif
-#include "mozilla/dom/BoxObject.h"
 
 #include "mozilla/DocLoadingTimelineMarker.h"
 
 #include "mozilla/dom/WindowGlobalChild.h"
 
 #include "nsISpeculativeConnect.h"
 
 #include "mozilla/MediaManager.h"
@@ -1242,17 +1241,16 @@ Document::Document(const char* aContentT
       mSSApplicableStateNotificationPending(false),
       mMayHaveTitleElement(false),
       mDOMLoadingSet(false),
       mDOMInteractiveSet(false),
       mDOMCompleteSet(false),
       mAutoFocusFired(false),
       mScrolledToRefAlready(false),
       mChangeScrollPosWhenScrollingToRef(false),
-      mHasWarnedAboutBoxObjects(false),
       mDelayFrameLoaderInitialization(false),
       mSynchronousDOMContentLoaded(false),
       mMaybeServiceWorkerControlled(false),
       mAllowZoom(false),
       mValidScaleFloat(false),
       mValidMinScale(false),
       mValidMaxScale(false),
       mWidthStrEmpty(false),
@@ -1310,17 +1308,16 @@ Document::Document(const char* aContentT
       mStackRefCnt(0),
       mUpdateNestLevel(0),
       mViewportType(Unknown),
       mSubDocuments(nullptr),
       mHeaderData(nullptr),
       mFlashClassification(FlashClassification::Unknown),
       mScrollAnchorAdjustmentLength(0),
       mScrollAnchorAdjustmentCount(0),
-      mBoxObjectTable(nullptr),
       mCurrentOrientationAngle(0),
       mCurrentOrientationType(OrientationType::Portrait_primary),
       mServoRestyleRootDirtyBits(0),
       mThrowOnDynamicMarkupInsertionCounter(0),
       mIgnoreOpensDuringUnloadCounter(0),
       mDocLWTheme(Doc_Theme_Uninitialized),
       mSavedResolution(1.0f),
       mPendingInitialTranslation(false),
@@ -1466,29 +1463,16 @@ void Document::GetFailedCertSecurityInfo
   rv = cert->GetSubjectAltNames(subjectAltNames);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(rv);
     return;
   }
   aInfo.mSubjectAltNames = subjectAltNames;
 }
 
-void Document::ClearAllBoxObjects() {
-  if (mBoxObjectTable) {
-    for (auto iter = mBoxObjectTable->Iter(); !iter.Done(); iter.Next()) {
-      nsPIBoxObject* boxObject = iter.UserData();
-      if (boxObject) {
-        boxObject->Clear();
-      }
-    }
-    delete mBoxObjectTable;
-    mBoxObjectTable = nullptr;
-  }
-}
-
 bool Document::IsAboutPage() const {
   nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
   nsCOMPtr<nsIURI> uri;
   principal->GetURI(getter_AddRefs(uri));
   bool isAboutScheme = true;
   if (uri) {
     uri->SchemeIs("about", &isAboutScheme);
   }
@@ -1674,18 +1658,16 @@ Document::~Document() {
   }
 
   if (mXULPersist) {
     mXULPersist->DropDocumentReference();
   }
 
   delete mHeaderData;
 
-  ClearAllBoxObjects();
-
   mPendingTitleChangeEvent.Revoke();
 
   mPlugins.Clear();
 
   MOZ_ASSERT(mDOMMediaQueryLists.isEmpty(),
              "must not have media query lists left");
 
   if (mNodeInfoManager) {
@@ -1812,25 +1794,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParser)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScriptGlobalObject)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListenerManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheetSetList)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScriptLoader)
 
   DocumentOrShadowRoot::Traverse(tmp, cb);
 
-  // The boxobject for an element will only exist as long as it's in the
-  // document, so we'll traverse the table here instead of from the element.
-  if (tmp->mBoxObjectTable) {
-    for (auto iter = tmp->mBoxObjectTable->Iter(); !iter.Done(); iter.Next()) {
-      NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mBoxObjectTable entry");
-      cb.NoteXPCOMChild(iter.UserData());
-    }
-  }
-
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChannel)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLayoutHistoryState)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnloadBlocker)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDOMImplementation)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImageMaps)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOrientationPendingPromise)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOriginalDocument)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCachedEncoder)
@@ -1951,18 +1924,16 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Do
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mMidasCommandManager)
 
   tmp->mParentDocument = nullptr;
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPreloadingImages)
 
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mIntersectionObservers)
 
-  tmp->ClearAllBoxObjects();
-
   if (tmp->mListenerManager) {
     tmp->mListenerManager->Disconnect();
     tmp->UnsetFlags(NODE_HAS_LISTENERMANAGER);
     tmp->mListenerManager = nullptr;
   }
 
   if (tmp->mStyleSheetSetList) {
     tmp->mStyleSheetSetList->Disconnect();
@@ -7691,65 +7662,16 @@ void Document::DoNotifyPossibleTitleChan
   }
 
   // Fire a DOM event for the title change.
   nsContentUtils::DispatchChromeEvent(this, ToSupports(this),
                                       NS_LITERAL_STRING("DOMTitleChanged"),
                                       CanBubble::eYes, Cancelable::eYes);
 }
 
-already_AddRefed<BoxObject> Document::GetBoxObjectFor(Element* aElement,
-                                                      ErrorResult& aRv) {
-  if (!aElement) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
-  Document* doc = aElement->OwnerDoc();
-  if (doc != this) {
-    aRv.Throw(NS_ERROR_DOM_WRONG_DOCUMENT_ERR);
-    return nullptr;
-  }
-
-  if (!mHasWarnedAboutBoxObjects && !aElement->IsXULElement()) {
-    mHasWarnedAboutBoxObjects = true;
-    nsContentUtils::ReportToConsole(
-        nsIScriptError::warningFlag, NS_LITERAL_CSTRING("BoxObjects"), this,
-        nsContentUtils::eDOM_PROPERTIES, "UseOfGetBoxObjectForWarning");
-  }
-
-  if (!mBoxObjectTable) {
-    mBoxObjectTable =
-        new nsRefPtrHashtable<nsPtrHashKey<nsIContent>, BoxObject>(6);
-  }
-
-  RefPtr<BoxObject> boxObject;
-  auto entry = mBoxObjectTable->LookupForAdd(aElement);
-  if (entry) {
-    boxObject = entry.Data();
-    return boxObject.forget();
-  }
-
-  boxObject = new BoxObject();
-  boxObject->Init(aElement);
-  entry.OrInsert([&boxObject]() { return boxObject; });
-
-  return boxObject.forget();
-}
-
-void Document::ClearBoxObjectFor(nsIContent* aContent) {
-  if (mBoxObjectTable) {
-    if (auto entry = mBoxObjectTable->Lookup(aContent)) {
-      nsPIBoxObject* boxObject = entry.Data();
-      boxObject->Clear();
-      entry.Remove();
-    }
-  }
-}
-
 already_AddRefed<MediaQueryList> Document::MatchMedia(
     const nsAString& aMediaQueryList, CallerType aCallerType) {
   RefPtr<MediaQueryList> result =
       new MediaQueryList(this, aMediaQueryList, aCallerType);
 
   mDOMMediaQueryLists.insertBack(result);
 
   return result.forget();
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -154,17 +154,16 @@ class Loader;
 class ImageLoader;
 class Rule;
 }  // namespace css
 
 namespace dom {
 class Animation;
 class AnonymousContent;
 class Attr;
-class BoxObject;
 class XULBroadcastManager;
 class XULPersist;
 class ClientInfo;
 class ClientState;
 class CDATASection;
 class Comment;
 struct CustomElementDefinition;
 class DocGroup;
@@ -1618,18 +1617,16 @@ class Document : public nsINode,
   nsresult InitCSP(nsIChannel* aChannel);
 
   nsresult InitFeaturePolicy(nsIChannel* aChannel);
 
   void PostUnblockOnloadEvent();
 
   void DoUnblockOnload();
 
-  void ClearAllBoxObjects();
-
   void MaybeEndOutermostXBLUpdate();
 
   void RetrieveRelevantHeaders(nsIChannel* aChannel);
 
   void TryChannelCharset(nsIChannel* aChannel, int32_t& aCharsetSource,
                          NotNull<const Encoding*>& aEncoding,
                          nsHtml5TreeOpExecutor* aExecutor);
 
@@ -2528,30 +2525,16 @@ class Document : public nsINode,
 #endif
     mStyledLinks.RemoveEntry(aLink);
   }
 
   // Refreshes the hrefs of all the links in the document.
   void RefreshLinkHrefs();
 
   /**
-   * Resets and removes a box object from the document's box object cache
-   *
-   * @param aElement canonical nsIContent pointer of the box object's element
-   */
-  void ClearBoxObjectFor(nsIContent* aContent);
-
-  /**
-   * Get the box object for an element. This is not exposed through a
-   * scriptable interface except for XUL documents.
-   */
-  already_AddRefed<BoxObject> GetBoxObjectFor(Element* aElement,
-                                              ErrorResult& aRv);
-
-  /**
    * Support for window.matchMedia()
    */
 
   already_AddRefed<MediaQueryList> MatchMedia(const nsAString& aMediaQueryList,
                                               CallerType aCallerType);
 
   LinkedList<MediaQueryList>& MediaQueryLists() { return mDOMMediaQueryLists; }
 
@@ -4478,18 +4461,16 @@ class Document : public nsINode,
   bool mDOMLoadingSet : 1;
   bool mDOMInteractiveSet : 1;
   bool mDOMCompleteSet : 1;
   bool mAutoFocusFired : 1;
 
   bool mScrolledToRefAlready : 1;
   bool mChangeScrollPosWhenScrollingToRef : 1;
 
-  bool mHasWarnedAboutBoxObjects : 1;
-
   bool mDelayFrameLoaderInitialization : 1;
 
   bool mSynchronousDOMContentLoaded : 1;
 
   // Set to true when the document is possibly controlled by the ServiceWorker.
   // Used to prevent multiple requests to ServiceWorkerManager.
   bool mMaybeServiceWorkerControlled : 1;
 
@@ -4874,18 +4855,16 @@ class Document : public nsINode,
   // Tracking for plugins in the document.
   nsTHashtable<nsPtrHashKey<nsIObjectLoadingContent>> mPlugins;
 
   RefPtr<DocumentTimeline> mDocumentTimeline;
   LinkedList<DocumentTimeline> mTimelines;
 
   RefPtr<dom::ScriptLoader> mScriptLoader;
 
-  nsRefPtrHashtable<nsPtrHashKey<nsIContent>, BoxObject>* mBoxObjectTable;
-
   // Tracker for animations that are waiting to start.
   // nullptr until GetOrCreatePendingAnimationTracker is called.
   RefPtr<PendingAnimationTracker> mPendingAnimationTracker;
 
   // A document "without a browsing context" that owns the content of
   // HTMLTemplateElement.
   RefPtr<Document> mTemplateContentsOwner;
 
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -89,17 +89,16 @@
 #include "nsFrameSelection.h"
 #ifdef DEBUG
 #  include "nsRange.h"
 #endif
 
 #include "nsBindingManager.h"
 #include "nsXBLBinding.h"
 #include "nsPIDOMWindow.h"
-#include "nsPIBoxObject.h"
 #include "mozilla/dom/DOMRect.h"
 #include "nsSVGUtils.h"
 #include "nsLayoutUtils.h"
 #include "nsGkAtoms.h"
 #include "ChildIterator.h"
 
 #include "nsIDOMEventListener.h"
 #include "nsIWebNavigation.h"
@@ -1937,18 +1936,16 @@ void Element::UnbindFromTree(bool aNullP
           document->BindingManager()->GetBindingWithContent(this);
       if (binding) {
         nsXBLBinding::UnbindAnonymousContent(document,
                                              binding->GetAnonymousContent(),
                                              /* aNullParent */ false);
       }
     }
 
-    document->ClearBoxObjectFor(this);
-
     // Disconnected must be enqueued whenever a connected custom element becomes
     // disconnected.
     CustomElementData* data = GetCustomElementData();
     if (data) {
       if (data->mState == CustomElementData::State::eCustom) {
         nsContentUtils::EnqueueLifecycleCallback(Document::eDisconnected, this);
       } else {
         // Remove an unresolved custom element that is a candidate for upgrade
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -70,17 +70,16 @@
 #ifdef DEBUG
 #  include "nsRange.h"
 #endif
 
 #include "nsBindingManager.h"
 #include "nsFrameLoader.h"
 #include "nsXBLBinding.h"
 #include "nsPIDOMWindow.h"
-#include "nsPIBoxObject.h"
 #include "nsSVGUtils.h"
 #include "nsLayoutUtils.h"
 #include "nsGkAtoms.h"
 #include "nsContentUtils.h"
 #include "nsTextFragment.h"
 #include "nsContentCID.h"
 #include "nsWindowSizes.h"
 
@@ -1168,17 +1167,16 @@ void FragmentOrElement::DestroyContent()
   if (IsElement()) {
     AsElement()->ClearServoData();
   }
 
   Document* document = OwnerDoc();
 
   document->BindingManager()->RemovedFromDocument(this, document,
                                                   nsBindingManager::eRunDtor);
-  document->ClearBoxObjectFor(this);
 
 #ifdef DEBUG
   uint32_t oldChildCount = GetChildCount();
 #endif
 
   for (nsIContent* child = GetFirstChild(); child;
        child = child->GetNextSibling()) {
     child->DestroyContent();
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -79,17 +79,16 @@
 #include "nsView.h"
 #include "nsViewManager.h"
 #include "nsIWebNavigation.h"
 #include "nsIWidget.h"
 #include "nsLayoutUtils.h"
 #include "nsNameSpaceManager.h"
 #include "nsNodeInfoManager.h"
 #include "nsNodeUtils.h"
-#include "nsPIBoxObject.h"
 #include "nsPIDOMWindow.h"
 #include "nsPresContext.h"
 #include "nsString.h"
 #include "nsStyleConsts.h"
 #include "nsSVGUtils.h"
 #include "nsTextNode.h"
 #include "nsUnicharUtils.h"
 #include "nsXBLBinding.h"
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -315,20 +315,18 @@ void nsNodeUtils::LastRelease(nsINode* a
       }
     }
 #endif
 
     nsContentUtils::RemoveListenerManager(aNode);
     aNode->UnsetFlags(NODE_HAS_LISTENERMANAGER);
   }
 
-  if (Element* element = Element::FromNode(aNode)) {
-    element->OwnerDoc()->ClearBoxObjectFor(element);
-    NS_ASSERTION(!element->GetXBLBinding(), "Node has binding on destruction");
-  }
+  NS_ASSERTION(!Element::FromNode(aNode) ||
+               !Element::FromNode(aNode)->GetXBLBinding(), "Node has binding on destruction");
 
   aNode->ReleaseWrapper(aNode);
 
   FragmentOrElement::RemoveBlackMarkedNode(aNode);
 }
 
 /* static */
 already_AddRefed<nsINode> nsNodeUtils::CloneNodeImpl(nsINode* aNode, bool aDeep,
@@ -432,17 +430,16 @@ already_AddRefed<nsINode> nsNodeUtils::C
       // the cloned document (somewhat like cloning and importing them into the
       // cloned document).
       nodeInfoManager = clone->mNodeInfo->NodeInfoManager();
     }
   } else if (nodeInfoManager) {
     Document* oldDoc = aNode->OwnerDoc();
     bool wasRegistered = false;
     if (elem) {
-      oldDoc->ClearBoxObjectFor(elem);
       wasRegistered = oldDoc->UnregisterActivityObserver(elem);
     }
 
     aNode->mNodeInfo.swap(newNodeInfo);
     if (elem) {
       elem->NodeInfoChanged(oldDoc);
     }
 
--- a/dom/canvas/test/webgl-conf/checkout/deqp/temp_externs/gecko_dom.js
+++ b/dom/canvas/test/webgl-conf/checkout/deqp/temp_externs/gecko_dom.js
@@ -556,24 +556,16 @@ Document.prototype.write = function(text
  * @see https://developer.mozilla.org/en/DOM/document.writeln
  * @param {string} text
  */
 Document.prototype.writeln = function(text) {};
 
 Document.prototype.ononline;
 Document.prototype.onoffline;
 
-// XUL
-/**
- * @see http://developer.mozilla.org/en/DOM/document.getBoxObjectFor
- * @return {BoxObject}
- * @nosideeffects
- */
-Document.prototype.getBoxObjectFor = function(element) {};
-
 // From:
 // http://lxr.mozilla.org/mozilla1.8/source/dom/public/idl/range/nsIDOMNSRange.idl
 
 /**
  * @param {string} tag
  * @return {DocumentFragment}
  */
 Range.prototype.createContextualFragment;
@@ -1071,37 +1063,16 @@ Plugin.prototype.description;
 Plugin.prototype.filename;
 
 /** @type {number} */
 Plugin.prototype.length;
 
 /** @type {string} */
 Plugin.prototype.name;
 
-/** @constructor */
-function BoxObject() {}
-
-/** @type {Element} */
-BoxObject.prototype.element;
-
-/** @type {number} */
-BoxObject.prototype.screenX;
-
-/** @type {number} */
-BoxObject.prototype.screenY;
-
-/** @type {number} */
-BoxObject.prototype.x;
-
-/** @type {number} */
-BoxObject.prototype.y;
-
-/** @type {number} */
-BoxObject.prototype.width;
-
 
 /**
  * @type {number}
  * @see http://www.google.com/codesearch/p?hl=en#eksvcKKj5Ng/mozilla/dom/public/idl/html/nsIDOMNSHTMLImageElement.idl&q=naturalWidth
  */
 HTMLImageElement.prototype.naturalWidth;
 
 /**
--- a/dom/chrome-webidl/XULTreeElement.webidl
+++ b/dom/chrome-webidl/XULTreeElement.webidl
@@ -109,29 +109,29 @@ interface XULTreeElement : XULElement
   void invalidateCell(long row, TreeColumn? col);
   void invalidateRange(long startIndex, long endIndex);
 
   /**
    * A hit test that can tell you what row the mouse is over.
    * returns -1 for invalid mouse coordinates.
    *
    * The coordinate system is the client coordinate system for the
-   * document this boxObject lives in, and the units are CSS pixels.
+   * document this tree lives in, and the units are CSS pixels.
    */
   long getRowAt(long x, long y);
 
   /**
    * A hit test that can tell you what cell the mouse is over.
    * TreeCellInfo.row is the row index hit,  returns -1 for invalid mouse
    * coordinates.  TreeCellInfo.col is the column hit.
    * TreeCellInfo.childElt is the pseudoelement hit: this can have values of
    * "cell", "twisty", "image", and "text".
    *
    * The coordinate system is the client coordinate system for the
-   * document this boxObject lives in, and the units are CSS pixels.
+   * document this tree lives in, and the units are CSS pixels.
    */
   [Throws]
   TreeCellInfo getCellAt(long x, long y);
 
   /**
    * Find the coordinates of an element within a specific cell.
    */
   [Throws]
deleted file mode 100644
--- a/dom/webidl/BoxObject.webidl
+++ /dev/null
@@ -1,33 +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/.
- */
-
-[Func="IsChromeOrXBL"]
-interface BoxObject {
-  readonly attribute Element? element;
-
-  readonly attribute long x;
-  readonly attribute long y;
-  [Throws]
-  readonly attribute long screenX;
-  [Throws]
-  readonly attribute long screenY;
-  readonly attribute long width;
-  readonly attribute long height;
-
-  nsISupports? getPropertyAsSupports(DOMString propertyName);
-  void setPropertyAsSupports(DOMString propertyName, nsISupports value);
-  [Throws]
-  DOMString? getProperty(DOMString propertyName);
-  void setProperty(DOMString propertyName, DOMString propertyValue);
-  void removeProperty(DOMString propertyName);
-
-  // for stepping through content in the expanded dom with box-ordinal-group order
-  readonly attribute Element? parentBox;
-  readonly attribute Element? firstChild;
-  readonly attribute Element? lastChild;
-  readonly attribute Element? nextSibling;
-  readonly attribute Element? previousSibling;
-};
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -187,18 +187,16 @@ partial interface Document {
                 [Pref="dom.select_events.enabled"]
                 attribute EventHandler onselectionchange;
 
   /**
    * True if this document is synthetic : stand alone image, video, audio file,
    * etc.
    */
   [Func="IsChromeOrXBLOrUAWidget"] readonly attribute boolean mozSyntheticDocument;
-  [Throws, Func="IsChromeOrXBL"]
-  BoxObject? getBoxObjectFor(Element? element);
   /**
    * Returns the script element whose script is currently being processed.
    *
    * @see <https://developer.mozilla.org/en/DOM/document.currentScript>
    */
   [Pure]
   readonly attribute Element? currentScript;
   /**
--- a/dom/webidl/XULElement.webidl
+++ b/dom/webidl/XULElement.webidl
@@ -71,18 +71,16 @@ interface XULElement : Element {
   // Properties for images
   [SetterThrows]
   attribute DOMString src;
 
   attribute boolean allowEvents;
 
   [Throws, ChromeOnly]
   readonly attribute XULControllers             controllers;
-  [Throws]
-  readonly attribute BoxObject?                 boxObject;
 
   [SetterThrows]
   attribute long tabIndex;
   [Throws]
   void                      blur();
   [NeedsCallerType]
   void                      click();
   void                      doCommand();
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -395,17 +395,16 @@ WEBIDL_FILES = [
     'BarProp.webidl',
     'BaseAudioContext.webidl',
     'BaseKeyframeTypes.webidl',
     'BasicCardPayment.webidl',
     'BatteryManager.webidl',
     'BeforeUnloadEvent.webidl',
     'BiquadFilterNode.webidl',
     'Blob.webidl',
-    'BoxObject.webidl',
     'BroadcastChannel.webidl',
     'BrowserElement.webidl',
     'BrowserElementDictionaries.webidl',
     'Cache.webidl',
     'CacheStorage.webidl',
     'CancelContentJSOptions.webidl',
     'CanvasCaptureMediaStream.webidl',
     'CanvasRenderingContext2D.webidl',
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -23,33 +23,30 @@
 
 #include "mozilla/ArrayUtils.h"
 
 #include <algorithm>
 
 #include "XULDocument.h"
 
 #include "nsError.h"
-#include "nsIBoxObject.h"
 #include "nsView.h"
 #include "nsViewManager.h"
 #include "nsIContentViewer.h"
 #include "nsIStreamListener.h"
 #include "nsITimer.h"
 #include "nsDocShell.h"
 #include "nsGkAtoms.h"
 #include "nsXMLContentSink.h"
 #include "nsXULContentSink.h"
 #include "nsXULContentUtils.h"
 #include "nsIStringEnumerator.h"
 #include "nsDocElementCreatedNotificationRunner.h"
 #include "nsNetUtil.h"
 #include "nsParserCIID.h"
-#include "nsPIBoxObject.h"
-#include "mozilla/dom/BoxObject.h"
 #include "nsString.h"
 #include "nsPIDOMWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsXULElement.h"
 #include "nsXULPrototypeCache.h"
 #include "mozilla/Logging.h"
 #include "nsIFrame.h"
 #include "nsXBLService.h"
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -36,18 +36,16 @@
 #include "nsViewManager.h"
 #include "nsIWidget.h"
 #include "nsLayoutCID.h"
 #include "nsContentCID.h"
 #include "mozilla/dom/Event.h"
 #include "nsStyleConsts.h"
 #include "nsString.h"
 #include "nsXULControllers.h"
-#include "nsIBoxObject.h"
-#include "nsPIBoxObject.h"
 #include "XULDocument.h"
 #include "nsXULPopupListener.h"
 #include "nsContentUtils.h"
 #include "nsContentList.h"
 #include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "nsPIDOMWindow.h"
 #include "nsJSPrincipals.h"
@@ -76,17 +74,16 @@
 #include "nsICSSDeclaration.h"
 #include "nsLayoutUtils.h"
 #include "XULFrameElement.h"
 #include "XULMenuElement.h"
 #include "XULPopupElement.h"
 #include "XULTreeElement.h"
 
 #include "mozilla/dom/XULElementBinding.h"
-#include "mozilla/dom/BoxObject.h"
 #include "mozilla/dom/XULBroadcastManager.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/MutationEventBinding.h"
 #include "mozilla/dom/XULCommandEvent.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
@@ -1131,21 +1128,16 @@ nsIControllers* nsXULElement::GetControl
     nsExtendedDOMSlots* slots = ExtendedDOMSlots();
 
     slots->mControllers = new nsXULControllers();
   }
 
   return Controllers();
 }
 
-already_AddRefed<BoxObject> nsXULElement::GetBoxObject(ErrorResult& rv) {
-  // XXX sXBL/XBL2 issue! Owner or current document?
-  return OwnerDoc()->GetBoxObjectFor(this, rv);
-}
-
 void nsXULElement::Click(CallerType aCallerType) {
   ClickWithInputSource(MouseEvent_Binding::MOZ_SOURCE_UNKNOWN,
                        aCallerType == CallerType::System);
 }
 
 void nsXULElement::ClickWithInputSource(uint16_t aInputSource,
                                         bool aIsTrustedEvent) {
   if (BoolAttrIsTrue(nsGkAtoms::disabled)) return;
--- a/dom/xul/nsXULElement.h
+++ b/dom/xul/nsXULElement.h
@@ -41,17 +41,16 @@ typedef nsTArray<RefPtr<nsXULPrototypeNo
 
 namespace mozilla {
 class EventChainPreVisitor;
 class EventListenerManager;
 namespace css {
 class StyleRule;
 }  // namespace css
 namespace dom {
-class BoxObject;
 class HTMLIFrameElement;
 class PrototypeDocumentContentSink;
 enum class CallerType : uint32_t;
 }  // namespace dom
 }  // namespace mozilla
 
 ////////////////////////////////////////////////////////////////////////
 
@@ -505,20 +504,16 @@ class nsXULElement : public nsStyledElem
   void SetSrc(const nsAString& aValue, mozilla::ErrorResult& rv) {
     SetXULAttr(nsGkAtoms::src, aValue, rv);
   }
   bool AllowEvents() const { return BoolAttrIsTrue(nsGkAtoms::allowevents); }
   void SetAllowEvents(bool aAllowEvents) {
     SetXULBoolAttr(nsGkAtoms::allowevents, aAllowEvents);
   }
   nsIControllers* GetControllers(mozilla::ErrorResult& rv);
-  // Note: this can only fail if the do_CreateInstance for the boxobject
-  // contact fails for some reason.
-  already_AddRefed<mozilla::dom::BoxObject> GetBoxObject(
-      mozilla::ErrorResult& rv);
   void Click(mozilla::dom::CallerType aCallerType);
   MOZ_CAN_RUN_SCRIPT_BOUNDARY void DoCommand();
   // Style() inherited from nsStyledElement
 
   nsINode* GetScopeChainParent() const override {
     // For XUL, the parent is the parent element, if any
     Element* parent = GetParentElement();
     return parent ? parent : nsStyledElement::GetScopeChainParent();
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -43,17 +43,16 @@
 #include "nsTableRowFrame.h"
 #include "nsTableCellFrame.h"
 #include "nsHTMLParts.h"
 #include "nsUnicharUtils.h"
 #include "nsViewManager.h"
 #include "nsStyleConsts.h"
 #ifdef MOZ_XUL
 #  include "nsXULElement.h"
-#  include "mozilla/dom/BoxObject.h"
 #endif  // MOZ_XUL
 #include "nsContainerFrame.h"
 #include "nsNameSpaceManager.h"
 #include "nsComboboxControlFrame.h"
 #include "nsListControlFrame.h"
 #include "nsPlaceholderFrame.h"
 #include "nsTableRowGroupFrame.h"
 #include "nsIFormControl.h"
@@ -202,17 +201,16 @@ static FrameCtorDebugFlags gFlags[] = {
 
 #  define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0]))
 #endif
 
 #ifdef MOZ_XUL
 #  include "nsMenuFrame.h"
 #  include "nsPopupSetFrame.h"
 #  include "nsTreeColFrame.h"
-#  include "nsIBoxObject.h"
 #  include "nsXULLabelFrame.h"
 
 //------------------------------------------------------------------
 
 nsContainerFrame* NS_NewRootBoxFrame(PresShell* aPresShell,
                                      ComputedStyle* aStyle);
 
 nsContainerFrame* NS_NewDocElementBoxFrame(PresShell* aPresShell,
deleted file mode 100644
--- a/layout/xul/BoxObject.cpp
+++ /dev/null
@@ -1,526 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/dom/BoxObject.h"
-#include "nsCOMPtr.h"
-#include "mozilla/PresShell.h"
-#include "mozilla/dom/Document.h"
-#include "nsPresContext.h"
-#include "nsIContent.h"
-#include "nsContainerFrame.h"
-#include "nsIDocShell.h"
-#include "nsReadableUtils.h"
-#include "nsView.h"
-#include "nsLayoutUtils.h"
-#include "nsISupportsPrimitives.h"
-#include "nsSupportsPrimitives.h"
-#include "mozilla/dom/Element.h"
-#include "nsComponentManagerUtils.h"
-#include "mozilla/dom/BoxObjectBinding.h"
-
-// Implementation /////////////////////////////////////////////////////////////
-
-namespace mozilla {
-namespace dom {
-
-// Static member variable initialization
-
-// Implement our nsISupports methods
-NS_IMPL_CYCLE_COLLECTION_CLASS(BoxObject)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(BoxObject)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(BoxObject)
-
-// QueryInterface implementation for BoxObject
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BoxObject)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsIBoxObject)
-  NS_INTERFACE_MAP_ENTRY(nsPIBoxObject)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(BoxObject)
-  // XXX jmorton: why aren't we unlinking mPropertyTable?
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(BoxObject)
-  if (tmp->mPropertyTable) {
-    for (auto iter = tmp->mPropertyTable->Iter(); !iter.Done(); iter.Next()) {
-      cb.NoteXPCOMChild(iter.UserData());
-    }
-  }
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(BoxObject)
-
-// Constructors/Destructors
-BoxObject::BoxObject() : mContent(nullptr) {}
-
-BoxObject::~BoxObject() {}
-
-NS_IMETHODIMP
-BoxObject::GetElement(Element** aResult) {
-  RefPtr<Element> element = mContent;
-  element.forget(aResult);
-  return NS_OK;
-}
-
-// nsPIBoxObject //////////////////////////////////////////////////////////////
-
-nsresult BoxObject::Init(Element* aElement) {
-  mContent = aElement;
-  return NS_OK;
-}
-
-void BoxObject::Clear() {
-  mPropertyTable = nullptr;
-  mContent = nullptr;
-}
-
-void BoxObject::ClearCachedValues() {}
-
-nsIFrame* BoxObject::GetFrame() const {
-  if (!GetPresShell() || !mContent) {
-    return nullptr;
-  }
-  return mContent->GetPrimaryFrame();
-}
-
-nsIFrame* BoxObject::GetFrameWithFlushPendingNotifications() {
-  RefPtr<PresShell> presShell = GetPresShellWithFlushPendingNotifications();
-  if (!presShell) {
-    return nullptr;
-  }
-
-  // If we didn't flush layout when getting the presshell, we should at least
-  // flush to make sure our frame model is up to date.
-  // XXXbz should flush on document, no?  Except people call this from
-  // frame code, maybe?
-  presShell->FlushPendingNotifications(FlushType::Frames);
-
-  // The flush might have killed mContent.
-  if (!mContent) {
-    return nullptr;
-  }
-
-  return mContent->GetPrimaryFrame();
-}
-
-PresShell* BoxObject::GetPresShell() const {
-  if (!mContent) {
-    return nullptr;
-  }
-
-  Document* doc = mContent->GetComposedDoc();
-  if (!doc) {
-    return nullptr;
-  }
-
-  return doc->GetPresShell();
-}
-
-PresShell* BoxObject::GetPresShellWithFlushPendingNotifications() {
-  if (!mContent) {
-    return nullptr;
-  }
-
-  RefPtr<Document> doc = mContent->GetComposedDoc();
-  if (!doc) {
-    return nullptr;
-  }
-
-  doc->FlushPendingNotifications(FlushType::Layout);
-
-  return doc->GetPresShell();
-}
-
-nsresult BoxObject::GetOffsetRect(nsIntRect& aRect) {
-  aRect.SetRect(0, 0, 0, 0);
-
-  if (!mContent) return NS_ERROR_NOT_INITIALIZED;
-
-  // Get the Frame for our content
-  nsIFrame* frame = GetFrameWithFlushPendingNotifications();
-  if (frame) {
-    // Get its origin
-    nsPoint origin = frame->GetPositionIgnoringScrolling();
-
-    // Find the frame parent whose content is the document element.
-    Element* docElement = mContent->GetComposedDoc()->GetRootElement();
-    nsIFrame* parent = frame->GetParent();
-    for (;;) {
-      // If we've hit the document element, break here
-      if (parent->GetContent() == docElement) {
-        break;
-      }
-
-      nsIFrame* next = parent->GetParent();
-      if (!next) {
-        NS_WARNING("We should have hit the document element...");
-        origin += parent->GetPosition();
-        break;
-      }
-
-      // Add the parent's origin to our own to get to the
-      // right coordinate system
-      origin += next->GetPositionOfChildIgnoringScrolling(parent);
-      parent = next;
-    }
-
-    // For the origin, add in the border for the frame
-    const nsStyleBorder* border = frame->StyleBorder();
-    origin.x += border->GetComputedBorderWidth(eSideLeft);
-    origin.y += border->GetComputedBorderWidth(eSideTop);
-
-    // And subtract out the border for the parent
-    const nsStyleBorder* parentBorder = parent->StyleBorder();
-    origin.x -= parentBorder->GetComputedBorderWidth(eSideLeft);
-    origin.y -= parentBorder->GetComputedBorderWidth(eSideTop);
-
-    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.
-    nsRect rcFrame = nsLayoutUtils::GetAllInFlowRectsUnion(frame, parent);
-    aRect.width = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.width);
-    aRect.height = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.height);
-  }
-
-  return NS_OK;
-}
-
-nsresult BoxObject::GetScreenPosition(nsIntPoint& aPoint) {
-  aPoint.x = aPoint.y = 0;
-
-  if (!mContent) return NS_ERROR_NOT_INITIALIZED;
-
-  nsIFrame* frame = GetFrameWithFlushPendingNotifications();
-  if (frame) {
-    CSSIntRect rect = frame->GetScreenRect();
-    aPoint.x = rect.x;
-    aPoint.y = rect.y;
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetX(int32_t* aResult) {
-  nsIntRect rect;
-  GetOffsetRect(rect);
-  *aResult = rect.x;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetY(int32_t* aResult) {
-  nsIntRect rect;
-  GetOffsetRect(rect);
-  *aResult = rect.y;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetWidth(int32_t* aResult) {
-  nsIntRect rect;
-  GetOffsetRect(rect);
-  *aResult = rect.width;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetHeight(int32_t* aResult) {
-  nsIntRect rect;
-  GetOffsetRect(rect);
-  *aResult = rect.height;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetScreenX(int32_t* _retval) {
-  nsIntPoint position;
-  nsresult rv = GetScreenPosition(position);
-  if (NS_FAILED(rv)) return rv;
-  *_retval = position.x;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetScreenY(int32_t* _retval) {
-  nsIntPoint position;
-  nsresult rv = GetScreenPosition(position);
-  if (NS_FAILED(rv)) return rv;
-  *_retval = position.y;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetPropertyAsSupports(const char16_t* aPropertyName,
-                                 nsISupports** aResult) {
-  NS_ENSURE_ARG(aPropertyName && *aPropertyName);
-  if (!mPropertyTable) {
-    *aResult = nullptr;
-    return NS_OK;
-  }
-  nsDependentString propertyName(aPropertyName);
-  mPropertyTable->Get(propertyName, aResult);  // Addref here.
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::SetPropertyAsSupports(const char16_t* aPropertyName,
-                                 nsISupports* aValue) {
-  NS_ENSURE_ARG(aPropertyName && *aPropertyName);
-
-  if (!mPropertyTable) {
-    mPropertyTable = new nsInterfaceHashtable<nsStringHashKey, nsISupports>(4);
-  }
-
-  nsDependentString propertyName(aPropertyName);
-  mPropertyTable->Put(propertyName, aValue);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-BoxObject::GetProperty(const char16_t* aPropertyName, char16_t** aResult) {
-  nsCOMPtr<nsISupports> data;
-  nsresult rv = GetPropertyAsSupports(aPropertyName, getter_AddRefs(data));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!data) {
-    *aResult = nullptr;
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsISupportsString> supportsStr = do_QueryInterface(data);
-  if (!supportsStr) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return supportsStr->ToString(aResult);
-}
-
-NS_IMETHODIMP
-BoxObject::SetProperty(const char16_t* aPropertyName,
-                       const char16_t* aPropertyValue) {
-  NS_ENSURE_ARG(aPropertyName && *aPropertyName);
-
-  nsDependentString propertyName(aPropertyName);
-  nsDependentString propertyValue;
-  if (aPropertyValue) {
-    propertyValue.Rebind(aPropertyValue);
-  } else {
-    propertyValue.SetIsVoid(true);
-  }
-
-  nsCOMPtr<nsISupportsString> supportsStr(
-      do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
-  NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY);
-  supportsStr->SetData(propertyValue);
-
-  return SetPropertyAsSupports(aPropertyName, supportsStr);
-}
-
-NS_IMETHODIMP
-BoxObject::RemoveProperty(const char16_t* aPropertyName) {
-  NS_ENSURE_ARG(aPropertyName && *aPropertyName);
-
-  if (!mPropertyTable) return NS_OK;
-
-  nsDependentString propertyName(aPropertyName);
-  mPropertyTable->Remove(propertyName);
-  return NS_OK;
-}
-
-Element* BoxObject::GetParentBox() {
-  nsIFrame* frame = GetFrame();
-  if (!frame) {
-    return nullptr;
-  }
-
-  nsIFrame* parent = frame->GetParent();
-  if (!parent) {
-    return nullptr;
-  }
-
-  nsIContent* parentContent = parent->GetContent();
-  // In theory parent could be viewport, and then parentContent is null.
-  if (parentContent && parentContent->IsElement()) {
-    return parentContent->AsElement();
-  }
-
-  return nullptr;
-}
-
-Element* BoxObject::GetFirstChild() {
-  nsIFrame* frame = GetFrame();
-  if (!frame) {
-    return nullptr;
-  }
-
-  nsIFrame* firstFrame = frame->PrincipalChildList().FirstChild();
-  if (!firstFrame) {
-    return nullptr;
-  }
-
-  nsIContent* content = firstFrame->GetContent();
-  if (content->IsElement()) {
-    return content->AsElement();
-  }
-
-  return nullptr;
-}
-
-Element* BoxObject::GetLastChild() {
-  nsIFrame* frame = GetFrame();
-  if (!frame) {
-    return nullptr;
-  }
-  return GetPreviousSibling(frame, nullptr);
-}
-
-Element* BoxObject::GetNextSibling() {
-  nsIFrame* frame = GetFrame();
-  if (!frame) {
-    return nullptr;
-  }
-
-  nsIFrame* nextFrame = frame->GetNextSibling();
-  if (!nextFrame) {
-    return nullptr;
-  }
-
-  nsIContent* content = nextFrame->GetContent();
-  if (content->IsElement()) {
-    return content->AsElement();
-  }
-
-  return nullptr;
-}
-
-Element* BoxObject::GetPreviousSibling() {
-  nsIFrame* frame = GetFrame();
-  if (!frame) {
-    return nullptr;
-  }
-  nsIFrame* parentFrame = frame->GetParent();
-  if (!parentFrame) {
-    return nullptr;
-  }
-  return GetPreviousSibling(parentFrame, frame);
-}
-
-Element* BoxObject::GetPreviousSibling(nsIFrame* aParentFrame,
-                                       nsIFrame* aFrame) {
-  nsIFrame* nextFrame = aParentFrame->PrincipalChildList().FirstChild();
-  nsIFrame* prevFrame = nullptr;
-  while (nextFrame) {
-    if (nextFrame == aFrame) break;
-    prevFrame = nextFrame;
-    nextFrame = nextFrame->GetNextSibling();
-  }
-
-  if (!prevFrame) {
-    return nullptr;
-  }
-
-  nsIContent* content = prevFrame->GetContent();
-  if (!content->IsElement()) {
-    return nullptr;
-  }
-
-  return content->AsElement();
-}
-
-Element* BoxObject::GetParentObject() const { return mContent; }
-
-JSObject* BoxObject::WrapObject(JSContext* aCx,
-                                JS::Handle<JSObject*> aGivenProto) {
-  return BoxObject_Binding::Wrap(aCx, this, aGivenProto);
-}
-
-Element* BoxObject::GetElement() const { return mContent; }
-
-int32_t BoxObject::X() {
-  int32_t ret = 0;
-  GetX(&ret);
-  return ret;
-}
-
-int32_t BoxObject::Y() {
-  int32_t ret = 0;
-  GetY(&ret);
-  return ret;
-}
-
-int32_t BoxObject::GetScreenX(ErrorResult& aRv) {
-  int32_t ret = 0;
-  aRv = GetScreenX(&ret);
-  return ret;
-}
-
-int32_t BoxObject::GetScreenY(ErrorResult& aRv) {
-  int32_t ret = 0;
-  aRv = GetScreenY(&ret);
-  return ret;
-}
-
-int32_t BoxObject::Width() {
-  int32_t ret = 0;
-  GetWidth(&ret);
-  return ret;
-}
-
-int32_t BoxObject::Height() {
-  int32_t ret = 0;
-  GetHeight(&ret);
-  return ret;
-}
-
-already_AddRefed<nsISupports> BoxObject::GetPropertyAsSupports(
-    const nsAString& propertyName) {
-  nsCOMPtr<nsISupports> ret;
-  GetPropertyAsSupports(PromiseFlatString(propertyName).get(),
-                        getter_AddRefs(ret));
-  return ret.forget();
-}
-
-void BoxObject::SetPropertyAsSupports(const nsAString& propertyName,
-                                      nsISupports* value) {
-  SetPropertyAsSupports(PromiseFlatString(propertyName).get(), value);
-}
-
-void BoxObject::GetProperty(const nsAString& propertyName, nsString& aRetVal,
-                            ErrorResult& aRv) {
-  nsCOMPtr<nsISupports> data(GetPropertyAsSupports(propertyName));
-  if (!data) {
-    return;
-  }
-
-  nsCOMPtr<nsISupportsString> supportsStr(do_QueryInterface(data));
-  if (!supportsStr) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return;
-  }
-
-  supportsStr->GetData(aRetVal);
-}
-
-void BoxObject::SetProperty(const nsAString& propertyName,
-                            const nsAString& propertyValue) {
-  SetProperty(PromiseFlatString(propertyName).get(),
-              PromiseFlatString(propertyValue).get());
-}
-
-void BoxObject::RemoveProperty(const nsAString& propertyName) {
-  RemoveProperty(PromiseFlatString(propertyName).get());
-}
-
-}  // namespace dom
-}  // namespace mozilla
deleted file mode 100644
--- a/layout/xul/BoxObject.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 mozilla_dom_BoxObject_h__
-#define mozilla_dom_BoxObject_h__
-
-#include "mozilla/Attributes.h"
-#include "mozilla/ErrorResult.h"
-#include "nsCOMPtr.h"
-#include "nsIBoxObject.h"
-#include "nsPIBoxObject.h"
-#include "nsPoint.h"
-#include "nsAutoPtr.h"
-#include "nsHashKeys.h"
-#include "nsInterfaceHashtable.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsWrapperCache.h"
-#include "nsRect.h"
-
-class nsIFrame;
-
-namespace mozilla {
-
-class PresShell;
-
-namespace dom {
-
-class Element;
-
-class BoxObject : public nsPIBoxObject, public nsWrapperCache {
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BoxObject)
-  NS_DECL_NSIBOXOBJECT
-
- public:
-  BoxObject();
-
-  // nsPIBoxObject
-  virtual nsresult Init(Element* aElement) override;
-  virtual void Clear() override;
-  virtual void ClearCachedValues() override;
-
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult GetOffsetRect(nsIntRect& aRect);
-  MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult GetScreenPosition(nsIntPoint& aPoint);
-
-  // Given a parent frame and a child frame, find the frame whose
-  // next sibling is the given child frame and return its element
-  static Element* GetPreviousSibling(nsIFrame* aParentFrame, nsIFrame* aFrame);
-
-  // WebIDL (wraps old impls)
-  Element* GetParentObject() const;
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aGivenProto) override;
-
-  Element* GetElement() const;
-
-  int32_t X();
-  int32_t Y();
-  int32_t GetScreenX(ErrorResult& aRv);
-  int32_t GetScreenY(ErrorResult& aRv);
-  int32_t Width();
-  int32_t Height();
-
-  already_AddRefed<nsISupports> GetPropertyAsSupports(
-      const nsAString& propertyName);
-  void SetPropertyAsSupports(const nsAString& propertyName, nsISupports* value);
-  void GetProperty(const nsAString& propertyName, nsString& aRetVal,
-                   ErrorResult& aRv);
-  void SetProperty(const nsAString& propertyName,
-                   const nsAString& propertyValue);
-  void RemoveProperty(const nsAString& propertyName);
-
-  Element* GetParentBox();
-  Element* GetFirstChild();
-  Element* GetLastChild();
-  Element* GetNextSibling();
-  Element* GetPreviousSibling();
-
- protected:
-  virtual ~BoxObject();
-
-  nsIFrame* GetFrame() const;
-  MOZ_CAN_RUN_SCRIPT nsIFrame* GetFrameWithFlushPendingNotifications();
-  PresShell* GetPresShell() const;
-  MOZ_CAN_RUN_SCRIPT PresShell* GetPresShellWithFlushPendingNotifications();
-
-  nsAutoPtr<nsInterfaceHashtable<nsStringHashKey, nsISupports>> mPropertyTable;
-
-  Element* mContent;  // [WEAK]
-};
-
-}  // namespace dom
-}  // namespace mozilla
-
-#endif
--- a/layout/xul/moz.build
+++ b/layout/xul/moz.build
@@ -10,36 +10,24 @@ with Files('**'):
 with Files('*Menu*'):
     BUG_COMPONENT = ('Core', 'XP Toolkit/Widgets: Menus')
 
 if CONFIG['ENABLE_TESTS']:
     MOCHITEST_MANIFESTS += ['test/mochitest.ini']
     MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
     BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
 
-XPIDL_SOURCES += [
-    'nsIBoxObject.idl',
-]
-
-XPIDL_MODULE = 'layout_xul'
-
 EXPORTS += [
     'nsBox.h',
     'nsIScrollbarMediator.h',
-    'nsPIBoxObject.h',
     'nsXULPopupManager.h',
     'nsXULTooltipListener.h',
 ]
 
-EXPORTS.mozilla.dom += [
-    'BoxObject.h',
-]
-
 UNIFIED_SOURCES += [
-    'BoxObject.cpp',
     'nsBox.cpp',
     'nsBoxFrame.cpp',
     'nsBoxLayout.cpp',
     'nsBoxLayoutState.cpp',
     'nsButtonBoxFrame.cpp',
     'nsRepeatService.cpp',
     'nsRootBoxFrame.cpp',
     'nsScrollbarButtonFrame.cpp',
deleted file mode 100644
--- a/layout/xul/nsIBoxObject.idl
+++ /dev/null
@@ -1,27 +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/. */
-
-#include "nsISupports.idl"
-
-webidl Element;
-
-[scriptable, uuid(ce572460-b0f2-4650-a9e7-c53a99d3b6ad)]
-interface nsIBoxObject : nsISupports
-{
-  readonly attribute Element element;
-
-  readonly attribute long x;
-  readonly attribute long y;
-  readonly attribute long screenX;
-  readonly attribute long screenY;
-  readonly attribute long width;
-  readonly attribute long height;
-
-  nsISupports getPropertyAsSupports(in wstring propertyName);
-  void setPropertyAsSupports(in wstring propertyName, in nsISupports value);
-  wstring getProperty(in wstring propertyName);
-  void setProperty(in wstring propertyName, in wstring propertyValue);
-  void removeProperty(in wstring propertyName);
-};
deleted file mode 100644
--- a/layout/xul/nsPIBoxObject.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 nsPIBoxObject_h___
-#define nsPIBoxObject_h___
-
-#include "nsIBoxObject.h"
-
-// {2b8bb262-1b0f-4572-ba87-5d4ae4954445}
-#define NS_PIBOXOBJECT_IID                           \
-  {                                                  \
-    0x2b8bb262, 0x1b0f, 0x4572, {                    \
-      0xba, 0x87, 0x5d, 0x4a, 0xe4, 0x95, 0x44, 0x45 \
-    }                                                \
-  }
-
-namespace mozilla {
-namespace dom {
-class Element;
-}  // namespace dom
-}  // namespace mozilla
-
-class nsPIBoxObject : public nsIBoxObject {
- public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIBOXOBJECT_IID)
-
-  virtual nsresult Init(mozilla::dom::Element* aElement) = 0;
-
-  // Drop the weak ref to the content node as needed
-  virtual void Clear() = 0;
-
-  // The values cached by the implementation of this interface should be
-  // cleared when this method is called.
-  virtual void ClearCachedValues() = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsPIBoxObject, NS_PIBOXOBJECT_IID)
-
-#endif
--- a/layout/xul/tree/nsTreeColumns.cpp
+++ b/layout/xul/tree/nsTreeColumns.cpp
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "nsNameSpaceManager.h"
 #include "nsGkAtoms.h"
-#include "nsIBoxObject.h"
 #include "nsTreeColumns.h"
 #include "nsTreeUtils.h"
 #include "mozilla/ComputedStyle.h"
 #include "nsContentUtils.h"
 #include "nsTreeBodyFrame.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/TreeColumnBinding.h"
 #include "mozilla/dom/TreeColumnsBinding.h"
--- a/layout/xul/tree/nsTreeSelection.cpp
+++ b/layout/xul/tree/nsTreeSelection.cpp
@@ -3,17 +3,16 @@
 /* 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/AsyncEventDispatcher.h"
 #include "mozilla/dom/Element.h"
 #include "nsCOMPtr.h"
 #include "nsTreeSelection.h"
-#include "nsIBoxObject.h"
 #include "XULTreeElement.h"
 #include "nsITreeView.h"
 #include "nsString.h"
 #include "nsIContent.h"
 #include "nsNameSpaceManager.h"
 #include "nsGkAtoms.h"
 #include "nsComponentManagerUtils.h"
 #include "nsTreeColumns.h"