зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1684909 - Make rendering aware of image-set(). r=dholbert
Differential Revision: https://phabricator.services.mozilla.com/D100700
This commit is contained in:
Родитель
50180b37c8
Коммит
ff64e2ac94
|
@ -1879,7 +1879,8 @@ bool nsCSSRendering::CanBuildWebRenderDisplayItemsForStyleImageLayer(
|
|||
|
||||
// We only support painting gradients and image for a single style image
|
||||
// layer, and we don't support crop-rects.
|
||||
const auto& styleImage = aBackgroundStyle->mImage.mLayers[aLayer].mImage;
|
||||
const auto& styleImage =
|
||||
aBackgroundStyle->mImage.mLayers[aLayer].mImage.FinalImage();
|
||||
if (styleImage.IsImageRequestType()) {
|
||||
if (styleImage.IsRect()) {
|
||||
return false;
|
||||
|
|
|
@ -50,8 +50,8 @@ nsSize CSSSizeOrRatio::ComputeConcreteSize() const {
|
|||
nsImageRenderer::nsImageRenderer(nsIFrame* aForFrame, const StyleImage* aImage,
|
||||
uint32_t aFlags)
|
||||
: mForFrame(aForFrame),
|
||||
mImage(aImage),
|
||||
mType(aImage->tag),
|
||||
mImage(&aImage->FinalImage()),
|
||||
mType(mImage->tag),
|
||||
mImageContainer(nullptr),
|
||||
mGradientData(nullptr),
|
||||
mPaintServerFrame(nullptr),
|
||||
|
@ -265,7 +265,8 @@ CSSSizeOrRatio nsImageRenderer::ComputeIntrinsicSize() {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case StyleImage::Tag::ImageSet: // TODO
|
||||
case StyleImage::Tag::ImageSet:
|
||||
MOZ_FALLTHROUGH_ASSERT("image-set should be resolved already");
|
||||
// Bug 546052 cross-fade not yet implemented.
|
||||
case StyleImage::Tag::CrossFade:
|
||||
// Per <http://dev.w3.org/csswg/css3-images/#gradients>, gradients have no
|
||||
|
@ -520,10 +521,11 @@ ImgDrawResult nsImageRenderer::Draw(nsPresContext* aPresContext,
|
|||
aOpacity);
|
||||
break;
|
||||
}
|
||||
case StyleImage::Tag::ImageSet:
|
||||
MOZ_FALLTHROUGH_ASSERT("image-set should be resolved already");
|
||||
// See bug 546052 - cross-fade implementation still being worked
|
||||
// on.
|
||||
case StyleImage::Tag::CrossFade:
|
||||
case StyleImage::Tag::ImageSet: // TODO
|
||||
case StyleImage::Tag::None:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -932,19 +932,30 @@ inline bool RestyleHint::DefinitelyRecascadesAllSubtree() const {
|
|||
return bool(*this & (RESTYLE_SELF | RECASCADE_SELF));
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const StyleImage& StyleImage::FinalImage() const {
|
||||
if (!IsImageSet()) {
|
||||
return *this;
|
||||
}
|
||||
auto& set = AsImageSet();
|
||||
return set->items.AsSpan()[set->selected_index].image.FinalImage();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool StyleImage::IsImageRequestType() const {
|
||||
return IsUrl() || IsRect();
|
||||
auto& finalImage = FinalImage();
|
||||
return finalImage.IsUrl() || finalImage.IsRect();
|
||||
}
|
||||
|
||||
template <>
|
||||
inline const StyleComputedImageUrl* StyleImage::GetImageRequestURLValue()
|
||||
const {
|
||||
if (IsUrl()) {
|
||||
return &AsUrl();
|
||||
auto& finalImage = FinalImage();
|
||||
if (finalImage.IsUrl()) {
|
||||
return &finalImage.AsUrl();
|
||||
}
|
||||
if (IsRect()) {
|
||||
return &AsRect()->url;
|
||||
if (finalImage.IsRect()) {
|
||||
return &finalImage.AsRect()->url;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1530,6 +1530,10 @@ bool StyleImage::StartDecoding() const {
|
|||
|
||||
template <>
|
||||
bool StyleImage::IsOpaque() const {
|
||||
if (IsImageSet()) {
|
||||
return FinalImage().IsOpaque();
|
||||
}
|
||||
|
||||
if (!IsComplete()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1586,12 +1590,11 @@ bool StyleImage::IsComplete() const {
|
|||
(status & imgIRequest::STATUS_SIZE_AVAILABLE) &&
|
||||
(status & imgIRequest::STATUS_FRAME_COMPLETE);
|
||||
}
|
||||
case Tag::ImageSet:
|
||||
return FinalImage().IsComplete();
|
||||
// Bug 546052 cross-fade not yet implemented.
|
||||
case Tag::CrossFade:
|
||||
return true;
|
||||
case Tag::ImageSet:
|
||||
// TODO: return if the selected image is complete.
|
||||
return true;
|
||||
}
|
||||
MOZ_ASSERT_UNREACHABLE("unexpected image type");
|
||||
return false;
|
||||
|
@ -1617,8 +1620,7 @@ bool StyleImage::IsSizeAvailable() const {
|
|||
(status & imgIRequest::STATUS_SIZE_AVAILABLE);
|
||||
}
|
||||
case Tag::ImageSet:
|
||||
// TODO: Reenter on the selected image.
|
||||
return true;
|
||||
return FinalImage().IsSizeAvailable();
|
||||
case Tag::CrossFade:
|
||||
// TODO: Bug 546052 cross-fade not yet implemented.
|
||||
return true;
|
||||
|
@ -1710,7 +1712,7 @@ nsStyleImageLayers::nsStyleImageLayers(const nsStyleImageLayers& aSource)
|
|||
|
||||
static bool AnyLayerIsElementImage(const nsStyleImageLayers& aLayers) {
|
||||
NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, aLayers) {
|
||||
if (aLayers.mLayers[i].mImage.IsElement()) {
|
||||
if (aLayers.mLayers[i].mImage.FinalImage().IsElement()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1743,8 +1745,9 @@ nsChangeHint nsStyleImageLayers::CalcDifference(
|
|||
const Layer& lessLayersLayer = lessLayers.mLayers[i];
|
||||
nsChangeHint layerDifference =
|
||||
moreLayersLayer.CalcDifference(lessLayersLayer);
|
||||
if (layerDifference && (moreLayersLayer.mImage.IsElement() ||
|
||||
lessLayersLayer.mImage.IsElement())) {
|
||||
if (layerDifference &&
|
||||
(moreLayersLayer.mImage.FinalImage().IsElement() ||
|
||||
lessLayersLayer.mImage.FinalImage().IsElement())) {
|
||||
layerDifference |=
|
||||
nsChangeHint_UpdateEffects | nsChangeHint_RepaintFrame;
|
||||
}
|
||||
|
@ -1848,6 +1851,7 @@ bool nsStyleImageLayers::operator==(const nsStyleImageLayers& aOther) const {
|
|||
static bool SizeDependsOnPositioningAreaSize(const StyleBackgroundSize& aSize,
|
||||
const StyleImage& aImage) {
|
||||
MOZ_ASSERT(!aImage.IsNone(), "caller should have handled this");
|
||||
MOZ_ASSERT(!aImage.IsImageSet(), "caller should have handled this");
|
||||
|
||||
// Contain and cover straightforwardly depend on frame size.
|
||||
if (aSize.IsCover() || aSize.IsContain()) {
|
||||
|
@ -1951,7 +1955,7 @@ bool nsStyleImageLayers::Layer::
|
|||
}
|
||||
|
||||
return mPosition.DependsOnPositioningAreaSize() ||
|
||||
SizeDependsOnPositioningAreaSize(mSize, mImage) ||
|
||||
SizeDependsOnPositioningAreaSize(mSize, mImage.FinalImage()) ||
|
||||
mRepeat.DependsOnPositioningAreaSize();
|
||||
}
|
||||
|
||||
|
|
|
@ -784,6 +784,10 @@ renaming_overrides_prefixing = true
|
|||
|
||||
"GenericImage" = """
|
||||
public:
|
||||
// If this is an image-set(), the final image we've selected, otherwise it
|
||||
// returns *this.
|
||||
const StyleGenericImage& FinalImage() const;
|
||||
|
||||
// Whether this image may have an image request associated with it.
|
||||
bool IsImageRequestType() const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче