OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 { | 48 { |
49 return adoptRef(new SVGImage(observer)); | 49 return adoptRef(new SVGImage(observer)); |
50 } | 50 } |
51 | 51 |
52 static bool isInSVGImage(const Node*); | 52 static bool isInSVGImage(const Node*); |
53 | 53 |
54 LayoutBox* embeddedContentBox() const; | 54 LayoutBox* embeddedContentBox() const; |
55 | 55 |
56 bool isSVGImage() const override { return true; } | 56 bool isSVGImage() const override { return true; } |
57 bool isTextureBacked() override { return false; } | 57 bool isTextureBacked() override { return false; } |
58 IntSize size() const override { return m_intrinsicSize; } | 58 IntSize size() const override { return m_concreteObjectSize; } |
59 | 59 |
60 bool currentFrameHasSingleSecurityOrigin() const override; | 60 bool currentFrameHasSingleSecurityOrigin() const override; |
61 | 61 |
62 void startAnimation(CatchUpAnimation = CatchUp) override; | 62 void startAnimation(CatchUpAnimation = CatchUp) override; |
63 void stopAnimation() override; | 63 void stopAnimation() override; |
64 void resetAnimation() override; | 64 void resetAnimation() override; |
65 | 65 |
66 // Advances an animated image. This will trigger an animation update for CSS | 66 // Advances an animated image. This will trigger an animation update for CSS |
67 // and advance the SMIL timeline by one frame. | 67 // and advance the SMIL timeline by one frame. |
68 void advanceAnimationForTesting() override; | 68 void advanceAnimationForTesting() override; |
(...skipping 14 matching lines...) Expand all Loading... |
83 | 83 |
84 private: | 84 private: |
85 friend class AXLayoutObject; | 85 friend class AXLayoutObject; |
86 friend class SVGImageChromeClient; | 86 friend class SVGImageChromeClient; |
87 friend class SVGImageForContainer; | 87 friend class SVGImageForContainer; |
88 | 88 |
89 ~SVGImage() override; | 89 ~SVGImage() override; |
90 | 90 |
91 String filenameExtension() const override; | 91 String filenameExtension() const override; |
92 | 92 |
| 93 FloatSize calculateConcreteObjectSize(const FloatSize&) const; |
93 IntSize containerSize() const; | 94 IntSize containerSize() const; |
94 bool usesContainerSize() const override { return true; } | 95 bool usesContainerSize() const override { return true; } |
95 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio) override; | 96 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei
ght, FloatSize& intrinsicRatio) override; |
96 | 97 |
97 bool dataChanged(bool allDataReceived) override; | 98 bool dataChanged(bool allDataReceived) override; |
98 | 99 |
99 // FIXME: SVGImages are underreporting decoded sizes and will be unable | 100 // FIXME: SVGImages are underreporting decoded sizes and will be unable |
100 // to prune because these functions are not implemented yet. | 101 // to prune because these functions are not implemented yet. |
101 void destroyDecodedData(bool) override { } | 102 void destroyDecodedData(bool) override { } |
102 | 103 |
103 // FIXME: Implement this to be less conservative. | 104 // FIXME: Implement this to be less conservative. |
104 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override
{ return false; } | 105 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override
{ return false; } |
105 | 106 |
106 SVGImage(ImageObserver*); | 107 SVGImage(ImageObserver*); |
107 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR
ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; | 108 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR
ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; |
108 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con
st FloatRect&, const FloatRect&, const KURL&); | 109 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con
st FloatRect&, const FloatRect&, const KURL&); |
109 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const
FloatRect&, const FloatSize&, const FloatPoint&, | 110 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const
FloatRect&, const FloatSize&, const FloatPoint&, |
110 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons
t KURL&); | 111 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons
t KURL&); |
111 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&); | 112 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&); |
112 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons
t FloatRect& toRect, RespectImageOrientationEnum, | 113 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons
t FloatRect& toRect, RespectImageOrientationEnum, |
113 ImageClampingMode, const KURL&); | 114 ImageClampingMode, const KURL&); |
114 | 115 |
115 OwnPtrWillBePersistent<SVGImageChromeClient> m_chromeClient; | 116 OwnPtrWillBePersistent<SVGImageChromeClient> m_chromeClient; |
116 OwnPtrWillBePersistent<Page> m_page; | 117 OwnPtrWillBePersistent<Page> m_page; |
117 IntSize m_intrinsicSize; | 118 |
| 119 // "The concrete object size is the result of combining an |
| 120 // object’s intrinsic dimensions and specified size with the |
| 121 // default object size of the context it’s used in, producing a |
| 122 // rectangle with a definite width and height." |
| 123 // |
| 124 // https://drafts.csswg.org/css-images-3/#concrete-object-size |
| 125 // |
| 126 // Note: For SVGImage there are no specified size |
| 127 // constraints. Such constraints are handled by the layout |
| 128 // machinery in LayoutReplaced. An image has only intrinsic size, |
| 129 // aspect ratio and default object size to consider. |
| 130 IntSize m_concreteObjectSize; |
118 }; | 131 }; |
119 | 132 |
120 DEFINE_IMAGE_TYPE_CASTS(SVGImage); | 133 DEFINE_IMAGE_TYPE_CASTS(SVGImage); |
121 | 134 |
122 class ImageObserverDisabler { | 135 class ImageObserverDisabler { |
123 STACK_ALLOCATED(); | 136 STACK_ALLOCATED(); |
124 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler); | 137 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler); |
125 public: | 138 public: |
126 ImageObserverDisabler(Image* image) | 139 ImageObserverDisabler(Image* image) |
127 : m_image(image) | 140 : m_image(image) |
128 { | 141 { |
129 m_observer = m_image->imageObserver(); | 142 m_observer = m_image->imageObserver(); |
130 m_image->setImageObserver(0); | 143 m_image->setImageObserver(0); |
131 } | 144 } |
132 | 145 |
133 ~ImageObserverDisabler() | 146 ~ImageObserverDisabler() |
134 { | 147 { |
135 m_image->setImageObserver(m_observer); | 148 m_image->setImageObserver(m_observer); |
136 } | 149 } |
137 private: | 150 private: |
138 Image* m_image; | 151 Image* m_image; |
139 RawPtrWillBeMember<ImageObserver> m_observer; | 152 RawPtrWillBeMember<ImageObserver> m_observer; |
140 }; | 153 }; |
141 | 154 |
142 } // namespace blink | 155 } // namespace blink |
143 | 156 |
144 #endif // SVGImage_h | 157 #endif // SVGImage_h |
OLD | NEW |