Open Bug 1137699 Opened 11 years ago Updated 1 year ago

[meta] Media query emulation

Categories

(DevTools :: General, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: ntim, Unassigned)

References

(Depends on 9 open bugs, Blocks 1 open bug)

Details

(Keywords: meta)

Media queries like : print, orientation, scan, ... should be able to be emulated. Code for the GCLI media command : http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/gcli/commands/media.js
Severity: normal → enhancement
Priority: -- → P3
Product: Firefox → DevTools
Depends on: 1477920
No longer depends on: 1589720
Depends on: 1592284
Depends on: 1591535
Depends on: 1534984
Depends on: 1591537
Depends on: 1591539
Depends on: 1651400
Depends on: 1692434
Severity: normal → S3
Depends on: 1822185
Depends on: 1824481
Depends on: 1827605

I imagine the emulation to work similar across media features, i.e. a shortcut that explicitly sets the value of the feature overwriting its actual value.
As far as I can tell, there is currently no uniform API to add such emulation functionality when implementing new media features.

Would it be possible to create a centralized way for emulations on the platform side, making it easier for the DevTools to add those features?

Sebastian

Flags: needinfo?(odvarko)
Flags: needinfo?(emilio)

How would that look like exactly? Different media features have different requirements: Some should affect only the top browsing context, some should affect only one document, some should affect all the subtree...

In general following the pattern of MediumOverride etc seems like it shouldn't be a lot of code per feature?

Flags: needinfo?(emilio)
Flags: needinfo?(odvarko)
Whiteboard: [devtools-triage]

I am turning this into a meta. There is already quite a few dependants and this feature represents significant amount of work on our side.

Honza

Keywords: meta
Summary: Media query emulation → [meta] Media query emulation
Whiteboard: [devtools-triage]
Type: enhancement → task

(In reply to Emilio Cobos Álvarez (:emilio) from comment #3)

How would that look like exactly? Different media features have different requirements: Some should affect only the top browsing context, some should affect only one document, some should affect all the subtree...

In general following the pattern of MediumOverride etc seems like it shouldn't be a lot of code per feature?

Note that the reasoning behind my suggestion is to make it easier to implement those emulations and allow the implementation of the emulation alongside the implementation of a new media feature. I.e. allow the DevTools to catch up with media feature implementations.

My knowledge of the code is very limited, though I see several places where overrides are defined like MediumOverride and PrefersColorSchemeOverride.

The idea is to have a central mechanism for the different media features that first checks a registry whether there's an explicit value set before their normal evaluation.
There would then be a central way for the DevTools to set and reset media feature overwrites in that registry. I imagine a InspectorUtils.setMediaFeatureOverride() that takes the media feature and an (optional) value, e.g. InspectorUtils.setMediaFeatureOverride('prefers-color-scheme', 'darK'), InspectorUtils.setMediaFeatureOverride('print'), or InspectorUtils.setMediaFeatureOverride('resolution', '150dpi').
To complement that there'd need to be a InspectorUtils.unsetMediaFeatureOverride() and a InspectorUtils.unsetAllMediaFeatureOverrides().

If that sounds reasonable, I'm happy to file bugs for that.

Sebastian

You need to log in before you can comment on or make changes to this bug.