diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/style/style_pending_image.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/style/style_pending_image.cc | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/chromium/third_party/blink/renderer/core/style/style_pending_image.cc b/chromium/third_party/blink/renderer/core/style/style_pending_image.cc index f793daca994..eb1be629218 100644 --- a/chromium/third_party/blink/renderer/core/style/style_pending_image.cc +++ b/chromium/third_party/blink/renderer/core/style/style_pending_image.cc @@ -4,27 +4,69 @@ #include "third_party/blink/renderer/core/style/style_pending_image.h" +#include "third_party/blink/renderer/core/css/css_crossfade_value.h" +#include "third_party/blink/renderer/core/css/css_gradient_value.h" +#include "third_party/blink/renderer/core/css/css_identifier_value.h" #include "third_party/blink/renderer/core/css/css_image_generator_value.h" #include "third_party/blink/renderer/core/css/css_image_set_value.h" #include "third_party/blink/renderer/core/css/css_image_value.h" +#include "third_party/blink/renderer/core/css/css_paint_value.h" #include "third_party/blink/renderer/core/style/computed_style.h" namespace blink { -CSSValue* StylePendingImage::ComputedCSSValue(const ComputedStyle& style, - bool allow_visited_style) const { - DCHECK(style.IsEnsuredInDisplayNone() || - style.Display() == EDisplay::kContents); +namespace { + +class ComputedCSSValueBuilder { + STACK_ALLOCATED(); + + public: + ComputedCSSValueBuilder(const ComputedStyle& style, bool allow_visited_style) + : style_(style), allow_visited_style_(allow_visited_style) {} + + CSSValue* Build(CSSValue* value) const; + + private: + CSSValue* CrossfadeArgument(CSSValue*) const; + + const ComputedStyle& style_; + const bool allow_visited_style_; +}; - CSSValue* value = CssValue(); +CSSValue* ComputedCSSValueBuilder::CrossfadeArgument(CSSValue* value) const { + if (auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) { + DCHECK_EQ(identifier_value->GetValueID(), CSSValueID::kNone); + return value; + } + return Build(value); +} + +CSSValue* ComputedCSSValueBuilder::Build(CSSValue* value) const { if (auto* image_value = DynamicTo<CSSImageValue>(value)) return image_value->ValueWithURLMadeAbsolute(); if (auto* image_set_value = DynamicTo<CSSImageSetValue>(value)) return image_set_value->ValueWithURLsMadeAbsolute(); - if (auto* image_generator_value = DynamicTo<CSSImageGeneratorValue>(value)) - return image_generator_value->ComputedCSSValue(style, allow_visited_style); + if (auto* image_crossfade = DynamicTo<cssvalue::CSSCrossfadeValue>(value)) { + return MakeGarbageCollected<cssvalue::CSSCrossfadeValue>( + CrossfadeArgument(&image_crossfade->From()), + CrossfadeArgument(&image_crossfade->To()), + &image_crossfade->Percentage()); + } + if (IsA<CSSPaintValue>(value)) + return value; + if (auto* image_gradient_value = DynamicTo<cssvalue::CSSGradientValue>(value)) + return image_gradient_value->ComputedCSSValue(style_, allow_visited_style_); NOTREACHED(); return value; } +} // namespace + +CSSValue* StylePendingImage::ComputedCSSValue(const ComputedStyle& style, + bool allow_visited_style) const { + DCHECK(style.IsEnsuredInDisplayNone() || + style.Display() == EDisplay::kContents); + return ComputedCSSValueBuilder(style, allow_visited_style).Build(CssValue()); +} + } // namespace blink |