mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #4471 : ProgramFOX/servo/issue-4433, r=jdm
Implemented CSSStyleDeclaration.setPropertyPriority, resolves #4433.
This commit is contained in:
commit
49f2c6974d
2 changed files with 41 additions and 2 deletions
|
@ -200,6 +200,43 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
||||||
Ok(())
|
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
|
// http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
|
||||||
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
|
fn SetPropertyValue(self, property: DOMString, value: DOMString) -> ErrorResult {
|
||||||
self.SetProperty(property, value, "".to_string())
|
self.SetProperty(property, value, "".to_string())
|
||||||
|
|
|
@ -20,8 +20,10 @@ interface CSSStyleDeclaration {
|
||||||
[TreatNullAs=EmptyString] optional DOMString priority = "");
|
[TreatNullAs=EmptyString] optional DOMString priority = "");
|
||||||
[Throws]
|
[Throws]
|
||||||
void setPropertyValue(DOMString property, [TreatNullAs=EmptyString] DOMString value);
|
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);
|
DOMString removeProperty(DOMString property);
|
||||||
//readonly attribute CSSRule? parentRule;
|
//readonly attribute CSSRule? parentRule;
|
||||||
[SetterThrows]
|
[SetterThrows]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue