RESOLVED FIXED 191442
[iOS] Do not show selection UI for editable elements with opacity near zero
https://bugs.webkit.org/show_bug.cgi?id=191442
Summary [iOS] Do not show selection UI for editable elements with opacity near zero
Daniel Bates
Reported 2018-11-08 16:11:07 PST
Pages on iCloud.com implement their own selection UI that interferes with the native iOS selection UI. Pages uses an editable element with CSS opacity set to value near 0 as a means to opt-out of selection painting on Mac. However, on iOS UIKit is responsible for painting the selection and providing selection assistance (i.e. the lollipops) and does not know about CSS opacity. I propose that we pass information about the editable node's opacity to the UIProcess so that we may opt-out of UIKit selection assistance and selection painting if the opacity is near 0.
Attachments
Patch (5.71 KB, patch)
2018-11-08 16:23 PST, Daniel Bates
no flags
Layout Tests (5.54 KB, patch)
2018-11-09 15:45 PST, Daniel Bates
no flags
WIP (needs tests) (14.61 KB, patch)
2018-11-11 21:33 PST, Wenson Hsieh
no flags
First pass (50.46 KB, patch)
2018-11-12 21:38 PST, Wenson Hsieh
no flags
Add missing layout test. (54.30 KB, patch)
2018-11-12 21:49 PST, Wenson Hsieh
simon.fraser: review+
Patch for EWS (60.33 KB, patch)
2018-11-13 12:25 PST, Wenson Hsieh
no flags
Patch for EWS (60.33 KB, patch)
2018-11-13 12:52 PST, Wenson Hsieh
no flags
Daniel Bates
Comment 1 2018-11-08 16:23:43 PST
Created attachment 354289 [details] Patch I am open to ideas on how to fix this bug as well as suggestions on the design in this proposed patch. I was unclear how to write a test for this change.
Simon Fraser (smfr)
Comment 2 2018-11-08 17:03:44 PST
Don't we have UIScriptController stuff to get selection rects?
Daniel Bates
Comment 3 2018-11-08 17:11:43 PST
(In reply to Simon Fraser (smfr) from comment #2) > Don't we have UIScriptController stuff to get selection rects? Does this tell us the UIView selection rect? This patch is all about painting. We want UIKit to know what text is selected. We just don’t want UIKit to paint the selection. Show the lollipops or a callout bar.
Wenson Hsieh
Comment 4 2018-11-08 17:13:07 PST
(In reply to Daniel Bates from comment #3) > (In reply to Simon Fraser (smfr) from comment #2) > > Don't we have UIScriptController stuff to get selection rects? > > Does this tell us the UIView selection rect? This patch is all about > painting. We want UIKit to know what text is selected. We just don’t want > UIKit to paint the selection. Show the lollipops or a callout bar. See: UIHelper.getUISelectionRects() UIHelper.getSelectionStartGrabberViewRect() etc. IIRC, there are some examples in editing/selection/ios
Wenson Hsieh
Comment 5 2018-11-08 17:15:14 PST
(In reply to Daniel Bates from comment #1) > Created attachment 354289 [details] > Patch > > I am open to ideas on how to fix this bug as well as suggestions on the > design in this proposed patch. I was unclear how to write a test for this > change. I had a patch to fix this not too long ago. I remember one mildly tricky thing to get right is handling hidden contenteditable subframes. For example, typing and editing in the hidden area in <https://whsieh.github.io/examples/hidden-contenteditable> shouldn't cause native selection UI to pop up.
Wenson Hsieh
Comment 6 2018-11-08 17:31:50 PST
(In reply to Wenson Hsieh from comment #4) > (In reply to Daniel Bates from comment #3) > > (In reply to Simon Fraser (smfr) from comment #2) > > > Don't we have UIScriptController stuff to get selection rects? > > > > Does this tell us the UIView selection rect? This patch is all about > > painting. We want UIKit to know what text is selected. We just don’t want > > UIKit to paint the selection. Show the lollipops or a callout bar. > > See: > > UIHelper.getUISelectionRects() > UIHelper.getSelectionStartGrabberViewRect() > > etc. > > IIRC, there are some examples in editing/selection/ios Oh, do you mean we want to detect when the view is transparent, even if it has a nonzero frame? It seems reasonable to add this functionality to UIScriptController, if what we have now doesn't suffice.
Daniel Bates
Comment 7 2018-11-09 15:41:41 PST
(In reply to Wenson Hsieh from comment #5) > (In reply to Daniel Bates from comment #1) > > Created attachment 354289 [details] > > Patch > > > > I am open to ideas on how to fix this bug as well as suggestions on the > > design in this proposed patch. I was unclear how to write a test for this > > change. > > I had a patch to fix this not too long ago. > Please post your patch!
Daniel Bates
Comment 8 2018-11-09 15:45:46 PST
Created attachment 354397 [details] Layout Tests
Daniel Bates
Comment 9 2018-11-09 15:46:48 PST
Wenson is willing to take over this bug since he has an existing patch. @Wenson: Here are some tests. Feel free to use them or scrap them.
Radar WebKit Bug Importer
Comment 10 2018-11-09 15:47:22 PST
Wenson Hsieh
Comment 11 2018-11-11 21:33:54 PST
Created attachment 354531 [details] WIP (needs tests)
Wenson Hsieh
Comment 12 2018-11-12 21:38:24 PST
Created attachment 354648 [details] First pass
Wenson Hsieh
Comment 13 2018-11-12 21:49:28 PST
Created attachment 354650 [details] Add missing layout test.
Simon Fraser (smfr)
Comment 14 2018-11-13 10:37:20 PST
Comment on attachment 354650 [details] Add missing layout test. View in context: https://bugs.webkit.org/attachment.cgi?id=354650&action=review > Source/WebCore/rendering/RenderObject.cpp:1525 > + if (layerRenderer.style().opacity() < minimumVisibleOpacity) > + return true; Opacity is multiplicative, so ideally you'd multiply it during your tree walk. For example, try ten nested divs with opacity 0.1.
Wenson Hsieh
Comment 15 2018-11-13 10:38:52 PST
Comment on attachment 354650 [details] Add missing layout test. View in context: https://bugs.webkit.org/attachment.cgi?id=354650&action=review >> Source/WebCore/rendering/RenderObject.cpp:1525 >> + return true; > > Opacity is multiplicative, so ideally you'd multiply it during your tree walk. For example, try ten nested divs with opacity 0.1. Oh, good point! I'll multiply on the way up, and add another layout test for this scenario as well.
Wenson Hsieh
Comment 16 2018-11-13 12:25:57 PST
Created attachment 354689 [details] Patch for EWS
Wenson Hsieh
Comment 17 2018-11-13 12:52:41 PST
Created attachment 354691 [details] Patch for EWS
WebKit Commit Bot
Comment 18 2018-11-13 14:30:36 PST
Comment on attachment 354691 [details] Patch for EWS Clearing flags on attachment: 354691 Committed r238146: <https://trac.webkit.org/changeset/238146>
Note You need to log in before you can comment on or make changes to this bug.