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

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

Issue 2769823002: Add decode() functionality to image elements. (Closed)
Patch Set: update Created 3 years, 8 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 * 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 14 matching lines...) Expand all
25 #define HTMLImageElement_h 25 #define HTMLImageElement_h
26 26
27 #include "bindings/core/v8/ActiveScriptWrappable.h" 27 #include "bindings/core/v8/ActiveScriptWrappable.h"
28 #include "core/CoreExport.h" 28 #include "core/CoreExport.h"
29 #include "core/html/FormAssociated.h" 29 #include "core/html/FormAssociated.h"
30 #include "core/html/HTMLElement.h" 30 #include "core/html/HTMLElement.h"
31 #include "core/html/HTMLImageLoader.h" 31 #include "core/html/HTMLImageLoader.h"
32 #include "core/html/canvas/CanvasImageElementSource.h" 32 #include "core/html/canvas/CanvasImageElementSource.h"
33 #include "core/imagebitmap/ImageBitmapSource.h" 33 #include "core/imagebitmap/ImageBitmapSource.h"
34 #include "platform/graphics/GraphicsTypes.h" 34 #include "platform/graphics/GraphicsTypes.h"
35 #include "platform/heap/HeapAllocator.h"
35 #include "platform/loader/fetch/FetchRequest.h" 36 #include "platform/loader/fetch/FetchRequest.h"
36 #include "platform/loader/fetch/ResourceResponse.h" 37 #include "platform/loader/fetch/ResourceResponse.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 class HTMLFormElement; 41 class HTMLFormElement;
41 class ImageCandidate; 42 class ImageCandidate;
42 class ShadowRoot; 43 class ShadowRoot;
43 class ImageBitmapOptions; 44 class ImageBitmapOptions;
44 45
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void setHeight(unsigned); 93 void setHeight(unsigned);
93 94
94 KURL src() const; 95 KURL src() const;
95 void setSrc(const String&); 96 void setSrc(const String&);
96 97
97 void setWidth(unsigned); 98 void setWidth(unsigned);
98 99
99 int x() const; 100 int x() const;
100 int y() const; 101 int y() const;
101 102
103 ScriptPromise decode(ScriptState*, ExceptionState&);
104
102 bool complete() const; 105 bool complete() const;
103 106
104 bool hasPendingActivity() const final { 107 bool hasPendingActivity() const final {
105 return imageLoader().hasPendingActivity(); 108 return imageLoader().hasPendingActivity();
106 } 109 }
107 110
108 bool canContainRangeEndPoint() const override { return false; } 111 bool canContainRangeEndPoint() const override { return false; }
109 112
110 const AtomicString imageSourceURL() const override; 113 const AtomicString imageSourceURL() const override;
111 114
(...skipping 22 matching lines...) Expand all
134 IntSize bitmapSourceSize() const override; 137 IntSize bitmapSourceSize() const override;
135 ScriptPromise createImageBitmap(ScriptState*, 138 ScriptPromise createImageBitmap(ScriptState*,
136 EventTarget&, 139 EventTarget&,
137 Optional<IntRect> cropRect, 140 Optional<IntRect> cropRect,
138 const ImageBitmapOptions&, 141 const ImageBitmapOptions&,
139 ExceptionState&) override; 142 ExceptionState&) override;
140 143
141 FormAssociated* toFormAssociatedOrNull() override { return this; }; 144 FormAssociated* toFormAssociatedOrNull() override { return this; };
142 void associateWith(HTMLFormElement*) override; 145 void associateWith(HTMLFormElement*) override;
143 146
147 void imageNotifyFinished(bool success);
148
144 protected: 149 protected:
145 // Controls how an image element appears in the layout. See: 150 // Controls how an image element appears in the layout. See:
146 // https://html.spec.whatwg.org/multipage/embedded-content.html#image-request 151 // https://html.spec.whatwg.org/multipage/embedded-content.html#image-request
147 enum class LayoutDisposition : uint8_t { 152 enum class LayoutDisposition : uint8_t {
148 // Displayed as a partially or completely loaded image. Corresponds to the 153 // Displayed as a partially or completely loaded image. Corresponds to the
149 // `current request` state being: `unavailable`, `partially available`, or 154 // `current request` state being: `unavailable`, `partially available`, or
150 // `completely available`. 155 // `completely available`.
151 PrimaryContent, 156 PrimaryContent,
152 // Showing a broken image icon and 'alt' text, if any. Corresponds to the 157 // Showing a broken image icon and 'alt' text, if any. Corresponds to the
153 // `current request` being in the `broken` state. 158 // `current request` being in the `broken` state.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 bool isInteractiveContent() const override; 199 bool isInteractiveContent() const override;
195 Image* imageContents() override; 200 Image* imageContents() override;
196 201
197 void resetFormOwner(); 202 void resetFormOwner();
198 ImageCandidate findBestFitImageFromPictureParent(); 203 ImageCandidate findBestFitImageFromPictureParent();
199 void setBestFitURLAndDPRFromImageCandidate(const ImageCandidate&); 204 void setBestFitURLAndDPRFromImageCandidate(const ImageCandidate&);
200 HTMLImageLoader& imageLoader() const override { return *m_imageLoader; } 205 HTMLImageLoader& imageLoader() const override { return *m_imageLoader; }
201 void notifyViewportChanged(); 206 void notifyViewportChanged();
202 void createMediaQueryListIfDoesNotExist(); 207 void createMediaQueryListIfDoesNotExist();
203 208
209 void requestDecode();
210 void didDecode(bool success);
211
204 Member<HTMLImageLoader> m_imageLoader; 212 Member<HTMLImageLoader> m_imageLoader;
205 Member<ViewportChangeListener> m_listener; 213 Member<ViewportChangeListener> m_listener;
206 Member<HTMLFormElement> m_form; 214 Member<HTMLFormElement> m_form;
207 AtomicString m_bestFitImageURL; 215 AtomicString m_bestFitImageURL;
208 float m_imageDevicePixelRatio; 216 float m_imageDevicePixelRatio;
209 Member<HTMLSourceElement> m_source; 217 Member<HTMLSourceElement> m_source;
210 LayoutDisposition m_layoutDisposition; 218 LayoutDisposition m_layoutDisposition;
211 unsigned m_formWasSetByParser : 1; 219 unsigned m_formWasSetByParser : 1;
212 unsigned m_elementCreatedByParser : 1; 220 unsigned m_elementCreatedByParser : 1;
213 unsigned m_isFallbackImage : 1; 221 unsigned m_isFallbackImage : 1;
222 HeapVector<Member<ScriptPromiseResolver>> m_decodePromiseResolvers;
214 223
215 ReferrerPolicy m_referrerPolicy; 224 ReferrerPolicy m_referrerPolicy;
225
226 WTF::WeakPtrFactory<HTMLImageElement> m_weakPtrFactory;
216 }; 227 };
217 228
218 } // namespace blink 229 } // namespace blink
219 230
220 #endif // HTMLImageElement_h 231 #endif // HTMLImageElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698