Bug 1942816 - Simplify computed/specified url split. r=dshin
This was only needed because computed images serialized differently, but
we fixed that in bug 1738693.
Differential Revision: https://phabricator.services.mozilla.com/D234968
This commit is contained in:
@@ -1113,16 +1113,6 @@ void Gecko_GetComputedURLSpec(const StyleComputedUrl* aURL, nsCString* aOut) {
|
|||||||
aOut->Assign(aURL->SpecifiedSerialization());
|
aOut->Assign(aURL->SpecifiedSerialization());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Gecko_GetComputedImageURLSpec(aURL, aOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Gecko_GetComputedImageURLSpec(const StyleComputedUrl* aURL,
|
|
||||||
nsCString* aOut) {
|
|
||||||
if (aURL->IsLocalRef() &&
|
|
||||||
StaticPrefs::layout_css_computed_style_dont_resolve_image_local_refs()) {
|
|
||||||
aOut->Assign(aURL->SpecifiedSerialization());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nsIURI* uri = aURL->GetURI()) {
|
if (nsIURI* uri = aURL->GetURI()) {
|
||||||
nsresult rv = uri->GetSpec(*aOut);
|
nsresult rv = uri->GetSpec(*aOut);
|
||||||
|
|||||||
@@ -318,8 +318,8 @@ void Gecko_CopyImageOrientationFrom(nsStyleVisibility* aDst,
|
|||||||
// list-style-image style.
|
// list-style-image style.
|
||||||
void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
|
void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
|
||||||
|
|
||||||
void Gecko_SetListStyleImageImageValue(
|
void Gecko_SetListStyleImageImageValue(nsStyleList* style_struct,
|
||||||
nsStyleList* style_struct, const mozilla::StyleComputedImageUrl* url);
|
const mozilla::StyleComputedUrl* url);
|
||||||
|
|
||||||
void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
|
void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
|
||||||
|
|
||||||
@@ -425,9 +425,6 @@ void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
|
|||||||
void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl* url,
|
void Gecko_GetComputedURLSpec(const mozilla::StyleComputedUrl* url,
|
||||||
nsCString* spec);
|
nsCString* spec);
|
||||||
|
|
||||||
void Gecko_GetComputedImageURLSpec(const mozilla::StyleComputedUrl* url,
|
|
||||||
nsCString* spec);
|
|
||||||
|
|
||||||
// Return true if the given image MIME type is supported
|
// Return true if the given image MIME type is supported
|
||||||
bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type,
|
bool Gecko_IsSupportedImageMimeType(const uint8_t* mime_type,
|
||||||
const uint32_t len);
|
const uint32_t len);
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ void ImageLoader::ClearFrames(nsPresContext* aPresContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CORSMode EffectiveCorsMode(nsIURI* aURI,
|
static CORSMode EffectiveCorsMode(nsIURI* aURI,
|
||||||
const StyleComputedImageUrl& aImage) {
|
const StyleComputedUrl& aImage) {
|
||||||
MOZ_ASSERT(aURI);
|
MOZ_ASSERT(aURI);
|
||||||
StyleCorsMode mode = aImage.CorsMode();
|
StyleCorsMode mode = aImage.CorsMode();
|
||||||
if (mode == StyleCorsMode::None) {
|
if (mode == StyleCorsMode::None) {
|
||||||
@@ -420,7 +420,7 @@ static CORSMode EffectiveCorsMode(nsIURI* aURI,
|
|||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
already_AddRefed<imgRequestProxy> ImageLoader::LoadImage(
|
already_AddRefed<imgRequestProxy> ImageLoader::LoadImage(
|
||||||
const StyleComputedImageUrl& aImage, Document& aDocument) {
|
const StyleComputedUrl& aImage, Document& aDocument) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
nsIURI* uri = aImage.GetURI();
|
nsIURI* uri = aImage.GetURI();
|
||||||
if (!uri) {
|
if (!uri) {
|
||||||
|
|||||||
@@ -533,9 +533,7 @@ cbindgen-types = [
|
|||||||
{ gecko = "StyleGenericCalcNode", servo = "crate::values::generics::calc::GenericCalcNode" },
|
{ gecko = "StyleGenericCalcNode", servo = "crate::values::generics::calc::GenericCalcNode" },
|
||||||
{ gecko = "StyleCssUrl", servo = "crate::gecko::url::CssUrl" },
|
{ gecko = "StyleCssUrl", servo = "crate::gecko::url::CssUrl" },
|
||||||
{ gecko = "StyleSpecifiedUrl", servo = "crate::gecko::url::SpecifiedUrl" },
|
{ gecko = "StyleSpecifiedUrl", servo = "crate::gecko::url::SpecifiedUrl" },
|
||||||
{ gecko = "StyleSpecifiedImageUrl", servo = "crate::gecko::url::SpecifiedImageUrl" },
|
|
||||||
{ gecko = "StyleComputedUrl", servo = "crate::gecko::url::ComputedUrl" },
|
{ gecko = "StyleComputedUrl", servo = "crate::gecko::url::ComputedUrl" },
|
||||||
{ gecko = "StyleComputedImageUrl", servo = "crate::gecko::url::ComputedImageUrl" },
|
|
||||||
{ gecko = "StyleLoadData", servo = "crate::gecko::url::LoadData" },
|
{ gecko = "StyleLoadData", servo = "crate::gecko::url::LoadData" },
|
||||||
{ gecko = "StyleGenericFilter", servo = "crate::values::generics::effects::Filter" },
|
{ gecko = "StyleGenericFilter", servo = "crate::values::generics::effects::Filter" },
|
||||||
{ gecko = "StyleGenericGradient", servo = "crate::values::generics::image::Gradient" },
|
{ gecko = "StyleGenericGradient", servo = "crate::values::generics::image::Gradient" },
|
||||||
|
|||||||
@@ -442,11 +442,11 @@ inline bool StyleComputedUrl::HasRef() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool StyleComputedImageUrl::IsImageResolved() const {
|
inline bool StyleComputedUrl::IsImageResolved() const {
|
||||||
return bool(LoadData().flags & StyleLoadDataFlags::TRIED_TO_RESOLVE_IMAGE);
|
return bool(LoadData().flags & StyleLoadDataFlags::TRIED_TO_RESOLVE_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline imgRequestProxy* StyleComputedImageUrl::GetImage() const {
|
inline imgRequestProxy* StyleComputedUrl::GetImage() const {
|
||||||
MOZ_ASSERT(IsImageResolved());
|
MOZ_ASSERT(IsImageResolved());
|
||||||
return LoadData().resolved_image;
|
return LoadData().resolved_image;
|
||||||
}
|
}
|
||||||
@@ -1005,8 +1005,7 @@ inline bool StyleImage::IsImageRequestType() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline const StyleComputedImageUrl* StyleImage::GetImageRequestURLValue()
|
inline const StyleComputedUrl* StyleImage::GetImageRequestURLValue() const {
|
||||||
const {
|
|
||||||
const auto& finalImage = FinalImage();
|
const auto& finalImage = FinalImage();
|
||||||
if (finalImage.IsUrl()) {
|
if (finalImage.IsUrl()) {
|
||||||
return &finalImage.AsUrl();
|
return &finalImage.AsUrl();
|
||||||
|
|||||||
@@ -1550,7 +1550,7 @@ void StyleImage::ResolveImage(Document& aDoc, const StyleImage* aOld) {
|
|||||||
const auto* url = GetImageRequestURLValue();
|
const auto* url = GetImageRequestURLValue();
|
||||||
// We could avoid this const_cast generating more code but it's not really
|
// We could avoid this const_cast generating more code but it's not really
|
||||||
// worth it.
|
// worth it.
|
||||||
const_cast<StyleComputedImageUrl*>(url)->ResolveImage(aDoc, old);
|
const_cast<StyleComputedUrl*>(url)->ResolveImage(aDoc, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@@ -1903,7 +1903,7 @@ bool nsStyleImageLayers::Layer::operator==(const Layer& aOther) const {
|
|||||||
template <class ComputedValueItem>
|
template <class ComputedValueItem>
|
||||||
static void FillImageLayerList(
|
static void FillImageLayerList(
|
||||||
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
|
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
|
||||||
ComputedValueItem nsStyleImageLayers::Layer::*aResultLocation,
|
ComputedValueItem nsStyleImageLayers::Layer::* aResultLocation,
|
||||||
uint32_t aItemCount, uint32_t aFillCount) {
|
uint32_t aItemCount, uint32_t aFillCount) {
|
||||||
MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
|
MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
|
||||||
for (uint32_t sourceLayer = 0, destLayer = aItemCount; destLayer < aFillCount;
|
for (uint32_t sourceLayer = 0, destLayer = aItemCount; destLayer < aFillCount;
|
||||||
@@ -1916,7 +1916,7 @@ static void FillImageLayerList(
|
|||||||
// layer.mPosition.*aResultLocation instead of layer.*aResultLocation.
|
// layer.mPosition.*aResultLocation instead of layer.*aResultLocation.
|
||||||
static void FillImageLayerPositionCoordList(
|
static void FillImageLayerPositionCoordList(
|
||||||
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
|
nsStyleAutoArray<nsStyleImageLayers::Layer>& aLayers,
|
||||||
LengthPercentage Position::*aResultLocation, uint32_t aItemCount,
|
LengthPercentage Position::* aResultLocation, uint32_t aItemCount,
|
||||||
uint32_t aFillCount) {
|
uint32_t aFillCount) {
|
||||||
MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
|
MOZ_ASSERT(aFillCount <= aLayers.Length(), "unexpected array length");
|
||||||
for (uint32_t sourceLayer = 0, destLayer = aItemCount; destLayer < aFillCount;
|
for (uint32_t sourceLayer = 0, destLayer = aItemCount; destLayer < aFillCount;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ static already_AddRefed<nsIURI> GetBaseURLForLocalRef(nsIContent* content,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static already_AddRefed<URLAndReferrerInfo> ResolveURLUsingLocalRef(
|
static already_AddRefed<URLAndReferrerInfo> ResolveURLUsingLocalRef(
|
||||||
nsIFrame* aFrame, const StyleComputedImageUrl& aURL) {
|
nsIFrame* aFrame, const StyleComputedUrl& aURL) {
|
||||||
MOZ_ASSERT(aFrame);
|
MOZ_ASSERT(aFrame);
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri = aURL.GetURI();
|
nsCOMPtr<nsIURI> uri = aURL.GetURI();
|
||||||
@@ -1016,7 +1016,7 @@ SVGMaskObserverList::SVGMaskObserverList(nsIFrame* aFrame) : mFrame(aFrame) {
|
|||||||
const nsStyleSVGReset* svgReset = aFrame->StyleSVGReset();
|
const nsStyleSVGReset* svgReset = aFrame->StyleSVGReset();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < svgReset->mMask.mImageCount; i++) {
|
for (uint32_t i = 0; i < svgReset->mMask.mImageCount; i++) {
|
||||||
const StyleComputedImageUrl* data =
|
const StyleComputedUrl* data =
|
||||||
svgReset->mMask.mLayers[i].mImage.GetImageRequestURLValue();
|
svgReset->mMask.mLayers[i].mImage.GetImageRequestURLValue();
|
||||||
RefPtr<URLAndReferrerInfo> maskUri;
|
RefPtr<URLAndReferrerInfo> maskUri;
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|||||||
@@ -9315,16 +9315,6 @@
|
|||||||
value: true
|
value: true
|
||||||
mirror: always
|
mirror: always
|
||||||
|
|
||||||
# Whether computed local-fragment-only image urls serialize using the same
|
|
||||||
# rules as filter/mask/etc (not resolving the URL for local refs).
|
|
||||||
#
|
|
||||||
# See https://github.com/w3c/csswg-drafts/issues/3195
|
|
||||||
- name: layout.css.computed-style.dont-resolve-image-local-refs
|
|
||||||
type: RelaxedAtomicBool
|
|
||||||
value: true
|
|
||||||
mirror: always
|
|
||||||
rust: true
|
|
||||||
|
|
||||||
# Are implicit tracks in computed grid templates serialized?
|
# Are implicit tracks in computed grid templates serialized?
|
||||||
- name: layout.css.serialize-grid-implicit-tracks
|
- name: layout.css.serialize-grid-implicit-tracks
|
||||||
type: RelaxedAtomicBool
|
type: RelaxedAtomicBool
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ impl PartialEq for CssUrlData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CssUrl {
|
impl CssUrl {
|
||||||
fn parse_with_cors_mode<'i, 't>(
|
/// Parse a URL with a particular CORS mode.
|
||||||
|
pub fn parse_with_cors_mode<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
cors_mode: CorsMode,
|
cors_mode: CorsMode,
|
||||||
@@ -278,52 +279,6 @@ impl ToComputedValue for SpecifiedUrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specified image `url()` value.
|
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
|
|
||||||
pub struct SpecifiedImageUrl(pub SpecifiedUrl);
|
|
||||||
|
|
||||||
impl SpecifiedImageUrl {
|
|
||||||
/// Parse a URL from a string value that is a valid CSS token for a URL.
|
|
||||||
pub fn parse_from_string(url: String, context: &ParserContext, cors_mode: CorsMode) -> Self {
|
|
||||||
SpecifiedImageUrl(SpecifiedUrl::parse_from_string(url, context, cors_mode))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Provides an alternate method for parsing that associates the URL
|
|
||||||
/// with anonymous CORS headers.
|
|
||||||
pub fn parse_with_cors_mode<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
cors_mode: CorsMode,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
Ok(SpecifiedImageUrl(SpecifiedUrl::parse_with_cors_mode(
|
|
||||||
context, input, cors_mode,
|
|
||||||
)?))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for SpecifiedImageUrl {
|
|
||||||
fn parse<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
SpecifiedUrl::parse(context, input).map(SpecifiedImageUrl)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToComputedValue for SpecifiedImageUrl {
|
|
||||||
type ComputedValue = ComputedImageUrl;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
|
||||||
ComputedImageUrl(self.0.to_computed_value(context))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
|
||||||
SpecifiedImageUrl(ToComputedValue::from_computed_value(&computed.0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The computed value of a CSS non-image `url()`.
|
/// The computed value of a CSS non-image `url()`.
|
||||||
///
|
///
|
||||||
/// The only difference between specified and computed URLs is the
|
/// The only difference between specified and computed URLs is the
|
||||||
@@ -360,21 +315,6 @@ impl ToCss for ComputedUrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The computed value of a CSS image `url()`.
|
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
|
|
||||||
#[repr(transparent)]
|
|
||||||
pub struct ComputedImageUrl(pub ComputedUrl);
|
|
||||||
|
|
||||||
impl ToCss for ComputedImageUrl {
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
||||||
where
|
|
||||||
W: Write,
|
|
||||||
{
|
|
||||||
self.0
|
|
||||||
.serialize_with(bindings::Gecko_GetComputedImageURLSpec, dest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// A table mapping CssUrlData objects to their lazily created LoadData
|
/// A table mapping CssUrlData objects to their lazily created LoadData
|
||||||
/// objects.
|
/// objects.
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ impl ToComputedValue for SpecifiedUrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specified image url() value for servo.
|
|
||||||
pub type SpecifiedImageUrl = CssUrl;
|
|
||||||
|
|
||||||
/// The computed value of a CSS `url()`, resolved relative to the stylesheet URL.
|
/// The computed value of a CSS `url()`, resolved relative to the stylesheet URL.
|
||||||
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
|
||||||
pub enum ComputedUrl {
|
pub enum ComputedUrl {
|
||||||
@@ -241,6 +238,3 @@ impl ToCss for ComputedUrl {
|
|||||||
dest.write_char(')')
|
dest.write_char(')')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The computed value of a CSS `url()` for image.
|
|
||||||
pub type ComputedImageUrl = ComputedUrl;
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
use crate::values::computed::percentage::Percentage;
|
use crate::values::computed::percentage::Percentage;
|
||||||
use crate::values::computed::position::Position;
|
use crate::values::computed::position::Position;
|
||||||
use crate::values::computed::url::ComputedImageUrl;
|
use crate::values::computed::url::ComputedUrl;
|
||||||
use crate::values::computed::{Angle, Color, Context};
|
use crate::values::computed::{Angle, Color, Context};
|
||||||
use crate::values::computed::{
|
use crate::values::computed::{
|
||||||
AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
|
AngleOrPercentage, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
|
||||||
@@ -26,7 +26,7 @@ pub use specified::ImageRendering;
|
|||||||
|
|
||||||
/// Computed values for an image according to CSS-IMAGES.
|
/// Computed values for an image according to CSS-IMAGES.
|
||||||
/// <https://drafts.csswg.org/css-images/#image-values>
|
/// <https://drafts.csswg.org/css-images/#image-values>
|
||||||
pub type Image = generic::GenericImage<Gradient, ComputedImageUrl, Color, Percentage, Resolution>;
|
pub type Image = generic::GenericImage<Gradient, ComputedUrl, Color, Percentage, Resolution>;
|
||||||
|
|
||||||
// Images should remain small, see https://github.com/servo/servo/pull/18430
|
// Images should remain small, see https://github.com/servo/servo/pull/18430
|
||||||
size_of_test!(Image, 16);
|
size_of_test!(Image, 16);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
use crate::values::generics::url::UrlOrNone as GenericUrlOrNone;
|
use crate::values::generics::url::UrlOrNone as GenericUrlOrNone;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use crate::gecko::url::{ComputedImageUrl, ComputedUrl};
|
pub use crate::gecko::url::ComputedUrl;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub use crate::servo::url::{ComputedImageUrl, ComputedUrl};
|
pub use crate::servo::url::ComputedUrl;
|
||||||
|
|
||||||
/// Computed <url> | <none>
|
/// Computed <url> | <none>
|
||||||
pub type UrlOrNone = GenericUrlOrNone<ComputedUrl>;
|
pub type UrlOrNone = GenericUrlOrNone<ComputedUrl>;
|
||||||
|
|||||||
@@ -95,8 +95,6 @@ trivial_to_resolved_value!(crate::values::AtomIdent);
|
|||||||
trivial_to_resolved_value!(crate::custom_properties::VariableValue);
|
trivial_to_resolved_value!(crate::custom_properties::VariableValue);
|
||||||
trivial_to_resolved_value!(crate::stylesheets::UrlExtraData);
|
trivial_to_resolved_value!(crate::stylesheets::UrlExtraData);
|
||||||
trivial_to_resolved_value!(computed::url::ComputedUrl);
|
trivial_to_resolved_value!(computed::url::ComputedUrl);
|
||||||
#[cfg(feature = "gecko")]
|
|
||||||
trivial_to_resolved_value!(computed::url::ComputedImageUrl);
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
trivial_to_resolved_value!(crate::Namespace);
|
trivial_to_resolved_value!(crate::Namespace);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use crate::values::generics::position::Position as GenericPosition;
|
|||||||
use crate::values::generics::NonNegative;
|
use crate::values::generics::NonNegative;
|
||||||
use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword};
|
use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPositionKeyword};
|
||||||
use crate::values::specified::position::{Position, PositionComponent, Side};
|
use crate::values::specified::position::{Position, PositionComponent, Side};
|
||||||
use crate::values::specified::url::SpecifiedImageUrl;
|
use crate::values::specified::url::SpecifiedUrl;
|
||||||
use crate::values::specified::{
|
use crate::values::specified::{
|
||||||
Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength,
|
Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength,
|
||||||
NonNegativeLengthPercentage, Resolution,
|
NonNegativeLengthPercentage, Resolution,
|
||||||
@@ -40,7 +40,7 @@ fn gradient_color_interpolation_method_enabled() -> bool {
|
|||||||
|
|
||||||
/// Specified values for an image according to CSS-IMAGES.
|
/// Specified values for an image according to CSS-IMAGES.
|
||||||
/// <https://drafts.csswg.org/css-images/#image-values>
|
/// <https://drafts.csswg.org/css-images/#image-values>
|
||||||
pub type Image = generic::Image<Gradient, SpecifiedImageUrl, Color, Percentage, Resolution>;
|
pub type Image = generic::Image<Gradient, SpecifiedUrl, Color, Percentage, Resolution>;
|
||||||
|
|
||||||
// Images should remain small, see https://github.com/servo/servo/pull/18430
|
// Images should remain small, see https://github.com/servo/servo/pull/18430
|
||||||
size_of_test!(Image, 16);
|
size_of_test!(Image, 16);
|
||||||
@@ -216,7 +216,7 @@ impl Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(url) = input
|
if let Ok(url) = input
|
||||||
.try_parse(|input| SpecifiedImageUrl::parse_with_cors_mode(context, input, cors_mode))
|
.try_parse(|input| SpecifiedUrl::parse_with_cors_mode(context, input, cors_mode))
|
||||||
{
|
{
|
||||||
return Ok(generic::Image::Url(url));
|
return Ok(generic::Image::Url(url));
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,7 @@ impl ImageSetItem {
|
|||||||
flags: ParseImageFlags,
|
flags: ParseImageFlags,
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
let image = match input.try_parse(|i| i.expect_url_or_string()) {
|
let image = match input.try_parse(|i| i.expect_url_or_string()) {
|
||||||
Ok(url) => Image::Url(SpecifiedImageUrl::parse_from_string(
|
Ok(url) => Image::Url(SpecifiedUrl::parse_from_string(
|
||||||
url.as_ref().into(),
|
url.as_ref().into(),
|
||||||
context,
|
context,
|
||||||
cors_mode,
|
cors_mode,
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
use crate::values::generics::url::GenericUrlOrNone;
|
use crate::values::generics::url::GenericUrlOrNone;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use crate::gecko::url::{SpecifiedImageUrl, SpecifiedUrl};
|
pub use crate::gecko::url::SpecifiedUrl;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub use crate::servo::url::{SpecifiedImageUrl, SpecifiedUrl};
|
pub use crate::servo::url::SpecifiedUrl;
|
||||||
|
|
||||||
/// Specified <url> | <none>
|
/// Specified <url> | <none>
|
||||||
pub type UrlOrNone = GenericUrlOrNone<SpecifiedUrl>;
|
pub type UrlOrNone = GenericUrlOrNone<SpecifiedUrl>;
|
||||||
|
|||||||
@@ -257,7 +257,6 @@ include = [
|
|||||||
"Translate",
|
"Translate",
|
||||||
"BorderImageWidth",
|
"BorderImageWidth",
|
||||||
"ComputedUrl",
|
"ComputedUrl",
|
||||||
"ComputedImageUrl",
|
|
||||||
"UrlOrNone",
|
"UrlOrNone",
|
||||||
"Filter",
|
"Filter",
|
||||||
"Gradient",
|
"Gradient",
|
||||||
@@ -946,7 +945,7 @@ renaming_overrides_prefixing = true
|
|||||||
bool IsImageRequestType() const;
|
bool IsImageRequestType() const;
|
||||||
|
|
||||||
// Gets the image request URL.
|
// Gets the image request URL.
|
||||||
const StyleComputedImageUrl* GetImageRequestURLValue() const;
|
const StyleComputedUrl* GetImageRequestURLValue() const;
|
||||||
|
|
||||||
// Gets the image data of this image if it has any image request.
|
// Gets the image data of this image if it has any image request.
|
||||||
imgRequestProxy* GetImageRequest() const;
|
imgRequestProxy* GetImageRequest() const;
|
||||||
|
|||||||
@@ -5937,7 +5937,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(
|
|||||||
use style::properties::PropertyDeclaration;
|
use style::properties::PropertyDeclaration;
|
||||||
use style::stylesheets::CorsMode;
|
use style::stylesheets::CorsMode;
|
||||||
use style::values::generics::image::Image;
|
use style::values::generics::image::Image;
|
||||||
use style::values::specified::url::SpecifiedImageUrl;
|
use style::values::specified::url::SpecifiedUrl;
|
||||||
|
|
||||||
let url_data = UrlExtraData::from_ptr_ref(&raw_extra_data);
|
let url_data = UrlExtraData::from_ptr_ref(&raw_extra_data);
|
||||||
let string = value.as_str_unchecked();
|
let string = value.as_str_unchecked();
|
||||||
@@ -5951,7 +5951,7 @@ pub unsafe extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
let url = SpecifiedImageUrl::parse_from_string(string.into(), &context, CorsMode::None);
|
let url = SpecifiedUrl::parse_from_string(string.into(), &context, CorsMode::None);
|
||||||
let decl = PropertyDeclaration::BackgroundImage(BackgroundImage(vec![Image::Url(url)].into()));
|
let decl = PropertyDeclaration::BackgroundImage(BackgroundImage(vec![Image::Url(url)].into()));
|
||||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
decls.push(decl, Importance::Normal);
|
decls.push(decl, Importance::Normal);
|
||||||
|
|||||||
Reference in New Issue
Block a user