Skip to content

Commit

Permalink
Auto merge of #16835 - ferjm:bug1350175.line.column.css.rules, r=upsu…
Browse files Browse the repository at this point in the history
…per,SimonSapin

Stylo: Bug 1350175 - Support getting line / column number of CSS rules

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

Bugzilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1350175

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16835)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed May 15, 2017
2 parents 94e977e + bc156cf commit 5cd8265
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 56 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion components/style/encoding_support.rs
Expand Up @@ -88,6 +88,7 @@ impl Stylesheet {
&string,
url_data,
stylesheet_loader,
error_reporter)
error_reporter,
0)
}
}
11 changes: 10 additions & 1 deletion components/style/font_face.rs
Expand Up @@ -12,6 +12,7 @@
use computed_values::{font_style, font_weight, font_stretch};
use computed_values::font_family::FamilyName;
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser};
use cssparser::SourceLocation;
#[cfg(feature = "gecko")] use gecko_bindings::structs::CSSFontFaceDescriptors;
#[cfg(feature = "gecko")] use cssparser::UnicodeRange;
use parser::{ParserContext, log_css_error, Parse};
Expand Down Expand Up @@ -74,8 +75,10 @@ impl ToCss for UrlSource {
/// Parse the block inside a `@font-face` rule.
///
/// Note that the prelude parsing code lives in the `stylesheets` module.
pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser) -> FontFaceRuleData {
pub fn parse_font_face_block(context: &ParserContext, input: &mut Parser, location: SourceLocation)
-> FontFaceRuleData {
let mut rule = FontFaceRuleData::empty();
rule.source_location = location;
{
let parser = FontFaceRuleParser {
context: context,
Expand Down Expand Up @@ -186,6 +189,8 @@ macro_rules! font_face_descriptors_common {
#[$doc]
pub $ident: Option<$ty>,
)*
/// Line and column of the @font-face rule source code.
pub source_location: SourceLocation,
}

impl FontFaceRuleData {
Expand All @@ -194,6 +199,10 @@ macro_rules! font_face_descriptors_common {
$(
$ident: None,
)*
source_location: SourceLocation {
line: 0,
column: 0,
},
}
}

Expand Down
28 changes: 19 additions & 9 deletions components/style/gecko/generated/bindings.rs
Expand Up @@ -1255,7 +1255,8 @@ extern "C" {
-> *const ::std::os::raw::c_char;
}
extern "C" {
pub fn Gecko_CSSFontFaceRule_Create() -> *mut nsCSSFontFaceRule;
pub fn Gecko_CSSFontFaceRule_Create(line: u32, column: u32)
-> *mut nsCSSFontFaceRule;
}
extern "C" {
pub fn Gecko_CSSFontFaceRule_GetCssText(rule: *const nsCSSFontFaceRule,
Expand Down Expand Up @@ -1621,7 +1622,8 @@ extern "C" {
media_list:
*const RawServoMediaList,
extra_data:
*mut RawGeckoURLExtraData)
*mut RawGeckoURLExtraData,
line_number_offset: u32)
-> RawServoStyleSheetStrong;
}
extern "C" {
Expand All @@ -1636,7 +1638,8 @@ extern "C" {
*mut ServoStyleSheet,
data: *const nsACString,
extra_data:
*mut RawGeckoURLExtraData);
*mut RawGeckoURLExtraData,
line_number_offset: u32);
}
extern "C" {
pub fn Servo_StyleSheet_HasRules(sheet: RawServoStyleSheetBorrowed)
Expand Down Expand Up @@ -1726,7 +1729,8 @@ extern "C" {
}
extern "C" {
pub fn Servo_CssRules_GetStyleRuleAt(rules: ServoCssRulesBorrowed,
index: u32)
index: u32, line: *mut u32,
column: *mut u32)
-> RawServoStyleRuleStrong;
}
extern "C" {
Expand All @@ -1739,7 +1743,8 @@ extern "C" {
}
extern "C" {
pub fn Servo_CssRules_GetMediaRuleAt(rules: ServoCssRulesBorrowed,
index: u32)
index: u32, line: *mut u32,
column: *mut u32)
-> RawServoMediaRuleStrong;
}
extern "C" {
Expand All @@ -1756,7 +1761,8 @@ extern "C" {
}
extern "C" {
pub fn Servo_CssRules_GetNamespaceRuleAt(rules: ServoCssRulesBorrowed,
index: u32)
index: u32, line: *mut u32,
column: *mut u32)
-> RawServoNamespaceRuleStrong;
}
extern "C" {
Expand All @@ -1769,7 +1775,9 @@ extern "C" {
}
extern "C" {
pub fn Servo_CssRules_GetPageRuleAt(rules: ServoCssRulesBorrowed,
index: u32) -> RawServoPageRuleStrong;
index: u32, line: *mut u32,
column: *mut u32)
-> RawServoPageRuleStrong;
}
extern "C" {
pub fn Servo_PageRule_Debug(rule: RawServoPageRuleBorrowed,
Expand All @@ -1781,7 +1789,8 @@ extern "C" {
}
extern "C" {
pub fn Servo_CssRules_GetSupportsRuleAt(rules: ServoCssRulesBorrowed,
index: u32)
index: u32, line: *mut u32,
column: *mut u32)
-> RawServoSupportsRuleStrong;
}
extern "C" {
Expand All @@ -1798,7 +1807,8 @@ extern "C" {
}
extern "C" {
pub fn Servo_CssRules_GetDocumentRuleAt(rules: ServoCssRulesBorrowed,
index: u32)
index: u32, line: *mut u32,
column: *mut u32)
-> RawServoDocumentRuleStrong;
}
extern "C" {
Expand Down
4 changes: 3 additions & 1 deletion components/style/gecko/rules.rs
Expand Up @@ -117,7 +117,9 @@ impl ToNsCssValue for Vec<UnicodeRange> {
impl From<FontFaceRuleData> for FontFaceRule {
fn from(data: FontFaceRuleData) -> FontFaceRule {
let mut result = unsafe {
UniqueRefPtr::from_addrefed(bindings::Gecko_CSSFontFaceRule_Create())
UniqueRefPtr::from_addrefed(bindings::Gecko_CSSFontFaceRule_Create(
data.source_location.line as u32, data.source_location.column as u32
))
};
data.set_descriptors(&mut result.mDecl.mDescriptors);
result.get()
Expand Down

0 comments on commit 5cd8265

Please sign in to comment.