Skip to content
Permalink
Browse files

Implemented CSSStyleDeclaration.setPropertyPriority

Implemented CSSStyleDeclaration.setPropertyPriority, resolves #4433
  • Loading branch information...
ProgramFOX committed Dec 23, 2014
1 parent 0109cc3 commit 07d37af37e5c12fd1084ecc5714ef46d874baefa
@@ -200,6 +200,43 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
Ok(())
}

// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertypriority
fn SetPropertyPriority(self, property: DOMString, priority: DOMString) -> ErrorResult {
//TODO: disallow modifications if readonly flag is set

// Step 2
let property = property.as_slice().to_ascii_lower();

// Step 3
if !is_supported_property(property.as_slice()) {
return Ok(());
}

// Step 4
let priority = priority.as_slice().to_ascii_lower();
if priority.as_slice() != "important" && !priority.is_empty() {
return Ok(());
}

let owner = self.owner.root();
let window = window_from_node(*owner).root();
let page = window.page();
let decl_block = parse_style_attribute(property.as_slice(),
&page.get_url());
let element: JSRef<Element> = ElementCast::from_ref(*owner);

// Step 5
for decl in decl_block.normal.iter() {
// Step 6
element.update_inline_style(decl.clone(), !priority.is_empty());
}

let document = document_from_node(element).root();
let node: JSRef<Node> = NodeCast::from_ref(element);
document.content_changed(node, NodeDamage::NodeStyleDamaged);
Ok(())
}

// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
self.SetProperty(property, value, "".to_string())
@@ -20,8 +20,10 @@ interface CSSStyleDeclaration {
[TreatNullAs=EmptyString] optional DOMString priority = "");
[Throws]
void setPropertyValue(DOMString property, [TreatNullAs=EmptyString] DOMString value);
//[Throws]
//void setPropertyPriority(DOMString property, [TreatNullAs=EmptyString] DOMString priority);

[Throws]
void setPropertyPriority(DOMString property, [TreatNullAs=EmptyString] DOMString priority);

DOMString removeProperty(DOMString property);
//readonly attribute CSSRule? parentRule;
[SetterThrows]

5 comments on commit 07d37af

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 23, 2014

saw approval from jdm
at ProgramFOX@07d37af

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 23, 2014

merging ProgramFOX/servo/issue-4433 = 07d37af into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 23, 2014

ProgramFOX/servo/issue-4433 = 07d37af merged ok, testing candidate = 49f2c69

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 23, 2014

fast-forwarding master to auto = 49f2c69

Please sign in to comment.
You can’t perform that action at this time.