From cabbc295b7cc341589d2c0494e4029f11f6a51ed Mon Sep 17 00:00:00 2001 From: "jonlee@apple.com" Date: Thu, 22 Sep 2011 22:35:21 +0000 Subject: [PATCH] Progress control gets cropped on the bottom https://bugs.webkit.org/show_bug.cgi?id=68302 Reviewed by Kent Tamura. As it turns out the smaller control type does not get rendered either, so this patch fixes both. * manual-tests/dom/progressbar.html: Altered to show both sizes of controls * rendering/RenderThemeMac.h: * rendering/RenderThemeMac.mm: Added methods to inflate the drawing rect (WebCore::RenderThemeMac::progressBarSizes): (WebCore::RenderThemeMac::progressBarMargins): (WebCore::RenderThemeMac::minimumProgressBarHeight): (WebCore::RenderThemeMac::paintProgressBar): Inflate the rect based on minimum desired control height and glow margin. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95757 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 20 ++++++++++ Source/WebCore/manual-tests/dom/progressbar.html | 15 ++++++-- Source/WebCore/rendering/RenderThemeMac.h | 8 +++- Source/WebCore/rendering/RenderThemeMac.mm | 48 +++++++++++++++++++++--- 4 files changed, 80 insertions(+), 11 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 423475b..f243fe8 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2011-09-22 Jon Lee + + Progress control gets cropped on the bottom + https://bugs.webkit.org/show_bug.cgi?id=68302 + + + Reviewed by Kent Tamura. + + As it turns out the smaller control type does not get rendered either, so this patch + fixes both. + + * manual-tests/dom/progressbar.html: Altered to show both sizes of controls + * rendering/RenderThemeMac.h: + * rendering/RenderThemeMac.mm: Added methods to inflate the drawing rect + (WebCore::RenderThemeMac::progressBarSizes): + (WebCore::RenderThemeMac::progressBarMargins): + (WebCore::RenderThemeMac::minimumProgressBarHeight): + (WebCore::RenderThemeMac::paintProgressBar): Inflate the rect based on minimum desired + control height and glow margin. + 2011-09-22 David Hyatt https://bugs.webkit.org/show_bug.cgi?id=68658 diff --git a/Source/WebCore/manual-tests/dom/progressbar.html b/Source/WebCore/manual-tests/dom/progressbar.html index 95e64f2..99c888d 100644 --- a/Source/WebCore/manual-tests/dom/progressbar.html +++ b/Source/WebCore/manual-tests/dom/progressbar.html @@ -1,8 +1,15 @@ - -

Indeterminate progress bar

+

Progress bars

+

Large

+
This is an example of a determinate progress bar.
This is an example of an indeterminate progress bar.
This is an example of a right-to-left determinate progress bar.
This is an example of a right-to-left indeterminate progress bar.
- - +
+

Small

