mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use PropertyId instead of Atom for CSSStyleDeclaration::get_computed_style
This commit is contained in:
parent
fdc40592de
commit
58d452fa4e
9 changed files with 85 additions and 85 deletions
|
@ -12,7 +12,6 @@ use dom::element::Element;
|
|||
use dom::node::{Node, NodeDamage, window_from_node};
|
||||
use dom::window::Window;
|
||||
use parking_lot::RwLock;
|
||||
use servo_atoms::Atom;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::sync::Arc;
|
||||
use style::parser::ParserContextExtraData;
|
||||
|
@ -74,12 +73,12 @@ impl CSSStyleDeclaration {
|
|||
CSSStyleDeclarationBinding::Wrap)
|
||||
}
|
||||
|
||||
fn get_computed_style(&self, property: &Atom) -> Option<DOMString> {
|
||||
fn get_computed_style(&self, property: PropertyId) -> DOMString {
|
||||
let node = self.owner.upcast::<Node>();
|
||||
if !node.is_in_doc() {
|
||||
// TODO: Node should be matched against the style rules of this window.
|
||||
// Firefox is currently the only browser to implement this.
|
||||
return None;
|
||||
return DOMString::new();
|
||||
}
|
||||
let addr = node.to_trusted_node_address();
|
||||
window_from_node(&*self.owner).resolved_style_query(addr, self.pseudo.clone(), property)
|
||||
|
@ -103,14 +102,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
}
|
||||
|
||||
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
|
||||
fn GetPropertyValue(&self, mut property: DOMString) -> DOMString {
|
||||
if self.readonly {
|
||||
// Readonly style declarations are used for getComputedStyle.
|
||||
property.make_ascii_lowercase();
|
||||
let property = Atom::from(property);
|
||||
return self.get_computed_style(&property).unwrap_or(DOMString::new());
|
||||
}
|
||||
|
||||
fn GetPropertyValue(&self, property: DOMString) -> DOMString {
|
||||
let id = if let Ok(id) = PropertyId::parse(property.into()) {
|
||||
id
|
||||
} else {
|
||||
|
@ -118,6 +110,11 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
return DOMString::new()
|
||||
};
|
||||
|
||||
if self.readonly {
|
||||
// Readonly style declarations are used for getComputedStyle.
|
||||
return self.get_computed_style(id);
|
||||
}
|
||||
|
||||
let style_attribute = self.owner.style_attribute().borrow();
|
||||
let style_attribute = if let Some(ref lock) = *style_attribute {
|
||||
lock.read()
|
||||
|
|
|
@ -92,6 +92,7 @@ use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
|
|||
use style::context::ReflowGoal;
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
use style::media_queries;
|
||||
use style::properties::PropertyId;
|
||||
use style::properties::longhands::overflow_x;
|
||||
use style::selector_parser::PseudoElement;
|
||||
use style::str::HTML_SPACE_CHARACTERS;
|
||||
|
@ -1295,16 +1296,16 @@ impl Window {
|
|||
}
|
||||
|
||||
pub fn resolved_style_query(&self,
|
||||
element: TrustedNodeAddress,
|
||||
pseudo: Option<PseudoElement>,
|
||||
property: &Atom) -> Option<DOMString> {
|
||||
element: TrustedNodeAddress,
|
||||
pseudo: Option<PseudoElement>,
|
||||
property: PropertyId) -> DOMString {
|
||||
if !self.reflow(ReflowGoal::ForScriptQuery,
|
||||
ReflowQueryType::ResolvedStyleQuery(element, pseudo, property.clone()),
|
||||
ReflowQueryType::ResolvedStyleQuery(element, pseudo, property),
|
||||
ReflowReason::Query) {
|
||||
return None;
|
||||
return DOMString::new();
|
||||
}
|
||||
let ResolvedStyleResponse(resolved) = self.layout_rpc.resolved_style();
|
||||
resolved.map(DOMString::from)
|
||||
DOMString::from(resolved)
|
||||
}
|
||||
|
||||
pub fn offset_parent_query(&self, node: TrustedNodeAddress) -> (Option<Root<Element>>, Rect<Au>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue