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

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. 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
(...skipping 13 matching lines...) Expand all
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(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 LayoutReplaced* embeddedReplacedContent() const final; 84 LayoutReplaced* embeddedReplacedContent() 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(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; 109 void imageNotifyFinished(ImageResource*) final;
111 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final; 110 bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final;
112 111
113 bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, const In lineFlowBox*) const final; 112 bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, const In lineFlowBox*) const final;
114 113
115 void invalidatePaintAndMarkForLayoutIfNeeded(); 114 void invalidatePaintAndMarkForLayoutIfNeeded();
116 void updateIntrinsicSizeIfNeeded(const LayoutSize&); 115 void updateIntrinsicSizeIfNeeded(const LayoutSize&);
117 116
118 // This member wraps the associated decoded image. 117 // This member wraps the associated decoded image.
119 // 118 //
120 // This field is set using setImageResource above which can be called in 119 // This field is set using setImageResource above which can be called in
121 // several ways: 120 // several ways:
122 // * For normal images, from the network stack (ImageLoader) once we have 121 // * For normal images, from the network stack (ImageLoader) once we have
123 // some image data. 122 // some image data.
124 // * For generated content, the resource is loaded during style resolution 123 // * For generated content, the resource is loaded during style resolution
125 // and thus is stored in ComputedStyle (see ContentData::image) that gets 124 // and thus is stored in ComputedStyle (see ContentData::image) that gets
126 // propagated to the anonymous LayoutImage in LayoutObject::createObject. 125 // propagated to the anonymous LayoutImage in LayoutObject::createObject.
127 OwnPtrWillBePersistent<LayoutImageResource> m_imageResource; 126 OwnPtrWillBePersistent<LayoutImageResource> m_imageResource;
128 bool m_didIncrementVisuallyNonEmptyPixelCount; 127 bool m_didIncrementVisuallyNonEmptyPixelCount;
129 128
130 // This field stores whether this image is generated with 'content'. 129 // This field stores whether this image is generated with 'content'.
131 bool m_isGeneratedContent; 130 bool m_isGeneratedContent;
132 float m_imageDevicePixelRatio; 131 float m_imageDevicePixelRatio;
133 }; 132 };
134 133
135 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutImage, isLayoutImage()); 134 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutImage, isLayoutImage());
136 135
137 } // namespace blink 136 } // namespace blink
138 137
139 #endif // LayoutImage_h 138 #endif // LayoutImage_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MockResourceClients.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698