Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement document.compatMode #1599

Merged
merged 1 commit into from Jan 31, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implement document.compatMode

  • Loading branch information
brunoabinader committed Jan 30, 2014
commit 56572a28142978c4e6e620c21c0b3e5497e3e477
@@ -22,6 +22,7 @@ use dom::uievent::UIEvent;
use dom::window::Window;
use dom::htmltitleelement::HTMLTitleElement;
use html::hubbub_html_parser::build_element_from_tag;
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
use layout_interface::{DocumentDamageLevel, ContentChangedDocumentDamage};
use servo_util::namespace::Null;

@@ -91,7 +92,8 @@ pub struct Document {
idmap: HashMap<DOMString, AbstractNode>,
implementation: Option<@mut DOMImplementation>,
content_type: DOMString,
url: Url
url: Url,
quirks_mode: QuirksMode
}

impl Document {
@@ -136,7 +138,9 @@ impl Document {
url: match url {
None => from_str("about:blank").unwrap(),
Some(_url) => _url
}
},
// http://dom.spec.whatwg.org/#concept-document-quirks
quirks_mode: NoQuirks
}
}

@@ -191,6 +195,18 @@ impl Document {
self.URL()
}

// http://dom.spec.whatwg.org/#dom-document-compatmode
pub fn CompatMode(&self) -> DOMString {
match self.quirks_mode {
NoQuirks => ~"CSS1Compat",
LimitedQuirks | FullQuirks => ~"BackCompat"
}
}

pub fn set_quirks_mode(&mut self, mode: QuirksMode) {
self.quirks_mode = mode;
}

// http://dom.spec.whatwg.org/#dom-document-content_type
pub fn ContentType(&self) -> DOMString {
self.content_type.clone()
@@ -28,7 +28,8 @@ interface Document : Node {
readonly attribute DOMImplementation implementation;
readonly attribute DOMString URL;
readonly attribute DOMString documentURI;
// readonly attribute DOMString compatMode;
// readonly attribute DOMString origin;
readonly attribute DOMString compatMode;
// readonly attribute DOMString characterSet;
readonly attribute DOMString contentType;

@@ -445,6 +445,7 @@ pub fn parse_html(cx: *JSContext,
},
set_quirks_mode: |_mode| {
debug!("set quirks mode");
document.mut_document().set_quirks_mode(_mode);
},
encoding_change: |_encname| {
debug!("encoding change");
@@ -0,0 +1,21 @@
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: BackCompat
{
is(document.compatMode, "BackCompat", "test1-0, BackCompat");
}

// test2: Non-parsed documents
{
var xmldoc = new Document;
is(xmldoc.compatMode, "CSS1Compat", "test2-0, Non-parsed documents");

var htmldoc = document.implementation.createHTMLDocument("title");
is(htmldoc.compatMode, "CSS1Compat", "test2-1, Non-parsed documents");
}
finish();
</script>
</head>
</html>
@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: Loose HTML
{
is(document.compatMode, "BackCompat", "test1-0, Loose HTML");
}
finish();
</script>
</head>
</html>
@@ -0,0 +1,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="harness.js"></script>
<script>
// test1: Strict HTML
{
is(document.compatMode, "CSS1Compat", "test1-0, Strict HTML");
}
finish();
</script>
</head>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.