servo: Merge #17316 - Resolve counter style during parallel traversal when possible (from upsuper:bug1371976); r=heycam

This is the Servo side change of [bug 1371976](https://bugzilla.mozilla.org/show_bug.cgi?id=1371976).

Source-Repo: https://github.com/servo/servo
Source-Revision: 63a5ab154eabf72595477f8136e371127bcd8486

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : b98ce494b01773768afba6fb6a3a5364a0537cca
This commit is contained in:
Xidorn Quan 2017-06-14 03:07:27 -07:00
Родитель 40736475a0
Коммит 7475262089
4 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -906,7 +906,9 @@ extern "C" {
} }
extern "C" { extern "C" {
pub fn Gecko_SetCounterStyleToName(ptr: *mut CounterStylePtr, pub fn Gecko_SetCounterStyleToName(ptr: *mut CounterStylePtr,
name: *mut nsIAtom); name: *mut nsIAtom,
pres_context:
RawGeckoPresContextBorrowed);
} }
extern "C" { extern "C" {
pub fn Gecko_SetCounterStyleToSymbols(ptr: *mut CounterStylePtr, pub fn Gecko_SetCounterStyleToSymbols(ptr: *mut CounterStylePtr,

Просмотреть файл

@ -12,6 +12,7 @@ use cssparser::RGBA;
use gecko_bindings::structs::{CounterStylePtr, nsStyleCoord}; use gecko_bindings::structs::{CounterStylePtr, nsStyleCoord};
use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius}; use gecko_bindings::structs::{StyleGridTrackBreadth, StyleShapeRadius};
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue}; use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
use media_queries::Device;
use nsstring::{nsACString, nsCString}; use nsstring::{nsACString, nsCString};
use std::cmp::max; use std::cmp::max;
use values::{Auto, Either, ExtremumLength, None_, Normal}; use values::{Auto, Either, ExtremumLength, None_, Normal};
@ -397,15 +398,16 @@ pub fn round_border_to_device_pixels(width: Au, au_per_device_px: Au) -> Au {
impl CounterStyleOrNone { impl CounterStyleOrNone {
/// Convert this counter style to a Gecko CounterStylePtr. /// Convert this counter style to a Gecko CounterStylePtr.
pub fn to_gecko_value(self, gecko_value: &mut CounterStylePtr) { pub fn to_gecko_value(self, gecko_value: &mut CounterStylePtr, device: &Device) {
use gecko_bindings::bindings::Gecko_SetCounterStyleToName as set_name; use gecko_bindings::bindings::Gecko_SetCounterStyleToName as set_name;
use gecko_bindings::bindings::Gecko_SetCounterStyleToSymbols as set_symbols; use gecko_bindings::bindings::Gecko_SetCounterStyleToSymbols as set_symbols;
let pres_context = unsafe { &*device.pres_context };
match self { match self {
CounterStyleOrNone::None => unsafe { CounterStyleOrNone::None => unsafe {
set_name(gecko_value, atom!("none").into_addrefed()); set_name(gecko_value, atom!("none").into_addrefed(), pres_context);
}, },
CounterStyleOrNone::Name(name) => unsafe { CounterStyleOrNone::Name(name) => unsafe {
set_name(gecko_value, name.0.into_addrefed()); set_name(gecko_value, name.0.into_addrefed(), pres_context);
}, },
CounterStyleOrNone::Symbols(symbols_type, symbols) => { CounterStyleOrNone::Symbols(symbols_type, symbols) => {
let symbols: Vec<_> = symbols.0.iter().map(|symbol| match *symbol { let symbols: Vec<_> = symbols.0.iter().map(|symbol| match *symbol {

Просмотреть файл

@ -3202,12 +3202,12 @@ fn static_assert() {
unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); } unsafe { Gecko_CopyListStyleImageFrom(&mut self.gecko, &other.gecko); }
} }
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T) { pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {
use gecko_bindings::bindings::Gecko_SetCounterStyleToString; use gecko_bindings::bindings::Gecko_SetCounterStyleToString;
use nsstring::{nsACString, nsCString}; use nsstring::{nsACString, nsCString};
use self::longhands::list_style_type::computed_value::T; use self::longhands::list_style_type::computed_value::T;
match v { match v {
T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle), T::CounterStyle(s) => s.to_gecko_value(&mut self.gecko.mCounterStyle, device),
T::String(s) => unsafe { T::String(s) => unsafe {
Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle, Gecko_SetCounterStyleToString(&mut self.gecko.mCounterStyle,
&nsCString::from(s) as &nsACString) &nsCString::from(s) as &nsACString)
@ -4254,7 +4254,7 @@ clip-path
self.gecko.mContents.is_empty() self.gecko.mContents.is_empty()
} }
pub fn set_content(&mut self, v: longhands::content::computed_value::T) { pub fn set_content(&mut self, v: longhands::content::computed_value::T, device: &Device) {
use properties::longhands::content::computed_value::T; use properties::longhands::content::computed_value::T;
use properties::longhands::content::computed_value::ContentItem; use properties::longhands::content::computed_value::ContentItem;
use values::generics::CounterStyleOrNone; use values::generics::CounterStyleOrNone;
@ -4275,7 +4275,8 @@ clip-path
fn set_counter_function(data: &mut nsStyleContentData, fn set_counter_function(data: &mut nsStyleContentData,
content_type: nsStyleContentType, content_type: nsStyleContentType,
name: &str, sep: &str, style: CounterStyleOrNone) { name: &str, sep: &str,
style: CounterStyleOrNone, device: &Device) {
debug_assert!(content_type == eStyleContentType_Counter || debug_assert!(content_type == eStyleContentType_Counter ||
content_type == eStyleContentType_Counters); content_type == eStyleContentType_Counters);
let counter_func = unsafe { let counter_func = unsafe {
@ -4285,7 +4286,7 @@ clip-path
if content_type == eStyleContentType_Counters { if content_type == eStyleContentType_Counters {
counter_func.mSeparator.assign_utf8(sep); counter_func.mSeparator.assign_utf8(sep);
} }
style.to_gecko_value(&mut counter_func.mCounterStyle); style.to_gecko_value(&mut counter_func.mCounterStyle, device);
} }
match v { match v {
@ -4349,11 +4350,11 @@ clip-path
=> self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote, => self.gecko.mContents[i].mType = eStyleContentType_NoCloseQuote,
ContentItem::Counter(name, style) => { ContentItem::Counter(name, style) => {
set_counter_function(&mut self.gecko.mContents[i], set_counter_function(&mut self.gecko.mContents[i],
eStyleContentType_Counter, &name, "", style); eStyleContentType_Counter, &name, "", style, device);
} }
ContentItem::Counters(name, sep, style) => { ContentItem::Counters(name, sep, style) => {
set_counter_function(&mut self.gecko.mContents[i], set_counter_function(&mut self.gecko.mContents[i],
eStyleContentType_Counters, &name, &sep, style); eStyleContentType_Counters, &name, &sep, style, device);
} }
ContentItem::Url(ref url) => { ContentItem::Url(ref url) => {
unsafe { unsafe {

Просмотреть файл

@ -344,6 +344,8 @@
<% <%
maybe_wm = ", wm" if property.logical else "" maybe_wm = ", wm" if property.logical else ""
maybe_cacheable = ", cacheable" if property.has_uncacheable_values == "True" else "" maybe_cacheable = ", cacheable" if property.has_uncacheable_values == "True" else ""
props_need_device = "content list_style_type".split() if product == "gecko" else []
maybe_device = ", context.device" if property.ident in props_need_device else ""
%> %>
match *value { match *value {
DeclaredValue::Value(ref specified_value) => { DeclaredValue::Value(ref specified_value) => {
@ -375,7 +377,8 @@
inherited_style.get_font()); inherited_style.get_font());
% else: % else:
context.mutate_style().mutate_${data.current_style_struct.name_lower}() context.mutate_style().mutate_${data.current_style_struct.name_lower}()
.set_${property.ident}(computed ${maybe_cacheable} ${maybe_wm}); .set_${property.ident}(computed ${maybe_device}
${maybe_cacheable} ${maybe_wm});
% endif % endif
% endif % endif
} }