Bug 180086

Summary: Alternative Presentation Button: Improve substitution heuristic
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebCore Misc.Assignee: Daniel Bates <dbates>
Status: RESOLVED INVALID    
Severity: Normal CC: bfulgham, ews-watchlist, mjs, rniwa, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=179785
Bug Depends on: 180381    
Bug Blocks:    
Attachments:
Description Flags
Patch and layout test
none
Archive of layout-test-results from ews101 for mac-elcapitan
none
Archive of layout-test-results from ews104 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews114 for mac-elcapitan
none
Archive of layout-test-results from ews123 for ios-simulator-wk2
none
Patch and layout test
none
Archive of layout-test-results from ews102 for mac-elcapitan
none
Archive of layout-test-results from ews105 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews115 for mac-elcapitan
none
Patch and layout test
none
Archive of layout-test-results from ews104 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews100 for mac-elcapitan
none
Archive of layout-test-results from ews125 for ios-simulator-wk2
none
Archive of layout-test-results from ews116 for mac-elcapitan
none
Patch and layout test
rniwa: review+, ews-watchlist: commit-queue-
Archive of layout-test-results from ews103 for mac-elcapitan
none
Archive of layout-test-results from ews105 for mac-elcapitan-wk2
none
Archive of layout-test-results from ews112 for mac-elcapitan
none
Patch for landing none

