Bug 1276438 part 5. Get rid of IsCurrentBodyElement. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 26 Jan 2018 00:53:35 -0500
changeset 748749 ca1495aea9767f523dd3543717ced61408b45bf9
parent 748748 d6b890b102b7197415317b0966e6a5c636fd5f57
child 748750 c5f9de9ad886275c5a90e953ec19c60d65a33797
push id97228
push usersfraser@mozilla.com
push dateTue, 30 Jan 2018 10:21:04 +0000
reviewersmystor
bugs1276438
milestone60.0a1
Bug 1276438 part 5. Get rid of IsCurrentBodyElement. r=mystor MozReview-Commit-ID: JMBFmVoMiMS
dom/html/HTMLBodyElement.cpp
dom/html/nsGenericHTMLElement.cpp
dom/html/nsGenericHTMLElement.h
--- a/dom/html/HTMLBodyElement.cpp
+++ b/dom/html/HTMLBodyElement.cpp
@@ -10,16 +10,17 @@
 #include "mozilla/HTMLEditor.h"
 #include "mozilla/TextEditor.h"
 #include "nsAttrValueInlines.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
+#include "nsIDocumentInlines.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsMappedAttributes.h"
 #include "nsIDocShell.h"
 #include "nsRuleWalker.h"
 #include "nsGlobalWindow.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Body)
 
@@ -269,17 +270,17 @@ already_AddRefed<TextEditor>
 HTMLBodyElement::GetAssociatedEditor()
 {
   RefPtr<TextEditor> textEditor = GetTextEditorInternal();
   if (textEditor) {
     return textEditor.forget();
   }
 
   // Make sure this is the actual body of the document
-  if (!IsCurrentBodyElement()) {
+  if (this != OwnerDoc()->GetBodyElement()) {
     return nullptr;
   }
 
   // For designmode, try to get document's editor
   nsPresContext* presContext = GetPresContext(eForComposedDoc);
   if (!presContext) {
     return nullptr;
   }
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2677,36 +2677,16 @@ already_AddRefed<TextEditor>
 nsGenericHTMLElement::GetAssociatedEditor()
 {
   // If contenteditable is ever implemented, it might need to do something different here?
 
   RefPtr<TextEditor> textEditor = GetTextEditorInternal();
   return textEditor.forget();
 }
 
-bool
-nsGenericHTMLElement::IsCurrentBodyElement()
-{
-  // TODO Bug 698498: Should this handle the case where GetBody returns a
-  //                  frameset?
-  if (!IsHTMLElement(nsGkAtoms::body)) {
-    return false;
-  }
-
-  nsCOMPtr<nsIDOMHTMLDocument> htmlDocument =
-    do_QueryInterface(GetUncomposedDoc());
-  if (!htmlDocument) {
-    return false;
-  }
-
-  nsCOMPtr<nsIDOMHTMLElement> htmlElement;
-  htmlDocument->GetBody(getter_AddRefs(htmlElement));
-  return htmlElement == static_cast<HTMLBodyElement*>(this);
-}
-
 // static
 void
 nsGenericHTMLElement::SyncEditorsOnSubtree(nsIContent* content)
 {
   /* Sync this node */
   nsGenericHTMLElement* element = FromContent(content);
   if (element) {
     RefPtr<TextEditor> textEditor = element->GetAssociatedEditor();
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -910,21 +910,16 @@ protected:
    * 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 (FlushType::Layout).
    * @param aRect the offset information [OUT]
    */
   mozilla::dom::Element* GetOffsetRect(mozilla::CSSIntRect& aRect);
 
   /**
-   * 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
    * spellchecking.
    */
   static void SyncEditorsOnSubtree(nsIContent* content);
 
   enum ContentEditableTristate {
     eInherit = -1,
     eFalse = 0,