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

Unified Diff: Source/core/html/HTMLImageElement.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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLImageElement.h
diff --git a/Source/core/html/HTMLImageElement.h b/Source/core/html/HTMLImageElement.h
index 4d1f09a54e4d72c9a0d4de6537b4e07194009800..93f1b83df9bf87e700021ae1aca7341e0ef01d80 100644
--- a/Source/core/html/HTMLImageElement.h
+++ b/Source/core/html/HTMLImageElement.h
@@ -24,6 +24,7 @@
#ifndef HTMLImageElement_h
#define HTMLImageElement_h
+#include "core/frame/ViewportChangeNotifier.h"
#include "core/html/HTMLElement.h"
#include "core/html/HTMLImageLoader.h"
#include "core/html/canvas/CanvasImageSource.h"
@@ -101,6 +102,31 @@ protected:
virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
private:
+ class ImageViewportChangeListener: public ViewportChangeListener {
haraken 2014/07/11 06:10:21 Add FINAL.
+ public:
+ static PassRefPtrWillBeRawPtr<ImageViewportChangeListener> create(HTMLImageElement* element)
+ {
+ return adoptRefWillBeNoop(new ImageViewportChangeListener(element));
+ }
+
+ virtual void viewportChanged() OVERRIDE
+ {
+ // Re-selecting the source URL in order to pick a more fitting resource
+ // And update the image's intrinsic dimensions when the viewport changes.
+ // Picking of a better fitting resource is UA dependant, not spec required.
+ m_element->selectSourceURL(ImageLoader::UpdateForce);
+ }
+
+ ImageViewportChangeListener(HTMLImageElement* element)
haraken 2014/07/11 06:10:21 Add explicit.
+ : m_element(element)
+ {
+ ASSERT(element);
+ }
+
+ private:
+ HTMLImageElement* m_element;
haraken 2014/07/11 06:10:21 I guess this should be RawPtrWillBeMember<HTMLImag
+ };
+
virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
@@ -141,6 +167,11 @@ private:
float m_imageDevicePixelRatio;
bool m_formWasSetByParser;
bool m_elementCreatedByParser;
+ // Intrinsic sizing is viewport dependant if the 'w' descriptor was used for the picked resource.
+ bool m_intrinsicSizingViewportDependant;
+ // Effective size is viewport dependant if the sizes attribute's effective size used v* length units.
+ bool m_effectiveSizeViewportDependant;
+ RefPtrWillBeMember<ImageViewportChangeListener> m_viewportListener;
};
} //namespace

Powered by Google App Engine
This is Rietveld 408576698