mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
geckolib: Allow an ErrorReporter to be created with null URL data.
This allows us to create an ErrorReporter that will report errors as being "from DOM" rather than a specific URL. Also, factor out a method on ErrorReporter so that we don't need to pass in a UrlExtraData reference.
This commit is contained in:
parent
393ab5ab1e
commit
7940061c9a
1 changed files with 18 additions and 9 deletions
|
@ -16,7 +16,6 @@ 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;
|
||||
use style_traits::StyleParseErrorKind;
|
||||
|
||||
|
@ -29,10 +28,12 @@ impl ErrorReporter {
|
|||
/// Create a new instance of the Gecko error reporter.
|
||||
pub fn new(sheet: *mut ServoStyleSheet,
|
||||
loader: *mut Loader,
|
||||
url: *mut RawUrlExtraData) -> ErrorReporter {
|
||||
extra_data: *mut RawUrlExtraData) -> ErrorReporter {
|
||||
unsafe {
|
||||
let url = RefPtr::from_ptr_ref(&url);
|
||||
ErrorReporter(Gecko_CreateCSSErrorReporter(sheet, loader, url.mBaseURI.raw::<nsIURI>()))
|
||||
let url = extra_data.as_ref()
|
||||
.map(|d| d.mBaseURI.raw::<nsIURI>())
|
||||
.unwrap_or(ptr::null_mut());
|
||||
ErrorReporter(Gecko_CreateCSSErrorReporter(sheet, loader, url))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -364,11 +365,8 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ParseErrorReporter for ErrorReporter {
|
||||
fn report_error(&self,
|
||||
_url: &UrlExtraData,
|
||||
location: SourceLocation,
|
||||
error: ContextualParseError) {
|
||||
impl ErrorReporter {
|
||||
pub fn report(&self, location: SourceLocation, error: ContextualParseError) {
|
||||
let (pre, name, action) = error.to_gecko_message();
|
||||
let suffix = match action {
|
||||
Action::Nothing => ptr::null(),
|
||||
|
@ -400,3 +398,14 @@ impl ParseErrorReporter for ErrorReporter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseErrorReporter for ErrorReporter {
|
||||
fn report_error(
|
||||
&self,
|
||||
_url: &UrlExtraData,
|
||||
location: SourceLocation,
|
||||
error: ContextualParseError
|
||||
) {
|
||||
self.report(location, error)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue