1 /* 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 24 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_GENERATED_IMAGE_H_ 25 #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_GENERATED_IMAGE_H_ 26 27 #include "third_party/blink/renderer/core/core_export.h" 28 #include "third_party/blink/renderer/core/style/style_image.h" 29 #include "third_party/blink/renderer/platform/wtf/casting.h" 30 31 namespace blink { 32 33 class CSSValue; 34 class CSSImageGeneratorValue; 35 class Document; 36 class ImageResourceObserver; 37 38 // This class represents a generated <image> such as a gradient, cross-fade or 39 // paint(...) function. 40 class CORE_EXPORT StyleGeneratedImage final : public StyleImage { 41 public: 42 explicit StyleGeneratedImage(const CSSImageGeneratorValue&); 43 Data()44 WrappedImagePtr Data() const override { return image_generator_value_.Get(); } 45 46 CSSValue* CssValue() const override; 47 CSSValue* ComputedCSSValue(const ComputedStyle&, 48 bool allow_visited_style) const override; 49 50 FloatSize ImageSize(const Document&, 51 float multiplier, 52 const FloatSize& default_object_size, 53 RespectImageOrientationEnum) const override; HasIntrinsicSize()54 bool HasIntrinsicSize() const override { return fixed_size_; } 55 void AddClient(ImageResourceObserver*) override; 56 void RemoveClient(ImageResourceObserver*) override; 57 // The |target_size| is the desired image size 58 scoped_refptr<Image> GetImage(const ImageResourceObserver&, 59 const Document&, 60 const ComputedStyle&, 61 const FloatSize& target_size) const override; 62 bool KnownToBeOpaque(const Document&, const ComputedStyle&) const override; 63 64 bool IsUsingCustomProperty(const AtomicString& custom_property_name, 65 const Document&) const; 66 67 void Trace(Visitor*) const override; 68 69 private: 70 bool IsEqual(const StyleImage&) const override; 71 72 // TODO(sashab): Replace this with <const CSSImageGeneratorValue> once 73 // Member<> supports const types. 74 Member<CSSImageGeneratorValue> image_generator_value_; 75 const bool fixed_size_; 76 }; 77 78 template <> 79 struct DowncastTraits<StyleGeneratedImage> { 80 static bool AllowFrom(const StyleImage& styleImage) { 81 return styleImage.IsGeneratedImage(); 82 } 83 }; 84 85 } // namespace blink 86 #endif 87