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

Side by Side Diff: Source/core/loader/ImageLoader.h

Issue 369423002: Have srcset respond to viewport changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Self review nits Created 6 years, 5 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, 2009 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2009 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ForceLoadImmediately 68 ForceLoadImmediately
69 }; 69 };
70 70
71 enum UpdateFromElementBehavior { 71 enum UpdateFromElementBehavior {
72 // This should be the update behavior when the element is attached to a document, or when DOM mutations trigger a new load. 72 // This should be the update behavior when the element is attached to a document, or when DOM mutations trigger a new load.
73 // Starts loading if a load hasn't already been started. 73 // Starts loading if a load hasn't already been started.
74 UpdateNormal, 74 UpdateNormal,
75 // This should be the update behavior when the resource was changed (via 'src', 'srcset' or 'sizes'). 75 // This should be the update behavior when the resource was changed (via 'src', 'srcset' or 'sizes').
76 // Starts a new load even if a previous load of the same resource have f ailed, to match Firefox's behavior. 76 // Starts a new load even if a previous load of the same resource have f ailed, to match Firefox's behavior.
77 // FIXME - Verify that this is the right behavior according to the spec. 77 // FIXME - Verify that this is the right behavior according to the spec.
78 UpdateIgnorePreviousError 78 UpdateIgnorePreviousError,
79 // This forces the image to update its intrinsic size, even if the image source has not changed.
80 UpdateForce
79 }; 81 };
80 82
81 enum BypassMainWorldBehavior { 83 enum BypassMainWorldBehavior {
82 BypassMainWorldCSP, 84 BypassMainWorldCSP,
83 DoNotBypassMainWorldCSP 85 DoNotBypassMainWorldCSP
84 }; 86 };
85 87
86 void updateFromElement(UpdateFromElementBehavior = UpdateNormal, LoadType = LoadNormally); 88 void updateFromElement(UpdateFromElementBehavior = UpdateNormal, LoadType = LoadNormally);
87 89
88 void elementDidMoveToNewDocument(); 90 void elementDidMoveToNewDocument();
(...skipping 22 matching lines...) Expand all
111 void addClient(ImageLoaderClient*); 113 void addClient(ImageLoaderClient*);
112 void removeClient(ImageLoaderClient*); 114 void removeClient(ImageLoaderClient*);
113 115
114 protected: 116 protected:
115 virtual void notifyFinished(Resource*) OVERRIDE; 117 virtual void notifyFinished(Resource*) OVERRIDE;
116 118
117 private: 119 private:
118 class Task; 120 class Task;
119 121
120 // Called from the task or from updateFromElement to initiate the load. 122 // Called from the task or from updateFromElement to initiate the load.
121 void doUpdateFromElement(BypassMainWorldBehavior); 123 void doUpdateFromElement(BypassMainWorldBehavior, UpdateFromElementBehavior) ;
122 124
123 virtual void dispatchLoadEvent() = 0; 125 virtual void dispatchLoadEvent() = 0;
124 virtual String sourceURI(const AtomicString&) const = 0; 126 virtual String sourceURI(const AtomicString&) const = 0;
125 127
126 void updatedHasPendingEvent(); 128 void updatedHasPendingEvent();
127 129
128 void dispatchPendingLoadEvent(); 130 void dispatchPendingLoadEvent();
129 void dispatchPendingErrorEvent(); 131 void dispatchPendingErrorEvent();
130 132
131 RenderImageResource* renderImageResource(); 133 RenderImageResource* renderImageResource();
132 void updateRenderer(); 134 void updateRenderer();
133 135
134 void setImageWithoutConsideringPendingLoadEvent(ImageResource*); 136 void setImageWithoutConsideringPendingLoadEvent(ImageResource*);
135 void sourceImageChanged(); 137 void sourceImageChanged();
136 void clearFailedLoadURL(); 138 void clearFailedLoadURL();
137 void crossSiteOrCSPViolationOccured(AtomicString); 139 void crossSiteOrCSPViolationOccured(AtomicString);
138 void enqueueImageLoadingMicroTask(); 140 void enqueueImageLoadingMicroTask(UpdateFromElementBehavior);
139 static ResourcePtr<ImageResource> createImageResourceForImageDocument(Docume nt&, FetchRequest&); 141 static ResourcePtr<ImageResource> createImageResourceForImageDocument(Docume nt&, FetchRequest&);
140 142
141 void timerFired(Timer<ImageLoader>*); 143 void timerFired(Timer<ImageLoader>*);
142 144
143 KURL imageSourceToKURL(AtomicString) const; 145 KURL imageSourceToKURL(AtomicString) const;
144 146
145 // Used to determine whether to immediately initiate the load 147 // Used to determine whether to immediately initiate the load
146 // or to schedule a microtask. 148 // or to schedule a microtask.
147 bool shouldLoadImmediately(const KURL&, LoadType) const; 149 bool shouldLoadImmediately(const KURL&, LoadType) const;
148 150
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 bool m_hasPendingErrorEvent : 1; 185 bool m_hasPendingErrorEvent : 1;
184 bool m_imageComplete : 1; 186 bool m_imageComplete : 1;
185 bool m_loadingImageDocument : 1; 187 bool m_loadingImageDocument : 1;
186 bool m_elementIsProtected : 1; 188 bool m_elementIsProtected : 1;
187 unsigned m_highPriorityClientCount; 189 unsigned m_highPriorityClientCount;
188 }; 190 };
189 191
190 } 192 }
191 193
192 #endif 194 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698