| 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 | 4  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights | 
| 5  * reserved. | 5  * reserved. | 
| 6  * Copyright (C) 2010 Google Inc. All rights reserved. | 6  * Copyright (C) 2010 Google Inc. All rights reserved. | 
| 7  * | 7  * | 
| 8  * This library is free software; you can redistribute it and/or | 8  * This library is free software; you can redistribute it and/or | 
| 9  * modify it under the terms of the GNU Library General Public | 9  * modify it under the terms of the GNU Library General Public | 
| 10  * License as published by the Free Software Foundation; either | 10  * License as published by the Free Software Foundation; either | 
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 134   selectSourceURL(ImageLoader::UpdateSizeChanged); | 134   selectSourceURL(ImageLoader::UpdateSizeChanged); | 
| 135 } | 135 } | 
| 136 | 136 | 
| 137 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document) { | 137 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document) { | 
| 138   HTMLImageElement* image = new HTMLImageElement(document); | 138   HTMLImageElement* image = new HTMLImageElement(document); | 
| 139   image->m_elementCreatedByParser = false; | 139   image->m_elementCreatedByParser = false; | 
| 140   return image; | 140   return image; | 
| 141 } | 141 } | 
| 142 | 142 | 
| 143 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, | 143 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, | 
| 144                                                            int width) { | 144                                                            unsigned width) { | 
| 145   HTMLImageElement* image = new HTMLImageElement(document); | 145   HTMLImageElement* image = new HTMLImageElement(document); | 
| 146   image->setWidth(width); | 146   image->setWidth(width); | 
| 147   image->m_elementCreatedByParser = false; | 147   image->m_elementCreatedByParser = false; | 
| 148   return image; | 148   return image; | 
| 149 } | 149 } | 
| 150 | 150 | 
| 151 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, | 151 HTMLImageElement* HTMLImageElement::createForJSConstructor(Document& document, | 
| 152                                                            int width, | 152                                                            unsigned width, | 
| 153                                                            int height) { | 153                                                            unsigned height) { | 
| 154   HTMLImageElement* image = new HTMLImageElement(document); | 154   HTMLImageElement* image = new HTMLImageElement(document); | 
| 155   image->setWidth(width); | 155   image->setWidth(width); | 
| 156   image->setHeight(height); | 156   image->setHeight(height); | 
| 157   image->m_elementCreatedByParser = false; | 157   image->m_elementCreatedByParser = false; | 
| 158   return image; | 158   return image; | 
| 159 } | 159 } | 
| 160 | 160 | 
| 161 bool HTMLImageElement::isPresentationAttribute( | 161 bool HTMLImageElement::isPresentationAttribute( | 
| 162     const QualifiedName& name) const { | 162     const QualifiedName& name) const { | 
| 163   if (name == widthAttr || name == heightAttr || name == borderAttr || | 163   if (name == widthAttr || name == heightAttr || name == borderAttr || | 
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 419     resetFormOwner(); | 419     resetFormOwner(); | 
| 420   if (m_listener) { | 420   if (m_listener) { | 
| 421     document().mediaQueryMatcher().removeViewportListener(m_listener); | 421     document().mediaQueryMatcher().removeViewportListener(m_listener); | 
| 422     Node* parent = parentNode(); | 422     Node* parent = parentNode(); | 
| 423     if (parent && isHTMLPictureElement(*parent)) | 423     if (parent && isHTMLPictureElement(*parent)) | 
| 424       toHTMLPictureElement(parent)->removeListenerFromSourceChildren(); | 424       toHTMLPictureElement(parent)->removeListenerFromSourceChildren(); | 
| 425   } | 425   } | 
| 426   HTMLElement::removedFrom(insertionPoint); | 426   HTMLElement::removedFrom(insertionPoint); | 
| 427 } | 427 } | 
| 428 | 428 | 
| 429 int HTMLImageElement::width() { | 429 unsigned HTMLImageElement::width() { | 
| 430   if (inActiveDocument()) | 430   if (inActiveDocument()) | 
| 431     document().updateStyleAndLayoutIgnorePendingStylesheets(); | 431     document().updateStyleAndLayoutIgnorePendingStylesheets(); | 
| 432 | 432 | 
| 433   if (!layoutObject()) { | 433   if (!layoutObject()) { | 
| 434     // check the attribute first for an explicit pixel value | 434     // check the attribute first for an explicit pixel value | 
| 435     bool ok; | 435     unsigned width = 0; | 
| 436     int width = getAttribute(widthAttr).toInt(&ok); | 436     if (parseHTMLNonNegativeInteger(getAttribute(widthAttr), width)) | 
| 437     if (ok) |  | 
| 438       return width; | 437       return width; | 
| 439 | 438 | 
| 440     // if the image is available, use its width | 439     // if the image is available, use its width | 
| 441     if (imageLoader().image()) | 440     if (imageLoader().image()) { | 
| 442       return imageLoader() | 441       return imageLoader() | 
| 443           .image() | 442           .image() | 
| 444           ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), | 443           ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), | 
| 445                       1.0f) | 444                       1.0f) | 
| 446           .width() | 445           .width() | 
| 447           .toInt(); | 446           .toUnsigned(); | 
|  | 447     } | 
| 448   } | 448   } | 
| 449 | 449 | 
| 450   LayoutBox* box = layoutBox(); | 450   LayoutBox* box = layoutBox(); | 
| 451   return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth(), | 451   return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth(), | 
| 452                                      box) | 452                                      box) | 
| 453              : 0; | 453              : 0; | 
| 454 } | 454 } | 
| 455 | 455 | 
| 456 int HTMLImageElement::height() { | 456 unsigned HTMLImageElement::height() { | 
| 457   if (inActiveDocument()) | 457   if (inActiveDocument()) | 
| 458     document().updateStyleAndLayoutIgnorePendingStylesheets(); | 458     document().updateStyleAndLayoutIgnorePendingStylesheets(); | 
| 459 | 459 | 
| 460   if (!layoutObject()) { | 460   if (!layoutObject()) { | 
| 461     // check the attribute first for an explicit pixel value | 461     // check the attribute first for an explicit pixel value | 
| 462     bool ok; | 462     unsigned height = 0; | 
| 463     int height = getAttribute(heightAttr).toInt(&ok); | 463     if (parseHTMLNonNegativeInteger(getAttribute(heightAttr), height)) | 
| 464     if (ok) |  | 
| 465       return height; | 464       return height; | 
| 466 | 465 | 
| 467     // if the image is available, use its height | 466     // if the image is available, use its height | 
| 468     if (imageLoader().image()) | 467     if (imageLoader().image()) { | 
| 469       return imageLoader() | 468       return imageLoader() | 
| 470           .image() | 469           .image() | 
| 471           ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), | 470           ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), | 
| 472                       1.0f) | 471                       1.0f) | 
| 473           .height() | 472           .height() | 
| 474           .toInt(); | 473           .toUnsigned(); | 
|  | 474     } | 
| 475   } | 475   } | 
| 476 | 476 | 
| 477   LayoutBox* box = layoutBox(); | 477   LayoutBox* box = layoutBox(); | 
| 478   return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(), | 478   return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(), | 
| 479                                      box) | 479                                      box) | 
| 480              : 0; | 480              : 0; | 
| 481 } | 481 } | 
| 482 | 482 | 
| 483 int HTMLImageElement::naturalWidth() const { | 483 unsigned HTMLImageElement::naturalWidth() const { | 
| 484   if (!imageLoader().image()) | 484   if (!imageLoader().image()) | 
| 485     return 0; | 485     return 0; | 
| 486 | 486 | 
| 487   return imageLoader() | 487   return imageLoader() | 
| 488       .image() | 488       .image() | 
| 489       ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), | 489       ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), | 
| 490                   m_imageDevicePixelRatio, | 490                   m_imageDevicePixelRatio, | 
| 491                   ImageResource::IntrinsicCorrectedToDPR) | 491                   ImageResource::IntrinsicCorrectedToDPR) | 
| 492       .width() | 492       .width() | 
| 493       .toInt(); | 493       .toUnsigned(); | 
| 494 } | 494 } | 
| 495 | 495 | 
| 496 int HTMLImageElement::naturalHeight() const { | 496 unsigned HTMLImageElement::naturalHeight() const { | 
| 497   if (!imageLoader().image()) | 497   if (!imageLoader().image()) | 
| 498     return 0; | 498     return 0; | 
| 499 | 499 | 
| 500   return imageLoader() | 500   return imageLoader() | 
| 501       .image() | 501       .image() | 
| 502       ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), | 502       ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), | 
| 503                   m_imageDevicePixelRatio, | 503                   m_imageDevicePixelRatio, | 
| 504                   ImageResource::IntrinsicCorrectedToDPR) | 504                   ImageResource::IntrinsicCorrectedToDPR) | 
| 505       .height() | 505       .height() | 
| 506       .toInt(); | 506       .toUnsigned(); | 
| 507 } | 507 } | 
| 508 | 508 | 
| 509 const String& HTMLImageElement::currentSrc() const { | 509 const String& HTMLImageElement::currentSrc() const { | 
| 510   // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom-
     img-currentsrc | 510   // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom-
     img-currentsrc | 
| 511   // The currentSrc IDL attribute must return the img element's current | 511   // The currentSrc IDL attribute must return the img element's current | 
| 512   // request's current URL. | 512   // request's current URL. | 
| 513 | 513 | 
| 514   // Return the picked URL string in case of load error. | 514   // Return the picked URL string in case of load error. | 
| 515   if (imageLoader().hadError()) | 515   if (imageLoader().hadError()) | 
| 516     return m_bestFitImageURL; | 516     return m_bestFitImageURL; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 537 | 537 | 
| 538 const QualifiedName& HTMLImageElement::subResourceAttributeName() const { | 538 const QualifiedName& HTMLImageElement::subResourceAttributeName() const { | 
| 539   return srcAttr; | 539   return srcAttr; | 
| 540 } | 540 } | 
| 541 | 541 | 
| 542 bool HTMLImageElement::draggable() const { | 542 bool HTMLImageElement::draggable() const { | 
| 543   // Image elements are draggable by default. | 543   // Image elements are draggable by default. | 
| 544   return !equalIgnoringCase(getAttribute(draggableAttr), "false"); | 544   return !equalIgnoringCase(getAttribute(draggableAttr), "false"); | 
| 545 } | 545 } | 
| 546 | 546 | 
| 547 void HTMLImageElement::setHeight(int value) { | 547 void HTMLImageElement::setHeight(unsigned value) { | 
| 548   setIntegralAttribute(heightAttr, value); | 548   setUnsignedIntegralAttribute(heightAttr, value); | 
| 549 } | 549 } | 
| 550 | 550 | 
| 551 KURL HTMLImageElement::src() const { | 551 KURL HTMLImageElement::src() const { | 
| 552   return document().completeURL(getAttribute(srcAttr)); | 552   return document().completeURL(getAttribute(srcAttr)); | 
| 553 } | 553 } | 
| 554 | 554 | 
| 555 void HTMLImageElement::setSrc(const String& value) { | 555 void HTMLImageElement::setSrc(const String& value) { | 
| 556   setAttribute(srcAttr, AtomicString(value)); | 556   setAttribute(srcAttr, AtomicString(value)); | 
| 557 } | 557 } | 
| 558 | 558 | 
| 559 void HTMLImageElement::setWidth(int value) { | 559 void HTMLImageElement::setWidth(unsigned value) { | 
| 560   setIntegralAttribute(widthAttr, value); | 560   setUnsignedIntegralAttribute(widthAttr, value); | 
| 561 } | 561 } | 
| 562 | 562 | 
| 563 int HTMLImageElement::x() const { | 563 int HTMLImageElement::x() const { | 
| 564   document().updateStyleAndLayoutIgnorePendingStylesheets(); | 564   document().updateStyleAndLayoutIgnorePendingStylesheets(); | 
| 565   LayoutObject* r = layoutObject(); | 565   LayoutObject* r = layoutObject(); | 
| 566   if (!r) | 566   if (!r) | 
| 567     return 0; | 567     return 0; | 
| 568 | 568 | 
| 569   // FIXME: This doesn't work correctly with transforms. | 569   // FIXME: This doesn't work correctly with transforms. | 
| 570   FloatPoint absPos = r->localToAbsolute(); | 570   FloatPoint absPos = r->localToAbsolute(); | 
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 885   ImageResource* image = cachedImage(); | 885   ImageResource* image = cachedImage(); | 
| 886   if (!image) | 886   if (!image) | 
| 887     return IntSize(); | 887     return IntSize(); | 
| 888   LayoutSize lSize = image->imageSize( | 888   LayoutSize lSize = image->imageSize( | 
| 889       LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); | 889       LayoutObject::shouldRespectImageOrientation(layoutObject()), 1.0f); | 
| 890   DCHECK(lSize.fraction().isZero()); | 890   DCHECK(lSize.fraction().isZero()); | 
| 891   return IntSize(lSize.width().toInt(), lSize.height().toInt()); | 891   return IntSize(lSize.width().toInt(), lSize.height().toInt()); | 
| 892 } | 892 } | 
| 893 | 893 | 
| 894 }  // namespace blink | 894 }  // namespace blink | 
| OLD | NEW | 
|---|