From: jchaffraix@webkit.org Date: Wed, 16 Apr 2008 19:47:55 +0000 (+0000) Subject: 2008-04-16 Anatoli Papirovski X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=edaa26f07718c3bef892c067e183d9ec6419d447 2008-04-16 Anatoli Papirovski Reviewed by David. Optimized the calculation of background-size. * rendering/RenderBox.cpp: (WebCore::RenderBox::calculateBackgroundSize): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@31958 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 3548b96..76c2ee5 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,12 @@ +2008-04-16 Anatoli Papirovski + + Reviewed by David. + + Optimized the calculation of background-size. + + * rendering/RenderBox.cpp: + (WebCore::RenderBox::calculateBackgroundSize): + 2008-04-16 Adam Roben Fix Bug 17228: console.{log,warn,info,error} should support format diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp index e10b9110..c1878f1 100644 --- a/WebCore/rendering/RenderBox.cpp +++ b/WebCore/rendering/RenderBox.cpp @@ -436,37 +436,27 @@ IntSize RenderBox::calculateBackgroundSize(const BackgroundLayer* bgLayer, int s Length bgWidth = bgLayer->backgroundSize().width; Length bgHeight = bgLayer->backgroundSize().height; - if (bgWidth.isPercent()) - w = bgWidth.calcValue(scaledWidth); - else if (bgWidth.isFixed()) + if (bgWidth.isFixed()) w = bgWidth.value(); - else if (bgWidth.isAuto()) { - // If the width is auto and the height is not, we have to use the appropriate - // scale to maintain our aspect ratio. - if (bgHeight.isPercent()) { - int scaledH = bgHeight.calcValue(scaledHeight); - w = bg->imageSize(style()->effectiveZoom()).width() * scaledH / bg->imageSize(style()->effectiveZoom()).height(); - } else if (bgHeight.isFixed()) - w = bg->imageSize(style()->effectiveZoom()).width() * bgHeight.value() / bg->imageSize(style()->effectiveZoom()).height(); - } - - if (bgHeight.isPercent()) - h = bgHeight.calcValue(scaledHeight); - else if (bgHeight.isFixed()) + else if (bgWidth.isPercent()) + w = bgWidth.calcValue(scaledWidth); + + if (bgHeight.isFixed()) h = bgHeight.value(); - else if (bgHeight.isAuto()) { - // If the height is auto and the width is not, we have to use the appropriate - // scale to maintain our aspect ratio. - if (bgWidth.isPercent()) - h = bg->imageSize(style()->effectiveZoom()).height() * w / bg->imageSize(style()->effectiveZoom()).width(); - else if (bgWidth.isFixed()) - h = bg->imageSize(style()->effectiveZoom()).height() * bgWidth.value() / bg->imageSize(style()->effectiveZoom()).width(); - else if (bgWidth.isAuto()) { - // If both width and height are auto, we just want to use the image's - // intrinsic size. - w = bg->imageSize(style()->effectiveZoom()).width(); - h = bg->imageSize(style()->effectiveZoom()).height(); - } + else if (bgHeight.isPercent()) + h = bgHeight.calcValue(scaledHeight); + + // If one of the values is auto we have to use the appropriate + // scale to maintain our aspect ratio. + if (bgWidth.isAuto() && !bgHeight.isAuto()) + w = bg->imageSize(style()->effectiveZoom()).width() * h / bg->imageSize(style()->effectiveZoom()).height(); + else if (!bgWidth.isAuto() && bgHeight.isAuto()) + h = bg->imageSize(style()->effectiveZoom()).height() * w / bg->imageSize(style()->effectiveZoom()).width(); + else if (bgWidth.isAuto() && bgHeight.isAuto()) { + // If both width and height are auto, we just want to use the image's + // intrinsic size. + w = bg->imageSize(style()->effectiveZoom()).width(); + h = bg->imageSize(style()->effectiveZoom()).height(); } return IntSize(max(1, w), max(1, h));