Bug 15062

Summary: Implement document.compatMode
Product: WebKit Reporter: Geoffrey Garen <ggaren>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, magic, sam
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 9117    
Attachments:
Description Flags
implementation in the Document interface
sam: review-
Implement compatMode (in HTMLDocument interface) mjs: review+

Description Geoffrey Garen 2007-08-23 11:55:19 PDT
In IE and FF, it tells you whether you're in quirks mode:

document.compatMode := "BackCompat" | "CSS1Compat"
Comment 1 Vincent Ricard 2007-08-28 14:05:45 PDT
Created attachment 16147 [details]
implementation in the Document interface

here is a patch to implement document.compatMode. I used the followings links to match the FF behavior; but i'm not sure if compatMode should be declared in the Document interface or in HTMLDocument:
- http://www.whatwg.org/specs/web-apps/current-work/multipage/section-documents.html
- http://developer.mozilla.org/en/docs/DOM:document.compatMode

So if we are in Strict mode (or AlmostStrict), we return 'CSS1Compat', otherwie we return 'BackCompat'.
Comment 2 Sam Weinig 2007-08-28 20:50:58 PDT
Comment on attachment 16147 [details]
implementation in the Document interface

The "{" should be on a new line.
+String Document::compatMode() const {
+    return inCompatMode() ? "BackCompat" : "CSS1Compat";
+}

I don't think there is any reason for [ConvertNullStringTo=Undefined] as null is not a possible return value.
+        readonly attribute [ConvertNullStringTo=Undefined] DOMString compatMode;

Also, does this attribute make sense for Documents other HTML documents?  If not, can we put this in the HTMLDocument?  r- for now.
Comment 3 Sam Weinig 2007-08-28 20:53:21 PDT
I would also like to see a test for when we are in AlmostStrict mode.
Comment 4 Vincent Ricard 2007-08-31 03:03:50 PDT
Created attachment 16167 [details]
Implement compatMode (in HTMLDocument interface)

Here is the previous patch with all needed corrections (compatMode now belongs to HTMLDocument), and a new test case (now, there is one for each ParseMode)
Comment 5 Alexey Proskuryakov 2007-08-31 05:42:15 PDT
(In reply to comment #2)
> Also, does this attribute make sense for Documents other HTML documents?

It works for XHTML in Firefox, so it probably does with our current code organization.
Comment 6 Maciej Stachowiak 2007-09-04 04:50:17 PDT
Comment on attachment 16167 [details]
Implement compatMode (in HTMLDocument interface)

Implementing in HTMLDocument is ok for now - eventually we'll move all HTMLDocument stuff to be on all documents.

r=me for feature-branch
Comment 7 Eric Seidel (no email) 2007-10-07 01:47:30 PDT
Landed as r26096 on feature-branch.
Comment 8 Alexey Proskuryakov 2007-10-07 02:19:37 PDT
These landed tests fail for me:

fast/dom/compatMode-AlmostStrict.html -> failed
.
fast/dom/compatMode-Compat.html -> failed
.
fast/dom/compatMode-Strict.html -> failed

-SUCCESS
+FAILURE