Bug 92473

Summary: [CSS] Add tests for :read-only and :read-write
Product: WebKit Reporter: yosin
Component: CSSAssignee: KyungTae Kim <ktf.kim>
Status: RESOLVED FIXED    
Severity: Normal CC: adele, allan.jensen, bdakin, benjamin, buildbot, commit-queue, darin, esprehn+autocc, gyuyoung.kim, ktf.kim, rniwa, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jsfiddle.net/ZnrQT/
Bug Depends on: 92602    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2
none
Archive of layout-test-results from webkit-ews-02 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2
none
Patch
none
Patch
none
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion
none
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2
none
Patch
none
Patch
none
Patch none

yosin
Reported 2012-07-27 01:55:53 PDT
According HTML5 specification[1], :read-only and :read-write selector should match all elements. Although, current implementation applies only isFormisFormControlElement: In WebCore/css/SelectorChecker.cpp: bool SelectorChecker::checkOneSelector(const SelectorCheckingContext& context, PseudoId& dynamicPseudo) const { ... case CSSSelector::PseudoReadWrite: if (!element || !element->isFormControlElement()) return false; return element->isTextFormControl() && !element->isReadOnlyFormControl(); ... } = Browser Behaviors = Result of http://jsfiddle.net/ZnrQT/ (:read-only: color: red, :read-write: color: green) Chromium: input and textarea are red FireFox: all colors are default(black) IE: all colors are default(black) Opera: all colors are red except for input type "date". = References = [1] http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#pseudo-classes
Attachments
Patch (11.19 KB, patch)
2014-01-22 02:57 PST, KyungTae Kim
no flags
Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2 (456.97 KB, application/zip)
2014-01-22 04:03 PST, Build Bot
no flags
Archive of layout-test-results from webkit-ews-02 for mac-mountainlion (500.64 KB, application/zip)
2014-01-22 04:29 PST, Build Bot
no flags
Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2 (452.56 KB, application/zip)
2014-01-22 04:58 PST, Build Bot
no flags
Patch (12.77 KB, patch)
2014-01-22 05:16 PST, KyungTae Kim
no flags
Patch (20.88 KB, patch)
2014-02-03 21:45 PST, KyungTae Kim
no flags
Archive of layout-test-results from webkit-ews-08 for mac-mountainlion (545.27 KB, application/zip)
2014-02-03 23:40 PST, Build Bot
no flags
Archive of layout-test-results from webkit-ews-05 for mac-mountainlion (593.39 KB, application/zip)
2014-02-04 00:25 PST, Build Bot
no flags
Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2 (556.49 KB, application/zip)
2014-02-04 00:48 PST, Build Bot
no flags
Patch (20.95 KB, patch)
2014-02-04 01:37 PST, KyungTae Kim
no flags
Patch (23.35 KB, patch)
2014-02-04 21:29 PST, KyungTae Kim
no flags
Patch (9.89 KB, patch)
2014-11-01 22:24 PDT, Benjamin Poulain
no flags
yosin
Comment 1 2012-07-31 01:12:48 PDT
Definition of "editing host" and "editable" are found in "HTML Editing APIs" http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#editing-host
KyungTae Kim
Comment 2 2014-01-22 02:57:19 PST
KyungTae Kim
Comment 3 2014-01-22 03:01:07 PST
By the spec (http://www.w3.org/TR/css3-ui/), most elements are :read-only but if a element with contenteditable attribute, it is :read-write. Additionally, children of contenteditable elements seems not :read-write, because their contents are not user-alterable. 4.1.7. :read-only and :read-write An element whose contents are not user-alterable is :read-only. However, elements whose contents are user-alterable (such as text input fields) are considered to be in a :read-write state. In typical documents, most elements are :read-only. However it may be possible (e.g. in the context of an editor) for any element to become :read-write.
Build Bot
Comment 4 2014-01-22 04:03:45 PST
Comment on attachment 221847 [details] Patch Attachment 221847 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/4814773833170944 New failing tests: fast/forms/select-live-pseudo-selectors.html
Build Bot
Comment 5 2014-01-22 04:03:48 PST
Created attachment 221856 [details] Archive of layout-test-results from webkit-ews-16 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-16 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
Build Bot
Comment 6 2014-01-22 04:29:31 PST
Comment on attachment 221847 [details] Patch Attachment 221847 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/6751327879168000 New failing tests: fast/forms/select-live-pseudo-selectors.html platform/mac/fast/objc/dom-html-select-live-pseudo-selectors.html
Build Bot
Comment 7 2014-01-22 04:29:33 PST
Created attachment 221857 [details] Archive of layout-test-results from webkit-ews-02 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-02 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Build Bot
Comment 8 2014-01-22 04:58:12 PST
Comment on attachment 221847 [details] Patch Attachment 221847 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/5336707922657280 New failing tests: fast/forms/select-live-pseudo-selectors.html
Build Bot
Comment 9 2014-01-22 04:58:15 PST
Created attachment 221860 [details] Archive of layout-test-results from webkit-ews-15 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-15 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
KyungTae Kim
Comment 10 2014-01-22 05:16:33 PST
Darin Adler
Comment 11 2014-02-02 23:37:34 PST
Comment on attachment 221861 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=221861&action=review A good start, but test and implementation both need more work. We need more test coverage on elements that are not editable, including non-HTML elements. Doing all the tests with <div> is not OK. > Source/WebCore/html/HTMLElement.cpp:1110 > +bool HTMLElement::matchesReadOnlyPseudoClass() const > +{ > + return !matchesReadWritePseudoClass(); > +} I think that Element::matchesReadOnlyPseudoClass needs to also return true; a test case that would cover that would be any non-HTML element that is styled with ::read-only. I’m thinking that we should get rid of the virtual matchesReadOnlyPseudoClass function entirely and just have Element::matchesReadOnlyPseudoClass be an inline non-virtual member function that returns !matchesReadWritePseudoClass(). While this change is OK for CSS purposes, I think it also changes the behavior of RenderTheme::isReadOnlyControl, causing it to return true for many renderers where it used to return false. It will return for many renderers for elements are not controls at all. Did you test to make sure that’s OK? I’m particularly concerned about the use in RenderThemeSafari::determineState, but also I am not sure if RenderThemeSafari is still live code or not. > Source/WebCore/html/HTMLElement.h:103 > + virtual bool matchesReadOnlyPseudoClass() const; > + virtual bool matchesReadWritePseudoClass() const; These should both be marked "override". I also suggest making them private rather than public, because no code should be calling this directly on an HTMLElement. > LayoutTests/fast/css/readwrite-pseudoclass-editable.html:9 > + shouldBeEqualToString("window.getComputedStyle(document.getElementById('editable1'),null).getPropertyValue('background-color')","rgb(255, 0, 0)"); To make the test more readable I suggest the following simplification: 1) Don’t use "window."; we can just use “getComputedStyle”. 2) Don’t pass “null” explicitly. I think we can just omit the second argument to getComputedStyle. 3) Use a helper function: function backgroundColor(identifier) { return getComputedStyle(document.getElementById(identifier)).getPropertyValue("background-color"); } shouldBeEqualToString("backgroundColor('editable1')", "rgb(255, 0, 0)"); By using the named helper function the test itself and the test output are more readable. > LayoutTests/fast/css/readwrite-pseudoclass-editable.html:16 > + isSuccessfullyParsed(); I don’t think this is the right place for that function call. How do we do this in other tests. > LayoutTests/fast/css/readwrite-pseudoclass-editable.html:22 > + :read-write { > + background-color: red; > + } This test case covers :read-write only. We need to test :read-only too. > LayoutTests/fast/css/readwrite-pseudoclass-editable.html:33 > + <div id="editable1" contenteditable> > + <div id="div_in_editable"></div> > + <input type="text" readonly id="readonly_in_editable"/> > + <input type="text" disabled id="disabled_in_editable"/> > + </div> > + <div id="editable2" contenteditable="true"></div> > + <div id="editable3" contenteditable="plaintext-only"></div> > + <div id="non_editable" contenteditable="false"></div> Where’s the test case for contenteditable=""? That’s specially handled in the code above, and so it needs a test case.
KyungTae Kim
Comment 12 2014-02-03 21:45:20 PST
Build Bot
Comment 13 2014-02-03 23:40:34 PST
Comment on attachment 223072 [details] Patch Attachment 223072 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/6446230313893888 New failing tests: fast/css/readwrite-pseudoclass-editable.html
Build Bot
Comment 14 2014-02-03 23:40:37 PST
Created attachment 223076 [details] Archive of layout-test-results from webkit-ews-08 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-08 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Build Bot
Comment 15 2014-02-04 00:25:05 PST
Comment on attachment 223072 [details] Patch Attachment 223072 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/6245221952126976 New failing tests: fast/css/readwrite-pseudoclass-editable.html
Build Bot
Comment 16 2014-02-04 00:25:09 PST
Created attachment 223079 [details] Archive of layout-test-results from webkit-ews-05 for mac-mountainlion The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: webkit-ews-05 Port: mac-mountainlion Platform: Mac OS X 10.8.5
Build Bot
Comment 17 2014-02-04 00:48:25 PST
Comment on attachment 223072 [details] Patch Attachment 223072 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/6577233661526016 New failing tests: fast/css/readwrite-pseudoclass-editable.html
Build Bot
Comment 18 2014-02-04 00:48:29 PST
Created attachment 223083 [details] Archive of layout-test-results from webkit-ews-10 for mac-mountainlion-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: webkit-ews-10 Port: mac-mountainlion-wk2 Platform: Mac OS X 10.8.5
KyungTae Kim
Comment 19 2014-02-04 01:37:42 PST
KyungTae Kim
Comment 20 2014-02-04 04:11:21 PST
(In reply to comment #11) > (From update of attachment 221861 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=221861&action=review > We need more test coverage on elements that are not editable, including non-HTML elements. Doing all the tests with <div> is not OK. I changed the test case to use many types, but I'm confused how the test coverage should be. Should it include all sort of elements? > I’m thinking that we should get rid of the virtual matchesReadOnlyPseudoClass function entirely and just have Element::matchesReadOnlyPseudoClass be an inline non-virtual member function that returns !matchesReadWritePseudoClass(). I modified as your comment, and removed each element's matchesReadOnlyPseudoClass methods. I think a disabled input is also :read-only because it's not user-alterable. > While this change is OK for CSS purposes, I think it also changes the behavior of RenderTheme::isReadOnlyControl, causing it to return true for many renderers where it used to return false. It will return for many renderers for elements are not controls at all. Did you test to make sure that’s OK? I’m particularly concerned about the use in RenderThemeSafari::determineState, but also I am not sure if RenderThemeSafari is still live code or not. isReadOnlyControl means isControl && isReadOnly, and I changed that function like it. However, I could not sure it yet because I couldn't find the test case for that. The newly added test cases are readonly-pseudoclass-common-element.html and readwrite-pseudoclass-editable.html. I modified the test cases as your comment.
Darin Adler
Comment 21 2014-02-04 20:51:00 PST
(In reply to comment #20) > (In reply to comment #11) > > We need more test coverage on elements that are not editable, including non-HTML elements. Doing all the tests with <div> is not OK. > I changed the test case to use many types, but I'm confused how the test coverage should be. Should it include all sort of elements? I think we want at least one SVG element and at least one MathML element; probably not important to have a big variety of HTML elements, although it would be good to cover any that have special rules.
KyungTae Kim
Comment 22 2014-02-04 21:29:25 PST
KyungTae Kim
Comment 23 2014-02-16 23:08:36 PST
(In reply to comment #21) > (In reply to comment #20) > > (In reply to comment #11) > > > We need more test coverage on elements that are not editable, including non-HTML elements. Doing all the tests with <div> is not OK. > > I changed the test case to use many types, but I'm confused how the test coverage should be. Should it include all sort of elements? > > I think we want at least one SVG element and at least one MathML element; probably not important to have a big variety of HTML elements, although it would be good to cover any that have special rules. I added SVG & MathML case on the updated patch.
Benjamin Poulain
Comment 24 2014-11-01 22:24:12 PDT
Benjamin Poulain
Comment 25 2014-11-01 22:25:50 PDT
I fixed this bug a month ago, I was unaware you had a fix for it. :( Your tests are still interesting by themselves, let's land that if the bots are green.
WebKit Commit Bot
Comment 26 2014-11-02 00:06:21 PDT
Comment on attachment 240806 [details] Patch Clearing flags on attachment: 240806 Committed r175461: <http://trac.webkit.org/changeset/175461>
WebKit Commit Bot
Comment 27 2014-11-02 00:06:28 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.