| 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (imageLoader().image()) { | 444 if (imageLoader().image()) { |
| 445 return imageLoader() | 445 return imageLoader() |
| 446 .image() | 446 .image() |
| 447 ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), | 447 ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), |
| 448 1.0f) | 448 1.0f) |
| 449 .width() | 449 .width() |
| 450 .toUnsigned(); | 450 .toUnsigned(); |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 LayoutBox* box = layoutBox(); | 454 return layoutBoxWidth(); |
| 455 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth(), | |
| 456 box) | |
| 457 : 0; | |
| 458 } | 455 } |
| 459 | 456 |
| 460 unsigned HTMLImageElement::height() { | 457 unsigned HTMLImageElement::height() { |
| 461 if (inActiveDocument()) | 458 if (inActiveDocument()) |
| 462 document().updateStyleAndLayoutIgnorePendingStylesheets(); | 459 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 463 | 460 |
| 464 if (!layoutObject()) { | 461 if (!layoutObject()) { |
| 465 // check the attribute first for an explicit pixel value | 462 // check the attribute first for an explicit pixel value |
| 466 unsigned height = 0; | 463 unsigned height = 0; |
| 467 if (parseHTMLNonNegativeInteger(getAttribute(heightAttr), height)) | 464 if (parseHTMLNonNegativeInteger(getAttribute(heightAttr), height)) |
| 468 return height; | 465 return height; |
| 469 | 466 |
| 470 // if the image is available, use its height | 467 // if the image is available, use its height |
| 471 if (imageLoader().image()) { | 468 if (imageLoader().image()) { |
| 472 return imageLoader() | 469 return imageLoader() |
| 473 .image() | 470 .image() |
| 474 ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), | 471 ->imageSize(LayoutObject::shouldRespectImageOrientation(nullptr), |
| 475 1.0f) | 472 1.0f) |
| 476 .height() | 473 .height() |
| 477 .toUnsigned(); | 474 .toUnsigned(); |
| 478 } | 475 } |
| 479 } | 476 } |
| 480 | 477 |
| 481 LayoutBox* box = layoutBox(); | 478 return layoutBoxHeight(); |
| 482 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(), | |
| 483 box) | |
| 484 : 0; | |
| 485 } | 479 } |
| 486 | 480 |
| 487 unsigned HTMLImageElement::naturalWidth() const { | 481 unsigned HTMLImageElement::naturalWidth() const { |
| 488 if (!imageLoader().image()) | 482 if (!imageLoader().image()) |
| 489 return 0; | 483 return 0; |
| 490 | 484 |
| 491 return imageLoader() | 485 return imageLoader() |
| 492 .image() | 486 .image() |
| 493 ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), | 487 ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), |
| 494 m_imageDevicePixelRatio, | 488 m_imageDevicePixelRatio, |
| 495 ImageResourceContent::IntrinsicCorrectedToDPR) | 489 ImageResourceContent::IntrinsicCorrectedToDPR) |
| 496 .width() | 490 .width() |
| 497 .toUnsigned(); | 491 .toUnsigned(); |
| 498 } | 492 } |
| 499 | 493 |
| 500 unsigned HTMLImageElement::naturalHeight() const { | 494 unsigned HTMLImageElement::naturalHeight() const { |
| 501 if (!imageLoader().image()) | 495 if (!imageLoader().image()) |
| 502 return 0; | 496 return 0; |
| 503 | 497 |
| 504 return imageLoader() | 498 return imageLoader() |
| 505 .image() | 499 .image() |
| 506 ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), | 500 ->imageSize(LayoutObject::shouldRespectImageOrientation(layoutObject()), |
| 507 m_imageDevicePixelRatio, | 501 m_imageDevicePixelRatio, |
| 508 ImageResourceContent::IntrinsicCorrectedToDPR) | 502 ImageResourceContent::IntrinsicCorrectedToDPR) |
| 509 .height() | 503 .height() |
| 510 .toUnsigned(); | 504 .toUnsigned(); |
| 511 } | 505 } |
| 512 | 506 |
| 507 unsigned HTMLImageElement::layoutBoxWidth() const { |
| 508 LayoutBox* box = layoutBox(); |
| 509 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth(), |
| 510 box) |
| 511 : 0; |
| 512 } |
| 513 |
| 514 unsigned HTMLImageElement::layoutBoxHeight() const { |
| 515 LayoutBox* box = layoutBox(); |
| 516 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight(), |
| 517 box) |
| 518 : 0; |
| 519 } |
| 520 |
| 513 const String& HTMLImageElement::currentSrc() const { | 521 const String& HTMLImageElement::currentSrc() const { |
| 514 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom-
img-currentsrc | 522 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#dom-
img-currentsrc |
| 515 // The currentSrc IDL attribute must return the img element's current | 523 // The currentSrc IDL attribute must return the img element's current |
| 516 // request's current URL. | 524 // request's current URL. |
| 517 | 525 |
| 518 // Return the picked URL string in case of load error. | 526 // Return the picked URL string in case of load error. |
| 519 if (imageLoader().hadError()) | 527 if (imageLoader().hadError()) |
| 520 return m_bestFitImageURL; | 528 return m_bestFitImageURL; |
| 521 // Initially, the pending request turns into current request when it is either | 529 // Initially, the pending request turns into current request when it is either |
| 522 // available or broken. We use the image's dimensions as a proxy to it being | 530 // available or broken. We use the image's dimensions as a proxy to it being |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 void HTMLImageElement::associateWith(HTMLFormElement* form) { | 918 void HTMLImageElement::associateWith(HTMLFormElement* form) { |
| 911 if (form && form->isConnected()) { | 919 if (form && form->isConnected()) { |
| 912 m_form = form; | 920 m_form = form; |
| 913 m_formWasSetByParser = true; | 921 m_formWasSetByParser = true; |
| 914 m_form->associate(*this); | 922 m_form->associate(*this); |
| 915 m_form->didAssociateByParser(); | 923 m_form->didAssociateByParser(); |
| 916 } | 924 } |
| 917 }; | 925 }; |
| 918 | 926 |
| 919 } // namespace blink | 927 } // namespace blink |
| OLD | NEW |