| 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. |
| 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/parser/SizesAttributeParser.h" |
| 30 #include "core/dom/Attribute.h" | 31 #include "core/dom/Attribute.h" |
| 31 #include "core/fetch/ImageResource.h" | 32 #include "core/fetch/ImageResource.h" |
| 32 #include "core/html/HTMLAnchorElement.h" | 33 #include "core/html/HTMLAnchorElement.h" |
| 33 #include "core/html/HTMLCanvasElement.h" | 34 #include "core/html/HTMLCanvasElement.h" |
| 34 #include "core/html/HTMLFormElement.h" | 35 #include "core/html/HTMLFormElement.h" |
| 35 #include "core/html/canvas/CanvasRenderingContext.h" | 36 #include "core/html/canvas/CanvasRenderingContext.h" |
| 36 #include "core/html/parser/HTMLParserIdioms.h" | 37 #include "core/html/parser/HTMLParserIdioms.h" |
| 37 #include "core/html/parser/HTMLSrcsetParser.h" | 38 #include "core/html/parser/HTMLSrcsetParser.h" |
| 38 #include "core/rendering/RenderImage.h" | 39 #include "core/rendering/RenderImage.h" |
| 39 | 40 |
| 40 using namespace std; | 41 using namespace std; |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 using namespace HTMLNames; | 45 using namespace HTMLNames; |
| 45 | 46 |
| 46 HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form) | 47 HTMLImageElement::HTMLImageElement(Document& document, HTMLFormElement* form) |
| 47 : HTMLElement(imgTag, document) | 48 : HTMLElement(imgTag, document) |
| 48 , m_imageLoader(this) | 49 , m_imageLoader(this) |
| 49 , m_compositeOperator(CompositeSourceOver) | 50 , m_compositeOperator(CompositeSourceOver) |
| 50 , m_imageDevicePixelRatio(1.0f) | 51 , m_imageDevicePixelRatio(1.0f) |
| 51 , m_formWasSetByParser(false) | 52 , m_formWasSetByParser(false) |
| 53 , m_effectiveSize(0) |
| 52 { | 54 { |
| 53 ScriptWrappable::init(this); | 55 ScriptWrappable::init(this); |
| 54 if (form && form->inDocument()) { | 56 if (form && form->inDocument()) { |
| 55 m_form = form->createWeakPtr(); | 57 m_form = form->createWeakPtr(); |
| 56 m_formWasSetByParser = true; | 58 m_formWasSetByParser = true; |
| 57 m_form->associate(*this); | 59 m_form->associate(*this); |
| 58 m_form->didAssociateByParser(); | 60 m_form->didAssociateByParser(); |
| 59 } | 61 } |
| 60 } | 62 } |
| 61 | 63 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (RuntimeEnabledFeatures::srcsetEnabled()) { | 159 if (RuntimeEnabledFeatures::srcsetEnabled()) { |
| 158 ImageCandidate candidate = bestFitSourceForImageAttributes(document(
).devicePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); | 160 ImageCandidate candidate = bestFitSourceForImageAttributes(document(
).devicePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); |
| 159 m_bestFitImageURL = candidate.toAtomicString(); | 161 m_bestFitImageURL = candidate.toAtomicString(); |
| 160 float candidateScaleFactor = candidate.scaleFactor(); | 162 float candidateScaleFactor = candidate.scaleFactor(); |
| 161 if (candidateScaleFactor > 0) | 163 if (candidateScaleFactor > 0) |
| 162 m_imageDevicePixelRatio = 1 / candidateScaleFactor; | 164 m_imageDevicePixelRatio = 1 / candidateScaleFactor; |
| 163 if (renderer() && renderer()->isImage()) | 165 if (renderer() && renderer()->isImage()) |
| 164 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevic
ePixelRatio); | 166 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevic
ePixelRatio); |
| 165 } | 167 } |
| 166 m_imageLoader.updateFromElementIgnoringPreviousError(); | 168 m_imageLoader.updateFromElementIgnoringPreviousError(); |
| 169 } else if (RuntimeEnabledFeatures::sizesAttributeEnabled() && name == sizesA
ttr) { |
| 170 m_effectiveSize = SizesAttributeParser::findEffectiveSize(value, MediaVa
lues::create(document(), MediaValues::DynamicMode)); |
| 167 } else if (name == usemapAttr) { | 171 } else if (name == usemapAttr) { |
| 168 setIsLink(!value.isNull()); | 172 setIsLink(!value.isNull()); |
| 169 } else if (name == compositeAttr) { | 173 } else if (name == compositeAttr) { |
| 170 // FIXME: images don't support blend modes in their compositing attribut
e. | 174 // FIXME: images don't support blend modes in their compositing attribut
e. |
| 171 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; | 175 blink::WebBlendMode blendOp = blink::WebBlendModeNormal; |
| 172 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)
) | 176 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp)
) |
| 173 m_compositeOperator = CompositeSourceOver; | 177 m_compositeOperator = CompositeSourceOver; |
| 174 } else { | 178 } else { |
| 175 HTMLElement::parseAttribute(name, value); | 179 HTMLElement::parseAttribute(name, value); |
| 176 } | 180 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 if (!image) | 470 if (!image) |
| 467 return FloatSize(); | 471 return FloatSize(); |
| 468 LayoutSize size; | 472 LayoutSize size; |
| 469 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. | 473 size = image->imageSizeForRenderer(renderer(), 1.0f); // FIXME: Not sure abo
ut this. |
| 470 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) | 474 if (renderer() && renderer()->isRenderImage() && image->image() && !image->i
mage()->hasRelativeWidth()) |
| 471 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); | 475 size.scale(toRenderImage(renderer())->imageDevicePixelRatio()); |
| 472 return size; | 476 return size; |
| 473 } | 477 } |
| 474 | 478 |
| 475 } | 479 } |
| OLD | NEW |