Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: third_party/WebKit/Source/core/html/HTMLMarqueeElement.cpp

Issue 2554573005: Use presentation attributes in HTMLMarquee (Closed)
Patch Set: Fix call to isPresentationAttribute Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMarqueeElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMarqueeElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMarqueeElement.cpp b/third_party/WebKit/Source/core/html/HTMLMarqueeElement.cpp
index 5602816a2f5603385459b1bff2815c2607ad36da..394dc7651c3a63a38db1f2e89f7037e9a96900f2 100644
--- a/third_party/WebKit/Source/core/html/HTMLMarqueeElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMarqueeElement.cpp
@@ -39,29 +39,12 @@
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLContentElement.h"
-#include "core/html/HTMLDimension.h"
#include "core/html/HTMLDivElement.h"
#include "core/html/HTMLStyleElement.h"
#include <cstdlib>
namespace blink {
-namespace {
-
-String convertHTMLLengthToCSSLength(const String& htmlLength) {
- HTMLDimension dimension;
- parseDimensionValue(htmlLength, dimension);
- if (dimension.isRelative())
- return String();
- CSSPrimitiveValue* cssValue = CSSPrimitiveValue::create(
- dimension.value(), dimension.isPercentage()
- ? CSSPrimitiveValue::UnitType::Percentage
- : CSSPrimitiveValue::UnitType::Pixels);
- return cssValue->customCSSText();
-}
-
-} // namespace
-
inline HTMLMarqueeElement::HTMLMarqueeElement(Document& document)
: HTMLElement(HTMLNames::marqueeTag, document) {
UseCounter::count(document, UseCounter::HTMLMarqueeElement);
@@ -76,8 +59,8 @@ HTMLMarqueeElement* HTMLMarqueeElement::create(Document& document) {
void HTMLMarqueeElement::didAddUserAgentShadowRoot(ShadowRoot& shadowRoot) {
Element* style = HTMLStyleElement::create(document(), false);
style->setTextContent(
- ":host { display: inline-block; width: -webkit-fill-available; overflow: "
- "hidden; text-align: initial; white-space: nowrap; }"
+ ":host { display: inline-block; overflow: hidden;"
+ "text-align: initial; white-space: nowrap; }"
":host([direction=\"up\"]), :host([direction=\"down\"]) { overflow: "
"initial; overflow-y: hidden; white-space: initial; }"
":host > div { will-change: transform; }");
@@ -90,31 +73,12 @@ void HTMLMarqueeElement::didAddUserAgentShadowRoot(ShadowRoot& shadowRoot) {
m_mover = mover;
}
-void HTMLMarqueeElement::attributeChanged(const QualifiedName& name,
- const AtomicString& oldValue,
- const AtomicString& newValue,
- AttributeModificationReason reason) {
- HTMLElement::attributeChanged(name, oldValue, newValue, reason);
- attributeChangedCallback(name, newValue);
-}
-
Node::InsertionNotificationRequest HTMLMarqueeElement::insertedInto(
ContainerNode* insertionPoint) {
HTMLElement::insertedInto(insertionPoint);
- if (isConnected()) {
- static const QualifiedName* presentationalAttributes[] = {
- &HTMLNames::bgcolorAttr, &HTMLNames::heightAttr, &HTMLNames::hspaceAttr,
- &HTMLNames::vspaceAttr, &HTMLNames::widthAttr};
- for (const auto* attr : presentationalAttributes) {
- const AtomicString& value = getAttribute(*attr);
- if (value.isNull())
- continue;
- attributeChangedCallback(*attr, value);
- }
-
+ if (isConnected())
start();
- }
return InsertionDone;
}
@@ -207,28 +171,34 @@ void HTMLMarqueeElement::stop() {
m_player->pause();
}
-void HTMLMarqueeElement::attributeChangedCallback(const QualifiedName& attr,
- const String& newValue) {
+bool HTMLMarqueeElement::isPresentationAttribute(
+ const QualifiedName& attr) const {
+ if (attr == HTMLNames::bgcolorAttr || attr == HTMLNames::heightAttr ||
+ attr == HTMLNames::hspaceAttr || attr == HTMLNames::vspaceAttr ||
+ attr == HTMLNames::widthAttr) {
+ return true;
+ }
+ return HTMLElement::isPresentationAttribute(attr);
+}
+
+void HTMLMarqueeElement::collectStyleForPresentationAttribute(
+ const QualifiedName& attr,
+ const AtomicString& value,
+ MutableStylePropertySet* style) {
if (attr == HTMLNames::bgcolorAttr) {
- style()->setProperty("background-color", newValue, String(),
- ASSERT_NO_EXCEPTION);
+ addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value);
} else if (attr == HTMLNames::heightAttr) {
- style()->setProperty("height", convertHTMLLengthToCSSLength(newValue),
- String(), ASSERT_NO_EXCEPTION);
+ addHTMLLengthToStyle(style, CSSPropertyHeight, value);
} else if (attr == HTMLNames::hspaceAttr) {
- style()->setProperty("margin-left", convertHTMLLengthToCSSLength(newValue),
- String(), ASSERT_NO_EXCEPTION);
- style()->setProperty("margin-right", convertHTMLLengthToCSSLength(newValue),
- String(), ASSERT_NO_EXCEPTION);
+ addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value);
+ addHTMLLengthToStyle(style, CSSPropertyMarginRight, value);
} else if (attr == HTMLNames::vspaceAttr) {
- style()->setProperty("margin-top", convertHTMLLengthToCSSLength(newValue),
- String(), ASSERT_NO_EXCEPTION);
- style()->setProperty("margin-bottom",
- convertHTMLLengthToCSSLength(newValue), String(),
- ASSERT_NO_EXCEPTION);
+ addHTMLLengthToStyle(style, CSSPropertyMarginTop, value);
+ addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value);
} else if (attr == HTMLNames::widthAttr) {
- style()->setProperty("width", convertHTMLLengthToCSSLength(newValue),
- String(), ASSERT_NO_EXCEPTION);
+ addHTMLLengthToStyle(style, CSSPropertyWidth, value);
+ } else {
+ HTMLElement::collectStyleForPresentationAttribute(attr, value, style);
}
}
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLMarqueeElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698