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 14 matching lines...) Expand all Loading... | |
| 25 | 25 |
| 26 #include "CSSPropertyNames.h" | 26 #include "CSSPropertyNames.h" |
| 27 #include "HTMLNames.h" | 27 #include "HTMLNames.h" |
| 28 #include "bindings/v8/ScriptEventListener.h" | 28 #include "bindings/v8/ScriptEventListener.h" |
| 29 #include "core/dom/Attribute.h" | 29 #include "core/dom/Attribute.h" |
| 30 #include "core/dom/EventNames.h" | 30 #include "core/dom/EventNames.h" |
| 31 #include "core/fetch/ImageResource.h" | 31 #include "core/fetch/ImageResource.h" |
| 32 #include "core/html/HTMLAnchorElement.h" | 32 #include "core/html/HTMLAnchorElement.h" |
| 33 #include "core/html/HTMLFormElement.h" | 33 #include "core/html/HTMLFormElement.h" |
| 34 #include "core/html/parser/HTMLParserIdioms.h" | 34 #include "core/html/parser/HTMLParserIdioms.h" |
| 35 #include "core/page/Page.h" | |
| 35 #include "core/rendering/RenderImage.h" | 36 #include "core/rendering/RenderImage.h" |
| 36 | 37 |
| 37 using namespace std; | 38 using namespace std; |
| 38 | 39 |
| 39 namespace WebCore { | 40 namespace WebCore { |
| 40 | 41 |
| 41 using namespace HTMLNames; | 42 using namespace HTMLNames; |
| 42 | 43 |
| 43 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document* docum ent, HTMLFormElement* form) | 44 HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document* docum ent, HTMLFormElement* form) |
| 44 : HTMLElement(tagName, document) | 45 : HTMLElement(tagName, document) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); | 101 addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value); |
| 101 addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); | 102 addHTMLLengthToStyle(style, CSSPropertyMarginRight, value); |
| 102 } else if (name == alignAttr) | 103 } else if (name == alignAttr) |
| 103 applyAlignmentAttributeToStyle(value, style); | 104 applyAlignmentAttributeToStyle(value, style); |
| 104 else if (name == valignAttr) | 105 else if (name == valignAttr) |
| 105 addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, value); | 106 addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, value); |
| 106 else | 107 else |
| 107 HTMLElement::collectStyleForPresentationAttribute(name, value, style); | 108 HTMLElement::collectStyleForPresentationAttribute(name, value, style); |
| 108 } | 109 } |
| 109 | 110 |
| 111 const AtomicString HTMLImageElement::imageSourceURL() const | |
| 112 { | |
| 113 return m_bestFitImageURL.isEmpty() ? fastGetAttribute(srcAttr) : m_bestFitIm ageURL; | |
| 114 } | |
| 115 | |
| 110 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) | 116 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) |
| 111 { | 117 { |
| 112 if (name == altAttr) { | 118 if (name == altAttr) { |
| 113 if (renderer() && renderer()->isImage()) | 119 if (renderer() && renderer()->isImage()) |
| 114 toRenderImage(renderer())->updateAltText(); | 120 toRenderImage(renderer())->updateAltText(); |
| 115 } else if (name == srcAttr) | 121 } else if (name == srcAttr || name == srcsetAttr) { |
| 122 float deviceScaleFactor = 1.0; | |
| 123 if (Page* page = document().page()) | |
| 124 deviceScaleFactor = page->deviceScaleFactor(); | |
|
johnme
2013/09/04 09:50:22
As discussed on blink-dev, you probably want:
flo
| |
| 125 m_bestFitImageURL = bestFitSourceForImageAttributes(deviceScaleFactor, f astGetAttribute(srcAttr), fastGetAttribute(srcsetAttr)); | |
| 116 m_imageLoader.updateFromElementIgnoringPreviousError(); | 126 m_imageLoader.updateFromElementIgnoringPreviousError(); |
| 127 } | |
| 117 else if (name == usemapAttr) | 128 else if (name == usemapAttr) |
| 118 setIsLink(!value.isNull()); | 129 setIsLink(!value.isNull()); |
| 119 else if (name == onbeforeloadAttr) | 130 else if (name == onbeforeloadAttr) |
| 120 setAttributeEventListener(eventNames().beforeloadEvent, createAttributeE ventListener(this, name, value)); | 131 setAttributeEventListener(eventNames().beforeloadEvent, createAttributeE ventListener(this, name, value)); |
| 121 else if (name == compositeAttr) { | 132 else if (name == compositeAttr) { |
| 122 // 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. |
| 123 BlendMode blendOp = BlendModeNormal; | 134 BlendMode blendOp = BlendModeNormal; |
| 124 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) | 135 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) ) |
| 125 m_compositeOperator = CompositeSourceOver; | 136 m_compositeOperator = CompositeSourceOver; |
| 126 } else | 137 } else |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 | 378 |
| 368 Image* HTMLImageElement::imageContents() | 379 Image* HTMLImageElement::imageContents() |
| 369 { | 380 { |
| 370 if (!m_imageLoader.imageComplete()) | 381 if (!m_imageLoader.imageComplete()) |
| 371 return 0; | 382 return 0; |
| 372 | 383 |
| 373 return m_imageLoader.image()->image(); | 384 return m_imageLoader.image()->image(); |
| 374 } | 385 } |
| 375 | 386 |
| 376 } | 387 } |
| OLD | NEW |