mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Support url() values in background-image and mask-image in stylo. r=manishearth
MozReview-Commit-ID: 7IUzzVV9rOi
This commit is contained in:
parent
df4194154e
commit
2d232cecb2
5 changed files with 30 additions and 11 deletions
|
@ -67,7 +67,8 @@ class Longhand(object):
|
|||
def __init__(self, style_struct, name, animatable=None, derived_from=None, keyword=None,
|
||||
predefined_type=None, custom_cascade=False, experimental=False, internal=False,
|
||||
need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False,
|
||||
allowed_in_keyframe_block=True, complex_color=False, cast_type='u8'):
|
||||
allowed_in_keyframe_block=True, complex_color=False, cast_type='u8',
|
||||
has_uncacheable_values=False):
|
||||
self.name = name
|
||||
self.keyword = keyword
|
||||
self.predefined_type = predefined_type
|
||||
|
@ -78,6 +79,7 @@ class Longhand(object):
|
|||
self.custom_cascade = custom_cascade
|
||||
self.internal = internal
|
||||
self.need_index = need_index
|
||||
self.has_uncacheable_values = has_uncacheable_values
|
||||
self.gecko_ffi_name = gecko_ffi_name or "m" + self.camel_case
|
||||
self.depend_on_viewport_size = depend_on_viewport_size
|
||||
self.derived_from = (derived_from or "").split()
|
||||
|
|
|
@ -30,6 +30,7 @@ use gecko_bindings::bindings::Gecko_SetGradientImageValue;
|
|||
use gecko_bindings::bindings::Gecko_SetListStyleType;
|
||||
use gecko_bindings::bindings::Gecko_SetMozBinding;
|
||||
use gecko_bindings::bindings::Gecko_SetNullImageValue;
|
||||
use gecko_bindings::bindings::Gecko_SetUrlImageValue;
|
||||
use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
|
||||
use gecko_bindings::structs;
|
||||
|
@ -1196,8 +1197,10 @@ fn static_assert() {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn set_${shorthand}_image(&mut self,
|
||||
images: longhands::${shorthand}_image::computed_value::T) {
|
||||
images: longhands::${shorthand}_image::computed_value::T,
|
||||
cacheable: &mut bool) {
|
||||
use gecko_bindings::structs::nsStyleImage;
|
||||
use gecko_bindings::structs::nsStyleImageLayers_LayerType as LayerType;
|
||||
use gecko_bindings::structs::{NS_STYLE_GRADIENT_SHAPE_LINEAR, NS_STYLE_GRADIENT_SHAPE_CIRCULAR};
|
||||
|
@ -1385,13 +1388,20 @@ fn static_assert() {
|
|||
Image::Gradient(gradient) => {
|
||||
set_gradient(gradient, &mut geckoimage.mImage)
|
||||
},
|
||||
Image::Url(..) => {
|
||||
// let utf8_bytes = url.as_bytes();
|
||||
// Gecko_SetUrlImageValue(&mut self.gecko.mImage.mLayers.mFirstElement,
|
||||
// utf8_bytes.as_ptr() as *const _,
|
||||
// utf8_bytes.len());
|
||||
warn!("stylo: imgRequestProxies are not threadsafe in gecko, \
|
||||
background-image: url() not yet implemented");
|
||||
Image::Url(ref url, ref extra_data) => {
|
||||
unsafe {
|
||||
Gecko_SetUrlImageValue(&mut geckoimage.mImage,
|
||||
url.as_str().as_ptr(),
|
||||
url.as_str().len() as u32,
|
||||
extra_data.base.get(),
|
||||
extra_data.referrer.get(),
|
||||
extra_data.principal.get());
|
||||
}
|
||||
// We unfortunately must make any url() value uncacheable, since
|
||||
// the applicable declarations cache is not per document, but
|
||||
// global, and the imgRequestProxy objects we store in the style
|
||||
// structs don't like to be tracked by more than one document.
|
||||
*cacheable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,8 +224,13 @@
|
|||
match *value {
|
||||
DeclaredValue::Value(ref specified_value) => {
|
||||
let computed = specified_value.to_computed_value(context);
|
||||
% if property.has_uncacheable_values:
|
||||
context.mutate_style().mutate_${data.current_style_struct.name_lower}()
|
||||
.set_${property.ident}(computed, cacheable);
|
||||
% else:
|
||||
context.mutate_style().mutate_${data.current_style_struct.name_lower}()
|
||||
.set_${property.ident}(computed);
|
||||
% endif
|
||||
}
|
||||
DeclaredValue::WithVariables { .. } => unreachable!(),
|
||||
DeclaredValue::Initial => {
|
||||
|
|
|
@ -10,7 +10,8 @@ ${helpers.predefined_type("background-color", "CSSColor",
|
|||
"::cssparser::Color::RGBA(::cssparser::RGBA { red: 0., green: 0., blue: 0., alpha: 0. }) /* transparent */",
|
||||
animatable=True)}
|
||||
|
||||
<%helpers:vector_longhand name="background-image" animatable="False">
|
||||
<%helpers:vector_longhand name="background-image" animatable="False"
|
||||
has_uncacheable_values="${product == 'gecko'}">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::specified::Image;
|
||||
|
|
|
@ -146,7 +146,8 @@ ${helpers.single_keyword("mask-composite",
|
|||
products="gecko",
|
||||
animatable=False)}
|
||||
|
||||
<%helpers:vector_longhand name="mask-image" products="gecko" animatable="False">
|
||||
<%helpers:vector_longhand name="mask-image" products="gecko" animatable="False"
|
||||
has_uncacheable_values="${product == 'gecko'}">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use url::Url;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue