Changeset 58228 in webkit


Ignore:
Timestamp:
Apr 25, 2010 6:52:18 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-25 yael aharon <yael.aharon@nokia.com>

Reviewed by Adele Peterson.

Allow styling of HTMLProgressElement.
https://bugs.webkit.org/show_bug.cgi?id=37901

Added a test for changing the -webkit-appearance statically and dynamically.

  • fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html: Added.
  • platform/chromium/test_expectations.txt:
  • platform/gtk/Skipped:
  • platform/mac/fast/dom/HTMLProgressElement: Added.
  • platform/mac/fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element-expected.checksum: Added.
  • platform/mac/fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element-expected.png: Added.
  • platform/mac/fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element-expected.txt: Added.
  • platform/qt/Skipped:
  • platform/win/Skipped:

2010-04-25 yael aharon <yael.aharon@nokia.com>

Reviewed by Adele Peterson.

Allow styling of HTMLProgressElement.
https://bugs.webkit.org/show_bug.cgi?id=37901

Added a new pseudo element to represent the value portion of the progress element.
Web developers can style this pseudo element separate from the rest of the progress element.

Test: fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html

  • css/CSSPrimitiveValueMappings.h: (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
  • css/CSSSelector.cpp: (WebCore::CSSSelector::pseudoId): (WebCore::nameToPseudoTypeMap): (WebCore::CSSSelector::extractPseudoType):
  • css/CSSSelector.h:
  • css/CSSValueKeywords.in:
  • platform/ThemeTypes.h:
  • rendering/RenderProgress.cpp: (WebCore::ProgressValueElement::isShadowNode): (WebCore::ProgressValueElement::shadowParentNode): (WebCore::ProgressValueElement::ProgressValueElement): (WebCore::RenderProgress::RenderProgress): (WebCore::RenderProgress::~RenderProgress): (WebCore::RenderProgress::layout): (WebCore::RenderProgress::styleDidChange): (WebCore::RenderProgress::updateFromElement): (WebCore::RenderProgress::updateValuePartState): (WebCore::RenderProgress::createStyleForValuePart): (WebCore::RenderProgress::updateAnimationState):
  • rendering/RenderTheme.cpp: (WebCore::RenderTheme::isControlStyled):
  • rendering/RenderProgress.h:
  • rendering/style/RenderStyleConstants.h:
Location:
trunk
Files:
5 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r58224 r58228  
     12010-04-25  yael aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        Allow styling of HTMLProgressElement.
     6        https://bugs.webkit.org/show_bug.cgi?id=37901
     7
     8        Added a test for changing the -webkit-appearance statically and dynamically.
     9
     10        * fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html: Added.
     11        * platform/chromium/test_expectations.txt:
     12        * platform/gtk/Skipped:
     13        * platform/mac/fast/dom/HTMLProgressElement: Added.
     14        * platform/mac/fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element-expected.checksum: Added.
     15        * platform/mac/fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element-expected.png: Added.
     16        * platform/mac/fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element-expected.txt: Added.
     17        * platform/qt/Skipped:
     18        * platform/win/Skipped:
     19
    1202010-04-24  Darin Adler  <darin@apple.com>
    221
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r58159 r58228  
    26332633BUG38227 DEFER : fast/dom/HTMLProgressElement/progress-element.html = MISSING
    26342634BUG38227 DEFER : fast/dom/HTMLProgressElement/set-progress-properties.html = TEXT
     2635BUG38227 SKIP : fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html = FAIL
    26352636
    26362637// WebKit roll 56004 -> 56026
  • trunk/LayoutTests/platform/gtk/Skipped

    r58150 r58228  
    58345834fast/dom/HTMLProgressElement/progress-element.html
    58355835fast/dom/HTMLProgressElement/set-progress-properties.html
     5836fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html
    58365837
    58375838# Needs mock support, and build slave Geolocation service
  • trunk/LayoutTests/platform/qt/Skipped

    r58218 r58228  
    52205220svg/custom/recursive-clippath.svg
    52215221svg/custom/marker-overflow-clip.svg
     5222
     5223# Need new results
     5224fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html
     5225
  • trunk/LayoutTests/platform/win/Skipped

    r58217 r58228  
    831831fast/dom/HTMLProgressElement/progress-element.html
    832832fast/dom/HTMLProgressElement/set-progress-properties.html
     833fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html
    833834
    834835# No Widgets 1.0 support
  • trunk/WebCore/ChangeLog

    r58222 r58228  
     12010-04-25  yael aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        Allow styling of HTMLProgressElement.
     6        https://bugs.webkit.org/show_bug.cgi?id=37901
     7
     8        Added a new pseudo element to represent the value portion of the progress element.
     9        Web developers can style this pseudo element separate from the rest of the progress element.
     10
     11        Test: fast/dom/HTMLProgressElement/progress-bar-value-pseudo-element.html
     12
     13        * css/CSSPrimitiveValueMappings.h:
     14        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
     15        * css/CSSSelector.cpp:
     16        (WebCore::CSSSelector::pseudoId):
     17        (WebCore::nameToPseudoTypeMap):
     18        (WebCore::CSSSelector::extractPseudoType):
     19        * css/CSSSelector.h:
     20        * css/CSSValueKeywords.in:
     21        * platform/ThemeTypes.h:
     22        * rendering/RenderProgress.cpp:
     23        (WebCore::ProgressValueElement::isShadowNode):
     24        (WebCore::ProgressValueElement::shadowParentNode):
     25        (WebCore::ProgressValueElement::ProgressValueElement):
     26        (WebCore::RenderProgress::RenderProgress):
     27        (WebCore::RenderProgress::~RenderProgress):
     28        (WebCore::RenderProgress::layout):
     29        (WebCore::RenderProgress::styleDidChange):
     30        (WebCore::RenderProgress::updateFromElement):
     31        (WebCore::RenderProgress::updateValuePartState):
     32        (WebCore::RenderProgress::createStyleForValuePart):
     33        (WebCore::RenderProgress::updateAnimationState):
     34        * rendering/RenderTheme.cpp:
     35        (WebCore::RenderTheme::isControlStyled):
     36        * rendering/RenderProgress.h:
     37        * rendering/style/RenderStyleConstants.h:
     38
    1392010-04-24  Simon Fraser  <simon.fraser@apple.com>
    240
  • trunk/WebCore/css/CSSPrimitiveValueMappings.h

    r55980 r58228  
    277277            break;
    278278        case ProgressBarPart:
    279 #if ENABLE(PROGRESS_BAR)
     279#if ENABLE(PROGRESS_TAG)
    280280            m_value.ident = CSSValueProgressBar;
     281#endif
     282            break;
     283        case ProgressBarValuePart:
     284#if ENABLE(PROGRESS_TAG)
     285            m_value.ident = CSSValueProgressBarValue;
    281286#endif
    282287            break;
  • trunk/WebCore/css/CSSSelector.cpp

    r57810 r58228  
    144144    case PseudoOuterSpinButton:
    145145        return OUTER_SPIN_BUTTON;
     146    case PseudoProgressBarValue:
     147#if ENABLE(PROGRESS_TAG)
     148        return PROGRESS_BAR_VALUE;
     149#else
     150        ASSERT_NOT_REACHED();
     151        return NOPSEUDO;
     152#endif
    146153    case PseudoInputListButton:
    147154#if ENABLE(DATALIST)
     
    268275    DEFINE_STATIC_LOCAL(AtomicString, optional, ("optional"));
    269276    DEFINE_STATIC_LOCAL(AtomicString, outerSpinButton, ("-webkit-outer-spin-button"));
    270 #if ENABLE(PROGRESS_BAR)
    271     DEFINE_STATIC_LOCAL(AtomicString, progressBar, ("-webkit-progress-bar"));
     277#if ENABLE(PROGRESS_TAG)
     278    DEFINE_STATIC_LOCAL(AtomicString, progressBarValue, ("-webkit-progress-bar-value"));
    272279#endif
    273280    DEFINE_STATIC_LOCAL(AtomicString, required, ("required"));
     
    361368        nameToPseudoType->set(nthLastOfType.impl(), CSSSelector::PseudoNthLastOfType);
    362369        nameToPseudoType->set(outerSpinButton.impl(), CSSSelector::PseudoOuterSpinButton);
     370#if ENABLE(PROGRESS_TAG)
     371        nameToPseudoType->set(progressBarValue.impl(), CSSSelector::PseudoProgressBarValue);
     372#endif
    363373        nameToPseudoType->set(root.impl(), CSSSelector::PseudoRoot);
    364374        nameToPseudoType->set(windowInactive.impl(), CSSSelector::PseudoWindowInactive);
     
    440450    case PseudoMediaControlsVolumeSliderContainer:
    441451    case PseudoOuterSpinButton:
     452    case PseudoProgressBarValue:
    442453    case PseudoResizer:
    443454    case PseudoScrollbar:
  • trunk/WebCore/css/CSSSelector.h

    r57809 r58228  
    188188            PseudoInnerSpinButton,
    189189            PseudoOuterSpinButton,
     190            PseudoProgressBarValue,
    190191        };
    191192
  • trunk/WebCore/css/CSSValueKeywords.in

    r57319 r58228  
    584584outer-spin-button
    585585progress-bar
     586progress-bar-value
    586587slider-horizontal
    587588slider-vertical
  • trunk/WebCore/platform/ThemeTypes.h

    r55980 r58228  
    5353    MediaSliderPart, MediaSliderThumbPart, MediaVolumeSliderContainerPart, MediaVolumeSliderPart, MediaVolumeSliderThumbPart,
    5454    MediaControlsBackgroundPart, MediaCurrentTimePart, MediaTimeRemainingPart,
    55     MenulistPart, MenulistButtonPart, MenulistTextPart, MenulistTextFieldPart, OuterSpinButtonPart, ProgressBarPart,
     55    MenulistPart, MenulistButtonPart, MenulistTextPart, MenulistTextFieldPart, OuterSpinButtonPart, ProgressBarPart, ProgressBarValuePart,
    5656    SliderHorizontalPart, SliderVerticalPart, SliderThumbHorizontalPart,
    5757    SliderThumbVerticalPart, CaretPart, SearchFieldPart, SearchFieldDecorationPart,
  • trunk/WebCore/rendering/RenderProgress.cpp

    r57494 r58228  
    2424#include "RenderProgress.h"
    2525
     26#include "HTMLDivElement.h"
    2627#include "HTMLProgressElement.h"
    2728#include "RenderTheme.h"
     29#include "RenderView.h"
    2830#include <wtf/CurrentTime.h>
     31#include <wtf/RefPtr.h>
    2932
    3033using namespace std;
     
    3336
    3437using namespace HTMLNames;
     38
     39class ProgressValueElement : public HTMLDivElement {
     40public:
     41    ProgressValueElement(Document*, Node* shadowParent);
     42
     43private:       
     44    virtual bool isShadowNode() const { return true; }
     45    virtual Node* shadowParentNode() { return m_shadowParent; }
     46
     47    Node* m_shadowParent;
     48};
     49
     50ProgressValueElement::ProgressValueElement(Document* document, Node* shadowParent)
     51: HTMLDivElement(divTag, document)
     52, m_shadowParent(shadowParent)
     53{
     54}
    3555
    3656RenderProgress::RenderProgress(HTMLProgressElement* element)
     
    4262    , m_animating(false)
    4363    , m_animationTimer(this, &RenderProgress::animationTimerFired)
    44 {
     64    , m_valuePart(0)
     65{
     66}
     67
     68RenderProgress::~RenderProgress()
     69{
     70    if (m_valuePart)
     71        m_valuePart->detach();
    4572}
    4673
     
    5077
    5178    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
     79
     80    IntSize oldSize = size();
    5281
    5382    calcWidth();
    5483    calcHeight();
    55 
    56     m_overflow.clear();
     84    if (m_valuePart) {
     85        IntRect valuePartRect(borderLeft() + paddingLeft(), borderTop() + paddingTop(), lround((width() - borderLeft() - paddingLeft() - borderRight() - paddingRight()) * position()), height()  - borderTop() - paddingTop() - borderBottom() - paddingBottom());
     86        if (style()->direction() == RTL)
     87            valuePartRect.setX(width() - borderRight() - paddingRight() - valuePartRect.width());
     88        toRenderBox(m_valuePart->renderer())->setFrameRect(valuePartRect);
     89
     90        if (oldSize != size())
     91            m_valuePart->renderer()->setChildNeedsLayout(true, false);
     92       
     93        LayoutStateMaintainer statePusher(view(), this, size());
     94       
     95        IntRect oldRect = toRenderBox(m_valuePart->renderer())->frameRect();
     96       
     97        m_valuePart->renderer()->layoutIfNeeded();
     98
     99        toRenderBox(m_valuePart->renderer())->setFrameRect(valuePartRect);
     100        if (m_valuePart->renderer()->checkForRepaintDuringLayout())
     101            m_valuePart->renderer()->repaintDuringLayoutIfMoved(oldRect);
     102       
     103        statePusher.pop();
     104        addOverflowFromChild(toRenderBox(m_valuePart->renderer()));
     105    }
    57106
    58107    updateAnimationState();
     
    63112}
    64113
     114void RenderProgress::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
     115{
     116    RenderBlock::styleDidChange(diff, oldStyle);
     117
     118    updateValuePartState();
     119}
     120   
    65121void RenderProgress::updateFromElement()
    66122{
     
    72128    updateAnimationState();
    73129
     130    updateValuePartState();
     131   
    74132    repaint();
     133}
     134
     135void RenderProgress::updateValuePartState()
     136{
     137    bool needLayout = !style()->hasAppearance() || m_valuePart;
     138    if (!style()->hasAppearance() && !m_valuePart) {
     139        m_valuePart = new ProgressValueElement(document(), node());
     140        RefPtr<RenderStyle> styleForValuePart = createStyleForValuePart(style());
     141        m_valuePart->setRenderer(m_valuePart->createRenderer(renderArena(), styleForValuePart.get()));
     142        m_valuePart->renderer()->setStyle(styleForValuePart.release());
     143        m_valuePart->setAttached();
     144        m_valuePart->setInDocument(true);
     145        addChild(m_valuePart->renderer());
     146    } else if (style()->hasAppearance() && m_valuePart) {
     147        m_valuePart->detach();
     148        m_valuePart = 0;
     149    }
     150    if (needLayout)
     151        setNeedsLayout(true);
     152}
     153
     154PassRefPtr<RenderStyle> RenderProgress::createStyleForValuePart(RenderStyle* parentStyle)
     155{
     156    RefPtr<RenderStyle> styleForValuePart;
     157    RenderStyle* pseudoStyle = getCachedPseudoStyle(PROGRESS_BAR_VALUE);
     158    if (pseudoStyle)
     159        styleForValuePart = RenderStyle::clone(pseudoStyle);
     160    else
     161        styleForValuePart = RenderStyle::create();
     162   
     163    if (parentStyle)
     164        styleForValuePart->inheritFrom(parentStyle);
     165    styleForValuePart->setDisplay(BLOCK);
     166    styleForValuePart->setAppearance(ProgressBarValuePart);
     167    return styleForValuePart.release();
    75168}
    76169
     
    100193    m_animationRepeatInterval = theme()->animationRepeatIntervalForProgressBar(this);
    101194
    102     bool animating = m_animationDuration > 0;
     195    bool animating = style()->hasAppearance() && m_animationDuration > 0;
    103196    if (animating == m_animating)
    104197        return;
  • trunk/WebCore/rendering/RenderProgress.h

    r57494 r58228  
    2828
    2929class HTMLProgressElement;
     30class ProgressValueElement;
    3031
    3132class RenderProgress : public RenderBlock {
    3233public:
    3334    RenderProgress(HTMLProgressElement*);
     35    virtual ~RenderProgress();
     36
    3437    double position() { return m_position; }
    3538    double animationProgress();
     
    4346    virtual void updateFromElement();
    4447    virtual void paint(PaintInfo&, int tx, int ty);
     48    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
    4549
    4650    void animationTimerFired(Timer<RenderProgress>*);
    4751    void updateAnimationState();
     52    void updateValuePartState();
     53    PassRefPtr<RenderStyle> createStyleForValuePart(RenderStyle*);
    4854
    4955    double m_position;
     
    5359    bool m_animating;
    5460    Timer<RenderProgress> m_animationTimer;
     61    RefPtr<ProgressValueElement> m_valuePart;
    5562};
    5663
  • trunk/WebCore/rendering/RenderTheme.cpp

    r56850 r58228  
    614614        case ListboxPart:
    615615        case MenulistPart:
     616        case ProgressBarPart:
    616617        // FIXME: Uncomment this when making search fields style-able.
    617618        // case SearchFieldPart:
  • trunk/WebCore/rendering/style/RenderStyleConstants.h

    r57292 r58228  
    7575    MEDIA_CONTROLS_RETURN_TO_REALTIME_BUTTON, MEDIA_CONTROLS_TOGGLE_CLOSED_CAPTIONS_BUTTON,
    7676    MEDIA_CONTROLS_STATUS_DISPLAY, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
    77     INPUT_LIST_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK,
     77    INPUT_LIST_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK, PROGRESS_BAR_VALUE,
    7878
    7979    AFTER_LAST_INTERNAL_PSEUDOID,
Note: See TracChangeset for help on using the changeset viewer.