mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
stylo: Create error reporters linked to documents (bug 1352669)
This commit is contained in:
parent
4b91014b14
commit
a08371e8eb
19 changed files with 5536 additions and 4324 deletions
|
@ -219,9 +219,6 @@ pub struct LayoutThread {
|
||||||
/// All the other elements of this struct are read-only.
|
/// All the other elements of this struct are read-only.
|
||||||
rw_data: Arc<Mutex<LayoutThreadData>>,
|
rw_data: Arc<Mutex<LayoutThreadData>>,
|
||||||
|
|
||||||
/// The CSS error reporter for all CSS loaded in this layout thread
|
|
||||||
error_reporter: CSSErrorReporter,
|
|
||||||
|
|
||||||
webrender_image_cache: Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder),
|
webrender_image_cache: Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder),
|
||||||
WebRenderImageInfo>>>,
|
WebRenderImageInfo>>>,
|
||||||
/// The executor for paint worklets.
|
/// The executor for paint worklets.
|
||||||
|
@ -532,10 +529,6 @@ impl LayoutThread {
|
||||||
text_index_response: TextIndexResponse(None),
|
text_index_response: TextIndexResponse(None),
|
||||||
nodes_from_point_response: vec![],
|
nodes_from_point_response: vec![],
|
||||||
})),
|
})),
|
||||||
error_reporter: CSSErrorReporter {
|
|
||||||
pipelineid: id,
|
|
||||||
script_chan: Arc::new(Mutex::new(script_chan)),
|
|
||||||
},
|
|
||||||
webrender_image_cache:
|
webrender_image_cache:
|
||||||
Arc::new(RwLock::new(FnvHashMap::default())),
|
Arc::new(RwLock::new(FnvHashMap::default())),
|
||||||
timer:
|
timer:
|
||||||
|
@ -580,7 +573,6 @@ impl LayoutThread {
|
||||||
guards: guards,
|
guards: guards,
|
||||||
running_animations: self.running_animations.clone(),
|
running_animations: self.running_animations.clone(),
|
||||||
expired_animations: self.expired_animations.clone(),
|
expired_animations: self.expired_animations.clone(),
|
||||||
error_reporter: &self.error_reporter,
|
|
||||||
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
|
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
|
||||||
timer: self.timer.clone(),
|
timer: self.timer.clone(),
|
||||||
quirks_mode: self.quirks_mode.unwrap(),
|
quirks_mode: self.quirks_mode.unwrap(),
|
||||||
|
|
|
@ -508,7 +508,6 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
|
||||||
previous_style,
|
previous_style,
|
||||||
/* cascade_info = */ None,
|
/* cascade_info = */ None,
|
||||||
/* visited_style = */ None,
|
/* visited_style = */ None,
|
||||||
&*context.error_reporter,
|
|
||||||
font_metrics_provider,
|
font_metrics_provider,
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
context.quirks_mode);
|
context.quirks_mode);
|
||||||
|
|
|
@ -12,7 +12,6 @@ use bloom::StyleBloom;
|
||||||
use cache::LRUCache;
|
use cache::LRUCache;
|
||||||
use data::{EagerPseudoStyles, ElementData};
|
use data::{EagerPseudoStyles, ElementData};
|
||||||
use dom::{OpaqueNode, TNode, TElement, SendElement};
|
use dom::{OpaqueNode, TNode, TElement, SendElement};
|
||||||
use error_reporting::ParseErrorReporter;
|
|
||||||
use euclid::Size2D;
|
use euclid::Size2D;
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use font_metrics::FontMetricsProvider;
|
use font_metrics::FontMetricsProvider;
|
||||||
|
@ -122,9 +121,6 @@ pub struct SharedStyleContext<'a> {
|
||||||
/// Guards for pre-acquired locks
|
/// Guards for pre-acquired locks
|
||||||
pub guards: StylesheetGuards<'a>,
|
pub guards: StylesheetGuards<'a>,
|
||||||
|
|
||||||
///The CSS error reporter for all CSS loaded in this layout thread
|
|
||||||
pub error_reporter: &'a ParseErrorReporter,
|
|
||||||
|
|
||||||
/// The current timer for transitions and animations. This is needed to test
|
/// The current timer for transitions and animations. This is needed to test
|
||||||
/// them.
|
/// them.
|
||||||
pub timer: Timer,
|
pub timer: Timer,
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl<'a> ContextualParseError<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A generic trait for an error reporter.
|
/// A generic trait for an error reporter.
|
||||||
pub trait ParseErrorReporter : Sync {
|
pub trait ParseErrorReporter {
|
||||||
/// Called when the style engine detects an error.
|
/// Called when the style engine detects an error.
|
||||||
///
|
///
|
||||||
/// Returns the current input being parsed, the source position it was
|
/// Returns the current input being parsed, the source position it was
|
||||||
|
@ -188,8 +188,3 @@ impl ParseErrorReporter for NullReporter {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an instance of the default error reporter.
|
|
||||||
pub fn create_error_reporter() -> RustLogReporter {
|
|
||||||
RustLogReporter
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ use gecko_bindings::structs::nsTArray;
|
||||||
type nsACString_internal = nsACString;
|
type nsACString_internal = nsACString;
|
||||||
type nsAString_internal = nsAString;
|
type nsAString_internal = nsAString;
|
||||||
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
||||||
|
use gecko_bindings::structs::mozilla::css::ErrorReporter;
|
||||||
use gecko_bindings::structs::mozilla::css::ImageValue;
|
use gecko_bindings::structs::mozilla::css::ImageValue;
|
||||||
use gecko_bindings::structs::mozilla::css::URLValue;
|
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||||
|
@ -71,6 +72,7 @@ use gecko_bindings::structs::nsChangeHint;
|
||||||
use gecko_bindings::structs::nsCursorImage;
|
use gecko_bindings::structs::nsCursorImage;
|
||||||
use gecko_bindings::structs::nsFont;
|
use gecko_bindings::structs::nsFont;
|
||||||
use gecko_bindings::structs::nsIAtom;
|
use gecko_bindings::structs::nsIAtom;
|
||||||
|
use gecko_bindings::structs::nsIURI;
|
||||||
use gecko_bindings::structs::nsCompatibility;
|
use gecko_bindings::structs::nsCompatibility;
|
||||||
use gecko_bindings::structs::nsMediaFeature;
|
use gecko_bindings::structs::nsMediaFeature;
|
||||||
use gecko_bindings::structs::nsRestyleHint;
|
use gecko_bindings::structs::nsRestyleHint;
|
||||||
|
@ -2262,7 +2264,8 @@ extern "C" {
|
||||||
value: *const nsACString,
|
value: *const nsACString,
|
||||||
data: *mut RawGeckoURLExtraData,
|
data: *mut RawGeckoURLExtraData,
|
||||||
parsing_mode: ParsingMode,
|
parsing_mode: ParsingMode,
|
||||||
quirks_mode: nsCompatibility)
|
quirks_mode: nsCompatibility,
|
||||||
|
loader: *mut Loader)
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -2411,7 +2414,8 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ParseStyleAttribute(data: *const nsACString,
|
pub fn Servo_ParseStyleAttribute(data: *const nsACString,
|
||||||
extra_data: *mut RawGeckoURLExtraData,
|
extra_data: *mut RawGeckoURLExtraData,
|
||||||
quirks_mode: nsCompatibility)
|
quirks_mode: nsCompatibility,
|
||||||
|
loader: *mut Loader)
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -2480,8 +2484,8 @@ extern "C" {
|
||||||
is_important: bool,
|
is_important: bool,
|
||||||
data: *mut RawGeckoURLExtraData,
|
data: *mut RawGeckoURLExtraData,
|
||||||
parsing_mode: ParsingMode,
|
parsing_mode: ParsingMode,
|
||||||
quirks_mode: nsCompatibility)
|
quirks_mode: nsCompatibility,
|
||||||
-> bool;
|
loader: *mut Loader) -> bool;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_DeclarationBlock_SetPropertyById(declarations:
|
pub fn Servo_DeclarationBlock_SetPropertyById(declarations:
|
||||||
|
@ -2493,7 +2497,8 @@ extern "C" {
|
||||||
*mut RawGeckoURLExtraData,
|
*mut RawGeckoURLExtraData,
|
||||||
parsing_mode: ParsingMode,
|
parsing_mode: ParsingMode,
|
||||||
quirks_mode:
|
quirks_mode:
|
||||||
nsCompatibility)
|
nsCompatibility,
|
||||||
|
loader: *mut Loader)
|
||||||
-> bool;
|
-> bool;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -2891,3 +2896,23 @@ extern "C" {
|
||||||
ServoComputedValuesBorrowedOrNull)
|
ServoComputedValuesBorrowedOrNull)
|
||||||
-> *const nsStyleEffects;
|
-> *const nsStyleEffects;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
|
||||||
|
loader: *mut Loader, uri: *mut nsIURI)
|
||||||
|
-> *mut ErrorReporter;
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_DestroyCSSErrorReporter(reporter: *mut ErrorReporter);
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Gecko_ReportUnexpectedCSSError(reporter: *mut ErrorReporter,
|
||||||
|
message:
|
||||||
|
*const ::std::os::raw::c_char,
|
||||||
|
param:
|
||||||
|
*const ::std::os::raw::c_char,
|
||||||
|
paramLen: u32,
|
||||||
|
source:
|
||||||
|
*const ::std::os::raw::c_char,
|
||||||
|
sourceLen: u32, lineNumber: u32,
|
||||||
|
colNumber: u32, aURI: *mut nsIURI);
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -23,7 +23,7 @@ use data::ElementData;
|
||||||
use dom::{self, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode};
|
use dom::{self, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode};
|
||||||
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
|
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
|
||||||
use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE};
|
use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE};
|
||||||
use error_reporting::create_error_reporter;
|
use error_reporting::ParseErrorReporter;
|
||||||
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
|
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
|
||||||
use gecko::data::PerDocumentStyleData;
|
use gecko::data::PerDocumentStyleData;
|
||||||
use gecko::global_style_data::GLOBAL_STYLE_DATA;
|
use gecko::global_style_data::GLOBAL_STYLE_DATA;
|
||||||
|
@ -478,8 +478,9 @@ impl<'le> GeckoElement<'le> {
|
||||||
/// Parse the style attribute of an element.
|
/// Parse the style attribute of an element.
|
||||||
pub fn parse_style_attribute(value: &str,
|
pub fn parse_style_attribute(value: &str,
|
||||||
url_data: &UrlExtraData,
|
url_data: &UrlExtraData,
|
||||||
quirks_mode: QuirksMode) -> PropertyDeclarationBlock {
|
quirks_mode: QuirksMode,
|
||||||
parse_style_attribute(value, url_data, &create_error_reporter(), quirks_mode)
|
reporter: &ParseErrorReporter) -> PropertyDeclarationBlock {
|
||||||
|
parse_style_attribute(value, url_data, reporter, quirks_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flags(&self) -> u32 {
|
fn flags(&self) -> u32 {
|
||||||
|
|
|
@ -401,7 +401,6 @@ trait PrivateMatchMethods: TElement {
|
||||||
layout_parent_style,
|
layout_parent_style,
|
||||||
visited_values_to_insert,
|
visited_values_to_insert,
|
||||||
Some(&mut cascade_info),
|
Some(&mut cascade_info),
|
||||||
&*shared_context.error_reporter,
|
|
||||||
font_metrics_provider,
|
font_metrics_provider,
|
||||||
cascade_flags,
|
cascade_flags,
|
||||||
shared_context.quirks_mode));
|
shared_context.quirks_mode));
|
||||||
|
|
|
@ -314,8 +314,7 @@
|
||||||
default_style: &ComputedValues,
|
default_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
cacheable: &mut bool,
|
cacheable: &mut bool,
|
||||||
cascade_info: &mut Option<<&mut CascadeInfo>,
|
cascade_info: &mut Option<<&mut CascadeInfo>) {
|
||||||
error_reporter: &ParseErrorReporter) {
|
|
||||||
let declared_value = match *declaration {
|
let declared_value = match *declaration {
|
||||||
PropertyDeclaration::${property.camel_case}(ref value) => {
|
PropertyDeclaration::${property.camel_case}(ref value) => {
|
||||||
DeclaredValue::Value(value)
|
DeclaredValue::Value(value)
|
||||||
|
@ -424,15 +423,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, error_reporter, quirks_mode);
|
}, quirks_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
% if property.custom_cascade:
|
% if property.custom_cascade:
|
||||||
cascade_property_custom(declaration,
|
cascade_property_custom(declaration,
|
||||||
inherited_style,
|
inherited_style,
|
||||||
context,
|
context,
|
||||||
cacheable,
|
cacheable);
|
||||||
error_reporter);
|
|
||||||
% endif
|
% endif
|
||||||
% else:
|
% else:
|
||||||
// Do not allow stylesheets to set derived properties.
|
// Do not allow stylesheets to set derived properties.
|
||||||
|
|
|
@ -523,7 +523,6 @@ impl AnimationValue {
|
||||||
/// Construct an AnimationValue from a property declaration
|
/// Construct an AnimationValue from a property declaration
|
||||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
||||||
initial: &ComputedValues) -> Option<Self> {
|
initial: &ComputedValues) -> Option<Self> {
|
||||||
use error_reporting::create_error_reporter;
|
|
||||||
use properties::LonghandId;
|
use properties::LonghandId;
|
||||||
use properties::DeclaredValue;
|
use properties::DeclaredValue;
|
||||||
|
|
||||||
|
@ -587,7 +586,6 @@ impl AnimationValue {
|
||||||
},
|
},
|
||||||
PropertyDeclaration::WithVariables(id, ref variables) => {
|
PropertyDeclaration::WithVariables(id, ref variables) => {
|
||||||
let custom_props = context.style().custom_properties();
|
let custom_props = context.style().custom_properties();
|
||||||
let reporter = create_error_reporter();
|
|
||||||
match id {
|
match id {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
|
@ -612,7 +610,6 @@ impl AnimationValue {
|
||||||
};
|
};
|
||||||
result = AnimationValue::from_declaration(&declaration, context, initial);
|
result = AnimationValue::from_declaration(&declaration, context, initial);
|
||||||
},
|
},
|
||||||
&reporter,
|
|
||||||
quirks_mode);
|
quirks_mode);
|
||||||
result
|
result
|
||||||
},
|
},
|
||||||
|
|
|
@ -136,8 +136,7 @@
|
||||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||||
_inherited_style: &ComputedValues,
|
_inherited_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
_cacheable: &mut bool,
|
_cacheable: &mut bool) {
|
||||||
_error_reporter: &ParseErrorReporter) {
|
|
||||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
||||||
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
||||||
longhands::_servo_under_display_none::derive_from_display(context);
|
longhands::_servo_under_display_none::derive_from_display(context);
|
||||||
|
|
|
@ -261,8 +261,7 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||||
_inherited_style: &ComputedValues,
|
_inherited_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
_cacheable: &mut bool,
|
_cacheable: &mut bool) {
|
||||||
_error_reporter: &ParseErrorReporter) {
|
|
||||||
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -21,10 +21,10 @@ use app_units::Au;
|
||||||
#[cfg(feature = "servo")] use cssparser::RGBA;
|
#[cfg(feature = "servo")] use cssparser::RGBA;
|
||||||
use cssparser::{Parser, TokenSerializationType, serialize_identifier};
|
use cssparser::{Parser, TokenSerializationType, serialize_identifier};
|
||||||
use cssparser::{ParserInput, CompactCowStr};
|
use cssparser::{ParserInput, CompactCowStr};
|
||||||
use error_reporting::ParseErrorReporter;
|
|
||||||
#[cfg(feature = "servo")] use euclid::SideOffsets2D;
|
#[cfg(feature = "servo")] use euclid::SideOffsets2D;
|
||||||
use computed_values;
|
use computed_values;
|
||||||
use context::QuirksMode;
|
use context::QuirksMode;
|
||||||
|
use error_reporting::NullReporter;
|
||||||
use font_metrics::FontMetricsProvider;
|
use font_metrics::FontMetricsProvider;
|
||||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings;
|
#[cfg(feature = "gecko")] use gecko_bindings::bindings;
|
||||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID};
|
#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID};
|
||||||
|
@ -377,7 +377,6 @@ impl PropertyDeclarationIdSet {
|
||||||
% endif
|
% endif
|
||||||
custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
f: &mut F,
|
f: &mut F,
|
||||||
error_reporter: &ParseErrorReporter,
|
|
||||||
quirks_mode: QuirksMode)
|
quirks_mode: QuirksMode)
|
||||||
% if property.boxed:
|
% if property.boxed:
|
||||||
where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
|
where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
|
||||||
|
@ -392,7 +391,6 @@ impl PropertyDeclarationIdSet {
|
||||||
with_variables.from_shorthand,
|
with_variables.from_shorthand,
|
||||||
custom_properties,
|
custom_properties,
|
||||||
f,
|
f,
|
||||||
error_reporter,
|
|
||||||
quirks_mode);
|
quirks_mode);
|
||||||
} else {
|
} else {
|
||||||
f(value);
|
f(value);
|
||||||
|
@ -408,7 +406,6 @@ impl PropertyDeclarationIdSet {
|
||||||
from_shorthand: Option<ShorthandId>,
|
from_shorthand: Option<ShorthandId>,
|
||||||
custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
f: &mut F,
|
f: &mut F,
|
||||||
error_reporter: &ParseErrorReporter,
|
|
||||||
quirks_mode: QuirksMode)
|
quirks_mode: QuirksMode)
|
||||||
% if property.boxed:
|
% if property.boxed:
|
||||||
where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
|
where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
|
||||||
|
@ -421,12 +418,10 @@ impl PropertyDeclarationIdSet {
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|css| {
|
.and_then(|css| {
|
||||||
// As of this writing, only the base URL is used for property values:
|
// As of this writing, only the base URL is used for property values:
|
||||||
//
|
let reporter = NullReporter;
|
||||||
// FIXME(pcwalton): Cloning the error reporter is slow! But so are custom
|
|
||||||
// properties, so whatever...
|
|
||||||
let context = ParserContext::new(Origin::Author,
|
let context = ParserContext::new(Origin::Author,
|
||||||
url_data,
|
url_data,
|
||||||
error_reporter,
|
&reporter,
|
||||||
None,
|
None,
|
||||||
PARSING_MODE_DEFAULT,
|
PARSING_MODE_DEFAULT,
|
||||||
quirks_mode);
|
quirks_mode);
|
||||||
|
@ -2514,8 +2509,7 @@ pub type CascadePropertyFn =
|
||||||
default_style: &ComputedValues,
|
default_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
cacheable: &mut bool,
|
cacheable: &mut bool,
|
||||||
cascade_info: &mut Option<<&mut CascadeInfo>,
|
cascade_info: &mut Option<<&mut CascadeInfo>);
|
||||||
error_reporter: &ParseErrorReporter);
|
|
||||||
|
|
||||||
/// A per-longhand array of functions to perform the CSS cascade on each of
|
/// A per-longhand array of functions to perform the CSS cascade on each of
|
||||||
/// them, effectively doing virtual dispatch.
|
/// them, effectively doing virtual dispatch.
|
||||||
|
@ -2577,7 +2571,6 @@ pub fn cascade(device: &Device,
|
||||||
layout_parent_style: Option<<&ComputedValues>,
|
layout_parent_style: Option<<&ComputedValues>,
|
||||||
visited_style: Option<Arc<ComputedValues>>,
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
cascade_info: Option<<&mut CascadeInfo>,
|
cascade_info: Option<<&mut CascadeInfo>,
|
||||||
error_reporter: &ParseErrorReporter,
|
|
||||||
font_metrics_provider: &FontMetricsProvider,
|
font_metrics_provider: &FontMetricsProvider,
|
||||||
flags: CascadeFlags,
|
flags: CascadeFlags,
|
||||||
quirks_mode: QuirksMode)
|
quirks_mode: QuirksMode)
|
||||||
|
@ -2625,7 +2618,6 @@ pub fn cascade(device: &Device,
|
||||||
layout_parent_style,
|
layout_parent_style,
|
||||||
visited_style,
|
visited_style,
|
||||||
cascade_info,
|
cascade_info,
|
||||||
error_reporter,
|
|
||||||
font_metrics_provider,
|
font_metrics_provider,
|
||||||
flags,
|
flags,
|
||||||
quirks_mode)
|
quirks_mode)
|
||||||
|
@ -2641,7 +2633,6 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
layout_parent_style: &ComputedValues,
|
layout_parent_style: &ComputedValues,
|
||||||
visited_style: Option<Arc<ComputedValues>>,
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
mut cascade_info: Option<<&mut CascadeInfo>,
|
mut cascade_info: Option<<&mut CascadeInfo>,
|
||||||
error_reporter: &ParseErrorReporter,
|
|
||||||
font_metrics_provider: &FontMetricsProvider,
|
font_metrics_provider: &FontMetricsProvider,
|
||||||
flags: CascadeFlags,
|
flags: CascadeFlags,
|
||||||
quirks_mode: QuirksMode)
|
quirks_mode: QuirksMode)
|
||||||
|
@ -2795,8 +2786,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
default_style,
|
default_style,
|
||||||
&mut context,
|
&mut context,
|
||||||
&mut cacheable,
|
&mut cacheable,
|
||||||
&mut cascade_info,
|
&mut cascade_info);
|
||||||
error_reporter);
|
|
||||||
}
|
}
|
||||||
% if category_to_cascade_now == "early":
|
% if category_to_cascade_now == "early":
|
||||||
let writing_mode = get_writing_mode(context.style.get_inheritedbox());
|
let writing_mode = get_writing_mode(context.style.get_inheritedbox());
|
||||||
|
@ -2869,8 +2859,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
default_style,
|
default_style,
|
||||||
&mut context,
|
&mut context,
|
||||||
&mut cacheable,
|
&mut cacheable,
|
||||||
&mut cascade_info,
|
&mut cascade_info);
|
||||||
error_reporter);
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
context.style.mutate_font().fixup_none_generic(context.device);
|
context.style.mutate_font().fixup_none_generic(context.device);
|
||||||
% endif
|
% endif
|
||||||
|
@ -2884,8 +2873,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
default_style,
|
default_style,
|
||||||
&mut context,
|
&mut context,
|
||||||
&mut cacheable,
|
&mut cacheable,
|
||||||
&mut cascade_info,
|
&mut cascade_info);
|
||||||
error_reporter);
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
// Font size must be explicitly inherited to handle lang changes and
|
// Font size must be explicitly inherited to handle lang changes and
|
||||||
// scriptlevel changes.
|
// scriptlevel changes.
|
||||||
|
@ -2902,8 +2890,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
default_style,
|
default_style,
|
||||||
&mut context,
|
&mut context,
|
||||||
&mut cacheable,
|
&mut cacheable,
|
||||||
&mut cascade_info,
|
&mut cascade_info);
|
||||||
error_reporter);
|
|
||||||
% endif
|
% endif
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -10,7 +10,6 @@ use bit_vec::BitVec;
|
||||||
use context::{CascadeInputs, QuirksMode};
|
use context::{CascadeInputs, QuirksMode};
|
||||||
use dom::TElement;
|
use dom::TElement;
|
||||||
use element_state::ElementState;
|
use element_state::ElementState;
|
||||||
use error_reporting::create_error_reporter;
|
|
||||||
use font_metrics::FontMetricsProvider;
|
use font_metrics::FontMetricsProvider;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
|
use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
|
||||||
|
@ -639,7 +638,6 @@ impl Stylist {
|
||||||
parent.map(|p| &**p),
|
parent.map(|p| &**p),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
&create_error_reporter(),
|
|
||||||
font_metrics,
|
font_metrics,
|
||||||
cascade_flags,
|
cascade_flags,
|
||||||
self.quirks_mode);
|
self.quirks_mode);
|
||||||
|
@ -748,7 +746,6 @@ impl Stylist {
|
||||||
Some(inherited_style),
|
Some(inherited_style),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
&create_error_reporter(),
|
|
||||||
font_metrics,
|
font_metrics,
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
self.quirks_mode);
|
self.quirks_mode);
|
||||||
|
@ -780,7 +777,6 @@ impl Stylist {
|
||||||
Some(parent_style),
|
Some(parent_style),
|
||||||
visited_values,
|
visited_values,
|
||||||
None,
|
None,
|
||||||
&create_error_reporter(),
|
|
||||||
font_metrics,
|
font_metrics,
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
self.quirks_mode);
|
self.quirks_mode);
|
||||||
|
@ -1367,7 +1363,6 @@ impl Stylist {
|
||||||
Some(parent_style),
|
Some(parent_style),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
&create_error_reporter(),
|
|
||||||
&metrics,
|
&metrics,
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
self.quirks_mode))
|
self.quirks_mode))
|
||||||
|
|
97
ports/geckolib/error_reporter.rs
Normal file
97
ports/geckolib/error_reporter.rs
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
//! Wrapper around Gecko's CSS error reporting mechanism.
|
||||||
|
|
||||||
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
|
use cssparser::{Parser, SourcePosition};
|
||||||
|
use style::error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||||
|
use style::gecko_bindings::bindings::{Gecko_CreateCSSErrorReporter, Gecko_DestroyCSSErrorReporter};
|
||||||
|
use style::gecko_bindings::bindings::Gecko_ReportUnexpectedCSSError;
|
||||||
|
use style::gecko_bindings::structs::{Loader, ServoStyleSheet, nsIURI};
|
||||||
|
use style::gecko_bindings::structs::ErrorReporter as GeckoErrorReporter;
|
||||||
|
use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData;
|
||||||
|
use style::gecko_bindings::sugar::refptr::RefPtr;
|
||||||
|
use style::stylesheets::UrlExtraData;
|
||||||
|
|
||||||
|
/// Wrapper around an instance of Gecko's CSS error reporter.
|
||||||
|
pub struct ErrorReporter(*mut GeckoErrorReporter);
|
||||||
|
|
||||||
|
impl ErrorReporter {
|
||||||
|
/// Create a new instance of the Gecko error reporter.
|
||||||
|
pub fn new(sheet: *mut ServoStyleSheet,
|
||||||
|
loader: *mut Loader,
|
||||||
|
url: *mut RawUrlExtraData) -> ErrorReporter {
|
||||||
|
unsafe {
|
||||||
|
let url = RefPtr::from_ptr_ref(&url);
|
||||||
|
ErrorReporter(Gecko_CreateCSSErrorReporter(sheet, loader, url.mBaseURI.raw::<nsIURI>()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for ErrorReporter {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
Gecko_DestroyCSSErrorReporter(self.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trait ErrorHelpers<'a> {
|
||||||
|
fn to_gecko_message(&self) -> (&'static [u8], &'a str);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
|
||||||
|
fn to_gecko_message(&self) -> (&'static [u8], &'a str) {
|
||||||
|
match *self {
|
||||||
|
ContextualParseError::UnsupportedPropertyDeclaration(decl, _) =>
|
||||||
|
(b"PEUnknownProperty\0", decl),
|
||||||
|
ContextualParseError::UnsupportedFontFaceDescriptor(decl, _) =>
|
||||||
|
(b"PEUnknwnFontDesc\0", decl),
|
||||||
|
ContextualParseError::InvalidKeyframeRule(rule, _) =>
|
||||||
|
(b"PEKeyframeBadName\0", rule),
|
||||||
|
ContextualParseError::UnsupportedKeyframePropertyDeclaration(decl, _) =>
|
||||||
|
(b"PEBadSelectorKeyframeRuleIgnored\0", decl),
|
||||||
|
ContextualParseError::InvalidRule(rule, _) =>
|
||||||
|
(b"PEDeclDropped\0", rule),
|
||||||
|
ContextualParseError::UnsupportedRule(rule, _) =>
|
||||||
|
(b"PEDeclDropped\0", rule),
|
||||||
|
ContextualParseError::UnsupportedViewportDescriptorDeclaration(..) |
|
||||||
|
ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(..) |
|
||||||
|
ContextualParseError::InvalidCounterStyleWithoutSymbols(..) |
|
||||||
|
ContextualParseError::InvalidCounterStyleNotEnoughSymbols(..) |
|
||||||
|
ContextualParseError::InvalidCounterStyleWithoutAdditiveSymbols |
|
||||||
|
ContextualParseError::InvalidCounterStyleExtendsWithSymbols |
|
||||||
|
ContextualParseError::InvalidCounterStyleExtendsWithAdditiveSymbols =>
|
||||||
|
(b"PEUnknownAtRule\0", ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ParseErrorReporter for ErrorReporter {
|
||||||
|
fn report_error<'a>(&self,
|
||||||
|
input: &mut Parser,
|
||||||
|
position: SourcePosition,
|
||||||
|
error: ContextualParseError<'a>,
|
||||||
|
url: &UrlExtraData,
|
||||||
|
line_number_offset: u64) {
|
||||||
|
let location = input.source_location(position);
|
||||||
|
let line_number = location.line + line_number_offset as u32;
|
||||||
|
|
||||||
|
let (name, param) = error.to_gecko_message();
|
||||||
|
let source = "";
|
||||||
|
unsafe {
|
||||||
|
Gecko_ReportUnexpectedCSSError(self.0,
|
||||||
|
name.as_ptr() as *const _,
|
||||||
|
param.as_ptr() as *const _,
|
||||||
|
param.len() as u32,
|
||||||
|
source.as_ptr() as *const _,
|
||||||
|
source.len() as u32,
|
||||||
|
line_number as u32,
|
||||||
|
location.column as u32,
|
||||||
|
url.mBaseURI.raw::<nsIURI>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ use style::data::{ElementData, ElementStyles, RestyleData};
|
||||||
use style::dom::{AnimationOnlyDirtyDescendants, DirtyDescendants};
|
use style::dom::{AnimationOnlyDirtyDescendants, DirtyDescendants};
|
||||||
use style::dom::{ShowSubtreeData, TElement, TNode};
|
use style::dom::{ShowSubtreeData, TElement, TNode};
|
||||||
use style::element_state::ElementState;
|
use style::element_state::ElementState;
|
||||||
use style::error_reporting::RustLogReporter;
|
use style::error_reporting::{NullReporter, ParseErrorReporter};
|
||||||
use style::font_metrics::{FontMetricsProvider, get_metrics_provider_for_product};
|
use style::font_metrics::{FontMetricsProvider, get_metrics_provider_for_product};
|
||||||
use style::gecko::data::{GeckoStyleSheet, PerDocumentStyleData, PerDocumentStyleDataImpl};
|
use style::gecko::data::{GeckoStyleSheet, PerDocumentStyleData, PerDocumentStyleDataImpl};
|
||||||
use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData, STYLE_THREAD_POOL};
|
use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData, STYLE_THREAD_POOL};
|
||||||
|
@ -118,6 +118,7 @@ use style::traversal::{resolve_style, resolve_default_style};
|
||||||
use style::values::{CustomIdent, KeyframesName};
|
use style::values::{CustomIdent, KeyframesName};
|
||||||
use style::values::computed::Context;
|
use style::values::computed::Context;
|
||||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss};
|
use style_traits::{PARSING_MODE_DEFAULT, ToCss};
|
||||||
|
use super::error_reporter::ErrorReporter;
|
||||||
use super::stylesheet_loader::StylesheetLoader;
|
use super::stylesheet_loader::StylesheetLoader;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -172,8 +173,6 @@ unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
|
||||||
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEFAULT_ERROR_REPORTER: RustLogReporter = RustLogReporter;
|
|
||||||
|
|
||||||
fn create_shared_context<'a>(global_style_data: &GlobalStyleData,
|
fn create_shared_context<'a>(global_style_data: &GlobalStyleData,
|
||||||
guard: &'a SharedRwLockReadGuard,
|
guard: &'a SharedRwLockReadGuard,
|
||||||
per_doc_data: &'a PerDocumentStyleDataImpl,
|
per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||||
|
@ -184,7 +183,6 @@ fn create_shared_context<'a>(global_style_data: &GlobalStyleData,
|
||||||
stylist: &per_doc_data.stylist,
|
stylist: &per_doc_data.stylist,
|
||||||
options: global_style_data.options.clone(),
|
options: global_style_data.options.clone(),
|
||||||
guards: StylesheetGuards::same(guard),
|
guards: StylesheetGuards::same(guard),
|
||||||
error_reporter: &DEFAULT_ERROR_REPORTER,
|
|
||||||
timer: Timer::new(),
|
timer: Timer::new(),
|
||||||
quirks_mode: per_doc_data.stylist.quirks_mode(),
|
quirks_mode: per_doc_data.stylist.quirks_mode(),
|
||||||
traversal_flags: traversal_flags,
|
traversal_flags: traversal_flags,
|
||||||
|
@ -755,7 +753,7 @@ pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyl
|
||||||
origin,
|
origin,
|
||||||
shared_lock,
|
shared_lock,
|
||||||
/* loader = */ None,
|
/* loader = */ None,
|
||||||
&RustLogReporter,
|
&NullReporter,
|
||||||
QuirksMode::NoQuirks,
|
QuirksMode::NoQuirks,
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
@ -782,6 +780,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
|
||||||
SheetParsingMode::eSafeAgentSheetFeatures => Origin::UserAgent,
|
SheetParsingMode::eSafeAgentSheetFeatures => Origin::UserAgent,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let reporter = ErrorReporter::new(stylesheet, loader, extra_data);
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&extra_data) };
|
let url_data = unsafe { RefPtr::from_ptr_ref(&extra_data) };
|
||||||
let loader = if loader.is_null() {
|
let loader = if loader.is_null() {
|
||||||
None
|
None
|
||||||
|
@ -798,7 +797,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
|
||||||
|
|
||||||
Arc::new(StylesheetContents::from_str(
|
Arc::new(StylesheetContents::from_str(
|
||||||
input, url_data.clone(), origin,
|
input, url_data.clone(), origin,
|
||||||
&global_style_data.shared_lock, loader, &RustLogReporter,
|
&global_style_data.shared_lock, loader, &reporter,
|
||||||
quirks_mode.into(), line_number_offset as u64)
|
quirks_mode.into(), line_number_offset as u64)
|
||||||
).into_strong()
|
).into_strong()
|
||||||
}
|
}
|
||||||
|
@ -1775,7 +1774,8 @@ fn parse_property_into(declarations: &mut SourcePropertyDeclaration,
|
||||||
value: *const nsACString,
|
value: *const nsACString,
|
||||||
data: *mut URLExtraData,
|
data: *mut URLExtraData,
|
||||||
parsing_mode: structs::ParsingMode,
|
parsing_mode: structs::ParsingMode,
|
||||||
quirks_mode: QuirksMode) -> Result<(), ()> {
|
quirks_mode: QuirksMode,
|
||||||
|
reporter: &ParseErrorReporter) -> Result<(), ()> {
|
||||||
use style_traits::ParsingMode;
|
use style_traits::ParsingMode;
|
||||||
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
||||||
|
@ -1786,7 +1786,7 @@ fn parse_property_into(declarations: &mut SourcePropertyDeclaration,
|
||||||
property_id,
|
property_id,
|
||||||
value,
|
value,
|
||||||
url_data,
|
url_data,
|
||||||
&RustLogReporter,
|
reporter,
|
||||||
parsing_mode,
|
parsing_mode,
|
||||||
quirks_mode)
|
quirks_mode)
|
||||||
}
|
}
|
||||||
|
@ -1795,13 +1795,15 @@ fn parse_property_into(declarations: &mut SourcePropertyDeclaration,
|
||||||
pub extern "C" fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const nsACString,
|
pub extern "C" fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const nsACString,
|
||||||
data: *mut URLExtraData,
|
data: *mut URLExtraData,
|
||||||
parsing_mode: structs::ParsingMode,
|
parsing_mode: structs::ParsingMode,
|
||||||
quirks_mode: nsCompatibility)
|
quirks_mode: nsCompatibility,
|
||||||
|
loader: *mut Loader)
|
||||||
-> RawServoDeclarationBlockStrong {
|
-> RawServoDeclarationBlockStrong {
|
||||||
let id = get_property_id_from_nscsspropertyid!(property,
|
let id = get_property_id_from_nscsspropertyid!(property,
|
||||||
RawServoDeclarationBlockStrong::null());
|
RawServoDeclarationBlockStrong::null());
|
||||||
let mut declarations = SourcePropertyDeclaration::new();
|
let mut declarations = SourcePropertyDeclaration::new();
|
||||||
|
let reporter = ErrorReporter::new(ptr::null_mut(), loader, data);
|
||||||
match parse_property_into(&mut declarations, id, value, data,
|
match parse_property_into(&mut declarations, id, value, data,
|
||||||
parsing_mode, quirks_mode.into()) {
|
parsing_mode, quirks_mode.into(), &reporter) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let mut block = PropertyDeclarationBlock::new();
|
let mut block = PropertyDeclarationBlock::new();
|
||||||
|
@ -1820,7 +1822,7 @@ pub extern "C" fn Servo_ParseEasing(easing: *const nsAString,
|
||||||
use style::properties::longhands::transition_timing_function;
|
use style::properties::longhands::transition_timing_function;
|
||||||
|
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
||||||
let reporter = RustLogReporter;
|
let reporter = NullReporter;
|
||||||
let context = ParserContext::new(Origin::Author,
|
let context = ParserContext::new(Origin::Author,
|
||||||
url_data,
|
url_data,
|
||||||
&reporter,
|
&reporter,
|
||||||
|
@ -1897,13 +1899,16 @@ pub extern "C" fn Servo_MatrixTransform_Operate(matrix_operator: MatrixTransform
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString,
|
pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString,
|
||||||
raw_extra_data: *mut URLExtraData,
|
raw_extra_data: *mut URLExtraData,
|
||||||
quirks_mode: nsCompatibility)
|
quirks_mode: nsCompatibility,
|
||||||
|
loader: *mut Loader)
|
||||||
-> RawServoDeclarationBlockStrong {
|
-> RawServoDeclarationBlockStrong {
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let value = unsafe { data.as_ref().unwrap().as_str_unchecked() };
|
let value = unsafe { data.as_ref().unwrap().as_str_unchecked() };
|
||||||
|
let reporter = ErrorReporter::new(ptr::null_mut(), loader, raw_extra_data);
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) };
|
let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) };
|
||||||
Arc::new(global_style_data.shared_lock.wrap(
|
Arc::new(global_style_data.shared_lock.wrap(
|
||||||
GeckoElement::parse_style_attribute(value, url_data, quirks_mode.into()))).into_strong()
|
GeckoElement::parse_style_attribute(value, url_data, quirks_mode.into(), &reporter)))
|
||||||
|
.into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -2043,10 +2048,12 @@ pub extern "C" fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: Ra
|
||||||
fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId,
|
fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId,
|
||||||
value: *const nsACString, is_important: bool, data: *mut URLExtraData,
|
value: *const nsACString, is_important: bool, data: *mut URLExtraData,
|
||||||
parsing_mode: structs::ParsingMode,
|
parsing_mode: structs::ParsingMode,
|
||||||
quirks_mode: QuirksMode) -> bool {
|
quirks_mode: QuirksMode,
|
||||||
|
loader: *mut Loader) -> bool {
|
||||||
let mut source_declarations = SourcePropertyDeclaration::new();
|
let mut source_declarations = SourcePropertyDeclaration::new();
|
||||||
|
let reporter = ErrorReporter::new(ptr::null_mut(), loader, data);
|
||||||
match parse_property_into(&mut source_declarations, property_id, value, data,
|
match parse_property_into(&mut source_declarations, property_id, value, data,
|
||||||
parsing_mode, quirks_mode) {
|
parsing_mode, quirks_mode, &reporter) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
||||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
|
@ -2062,9 +2069,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetProperty(declarations: RawServoDecla
|
||||||
property: *const nsACString, value: *const nsACString,
|
property: *const nsACString, value: *const nsACString,
|
||||||
is_important: bool, data: *mut URLExtraData,
|
is_important: bool, data: *mut URLExtraData,
|
||||||
parsing_mode: structs::ParsingMode,
|
parsing_mode: structs::ParsingMode,
|
||||||
quirks_mode: nsCompatibility) -> bool {
|
quirks_mode: nsCompatibility,
|
||||||
|
loader: *mut Loader) -> bool {
|
||||||
set_property(declarations, get_property_id_from_property!(property, false),
|
set_property(declarations, get_property_id_from_property!(property, false),
|
||||||
value, is_important, data, parsing_mode, quirks_mode.into())
|
value, is_important, data, parsing_mode, quirks_mode.into(), loader)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -2072,9 +2080,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetPropertyById(declarations: RawServoD
|
||||||
property: nsCSSPropertyID, value: *const nsACString,
|
property: nsCSSPropertyID, value: *const nsACString,
|
||||||
is_important: bool, data: *mut URLExtraData,
|
is_important: bool, data: *mut URLExtraData,
|
||||||
parsing_mode: structs::ParsingMode,
|
parsing_mode: structs::ParsingMode,
|
||||||
quirks_mode: nsCompatibility) -> bool {
|
quirks_mode: nsCompatibility,
|
||||||
|
loader: *mut Loader) -> bool {
|
||||||
set_property(declarations, get_property_id_from_nscsspropertyid!(property, false),
|
set_property(declarations, get_property_id_from_nscsspropertyid!(property, false),
|
||||||
value, is_important, data, parsing_mode, quirks_mode.into())
|
value, is_important, data, parsing_mode, quirks_mode.into(), loader)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId) {
|
fn remove_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId) {
|
||||||
|
@ -2142,7 +2151,7 @@ pub extern "C" fn Servo_MediaList_SetText(list: RawServoMediaListBorrowed, text:
|
||||||
let mut input = ParserInput::new(&text);
|
let mut input = ParserInput::new(&text);
|
||||||
let mut parser = Parser::new(&mut input);
|
let mut parser = Parser::new(&mut input);
|
||||||
let url_data = unsafe { dummy_url_data() };
|
let url_data = unsafe { dummy_url_data() };
|
||||||
let reporter = RustLogReporter;
|
let reporter = NullReporter;
|
||||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||||
PARSING_MODE_DEFAULT,
|
PARSING_MODE_DEFAULT,
|
||||||
QuirksMode::NoQuirks);
|
QuirksMode::NoQuirks);
|
||||||
|
@ -2174,7 +2183,7 @@ pub extern "C" fn Servo_MediaList_AppendMedium(list: RawServoMediaListBorrowed,
|
||||||
new_medium: *const nsACString) {
|
new_medium: *const nsACString) {
|
||||||
let new_medium = unsafe { new_medium.as_ref().unwrap().as_str_unchecked() };
|
let new_medium = unsafe { new_medium.as_ref().unwrap().as_str_unchecked() };
|
||||||
let url_data = unsafe { dummy_url_data() };
|
let url_data = unsafe { dummy_url_data() };
|
||||||
let reporter = RustLogReporter;
|
let reporter = NullReporter;
|
||||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||||
PARSING_MODE_DEFAULT,
|
PARSING_MODE_DEFAULT,
|
||||||
QuirksMode::NoQuirks);
|
QuirksMode::NoQuirks);
|
||||||
|
@ -2188,7 +2197,7 @@ pub extern "C" fn Servo_MediaList_DeleteMedium(list: RawServoMediaListBorrowed,
|
||||||
old_medium: *const nsACString) -> bool {
|
old_medium: *const nsACString) -> bool {
|
||||||
let old_medium = unsafe { old_medium.as_ref().unwrap().as_str_unchecked() };
|
let old_medium = unsafe { old_medium.as_ref().unwrap().as_str_unchecked() };
|
||||||
let url_data = unsafe { dummy_url_data() };
|
let url_data = unsafe { dummy_url_data() };
|
||||||
let reporter = RustLogReporter;
|
let reporter = NullReporter;
|
||||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||||
PARSING_MODE_DEFAULT,
|
PARSING_MODE_DEFAULT,
|
||||||
QuirksMode::NoQuirks);
|
QuirksMode::NoQuirks);
|
||||||
|
@ -2554,7 +2563,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(declarations:
|
||||||
|
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) };
|
let url_data = unsafe { RefPtr::from_ptr_ref(&raw_extra_data) };
|
||||||
let string = unsafe { (*value).to_string() };
|
let string = unsafe { (*value).to_string() };
|
||||||
let error_reporter = RustLogReporter;
|
let error_reporter = NullReporter;
|
||||||
let context = ParserContext::new(Origin::Author, url_data, &error_reporter,
|
let context = ParserContext::new(Origin::Author, url_data, &error_reporter,
|
||||||
Some(CssRuleType::Style), PARSING_MODE_DEFAULT,
|
Some(CssRuleType::Style), PARSING_MODE_DEFAULT,
|
||||||
QuirksMode::NoQuirks);
|
QuirksMode::NoQuirks);
|
||||||
|
@ -2595,7 +2604,8 @@ pub extern "C" fn Servo_CSSSupports2(property: *const nsACString,
|
||||||
value,
|
value,
|
||||||
unsafe { DUMMY_URL_DATA },
|
unsafe { DUMMY_URL_DATA },
|
||||||
structs::ParsingMode_Default,
|
structs::ParsingMode_Default,
|
||||||
QuirksMode::NoQuirks
|
QuirksMode::NoQuirks,
|
||||||
|
&NullReporter,
|
||||||
).is_ok()
|
).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2607,7 +2617,7 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
|
||||||
let cond = input.parse_entirely(|i| parse_condition_or_declaration(i));
|
let cond = input.parse_entirely(|i| parse_condition_or_declaration(i));
|
||||||
if let Ok(cond) = cond {
|
if let Ok(cond) = cond {
|
||||||
let url_data = unsafe { dummy_url_data() };
|
let url_data = unsafe { dummy_url_data() };
|
||||||
let reporter = RustLogReporter;
|
let reporter = NullReporter;
|
||||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Style),
|
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Style),
|
||||||
PARSING_MODE_DEFAULT,
|
PARSING_MODE_DEFAULT,
|
||||||
QuirksMode::NoQuirks);
|
QuirksMode::NoQuirks);
|
||||||
|
|
|
@ -13,6 +13,7 @@ extern crate selectors;
|
||||||
#[macro_use] extern crate style;
|
#[macro_use] extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
|
|
||||||
|
mod error_reporter;
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub mod glue;
|
pub mod glue;
|
||||||
mod stylesheet_loader;
|
mod stylesheet_loader;
|
||||||
|
|
|
@ -10,6 +10,9 @@ use style::gecko_properties::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/check_bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/check_bindings.rs"));
|
||||||
|
|
||||||
|
#[path = "../../../ports/geckolib/error_reporter.rs"]
|
||||||
|
mod error_reporter;
|
||||||
|
|
||||||
#[path = "../../../ports/geckolib/stylesheet_loader.rs"]
|
#[path = "../../../ports/geckolib/stylesheet_loader.rs"]
|
||||||
mod stylesheet_loader;
|
mod stylesheet_loader;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue