Reviewers: tkent
CL:
https://codereview.chromium.org/2376593003/Message:
PTAL.
BTW this also fixes the scope tests in:
http://w3c-test.org/html/dom/reflection-tabular.htmlDescription:
Limit scope getter to predefined values
The scope attribute is limited to four predefined keywords [1], make
sure the idl binding will only return one of those keywords or
empty string (for default).
Behavior matches Safari and Firefox.
[1]
https://html.spec.whatwg.org/#the-th-element:attr-th-scopeAffected files (+27, -4 lines):
M third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html
M third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt
M third_party/WebKit/Source/core/html/HTMLTableCellElement.h
M third_party/WebKit/Source/core/html/HTMLTableCellElement.cpp
M third_party/WebKit/Source/core/html/HTMLTableCellElement.idl
Index: third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt
diff --git a/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt b/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt
index b7ea08dfccafdae2ab2e51eccb168d0dc071f9db..e11458e94bdcf2d5d70af14ad7b7c4010eb58eb5 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null-expected.txt
@@ -249,7 +249,7 @@ TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.ch
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.chOff]
TEST SUCCEEDED: The value was the empty string. [tested HTMLTableCellElement.headers]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.height]
-TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.scope]
+TEST SUCCEEDED: The value was the empty string. [tested HTMLTableCellElement.scope]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.vAlign]
TEST SUCCEEDED: The value was the string 'null'. [tested HTMLTableCellElement.width]
Index: third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html b/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html
index 35acafb6175fe22b89a24b1a7e1a77cc43d622f7..54f94ac1a0ff159be76a3f9cb6dc1a61133cdbb4 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/element-attribute-js-null.html
@@ -577,7 +577,7 @@
{name: 'chOff', expectedNull: 'null'},
{name: 'headers', expectedNull: ''},
{name: 'height', expectedNull: 'null'},
- {name: 'scope', expectedNull: 'null'},
+ {name: 'scope', expectedNull: ''},
{name: 'vAlign', expectedNull: 'null'},
{name: 'width', expectedNull: 'null'}
]
Index: third_party/WebKit/Source/core/html/HTMLTableCellElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLTableCellElement.cpp b/third_party/WebKit/Source/core/html/HTMLTableCellElement.cpp
index 26553e6f9bcc05a40c50c723c3a041f695542430..58d6ae5e589aa7ff66aef7c9910963dbba00cf13 100644
--- a/third_party/WebKit/Source/core/html/HTMLTableCellElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLTableCellElement.cpp
@@ -174,7 +174,29 @@ void HTMLTableCellElement::setRowSpan(unsigned n)
const AtomicString& HTMLTableCellElement::scope() const
{
- return fastGetAttribute(scopeAttr);
+ const AtomicString& scopeValue = fastGetAttribute(scopeAttr);
+ if (equalIgnoringCase(scopeValue, "row")) {
+ DEFINE_STATIC_LOCAL(const AtomicString, row, ("row"));
+ return row;
+ }
+ if (equalIgnoringCase(scopeValue, "col")) {
+ DEFINE_STATIC_LOCAL(const AtomicString, col, ("col"));
+ return col;
+ }
+ if (equalIgnoringCase(scopeValue, "rowgroup")) {
+ DEFINE_STATIC_LOCAL(const AtomicString, rowgroup, ("rowgroup"));
+ return rowgroup;
+ }
+ if (equalIgnoringCase(scopeValue, "colgroup")) {
+ DEFINE_STATIC_LOCAL(const AtomicString, colgroup, ("colgroup"));
+ return colgroup;
+ }
+ return emptyAtom;
+}
+
+void HTMLTableCellElement::setScope(const AtomicString& value)
+{
+ setAttribute(scopeAttr, value);
}
} // namespace blink
Index: third_party/WebKit/Source/core/html/HTMLTableCellElement.h
diff --git a/third_party/WebKit/Source/core/html/HTMLTableCellElement.h b/third_party/WebKit/Source/core/html/HTMLTableCellElement.h
index 58c47f0d3ab15a5cf169dfbd7d8f6b9282e42e05..1caed31bcee898d1bc29f1d76688380a0d4c8b29 100644
--- a/third_party/WebKit/Source/core/html/HTMLTableCellElement.h
+++ b/third_party/WebKit/Source/core/html/HTMLTableCellElement.h
@@ -49,6 +49,7 @@ public:
const AtomicString& headers() const;
void setRowSpan(unsigned);
const AtomicString& scope() const;
+ void setScope(const AtomicString&);
private:
HTMLTableCellElement(const QualifiedName&, Document&);
Index: third_party/WebKit/Source/core/html/HTMLTableCellElement.idl
diff --git a/third_party/WebKit/Source/core/html/HTMLTableCellElement.idl b/third_party/WebKit/Source/core/html/HTMLTableCellElement.idl
index c029aef2c5980150fde538fe795c9264aacad39f..d7adc87977422c1db87f4f1f372ce600373b913b 100644
--- a/third_party/WebKit/Source/core/html/HTMLTableCellElement.idl
+++ b/third_party/WebKit/Source/core/html/HTMLTableCellElement.idl
@@ -47,5 +47,5 @@ interface HTMLTableCellElement : HTMLElement {
// respectively. HTMLTableHeaderCellElement has the abbr and scope
// attributes, while HTMLTableDataCellElement has only abbr.
[CEReactions, Reflect] attribute DOMString abbr;
- [CEReactions, Reflect] attribute DOMString scope;
+ [CEReactions] attribute DOMString scope;
};