Closed
      
        Bug 836176
      
      
        Opened 12 years ago
          Closed 6 years ago
      
        
    
  
Remove nsIHTMLDocument 
    Categories
(Core :: DOM: Core & HTML, defect)
        Core
          
        
        
      
        
    
        DOM: Core & HTML
          
        
        
      
        
    Tracking
()
        RESOLVED
        FIXED
        
    
  
        
            mozilla69
        
    
  
| Tracking | Status | |
|---|---|---|
| firefox69 | --- | fixed | 
People
(Reporter: dzbarsky, Assigned: ehsan.akhgari)
References
Details
Attachments
(6 files)
| 1.81 KB,
          patch         | bzbarsky
:
              
              review+ dzbarsky
:
              
              checkin+ | Details | Diff | Splinter Review | 
| 65.22 KB,
          patch         | Details | Diff | Splinter Review | |
| 2.48 KB,
          patch         | bzbarsky
:
              
              review+ dzbarsky
:
              
              checkin+ | Details | Diff | Splinter Review | 
| 47 bytes,
          text/x-phabricator-request         | Details | Review | |
| 47 bytes,
          text/x-phabricator-request         | Details | Review | |
| 47 bytes,
          text/x-phabricator-request         | Details | Review | 
      No description provided.
| Reporter | ||
| Comment 1•12 years ago
           | ||
        Attachment #707983 -
        Flags: review?(bzbarsky)
| Reporter | ||
| Comment 2•12 years ago
           | ||
|   | ||
| Comment 3•12 years ago
           | ||
Comment on attachment 707983 [details] [diff] [review]
Part 1: Add nsIDocument::AsHTMLDocument
r=me
If we cared to inline it, we could put the impl in nsHTMLDocument.h, but this is probably fine.
        Attachment #707983 -
        Flags: review?(bzbarsky) → review+
| Reporter | ||
| Comment 4•12 years ago
           | ||
Whiteboard: [leave open]
| Reporter | ||
| Updated•12 years ago
           | 
        Attachment #707983 -
        Flags: checkin+
| Comment 5•12 years ago
           | ||
Are no binary add-ons using nsIHTMLDocument?
| Comment 6•12 years ago
           | ||
