summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/HTMLMarqueeElement.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/html/HTMLMarqueeElement.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/html/HTMLMarqueeElement.cpp')
-rw-r--r--Source/WebCore/html/HTMLMarqueeElement.cpp65
1 files changed, 28 insertions, 37 deletions
diff --git a/Source/WebCore/html/HTMLMarqueeElement.cpp b/Source/WebCore/html/HTMLMarqueeElement.cpp
index 602a6fba4..baf71c2fa 100644
--- a/Source/WebCore/html/HTMLMarqueeElement.cpp
+++ b/Source/WebCore/html/HTMLMarqueeElement.cpp
@@ -28,6 +28,7 @@
#include "CSSValueKeywords.h"
#include "ExceptionCode.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include "RenderLayer.h"
#include "RenderMarquee.h"
@@ -42,20 +43,20 @@ inline HTMLMarqueeElement::HTMLMarqueeElement(const QualifiedName& tagName, Docu
ASSERT(hasTagName(marqueeTag));
}
-PassRefPtr<HTMLMarqueeElement> HTMLMarqueeElement::create(const QualifiedName& tagName, Document& document)
+Ref<HTMLMarqueeElement> HTMLMarqueeElement::create(const QualifiedName& tagName, Document& document)
{
- RefPtr<HTMLMarqueeElement> marqueeElement(adoptRef(new HTMLMarqueeElement(tagName, document)));
+ auto marqueeElement = adoptRef(*new HTMLMarqueeElement(tagName, document));
marqueeElement->suspendIfNeeded();
- return marqueeElement.release();
+ return marqueeElement;
}
int HTMLMarqueeElement::minimumDelay() const
{
- if (fastGetAttribute(truespeedAttr).isEmpty()) {
+ if (!hasAttributeWithoutSynchronization(truespeedAttr)) {
// WinIE uses 60ms as the minimum delay by default.
return 60;
}
- return 0;
+ return 16; // Don't allow timers at < 16ms intervals to avoid CPU hogging: webkit.org/b/160609
}
bool HTMLMarqueeElement::isPresentationAttribute(const QualifiedName& name) const
@@ -94,7 +95,7 @@ void HTMLMarqueeElement::collectStyleForPresentationAttribute(const QualifiedNam
addHTMLLengthToStyle(style, CSSPropertyWebkitMarqueeSpeed, value);
} else if (name == loopAttr) {
if (!value.isEmpty()) {
- if (value == "-1" || equalIgnoringCase(value, "infinite"))
+ if (value == "-1" || equalLettersIgnoringASCIICase(value, "infinite"))
addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarqueeRepetition, CSSValueInfinite);
else
addHTMLLengthToStyle(style, CSSPropertyWebkitMarqueeRepetition, value);
@@ -111,62 +112,52 @@ void HTMLMarqueeElement::collectStyleForPresentationAttribute(const QualifiedNam
void HTMLMarqueeElement::start()
{
- if (RenderMarquee* marqueeRenderer = renderMarquee())
- marqueeRenderer->start();
+ if (auto* renderer = renderMarquee())
+ renderer->start();
}
void HTMLMarqueeElement::stop()
{
- if (RenderMarquee* marqueeRenderer = renderMarquee())
- marqueeRenderer->stop();
+ if (auto* renderer = renderMarquee())
+ renderer->stop();
}
-int HTMLMarqueeElement::scrollAmount() const
+unsigned HTMLMarqueeElement::scrollAmount() const
{
- bool ok;
- int scrollAmount = fastGetAttribute(scrollamountAttr).toInt(&ok);
- return ok && scrollAmount >= 0 ? scrollAmount : RenderStyle::initialMarqueeIncrement().intValue();
+ return limitToOnlyHTMLNonNegative(attributeWithoutSynchronization(scrollamountAttr), RenderStyle::initialMarqueeIncrement().intValue());
}
-void HTMLMarqueeElement::setScrollAmount(int scrollAmount, ExceptionCode& ec)
+void HTMLMarqueeElement::setScrollAmount(unsigned scrollAmount)
{
- if (scrollAmount < 0)
- ec = INDEX_SIZE_ERR;
- else
- setIntegralAttribute(scrollamountAttr, scrollAmount);
+ setUnsignedIntegralAttribute(scrollamountAttr, limitToOnlyHTMLNonNegative(scrollAmount, RenderStyle::initialMarqueeIncrement().intValue()));
}
-int HTMLMarqueeElement::scrollDelay() const
+unsigned HTMLMarqueeElement::scrollDelay() const
{
- bool ok;
- int scrollDelay = fastGetAttribute(scrolldelayAttr).toInt(&ok);
- return ok && scrollDelay >= 0 ? scrollDelay : RenderStyle::initialMarqueeSpeed();
+ return limitToOnlyHTMLNonNegative(attributeWithoutSynchronization(scrolldelayAttr), RenderStyle::initialMarqueeSpeed());
}
-void HTMLMarqueeElement::setScrollDelay(int scrollDelay, ExceptionCode& ec)
+void HTMLMarqueeElement::setScrollDelay(unsigned scrollDelay)
{
- if (scrollDelay < 0)
- ec = INDEX_SIZE_ERR;
- else
- setIntegralAttribute(scrolldelayAttr, scrollDelay);
+ setUnsignedIntegralAttribute(scrolldelayAttr, limitToOnlyHTMLNonNegative(scrollDelay, RenderStyle::initialMarqueeSpeed()));
}
int HTMLMarqueeElement::loop() const
{
bool ok;
- int loopValue = fastGetAttribute(loopAttr).toInt(&ok);
+ int loopValue = attributeWithoutSynchronization(loopAttr).toInt(&ok);
return ok && loopValue > 0 ? loopValue : -1;
}
-void HTMLMarqueeElement::setLoop(int loop, ExceptionCode& ec)
+ExceptionOr<void> HTMLMarqueeElement::setLoop(int loop)
{
if (loop <= 0 && loop != -1)
- ec = INDEX_SIZE_ERR;
- else
- setIntegralAttribute(loopAttr, loop);
+ return Exception { INDEX_SIZE_ERR };
+ setIntegralAttribute(loopAttr, loop);
+ return { };
}
-bool HTMLMarqueeElement::canSuspend() const
+bool HTMLMarqueeElement::canSuspendForDocumentSuspension() const
{
return true;
}
@@ -185,9 +176,9 @@ void HTMLMarqueeElement::resume()
RenderMarquee* HTMLMarqueeElement::renderMarquee() const
{
- if (renderer() && renderer()->hasLayer())
- return renderBoxModelObject()->layer()->marquee();
- return 0;
+ if (!renderer() || !renderer()->hasLayer())
+ return nullptr;
+ return renderBoxModelObject()->layer()->marquee();
}
} // namespace WebCore