| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #define StyleFetchedImageSet_h | 27 #define StyleFetchedImageSet_h |
| 28 | 28 |
| 29 #include "core/loader/resource/ImageResourceObserver.h" | 29 #include "core/loader/resource/ImageResourceObserver.h" |
| 30 #include "core/style/StyleImage.h" | 30 #include "core/style/StyleImage.h" |
| 31 #include "platform/geometry/LayoutSize.h" | 31 #include "platform/geometry/LayoutSize.h" |
| 32 #include "platform/weborigin/KURL.h" | 32 #include "platform/weborigin/KURL.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class CSSImageSetValue; | 36 class CSSImageSetValue; |
| 37 class ImageResourceObserver; |
| 37 | 38 |
| 38 // This class keeps one cached image and has access to a set of alternatives. | 39 // This class keeps one cached image and has access to a set of alternatives. |
| 39 | 40 |
| 40 class StyleFetchedImageSet final : public StyleImage, | 41 class StyleFetchedImageSet final : public StyleImage, |
| 41 public ImageResourceObserver { | 42 public ImageResourceObserver { |
| 42 USING_PRE_FINALIZER(StyleFetchedImageSet, Dispose); | 43 USING_PRE_FINALIZER(StyleFetchedImageSet, Dispose); |
| 43 | 44 |
| 44 public: | 45 public: |
| 45 static StyleFetchedImageSet* Create(ImageResourceContent* image, | 46 static StyleFetchedImageSet* Create(ImageResourceContent* image, |
| 46 float image_scale_factor, | 47 float image_scale_factor, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 59 WrappedImagePtr Data() const override; | 60 WrappedImagePtr Data() const override; |
| 60 | 61 |
| 61 bool CanRender() const override; | 62 bool CanRender() const override; |
| 62 bool IsLoaded() const override; | 63 bool IsLoaded() const override; |
| 63 bool ErrorOccurred() const override; | 64 bool ErrorOccurred() const override; |
| 64 LayoutSize ImageSize(const Document&, | 65 LayoutSize ImageSize(const Document&, |
| 65 float multiplier, | 66 float multiplier, |
| 66 const LayoutSize& default_object_size) const override; | 67 const LayoutSize& default_object_size) const override; |
| 67 bool ImageHasRelativeSize() const override; | 68 bool ImageHasRelativeSize() const override; |
| 68 bool UsesImageContainerSize() const override; | 69 bool UsesImageContainerSize() const override; |
| 69 void AddClient(LayoutObject*) override; | 70 void AddClient(ImageResourceObserver*) override; |
| 70 void RemoveClient(LayoutObject*) override; | 71 void RemoveClient(ImageResourceObserver*) override; |
| 71 PassRefPtr<Image> GetImage(const LayoutObject&, | 72 PassRefPtr<Image> GetImage(const ImageResourceObserver&, |
| 72 const IntSize&) const override; | 73 const Document&, |
| 74 const ComputedStyle&, |
| 75 const IntSize& container_size) const override; |
| 73 float ImageScaleFactor() const override { return image_scale_factor_; } | 76 float ImageScaleFactor() const override { return image_scale_factor_; } |
| 74 bool KnownToBeOpaque(const Document&, const ComputedStyle&) const override; | 77 bool KnownToBeOpaque(const Document&, const ComputedStyle&) const override; |
| 75 ImageResourceContent* CachedImage() const override; | 78 ImageResourceContent* CachedImage() const override; |
| 76 | 79 |
| 77 DECLARE_VIRTUAL_TRACE(); | 80 DECLARE_VIRTUAL_TRACE(); |
| 78 | 81 |
| 79 private: | 82 private: |
| 80 StyleFetchedImageSet(ImageResourceContent*, | 83 StyleFetchedImageSet(ImageResourceContent*, |
| 81 float image_scale_factor, | 84 float image_scale_factor, |
| 82 CSSImageSetValue*, | 85 CSSImageSetValue*, |
| 83 const KURL&); | 86 const KURL&); |
| 84 | 87 |
| 85 void Dispose(); | 88 void Dispose(); |
| 86 | 89 |
| 87 String DebugName() const override { return "StyleFetchedImageSet"; } | 90 String DebugName() const override { return "StyleFetchedImageSet"; } |
| 88 | 91 |
| 89 Member<ImageResourceContent> best_fit_image_; | 92 Member<ImageResourceContent> best_fit_image_; |
| 90 float image_scale_factor_; | 93 float image_scale_factor_; |
| 91 | 94 |
| 92 Member<CSSImageSetValue> image_set_value_; // Not retained; it owns us. | 95 Member<CSSImageSetValue> image_set_value_; // Not retained; it owns us. |
| 93 const KURL url_; | 96 const KURL url_; |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 DEFINE_STYLE_IMAGE_TYPE_CASTS(StyleFetchedImageSet, IsImageResourceSet()); | 99 DEFINE_STYLE_IMAGE_TYPE_CASTS(StyleFetchedImageSet, IsImageResourceSet()); |
| 97 | 100 |
| 98 } // namespace blink | 101 } // namespace blink |
| 99 | 102 |
| 100 #endif // StyleFetchedImageSet_h | 103 #endif // StyleFetchedImageSet_h |
| OLD | NEW |