Comment on attachment 707984 [details] [diff] [review]
Part 2: Remove nsIHTMLDocument
Review of attachment 707984 [details] [diff] [review]:
-----------------------------------------------------------------
Without looking further than the context included in the patch, we may need a number of null checks.
::: content/base/src/nsContentUtils.cpp
@@ +2183,5 @@
>    if (IsAutocompleteOff(aContent)) {
>      return NS_OK;
>    }
>  
> +  nsHTMLDocument* htmlDocument = aContent->GetCurrentDoc()->AsHTMLDocument();
Is GetCurrentDoc() never null?
@@ +4065,5 @@
>    // for compiling event handlers... so just bail out.
>    nsCOMPtr<nsIDocument> document = aContextNode->OwnerDoc();
>    bool isHTML = document->IsHTML();
>  #ifdef DEBUG
> +  NS_ASSERTION(!isHTML || document->AsHTMLDocument(), "Should have HTMLDocument here!");
If you think this assertion is still useful, get rid of the ifdef, at least.
::: content/base/src/nsCopySupport.cpp
@@ +413,5 @@
>    // also consider ourselves in a text widget if we can't find an html
>    // document. Note that XHTML is not counted as HTML here, because we can't
>    // copy it properly (all the copy code for non-plaintext assumes using HTML
>    // serializers and parsers is OK, and those mess up XHTML).
> +  if (!aDoc->IsHTML())
aDoc is never null?
::: content/base/src/nsDocumentEncoder.cpp
@@ +1393,5 @@
>      }
>    }
>    
>    // also consider ourselves in a text widget if we can't find an html document
> +  if (!mDocument->IsHTML())
And here?
::: content/base/src/nsXMLHttpRequest.cpp
@@ +2206,5 @@
>      }
>  
>      if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) {
> +      nsCOMPtr<nsIDocument> doc = do_QueryInterface(mResponseXML);
> +      if (doc->IsHTML()) {
And doc here?
::: content/html/content/src/nsGenericHTMLElement.cpp
@@ +527,5 @@
>      return false;                       // Not spellchecked by default
>    }
>  
>    if (IsCurrentBodyElement()) {
> +    nsHTMLDocument* doc = GetCurrentDoc()->AsHTMLDocument();
I guess IsCurrentBodyElement() == true ==> IsInDoc() == true ==> GetCurrentDoc() != null, so this is safe... Assert, please.
@@ +645,5 @@
>  
>    RemoveFromNameTable();
>  
>    if (GetContentEditableValue() == eTrue) {
> +    nsIDocument* doc = GetCurrentDoc();
How about here?
::: content/html/content/src/nsHTMLFormElement.cpp
@@ +445,5 @@
>                                                   aCompileEventHandlers);
>    NS_ENSURE_SUCCESS(rv, rv);
>  
> +  if (aDocument->IsHTML()) {
> +    aDocument->AsHTMLDocument()->AddedForm();
This is probably fine
@@ +510,5 @@
>  
>  void
>  nsHTMLFormElement::UnbindFromTree(bool aDeep, bool aNullParent)
>  {
> +  nsCOMPtr<nsIDocument> oldDocument = do_QueryInterface(GetCurrentDoc());
GetCurrentDoc() already returns nsIDocument
@@ +1473,5 @@
>    // a document inside XUL.
>  
>    nsCOMPtr<nsIURI> actionURL;
>    if (action.IsEmpty()) {
> +    if (!document->IsHTML()) {
Can document be null?
::: content/html/document/src/nsHTMLDocument.cpp
@@ +1196,4 @@
>                     "Huh, how did this happen? This should only be used with "
>                     "HTML documents!");
>      }
>  #endif
Get rid of the extra scoping and the ifdef
@@ +1239,4 @@
>                   "Huh, how did this happen? This should only be used with "
>                   "HTML documents!");
>    }
>  #endif
Same here
::: content/xml/document/src/nsXMLContentSink.cpp
@@ +377,5 @@
>    if (NS_SUCCEEDED(aResult) || aResultDocument) {
>      // Transform succeeded or it failed and we have an error
>      // document to display.
>      mDocument = aResultDocument;
> +    if (mDocument->IsHTML()) {
Looks like mDocument could be null here
::: docshell/base/nsDocShellEditorData.cpp
@@ +210,5 @@
>  
>    nsCOMPtr<nsIDOMDocument> domDoc;
>    domWindow->GetDocument(getter_AddRefs(domDoc));
> +  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
> +  if (doc->IsHTML())
domDoc could most likely be null
@@ +233,5 @@
>  
>    nsCOMPtr<nsIDOMDocument> domDoc;
>    domWindow->GetDocument(getter_AddRefs(domDoc));
> +  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
> +  if (doc->IsHTML())
Same here
::: docshell/base/nsDocShellEditorData.h
@@ +64,5 @@
>  
>    // Backup for mMakeEditable while the editor is detached.
>    bool mDetachedMakeEditable;
>  
> +  // Backup for the corresponding nsHTMLDocument's  editing state while
While you're here, want to fix the weird double space?
::: dom/base/nsDOMClassInfo.cpp
@@ +8376,2 @@
>        xpc::Throw(cx, rv);
>        return JS_FALSE;
You don't want to xpc::Throw a success result.
::: dom/base/nsFocusManager.cpp
@@ +2031,5 @@
>    if (editorDocShell) {
>      editorDocShell->GetEditable(&isEditable);
>  
>      if (isEditable) {
> +      nsHTMLDocument* doc = presShell->GetDocument()->AsHTMLDocument();
Can GetDocument() be null?
@@ +2983,5 @@
>    }
>  
>    // Finally, check if this is a frameset
> +  if (aDocument->IsHTML() &&
> +      aDocument->AsHTMLDocument()->GetHtmlChildElement(nsGkAtoms::frameset)) {
How about aDocument?
::: dom/base/nsGlobalWindow.cpp
@@ +2341,2 @@
>      nsWindowSH::InstallGlobalScopePolluter(cx, newInnerWindow->mJSObject,
> +                                           doc->AsHTMLDocument());
mDocument can be null, I think
::: editor/composer/src/nsEditingSession.cpp
@@ +541,5 @@
>    // Check if we're turning off editing (from contentEditable or designMode).
>    nsCOMPtr<nsIDOMDocument> domDoc;
>    aWindow->GetDocument(getter_AddRefs(domDoc));
> +  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
> +  bool stopEditing = doc->IsHTML() && doc->AsHTMLDocument()->IsEditingOn();
doc &&
@@ +687,2 @@
>  
> +        nsHTMLDocument* htmlDoc = doc->AsHTMLDocument();
And here
::: parser/html/Makefile.in
@@ +92,5 @@
>  
>  include $(topsrcdir)/config/rules.mk
>  
>  INCLUDES	+= \
> +		-I$(srcdir)/../../layout/style \
Which headers is this for? Can we export them, or not have nsHTMLDocument.h include them?
| Comment 7•12 years ago
           | ||
| Reporter | ||
| Comment 9•12 years ago
           | ||
(In reply to :Ms2ger from comment #6)
> Comment on attachment 707984 [details] [diff] [review]
> Part 2: Remove nsIHTMLDocument
> 
> Review of attachment 707984 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> 
> ::: content/base/src/nsCopySupport.cpp
> @@ +413,5 @@
> >    // also consider ourselves in a text widget if we can't find an html
> >    // document. Note that XHTML is not counted as HTML here, because we can't
> >    // copy it properly (all the copy code for non-plaintext assumes using HTML
> >    // serializers and parsers is OK, and those mess up XHTML).
> > +  if (!aDoc->IsHTML())
> 
> aDoc is never null?
Nope, I added an assert.
> 
> ::: content/base/src/nsXMLHttpRequest.cpp
> @@ +2206,5 @@
> >      }
> >  
> >      if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) {
> > +      nsCOMPtr<nsIDocument> doc = do_QueryInterface(mResponseXML);
> > +      if (doc->IsHTML()) {
> 
> And doc here?
The QI is not needed and we deref mResponseXML right above.
 
> 
> ::: content/html/content/src/nsHTMLFormElement.cpp
> @@ +445,5 @@
> >                                                   aCompileEventHandlers);
> >    NS_ENSURE_SUCCESS(rv, rv);
> >  
> > +  if (aDocument->IsHTML()) {
> > +    aDocument->AsHTMLDocument()->AddedForm();
> 
> This is probably fine
> 
This needs a null check actually.
> GetCurrentDoc() already returns nsIDocument
> 
> @@ +1473,5 @@
> >    // a document inside XUL.
> >  
> >    nsCOMPtr<nsIURI> actionURL;
> >    if (action.IsEmpty()) {
> > +    if (!document->IsHTML()) {
> 
> Can document be null?
If it is we'll crash when calling GetDocumentURI right above these lines.
> 
> @@ +2983,5 @@
> >    }
> >  
> >    // Finally, check if this is a frameset
> > +  if (aDocument->IsHTML() &&
> > +      aDocument->AsHTMLDocument()->GetHtmlChildElement(nsGkAtoms::frameset)) {
> 
> How about aDocument?
> 
No, its dereferenced right above this.
| Comment 10•12 years ago
           | ||
(In reply to David Zbarsky (:dzbarsky) from comment #9)
> > aDoc is never null?
> 
> Nope, I added an assert.
If aDoc can be null for a valid reason, an error check should be added rather than an assertion.
| Reporter | ||
| Comment 11•12 years ago
           | ||
        Attachment #738853 -
        Flags: review?(bzbarsky)
|   | ||
| Comment 12•12 years ago
           | ||
Comment on attachment 738853 [details] [diff] [review]
Part 1.5: Fix AsHTMLDocument
r=me
        Attachment #738853 -
        Flags: review?(bzbarsky) → review+
| Reporter | ||
| Comment 13•12 years ago
           | ||
| Reporter | ||
| Updated•12 years ago
           | 
        Attachment #738853 -
        Flags: checkin+
| Comment 14•12 years ago
           | ||
| Updated•6 years ago
           | 
Component: DOM → DOM: Core & HTML
| Assignee | ||
| Updated•6 years ago
           | 
| Assignee | ||
| Comment 15•6 years ago
           | ||
| Assignee | ||
| Comment 16•6 years ago
           | ||
| Comment 17•6 years ago
           | ||
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7c20ef4aadca
Part 2: Remove nsIHTMLDocument::SetIsXHTML(); r=farre
https://hg.mozilla.org/integration/autoland/rev/f848dfc22ff4
Part 3: Remove nsIHTMLDocument; r=farre
| Assignee | ||
| Comment 18•6 years ago
           | ||
| Comment 19•6 years ago
           | ||
Pushed by eakhgari@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/57b2544a30e4
Part 4: drop a useless null check
|   | ||
| Comment 20•6 years ago
           | ||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/7c20ef4aadca
https://hg.mozilla.org/mozilla-central/rev/f848dfc22ff4
https://hg.mozilla.org/mozilla-central/rev/57b2544a30e4
Status: NEW → RESOLVED
Closed: 6 years ago
          status-firefox69:
          --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla69
          You need to log in
          before you can comment on or make changes to this bug.
        
Description
•