When restoring a tab with "Page Style" to "No Style", the styled page is briefly displayed

NEW
Unassigned

Status

()

--
minor
8 years ago
5 years ago

People

(Reporter: dholbert, Unassigned)

Tracking

(Blocks: 1 bug)

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

8 years ago
STEPS TO REPRODUCE:
 1. Open two tabs. In one, load a long bug page, e.g.:
   https://bugzilla.mozilla.org/show_bug.cgi?id=129941
 2. In View Menu, Page Style submenu, choose "No Style"
 3. Close the tab.
 4. Ctrl+Shift+T to restore the tab.

EXPECTED RESULTS: Page restored with no style. (As it was just before step 3)

ACTUAL RESULTS: While the page is being restored, it's briefly displayed with its styles applied, before the final no-style rendering is settled upon.

Mozilla/5.0 (X11; Linux i686; rv:6.0a1) Gecko/20110501 Firefox/6.0a1
Not a style system bug.  Session restore restores the document and then in the onload handler calls sss_restoreDocument which calls restoreTextDataAndScrolling which does:

  3138     let selectedPageStyle = aBrowser.__SS_restore_pageStyle;
  3154       Array.forEach(aContent.document.styleSheets, function(aSS) {
  3155         aSS.disabled = aSS.title && aSS.title != selectedPageStyle;
  3156       });

which is just broken.  This code should just set the selectedStyleSheetSet on the document as soon as it can, and then things will Just Work.
Component: Style System (CSS) → Session Restore
Product: Core → Firefox
QA Contact: style-system → session.restore
/me didn't write that code

Currently we loop over document.styleSheets to get the enabled one for media=screen|all. Then we look at frames and do the same.
https://mxr.mozilla.org/mozilla-central/source/browser/components/sessionstore/src/nsSessionStore.js#1999

So you're saying we can instead just store document.selectedStyleSheetSet and then set that at some point after load (not waiting for all the way loaded like we do now)?
Severity: normal → minor
OS: Linux → All
Hardware: x86 → All
That's a good question.

The current sessionstore _getSelectedPageStyle code will return the title of the first non-disabled stylesheet with a nonempty title that applies to the screen or all medium... if you ignore media queries, etc.  If media queries are present, it'll screw up.

document.selectedStyleSheetSet will return a string S which has the following property: if there are sheets with titles that are currently enabled, they all have the title S.  If there are no enabled sheets with titles, it will return the empty string.  If there are sheets that are enabled and have different nonempty titles it will return null.

So it has behavior that's pretty different from the current sessionstore behavior.  However I think it's the desired behavior here.

So yes, I think you should just save document.selectedStyleSheetSet (plus whatever you want to do for subframes) and then on restore just assign to selectedStyleSheetSet.  That assignment can happen any time after the document is the document for the page being loaded (as opposed to about:blank); it does not have to wait for load end.  In fact, the earlier the better (because then we will prioritize loading sheets for the "right" stylesheet set over other ones).
You need to log in before you can comment on or make changes to this bug.