OLD | NEW |
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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 using namespace HTMLNames; | 43 using namespace HTMLNames; |
44 | 44 |
45 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
ent, HTMLFormElement* form) | 45 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
ent, HTMLFormElement* form) |
46 : HTMLElement(tagName, document) | 46 : HTMLElement(tagName, document) |
47 , m_imageLoader(this) | 47 , m_imageLoader(this) |
48 , m_form(form) | 48 , m_form(form) |
49 , m_compositeOperator(CompositeSourceOver) | 49 , m_compositeOperator(CompositeSourceOver) |
| 50 , m_imageDevicePixelRatio(1.0f) |
50 { | 51 { |
51 ASSERT(hasTagName(imgTag)); | 52 ASSERT(hasTagName(imgTag)); |
52 ScriptWrappable::init(this); | 53 ScriptWrappable::init(this); |
53 if (form) | 54 if (form) |
54 form->registerImgElement(this); | 55 form->registerImgElement(this); |
55 } | 56 } |
56 | 57 |
57 PassRefPtr<HTMLImageElement> HTMLImageElement::create(Document& document) | 58 PassRefPtr<HTMLImageElement> HTMLImageElement::create(Document& document) |
58 { | 59 { |
59 return adoptRef(new HTMLImageElement(imgTag, document)); | 60 return adoptRef(new HTMLImageElement(imgTag, document)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 { | 114 { |
114 return m_bestFitImageURL.isNull() ? fastGetAttribute(srcAttr) : m_bestFitIma
geURL; | 115 return m_bestFitImageURL.isNull() ? fastGetAttribute(srcAttr) : m_bestFitIma
geURL; |
115 } | 116 } |
116 | 117 |
117 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) | 118 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
ing& value) |
118 { | 119 { |
119 if (name == altAttr) { | 120 if (name == altAttr) { |
120 if (renderer() && renderer()->isImage()) | 121 if (renderer() && renderer()->isImage()) |
121 toRenderImage(renderer())->updateAltText(); | 122 toRenderImage(renderer())->updateAltText(); |
122 } else if (name == srcAttr || name == srcsetAttr) { | 123 } else if (name == srcAttr || name == srcsetAttr) { |
123 if (RuntimeEnabledFeatures::srcsetEnabled()) | 124 if (RuntimeEnabledFeatures::srcsetEnabled()) { |
124 m_bestFitImageURL = bestFitSourceForImageAttributes(document().devic
ePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); | 125 ImageCandidate candidate = bestFitSourceForImageAttributes(document(
).devicePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); |
| 126 m_bestFitImageURL = candidate.toString(); |
| 127 float candidateScaleFactor = candidate.scaleFactor(); |
| 128 if (candidateScaleFactor > 0) |
| 129 m_imageDevicePixelRatio = 1 / candidateScaleFactor; |
| 130 if (renderer() && renderer()->isImage()) |
| 131 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevic
ePixelRatio); |
| 132 } |
125 m_imageLoader.updateFromElementIgnoringPreviousError(); | 133 m_imageLoader.updateFromElementIgnoringPreviousError(); |
126 } | 134 } |
127 else if (name == usemapAttr) | 135 else if (name == usemapAttr) |
128 setIsLink(!value.isNull()); | 136 setIsLink(!value.isNull()); |
129 else if (name == onbeforeloadAttr) | 137 else if (name == onbeforeloadAttr) |
130 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve
ntListener(this, name, value)); | 138 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve
ntListener(this, name, value)); |
131 else if (name == compositeAttr) { | 139 else if (name == compositeAttr) { |
132 // FIXME: images don't support blend modes in their compositing attribut
e. | 140 // FIXME: images don't support blend modes in their compositing attribut
e. |
133 BlendMode blendOp = BlendModeNormal; | 141 BlendMode blendOp = BlendModeNormal; |
134 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)
) | 142 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)
) |
(...skipping 14 matching lines...) Expand all Loading... |
149 return alt; | 157 return alt; |
150 } | 158 } |
151 | 159 |
152 RenderObject* HTMLImageElement::createRenderer(RenderStyle* style) | 160 RenderObject* HTMLImageElement::createRenderer(RenderStyle* style) |
153 { | 161 { |
154 if (style->hasContent()) | 162 if (style->hasContent()) |
155 return RenderObject::createObject(this, style); | 163 return RenderObject::createObject(this, style); |
156 | 164 |
157 RenderImage* image = new RenderImage(this); | 165 RenderImage* image = new RenderImage(this); |
158 image->setImageResource(RenderImageResource::create()); | 166 image->setImageResource(RenderImageResource::create()); |
| 167 image->setImageDevicePixelRatio(m_imageDevicePixelRatio); |
159 return image; | 168 return image; |
160 } | 169 } |
161 | 170 |
162 bool HTMLImageElement::canStartSelection() const | 171 bool HTMLImageElement::canStartSelection() const |
163 { | 172 { |
164 if (shadow()) | 173 if (shadow()) |
165 return HTMLElement::canStartSelection(); | 174 return HTMLElement::canStartSelection(); |
166 | 175 |
167 return false; | 176 return false; |
168 } | 177 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 391 |
383 return m_imageLoader.image()->image(); | 392 return m_imageLoader.image()->image(); |
384 } | 393 } |
385 | 394 |
386 bool HTMLImageElement::isInteractiveContent() const | 395 bool HTMLImageElement::isInteractiveContent() const |
387 { | 396 { |
388 return fastHasAttribute(usemapAttr); | 397 return fastHasAttribute(usemapAttr); |
389 } | 398 } |
390 | 399 |
391 } | 400 } |
OLD | NEW |