Changeset 95757 in webkit


Ignore:
Timestamp:
Sep 22, 2011 3:35:21 PM (13 years ago)
Author:
jonlee@apple.com
Message:

Progress control gets cropped on the bottom
https://bugs.webkit.org/show_bug.cgi?id=68302
<rdar://problem/10069915>

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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95756 r95757  
     12011-09-22  Jon Lee  <jonlee@apple.com>
     2
     3        Progress control gets cropped on the bottom
     4        https://bugs.webkit.org/show_bug.cgi?id=68302
     5        <rdar://problem/10069915>
     6
     7        Reviewed by Kent Tamura.
     8
     9        As it turns out the smaller control type does not get rendered either, so this patch
     10        fixes both.
     11
     12        * manual-tests/dom/progressbar.html: Altered to show both sizes of controls
     13        * rendering/RenderThemeMac.h:
     14        * rendering/RenderThemeMac.mm: Added methods to inflate the drawing rect
     15        (WebCore::RenderThemeMac::progressBarSizes):
     16        (WebCore::RenderThemeMac::progressBarMargins):
     17        (WebCore::RenderThemeMac::minimumProgressBarHeight):
     18        (WebCore::RenderThemeMac::paintProgressBar): Inflate the rect based on minimum desired
     19        control height and glow margin.
     20
    1212011-09-22  David Hyatt  <hyatt@apple.com>
    222
  • trunk/Source/WebCore/manual-tests/dom/progressbar.html

    r56850 r95757  
    1 <html><body>
    2 <h1>Indeterminate progress bar</h1>
     1<h1>Progress bars</h1>
     2<h2>Large</h2>
     3<div style="font-size:16px">
    34This is an example of <progress value=7 max=10></progress> a determinate progress bar.<br>
    45This is an example of <progress></progress> an indeterminate progress bar.<br>
    56This is an example of <progress dir=rtl value=7 max=10></progress> a right-to-left determinate progress bar.<br>
    67This is an example of <progress dir=rtl></progress> a right-to-left indeterminate progress bar.<br>
    7 
    8 </body></html>
     8</div>
     9<h2>Small</h2>
     10<div style="font-size:14px">
     11This is an example of <progress value=4 max=10></progress> a small determinate progress bar.<br>
     12This is an example of <progress></progress> a small indeterminate progress bar.<br>
     13This is an example of <progress dir=rtl value=4 max=10></progress> a small right-to-left determinate progress bar.<br>
     14This is an example of <progress dir=rtl></progress> a small right-to-left indeterminate progress bar.<br>
     15</div>
  • trunk/Source/WebCore/rendering/RenderThemeMac.h

    r89048 r95757  
    22 * This file is part of the theme implementation for form controls in WebCore.
    33 *
    4  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc.
     4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Computer, Inc.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    226226#endif
    227227
     228#if ENABLE(PROGRESS_TAG)
     229    int minimumProgressBarHeight(RenderStyle*) const;
     230    const IntSize* progressBarSizes() const;
     231    const int* progressBarMargins(NSControlSize) const;
     232#endif
     233
    228234private:
    229235    mutable RetainPtr<NSPopUpButtonCell> m_popupButton;
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r93021 r95757  
    11/*
    2  * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    910910
    911911#if ENABLE(PROGRESS_TAG)
    912 
     912const IntSize* RenderThemeMac::progressBarSizes() const
     913{
     914    static const IntSize sizes[3] = { IntSize(0, 20), IntSize(0, 12), IntSize(0, 12) };
     915    return sizes;
     916}
     917
     918const int* RenderThemeMac::progressBarMargins(NSControlSize controlSize) const
     919{
     920    static const int margins[3][4] =
     921    {
     922        { 0, 0, 1, 0 },
     923        { 0, 0, 1, 0 },
     924        { 0, 0, 1, 0 },
     925    };
     926    return margins[controlSize];
     927}
     928
     929int RenderThemeMac::minimumProgressBarHeight(RenderStyle* style) const
     930{
     931    return sizeForSystemFont(style, progressBarSizes()).height();
     932}
     933   
    913934double RenderThemeMac::animationRepeatIntervalForProgressBar(RenderProgress*) const
    914935{
     
    930951        return true;
    931952
     953    float zoomLevel = renderObject->style()->effectiveZoom();
     954    int controlSize = controlSizeForFont(renderObject->style());
     955    IntSize size = progressBarSizes()[controlSize];
     956    size.setHeight(size.height() * zoomLevel);
     957    size.setWidth(rect.width());
     958   
     959    // Now inflate it to account for the shadow.
     960    IntRect inflatedRect = rect;
     961    if (rect.height() <= minimumProgressBarHeight(renderObject->style()))
     962        inflatedRect = inflateRect(inflatedRect, size, progressBarMargins(controlSize), zoomLevel);
     963   
    932964    RenderProgress* renderProgress = toRenderProgress(renderObject);
    933965    HIThemeTrackDrawInfo trackInfo;
    934966    trackInfo.version = 0;
    935     trackInfo.kind = renderProgress->position() < 0 ? kThemeLargeIndeterminateBar : kThemeLargeProgressBar;
    936     trackInfo.bounds = IntRect(IntPoint(), rect.size());
     967    if (controlSize == NSRegularControlSize)
     968        trackInfo.kind = renderProgress->position() < 0 ? kThemeLargeIndeterminateBar : kThemeLargeProgressBar;
     969    else
     970        trackInfo.kind = renderProgress->position() < 0 ? kThemeMediumIndeterminateBar : kThemeMediumProgressBar;
     971   
     972    trackInfo.bounds = IntRect(IntPoint(), inflatedRect.size());
    937973    trackInfo.min = 0;
    938974    trackInfo.max = numeric_limits<SInt32>::max();
     
    944980    trackInfo.filler1 = 0;
    945981
    946     OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(rect.size());
     982    OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(inflatedRect.size());
    947983    if (!imageBuffer)
    948984        return true;
     
    955991
    956992    if (!renderProgress->style()->isLeftToRightDirection()) {
    957         paintInfo.context->translate(2 * rect.x() + rect.width(), 0);
     993        paintInfo.context->translate(2 * inflatedRect.x() + inflatedRect.width(), 0);
    958994        paintInfo.context->scale(FloatSize(-1, 1));
    959995    }
    960996   
    961     paintInfo.context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, rect.location());
     997    paintInfo.context->drawImageBuffer(imageBuffer.get(), ColorSpaceDeviceRGB, inflatedRect.location());
    962998    return false;
    963999}   
Note: See TracChangeset for help on using the changeset viewer.