summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLProgressElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/HTMLProgressElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLProgressElement.cpp61
1 files changed, 24 insertions, 37 deletions
diff --git a/Source/WebCore/html/HTMLProgressElement.cpp b/Source/WebCore/html/HTMLProgressElement.cpp
index c877fbe05..8b40e1dc2 100644
--- a/Source/WebCore/html/HTMLProgressElement.cpp
+++ b/Source/WebCore/html/HTMLProgressElement.cpp
@@ -19,13 +19,9 @@
*/
#include "config.h"
-#if ENABLE(PROGRESS_ELEMENT)
#include "HTMLProgressElement.h"
-#include "Attribute.h"
#include "ElementIterator.h"
-#include "EventNames.h"
-#include "ExceptionCode.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "ProgressShadowElement.h"
@@ -51,19 +47,19 @@ HTMLProgressElement::~HTMLProgressElement()
{
}
-PassRefPtr<HTMLProgressElement> HTMLProgressElement::create(const QualifiedName& tagName, Document& document)
+Ref<HTMLProgressElement> HTMLProgressElement::create(const QualifiedName& tagName, Document& document)
{
- RefPtr<HTMLProgressElement> progress = adoptRef(new HTMLProgressElement(tagName, document));
+ Ref<HTMLProgressElement> progress = adoptRef(*new HTMLProgressElement(tagName, document));
progress->ensureUserAgentShadowRoot();
- return progress.release();
+ return progress;
}
-RenderPtr<RenderElement> HTMLProgressElement::createElementRenderer(PassRef<RenderStyle> style)
+RenderPtr<RenderElement> HTMLProgressElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- if (!style.get().hasAppearance() || hasAuthorShadowRoot())
- return RenderElement::createFor(*this, std::move(style));
+ if (!style.hasAppearance())
+ return RenderElement::createFor(*this, WTFMove(style));
- return createRenderer<RenderProgress>(*this, std::move(style));
+ return createRenderer<RenderProgress>(*this, WTFMove(style));
}
bool HTMLProgressElement::childShouldCreateRenderer(const Node& child) const
@@ -73,9 +69,9 @@ bool HTMLProgressElement::childShouldCreateRenderer(const Node& child) const
RenderProgress* HTMLProgressElement::renderProgress() const
{
- if (renderer() && renderer()->isProgress())
- return toRenderProgress(renderer());
- return toRenderProgress(descendantsOfType<Element>(*userAgentShadowRoot()).first()->renderer());
+ if (is<RenderProgress>(renderer()))
+ return downcast<RenderProgress>(renderer());
+ return downcast<RenderProgress>(descendantsOfType<Element>(*userAgentShadowRoot()).first()->renderer());
}
void HTMLProgressElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
@@ -96,32 +92,24 @@ void HTMLProgressElement::didAttachRenderers()
double HTMLProgressElement::value() const
{
- double value = parseToDoubleForNumberType(fastGetAttribute(valueAttr));
+ double value = parseToDoubleForNumberType(attributeWithoutSynchronization(valueAttr));
return !std::isfinite(value) || value < 0 ? 0 : std::min(value, max());
}
-void HTMLProgressElement::setValue(double value, ExceptionCode& ec)
+void HTMLProgressElement::setValue(double value)
{
- if (!std::isfinite(value)) {
- ec = NOT_SUPPORTED_ERR;
- return;
- }
- setAttribute(valueAttr, AtomicString::number(value >= 0 ? value : 0));
+ setAttributeWithoutSynchronization(valueAttr, AtomicString::number(value >= 0 ? value : 0));
}
double HTMLProgressElement::max() const
{
- double max = parseToDoubleForNumberType(getAttribute(maxAttr));
+ double max = parseToDoubleForNumberType(attributeWithoutSynchronization(maxAttr));
return !std::isfinite(max) || max <= 0 ? 1 : max;
}
-void HTMLProgressElement::setMax(double max, ExceptionCode& ec)
+void HTMLProgressElement::setMax(double max)
{
- if (!std::isfinite(max)) {
- ec = NOT_SUPPORTED_ERR;
- return;
- }
- setAttribute(maxAttr, AtomicString::number(max > 0 ? max : 1));
+ setAttributeWithoutSynchronization(maxAttr, AtomicString::number(max > 0 ? max : 1));
}
double HTMLProgressElement::position() const
@@ -133,7 +121,7 @@ double HTMLProgressElement::position() const
bool HTMLProgressElement::isDeterminate() const
{
- return fastHasAttribute(valueAttr);
+ return hasAttributeWithoutSynchronization(valueAttr);
}
void HTMLProgressElement::didElementStateChange()
@@ -143,7 +131,7 @@ void HTMLProgressElement::didElementStateChange()
bool wasDeterminate = render->isDeterminate();
render->updateFromElement();
if (wasDeterminate != isDeterminate())
- didAffectSelector(AffectedSelectorIndeterminate);
+ invalidateStyleForSubtree();
}
}
@@ -151,16 +139,16 @@ void HTMLProgressElement::didAddUserAgentShadowRoot(ShadowRoot* root)
{
ASSERT(!m_value);
- RefPtr<ProgressInnerElement> inner = ProgressInnerElement::create(document());
+ auto inner = ProgressInnerElement::create(document());
root->appendChild(inner);
- RefPtr<ProgressBarElement> bar = ProgressBarElement::create(document());
- RefPtr<ProgressValueElement> value = ProgressValueElement::create(document());
- m_value = value.get();
+ auto bar = ProgressBarElement::create(document());
+ auto value = ProgressValueElement::create(document());
+ m_value = value.ptr();
m_value->setWidthPercentage(HTMLProgressElement::IndeterminatePosition * 100);
- bar->appendChild(m_value, ASSERT_NO_EXCEPTION);
+ bar->appendChild(value);
- inner->appendChild(bar, ASSERT_NO_EXCEPTION);
+ inner->appendChild(bar);
}
bool HTMLProgressElement::shouldAppearIndeterminate() const
@@ -169,4 +157,3 @@ bool HTMLProgressElement::shouldAppearIndeterminate() const
}
} // namespace
-#endif