Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GrabToPan] Prefer the standard, rather than a prefixed, matchesSelector value #13142

Closed

Conversation

Snuffleupagus
Copy link
Collaborator

Given how these checks are currently implemented, they will always prefer the prefixed versions over the standard one which does seem quite unfortunate.
This looks especially bad in MOZCENTRAL-builds, since Firefox nowadays support a number of webkit-prefixes/methods to improve web-compatiblity, where we thus end up using webkitMatchesSelector.

To address this I'm thus proposing that we simply reverse the order in which we check for the matchesSelector value, which according to the following compatibility information ought to work fine in general:
https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#browser_compatibility

Given that `matchesSelector` isn't necessary until `GrabToPan` is both enabled *and* used, it doesn't seem necessary to run this code unconditionally.
…ctor` value

Given how these checks are currently implemented, they will *always* prefer the prefixed versions over the standard one which does seem quite unfortunate.
This looks especially bad in MOZCENTRAL-builds, since Firefox nowadays support a number of `webkit`-prefixes/methods to improve web-compatiblity, where we thus end up using `webkitMatchesSelector`.

To address this I'm thus proposing that we simply *reverse* the order in which we check for the `matchesSelector` value, which according to the following compatibility information ought to work fine in general:
https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#browser_compatibility
/**
* @private
*/
get _matchesSelector() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could perhaps even add a fast-path for MOZCENTRAL here, e.g. as outlined below, however given that this code no longer runs unconditionally that's probably not necessary.

if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
  return shadow(this, "matchesSelector", "matches");
}

@Snuffleupagus
Copy link
Collaborator Author

[...] which according to the following compatibility information ought to work fine in general:
https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#browser_compatibility

Actually, looking at that table a bit closer now, I'm starting to wonder if we could simply remove the matchesSelector logic altogether and just use Element.matches() directly!?

@Snuffleupagus Snuffleupagus marked this pull request as draft March 25, 2021 19:20
@Snuffleupagus
Copy link
Collaborator Author

Closing in favour of PR #13144.

@Snuffleupagus Snuffleupagus deleted the GrabToPan-matchesSelector branch March 25, 2021 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant