WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 29241
Bug 120273
Making a focused element invisible should make it blur
https://bugs.webkit.org/show_bug.cgi?id=120273
Summary
Making a focused element invisible should make it blur
Arunprasad Rajkumar
Reported
2013-08-25 05:54:01 PDT
It is a blink merge
https://chromiumcodereview.appspot.com/14248006
. According to the specification, we should remove focus when a focused element becomes unforcusable, and Internet Explorer follows it. We check focusable state after layout asynchronously because setFocusedNode(0) dispatches synchronous events and callers of Document::updateLayout don't expect DOM state changes. Also, we introduce m_didPostCheckFocusedNodeTask flag to avoid duplicated tasks in the pending task queue.
Attachments
Patch
(8.13 KB, patch)
2013-08-25 06:17 PDT
,
Arunprasad Rajkumar
no flags
Details
Formatted Diff
Diff
Patch
(8.12 KB, patch)
2013-08-25 08:06 PDT
,
Arunprasad Rajkumar
darin
: review-
Details
Formatted Diff
Diff
It is not working in Chrome even it has fix
(1.40 KB, text/html)
2013-08-29 12:09 PDT
,
Arunprasad Rajkumar
no flags
Details
test case - chrome also not working for certain cases(like calling display:none from timer)
(1.40 KB, text/html)
2013-08-29 12:22 PDT
,
Arunprasad Rajkumar
no flags
Details
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Arunprasad Rajkumar
Comment 1
2013-08-25 06:17:58 PDT
Created
attachment 209592
[details]
Patch
Sergio Correia (qrwteyrutiyoup)
Comment 2
2013-08-25 07:41:15 PDT
Comment on
attachment 209592
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=209592&action=review
> LayoutTests/ChangeLog:8 > + * fast/dom/HTMLDocument/active-element-gets-unforcusable.html: Added.
typo in the filenames? "unfoRcusable"
Arunprasad Rajkumar
Comment 3
2013-08-25 08:06:40 PDT
Created
attachment 209593
[details]
Patch
Arunprasad Rajkumar
Comment 4
2013-08-25 08:07:35 PDT
(In reply to
comment #2
)
> (From update of
attachment 209592
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=209592&action=review
> > > LayoutTests/ChangeLog:8 > > + * fast/dom/HTMLDocument/active-element-gets-unforcusable.html: Added. > > typo in the filenames? "unfoRcusable"
Oops!. Fixed in the new patch :)
Jose Lejin PJ
Comment 5
2013-08-26 06:19:19 PDT
Seems use case in
Bug#120283
can be resolved with this.
Darin Adler
Comment 6
2013-08-26 09:57:58 PDT
Comment on
attachment 209593
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=209593&action=review
> Source/WebCore/dom/Document.cpp:381 > +// This class should be passed only to Document::postTask.
I don't understand the value of this comment. What other bad thing could someone do with this class. Next time just leave this out. I suspect this entire class will go away, but we if keep it I have a few comments.
> Source/WebCore/dom/Document.cpp:386 > + return adoptPtr(new CheckFocusedNodeTask());
I suggest omitting the "()" here.
> Source/WebCore/dom/Document.cpp:388 > + virtual ~CheckFocusedNodeTask() { }
I suggest omitting this entirely. It should be generated.
> Source/WebCore/dom/Document.cpp:391 > + CheckFocusedNodeTask() { }
Doesn't seem to be valuable to make this private. There would be no harm if someone constructed one of these without using the create function. I suggest just omitting this and letting it be generated.
> Source/WebCore/dom/Document.cpp:395 > + Document* document = toDocument(context);
I suggest using Document& here instead of Document* since it can’t be null. In newer code in general we are trying to use references for such things.
> Source/WebCore/dom/Document.cpp:401 > + if (focusedElement->renderer() && focusedElement->renderer()->needsLayout()) > + return;
This needsLayout check does not make sense. It's not helpful to check if the single renderer has the needs-layout bit set on it. What bug did it fix to check this?
> Source/WebCore/dom/Document.cpp:1885 > + // FIXME: Using a Task doesn't look a good idea.
Yes, a Task is not a good fix for this. I suggest sharing the updateFocusAppearance timer.
> Source/WebCore/dom/Document.cpp:1889 > + if (m_focusedElement && !m_didPostCheckFocusedNodeTask) { > + postTask(CheckFocusedNodeTask::create()); > + m_didPostCheckFocusedNodeTask = true; > + }
Here’s what I think this code should say: if (!m_focusedElement->isFocusable()) updateFocusAppearanceSoon(false); Then, inside the updateFocusAppearanceTimerFired function: if (element->isFocusable()) element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection); else document->setFocusedElement(0); Please give that a try and see if there are any problems caused by that approach.
Arunprasad Rajkumar
Comment 7
2013-08-26 10:36:28 PDT
(In reply to
comment #6
)
> (From update of
attachment 209593
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=209593&action=review
> > > Source/WebCore/dom/Document.cpp:381 > > +// This class should be passed only to Document::postTask. > > I don't understand the value of this comment. What other bad thing could someone do with this class. Next time just leave this out. I suspect this entire class will go away, but we if keep it I have a few comments. > > > Source/WebCore/dom/Document.cpp:386 > > + return adoptPtr(new CheckFocusedNodeTask()); > > I suggest omitting the "()" here. > > > Source/WebCore/dom/Document.cpp:388 > > + virtual ~CheckFocusedNodeTask() { } > > I suggest omitting this entirely. It should be generated. > > > Source/WebCore/dom/Document.cpp:391 > > + CheckFocusedNodeTask() { } > > Doesn't seem to be valuable to make this private. There would be no harm if someone constructed one of these without using the create function. I suggest just omitting this and letting it be generated. > > > Source/WebCore/dom/Document.cpp:395 > > + Document* document = toDocument(context); > > I suggest using Document& here instead of Document* since it can’t be null. In newer code in general we are trying to use references for such things. > > > Source/WebCore/dom/Document.cpp:401 > > + if (focusedElement->renderer() && focusedElement->renderer()->needsLayout()) > > + return; > > This needsLayout check does not make sense. It's not helpful to check if the single renderer has the needs-layout bit set on it. What bug did it fix to check this? > > > Source/WebCore/dom/Document.cpp:1885 > > + // FIXME: Using a Task doesn't look a good idea. > > Yes, a Task is not a good fix for this. I suggest sharing the updateFocusAppearance timer. > > > Source/WebCore/dom/Document.cpp:1889 > > + if (m_focusedElement && !m_didPostCheckFocusedNodeTask) { > > + postTask(CheckFocusedNodeTask::create()); > > + m_didPostCheckFocusedNodeTask = true; > > + } > > Here’s what I think this code should say: > > if (!m_focusedElement->isFocusable()) > updateFocusAppearanceSoon(false); > > Then, inside the updateFocusAppearanceTimerFired function: > > if (element->isFocusable()) > element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection); > else > document->setFocusedElement(0); > > Please give that a try and see if there are any problems caused by that approach.
Darin, Thanks for your comments :) Sure, I will try with m_updateFocusAppearanceTimer and let u know the result.
Arunprasad Rajkumar
Comment 8
2013-08-29 08:46:17 PDT
Comment on
attachment 209593
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=209593&action=review
>> Source/WebCore/dom/Document.cpp:1885 >> + // FIXME: Using a Task doesn't look a good idea. > > Yes, a Task is not a good fix for this. I suggest sharing the updateFocusAppearance timer.
I tried using updateFocusAppearance timer, but Document::updateFocusAppearanceTimerFired calls Document::updateLayout, from Document::updateLayout() again we are scheduling a timer. It cases above 2 functions being called repeatedly. I'm going to try with a separate timer for this instead of reusing updateFocusAppearance timer. Hope it will be good to do. What do you think?
Arunprasad Rajkumar
Comment 9
2013-08-29 09:03:23 PDT
(In reply to
comment #8
)
> (From update of
attachment 209593
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=209593&action=review
> > >> Source/WebCore/dom/Document.cpp:1885 > >> + // FIXME: Using a Task doesn't look a good idea. > > > > Yes, a Task is not a good fix for this. I suggest sharing the updateFocusAppearance timer. > > I tried using updateFocusAppearance timer, but Document::updateFocusAppearanceTimerFired calls Document::updateLayout, from Document::updateLayout() again we are scheduling a timer. It cases above 2 functions being called repeatedly. > > I'm going to try with a separate timer for this instead of reusing updateFocusAppearance timer. Hope it will be good to do. What do you think?
May be with little tweaking it is achievable :) Will try with a recursive guard member.
Alexey Proskuryakov
Comment 10
2013-08-29 09:13:34 PDT
This loooks like a duplicate of
bug 29241
.
Arunprasad Rajkumar
Comment 11
2013-08-29 09:42:03 PDT
(In reply to
comment #10
)
> This loooks like a duplicate of
bug 29241
.
Yes, you are right :)
Darin Adler
Comment 12
2013-08-29 10:15:40 PDT
Can we avoid the recursion by ordering the operations appropriately without a recursion guard? Please keep in mind the timer again is *not* recursion. Scheduling timer over and over again infinitely would be a problem, but still, not infinite recursion.
Darin Adler
Comment 13
2013-08-29 10:16:24 PDT
Please keep in mind that scheduling the timer again is *not* recursion (I meant to say). Also lets mark this a duplicate of the older bug. *** This bug has been marked as a duplicate of
bug 29241
***
Arunprasad Rajkumar
Comment 14
2013-08-29 12:09:20 PDT
Created
attachment 210012
[details]
It is not working in Chrome even it has fix
Arunprasad Rajkumar
Comment 15
2013-08-29 12:11:21 PDT
(In reply to
comment #12
)
> Can we avoid the recursion by ordering the operations appropriately without a recursion guard? Please keep in mind the timer again is *not* recursion. Scheduling timer over and over again infinitely would be a problem, but still, not infinite recursion.
(In reply to
comment #13
)
> Please keep in mind that scheduling the timer again is *not* recursion (I meant to say). >
Yeah, understood :)
> Also lets mark this a duplicate of the older bug.
Patch should be submitted to #29241 ?
> > *** This bug has been marked as a duplicate of
bug 29241
***
Refer the attachment,
https://bugs.webkit.org/attachment.cgi?id=210012
, it is not working in chrome also. I think Chrome haven't implemented properly it seems.
Arunprasad Rajkumar
Comment 16
2013-08-29 12:22:21 PDT
Created
attachment 210015
[details]
test case - chrome also not working for certain cases(like calling display:none from timer)
Darin Adler
Comment 17
2013-08-29 13:03:50 PDT
Yes, lets move discussion and further patches to
bug 29241
.
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