mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Stop parsing style attributes during restyle in geckolib.
This commit is contained in:
parent
ba30d72679
commit
98a32a76df
3 changed files with 83 additions and 18 deletions
|
@ -15,12 +15,14 @@ use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetLastChildElement};
|
|||
use gecko_bindings::bindings::{Gecko_GetNextSibling, Gecko_GetNextSiblingElement};
|
||||
use gecko_bindings::bindings::{Gecko_GetParentElement, Gecko_GetParentNode};
|
||||
use gecko_bindings::bindings::{Gecko_GetPrevSibling, Gecko_GetPrevSiblingElement};
|
||||
use gecko_bindings::bindings::{Gecko_IsHTMLElementInHTMLDocument, Gecko_IsLink, Gecko_IsRootElement, Gecko_IsTextNode};
|
||||
use gecko_bindings::bindings::{Gecko_GetServoDeclarationBlock, Gecko_IsHTMLElementInHTMLDocument};
|
||||
use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement, Gecko_IsTextNode};
|
||||
use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink};
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use gecko_bindings::bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsElement, Gecko_SetNodeData};
|
||||
use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use gecko_bindings::structs::nsIAtom;
|
||||
use glue::GeckoDeclarationBlock;
|
||||
use libc::uintptr_t;
|
||||
use properties::GeckoComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PrivateStyleData};
|
||||
|
@ -317,6 +319,15 @@ impl<'le> GeckoElement<'le> {
|
|||
unsafe fn from_ref(el: &RawGeckoElement) -> GeckoElement<'le> {
|
||||
GeckoElement::from_raw(el as *const RawGeckoElement as *mut RawGeckoElement)
|
||||
}
|
||||
|
||||
pub fn parse_style_attribute(value: &str) -> Option<PropertyDeclarationBlock> {
|
||||
// FIXME(bholley): Real base URL and error reporter.
|
||||
let base_url = &*DUMMY_BASE_URL;
|
||||
// FIXME(heycam): Needs real ParserContextExtraData so that URLs parse
|
||||
// properly.
|
||||
let extra_data = ParserContextExtraData::default();
|
||||
Some(parse_style_attribute(value, &base_url, Box::new(StdoutErrorReporter), extra_data))
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
|
@ -325,6 +336,8 @@ lazy_static! {
|
|||
};
|
||||
}
|
||||
|
||||
static NO_STYLE_ATTRIBUTE: Option<PropertyDeclarationBlock> = None;
|
||||
|
||||
impl<'le> TElement for GeckoElement<'le> {
|
||||
type ConcreteNode = GeckoNode<'le>;
|
||||
type ConcreteDocument = GeckoDocument<'le>;
|
||||
|
@ -334,20 +347,10 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
}
|
||||
|
||||
fn style_attribute(&self) -> &Option<PropertyDeclarationBlock> {
|
||||
panic!("Requires signature modification - only implemented in stylo branch");
|
||||
/*
|
||||
// FIXME(bholley): We should do what Servo does here. Gecko needs to
|
||||
// call into the Servo CSS parser and then cache the resulting block
|
||||
// in the nsAttrValue. That will allow us to borrow it from here.
|
||||
let attr = self.get_attr(&ns!(), &atom!("style"));
|
||||
// FIXME(bholley): Real base URL and error reporter.
|
||||
let base_url = &*DUMMY_BASE_URL;
|
||||
// FIXME(heycam): Needs real ParserContextExtraData so that URLs parse
|
||||
// properly.
|
||||
let extra_data = ParserContextExtraData::default();
|
||||
attr.map(|v| parse_style_attribute(&v, &base_url, Box::new(StdoutErrorReporter),
|
||||
extra_data))
|
||||
*/
|
||||
unsafe {
|
||||
let ptr = Gecko_GetServoDeclarationBlock(self.element) as *mut GeckoDeclarationBlock;
|
||||
ptr.as_ref().map(|d| &d.declarations).unwrap_or(&NO_STYLE_ATTRIBUTE)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_state(&self) -> ElementState {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue