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

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: Remove ref-tests, fix generated content. 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool hasPendingActivity() const final { 95 bool hasPendingActivity() const final {
96 return imageLoader().hasPendingActivity(); 96 return imageLoader().hasPendingActivity();
97 } 97 }
98 98
99 bool canContainRangeEndPoint() const override { return false; } 99 bool canContainRangeEndPoint() const override { return false; }
100 100
101 const AtomicString imageSourceURL() const override; 101 const AtomicString imageSourceURL() const override;
102 102
103 HTMLFormElement* formOwner() const override; 103 HTMLFormElement* formOwner() const override;
104 void formRemovedFromTree(const Node& formRoot); 104 void formRemovedFromTree(const Node& formRoot);
105 virtual void ensureFallbackContent(); 105 virtual void ensureCollapsedOrFallbackContent();
106 virtual void ensureFallbackForGeneratedContent(); 106 virtual void ensureFallbackForGeneratedContent();
107 virtual void ensurePrimaryContent(); 107 virtual void ensurePrimaryContent();
108 108
109 // CanvasImageSource implementation 109 // CanvasImageSource implementation
110 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, 110 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*,
111 AccelerationHint, 111 AccelerationHint,
112 SnapshotReason, 112 SnapshotReason,
113 const FloatSize&) const override; 113 const FloatSize&) const override;
114 bool isSVGSource() const override; 114 bool isSVGSource() const override;
115 bool wouldTaintOrigin(SecurityOrigin*) const override; 115 bool wouldTaintOrigin(SecurityOrigin*) const override;
116 FloatSize elementSize(const FloatSize&) const override; 116 FloatSize elementSize(const FloatSize&) const override;
117 FloatSize defaultDestinationSize(const FloatSize&) const override; 117 FloatSize defaultDestinationSize(const FloatSize&) const override;
118 const KURL& sourceURL() const override; 118 const KURL& sourceURL() const override;
119 bool isAccelerated() const override { return false; } 119 bool isAccelerated() const override { return false; }
120 bool isOpaque() const override; 120 bool isOpaque() const override;
121 int sourceWidth() override; 121 int sourceWidth() override;
122 int sourceHeight() override; 122 int sourceHeight() override;
123 123
124 // public so that HTMLPictureElement can call this as well. 124 // public so that HTMLPictureElement can call this as well.
125 void selectSourceURL(ImageLoader::UpdateFromElementBehavior); 125 void selectSourceURL(ImageLoader::UpdateFromElementBehavior);
126 void reattachFallbackContent(); 126
127 void setUseFallbackContent();
128 void setIsFallbackImage() { m_isFallbackImage = true; } 127 void setIsFallbackImage() { m_isFallbackImage = true; }
129 128
130 FetchRequest::ResourceWidth getResourceWidth(); 129 FetchRequest::ResourceWidth getResourceWidth();
131 float sourceSize(Element&); 130 float sourceSize(Element&);
132 131
133 void forceReload() const; 132 void forceReload() const;
134 133
135 // ImageBitmapSource implementation 134 // ImageBitmapSource implementation
136 IntSize bitmapSourceSize() const override; 135 IntSize bitmapSourceSize() const override;
137 ScriptPromise createImageBitmap(ScriptState*, 136 ScriptPromise createImageBitmap(ScriptState*,
138 EventTarget&, 137 EventTarget&,
139 Optional<IntRect> cropRect, 138 Optional<IntRect> cropRect,
140 const ImageBitmapOptions&, 139 const ImageBitmapOptions&,
141 ExceptionState&) override; 140 ExceptionState&) override;
142 141
143 protected: 142 protected:
143 // Controls how an image element appears in the layout. See:
dominicc (has gone to gerrit) 2016/12/07 01:51:42 Awesome :D thank you.
144 // https://html.spec.whatwg.org/multipage/embedded-content.html#image-request
145 enum class LayoutDisposition : uint8_t {
146 // Displayed as a partially or completely loaded image. Corresponds to the
147 // `current request` state being: `unavailable`, `partially available`, or
148 // `completely available`.
149 PrimaryContent,
150 // Showing a broken image icon and 'alt' text, if any. Corresponds to the
151 // `current request` being in the `broken` state.
152 FallbackContent,
153 // No layout object. Corresponds to the `current request` being in the
154 // `broken` state when the resource load failed with an error that has the
155 // |shouldCollapseInitiator| flag set.
156 Collapsed
157 };
158
144 explicit HTMLImageElement(Document&, 159 explicit HTMLImageElement(Document&,
145 HTMLFormElement* = 0, 160 HTMLFormElement* = 0,
146 bool createdByParser = false); 161 bool createdByParser = false);
147 162
148 void didMoveToNewDocument(Document& oldDocument) override; 163 void didMoveToNewDocument(Document& oldDocument) override;
149 virtual bool useFallbackContent() const { return m_useFallbackContent; }
150 164
151 void didAddUserAgentShadowRoot(ShadowRoot&) override; 165 void didAddUserAgentShadowRoot(ShadowRoot&) override;
152 PassRefPtr<ComputedStyle> customStyleForLayoutObject() override; 166 PassRefPtr<ComputedStyle> customStyleForLayoutObject() override;
153 167
154 private: 168 private:
155 bool areAuthorShadowsAllowed() const override { return false; } 169 bool areAuthorShadowsAllowed() const override { return false; }
156 170
157 void parseAttribute(const QualifiedName&, 171 void parseAttribute(const QualifiedName&,
158 const AtomicString&, 172 const AtomicString&,
159 const AtomicString&) override; 173 const AtomicString&) override;
160 bool isPresentationAttribute(const QualifiedName&) const override; 174 bool isPresentationAttribute(const QualifiedName&) const override;
161 void collectStyleForPresentationAttribute(const QualifiedName&, 175 void collectStyleForPresentationAttribute(const QualifiedName&,
162 const AtomicString&, 176 const AtomicString&,
163 MutableStylePropertySet*) override; 177 MutableStylePropertySet*) override;
178 void setLayoutDisposition(LayoutDisposition, bool forceReattach = false);
164 179
165 void attachLayoutTree(const AttachContext& = AttachContext()) override; 180 void attachLayoutTree(const AttachContext& = AttachContext()) override;
181 bool layoutObjectIsNeeded(const ComputedStyle&) override;
166 LayoutObject* createLayoutObject(const ComputedStyle&) override; 182 LayoutObject* createLayoutObject(const ComputedStyle&) override;
167 183
168 bool canStartSelection() const override { return false; } 184 bool canStartSelection() const override { return false; }
169 185
170 bool isURLAttribute(const Attribute&) const override; 186 bool isURLAttribute(const Attribute&) const override;
171 bool hasLegalLinkAttribute(const QualifiedName&) const override; 187 bool hasLegalLinkAttribute(const QualifiedName&) const override;
172 const QualifiedName& subResourceAttributeName() const override; 188 const QualifiedName& subResourceAttributeName() const override;
173 189
174 bool draggable() const override; 190 bool draggable() const override;
175 191
(...skipping 10 matching lines...) Expand all
186 HTMLImageLoader& imageLoader() const { return *m_imageLoader; } 202 HTMLImageLoader& imageLoader() const { return *m_imageLoader; }
187 void notifyViewportChanged(); 203 void notifyViewportChanged();
188 void createMediaQueryListIfDoesNotExist(); 204 void createMediaQueryListIfDoesNotExist();
189 205
190 Member<HTMLImageLoader> m_imageLoader; 206 Member<HTMLImageLoader> m_imageLoader;
191 Member<ViewportChangeListener> m_listener; 207 Member<ViewportChangeListener> m_listener;
192 Member<HTMLFormElement> m_form; 208 Member<HTMLFormElement> m_form;
193 AtomicString m_bestFitImageURL; 209 AtomicString m_bestFitImageURL;
194 float m_imageDevicePixelRatio; 210 float m_imageDevicePixelRatio;
195 Member<HTMLSourceElement> m_source; 211 Member<HTMLSourceElement> m_source;
212 LayoutDisposition m_layoutDisposition;
196 unsigned m_formWasSetByParser : 1; 213 unsigned m_formWasSetByParser : 1;
197 unsigned m_elementCreatedByParser : 1; 214 unsigned m_elementCreatedByParser : 1;
198 unsigned m_useFallbackContent : 1;
199 unsigned m_isFallbackImage : 1; 215 unsigned m_isFallbackImage : 1;
200 216
201 ReferrerPolicy m_referrerPolicy; 217 ReferrerPolicy m_referrerPolicy;
202 }; 218 };
203 219
204 } // namespace blink 220 } // namespace blink
205 221
206 #endif // HTMLImageElement_h 222 #endif // HTMLImageElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698