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

Unified Diff: Source/core/html/parser/HTMLSrcsetParser.h

Issue 23861003: Enable srcset support in HTMLImageElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed a flaky test Created 7 years, 3 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
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | Source/core/html/parser/HTMLSrcsetParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLSrcsetParser.h
diff --git a/Source/core/testing/LayerRect.h b/Source/core/html/parser/HTMLSrcsetParser.h
similarity index 63%
copy from Source/core/testing/LayerRect.h
copy to Source/core/html/parser/HTMLSrcsetParser.h
index 4827feee4f2476d200f0a986a73c81ca9cb4d020..bb53cb893c90f0ed051243083120043e7ec5994d 100644
--- a/Source/core/testing/LayerRect.h
+++ b/Source/core/html/parser/HTMLSrcsetParser.h
@@ -28,44 +28,52 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef LayerRect_h
-#define LayerRect_h
+#ifndef HTMLSrcsetParser_h
+#define HTMLSrcsetParser_h
-#include "core/dom/ClientRect.h"
-
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefCounted.h"
-#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
-class Node;
-
-class LayerRect : public RefCounted<LayerRect> {
+class ImageCandidate {
public:
- static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, const String& layerType, PassRefPtr<ClientRect> rect)
+ ImageCandidate()
+ : m_scaleFactor(1.0)
+ {
+ }
+
+ ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor)
+ : m_string(source.createView(start, length))
+ , m_scaleFactor(scaleFactor)
{
- return adoptRef(new LayerRect(node, layerType, rect));
}
- Node* layerRootNode() const { return m_layerRootNode.get(); }
- String layerType() const { return m_layerType; }
- ClientRect* layerRelativeRect() const { return m_rect.get(); }
+ String toString() const
+ {
+ return m_string.toString();
+ }
-private:
- LayerRect(PassRefPtr<Node> node, const String& layerName, PassRefPtr<ClientRect> rect)
- : m_layerRootNode(node)
- , m_layerType(layerName)
- , m_rect(rect)
+ inline float scaleFactor() const
{
+ return m_scaleFactor;
}
- RefPtr<Node> m_layerRootNode;
- String m_layerType;
- RefPtr<ClientRect> m_rect;
+ inline bool isEmpty() const
+ {
+ return m_string.isEmpty();
+ }
+
+private:
+ StringView m_string;
+ float m_scaleFactor;
};
-} // namespace WebCore
+ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const String& srcsetAttribute);
+
+String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, const String& srcsetAttribute);
+
+String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, ImageCandidate& srcsetImageCandidate);
+
+}
#endif
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | Source/core/html/parser/HTMLSrcsetParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698