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 23 matching lines...) Expand all Loading... |
34 class HTMLAreaElement; | 34 class HTMLAreaElement; |
35 class HTMLMapElement; | 35 class HTMLMapElement; |
36 | 36 |
37 class CORE_EXPORT LayoutImage : public LayoutReplaced { | 37 class CORE_EXPORT LayoutImage : public LayoutReplaced { |
38 public: | 38 public: |
39 // These are the paddings to use when displaying either alt text or an image
. | 39 // These are the paddings to use when displaying either alt text or an image
. |
40 static const unsigned short paddingWidth = 4; | 40 static const unsigned short paddingWidth = 4; |
41 static const unsigned short paddingHeight = 4; | 41 static const unsigned short paddingHeight = 4; |
42 | 42 |
43 LayoutImage(Element*); | 43 LayoutImage(Element*); |
44 virtual ~LayoutImage(); | 44 ~LayoutImage() override; |
45 | 45 |
46 static LayoutImage* createAnonymous(Document*); | 46 static LayoutImage* createAnonymous(Document*); |
47 | 47 |
48 void setImageResource(PassOwnPtr<LayoutImageResource>); | 48 void setImageResource(PassOwnPtr<LayoutImageResource>); |
49 | 49 |
50 LayoutImageResource* imageResource() { return m_imageResource.get(); } | 50 LayoutImageResource* imageResource() { return m_imageResource.get(); } |
51 const LayoutImageResource* imageResource() const { return m_imageResource.ge
t(); } | 51 const LayoutImageResource* imageResource() const { return m_imageResource.ge
t(); } |
52 ImageResource* cachedImage() const { return m_imageResource ? m_imageResourc
e->cachedImage() : 0; } | 52 ImageResource* cachedImage() const { return m_imageResource ? m_imageResourc
e->cachedImage() : 0; } |
53 | 53 |
54 HTMLMapElement* imageMap() const; | 54 HTMLMapElement* imageMap() const; |
55 void areaElementFocusChanged(HTMLAreaElement*); | 55 void areaElementFocusChanged(HTMLAreaElement*); |
56 | 56 |
57 void setIsGeneratedContent(bool generated = true) { m_isGeneratedContent = g
enerated; } | 57 void setIsGeneratedContent(bool generated = true) { m_isGeneratedContent = g
enerated; } |
58 | 58 |
59 bool isGeneratedContent() const { return m_isGeneratedContent; } | 59 bool isGeneratedContent() const { return m_isGeneratedContent; } |
60 | 60 |
61 inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio
= factor; } | 61 inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio
= factor; } |
62 float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; } | 62 float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; } |
63 | 63 |
64 virtual void intrinsicSizeChanged() override | 64 void intrinsicSizeChanged() override |
65 { | 65 { |
66 if (m_imageResource) | 66 if (m_imageResource) |
67 imageChanged(m_imageResource->imagePtr()); | 67 imageChanged(m_imageResource->imagePtr()); |
68 } | 68 } |
69 | 69 |
70 virtual const char* name() const override { return "LayoutImage"; } | 70 const char* name() const override { return "LayoutImage"; } |
71 | 71 |
72 protected: | 72 protected: |
73 virtual bool needsPreferredWidthsRecalculation() const override final; | 73 bool needsPreferredWidthsRecalculation() const final; |
74 virtual LayoutBox* embeddedContentBox() const override final; | 74 LayoutBox* embeddedContentBox() const final; |
75 virtual void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, doub
le& intrinsicRatio) const override final; | 75 void computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intr
insicRatio) const final; |
76 | 76 |
77 virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) overrid
e; | 77 void imageChanged(WrappedImagePtr, const IntRect* = nullptr) override; |
78 | 78 |
79 virtual void paint(const PaintInfo&, const LayoutPoint&) override final; | 79 void paint(const PaintInfo&, const LayoutPoint&) final; |
80 | 80 |
81 virtual void layout() override; | 81 void layout() override; |
82 virtual bool updateImageLoadingPriorities() override final; | 82 bool updateImageLoadingPriorities() final; |
83 | 83 |
84 virtual bool isOfType(LayoutObjectType type) const override { return type ==
LayoutObjectLayoutImage || LayoutReplaced::isOfType(type); } | 84 bool isOfType(LayoutObjectType type) const override { return type == LayoutO
bjectLayoutImage || LayoutReplaced::isOfType(type); } |
85 | 85 |
86 virtual void willBeDestroyed() override; | 86 void willBeDestroyed() override; |
87 | 87 |
88 private: | 88 private: |
89 virtual bool isImage() const override { return true; } | 89 bool isImage() const override { return true; } |
90 | 90 |
91 virtual void paintReplaced(const PaintInfo&, const LayoutPoint&) override; | 91 void paintReplaced(const PaintInfo&, const LayoutPoint&) override; |
92 | 92 |
93 virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect,
unsigned maxDepthToTest) const override final; | 93 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned
maxDepthToTest) const final; |
94 virtual bool computeBackgroundIsKnownToBeObscured() override final; | 94 bool computeBackgroundIsKnownToBeObscured() final; |
95 | 95 |
96 virtual bool backgroundShouldAlwaysBeClipped() const override { return true;
} | 96 bool backgroundShouldAlwaysBeClipped() const override { return true; } |
97 | 97 |
98 virtual LayoutUnit minimumReplacedHeight() const override; | 98 LayoutUnit minimumReplacedHeight() const override; |
99 | 99 |
100 virtual void notifyFinished(Resource*) override final; | 100 void notifyFinished(Resource*) final; |
101 virtual bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInCo
ntainer, const LayoutPoint& accumulatedOffset, HitTestAction) override final; | 101 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer,
const LayoutPoint& accumulatedOffset, HitTestAction) final; |
102 | 102 |
103 virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance,
InlineFlowBox*) const override final; | 103 bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFl
owBox*) const final; |
104 | 104 |
105 void invalidatePaintAndMarkForLayoutIfNeeded(); | 105 void invalidatePaintAndMarkForLayoutIfNeeded(); |
106 void updateIntrinsicSizeIfNeeded(const LayoutSize&); | 106 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. | 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. |
108 void updateInnerContentRect(); | 108 void updateInnerContentRect(); |
109 | 109 |
110 // Text to display as long as the image isn't available. | 110 // Text to display as long as the image isn't available. |
111 OwnPtr<LayoutImageResource> m_imageResource; | 111 OwnPtr<LayoutImageResource> m_imageResource; |
112 bool m_didIncrementVisuallyNonEmptyPixelCount; | 112 bool m_didIncrementVisuallyNonEmptyPixelCount; |
113 bool m_isGeneratedContent; | 113 bool m_isGeneratedContent; |
114 float m_imageDevicePixelRatio; | 114 float m_imageDevicePixelRatio; |
115 }; | 115 }; |
116 | 116 |
117 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutImage, isLayoutImage()); | 117 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutImage, isLayoutImage()); |
118 | 118 |
119 } // namespace blink | 119 } // namespace blink |
120 | 120 |
121 #endif // LayoutImage_h | 121 #endif // LayoutImage_h |
OLD | NEW |