Open Bug 1429662 Opened 7 years ago Updated 2 years ago

[feature] Allow the possibility to switch to standard mode or change the doctype

Categories

(DevTools :: Inspector, enhancement, P2)

58 Branch
enhancement

Tracking

(Not tracked)

People

(Reporter: karlcow, Unassigned)

References

(Blocks 1 open bug)

Details

1. Go to a Web site with a document without a doctype 2. Go to the inspector 3. contextual menu on <html> and Edit as HTML. 4. add a <!doctype html> 5. validate the change. Expected: doctype is added and the page reparsed Actual doctype is ignored. Why is it important? Some layout issues are created because the browser is or is not in standard mode. Having an easy way to check that would be good. Either by injecting the right doctype as explained above. Or by activating the mode with a checkbox. [side comment: Probably would be interesting also for the developers to know that they are not in standard mode. Warning in the console that it might affect the layout?]
Thanks for filing Karl. (In reply to Karl Dubost :karlcow from comment #0) > Some layout issues are created because the browser is or is not in standard > mode. Having an easy way to check that would be good. Either by injecting > the right doctype as explained above. Or by activating the mode with a > checkbox. I think we could try using the document.implementation.createDocumentType() API for this. But I've not managed to make this work yet. For instance, if I try with a document that doesn't have a doctype, and I then insert one with: let newDocType = document.implementation.createDocumentType("html", "", ""); document.insertBefore(newDocType, document.documentElement); Then that does nothing. It doesn't seem to change the way Firefox renders the page. So, to me, this says that once a page has been rendered, we can't change its mode. Now instead, maybe we could add code that allows us to reload it in a special mode where DevTools can tell which doctype to use. @Ryan: do you think that's something that might be possible? > [side comment: Probably would be interesting also for the developers to know > that they are not in standard mode. Warning in the console that it might > affect the layout?] I agree. This is tracked in bug 1238861.
Flags: needinfo?(jryans)
Severity: normal → enhancement
Priority: -- → P3
(In reply to Patrick Brosset <:pbro> from comment #1) > So, to me, this says that once a page has been rendered, we can't change its > mode. > > Now instead, maybe we could add code that allows us to reload it in a > special mode where DevTools can tell which doctype to use. > @Ryan: do you think that's something that might be possible? Seems like your instincts are correct... The page's compat mode (based on doctype) gets set very early during parsing. There is some support for the compatibility mode changing over time[1] but it seems like all callers of that still happen quite early on. It's unclear to me if triggers it after a page is fully parsed and displayed would have the same effect as forcing it some value from the start of parsing. Anyway, we could add an override mode to the docShell (similar to what RDM does for the UA, touch events, etc.) set by DevTools and force the platform to use that instead. I'm just not sure yet if a page reload would be needed for it to take effect. Depends on whether `CompatibilityModeChanged`[1] can fully reverse the effects of the mode change. [1]: https://searchfox.org/mozilla-central/rev/062e1cf551f5bf3f0af33671b818f75a55ac497b/dom/html/nsHTMLDocument.cpp#870
Flags: needinfo?(jryans)
Product: Firefox → DevTools
Priority: P3 → P2
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.