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

CSSRule, CSSRuleList, CSSStyleSheet partial implementation #10765

Closed
wants to merge 32 commits into from
Closed
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a51248b
CSSRule, CSSRuleList, CSSStyleSheet partial implementation
srm09 Apr 20, 2016
17f919c
addressed majority of review comments
Apr 22, 2016
bb6427b
Resolved review comments with window error persisting
Apr 24, 2016
c4dfe14
review comments
Apr 25, 2016
5d0fadc
Fixed review comments and implementations
srm09 Apr 27, 2016
47dce3a
CSSRule, CSSRuleList, CSSStyleSheet partial implementation
srm09 Apr 20, 2016
5f8a60c
addressed majority of review comments
Apr 22, 2016
e9b0163
Resolved review comments with window error persisting
Apr 24, 2016
eca5bf6
Addressed review comments and implementations
srm09 Apr 27, 2016
378a2f4
Fixed Tidy Tests
Apr 6, 2016
7bb79a1
tried to fix review comments
May 1, 2016
3577d97
Solved cssstylesheet cssrule issue
May 1, 2016
08ddcbb
Added get owner node method
srm09 May 1, 2016
383a8d4
Added length for css rules:
May 1, 2016
1323d80
Solved tidy issues
May 1, 2016
7c88de0
Merge branch 'tmp' of https://github.com/mohammed-alfatih/servo into tmp
May 1, 2016
6557b73
get_nth
May 2, 2016
b9812fd
Called CSSRuleList::new
srm09 May 2, 2016
44ea6ea
Addressed all review comments
May 2, 2016
6f20811
CSSRule, CSSRuleList, CSSStyleSheet partial implementation
srm09 Apr 20, 2016
891f118
addressed majority of review comments
Apr 22, 2016
022593f
Resolved review comments with window error persisting
Apr 24, 2016
da035ae
review comments
Apr 25, 2016
231e66b
Fixed review comments and implementations
srm09 Apr 27, 2016
cad69ca
CSSRule, CSSRuleList, CSSStyleSheet partial implementation
srm09 Apr 20, 2016
cc94b6a
addressed majority of review comments
Apr 22, 2016
bb4a897
Resolved review comments with window error persisting
Apr 24, 2016
ff9a6e7
Fixed Tidy Tests
Apr 6, 2016
1ee1950
tried to fix review comments
May 1, 2016
022946c
Merge branch 'tmp' into sub
srm09 May 2, 2016
6714691
Fixed tidy tests
srm09 May 2, 2016
95fe153
fixed test expectations
May 3, 2016
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -38,7 +38,7 @@ impl CSSRuleList {
impl CSSRuleListMethods for CSSRuleList {
// https://drafts.csswg.org/cssom/#dom-stylesheetlist-length
fn Length(&self) -> u32 {
(self.stylesheet).deref().CssRules().Length()
(self.stylesheet).deref().get_cssstylesheet().rules.len() as u32
}

// https://drafts.csswg.org/cssom/#dom-stylesheetlist-item
@@ -9,9 +9,10 @@ use dom::bindings::js::Root;
use dom::bindings::reflector::reflect_dom_object;
use dom::cssrule::CSSRule;
use dom::window::Window;
use std::string::String;
use style::stylesheets;
use util::str::DOMString;


#[dom_struct]
pub struct CSSStyleRule {
cssrule: CSSRule,
@@ -20,19 +21,19 @@ pub struct CSSStyleRule {

impl CSSStyleRule {
#[allow(unrooted_must_root)]
fn new_inherited(cssrule: CSSRule, selectortext: DOMString) -> CSSStyleRule {
fn new_inherited(selectortext: DOMString) -> CSSStyleRule {
CSSStyleRule {
cssrule: cssrule,
cssrule: CSSRule::new_inherited(stylesheets::CSSRule::Charset(String::from(selectortext.clone()))),
selectortext: selectortext,
}
}

/*#[allow(unrooted_must_root)]
pub fn new(window: &Window, cssrule: CSSRule, selectortext: DOMString) -> Root<CSSStyleRule> {
reflect_dom_object(box CSSStyleRule::new_inherited(cssrule, selectortext),
#[allow(unrooted_must_root)]
pub fn new(window: &Window, selectortext: DOMString) -> Root<CSSStyleRule> {
reflect_dom_object(box CSSStyleRule::new_inherited(selectortext),
GlobalRef::Window(window),
CSSStyleRuleBinding::Wrap)
}*/
}
}

impl CSSStyleRuleMethods for CSSStyleRule {
@@ -2,11 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use core::ops::Deref;
use dom::bindings::codegen::Bindings::CSSStyleSheetBinding;
use dom::bindings::codegen::Bindings::CSSStyleSheetBinding::CSSStyleSheetMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{reflect_dom_object};
use dom::cssrulelist::CSSRuleList;
use dom::stylesheet::StyleSheet;
use dom::window::Window;
@@ -18,20 +19,22 @@ use util::str::DOMString;
pub struct CSSStyleSheet {
ss: StyleSheet,
stylesheet: Arc<Stylesheet>,
window: JS<Window>,
}

impl CSSStyleSheet {
#[allow(unrooted_must_root)]
fn new_inherited(stylesheet: Arc<Stylesheet>) -> CSSStyleSheet {
fn new_inherited(window: &Window, stylesheet: Arc<Stylesheet>) -> CSSStyleSheet {
CSSStyleSheet {
ss: StyleSheet::new_inherited(DOMString::from_string(String::from("text/css")), None, None, None),
stylesheet: stylesheet,
window: JS::from_ref(window),
}
}

#[allow(unrooted_must_root)]
pub fn new(window: &Window, stylesheet: Arc<Stylesheet>) -> Root<CSSStyleSheet> {
reflect_dom_object(box CSSStyleSheet::new_inherited(stylesheet),
reflect_dom_object(box CSSStyleSheet::new_inherited(window, stylesheet),
GlobalRef::Window(window),
CSSStyleSheetBinding::Wrap)
}
@@ -42,9 +45,8 @@ impl CSSStyleSheet {
}

impl CSSStyleSheetMethods for CSSStyleSheet {
// https://drafts.csswg.org/cssom/#dom-stylesheetlist-cssrules
// https://drafts.csswg.org/cssom/#dom-stylesheetlist-cssrules
fn CssRules(&self) -> Root<CSSRuleList> {
// TODO: step 1
Root::from_ref(&CSSRuleList::new_inherited(&self))
Root::from_ref(&CSSRuleList::new(self.window.deref(), &self))
}
}
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use core::ops::Deref;
use devtools_traits::CSSError;
use document_loader::{DocumentLoader, LoadType};
use dom::activation::{ActivationSource, synthetic_click_activation};
@@ -75,7 +76,6 @@ use dom::range::Range;
use dom::servohtmlparser::{ParserRoot, ParserRef, MutNullableParserField};
use dom::storageevent::StorageEvent;
use dom::stylesheetlist::StyleSheetList;
use dom::cssstylesheet::CSSStyleSheet;
use dom::text::Text;
use dom::touch::Touch;
use dom::touchevent::TouchEvent;
@@ -1828,12 +1828,11 @@ impl Document {
return self.referrer_policy.clone();
}

/*pub fn get_nth_cssstylesheet(&self, index: u32) -> Root<CSSStyleSheet> {
let mut stylesheets = self.stylesheets.borrow_mut();
let (ref mut node, ref mut sheet) = (*self.stylesheets.borrow()).unwrap()[index as usize];
CSSStyleSheet::new(&self.window, *sheet, ? )
}*/
pub fn get_nth_cssstylesheet(&self, index: u32) -> Root<CSSStyleSheet> {
let (ref mut node, ref mut sheet) = (self.stylesheets.borrow().clone()).unwrap()[index as usize];
let x = sheet.clone();
CSSStyleSheet::new(&self.window, x)
}
}


@@ -16,7 +16,6 @@ use dom::processinginstruction::ProcessingInstruction;
use dom::window::Window;
use util::str::DOMString;


#[dom_struct]
pub struct StyleSheet {
reflector_: Reflector,
@@ -37,7 +36,9 @@ impl StyleSheet {
type_: type_,
href: href,
title: title,
owner: Some(JS::from_ref(owner.unwrap()))
owner: owner.map(|node: &Node| {
JS::from_ref(node)
})
}
}

@@ -69,23 +70,15 @@ impl StyleSheetMethods for StyleSheet {
self.title.clone()
}

<<<<<<< ff9a6e7df127f956a80b5e0c9859d00b8db0d4dc
// https://drafts.csswg.org/cssom/#dom-stylesheet-title
fn GetOwnerNode(&self) -> Option<UnionTypes::ElementOrProcessingInstruction>{
None
}
=======
// https://drafts.csswg.org/cssom/#dom-stylesheet-ownernode
/* fn GetOwnerNode(&self) -> Option<UnionTypes::ElementOrProcessingInstruction>{
//None
if let Some(Element) = Some(Root::downcast::<Element>(Root::from_ref(self.owner.unwrap().deref()))){
let x = Root::downcast::<Element>(Root::from_ref(self.owner.unwrap().deref()));
UnionTypes::ElementOrProcessingInstruction::Element(x.unwrap());
}
else{
let x = Root::downcast::<ProcessingInstruction>(Root::from_ref(self.owner.unwrap().deref()));
UnionTypes::ElementOrProcessingInstruction::ProcessingInstruction(x.unwrap());
}
}*/
>>>>>>> tried to fix review comments
fn GetOwnerNode(&self) -> Option<UnionTypes::ElementOrProcessingInstruction>{
self.owner.as_ref().map(|owner: &JS<Node>| {
if let Some(elem) = Root::downcast::<Element>(Root::from_ref(owner.deref())) {
UnionTypes::ElementOrProcessingInstruction::Element(elem)
} else {
let instr: Option<Root<ProcessingInstruction>> = Root::downcast::<ProcessingInstruction>(Root::from_ref(owner.deref()));
UnionTypes::ElementOrProcessingInstruction::ProcessingInstruction(instr.unwrap())
}
})
}
}
@@ -6,7 +6,7 @@
interface StyleSheet {
readonly attribute DOMString type_;
readonly attribute DOMString? href;
//readonly attribute (Element or ProcessingInstruction)? ownerNode;
readonly attribute (Element or ProcessingInstruction)? ownerNode;
// readonly attribute StyleSheet? parentStyleSheet;
readonly attribute DOMString? title;

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.