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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLImageElement.h

Issue 2535383003: Collapse images disallowed by the Safe Browsing Subresource Filter. (Closed)
Patch Set: Rebase. Created 4 years 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 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2010 Google Inc. All rights reserved. 5 * Copyright (C) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool hasPendingActivity() const final { 97 bool hasPendingActivity() const final {
98 return imageLoader().hasPendingActivity(); 98 return imageLoader().hasPendingActivity();
99 } 99 }
100 100
101 bool canContainRangeEndPoint() const override { return false; } 101 bool canContainRangeEndPoint() const override { return false; }
102 102
103 const AtomicString imageSourceURL() const override; 103 const AtomicString imageSourceURL() const override;
104 104
105 HTMLFormElement* formOwner() const override; 105 HTMLFormElement* formOwner() const override;
106 void formRemovedFromTree(const Node& formRoot); 106 void formRemovedFromTree(const Node& formRoot);
107 virtual void ensureFallbackContent(); 107 virtual void ensureCollapsedOrFallbackContent();
108 virtual void ensureFallbackForGeneratedContent(); 108 virtual void ensureFallbackForGeneratedContent();
109 virtual void ensurePrimaryContent(); 109 virtual void ensurePrimaryContent();
110 110
111 // CanvasImageSource implementation 111 // CanvasImageSource implementation
112 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, 112 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*,
113 AccelerationHint, 113 AccelerationHint,
114 SnapshotReason, 114 SnapshotReason,
115 const FloatSize&) const override; 115 const FloatSize&) const override;
116 bool isSVGSource() const override; 116 bool isSVGSource() const override;
117 bool wouldTaintOrigin(SecurityOrigin*) const override; 117 bool wouldTaintOrigin(SecurityOrigin*) const override;
118 FloatSize elementSize(const FloatSize&) const override; 118 FloatSize elementSize(const FloatSize&) const override;
119 FloatSize defaultDestinationSize(const FloatSize&) const override; 119 FloatSize defaultDestinationSize(const FloatSize&) const override;
120 const KURL& sourceURL() const override; 120 const KURL& sourceURL() const override;
121 bool isAccelerated() const override { return false; } 121 bool isAccelerated() const override { return false; }
122 bool isOpaque() const override; 122 bool isOpaque() const override;
123 int sourceWidth() override; 123 int sourceWidth() override;
124 int sourceHeight() override; 124 int sourceHeight() override;
125 125
126 // public so that HTMLPictureElement can call this as well. 126 // public so that HTMLPictureElement can call this as well.
127 void selectSourceURL(ImageLoader::UpdateFromElementBehavior); 127 void selectSourceURL(ImageLoader::UpdateFromElementBehavior);
128 void reattachFallbackContent(); 128
129 void setUseFallbackContent();
130 void setIsFallbackImage() { m_isFallbackImage = true; } 129 void setIsFallbackImage() { m_isFallbackImage = true; }
131 130
132 FetchRequest::ResourceWidth getResourceWidth(); 131 FetchRequest::ResourceWidth getResourceWidth();
133 float sourceSize(Element&); 132 float sourceSize(Element&);
134 133
135 void forceReload() const; 134 void forceReload() const;
136 135
137 // ImageBitmapSource implementation 136 // ImageBitmapSource implementation
138 IntSize bitmapSourceSize() const override; 137 IntSize bitmapSourceSize() const override;
139 ScriptPromise createImageBitmap(ScriptState*, 138 ScriptPromise createImageBitmap(ScriptState*,
140 EventTarget&, 139 EventTarget&,
141 Optional<IntRect> cropRect, 140 Optional<IntRect> cropRect,
142 const ImageBitmapOptions&, 141 const ImageBitmapOptions&,
143 ExceptionState&) override; 142 ExceptionState&) override;
144 143
145 FormAssociated* toFormAssociatedOrNull() override { return this; }; 144 FormAssociated* toFormAssociatedOrNull() override { return this; };
146 void associateWith(HTMLFormElement*) override; 145 void associateWith(HTMLFormElement*) override;
147 146
148 protected: 147 protected:
148 // Controls how an image element appears in the layout. See:
149 // https://html.spec.whatwg.org/multipage/embedded-content.html#image-request
150 enum class LayoutDisposition : uint8_t {
151 // Displayed as a partially or completely loaded image. Corresponds to the
152 // `current request` state being: `unavailable`, `partially available`, or
153 // `completely available`.
154 PrimaryContent,
155 // Showing a broken image icon and 'alt' text, if any. Corresponds to the
156 // `current request` being in the `broken` state.
157 FallbackContent,
158 // No layout object. Corresponds to the `current request` being in the
159 // `broken` state when the resource load failed with an error that has the
160 // |shouldCollapseInitiator| flag set.
161 Collapsed
162 };
163
149 explicit HTMLImageElement(Document&, 164 explicit HTMLImageElement(Document&,
150 HTMLFormElement* = 0, 165 HTMLFormElement* = 0,
151 bool createdByParser = false); 166 bool createdByParser = false);
152 167
153 void didMoveToNewDocument(Document& oldDocument) override; 168 void didMoveToNewDocument(Document& oldDocument) override;
154 virtual bool useFallbackContent() const { return m_useFallbackContent; }
155 169
156 void didAddUserAgentShadowRoot(ShadowRoot&) override; 170 void didAddUserAgentShadowRoot(ShadowRoot&) override;
157 PassRefPtr<ComputedStyle> customStyleForLayoutObject() override; 171 PassRefPtr<ComputedStyle> customStyleForLayoutObject() override;
158 172
159 private: 173 private:
160 bool areAuthorShadowsAllowed() const override { return false; } 174 bool areAuthorShadowsAllowed() const override { return false; }
161 175
162 void parseAttribute(const QualifiedName&, 176 void parseAttribute(const QualifiedName&,
163 const AtomicString&, 177 const AtomicString&,
164 const AtomicString&) override; 178 const AtomicString&) override;
165 bool isPresentationAttribute(const QualifiedName&) const override; 179 bool isPresentationAttribute(const QualifiedName&) const override;
166 void collectStyleForPresentationAttribute(const QualifiedName&, 180 void collectStyleForPresentationAttribute(const QualifiedName&,
167 const AtomicString&, 181 const AtomicString&,
168 MutableStylePropertySet*) override; 182 MutableStylePropertySet*) override;
183 void setLayoutDisposition(LayoutDisposition, bool forceReattach = false);
169 184
170 void attachLayoutTree(const AttachContext& = AttachContext()) override; 185 void attachLayoutTree(const AttachContext& = AttachContext()) override;
186 bool layoutObjectIsNeeded(const ComputedStyle&) override;
171 LayoutObject* createLayoutObject(const ComputedStyle&) override; 187 LayoutObject* createLayoutObject(const ComputedStyle&) override;
172 188
173 bool canStartSelection() const override { return false; } 189 bool canStartSelection() const override { return false; }
174 190
175 bool isURLAttribute(const Attribute&) const override; 191 bool isURLAttribute(const Attribute&) const override;
176 bool hasLegalLinkAttribute(const QualifiedName&) const override; 192 bool hasLegalLinkAttribute(const QualifiedName&) const override;
177 const QualifiedName& subResourceAttributeName() const override; 193 const QualifiedName& subResourceAttributeName() const override;
178 194
179 bool draggable() const override; 195 bool draggable() const override;
180 196
(...skipping 10 matching lines...) Expand all
191 HTMLImageLoader& imageLoader() const { return *m_imageLoader; } 207 HTMLImageLoader& imageLoader() const { return *m_imageLoader; }
192 void notifyViewportChanged(); 208 void notifyViewportChanged();
193 void createMediaQueryListIfDoesNotExist(); 209 void createMediaQueryListIfDoesNotExist();
194 210
195 Member<HTMLImageLoader> m_imageLoader; 211 Member<HTMLImageLoader> m_imageLoader;
196 Member<ViewportChangeListener> m_listener; 212 Member<ViewportChangeListener> m_listener;
197 Member<HTMLFormElement> m_form; 213 Member<HTMLFormElement> m_form;
198 AtomicString m_bestFitImageURL; 214 AtomicString m_bestFitImageURL;
199 float m_imageDevicePixelRatio; 215 float m_imageDevicePixelRatio;
200 Member<HTMLSourceElement> m_source; 216 Member<HTMLSourceElement> m_source;
217 LayoutDisposition m_layoutDisposition;
201 unsigned m_formWasSetByParser : 1; 218 unsigned m_formWasSetByParser : 1;
202 unsigned m_elementCreatedByParser : 1; 219 unsigned m_elementCreatedByParser : 1;
203 unsigned m_useFallbackContent : 1;
204 unsigned m_isFallbackImage : 1; 220 unsigned m_isFallbackImage : 1;
205 221
206 ReferrerPolicy m_referrerPolicy; 222 ReferrerPolicy m_referrerPolicy;
207 }; 223 };
208 224
209 } // namespace blink 225 } // namespace blink
210 226
211 #endif // HTMLImageElement_h 227 #endif // HTMLImageElement_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.cpp ('k') | third_party/WebKit/Source/core/html/HTMLImageElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698