OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "core/rendering/RenderImageResource.h" | 28 #include "core/rendering/RenderImageResource.h" |
29 #include "core/rendering/RenderReplaced.h" | 29 #include "core/rendering/RenderReplaced.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
33 class HTMLAreaElement; | 33 class HTMLAreaElement; |
34 class HTMLMapElement; | 34 class HTMLMapElement; |
35 | 35 |
36 class RenderImage : public RenderReplaced { | 36 class RenderImage : public RenderReplaced { |
37 public: | 37 public: |
| 38 // These are the paddings to use when displaying either alt text or an image
. |
| 39 static const unsigned short paddingWidth = 4; |
| 40 static const unsigned short paddingHeight = 4; |
| 41 |
38 RenderImage(Element*); | 42 RenderImage(Element*); |
39 virtual ~RenderImage(); | 43 virtual ~RenderImage(); |
40 virtual void destroy() OVERRIDE; | 44 virtual void destroy() OVERRIDE; |
41 | 45 |
42 static RenderImage* createAnonymous(Document*); | 46 static RenderImage* createAnonymous(Document*); |
43 | 47 |
44 void setImageResource(PassOwnPtr<RenderImageResource>); | 48 void setImageResource(PassOwnPtr<RenderImageResource>); |
45 | 49 |
46 RenderImageResource* imageResource() { return m_imageResource.get(); } | 50 RenderImageResource* imageResource() { return m_imageResource.get(); } |
47 const RenderImageResource* imageResource() const { return m_imageResource.ge
t(); } | 51 const RenderImageResource* imageResource() const { return m_imageResource.ge
t(); } |
(...skipping 23 matching lines...) Expand all Loading... |
71 imageChanged(m_imageResource->imagePtr()); | 75 imageChanged(m_imageResource->imagePtr()); |
72 } | 76 } |
73 | 77 |
74 protected: | 78 protected: |
75 virtual bool needsPreferredWidthsRecalculation() const OVERRIDE FINAL; | 79 virtual bool needsPreferredWidthsRecalculation() const OVERRIDE FINAL; |
76 virtual RenderBox* embeddedContentBox() const OVERRIDE FINAL; | 80 virtual RenderBox* embeddedContentBox() const OVERRIDE FINAL; |
77 virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, doub
le& intrinsicRatio) const OVERRIDE FINAL; | 81 virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, doub
le& intrinsicRatio) const OVERRIDE FINAL; |
78 | 82 |
79 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE; | 83 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE; |
80 | 84 |
81 void paintIntoRect(GraphicsContext*, const LayoutRect&); | |
82 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL; | 85 virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL; |
83 virtual void layout() OVERRIDE; | 86 virtual void layout() OVERRIDE; |
84 virtual bool updateImageLoadingPriorities() OVERRIDE FINAL; | 87 virtual bool updateImageLoadingPriorities() OVERRIDE FINAL; |
85 | 88 |
86 private: | 89 private: |
87 virtual const char* renderName() const OVERRIDE { return "RenderImage"; } | 90 virtual const char* renderName() const OVERRIDE { return "RenderImage"; } |
88 | 91 |
89 virtual bool isImage() const OVERRIDE { return true; } | 92 virtual bool isImage() const OVERRIDE { return true; } |
90 virtual bool isRenderImage() const OVERRIDE FINAL { return true; } | 93 virtual bool isRenderImage() const OVERRIDE FINAL { return true; } |
91 | 94 |
92 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE; | 95 virtual void paintReplaced(PaintInfo&, const LayoutPoint&) OVERRIDE; |
93 | 96 |
94 virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect,
unsigned maxDepthToTest) const OVERRIDE FINAL; | 97 virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect,
unsigned maxDepthToTest) const OVERRIDE FINAL; |
95 virtual bool computeBackgroundIsKnownToBeObscured() OVERRIDE FINAL; | 98 virtual bool computeBackgroundIsKnownToBeObscured() OVERRIDE FINAL; |
96 | 99 |
97 virtual LayoutUnit minimumReplacedHeight() const OVERRIDE; | 100 virtual LayoutUnit minimumReplacedHeight() const OVERRIDE; |
98 | 101 |
99 virtual void notifyFinished(Resource*) OVERRIDE FINAL; | 102 virtual void notifyFinished(Resource*) OVERRIDE FINAL; |
100 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion) OVERRIDE FINAL; | 103 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes
tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct
ion) OVERRIDE FINAL; |
101 | 104 |
102 virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance,
InlineFlowBox*) const OVERRIDE FINAL; | 105 virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance,
InlineFlowBox*) const OVERRIDE FINAL; |
103 | 106 |
104 IntSize imageSizeForError(ImageResource*) const; | 107 IntSize imageSizeForError(ImageResource*) const; |
105 void paintInvalidationOrMarkForLayout(bool imageSizeChanged, const IntRect*
= 0); | 108 void paintInvalidationOrMarkForLayout(bool imageSizeChanged, const IntRect*
= 0); |
106 void updateIntrinsicSizeIfNeeded(const LayoutSize&); | 109 void updateIntrinsicSizeIfNeeded(const LayoutSize&); |
107 // Update the size of the image to be rendered. Object-fit may cause this to
be different from the CSS box's content rect. | 110 // Update the size of the image to be rendered. Object-fit may cause this to
be different from the CSS box's content rect. |
108 void updateInnerContentRect(); | 111 void updateInnerContentRect(); |
109 | 112 |
110 void paintAreaElementFocusRing(PaintInfo&); | |
111 | |
112 // Text to display as long as the image isn't available. | 113 // Text to display as long as the image isn't available. |
113 String m_altText; | 114 String m_altText; |
114 OwnPtr<RenderImageResource> m_imageResource; | 115 OwnPtr<RenderImageResource> m_imageResource; |
115 bool m_didIncrementVisuallyNonEmptyPixelCount; | 116 bool m_didIncrementVisuallyNonEmptyPixelCount; |
116 bool m_isGeneratedContent; | 117 bool m_isGeneratedContent; |
117 float m_imageDevicePixelRatio; | 118 float m_imageDevicePixelRatio; |
118 | 119 |
119 friend class RenderImageScaleObserver; | 120 friend class RenderImageScaleObserver; |
120 }; | 121 }; |
121 | 122 |
122 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderImage, isRenderImage()); | 123 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderImage, isRenderImage()); |
123 | 124 |
124 } // namespace blink | 125 } // namespace blink |
125 | 126 |
126 #endif // RenderImage_h | 127 #endif // RenderImage_h |
OLD | NEW |