Bug 15062 - Implement document.compatMode
Summary: Implement document.compatMode
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
Depends on:
Blocks: 9117
  Show dependency treegraph
Reported: 2007-08-23 11:55 PDT by Geoffrey Garen
Modified: 2007-10-07 02:19 PDT (History)
3 users (show)

See Also:

implementation in the Document interface (6.08 KB, patch)
2007-08-28 14:05 PDT, Vincent Ricard
sam: review-
Details | Formatted Diff | Diff
Implement compatMode (in HTMLDocument interface) (7.21 KB, patch)
2007-08-31 03:03 PDT, Vincent Ricard
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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