Bug 39887

Summary: [chromium] Add isXHTMLDocument() to Chromium's WebKit::WebDocument
Product: WebKit Reporter: Aaron Boodman <aa>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, dglazkov, eric, fishd, ojan, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
Patch
none
Patch fishd: review+, fishd: commit-queue-

Description Aaron Boodman 2010-05-28 10:57:17 PDT
Add isXHTMLDocument() to Chromium's WebKit::WebDocument
Comment 1 Aaron Boodman 2010-05-28 11:01:07 PDT
Created attachment 57345 [details]
Patch
Comment 2 WebKit Review Bot 2010-05-28 11:54:27 PDT
Attachment 57345 [details] did not build on chromium:
Build output: http://webkit-commit-queue.appspot.com/results/2644039
Comment 3 Aaron Boodman 2010-05-28 12:34:13 PDT
Whoops. Please hold for better patch.
Comment 4 Aaron Boodman 2010-05-28 12:55:55 PDT
Created attachment 57364 [details]
Patch
Comment 5 Darin Fisher (:fishd, Google) 2010-05-28 13:49:35 PDT
Comment on attachment 57364 [details]
Patch

WebCore/ChangeLog:5
 +          Added isXHTMLDocument() to WebCore::Document.
nit: add bug link

WebKit/chromium/ChangeLog:5
 +          Add isXHTMLDocument() to WebDocument.
nit: add bug link
Comment 6 Aaron Boodman 2010-05-28 15:43:15 PDT
Committed r60377: <http://trac.webkit.org/changeset/60377>
Comment 7 Eric Seidel (no email) 2010-05-28 15:44:50 PDT
Why would you want this?

Don't you want to know if it's XML vs. HTML?  I can't remember if there is a difference between an XHTML document and an SVG document.

Then again, all of this is going to change in HTML5.
Comment 8 Eric Seidel (no email) 2010-05-28 15:46:10 PDT
WebCore currently has 3 types of documents:

HTMLDocument (exposes things like document.body)
Document (generic XML, no .body)
SVGDocument (<svg> root, exposes a couple SVG-specific things).

HTML5 has opinions on all of this.  I think all interfaces are exposed on all document types in HTML5.
Comment 9 Aaron Boodman 2010-05-28 15:51:34 PDT
I want to know whether the document has things like a body node.

When I debugged through it Document::isHTMLDocument() is not currently true for XHTML documents. m_xhtml is true, but m_html is false. So I added this method so that I could catch the XHTML case.

Is there a better fix?
Comment 10 Eric Seidel (no email) 2010-05-28 15:57:20 PDT
Well, the real fix is HTML5. :)  But I'm surprised you don't just check document.body and if that fails, check document.documentElement.firstChild.

It's lame that our XHTML documents don't have a .body (even though no spec until HTML5 said they should), but the .documentElement is a pretty common workaround.

Again, all of this will go away when we move to HTML5's document structure (I don't know when that will be).  We should just design whatever API so that it is future compatible.
Comment 11 Aaron Boodman 2010-05-28 16:26:54 PDT
You are right, that is a better fix. I'm going to rollback this change and submit one just checking document.documentElement's node name is HTML, which is close enough to what I'm after, and more forward compatible.
Comment 12 Alexey Proskuryakov 2010-06-01 15:18:18 PDT
> It's lame that our XHTML documents don't have a .body (even though
> no spec until HTML5 said they should)

They do, and have done for a long time. Implemented in bug 12628.
Comment 13 Alexey Proskuryakov 2010-06-01 15:22:35 PDT
> SVGDocument (<svg> root, exposes a couple SVG-specific things).

It seems that the only difference is how document.title works - as you mentioned, all documents expose all interfaces in HTML5.