Closed Bug 1782981 Opened 2 years ago Closed 2 years ago

Hide the text recognition context menu if the macOS version doesn't support APIs

Categories

(Core :: DOM: Core & HTML, task, P2)

task

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: gregtatum, Assigned: gregtatum)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In older mac OS versions, the context menu will be there, but not work. We need to provide a way to determine if the API is actually available before showing user the option. Right now it's just a platform specific preference.

:emilio I have some fairly simple C++ code to determine if the text recognition APIs are available.

#ifdef XP_MACOSX

bool TextRecognition::IsSupported() {
  return nsCocoaFeatures::OnCatalinaOrLater();
}

#else

bool TextRecognition::IsSupported() {
  return false;
}

#endif

Do you have a recommendation where I can put this? I don't think putting it in dom/webidl/HTMLImageElement.webidl next to recognizeCurrentImageText() is an appropriate place, since I'd have to call out to the content process from the parent process, or create a dummy image element in the parent process.

Do you have a recommendation of where I could wire this up so I can call it from nsContextMenu.js?

Flags: needinfo?(emilio)

ChromeUtils.webidl or nsIXULRuntime.idl (which you can access via Services.appinfo) seem like decent options to put this.

Flags: needinfo?(emilio)

This code path gets executed by existing tests, and I don't believe
there is a way to execute this behavior using our CI, since it's a macOS
version check.

Depends on D153668

Pushed by gtatum@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5f860613e76d
Only show the macOS context menu if it is supported; r=nordzilla
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: