Commit 45c6a5f4 authored by morrita@google.com's avatar morrita@google.com

2011-01-27 MORITA Hajime <morrita@google.com>

        Reviewed by Dimitri Glazkov.

        Convert <progress> shadow DOM to a DOM-based shadow.
        https://bugs.webkit.org/show_bug.cgi?id=50660

        * Removed RenderProgress::m_valuePart, moved the shadow node
          to the shadow root of HTMLProgressElement.
        * Removed hard-coded pseudo ID for -webkit-progress-bar-value.
          ProgressBarValueElement is defined only for overriding
          shadowPseudoId().

        No new tests. No behavioral change.

        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::pseudoId):
        (WebCore::nameToPseudoTypeMap):
        (WebCore::CSSSelector::extractPseudoType):
        * css/CSSSelector.h:
        * html/HTMLProgressElement.cpp:
        (WebCore::ProgressBarValueElement::ProgressBarValueElement):
        (WebCore::ProgressBarValueElement::shadowPseudoId):
        (WebCore::ProgressBarValueElement::create):
        (WebCore::HTMLProgressElement::parseMappedAttribute):
        (WebCore::HTMLProgressElement::attach):
        (WebCore::HTMLProgressElement::valuePart):
        (WebCore::HTMLProgressElement::didElementStateChange):
        (WebCore::HTMLProgressElement::createShadowSubtreeIfNeeded):
        * html/HTMLProgressElement.h:
        * rendering/RenderProgress.cpp:
        (WebCore::RenderProgress::~RenderProgress):
        (WebCore::RenderProgress::updateFromElement):
        (WebCore::RenderProgress::layoutParts):
        (WebCore::RenderProgress::shouldHaveParts):
        (WebCore::RenderProgress::valuePart):
        * rendering/RenderProgress.h:
        * rendering/style/RenderStyleConstants.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77107 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 33875137
2011-01-27 MORITA Hajime <morrita@google.com>
Reviewed by Dimitri Glazkov.
Convert <progress> shadow DOM to a DOM-based shadow.
https://bugs.webkit.org/show_bug.cgi?id=50660
* Removed RenderProgress::m_valuePart, moved the shadow node
to the shadow root of HTMLProgressElement.
* Removed hard-coded pseudo ID for -webkit-progress-bar-value.
ProgressBarValueElement is defined only for overriding
shadowPseudoId().
No new tests. No behavioral change.
* css/CSSSelector.cpp:
(WebCore::CSSSelector::pseudoId):
(WebCore::nameToPseudoTypeMap):
(WebCore::CSSSelector::extractPseudoType):
* css/CSSSelector.h:
* html/HTMLProgressElement.cpp:
(WebCore::ProgressBarValueElement::ProgressBarValueElement):
(WebCore::ProgressBarValueElement::shadowPseudoId):
(WebCore::ProgressBarValueElement::create):
(WebCore::HTMLProgressElement::parseMappedAttribute):
(WebCore::HTMLProgressElement::attach):
(WebCore::HTMLProgressElement::valuePart):
(WebCore::HTMLProgressElement::didElementStateChange):
(WebCore::HTMLProgressElement::createShadowSubtreeIfNeeded):
* html/HTMLProgressElement.h:
* rendering/RenderProgress.cpp:
(WebCore::RenderProgress::~RenderProgress):
(WebCore::RenderProgress::updateFromElement):
(WebCore::RenderProgress::layoutParts):
(WebCore::RenderProgress::shouldHaveParts):
(WebCore::RenderProgress::valuePart):
* rendering/RenderProgress.h:
* rendering/style/RenderStyleConstants.h:
2011-01-30 Simon Fraser <simon.fraser@apple.com>
Reviewed by Ariya Hidayat.
......@@ -168,14 +168,6 @@ PseudoId CSSSelector::pseudoId(PseudoType type)
return INNER_SPIN_BUTTON;
case PseudoOuterSpinButton:
return OUTER_SPIN_BUTTON;
case PseudoProgressBarValue:
#if ENABLE(PROGRESS_TAG)
return PROGRESS_BAR_VALUE;
#else
ASSERT_NOT_REACHED();
return NOPSEUDO;
#endif
#if ENABLE(METER_TAG)
case PseudoMeterHorizontalBar:
return METER_HORIZONTAL_BAR;
......@@ -335,10 +327,6 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
DEFINE_STATIC_LOCAL(AtomicString, onlyOfType, ("only-of-type"));
DEFINE_STATIC_LOCAL(AtomicString, optional, ("optional"));
DEFINE_STATIC_LOCAL(AtomicString, outerSpinButton, ("-webkit-outer-spin-button"));
#if ENABLE(PROGRESS_TAG)
DEFINE_STATIC_LOCAL(AtomicString, progressBarValue, ("-webkit-progress-bar-value"));
#endif
#if ENABLE(METER_TAG)
DEFINE_STATIC_LOCAL(AtomicString, meterHorizontalBar, ("-webkit-meter-horizontal-bar"));
DEFINE_STATIC_LOCAL(AtomicString, meterHorizontalOptimumValue, ("-webkit-meter-horizontal-optimum-value"));
......@@ -442,9 +430,6 @@ static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap(
nameToPseudoType->set(nthLastChild.impl(), CSSSelector::PseudoNthLastChild);
nameToPseudoType->set(nthLastOfType.impl(), CSSSelector::PseudoNthLastOfType);
nameToPseudoType->set(outerSpinButton.impl(), CSSSelector::PseudoOuterSpinButton);
#if ENABLE(PROGRESS_TAG)
nameToPseudoType->set(progressBarValue.impl(), CSSSelector::PseudoProgressBarValue);
#endif
#if ENABLE(METER_TAG)
nameToPseudoType->set(meterHorizontalBar.impl(), CSSSelector::PseudoMeterHorizontalBar);
nameToPseudoType->set(meterHorizontalOptimumValue.impl(), CSSSelector::PseudoMeterHorizontalOptimum);
......@@ -544,7 +529,6 @@ void CSSSelector::extractPseudoType() const
case PseudoMeterVerticalSuboptimal:
case PseudoMeterVerticalEvenLessGood:
case PseudoOuterSpinButton:
case PseudoProgressBarValue:
case PseudoResizer:
case PseudoScrollbar:
case PseudoScrollbarCorner:
......
......@@ -195,7 +195,6 @@ namespace WebCore {
#endif
PseudoInnerSpinButton,
PseudoOuterSpinButton,
PseudoProgressBarValue,
PseudoLeftPage,
PseudoRightPage,
PseudoFirstPage,
......
......@@ -30,12 +30,33 @@
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "RenderProgress.h"
#include "ShadowElement.h"
#include <wtf/StdLibExtras.h>
namespace WebCore {
using namespace HTMLNames;
class ProgressBarValueElement : public ShadowBlockElement {
public:
ProgressBarValueElement(HTMLElement* shadowParent)
: ShadowBlockElement(shadowParent)
{
}
virtual const AtomicString& shadowPseudoId() const
{
DEFINE_STATIC_LOCAL(AtomicString, pseudId, ("-webkit-progress-bar-value"));
return pseudId;
}
static PassRefPtr<ProgressBarValueElement> create(HTMLElement* shadowParent)
{
return adoptRef(new ProgressBarValueElement(shadowParent));
}
};
HTMLProgressElement::HTMLProgressElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
: HTMLFormControlElement(tagName, document, form)
{
......@@ -60,21 +81,19 @@ const AtomicString& HTMLProgressElement::formControlType() const
void HTMLProgressElement::parseMappedAttribute(Attribute* attribute)
{
if (attribute->name() == valueAttr) {
if (renderer())
renderer()->updateFromElement();
} else if (attribute->name() == maxAttr) {
if (renderer())
renderer()->updateFromElement();
} else
if (attribute->name() == valueAttr)
didElementStateChange();
else if (attribute->name() == maxAttr)
didElementStateChange();
else
HTMLFormControlElement::parseMappedAttribute(attribute);
}
void HTMLProgressElement::attach()
{
createShadowSubtreeIfNeeded();
HTMLFormControlElement::attach();
if (renderer())
renderer()->updateFromElement();
didElementStateChange();
}
double HTMLProgressElement::value() const
......@@ -121,5 +140,23 @@ double HTMLProgressElement::position() const
return value() / max();
}
ShadowBlockElement* HTMLProgressElement::valuePart()
{
return static_cast<ShadowBlockElement*>(shadowRoot());
}
void HTMLProgressElement::didElementStateChange()
{
if (renderer())
renderer()->updateFromElement();
}
void HTMLProgressElement::createShadowSubtreeIfNeeded()
{
if (shadowRoot())
return;
setShadowRoot(ProgressBarValueElement::create(this).get());
}
} // namespace
#endif
......@@ -26,6 +26,8 @@
namespace WebCore {
class ShadowBlockElement;
class HTMLProgressElement : public HTMLFormControlElement {
public:
static PassRefPtr<HTMLProgressElement> create(const QualifiedName&, Document*, HTMLFormElement*);
......@@ -38,6 +40,7 @@ public:
double position() const;
ShadowBlockElement* valuePart();
private:
HTMLProgressElement(const QualifiedName&, Document*, HTMLFormElement*);
......@@ -50,6 +53,9 @@ private:
virtual void parseMappedAttribute(Attribute*);
virtual void attach();
void didElementStateChange();
void createShadowSubtreeIfNeeded();
};
} // namespace
......
......@@ -49,22 +49,14 @@ RenderProgress::RenderProgress(HTMLProgressElement* element)
RenderProgress::~RenderProgress()
{
if (m_valuePart)
m_valuePart->detach();
}
void RenderProgress::updateFromElement()
{
if (!m_valuePart) {
m_valuePart = ShadowBlockElement::createForPart(static_cast<HTMLElement*>(node()), PROGRESS_BAR_VALUE);
if (m_valuePart->renderer())
addChild(m_valuePart->renderer());
}
if (shouldHaveParts())
style()->setAppearance(NoControlPart);
else if (m_valuePart->renderer())
m_valuePart->renderer()->style()->setVisibility(HIDDEN);
else if (valuePart()->renderer())
valuePart()->renderer()->style()->setVisibility(HIDDEN);
HTMLProgressElement* element = progressElement();
if (m_position == element->position())
......@@ -102,7 +94,7 @@ void RenderProgress::paint(PaintInfo& paintInfo, int tx, int ty)
void RenderProgress::layoutParts()
{
m_valuePart->layoutAsPart(valuePartRect());
valuePart()->layoutAsPart(valuePartRect());
updateAnimationState();
}
......@@ -110,7 +102,7 @@ bool RenderProgress::shouldHaveParts() const
{
if (!style()->hasAppearance())
return true;
if (ShadowBlockElement::partShouldHaveStyle(this, PROGRESS_BAR_VALUE))
if (!(valuePart()->renderer() && valuePart()->renderer()->style()->hasAppearance()))
return true;
return false;
}
......@@ -145,6 +137,11 @@ HTMLProgressElement* RenderProgress::progressElement() const
return static_cast<HTMLProgressElement*>(node());
}
ShadowBlockElement* RenderProgress::valuePart() const
{
return progressElement()->valuePart();
}
} // namespace WebCore
#endif
......@@ -57,13 +57,14 @@ private:
void animationTimerFired(Timer<RenderProgress>*);
void updateAnimationState();
ShadowBlockElement* valuePart() const;
double m_position;
double m_animationStartTime;
double m_animationRepeatInterval;
double m_animationDuration;
bool m_animating;
Timer<RenderProgress> m_animationTimer;
RefPtr<ShadowBlockElement> m_valuePart;
};
inline RenderProgress* toRenderProgress(RenderObject* object)
......
......@@ -71,7 +71,7 @@ enum PseudoId {
SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL,
MEDIA_CONTROLS_TIMELINE_CONTAINER, MEDIA_CONTROLS_VOLUME_SLIDER_CONTAINER, MEDIA_CONTROLS_CURRENT_TIME_DISPLAY, MEDIA_CONTROLS_TIME_REMAINING_DISPLAY,
MEDIA_CONTROLS_STATUS_DISPLAY, SCROLLBAR_THUMB, SCROLLBAR_BUTTON, SCROLLBAR_TRACK, SCROLLBAR_TRACK_PIECE, SCROLLBAR_CORNER, RESIZER,
INPUT_LIST_BUTTON, INPUT_SPEECH_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK, PROGRESS_BAR_VALUE,
INPUT_LIST_BUTTON, INPUT_SPEECH_BUTTON, INNER_SPIN_BUTTON, OUTER_SPIN_BUTTON, VISITED_LINK,
METER_HORIZONTAL_BAR, METER_HORIZONTAL_OPTIMUM, METER_HORIZONTAL_SUBOPTIMAL, METER_HORIZONTAL_EVEN_LESS_GOOD,
METER_VERTICAL_BAR, METER_VERTICAL_OPTIMUM, METER_VERTICAL_SUBOPTIMAL, METER_VERTICAL_EVEN_LESS_GOOD,
AFTER_LAST_INTERNAL_PSEUDOID,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment