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

Side by Side Diff: sky/engine/core/html/HTMLImageElement.cpp

Issue 732813002: Remove sizes attr. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/css/parser/SizesAttributeParserTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv ed.
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 11 matching lines...) Expand all
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/html/HTMLImageElement.h" 24 #include "core/html/HTMLImageElement.h"
25 25
26 #include "core/CSSPropertyNames.h" 26 #include "core/CSSPropertyNames.h"
27 #include "core/HTMLNames.h" 27 #include "core/HTMLNames.h"
28 #include "core/MediaTypeNames.h" 28 #include "core/MediaTypeNames.h"
29 #include "core/css/MediaQueryListListener.h" 29 #include "core/css/MediaQueryListListener.h"
30 #include "core/css/MediaQueryMatcher.h" 30 #include "core/css/MediaQueryMatcher.h"
31 #include "core/css/MediaValuesDynamic.h" 31 #include "core/css/MediaValuesDynamic.h"
32 #include "core/css/parser/SizesAttributeParser.h"
33 #include "core/dom/Attribute.h" 32 #include "core/dom/Attribute.h"
34 #include "core/dom/NodeTraversal.h" 33 #include "core/dom/NodeTraversal.h"
35 #include "core/fetch/ImageResource.h" 34 #include "core/fetch/ImageResource.h"
36 #include "core/frame/UseCounter.h" 35 #include "core/frame/UseCounter.h"
37 #include "core/html/HTMLAnchorElement.h" 36 #include "core/html/HTMLAnchorElement.h"
38 #include "core/html/HTMLCanvasElement.h" 37 #include "core/html/HTMLCanvasElement.h"
39 #include "core/html/canvas/CanvasRenderingContext.h" 38 #include "core/html/canvas/CanvasRenderingContext.h"
40 #include "core/html/parser/HTMLParserIdioms.h" 39 #include "core/html/parser/HTMLParserIdioms.h"
41 #include "core/html/parser/HTMLSrcsetParser.h" 40 #include "core/html/parser/HTMLSrcsetParser.h"
42 #include "core/inspector/ConsoleMessage.h" 41 #include "core/inspector/ConsoleMessage.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 LayoutSize size; 376 LayoutSize size;
378 size = image->imageSizeForRenderer(renderer()); // FIXME: Not sure about thi s. 377 size = image->imageSizeForRenderer(renderer()); // FIXME: Not sure about thi s.
379 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth()) 378 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth())
380 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); 379 size.scale(toRenderImage(renderer())->imageDevicePixelRatio());
381 return size; 380 return size;
382 } 381 }
383 382
384 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior) 383 void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be havior)
385 { 384 {
386 unsigned effectiveSize = 0; 385 unsigned effectiveSize = 0;
387 if (RuntimeEnabledFeatures::pictureSizesEnabled()) {
388 String sizes = getAttribute(HTMLNames::sizesAttr);
389 if (!sizes.isNull())
390 UseCounter::count(document(), UseCounter::Sizes);
391 SizesAttributeParser parser = SizesAttributeParser(MediaValuesDynamic::c reate(document()), sizes);
392 effectiveSize = parser.length();
393 m_effectiveSizeViewportDependant = parser.viewportDependant();
394 }
395 ImageCandidate candidate = bestFitSourceForImageAttributes( 386 ImageCandidate candidate = bestFitSourceForImageAttributes(
396 document().devicePixelRatio(), effectiveSize, 387 document().devicePixelRatio(), effectiveSize,
397 getAttribute(HTMLNames::srcAttr), getAttribute(HTMLNames::srcsetAttr)); 388 getAttribute(HTMLNames::srcAttr), getAttribute(HTMLNames::srcsetAttr));
398 setBestFitURLAndDPRFromImageCandidate(candidate); 389 setBestFitURLAndDPRFromImageCandidate(candidate);
399 if (m_intrinsicSizingViewportDependant && m_effectiveSizeViewportDependant & & !m_listener.get()) { 390 if (m_intrinsicSizingViewportDependant && m_effectiveSizeViewportDependant & & !m_listener.get()) {
400 m_listener = ViewportChangeListener::create(this); 391 m_listener = ViewportChangeListener::create(this);
401 document().mediaQueryMatcher().addViewportListener(m_listener.get()); 392 document().mediaQueryMatcher().addViewportListener(m_listener.get());
402 } 393 }
403 imageLoader().updateFromElement(behavior); 394 imageLoader().updateFromElement(behavior);
404 } 395 }
405 396
406 const KURL& HTMLImageElement::sourceURL() const 397 const KURL& HTMLImageElement::sourceURL() const
407 { 398 {
408 return cachedImage()->response().url(); 399 return cachedImage()->response().url();
409 } 400 }
410 401
411 } 402 }
OLDNEW
« no previous file with comments | « sky/engine/core/css/parser/SizesAttributeParserTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698