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

Side by Side Diff: sky/engine/core/html/HTMLImageElement.cpp

Issue 708233002: Remove many attributes. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/html/HTMLImageElement.h ('k') | sky/engine/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.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 MediaQueryListListener::trace(visitor); 68 MediaQueryListListener::trace(visitor);
69 } 69 }
70 private: 70 private:
71 explicit ViewportChangeListener(HTMLImageElement* element) : m_element(eleme nt) { } 71 explicit ViewportChangeListener(HTMLImageElement* element) : m_element(eleme nt) { }
72 RawPtr<HTMLImageElement> m_element; 72 RawPtr<HTMLImageElement> m_element;
73 }; 73 };
74 74
75 HTMLImageElement::HTMLImageElement(Document& document, bool createdByParser) 75 HTMLImageElement::HTMLImageElement(Document& document, bool createdByParser)
76 : HTMLElement(HTMLNames::imgTag, document) 76 : HTMLElement(HTMLNames::imgTag, document)
77 , m_imageLoader(HTMLImageLoader::create(this)) 77 , m_imageLoader(HTMLImageLoader::create(this))
78 , m_compositeOperator(CompositeSourceOver)
79 , m_imageDevicePixelRatio(1.0f) 78 , m_imageDevicePixelRatio(1.0f)
80 , m_elementCreatedByParser(createdByParser) 79 , m_elementCreatedByParser(createdByParser)
81 , m_intrinsicSizingViewportDependant(false) 80 , m_intrinsicSizingViewportDependant(false)
82 , m_effectiveSizeViewportDependant(false) 81 , m_effectiveSizeViewportDependant(false)
83 { 82 {
84 ScriptWrappable::init(this); 83 ScriptWrappable::init(this);
85 } 84 }
86 85
87 PassRefPtr<HTMLImageElement> HTMLImageElement::create(Document& document) 86 PassRefPtr<HTMLImageElement> HTMLImageElement::create(Document& document)
88 { 87 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio); 150 toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRa tio);
152 } 151 }
153 152
154 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 153 void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
155 { 154 {
156 if (name == HTMLNames::altAttr) { 155 if (name == HTMLNames::altAttr) {
157 if (renderer() && renderer()->isImage()) 156 if (renderer() && renderer()->isImage())
158 toRenderImage(renderer())->updateAltText(); 157 toRenderImage(renderer())->updateAltText();
159 } else if (name == HTMLNames::srcAttr || name == HTMLNames::srcsetAttr || na me == HTMLNames::sizesAttr) { 158 } else if (name == HTMLNames::srcAttr || name == HTMLNames::srcsetAttr || na me == HTMLNames::sizesAttr) {
160 selectSourceURL(ImageLoader::UpdateIgnorePreviousError); 159 selectSourceURL(ImageLoader::UpdateIgnorePreviousError);
161 } else if (name == HTMLNames::usemapAttr) {
162 setIsLink(!value.isNull());
163 } else if (name == HTMLNames::compositeAttr) {
164 blink::WebBlendMode blendOp = blink::WebBlendModeNormal;
165 if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp) )
166 m_compositeOperator = CompositeSourceOver;
167 else if (m_compositeOperator != CompositeSourceOver)
168 UseCounter::count(document(), UseCounter::HTMLImageElementComposite) ;
169 } else { 160 } else {
170 HTMLElement::parseAttribute(name, value); 161 HTMLElement::parseAttribute(name, value);
171 } 162 }
172 } 163 }
173 164
174 const AtomicString& HTMLImageElement::altText() const 165 const AtomicString& HTMLImageElement::altText() const
175 { 166 {
176 // lets figure out the alt text.. magic stuff 167 // lets figure out the alt text.. magic stuff
177 // http://www.w3.org/TR/1998/REC-html40-19980424/appendix/notes.html#altgen 168 // http://www.w3.org/TR/1998/REC-html40-19980424/appendix/notes.html#altgen
178 // also heavily discussed by Hixie on bugzilla 169 // also heavily discussed by Hixie on bugzilla
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // We use the image's dimensions as a proxy to it being in any of these stat es. 300 // We use the image's dimensions as a proxy to it being in any of these stat es.
310 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade r().image()->image()->width()) 301 if (!imageLoader().image() || !imageLoader().image()->image() || !imageLoade r().image()->image()->width())
311 return emptyAtom; 302 return emptyAtom;
312 303
313 return imageLoader().image()->url().string(); 304 return imageLoader().image()->url().string();
314 } 305 }
315 306
316 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const 307 bool HTMLImageElement::isURLAttribute(const Attribute& attribute) const
317 { 308 {
318 return attribute.name() == HTMLNames::srcAttr 309 return attribute.name() == HTMLNames::srcAttr
319 || attribute.name() == HTMLNames::lowsrcAttr
320 || attribute.name() == HTMLNames::longdescAttr
321 || (attribute.name() == HTMLNames::usemapAttr && attribute.value().strin g()[0] != '#')
322 || HTMLElement::isURLAttribute(attribute); 310 || HTMLElement::isURLAttribute(attribute);
323 } 311 }
324 312
325 void HTMLImageElement::setHeight(int value) 313 void HTMLImageElement::setHeight(int value)
326 { 314 {
327 setIntegralAttribute(HTMLNames::heightAttr, value); 315 setIntegralAttribute(HTMLNames::heightAttr, value);
328 } 316 }
329 317
330 KURL HTMLImageElement::src() const 318 KURL HTMLImageElement::src() const
331 { 319 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 { 358 {
371 return imageLoader().imageComplete(); 359 return imageLoader().imageComplete();
372 } 360 }
373 361
374 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument) 362 void HTMLImageElement::didMoveToNewDocument(Document& oldDocument)
375 { 363 {
376 imageLoader().elementDidMoveToNewDocument(); 364 imageLoader().elementDidMoveToNewDocument();
377 HTMLElement::didMoveToNewDocument(oldDocument); 365 HTMLElement::didMoveToNewDocument(oldDocument);
378 } 366 }
379 367
380 bool HTMLImageElement::isServerMap() const
381 {
382 if (!hasAttribute(HTMLNames::ismapAttr))
383 return false;
384
385 const AtomicString& usemap = getAttribute(HTMLNames::usemapAttr);
386
387 // If the usemap attribute starts with '#', it refers to a map element in th e document.
388 if (usemap.string()[0] == '#')
389 return false;
390
391 return document().completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)).isE mpty();
392 }
393
394 Image* HTMLImageElement::imageContents() 368 Image* HTMLImageElement::imageContents()
395 { 369 {
396 if (!imageLoader().imageComplete()) 370 if (!imageLoader().imageComplete())
397 return 0; 371 return 0;
398 372
399 return imageLoader().image()->image(); 373 return imageLoader().image()->image();
400 } 374 }
401 375
402 PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageMode, Sou rceImageStatus* status) const 376 PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageMode, Sou rceImageStatus* status) const
403 { 377 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 439 }
466 imageLoader().updateFromElement(behavior); 440 imageLoader().updateFromElement(behavior);
467 } 441 }
468 442
469 const KURL& HTMLImageElement::sourceURL() const 443 const KURL& HTMLImageElement::sourceURL() const
470 { 444 {
471 return cachedImage()->response().url(); 445 return cachedImage()->response().url();
472 } 446 }
473 447
474 } 448 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/HTMLImageElement.h ('k') | sky/engine/core/html/HTMLImageElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698