Bug 180086 - Alternative Presentation Button: Improve substitution heuristic
Summary: Alternative Presentation Button: Improve substitution heuristic
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords: InRadar
Depends on: 180381
Blocks:
  Show dependency treegraph
 
Reported: 2017-11-28 09:34 PST by Daniel Bates
Modified: 2017-12-06 13:49 PST (History)
6 users (show)

See Also:


Attachments
Patch and layout test (13.36 KB, patch)
2017-11-30 15:26 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
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 Details
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 Details
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 Details
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 Details
Patch and layout test (23.23 KB, patch)
2017-12-01 12:46 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
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 Details
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 Details
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 Details
Patch and layout test (49.48 KB, patch)
2017-12-01 16:13 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
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 Details
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 Details
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 Details
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 Details
Patch and layout test (79.39 KB, patch)
2017-12-04 09:21 PST, Daniel Bates
rniwa: review+
ews-watchlist: commit-queue-
Details | Formatted Diff | Diff
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 Details
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 Details
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 Details
Patch for landing (81.61 KB, patch)
2017-12-06 13:46 PST, Daniel Bates
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 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>
Comment 1 Daniel Bates 2017-11-30 15:26:47 PST
Created attachment 328039 [details]
Patch and layout test
Comment 2 EWS Watchlist 2017-11-30 16:30:05 PST Comment hidden (obsolete)
Comment 3 EWS Watchlist 2017-11-30 16:30:06 PST Comment hidden (obsolete)
Comment 4 EWS Watchlist 2017-11-30 16:38:52 PST Comment hidden (obsolete)
Comment 5 EWS Watchlist 2017-11-30 16:38:53 PST Comment hidden (obsolete)
Comment 6 EWS Watchlist 2017-11-30 16:44:26 PST Comment hidden (obsolete)
Comment 7 EWS Watchlist 2017-11-30 16:44:27 PST Comment hidden (obsolete)
Comment 8 EWS Watchlist 2017-11-30 16:48:17 PST Comment hidden (obsolete)
Comment 9 EWS Watchlist 2017-11-30 16:48:19 PST Comment hidden (obsolete)
Comment 10 Daniel Bates 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.
Comment 11 EWS Watchlist 2017-12-01 15:49:03 PST Comment hidden (obsolete)
Comment 12 EWS Watchlist 2017-12-01 15:49:04 PST Comment hidden (obsolete)
Comment 13 EWS Watchlist 2017-12-01 15:56:40 PST Comment hidden (obsolete)
Comment 14 EWS Watchlist 2017-12-01 15:56:42 PST Comment hidden (obsolete)
Comment 15 EWS Watchlist 2017-12-01 16:11:03 PST Comment hidden (obsolete)
Comment 16 EWS Watchlist 2017-12-01 16:11:04 PST Comment hidden (obsolete)
Comment 17 Daniel Bates 2017-12-01 16:13:19 PST
Created attachment 328179 [details]
Patch and layout test
Comment 18 EWS Watchlist 2017-12-01 17:34:18 PST Comment hidden (obsolete)
Comment 19 EWS Watchlist 2017-12-01 17:34:20 PST Comment hidden (obsolete)
Comment 20 EWS Watchlist 2017-12-01 17:36:51 PST Comment hidden (obsolete)
Comment 21 EWS Watchlist 2017-12-01 17:36:53 PST Comment hidden (obsolete)
Comment 22 EWS Watchlist 2017-12-01 17:44:22 PST Comment hidden (obsolete)
Comment 23 EWS Watchlist 2017-12-01 17:44:24 PST Comment hidden (obsolete)
Comment 24 EWS Watchlist 2017-12-01 17:44:30 PST Comment hidden (obsolete)
Comment 25 EWS Watchlist 2017-12-01 17:44:31 PST Comment hidden (obsolete)
Comment 26 Daniel Bates 2017-12-04 09:21:04 PST
Created attachment 328350 [details]
Patch and layout test
Comment 27 EWS Watchlist 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
Comment 28 EWS Watchlist 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
Comment 29 EWS Watchlist 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
Comment 30 EWS Watchlist 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
Comment 31 EWS Watchlist 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
Comment 32 EWS Watchlist 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
Comment 33 Ryosuke Niwa 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.
Comment 34 Daniel Bates 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);"
Comment 35 Daniel Bates 2017-12-06 13:47:12 PST
The approach for the alternative presentation button has since changed. This bug is no longer applicable.