Daniel Bates
Reported 2017-11-28 09:34:54 PST
Improve substitution heuristic. Currently we may attach the Alternative Presentation Button shadow DOM to an arbitrary element. This approach is problematic when the element that is substituted has an existing shadow DOM or supports an author shadow DOM because the we do not support more than one shadow root per node. There is also a concern that the implementation of some elements may interfere with the Alternative Presentation Button shadow DOM. We should determine a set of elements that behave well ("safe") when the Alternative Presentation Button shadow DOM is attached and change the substitution heuristic to only perform the substitution if the there exists at least one "safe" element in the set of elements to be substituted. <rdar://problem/34916961>
Attachments
Patch and layout test (13.36 KB, patch)
2017-11-30 15:26 PST, Daniel Bates
no flags
Archive of layout-test-results from ews101 for mac-elcapitan (2.16 MB, application/zip)
2017-11-30 16:30 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (2.58 MB, application/zip)
2017-11-30 16:38 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-elcapitan (2.94 MB, application/zip)
2017-11-30 16:44 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews123 for ios-simulator-wk2 (2.30 MB, application/zip)
2017-11-30 16:48 PST, EWS Watchlist
no flags
Patch and layout test (23.23 KB, patch)
2017-12-01 12:46 PST, Daniel Bates
no flags
Archive of layout-test-results from ews102 for mac-elcapitan (2.56 MB, application/zip)
2017-12-01 15:49 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (2.59 MB, application/zip)
2017-12-01 15:56 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews115 for mac-elcapitan (3.21 MB, application/zip)
2017-12-01 16:11 PST, EWS Watchlist
no flags
Patch and layout test (49.48 KB, patch)
2017-12-01 16:13 PST, Daniel Bates
no flags
Archive of layout-test-results from ews104 for mac-elcapitan-wk2 (3.47 MB, application/zip)
2017-12-01 17:34 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews100 for mac-elcapitan (2.22 MB, application/zip)
2017-12-01 17:36 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews125 for ios-simulator-wk2 (2.42 MB, application/zip)
2017-12-01 17:44 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews116 for mac-elcapitan (2.99 MB, application/zip)
2017-12-01 17:44 PST, EWS Watchlist
no flags
Patch and layout test (79.39 KB, patch)
2017-12-04 09:21 PST, Daniel Bates
rniwa: review+
ews-watchlist: commit-queue-
Archive of layout-test-results from ews103 for mac-elcapitan (2.42 MB, application/zip)
2017-12-04 10:22 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (2.64 MB, application/zip)
2017-12-04 10:33 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews112 for mac-elcapitan (3.10 MB, application/zip)
2017-12-04 10:36 PST, EWS Watchlist
no flags
Patch for landing (81.61 KB, patch)
2017-12-06 13:46 PST, Daniel Bates
no flags
Daniel Bates
Comment 1 2017-11-30 15:26:47 PST
Created attachment 328039 [details] Patch and layout test
EWS Watchlist
Comment 2 2017-11-30 16:30:05 PST Comment hidden (obsolete)
EWS Watchlist
Comment 3 2017-11-30 16:30:06 PST Comment hidden (obsolete)
EWS Watchlist
Comment 4 2017-11-30 16:38:52 PST Comment hidden (obsolete)
EWS Watchlist
Comment 5 2017-11-30 16:38:53 PST Comment hidden (obsolete)
EWS Watchlist
Comment 6 2017-11-30 16:44:26 PST Comment hidden (obsolete)
EWS Watchlist
Comment 7 2017-11-30 16:44:27 PST Comment hidden (obsolete)
EWS Watchlist
Comment 8 2017-11-30 16:48:17 PST Comment hidden (obsolete)
EWS Watchlist
Comment 9 2017-11-30 16:48:19 PST Comment hidden (obsolete)
Daniel Bates
Comment 10 2017-12-01 12:46:13 PST
Created attachment 328136 [details] Patch and layout test We likely can simplify the logic for picking the element for alternative presentation in Editor::substituteWithAlternativePresentationButton(), including removing the need to expose Element::canAttachAuthorShadowRoot(). We are still iterating on the algorithm and I want to avoid a programmer error of inadvertently whitelisting an element that can have an author shadow root. Once we finalize the algorithm we will be in a position to determine whether it is necessary to expose Element::canAttachAuthorShadowRoot() to catch such errors. I added more test cases to LayoutTests/fast/forms/alternative-presentation-button/replacement.html and expect the EWS to fail this test. Will grab results from EWS and update patch.
EWS Watchlist
Comment 11 2017-12-01 15:49:03 PST Comment hidden (obsolete)
EWS Watchlist
Comment 12 2017-12-01 15:49:04 PST Comment hidden (obsolete)
EWS Watchlist
Comment 13 2017-12-01 15:56:40 PST Comment hidden (obsolete)
EWS Watchlist
Comment 14 2017-12-01 15:56:42 PST Comment hidden (obsolete)
EWS Watchlist
Comment 15 2017-12-01 16:11:03 PST Comment hidden (obsolete)
EWS Watchlist
Comment 16 2017-12-01 16:11:04 PST Comment hidden (obsolete)
Daniel Bates
Comment 17 2017-12-01 16:13:19 PST
Created attachment 328179 [details] Patch and layout test
EWS Watchlist
Comment 18 2017-12-01 17:34:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 19 2017-12-01 17:34:20 PST Comment hidden (obsolete)
EWS Watchlist
Comment 20 2017-12-01 17:36:51 PST Comment hidden (obsolete)
EWS Watchlist
Comment 21 2017-12-01 17:36:53 PST Comment hidden (obsolete)
EWS Watchlist
Comment 22 2017-12-01 17:44:22 PST Comment hidden (obsolete)
EWS Watchlist
Comment 23 2017-12-01 17:44:24 PST Comment hidden (obsolete)
EWS Watchlist
Comment 24 2017-12-01 17:44:30 PST Comment hidden (obsolete)
EWS Watchlist
Comment 25 2017-12-01 17:44:31 PST Comment hidden (obsolete)
Daniel Bates
Comment 26 2017-12-04 09:21:04 PST
Created attachment 328350 [details] Patch and layout test
EWS Watchlist
Comment 27 2017-12-04 10:22:37 PST
Comment on attachment 328350 [details] Patch and layout test Attachment 328350 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/5488740 New failing tests: fast/forms/alternative-presentation-button/replacement.html
EWS Watchlist
Comment 28 2017-12-04 10:22:39 PST
Created attachment 328358 [details] Archive of layout-test-results from ews103 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-elcapitan Platform: Mac OS X 10.11.6
EWS Watchlist
Comment 29 2017-12-04 10:33:28 PST
Comment on attachment 328350 [details] Patch and layout test Attachment 328350 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/5488818 New failing tests: fast/forms/alternative-presentation-button/replacement.html
EWS Watchlist
Comment 30 2017-12-04 10:33:30 PST
Created attachment 328359 [details] Archive of layout-test-results from ews105 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
EWS Watchlist
Comment 31 2017-12-04 10:36:07 PST
Comment on attachment 328350 [details] Patch and layout test Attachment 328350 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/5488720 New failing tests: fast/forms/alternative-presentation-button/replacement.html
EWS Watchlist
Comment 32 2017-12-04 10:36:09 PST
Created attachment 328361 [details] Archive of layout-test-results from ews112 for mac-elcapitan The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews112 Port: mac-elcapitan Platform: Mac OS X 10.11.6
Ryosuke Niwa
Comment 33 2017-12-04 12:21:44 PST
Comment on attachment 328350 [details] Patch and layout test View in context: https://bugs.webkit.org/attachment.cgi?id=328350&action=review > Source/WebCore/editing/Editor.cpp:3866 > + for (auto* tagName : tagNames) { > + if (element.hasTagName(*tagName)) > + return true; > + } > + return false; Instead of for looping, we should create a NeverDestroyed HashSet. > Source/WebCore/editing/Editor.cpp:3868 > + auto findElementForAlternativePresentation = [&] (const Vector<Ref<Element>>& ancestorElements) { What's the point of having this inner lambda? It would a lot cleaner to have this function as a separate static local function. > Source/WebCore/editing/Editor.cpp:3904 > + // Fix up the the list of elements to hide so that we do not hide the element for alternative presentation. Instead of having a comment like this, it's a lot better to extract a static local function of a descriptive name like elementsToHideExcludingAlternativePresentation. > LayoutTests/fast/forms/alternative-presentation-button/replacement.html:43 > + <a>a</a> You should add a test case with href: <a href=""> By the way, can't we use dump-as-markup.js in these tests? That would make the output a lot more readable & platform independent.
Daniel Bates
Comment 34 2017-12-06 13:46:14 PST
Created attachment 328618 [details] Patch for landing Patch that incorporates the feedback from Ryosuke Niwa. This patch depends on the patch for bug #180381. Otherwise, the layout test fast/forms/alternative-presentation-button/replacement.html will crash due to an assertion failure when executing "document.body.removeChild(testContainer);"
Daniel Bates
Comment 35 2017-12-06 13:47:12 PST
The approach for the alternative presentation button has since changed. This bug is no longer applicable.
Note You need to log in before you can comment on or make changes to this bug.