WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
115885
<label> element should send key and focus events if it has contenteditable attribute.
https://bugs.webkit.org/show_bug.cgi?id=115885
Summary
<label> element should send key and focus events if it has contenteditable at...
Yael
Reported
2013-05-09 18:58:25 PDT
HTMLLabelElement should be focusable if it passes the test isContentEditable(). As a result, the proper events would be sent. Both Opera and Firefox support this behavior. Merge of
https://src.chromium.org/viewvc/blink?view=rev&revision=149973
Attachments
Patch
(7.07 KB, patch)
2013-05-09 19:05 PDT
,
Yael
benjamin
: review-
benjamin
: commit-queue-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Yael
Comment 1
2013-05-09 19:05:49 PDT
Created
attachment 201311
[details]
Patch
Benjamin Poulain
Comment 2
2013-05-09 22:43:49 PDT
Comment on
attachment 201311
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=201311&action=review
> LayoutTests/fast/forms/label/labels-contenteditable.html:16 > +var parent = document.createElement('div'); > + > +parent.innerHTML = '<label id="label1" for="input1">text</label><input id="input1"> <label id="label2" contenteditable for="input2">text</label><input id="input2">';
Why do you do that? Why isn't that in the markup?
> LayoutTests/fast/forms/label/labels-contenteditable.html:34 > +label1.addEventListener('keydown', function () { alert("FAIL: keydown should not be sent if the label does not have contenteditable attribute"); }); > +label1.addEventListener('keypress', function () { alert("FAIL: keypress should not be sent if the label does not have contenteditable attribute"); }); > +label1.addEventListener('keyup', function () { alert("FAIL: keyup should not be sent if the label does not have contenteditable attribute"); }); > +label1.addEventListener('focus', function () { alert("FAIL: focus should not be sent if the label does not have contenteditable attribute"); }); > +label1.addEventListener('blur', function () { alert("FAIL: blur should not be sent if the label does not have contenteditable attribute"); }); > +input1.addEventListener('focus', function () { alert("PASS: label passed the focus to the corresponding control"); }); > +label2.addEventListener('keydown', function () { alert("PASS: keydown should be sent if the label has contenteditable attribute"); }); > +label2.addEventListener('keypress', function () { alert("PASS: keypress should be sent if the label has contenteditable attribute"); }); > +label2.addEventListener('keyup', function () { alert("PASS: keyup should be sent if the label has contenteditable attribute"); }); > +label2.addEventListener('focus', function () { alert("PASS: focus should be sent if the label has contenteditable attribute"); }); > +label2.addEventListener('blur', function () { alert("PASS: blur should be sent if the label has contenteditable attribute"); }); > +input2.addEventListener('focus', function () { alert("PASS: label passed the focus to the corresponding control"); });
You should use debug() logging instead of alert().
> LayoutTests/fast/forms/resources/label-test-util.js:80 > +function mouseMoveToLabel(labelId) { > + var label = document.getElementById(labelId); > + var itemHeight = Math.floor(label.offsetHeight / label.size); > + var offset = 5; > + if (window.eventSender) > + eventSender.mouseMoveTo(label.offsetLeft + offset, label.offsetTop + offset - window.pageYOffset); > +}
There is already code to do that in LayoutTest. None that you can use?
> Source/WebCore/html/HTMLLabelElement.cpp:69 > - return false; > + HTMLLabelElement* that = const_cast<HTMLLabelElement*>(this); > + return that->isContentEditable();
This is very much non-const. Shouldn't you instead assert there is no pending style recalc and use rendererIsEditable()???
Yael
Comment 3
2013-05-10 07:43:55 PDT
(In reply to
comment #2
)
> Shouldn't you instead assert there is no pending style recalc and use rendererIsEditable()???
Can you share how to decide when to assert and when to call updateStyleIfNeeded ?
Ahmad Saleem
Comment 4
2022-12-16 09:23:31 PST
Taking test from Chrome bug and then trying to type in the Label field, it does work and show "keyup" event in Safari 16.2: Link -
https://jsfiddle.net/faceleg/VBdDK/1/
Is this needed anymore? Thanks!
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug