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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 class CSSImageSetValue : public CSSValueList { | 40 class CSSImageSetValue : public CSSValueList { |
41 public: | 41 public: |
42 | 42 |
43 static PassRefPtrWillBeRawPtr<CSSImageSetValue> create() | 43 static PassRefPtrWillBeRawPtr<CSSImageSetValue> create() |
44 { | 44 { |
45 return adoptRefWillBeNoop(new CSSImageSetValue()); | 45 return adoptRefWillBeNoop(new CSSImageSetValue()); |
46 } | 46 } |
47 ~CSSImageSetValue(); | 47 ~CSSImageSetValue(); |
48 | 48 |
49 bool isCachePending(float deviceScaleFactor) const; | 49 StyleFetchedImageSet* cachedImageSet(Document*, float deviceScaleFactor, con
st ResourceLoaderOptions&); |
50 StyleImage* cachedImageSet(float deviceScaleFactor); | 50 StyleFetchedImageSet* cachedImageSet(Document*, float deviceScaleFactor); |
51 StyleFetchedImageSet* cacheImageSet(Document*, float deviceScaleFactor, cons
t ResourceLoaderOptions&); | 51 |
52 StyleFetchedImageSet* cacheImageSet(Document*, float deviceScaleFactor); | 52 // Returns a StyleFetchedImageSet if the best fit image has been cached alre
ady, otherwise a StylePendingImage. |
| 53 StyleImage* cachedOrPendingImageSet(float); |
53 | 54 |
54 String customCSSText() const; | 55 String customCSSText() const; |
55 | 56 |
| 57 bool isPending() const { return !m_accessedBestFitImage; } |
| 58 |
56 struct ImageWithScale { | 59 struct ImageWithScale { |
57 ALLOW_ONLY_INLINE_ALLOCATION(); | 60 ALLOW_ONLY_INLINE_ALLOCATION(); |
58 String imageURL; | 61 String imageURL; |
59 Referrer referrer; | 62 Referrer referrer; |
60 float scaleFactor; | 63 float scaleFactor; |
61 }; | 64 }; |
62 | 65 |
63 PassRefPtrWillBeRawPtr<CSSImageSetValue> valueWithURLsMadeAbsolute(); | 66 PassRefPtrWillBeRawPtr<CSSImageSetValue> valueWithURLsMadeAbsolute(); |
64 | 67 |
65 bool hasFailedOrCanceledSubresources() const; | 68 bool hasFailedOrCanceledSubresources() const; |
66 | 69 |
67 DECLARE_TRACE_AFTER_DISPATCH(); | 70 DECLARE_TRACE_AFTER_DISPATCH(); |
68 | 71 |
69 protected: | 72 protected: |
70 ImageWithScale bestImageForScaleFactor(float scaleFactor); | 73 ImageWithScale bestImageForScaleFactor(); |
71 | 74 |
72 private: | 75 private: |
73 CSSImageSetValue(); | 76 CSSImageSetValue(); |
74 | 77 |
75 void fillImageSet(); | 78 void fillImageSet(); |
76 static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale
second) { return first.scaleFactor < second.scaleFactor; } | 79 static inline bool compareByScaleFactor(ImageWithScale first, ImageWithScale
second) { return first.scaleFactor < second.scaleFactor; } |
77 | 80 |
78 bool m_isCachePending; | 81 RefPtrWillBeMember<StyleImage> m_imageSet; |
79 float m_cachedScaleFactor; | 82 bool m_accessedBestFitImage; |
80 RefPtrWillBeMember<StyleImage> m_cachedImageSet; | 83 |
| 84 // This represents the scale factor that we used to find the best fit image.
It does not necessarily |
| 85 // correspond to the scale factor of the best fit image. |
| 86 float m_scaleFactor; |
81 | 87 |
82 Vector<ImageWithScale> m_imagesInSet; | 88 Vector<ImageWithScale> m_imagesInSet; |
83 }; | 89 }; |
84 | 90 |
85 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageSetValue, isImageSetValue()); | 91 DEFINE_CSS_VALUE_TYPE_CASTS(CSSImageSetValue, isImageSetValue()); |
86 | 92 |
87 } // namespace blink | 93 } // namespace blink |
88 | 94 |
89 #endif // CSSImageSetValue_h | 95 #endif // CSSImageSetValue_h |
OLD | NEW |