Closed Bug 1568831 Opened 5 years ago Closed 3 years ago

Make the Eyedropper tool work with oop iframes

Categories

(DevTools :: Inspector, task, P3)

task

Tracking

(Fission Milestone:M7, firefox87 fixed)

RESOLVED FIXED
87 Branch
Fission Milestone M7
Tracking Status
firefox87 --- fixed

People

(Reporter: pbro, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

(Whiteboard: dt-fission-m3-mvp)

Attachments

(3 files)

With Fission and oop iframes in documents, we want the Eyedropper tool to still be able to sample colors from the entire page.

This tool, when it starts, takes a screenshot of the entire page. So this depends on bug 1499845.

Priority: P3 → P2
Whiteboard: dt-fission
Priority: P2 → P3
Whiteboard: dt-fission → dt-fission-reserve

Tentatively moving all bugs whose summaries mention "Fission" (or other Fission-related keywords) but are not assigned to a Fission Milestone to the "?" triage milestone.

This will generate a lot of bugmail, so you can filter your bugmail for the following UUID and delete them en masse:

0ee3c76a-bc79-4eb2-8d12-05dc0b68e732

Fission Milestone: --- → ?

Tracking for Fission Nightly (M6)

Fission Milestone: ? → M6
Type: enhancement → task
Priority: P3 → P2
Whiteboard: dt-fission-reserve → dt-fission-m2-mvp
Priority: P2 → P3
Whiteboard: dt-fission-m2-mvp → dt-fission-m2-reserve

I spent some time investigating this a little bit. Here are my findings. Hopefully they can help fix this bug later.

The new API the EyeDropper should use to capture a screenshot of the page in order to display a magnified version of it that allows selecting colors is drawSnapshot (found on WindowGlobalParent).

This only works from the parent process. However it can draw any frames you want. You just need to call it on the right browsing context.
Here are 2 examples:

  • To draw the inside of the selected tab, you'd do something like this (say, from the browser console): gBrowser.selectedBrowser.browsingContext.currentWindowGlobal.drawSnapshot().
  • However for the entire browser: docShell.browsingContext.currentWindowGlobal.drawSnapshot().

The API requires 3 arguments:

  • The first one is a DOMRect used to determine the position and size of the snapshot, it can be null if you want the entire viewport.
  • the second is the scale.
  • the third is the background color you need.

Example code you can run in the browser console:

var bc = gBrowser.selectedBrowser.browsingContext;

var img = await bc.currentWindowGlobal.drawSnapshot(null, 2, "white")

var c = document.createElement('canvas');
c.width = img.width;
c.height = img.height;
var cx = c.getContext('2d');
cx.drawImage(img, 0, 0);

c.toBlob(blob => {
  var url = window.URL.createObjectURL(blob);
	gBrowser.addTab(url, {triggeringPrincipal: document.nodePrincipal});
  window.URL.revokeObjectURL(url);
})

So, not only would we need to change the code inside this function to use drawSnapshot, but more importantly, we need to change how the EyeDropper itself is used. Right now we always instantiate it in the process the inspector targets. This means inside a normal tab, we end up instantiating the EyeDropper inside a content process, not the parent process. So we can't use drawSnapshot there.

dt-fission-m2-reserve bugs do not need to block Fission Nightly (M6). For now, let's track them for Fission riding the trains to Beta (M7) so we revisit these bugs before we ship Fission.

Fission Milestone: M6 → M7

Some STRs, so it's easily reproducible:

  • Load http://janodvarko.cz/tests/fission/case1/index.html
  • Open DevTools Toolbox and select the Inspector panel
  • Click on the Pipette icon “Grab a color from the page”
  • Try to pick green color from the remote iframe. The Eydroper shows always white color -> BUG

Honza

Has STR: --- → yes
Whiteboard: dt-fission-m2-reserve → dt-fission-m2-reserve, dt-fission-m3-mvp
Whiteboard: dt-fission-m2-reserve, dt-fission-m3-mvp → dt-fission-m3-mvp

Bulk move of all dt-fission-m3-mvp bugs to Fission MVP milestone.

Fission Milestone: M7 → MVP

Comment 3 still applies here, we need to use drawSnapshot in order to retrieve content from remote frame that might be in the page.

Also, we might still keep the actor in a content process and use devtools/server/actors/utils/capture-screenshot.js, since we're going to modify it as well for other screenshot related feature that need to be fixed for fission + remote frame.

This also applies to <object> tags, would that also fall under this bug?

Moving some dt-fission-m3-mvp bugs from Fission MVP to M7 (blocking Beta experiment).

Fission Milestone: MVP → M7
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Depends on: 1690217

The behaviour of the eyedropper is impacted when the page is zoomed-in, but we
didn't have a test for that, so we're adding one here.

Depends on D103877

The current implementation of the eyedropper was using drawWindow, which does
not handle remote frames.
To make the tool fission compatible, we re-use the screenshot-content actor which
do support remote frames. We had to do a few modification on it though so the
eyedropper would work the same as it does at the moment:

  • add a disableFlash property to the screenshot options, so we don't play the
    flash animation for the eyedropper
  • retrieve the page current zoom level from the screenshot-content actor so we
    can adjust the size of the resulting image
  • split the dpr screenshot option into 2 distinct ones:
    • snapshotScale, which will be the scale passed to drawSnapshot. By default,
      this will be the dpr of the window, so the screenshot is as crisp as it can be.
    • fileScale, which will be the scale of the resulting file.
  • we control the fileScale that is sent to the server with the ignoreDprForFileScale
    on the client. This is needed by the eyedropper so it doesn't draw images that are
    too big when the dpr is > 1.

With all those changes, browser_inspector_highlighter-eyedropper-frames.js is passing
with fission enabled, so we can remove the fail-if annotation it had.

Depends on D103878

Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c04b2c82c45c
[devtools] Turn EyeDropper into an class. r=ladybenko.
https://hg.mozilla.org/integration/autoland/rev/259d8d1ed711
[devtools] Add a test for the eyedropper when the page is zoomed-in. r=ladybenko.
https://hg.mozilla.org/integration/autoland/rev/0bfd8c9d71a6
[devtools] Make eyedropper fission compatible. r=ladybenko.
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Regressions: 1691392
See Also: → 1682021
Regressions: 1720371
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: