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 1 commit
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

addressed majority of review comments

  • Loading branch information
Isha Bobra
Isha Bobra committed Apr 22, 2016
commit 17f919cdb83653727a1801671f33dd2b41cf0e72
@@ -94,6 +94,9 @@ use url::Url;
use util::str::{DOMString, LengthOrPercentageOrAuto};
use uuid::Uuid;
use webrender_traits::WebGLError;
use style::selector_impl::ServoSelectorImpl;
use style::stylesheets::CSSRule;


/// A trait to allow tracing (only) DOM objects.
pub trait JSTraceable {
@@ -324,6 +327,11 @@ no_jsmanaged_fields!(ElementSnapshot);
no_jsmanaged_fields!(HttpsState);
no_jsmanaged_fields!(SharedRt);
no_jsmanaged_fields!(TouchpadPressurePhase);
no_jsmanaged_fields!(ServoSelectorImpl);

impl JSTraceable for CSSRule<ServoSelectorImpl> {
fn trace(&self, _: *mut JSTracer) {}
}

impl JSTraceable for ConstellationChan<ScriptMsg> {
#[inline]
@@ -2,44 +2,36 @@
* 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 dom::cssrule::CSSRule;
use dom::bindings::codegen::Bindings::CSSRuleBinding;
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleConstants;
use dom::bindings::codegen::Bindings::CSSRuleBinding::CSSRuleMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::cssstylerule::CSSStyleRule;
use dom::window::Window;
use util::str::DOMString;
use style::selector_impl::ServoSelectorImpl;
use style::stylesheets;


#[dom_struct]
pub struct CSSRule {
reflector_: Reflector,
/*const STYLE_RULE: u16 = 1;
const unsigned short CHARSET_RULE= 2; // historical
const unsigned short IMPORT_RULE = 3;
const unsigned short MEDIA_RULE = 4;
const unsigned short FONT_FACE_RULE = 5;
const unsigned short PAGE_RULE = 6;
const unsigned short MARGIN_RULE = 9;
const unsigned short NAMESPACE_RULE = 10;*/
type_: u16,
//cssText: DOMString,
rule: stylesheets::CSSRule<ServoSelectorImpl>,
}

impl CSSRule {
#[allow(unrooted_must_root)]
fn new_inherited(type_: u16) -> CSSRule {
fn new_inherited(rule: stylesheets::CSSRule<ServoSelectorImpl>) -> CSSRule {
CSSRule {
reflector_: Reflector::new(),
type_: type_
//cssText: cssText
rule: rule
}
}

#[allow(unrooted_must_root)]
pub fn new(window: &Window, type_: u16) -> Root<CSSRule> {
reflect_dom_object(box CSSRule::new_inherited(type_),
pub fn new(window: &Window, rule: stylesheets::CSSRule<ServoSelectorImpl>) -> Root<CSSRule> {
reflect_dom_object(box CSSRule::new_inherited(rule),
GlobalRef::Window(window),
CSSRuleBinding::Wrap)
}
@@ -49,21 +41,9 @@ impl CSSRuleMethods for CSSRule {
// https://drafts.csswg.org/cssom/#dom-cssrule-type
fn Type_(&self) -> u16 {

if self.eq(&self){
1}
else if self.eq(&self){
3}
else if self.eq(&self){
4}
else if self.eq(&self){
5}
else if self.eq(&self){
6}
else if self.eq(&self){
8}
else if self.eq(&self){
10}
else{
7}
match &self{
CSSStyleRule => CSSRuleConstants::STYLE_RULE,
}
//TODO match for other rules
}
}
@@ -8,27 +8,26 @@ use dom::bindings::global::GlobalRef;
use dom::bindings::js::{JS, Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::cssrule::CSSRule;
//use dom::cssstylesheet::CSSStyleSheet;
use style::servo::Stylesheet;
use dom::cssstylesheet::CSSStyleSheet;
use dom::window::Window;

#[dom_struct]
pub struct CSSRuleList {
reflector_: Reflector,
stylesheet: Stylesheet,
stylesheet: JS<CSSStyleSheet>,
}

impl CSSRuleList {
#[allow(unrooted_must_root)]
fn new_inherited(stylesheet: Stylesheet) -> CSSRuleList {
fn new_inherited(stylesheet: JS<CSSStyleSheet>) -> CSSRuleList {
CSSRuleList {
reflector_: Reflector::new(),
stylesheet: stylesheet
}
}

#[allow(unrooted_must_root)]
pub fn new(window: &Window, stylesheet: Stylesheet) -> Root<CSSRuleList> {
pub fn new(window: &Window, stylesheet: JS<CSSStyleSheet>) -> Root<CSSRuleList> {
reflect_dom_object(box CSSRuleList::new_inherited(stylesheet),
GlobalRef::Window(window), CSSRuleListBinding::Wrap)
}
@@ -37,7 +36,8 @@ impl CSSRuleList {
impl CSSRuleListMethods for CSSRuleList {
// https://drafts.csswg.org/cssom/#dom-stylesheetlist-length
fn Length(&self) -> u32 {
self.stylesheet.rules.len() as u32
//self.stylesheet.cssRules().len() as u32
0
}

// https://drafts.csswg.org/cssom/#dom-stylesheetlist-item
@@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 dom::bindings::codegen::Bindings::CSSStyleRuleBinding;
use dom::bindings::codegen::Bindings::CSSStyleRuleBinding::CSSStyleRuleMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{Root};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::window::Window;
use util::str::DOMString;


#[dom_struct]
pub struct CSSStyleRule {
reflector_: Reflector,
selectortext: DOMString,
}

impl CSSStyleRule {
#[allow(unrooted_must_root)]
fn new_inherited(selectortext: DOMString) -> CSSStyleRule {
CSSStyleRule {
reflector_: Reflector::new(),
selectortext: 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 {
// https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext
fn SelectorText(&self) -> DOMString {
self.selectortext.clone()
}
fn SetSelectorText(&self, value: DOMString) -> (){
}
}
@@ -3,50 +3,43 @@ 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::cssrule::CSSRule;
use dom::cssrulelist::CSSRuleList;
use dom::window::Window;
use style::servo::Stylesheet;
use std::sync::Arc;
use util::str::DOMString;

#[dom_struct]
pub struct CSSStyleSheet {
reflector_: Reflector,
reflector_: Reflector,
stylesheet: Arc<Stylesheet>,
//ownerRule: CSSRule,
//cssRules: CSSRuleList,
cssrules: Root<CSSRuleList>,
}

impl CSSStyleSheet {
#[allow(unrooted_must_root)]
fn new_inherited(stylesheet: Arc<Stylesheet>) -> CSSStyleSheet {
fn new_inherited(stylesheet: Arc<Stylesheet>, cssrules: Root<CSSRuleList>) -> CSSStyleSheet {
CSSStyleSheet {
reflector_: Reflector::new(),
//stylesheet: Arc::new(stylesheet)
reflector_: Reflector::new(),
stylesheet: stylesheet,
cssrules: cssrules, // cssrule: CSSRule::new(),
}
}

#[allow(unrooted_must_root)]
pub fn new(window: &Window, stylesheet: Arc<Stylesheet>) -> Root<CSSStyleSheet> {
reflect_dom_object(box CSSStyleSheet::new_inherited(stylesheet),
pub fn new(window: &Window, stylesheet: Arc<Stylesheet>, cssrules: Root<CSSRuleList>) -> Root<CSSStyleSheet> {
reflect_dom_object(box CSSStyleSheet::new_inherited(stylesheet, cssrules),
GlobalRef::Window(window),
CSSStyleSheetBinding::Wrap)
}
}

impl CSSStyleSheetMethods for CSSStyleSheet {

fn InsertRule(&self, rule: DOMString, index: u32) -> u32 {
0
fn CssRules(&self) -> Root<CSSRuleList> {
/*if self.disabled() == false {
panic!(DOMErrorName::SecurityError)
}
else{*/
self.cssrules.clone()
//}
}

fn DeleteRule(&self, index: u32) {
//self.stylesheet.borrow_mut().rules.remove(index);
}

/*fn CssRules(&self) -> Root<CSSRuleList> {
}*/
}
}
@@ -1814,18 +1814,18 @@ impl Document {
}
}

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

@@ -239,6 +239,7 @@ pub mod crypto;
pub mod css;
pub mod cssrule;
pub mod cssrulelist;
pub mod cssstylerule;
pub mod cssstylesheet;
pub mod cssstyledeclaration;
pub mod customevent;
@@ -1,12 +1,12 @@
interface CSSRule {
const unsigned short STYLE_RULE = 1;
/*const unsigned short CHARSET_RULE= 2; // historical
const unsigned short CHARSET_RULE= 2; // historical
const unsigned short IMPORT_RULE = 3;
const unsigned short MEDIA_RULE = 4;
const unsigned short FONT_FACE_RULE = 5;
const unsigned short PAGE_RULE = 6;
const unsigned short MARGIN_RULE = 9;
const unsigned short NAMESPACE_RULE = 10;*/
const unsigned short NAMESPACE_RULE = 10;
readonly attribute unsigned short type_;
//attribute DOMString cssText;
//readonly attribute CSSRule? parentRule;
@@ -0,0 +1,10 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

// https://drafts.csswg.org/cssom/#the-CSSStyleRule-interface
interface CSSStyleRule : CSSRule {
attribute DOMString selectorText;
//[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
@@ -1,7 +1,7 @@

interface CSSStyleSheet : StyleSheet {
//readonly attribute CSSRule? ownerRule;
//[SameObject] readonly attribute CSSRuleList cssRules;
unsigned long insertRule(DOMString rule, unsigned long index);
void deleteRule(unsigned long index);
};
[SameObject] readonly attribute CSSRuleList cssRules;
//unsigned long insertRule(DOMString rule, unsigned long index);
//void deleteRule(unsigned long index);
};
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.