HTMLOutputElement.htmlFor should be settable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Sep 2015 14:32:36 +0000 (14:32 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Sep 2015 14:32:36 +0000 (14:32 +0000)
commit54cc0e2b234cd89ad750356c59a5d7215be583dd
tree90e6fb6ef9668f9cb0188ed7fad0db7eabb8e9f4
parent758f2eb9b142943fab9b9f81029047cdc660ced4
HTMLOutputElement.htmlFor should be settable
https://bugs.webkit.org/show_bug.cgi?id=149418

Reviewed by Ryosuke Niwa.

Source/WebCore:

HTMLOutputElement.htmlFor should be settable as per the latest HTML
specification:
- https://html.spec.whatwg.org/multipage/forms.html#the-output-element

It is supposed to call DOMSettableTokenList.setValue() with the input
String. This patch adds support for this by adding [PutForwards=value]
IDL extended attribute.

This aligns our behavior with the specification, Firefox and Chrome.

No new tests, already covered by existing test.

* html/AttributeDOMTokenList.cpp:
(WebCore::AttributeDOMTokenList::AttributeDOMTokenList):
(WebCore::AttributeDOMTokenList::attributeValueChanged):
* html/AttributeDOMTokenList.h:
- Have AttributeDOMTokenList subclass DOMSettableTokenList instead of
DOMTokenList so that it can be used in places where the IDL expects
us to return a DOMSettableTokenList (e.g. HTMLOutputElement.htmlFor).
- Mark AttributeDOMTokenList as fast allocated.

* html/DOMSettableTokenList.cpp:
(WebCore::DOMSettableTokenList::setValue):
* html/DOMSettableTokenList.h:
- Move setValue() from DOMTokenList to DOMSettableTokenList
  as it is only needed by DOMSettableTokenList.
- Get rid of the factory function as all call sites are using
  AttributeDOMTokenList now.
- Stop inheriting RefCounted as AttributeDOMTokenList handles its
  own refcounting.

* html/DOMTokenList.cpp:
(WebCore::DOMTokenList::setValueInternal):
* html/DOMTokenList.h:
Rename setValue() to setValueInternal() as this version does not
update the associated attribute value, only the tokens.

* html/HTMLLinkElement.cpp:
* html/HTMLLinkElement.h:
- Have HTMLLinkElement.sizes use an AttributeDOMTokenList instead of
  a DOMSettableTokenList as there is an associated attribute. The
  previous code had a bug has setting HTMLLinkElement.sizes would not
  update the associated 'sizes' attribute. Switching to using
  AttributeDOMTokenList fixes this and a new layout test has been added
  to cover this.
- Create the AttributeDOMTokenList lazily to avoid updating it every
  time the sizes attribute changes until it is actually accessed.

* html/HTMLOutputElement.cpp:
* html/HTMLOutputElement.h:
- Have HTMLLinkElement.htmlFor use an AttributeDOMTokenList instead of
  a DOMSettableTokenList as there is an associated attribute.
- Create the AttributeDOMTokenList lazily to avoid updating it every
  time the sizes attribute changes until it is actually accessed.

* html/HTMLOutputElement.idl:
Add [PutForwards=value] on the htmlFor attribute, as per the
HTML specification.

LayoutTests:

* fast/dom/HTMLLinkElement/sizes-setter.html: Added
* fast/dom/HTMLLinkElement/sizes-setter-expected.txt: Added
Add layout test to make sure that setting HTMLLinkElement.sizes actually
updates the 'sizes' associated attribute.

* fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt:
* fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js:
Update existing layout test now that HTMLOutputElement.htmlFor is
settable.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@190168 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLLinkElement/sizes-setter-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLLinkElement/sizes-setter.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt
LayoutTests/fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js
Source/WebCore/ChangeLog
Source/WebCore/html/AttributeDOMTokenList.cpp
Source/WebCore/html/AttributeDOMTokenList.h
Source/WebCore/html/DOMSettableTokenList.cpp
Source/WebCore/html/DOMSettableTokenList.h
Source/WebCore/html/DOMTokenList.cpp
Source/WebCore/html/DOMTokenList.h
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLLinkElement.h
Source/WebCore/html/HTMLOutputElement.cpp
Source/WebCore/html/HTMLOutputElement.h
Source/WebCore/html/HTMLOutputElement.idl