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

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/FetchParameters.h" 36 #include "platform/loader/fetch/FetchParameters.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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void setHeight(unsigned); 96 void setHeight(unsigned);
96 97
97 KURL Src() const; 98 KURL Src() const;
98 void SetSrc(const String&); 99 void SetSrc(const String&);
99 100
100 void setWidth(unsigned); 101 void setWidth(unsigned);
101 102
102 int x() const; 103 int x() const;
103 int y() const; 104 int y() const;
104 105
106 ScriptPromise decode(ScriptState*, ExceptionState&);
107
105 bool complete() const; 108 bool complete() const;
106 109
107 bool HasPendingActivity() const final { 110 bool HasPendingActivity() const final {
108 return GetImageLoader().HasPendingActivity(); 111 return GetImageLoader().HasPendingActivity();
109 } 112 }
110 113
111 bool CanContainRangeEndPoint() const override { return false; } 114 bool CanContainRangeEndPoint() const override { return false; }
112 115
113 const AtomicString ImageSourceURL() const override; 116 const AtomicString ImageSourceURL() const override;
114 117
(...skipping 22 matching lines...) Expand all
137 IntSize BitmapSourceSize() const override; 140 IntSize BitmapSourceSize() const override;
138 ScriptPromise CreateImageBitmap(ScriptState*, 141 ScriptPromise CreateImageBitmap(ScriptState*,
139 EventTarget&, 142 EventTarget&,
140 Optional<IntRect> crop_rect, 143 Optional<IntRect> crop_rect,
141 const ImageBitmapOptions&, 144 const ImageBitmapOptions&,
142 ExceptionState&) override; 145 ExceptionState&) override;
143 146
144 FormAssociated* ToFormAssociatedOrNull() override { return this; }; 147 FormAssociated* ToFormAssociatedOrNull() override { return this; };
145 void AssociateWith(HTMLFormElement*) override; 148 void AssociateWith(HTMLFormElement*) override;
146 149
150 void ImageNotifyFinished(bool success);
151
147 protected: 152 protected:
148 // Controls how an image element appears in the layout. See: 153 // Controls how an image element appears in the layout. See:
149 // https://html.spec.whatwg.org/multipage/embedded-content.html#image-request 154 // https://html.spec.whatwg.org/multipage/embedded-content.html#image-request
150 enum class LayoutDisposition : uint8_t { 155 enum class LayoutDisposition : uint8_t {
151 // Displayed as a partially or completely loaded image. Corresponds to the 156 // Displayed as a partially or completely loaded image. Corresponds to the
152 // `current request` state being: `unavailable`, `partially available`, or 157 // `current request` state being: `unavailable`, `partially available`, or
153 // `completely available`. 158 // `completely available`.
154 kPrimaryContent, 159 kPrimaryContent,
155 // Showing a broken image icon and 'alt' text, if any. Corresponds to the 160 // Showing a broken image icon and 'alt' text, if any. Corresponds to the
156 // `current request` being in the `broken` state. 161 // `current request` being in the `broken` state.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 194
190 bool draggable() const override; 195 bool draggable() const override;
191 196
192 InsertionNotificationRequest InsertedInto(ContainerNode*) override; 197 InsertionNotificationRequest InsertedInto(ContainerNode*) override;
193 void RemovedFrom(ContainerNode*) override; 198 void RemovedFrom(ContainerNode*) override;
194 bool ShouldRegisterAsNamedItem() const override { return true; } 199 bool ShouldRegisterAsNamedItem() const override { return true; }
195 bool ShouldRegisterAsExtraNamedItem() const override { return true; } 200 bool ShouldRegisterAsExtraNamedItem() const override { return true; }
196 bool IsInteractiveContent() const override; 201 bool IsInteractiveContent() const override;
197 Image* ImageContents() override; 202 Image* ImageContents() override;
198 203
204 void RequestDecode();
205 void DidDecode(uint32_t sequence_id, bool success);
206
199 void ResetFormOwner(); 207 void ResetFormOwner();
200 ImageCandidate FindBestFitImageFromPictureParent(); 208 ImageCandidate FindBestFitImageFromPictureParent();
201 void SetBestFitURLAndDPRFromImageCandidate(const ImageCandidate&); 209 void SetBestFitURLAndDPRFromImageCandidate(const ImageCandidate&);
202 HTMLImageLoader& GetImageLoader() const override { return *image_loader_; } 210 HTMLImageLoader& GetImageLoader() const override { return *image_loader_; }
203 void NotifyViewportChanged(); 211 void NotifyViewportChanged();
204 void CreateMediaQueryListIfDoesNotExist(); 212 void CreateMediaQueryListIfDoesNotExist();
205 213
206 Member<HTMLImageLoader> image_loader_; 214 Member<HTMLImageLoader> image_loader_;
207 Member<ViewportChangeListener> listener_; 215 Member<ViewportChangeListener> listener_;
208 Member<HTMLFormElement> form_; 216 Member<HTMLFormElement> form_;
209 AtomicString best_fit_image_url_; 217 AtomicString best_fit_image_url_;
210 float image_device_pixel_ratio_; 218 float image_device_pixel_ratio_;
211 Member<HTMLSourceElement> source_; 219 Member<HTMLSourceElement> source_;
212 LayoutDisposition layout_disposition_; 220 LayoutDisposition layout_disposition_;
221 HeapVector<Member<ScriptPromiseResolver>> decode_promise_resolvers_;
222 uint32_t decode_sequence_id_;
213 unsigned form_was_set_by_parser_ : 1; 223 unsigned form_was_set_by_parser_ : 1;
214 unsigned element_created_by_parser_ : 1; 224 unsigned element_created_by_parser_ : 1;
215 unsigned is_fallback_image_ : 1; 225 unsigned is_fallback_image_ : 1;
216 226
217 ReferrerPolicy referrer_policy_; 227 ReferrerPolicy referrer_policy_;
218 }; 228 };
219 229
220 } // namespace blink 230 } // namespace blink
221 231
222 #endif // HTMLImageElement_h 232 #endif // HTMLImageElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698