Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow Gecko FFI functions for color parsing to report errors #19490

Merged
merged 5 commits into from Dec 5, 2017

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.
  • Loading branch information
heycam committed Dec 5, 2017
commit 7940061c9a76ce41acf13b227233860b983642c9
@@ -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)
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.