Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutImage.h

Issue 1728313003: Split ImageResourceClient into ResourceClient and ImageResourceObserver [2/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and reflect comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 37
38 // LayoutImage is used to display any image type. 38 // LayoutImage is used to display any image type.
39 // 39 //
40 // There is 2 types of images: 40 // There is 2 types of images:
41 // * normal images, e.g. <image>, <picture>. 41 // * normal images, e.g. <image>, <picture>.
42 // * content images with "content: url(path/to/image.png)". 42 // * content images with "content: url(path/to/image.png)".
43 // We store the type inside m_isGeneratedContent. 43 // We store the type inside m_isGeneratedContent.
44 // 44 //
45 // The class is image type agnostic as it only manipulates decoded images. 45 // The class is image type agnostic as it only manipulates decoded images.
46 // See LayoutImageResource that holds this image. 46 // See LayoutImageResource that holds this image.
47 class CORE_EXPORT LayoutImage : public LayoutReplaced, public ResourceClient { 47 class CORE_EXPORT LayoutImage : public LayoutReplaced {
48 public: 48 public:
49 // These are the paddings to use when displaying either alt text or an image . 49 // These are the paddings to use when displaying either alt text or an image .
50 static const unsigned short paddingWidth = 4; 50 static const unsigned short paddingWidth = 4;
51 static const unsigned short paddingHeight = 4; 51 static const unsigned short paddingHeight = 4;
52 52
53 LayoutImage(Element*); 53 LayoutImage(Element*);
54 ~LayoutImage() override; 54 ~LayoutImage() override;
55 55
56 static LayoutImage* createAnonymous(Document*); 56 static LayoutImage* createAnonymous(Document*);
57 57
58 void setImageResource(PassOwnPtrWillBeRawPtr<LayoutImageResource>); 58 void setImageResource(PassOwnPtrWillBeRawPtr<LayoutImageResource>);
59 59
60 LayoutImageResource* imageResource() { return m_imageResource.get(); } 60 LayoutImageResource* imageResource() { return m_imageResource.get(); }
61 const LayoutImageResource* imageResource() const { return m_imageResource.ge t(); } 61 const LayoutImageResource* imageResource() const { return m_imageResource.ge t(); }
62 ImageResource* cachedImage() const { return m_imageResource ? m_imageResourc e->cachedImage() : 0; } 62 ImageResource* cachedImage() const { return m_imageResource ? m_imageResourc e->cachedImage() : 0; }
63 63
64 HTMLMapElement* imageMap() const; 64 HTMLMapElement* imageMap() const;
65 void areaElementFocusChanged(HTMLAreaElement*); 65 void areaElementFocusChanged(HTMLAreaElement*);
66 66
67 void setIsGeneratedContent(bool generated = true) { m_isGeneratedContent = g enerated; } 67 void setIsGeneratedContent(bool generated = true) { m_isGeneratedContent = g enerated; }
68 68
69 bool isGeneratedContent() const { return m_isGeneratedContent; } 69 bool isGeneratedContent() const { return m_isGeneratedContent; }
70 70
71 inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio = factor; } 71 inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio = factor; }
72 float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; } 72 float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; }
73 73
74 void intrinsicSizeChanged() override 74 void intrinsicSizeChanged() override
75 { 75 {
76 if (m_imageResource) 76 if (m_imageResource)
77 imageChanged(m_imageResource->imagePtr()); 77 imageChanged(false, m_imageResource->imagePtr());
78 } 78 }
79 79
80 const char* name() const override { return "LayoutImage"; } 80 const char* name() const override { return "LayoutImage"; }
81 String debugName() const final { return LayoutObject::debugName(); }
82 81
83 protected: 82 protected:
84 bool needsPreferredWidthsRecalculation() const final; 83 bool needsPreferredWidthsRecalculation() const final;
85 LayoutBox* embeddedContentBox() const final; 84 LayoutBox* embeddedContentBox() const final;
86 void computeIntrinsicSizingInfo(IntrinsicSizingInfo&) const final; 85 void computeIntrinsicSizingInfo(IntrinsicSizingInfo&) const final;
87 86
88 void imageChanged(WrappedImagePtr, const IntRect* = nullptr) override; 87 void imageChanged(bool isNotifyingFinish, WrappedImagePtr, const IntRect* = nullptr) override;
89 88
90 void paint(const PaintInfo&, const LayoutPoint&) const final; 89 void paint(const PaintInfo&, const LayoutPoint&) const final;
91 90
92 bool isOfType(LayoutObjectType type) const override { return type == LayoutO bjectLayoutImage || LayoutReplaced::isOfType(type); } 91 bool isOfType(LayoutObjectType type) const override { return type == LayoutO bjectLayoutImage || LayoutReplaced::isOfType(type); }
93 92
94 void willBeDestroyed() override; 93 void willBeDestroyed() override;
95 94
96 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ; 95 void styleDidChange(StyleDifference, const ComputedStyle* oldStyle) override ;
97 96
98 private: 97 private:
99 bool isImage() const override { return true; } 98 bool isImage() const override { return true; }
100 99
101 void paintReplaced(const PaintInfo&, const LayoutPoint&) const override; 100 void paintReplaced(const PaintInfo&, const LayoutPoint&) const override;
102 101
103 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const final; 102 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const final;
104 bool computeBackgroundIsKnownToBeObscured() const final; 103 bool computeBackgroundIsKnownToBeObscured() const final;
105 104
106 bool backgroundShouldAlwaysBeClipped() const override { return true; } 105 bool backgroundShouldAlwaysBeClipped() const override { return true; }
107 106
108 LayoutUnit minimumReplacedHeight() const override; 107 LayoutUnit minimumReplacedHeight() const override;
109 108
110 void notifyFinished(Resource*) final;
111 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final; 109 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final;
112 110
113 bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, const In lineFlowBox*) const final; 111 bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, const In lineFlowBox*) const final;
114 112
115 void invalidatePaintAndMarkForLayoutIfNeeded(); 113 void invalidatePaintAndMarkForLayoutIfNeeded();
116 void updateIntrinsicSizeIfNeeded(const LayoutSize&); 114 void updateIntrinsicSizeIfNeeded(const LayoutSize&);
117 115
118 // This member wraps the associated decoded image. 116 // This member wraps the associated decoded image.
119 // 117 //
120 // This field is set using setImageResource above which can be called in 118 // This field is set using setImageResource above which can be called in
121 // several ways: 119 // several ways:
122 // * For normal images, from the network stack (ImageLoader) once we have 120 // * For normal images, from the network stack (ImageLoader) once we have
123 // some image data. 121 // some image data.
124 // * For generated content, the resource is loaded during style resolution 122 // * For generated content, the resource is loaded during style resolution
125 // and thus is stored in ComputedStyle (see ContentData::image) that gets 123 // and thus is stored in ComputedStyle (see ContentData::image) that gets
126 // propagated to the anonymous LayoutImage in LayoutObject::createObject. 124 // propagated to the anonymous LayoutImage in LayoutObject::createObject.
127 OwnPtrWillBePersistent<LayoutImageResource> m_imageResource; 125 OwnPtrWillBePersistent<LayoutImageResource> m_imageResource;
128 bool m_didIncrementVisuallyNonEmptyPixelCount; 126 bool m_didIncrementVisuallyNonEmptyPixelCount;
129 127
130 // This field stores whether this image is generated with 'content'. 128 // This field stores whether this image is generated with 'content'.
131 bool m_isGeneratedContent; 129 bool m_isGeneratedContent;
132 float m_imageDevicePixelRatio; 130 float m_imageDevicePixelRatio;
133 }; 131 };
134 132
135 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutImage, isLayoutImage()); 133 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutImage, isLayoutImage());
136 134
137 } // namespace blink 135 } // namespace blink
138 136
139 #endif // LayoutImage_h 137 #endif // LayoutImage_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698