Chromium Code Reviews| 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_concreteObjectSize; } | 58 IntSize size() const override { return m_intrinsicSize; } |
| 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; |
| 69 | 69 |
| 70 PassRefPtr<SkImage> imageForCurrentFrame() override; | 70 PassRefPtr<SkImage> imageForCurrentFrame() override; |
| 71 | 71 |
| 72 // Returns the SVG image document's frame. | 72 // Returns the SVG image document's frame. |
| 73 FrameView* frameView() const; | 73 FrameView* frameView() const; |
| 74 | 74 |
| 75 // Does the SVG image/document contain any animations? | 75 // Does the SVG image/document contain any animations? |
| 76 bool hasAnimations() const; | 76 bool hasAnimations() const; |
| 77 | 77 |
| 78 void updateUseCounters(Document&) const; | 78 void updateUseCounters(Document&) const; |
| 79 | 79 |
| 80 FloatSize calculateConcreteObjectSize(const FloatSize&) const; | |
| 81 | |
| 80 // DisplayItemClient methods. | 82 // DisplayItemClient methods. |
| 81 String debugName() const final { return "SVGImage"; } | 83 String debugName() const final { return "SVGImage"; } |
| 82 LayoutRect visualRect() const override; | 84 LayoutRect visualRect() const override; |
| 83 | 85 |
| 84 private: | 86 private: |
| 85 friend class AXLayoutObject; | 87 friend class AXLayoutObject; |
| 86 friend class SVGImageChromeClient; | 88 friend class SVGImageChromeClient; |
| 87 friend class SVGImageForContainer; | 89 friend class SVGImageForContainer; |
| 88 | 90 |
| 89 ~SVGImage() override; | 91 ~SVGImage() override; |
| 90 | 92 |
| 91 String filenameExtension() const override; | 93 String filenameExtension() const override; |
| 92 | 94 |
| 93 FloatSize calculateConcreteObjectSize(const FloatSize&) const; | |
| 94 IntSize containerSize() const; | 95 IntSize containerSize() const; |
| 95 bool usesContainerSize() const override { return true; } | 96 bool usesContainerSize() const override { return true; } |
| 96 void computeIntrinsicDimensions(FloatSize& intrinsicSize, FloatSize& intrins icRatio) override; | 97 void computeIntrinsicDimensions(FloatSize& intrinsicSize, FloatSize& intrins icRatio) override; |
| 97 | 98 |
| 98 bool dataChanged(bool allDataReceived) override; | 99 bool dataChanged(bool allDataReceived) override; |
| 99 | 100 |
| 100 // FIXME: SVGImages are underreporting decoded sizes and will be unable | 101 // FIXME: SVGImages are underreporting decoded sizes and will be unable |
| 101 // to prune because these functions are not implemented yet. | 102 // to prune because these functions are not implemented yet. |
| 102 void destroyDecodedData(bool) override { } | 103 void destroyDecodedData(bool) override { } |
| 103 | 104 |
| 104 // FIXME: Implement this to be less conservative. | 105 // FIXME: Implement this to be less conservative. |
| 105 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } | 106 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } |
| 106 | 107 |
| 107 SVGImage(ImageObserver*); | 108 SVGImage(ImageObserver*); |
| 108 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; | 109 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; |
| 109 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&); | 110 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&); |
| 110 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&, | 111 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&, |
| 111 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&); | 112 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&); |
| 112 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&); | 113 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&); |
| 113 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum, | 114 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum, |
| 114 ImageClampingMode, const KURL&); | 115 ImageClampingMode, const KURL&); |
| 115 | 116 |
| 116 OwnPtrWillBePersistent<SVGImageChromeClient> m_chromeClient; | 117 OwnPtrWillBePersistent<SVGImageChromeClient> m_chromeClient; |
| 117 OwnPtrWillBePersistent<Page> m_page; | 118 OwnPtrWillBePersistent<Page> m_page; |
| 118 | 119 |
| 119 // "The concrete object size is the result of combining an | 120 // When an SVG image has no intrinsic size the size depends on the |
| 120 // object’s intrinsic dimensions and specified size with the | 121 // default object size, which in turn depends on the |
| 121 // default object size of the context it’s used in, producing a | 122 // container. SVGImage may belong to multiple containers so the |
| 122 // rectangle with a definite width and height." | 123 // final image size can't be known in |
| 123 // | 124 // SVGImage. SVGImageForContainer carried the final image size, |
|
fs
2016/03/03 15:22:53
Nit: s/carried/carries/?
| |
| 124 // https://drafts.csswg.org/css-images-3/#concrete-object-size | 125 // also called concrete object size. |
| 125 // | 126 IntSize m_intrinsicSize; |
| 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; | |
| 131 }; | 127 }; |
| 132 | 128 |
| 133 DEFINE_IMAGE_TYPE_CASTS(SVGImage); | 129 DEFINE_IMAGE_TYPE_CASTS(SVGImage); |
| 134 | 130 |
| 135 class ImageObserverDisabler { | 131 class ImageObserverDisabler { |
| 136 STACK_ALLOCATED(); | 132 STACK_ALLOCATED(); |
| 137 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler); | 133 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler); |
| 138 public: | 134 public: |
| 139 ImageObserverDisabler(Image* image) | 135 ImageObserverDisabler(Image* image) |
| 140 : m_image(image) | 136 : m_image(image) |
| 141 { | 137 { |
| 142 m_observer = m_image->imageObserver(); | 138 m_observer = m_image->imageObserver(); |
| 143 m_image->setImageObserver(0); | 139 m_image->setImageObserver(0); |
| 144 } | 140 } |
| 145 | 141 |
| 146 ~ImageObserverDisabler() | 142 ~ImageObserverDisabler() |
| 147 { | 143 { |
| 148 m_image->setImageObserver(m_observer); | 144 m_image->setImageObserver(m_observer); |
| 149 } | 145 } |
| 150 private: | 146 private: |
| 151 Image* m_image; | 147 Image* m_image; |
| 152 RawPtrWillBeMember<ImageObserver> m_observer; | 148 RawPtrWillBeMember<ImageObserver> m_observer; |
| 153 }; | 149 }; |
| 154 | 150 |
| 155 } // namespace blink | 151 } // namespace blink |
| 156 | 152 |
| 157 #endif // SVGImage_h | 153 #endif // SVGImage_h |
| OLD | NEW |