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

Side by Side Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 23788011: Round off error while calculating the background-size: contain/cover. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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
« no previous file with comments | « LayoutTests/fast/css/background-size-cover-and-contain-expected.html ('k') | no next file » | 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 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 // If the image has neither an intrinsic width nor an intrinsic heig ht, its size is determined as for ‘contain’. 927 // If the image has neither an intrinsic width nor an intrinsic heig ht, its size is determined as for ‘contain’.
928 type = Contain; 928 type = Contain;
929 } 929 }
930 case Contain: 930 case Contain:
931 case Cover: { 931 case Cover: {
932 float horizontalScaleFactor = imageIntrinsicSize.width() 932 float horizontalScaleFactor = imageIntrinsicSize.width()
933 ? static_cast<float>(positioningAreaSize.width()) / imageIntrins icSize.width() : 1; 933 ? static_cast<float>(positioningAreaSize.width()) / imageIntrins icSize.width() : 1;
934 float verticalScaleFactor = imageIntrinsicSize.height() 934 float verticalScaleFactor = imageIntrinsicSize.height()
935 ? static_cast<float>(positioningAreaSize.height()) / imageIntrin sicSize.height() : 1; 935 ? static_cast<float>(positioningAreaSize.height()) / imageIntrin sicSize.height() : 1;
936 float scaleFactor = type == Contain ? min(horizontalScaleFactor, ver ticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor); 936 float scaleFactor = type == Contain ? min(horizontalScaleFactor, ver ticalScaleFactor) : max(horizontalScaleFactor, verticalScaleFactor);
937 return IntSize(max(1, static_cast<int>(imageIntrinsicSize.width() * scaleFactor)), max(1, static_cast<int>(imageIntrinsicSize.height() * scaleFactor ))); 937 return IntSize(max(1, static_cast<int>(round(imageIntrinsicSize.widt h() * scaleFactor))), max(1, static_cast<int>(round(imageIntrinsicSize.height() * scaleFactor))));
eseidel 2013/09/18 18:59:45 should this just be lround?
938 } 938 }
939 } 939 }
940 940
941 ASSERT_NOT_REACHED(); 941 ASSERT_NOT_REACHED();
942 return IntSize(); 942 return IntSize();
943 } 943 }
944 944
945 void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX(int xOffset) 945 void RenderBoxModelObject::BackgroundImageGeometry::setNoRepeatX(int xOffset)
946 { 946 {
947 m_destRect.move(max(xOffset, 0), 0); 947 m_destRect.move(max(xOffset, 0), 0);
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent()); 2786 ASSERT(!beforeChild || toBoxModelObject == beforeChild->parent());
2787 for (RenderObject* child = startChild; child && child != endChild; ) { 2787 for (RenderObject* child = startChild; child && child != endChild; ) {
2788 // Save our next sibling as moveChildTo will clear it. 2788 // Save our next sibling as moveChildTo will clear it.
2789 RenderObject* nextSibling = child->nextSibling(); 2789 RenderObject* nextSibling = child->nextSibling();
2790 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert); 2790 moveChildTo(toBoxModelObject, child, beforeChild, fullRemoveInsert);
2791 child = nextSibling; 2791 child = nextSibling;
2792 } 2792 }
2793 } 2793 }
2794 2794
2795 } // namespace WebCore 2795 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/background-size-cover-and-contain-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698