haikuwebkit/LayoutTests/fast/selectors/read-only-read-write-conten...

51 lines
4.2 KiB
Plaintext
Raw Permalink Normal View History

Add support for :read-write/:read-only matching editable content https://bugs.webkit.org/show_bug.cgi?id=136668 Reviewed by Antti Koivisto. Source/WebCore: This is the second part of the update of :read-write/:read-only to the latest spec (http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting.html#selectors). The selectors :read-write/:read-only should match elements that are editable. The exact definition is: "elements that are editing hosts or editable and are neither input elements nor textarea elements". Matching that definition is really easy. It was done by updating HTMLElement's matchesReadWritePseudoClass() to consider both contentEditable and designMode. The tricky part is making that efficient in all cases. Matching contentEditable is horribly inefficient compared to the other primitives. We don't want to execute that for every element. Since matchesReadWritePseudoClass() was used by the theming code, that code was adjusted to -Avoid calling that on regular HTMLElement, limiting the query to <input> and <textarea> where it is fast. -Avoid the call entirely when possible. Tests: fast/css/read-only-read-write-contenteditable-basics.html fast/css/read-only-read-write-designmode-basics.html fast/css/read-only-read-write-webkit-user-modify.html fast/selectors/read-only-read-write-contenteditable-basics.html fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html fast/selectors/read-only-read-write-designmode-basics.html fast/selectors/read-only-read-write-style-update.html * html/HTMLElement.cpp: (WebCore::contentEditableType): This code is a generalization of the code that was in HTMLElement::contentEditable(). It is used by both matchesReadWritePseudoClass() and contentEditable() to determine a valid state from the value of contentEditable. (WebCore::HTMLElement::matchesReadWritePseudoClass): Per the definition of editable content, we first check if the current element is an editing host, if not we look for an editing host. If there are none, test for designMode. (WebCore::HTMLElement::contentEditable): (WebCore::RenderTheme::isReadOnlyControl): The old definition would only match <input> and <textarea>. The code was updated to keep the same behavior after matchesReadWritePseudoClass() is udpated. This avoids the performance problem of calling matchesReadWritePseudoClass() on regular HTMLElement. * platform/ControlStates.h: ReadOnlyState was only used by ThemeMac for convertControlStatesToThemeDrawState(). In turn, convertControlStatesToThemeDrawState() was only used for painting "-webkit-inner-spin-button". Buttons are not read-write to begin with. The whole code looks like legacy from styling of input elements and was removed. Removing ReadOnlyState removes the expensive part of extractControlStatesForRenderer(). * html/HTMLElement.h: * html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElement::readOnlyAttributeChanged): * platform/mac/ThemeMac.mm: (WebCore::convertControlStatesToThemeDrawState): * rendering/RenderTheme.cpp: (WebCore::RenderTheme::extractControlStatesForRenderer): LayoutTests: * fast/css/read-only-read-write-contenteditable-basics-expected.html: Added. * fast/css/read-only-read-write-contenteditable-basics.html: Added. * fast/css/read-only-read-write-designmode-basics-expected.html: Added. * fast/css/read-only-read-write-designmode-basics.html: Added. * fast/css/read-only-read-write-webkit-user-modify-expected.txt: Added. * fast/css/read-only-read-write-webkit-user-modify.html: Added. * fast/selectors/read-only-read-write-contenteditable-basics-expected.txt: Added. * fast/selectors/read-only-read-write-contenteditable-basics.html: Added. * fast/selectors/read-only-read-write-contenteditable-svg-foreignObject-expected.txt: Added. * fast/selectors/read-only-read-write-contenteditable-svg-foreignObject.html: Added. * fast/selectors/read-only-read-write-designmode-basics-expected.txt: Added. * fast/selectors/read-only-read-write-designmode-basics.html: Added. * fast/selectors/read-only-read-write-style-update-expected.txt: Added. * fast/selectors/read-only-read-write-style-update.html: Added. Canonical link: https://commits.webkit.org/154493@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@173441 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-09-09 21:03:29 +00:00
At the time of writing this test, there is no specification for contenteditable for SVG. Adding contenteditable on an SVG element does not create an editing host. This test verify that having a SVG or HTML attribute "contenteditable" does not interfere with the selectors :read-write and :read-only.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getComputedStyle(document.querySelectorAll("#test-block *")[0]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[0]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[1]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[1]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[2]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[2]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[3]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[3]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[4]).color is "rgb(0, 255, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[4]).backgroundColor is "rgb(255, 255, 255)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[5]).color is "rgb(0, 255, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[5]).backgroundColor is "rgb(255, 255, 255)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[6]).color is "rgb(0, 255, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[6]).backgroundColor is "rgb(255, 255, 255)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[7]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[7]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[8]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[8]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[9]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[9]).backgroundColor is "rgb(255, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[10]).color is "rgb(0, 255, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[10]).backgroundColor is "rgb(255, 255, 255)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[11]).color is "rgb(0, 255, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[11]).backgroundColor is "rgb(255, 255, 255)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[12]).color is "rgb(0, 255, 0)"
PASS getComputedStyle(document.querySelectorAll("#test-block *")[12]).backgroundColor is "rgb(255, 255, 255)"
PASS document.querySelectorAll("#test-block :read-write").length is 6
PASS document.querySelectorAll("#test-block :read-write")[0].id is "editing-host-1"
PASS document.querySelectorAll("#test-block :read-write")[1].id is "editable-block-1"
PASS document.querySelectorAll("#test-block :read-write")[2].id is "editing-host-2"
PASS document.querySelectorAll("#test-block :read-write")[3].id is "editable-block-2"
PASS document.querySelectorAll("#test-block :read-write")[4].id is "nested-editing-host-2"
PASS document.querySelectorAll("#test-block :read-write")[5].id is "editable-block-3"
PASS document.querySelectorAll("#test-block :read-only").length is 7
PASS document.querySelectorAll("#test-block :read-only")[0].id is "svg-root-1"
PASS document.querySelectorAll("#test-block :read-only")[1].id is "fake-contenteditable-group-1"
PASS document.querySelectorAll("#test-block :read-only")[2].id is "foreign-object-1"
PASS document.querySelectorAll("#test-block :read-only")[3].id is "non-editable-block-1"
PASS document.querySelectorAll("#test-block :read-only")[4].id is "svg-root-2"
PASS document.querySelectorAll("#test-block :read-only")[5].id is "fake-contenteditable-group-2"
PASS document.querySelectorAll("#test-block :read-only")[6].id is "foreign-object-2"
PASS successfullyParsed is true
TEST COMPLETE