Chromium Code Reviews| 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_intrinsicSizeFactor(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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 m_bestFitImageURL = bestFitSourceForImageAttributes(document().devic ePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), m_intrin sicSizeFactor); |
| 125 m_imageLoader.updateFromElementIgnoringPreviousError(); | 126 m_imageLoader.updateFromElementIgnoringPreviousError(); |
| 126 } | 127 } |
| 127 else if (name == usemapAttr) | 128 else if (name == usemapAttr) |
| 128 setIsLink(!value.isNull()); | 129 setIsLink(!value.isNull()); |
| 129 else if (name == onbeforeloadAttr) | 130 else if (name == onbeforeloadAttr) |
| 130 setAttributeEventListener(EventNames::beforeload, createAttributeEventLi stener(this, name, value)); | 131 setAttributeEventListener(EventNames::beforeload, createAttributeEventLi stener(this, name, value)); |
| 131 else if (name == compositeAttr) { | 132 else if (name == compositeAttr) { |
| 132 // FIXME: images don't support blend modes in their compositing attribut e. | 133 // FIXME: images don't support blend modes in their compositing attribut e. |
| 133 BlendMode blendOp = BlendModeNormal; | 134 BlendMode blendOp = BlendModeNormal; |
| 134 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) | 135 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 149 return alt; | 150 return alt; |
| 150 } | 151 } |
| 151 | 152 |
| 152 RenderObject* HTMLImageElement::createRenderer(RenderStyle* style) | 153 RenderObject* HTMLImageElement::createRenderer(RenderStyle* style) |
| 153 { | 154 { |
| 154 if (style->hasContent()) | 155 if (style->hasContent()) |
| 155 return RenderObject::createObject(this, style); | 156 return RenderObject::createObject(this, style); |
| 156 | 157 |
| 157 RenderImage* image = new RenderImage(this); | 158 RenderImage* image = new RenderImage(this); |
| 158 image->setImageResource(RenderImageResource::create()); | 159 image->setImageResource(RenderImageResource::create()); |
| 160 image->setIntrinsicSizeFactor(m_intrinsicSizeFactor); | |
|
pdr.
2013/10/11 05:17:33
I'm not sure this will work for dynamic changes. F
Yoav Weiss
2013/10/11 07:22:32
Good catch! Will fix.
| |
| 159 return image; | 161 return image; |
| 160 } | 162 } |
| 161 | 163 |
| 162 bool HTMLImageElement::canStartSelection() const | 164 bool HTMLImageElement::canStartSelection() const |
| 163 { | 165 { |
| 164 if (shadow()) | 166 if (shadow()) |
| 165 return HTMLElement::canStartSelection(); | 167 return HTMLElement::canStartSelection(); |
| 166 | 168 |
| 167 return false; | 169 return false; |
| 168 } | 170 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 | 379 |
| 378 Image* HTMLImageElement::imageContents() | 380 Image* HTMLImageElement::imageContents() |
| 379 { | 381 { |
| 380 if (!m_imageLoader.imageComplete()) | 382 if (!m_imageLoader.imageComplete()) |
| 381 return 0; | 383 return 0; |
| 382 | 384 |
| 383 return m_imageLoader.image()->image(); | 385 return m_imageLoader.image()->image(); |
| 384 } | 386 } |
| 385 | 387 |
| 386 } | 388 } |
| OLD | NEW |