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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 | 392 |
| 393 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) | 393 void HTMLImageElement::removedFrom(ContainerNode* insertionPoint) |
| 394 { | 394 { |
| 395 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) | 395 if (!m_form || NodeTraversal::highestAncestorOrSelf(*m_form.get()) != NodeTr aversal::highestAncestorOrSelf(*this)) |
| 396 resetFormOwner(); | 396 resetFormOwner(); |
| 397 if (m_listener) | 397 if (m_listener) |
| 398 document().mediaQueryMatcher().removeViewportListener(m_listener); | 398 document().mediaQueryMatcher().removeViewportListener(m_listener); |
| 399 HTMLElement::removedFrom(insertionPoint); | 399 HTMLElement::removedFrom(insertionPoint); |
| 400 } | 400 } |
| 401 | 401 |
| 402 int HTMLImageElement::width(bool ignorePendingStylesheets) | 402 int HTMLImageElement::width() |
| 403 { | 403 { |
| 404 if (inActiveDocument()) | |
| 405 document().updateLayoutIgnorePendingStylesheets(); | |
| 406 | |
| 404 if (!layoutObject()) { | 407 if (!layoutObject()) { |
| 405 // check the attribute first for an explicit pixel value | 408 // check the attribute first for an explicit pixel value |
| 406 bool ok; | 409 bool ok; |
| 407 int width = getAttribute(widthAttr).toInt(&ok); | 410 int width = getAttribute(widthAttr).toInt(&ok); |
| 408 if (ok) | 411 if (ok) |
| 409 return width; | 412 return width; |
| 410 | 413 |
| 411 // if the image is available, use its width | 414 // if the image is available, use its width |
| 412 if (imageLoader().image()) | 415 if (imageLoader().image()) |
| 413 return imageLoader().image()->imageSizeForLayoutObject(layoutObject( ), 1.0f).width(); | 416 return imageLoader().image()->imageSizeForLayoutObject(layoutObject( ), 1.0f).width(); |
| 414 } | 417 } |
| 415 | 418 |
| 416 if (ignorePendingStylesheets) | |
| 417 document().updateLayoutIgnorePendingStylesheets(); | |
| 418 else | |
| 419 document().updateLayout(); | |
| 420 | |
| 421 LayoutBox* box = layoutBox(); | 419 LayoutBox* box = layoutBox(); |
| 422 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth() , box) : 0; | 420 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth() , box) : 0; |
| 423 } | 421 } |
| 424 | 422 |
| 425 int HTMLImageElement::height(bool ignorePendingStylesheets) | 423 int HTMLImageElement::height() |
| 426 { | 424 { |
| 425 if (inActiveDocument()) | |
|
pdr.
2015/08/15 02:09:26
The inActiveDocument check seems like a good idea.
| |
| 426 document().updateLayoutIgnorePendingStylesheets(); | |
| 427 | |
| 427 if (!layoutObject()) { | 428 if (!layoutObject()) { |
| 428 // check the attribute first for an explicit pixel value | 429 // check the attribute first for an explicit pixel value |
| 429 bool ok; | 430 bool ok; |
| 430 int height = getAttribute(heightAttr).toInt(&ok); | 431 int height = getAttribute(heightAttr).toInt(&ok); |
| 431 if (ok) | 432 if (ok) |
| 432 return height; | 433 return height; |
| 433 | 434 |
| 434 // if the image is available, use its height | 435 // if the image is available, use its height |
| 435 if (imageLoader().image()) | 436 if (imageLoader().image()) |
| 436 return imageLoader().image()->imageSizeForLayoutObject(layoutObject( ), 1.0f).height(); | 437 return imageLoader().image()->imageSizeForLayoutObject(layoutObject( ), 1.0f).height(); |
| 437 } | 438 } |
| 438 | 439 |
| 439 if (ignorePendingStylesheets) | |
| 440 document().updateLayoutIgnorePendingStylesheets(); | |
| 441 else | |
| 442 document().updateLayout(); | |
| 443 | |
| 444 LayoutBox* box = layoutBox(); | 440 LayoutBox* box = layoutBox(); |
| 445 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight( ), box) : 0; | 441 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight( ), box) : 0; |
| 446 } | 442 } |
| 447 | 443 |
| 448 int HTMLImageElement::naturalWidth() const | 444 int HTMLImageElement::naturalWidth() const |
| 449 { | 445 { |
| 450 if (!imageLoader().image()) | 446 if (!imageLoader().image()) |
| 451 return 0; | 447 return 0; |
| 452 | 448 |
| 453 return imageLoader().image()->imageSizeForLayoutObject(layoutObject(), m_ima geDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).width(); | 449 return imageLoader().image()->imageSizeForLayoutObject(layoutObject(), m_ima geDevicePixelRatio, ImageResource::IntrinsicCorrectedToDPR).width(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 ensureUserAgentShadowRoot(); | 749 ensureUserAgentShadowRoot(); |
| 754 } | 750 } |
| 755 | 751 |
| 756 bool HTMLImageElement::isOpaque() const | 752 bool HTMLImageElement::isOpaque() const |
| 757 { | 753 { |
| 758 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); | 754 Image* image = const_cast<HTMLImageElement*>(this)->imageContents(); |
| 759 return image && image->currentFrameKnownToBeOpaque(); | 755 return image && image->currentFrameKnownToBeOpaque(); |
| 760 } | 756 } |
| 761 | 757 |
| 762 } | 758 } |
| OLD | NEW |