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

Side by Side Diff: Source/core/html/HTMLImageElement.cpp

Issue 240063003: Revert "A sizes attribute parser" (https://codereview.chromium.org/224733011) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLImageElement.idl » ('j') | 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.
11 * 11 *
12 * This library is distributed in the hope that it will be useful, 12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details. 15 * Library General Public License for more details.
16 * 16 *
17 * You should have received a copy of the GNU Library General Public License 17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to 18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA. 20 * Boston, MA 02110-1301, USA.
21 */ 21 */
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 "CSSPropertyNames.h" 26 #include "CSSPropertyNames.h"
27 #include "HTMLNames.h" 27 #include "HTMLNames.h"
28 #include "RuntimeEnabledFeatures.h" 28 #include "RuntimeEnabledFeatures.h"
29 #include "bindings/v8/ScriptEventListener.h" 29 #include "bindings/v8/ScriptEventListener.h"
30 #include "core/css/MediaValuesDynamic.h"
31 #include "core/css/parser/SizesAttributeParser.h"
32 #include "core/dom/Attribute.h" 30 #include "core/dom/Attribute.h"
33 #include "core/fetch/ImageResource.h" 31 #include "core/fetch/ImageResource.h"
34 #include "core/html/HTMLAnchorElement.h" 32 #include "core/html/HTMLAnchorElement.h"
35 #include "core/html/HTMLCanvasElement.h" 33 #include "core/html/HTMLCanvasElement.h"
36 #include "core/html/HTMLFormElement.h" 34 #include "core/html/HTMLFormElement.h"
37 #include "core/html/canvas/CanvasRenderingContext.h" 35 #include "core/html/canvas/CanvasRenderingContext.h"
38 #include "core/html/parser/HTMLParserIdioms.h" 36 #include "core/html/parser/HTMLParserIdioms.h"
39 #include "core/html/parser/HTMLSrcsetParser.h" 37 #include "core/html/parser/HTMLSrcsetParser.h"
40 #include "core/rendering/RenderImage.h" 38 #include "core/rendering/RenderImage.h"
41 39
42 using namespace std; 40 using namespace std;
43 41
44 namespace WebCore { 42 namespace WebCore {
45 43
46 using namespace HTMLNames; 44 using namespace HTMLNames;
47 45
48 HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form) 46 HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form)
49 : HTMLElement(imgTag, document) 47 : HTMLElement(imgTag, document)
50 , m_imageLoader(this) 48 , m_imageLoader(this)
51 , m_compositeOperator(CompositeSourceOver) 49 , m_compositeOperator(CompositeSourceOver)
52 , m_imageDevicePixelRatio(1.0f) 50 , m_imageDevicePixelRatio(1.0f)
53 , m_formWasSetByParser(false) 51 , m_formWasSetByParser(false)
54 , m_effectiveSize(0)
55 { 52 {
56 ScriptWrappable::init(this); 53 ScriptWrappable::init(this);
57 if (form && form->inDocument()) { 54 if (form && form->inDocument()) {
58 m_form = form->createWeakPtr(); 55 m_form = form->createWeakPtr();
59 m_formWasSetByParser = true; 56 m_formWasSetByParser = true;
60 m_form->associate(*this); 57 m_form->associate(*this);
61 m_form->didAssociateByParser(); 58 m_form->didAssociateByParser();
62 } 59 }
63 } 60 }
64 61
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } else if (name == srcAttr || name == srcsetAttr) { 156 } else if (name == srcAttr || name == srcsetAttr) {
160 int effectiveSize = -1; // FIXME - hook up the real value from `sizes` 157 int effectiveSize = -1; // FIXME - hook up the real value from `sizes`
161 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src setAttr)); 158 ImageCandidate candidate = bestFitSourceForImageAttributes(document().de vicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(src setAttr));
162 m_bestFitImageURL = candidate.toAtomicString(); 159 m_bestFitImageURL = candidate.toAtomicString();
163 float candidateScaleFactor = candidate.scaleFactor(); 160 float candidateScaleFactor = candidate.scaleFactor();
164 if (candidateScaleFactor > 0) 161 if (candidateScaleFactor > 0)
165 m_imageDevicePixelRatio = 1 / candidateScaleFactor; 162 m_imageDevicePixelRatio = 1 / candidateScaleFactor;
166 if (renderer() && renderer()->isImage()) 163 if (renderer() && renderer()->isImage())
167 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePix elRatio); 164 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePix elRatio);
168 m_imageLoader.updateFromElementIgnoringPreviousError(); 165 m_imageLoader.updateFromElementIgnoringPreviousError();
169 } else if (RuntimeEnabledFeatures::pictureSizesEnabled() && name == sizesAtt r) {
170 m_effectiveSize = SizesAttributeParser::findEffectiveSize(value, MediaVa luesDynamic::create(document()));
171 } else if (name == usemapAttr) { 166 } else if (name == usemapAttr) {
172 setIsLink(!value.isNull()); 167 setIsLink(!value.isNull());
173 } else if (name == compositeAttr) { 168 } else if (name == compositeAttr) {
174 // FIXME: images don't support blend modes in their compositing attribut e. 169 // FIXME: images don't support blend modes in their compositing attribut e.
175 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; 170 blink::WebBlendMode blendOp = blink::WebBlendModeNormal;
176 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) 171 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) )
177 m_compositeOperator = CompositeSourceOver; 172 m_compositeOperator = CompositeSourceOver;
178 } else { 173 } else {
179 HTMLElement::parseAttribute(name, value); 174 HTMLElement::parseAttribute(name, value);
180 } 175 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (!image) 465 if (!image)
471 return FloatSize(); 466 return FloatSize();
472 LayoutSize size; 467 LayoutSize size;
473 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this. 468 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo ut this.
474 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth()) 469 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i mage()->hasRelativeWidth())
475 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); 470 size.scale(toRenderImage(renderer())->imageDevicePixelRatio());
476 return size; 471 return size;
477 } 472 }
478 473
479 } 474 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLImageElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698