+
+This is an example of a small determinate progress bar.
+This is an example of a small indeterminate progress bar.
+This is an example of a small right-to-left determinate progress bar.
+This is an example of a small right-to-left indeterminate progress bar.
+
diff --git a/Source/WebCore/rendering/RenderThemeMac.h b/Source/WebCore/rendering/RenderThemeMac.h index 1915b0e..2d72b81 100644 --- a/Source/WebCore/rendering/RenderThemeMac.h +++ b/Source/WebCore/rendering/RenderThemeMac.h @@ -1,7 +1,7 @@ /* * This file is part of the theme implementation for form controls in WebCore. * - * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Computer, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -225,6 +225,12 @@ private: NSLevelIndicatorCell* levelIndicatorFor(const RenderMeter*) const; #endif +#if ENABLE(PROGRESS_TAG) + int minimumProgressBarHeight(RenderStyle*) const; + const IntSize* progressBarSizes() const; + const int* progressBarMargins(NSControlSize) const; +#endif + private: mutable RetainPtr m_popupButton; mutable RetainPtr m_search; diff --git a/Source/WebCore/rendering/RenderThemeMac.mm b/Source/WebCore/rendering/RenderThemeMac.mm index 2ffc361..49c79f7 100644 --- a/Source/WebCore/rendering/RenderThemeMac.mm +++ b/Source/WebCore/rendering/RenderThemeMac.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -909,7 +909,28 @@ NSLevelIndicatorCell* RenderThemeMac::levelIndicatorFor(const RenderMeter* rende #endif #if ENABLE(PROGRESS_TAG) +const IntSize* RenderThemeMac::progressBarSizes() const +{ + static const IntSize sizes[3] = { IntSize(0, 20), IntSize(0, 12), IntSize(0, 12) }; + return sizes; +} + +const int* RenderThemeMac::progressBarMargins(NSControlSize controlSize) const +{ + static const int margins[3][4] = + { + { 0, 0, 1, 0 }, + { 0, 0, 1, 0 }, + { 0, 0, 1, 0 }, + }; + return margins[controlSize]; +} +int RenderThemeMac::minimumProgressBarHeight(RenderStyle* style) const +{ + return sizeForSystemFont(style, progressBarSizes()).height(); +} + double RenderThemeMac::animationRepeatIntervalForProgressBar(RenderProgress*) const { return progressAnimationFrameRate; @@ -929,11 +950,26 @@ bool RenderThemeMac::paintProgressBar(RenderObject* renderObject, const PaintInf if (!renderObject->isProgress()) return true; + float zoomLevel = renderObject->style()->effectiveZoom(); + int controlSize = controlSizeForFont(renderObject->style()); + IntSize size = progressBarSizes()[controlSize]; + size.setHeight(size.height() * zoomLevel); + size.setWidth(rect.width()); + + // Now inflate it to account for the shadow. + IntRect inflatedRect = rect; + if (rect.height() <= minimumProgressBarHeight(renderObject->style())) + inflatedRect = inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel); + RenderProgress* renderProgress = toRenderProgress(renderObject); HIThemeTrackDrawInfo trackInfo; trackInfo.version = 0; - trackInfo.kind = renderProgress->position() < 0 ? kThemeLargeIndeterminateBar : kThemeLargeProgressBar; - trackInfo.bounds = IntRect(IntPoint(), rect.size()); + if (controlSize == NSRegularControlSize) + trackInfo.kind = renderProgress->position() < 0 ? kThemeLargeIndeterminateBar : kThemeLargeProgressBar; + else + trackInfo.kind = renderProgress->position() < 0 ? kThemeMediumIndeterminateBar : kThemeMediumProgressBar; + + trackInfo.bounds = IntRect(IntPoint(), inflatedRect.size()); trackInfo.min = 0; trackInfo.max = numeric_limits::max(); trackInfo.value = lround(renderProgress->position() * nextafter(trackInfo.max, 0)); @@ -943,7 +979,7 @@ bool RenderThemeMac::paintProgressBar(RenderObject* renderObject, const PaintInf trackInfo.reserved = 0; trackInfo.filler1 = 0; - OwnPtr imageBuffer = ImageBuffer::create(rect.size()); + OwnPtr imageBuffer = ImageBuffer::create(inflatedRect.size()); if (!imageBuffer) return true; @@ -954,11 +990,11 @@ bool RenderThemeMac::paintProgressBar(RenderObject* renderObject, const PaintInf GraphicsContextStateSaver stateSaver(*paintInfo.context); if (!renderProgress->style()->isLeftToRightDirection()) { - paintInfo.context->translate(2 * rect.x() + rect.width(), 0); + paintInfo.context->translate(2 * inflatedRect.x() + inflatedRect.width(), 0); paintInfo.context->scale(FloatSize(-1, 1)); } - paintInfo.context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, rect.location()); + paintInfo.context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, inflatedRect.location()); return false; } #endif -- 2.7.4