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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLImageElement.cpp

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 3 months 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
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 if (!layoutObject()) { 412 if (!layoutObject()) {
413 // check the attribute first for an explicit pixel value 413 // check the attribute first for an explicit pixel value
414 bool ok; 414 bool ok;
415 int width = getAttribute(widthAttr).toInt(&ok); 415 int width = getAttribute(widthAttr).toInt(&ok);
416 if (ok) 416 if (ok)
417 return width; 417 return width;
418 418
419 // if the image is available, use its width 419 // if the image is available, use its width
420 if (imageLoader().image()) 420 if (imageLoader().image())
421 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI mageOrientation(nullptr), 1.0f).width(); 421 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI mageOrientation(nullptr), 1.0f).width().toInt();
422 } 422 }
423 423
424 LayoutBox* box = layoutBox(); 424 LayoutBox* box = layoutBox();
425 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth() , box) : 0; 425 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedWidth() , box) : 0;
426 } 426 }
427 427
428 int HTMLImageElement::height() 428 int HTMLImageElement::height()
429 { 429 {
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 bool ok;
436 int height = getAttribute(heightAttr).toInt(&ok); 436 int height = getAttribute(heightAttr).toInt(&ok);
437 if (ok) 437 if (ok)
438 return height; 438 return height;
439 439
440 // if the image is available, use its height 440 // if the image is available, use its height
441 if (imageLoader().image()) 441 if (imageLoader().image())
442 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI mageOrientation(nullptr), 1.0f).height(); 442 return imageLoader().image()->imageSize(LayoutObject::shouldRespectI mageOrientation(nullptr), 1.0f).height().toInt();
443 } 443 }
444 444
445 LayoutBox* box = layoutBox(); 445 LayoutBox* box = layoutBox();
446 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight( ), box) : 0; 446 return box ? adjustForAbsoluteZoom(box->contentBoxRect().pixelSnappedHeight( ), box) : 0;
447 } 447 }
448 448
449 int HTMLImageElement::naturalWidth() const 449 int HTMLImageElement::naturalWidth() const
450 { 450 {
451 if (!imageLoader().image()) 451 if (!imageLoader().image())
452 return 0; 452 return 0;
453 453
454 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec tedToDPR).width(); 454 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec tedToDPR).width().toInt();
455 } 455 }
456 456
457 int HTMLImageElement::naturalHeight() const 457 int HTMLImageElement::naturalHeight() const
458 { 458 {
459 if (!imageLoader().image()) 459 if (!imageLoader().image())
460 return 0; 460 return 0;
461 461
462 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec tedToDPR).height(); 462 return imageLoader().image()->imageSize(LayoutObject::shouldRespectImageOrie ntation(layoutObject()), m_imageDevicePixelRatio, ImageResource::IntrinsicCorrec tedToDPR).height().toInt();
463 } 463 }
464 464
465 const String& HTMLImageElement::currentSrc() const 465 const String& HTMLImageElement::currentSrc() const
466 { 466 {
467 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do m-img-currentsrc 467 // http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#do m-img-currentsrc
468 // The currentSrc IDL attribute must return the img element's current reques t's current URL. 468 // The currentSrc IDL attribute must return the img element's current reques t's current URL.
469 469
470 // Return the picked URL string in case of load error. 470 // Return the picked URL string in case of load error.
471 if (imageLoader().hadError()) 471 if (imageLoader().hadError())
472 return m_bestFitImageURL; 472 return m_bestFitImageURL;
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 return image->height(); 823 return image->height();
824 } 824 }
825 825
826 IntSize HTMLImageElement::bitmapSourceSize() const 826 IntSize HTMLImageElement::bitmapSourceSize() const
827 { 827 {
828 ImageResource* image = cachedImage(); 828 ImageResource* image = cachedImage();
829 if (!image) 829 if (!image)
830 return IntSize(); 830 return IntSize();
831 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f); 831 LayoutSize lSize = image->imageSize(LayoutObject::shouldRespectImageOrientat ion(layoutObject()), 1.0f);
832 DCHECK(lSize.fraction().isZero()); 832 DCHECK(lSize.fraction().isZero());
833 return IntSize(lSize.width(), lSize.height()); 833 return IntSize(lSize.width().toInt(), lSize.height().toInt());
834 } 834 }
835 835
836 } // namespace blink 836 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameViewAutoSizeInfo.cpp ('k') | third_party/WebKit/Source/core/html/ImageDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698