media="print" attribute on <link> fails when media="screen" used

RESOLVED INVALID

Status

()

Core
CSS Parsing and Computation
RESOLVED INVALID
16 years ago
15 years ago

People

(Reporter: Rich Doughty, Assigned: dbaron)

Tracking

({qawanted})

Trunk
qawanted
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.8) Gecko/20020204
BuildID:    2002020406

both the media="print" stylesheets that are attached to the page fail to render
either when selected via View->Use Stylesheet or when the doc is printed.

Instead a document with no styles attached is printed.

NOTE:
The print works when the media="screen" <link> elements are omitted.


Reproducible: Always
Steps to Reproduce:
1. Choose grey screen stylesheet and advanced print stylesheet on the form
2.submit the form. the look should be "grey".
3.print preview. 

Actual Results:  The doc shown has no styles attached. IE5.x and opera6 behave
as expected.

Expected Results:  the doc should have a a margin line, be mainly white like this:

http://www.richdoughty.net/bugzilla/home_print.htm

This page has the reference to the other stylesheets removed. print preview and
it works.


Does this come under the umbrella of Bug 72321 ?
(Assignee)

Comment 1

16 years ago
This is related to the fact that we use an entirely new styleset for printing. 
We probably need some parts to be shared and some parts to be new -- perhaps it
needs to be split into two objects or part moved to another object.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Ok... there are two separate issues here:

1)  View menu.  We show alternate sheets that are print-medium-only in the view
    menu.  When these are selected, they are enabled but still not applied since
    we are in the wrong medium.  It seems to me that we don't want to show
    sheets that don't apply to the screen medium in print preview.
2)  Printing.  Here the problem is that there are two preferred sheets with
    different titles in that document -- one for print media and one for screen
    media.  The HTML spec does not really clarify what should happen in that
    situation; the language there seems to assume that there is one and only one
    preferred sheet.  It would make _sense_ for the screen preferred sheet to be
    default in the screen medium and the print preferred sheet to be default in
    the print medium, but I'm not sure what we should actually be doing there...

We should focus this bug on one of those two issues and file a separate bug on
the other one.
OS: Windows 98 → All
Hardware: PC → All
(Reporter)

Comment 3

16 years ago
1) The view menu functionality wasn't really what i had in mind when I reported
this. personally I only use it for debugging :-)

2) This is what I was getting at. Opera and IE both use the media="screen" for
browser rendering and media="print" when printed.

this behaviour makes most sense IMHO.

one thing, why does it make a difference whether the stylesheet is titled or not? 
A titled stylesheet is one of a set of alternate stylesheets. Only one of a set
of alternates can be applied at once.

An untitled stylesheet a persistent sheet.  It is always applied (whenever one
is in the correct medium).

Maybe we should consider having separate lists of alternates for separate media
or something.... Right now we only have a single alternate list of mutually
exclusive sheets.  I'm not sure what the HTML spec is really saying here, if
anything....  Ian?

Bug 129884 filed on the side issue with the "Use Stylesheet" menu.
Keywords: qawanted
(Reporter)

Comment 5

16 years ago
http://www.w3.org/TR/html4/present/styles.html#h-14.3.1

The spec seems pretty clear on this. I think this boils down to my misuse of the
title attribute. I've a feeling Moz is right on this one...
Agreed. Changing the preferred stylesheet based on the media attribute is not
correct per HTML4. It will also make things even more complicated once media
queries come about and whether a stylesheet applies depends on more than just a
string comparison.

I think it's up to the author to provide stylesheets that cover the various
media for each alternate stylesheets set. Lack of an explicit stylesheet is
still a valid stylesheet -- it just means "use the UA's values". If you switch
to a different media you're going to want to be using the same stylesheet set.
How would the author specify that the "print" version of an alternate stylesheet
set was the UA's defaults, otherwise?
(Reporter)

Comment 7

16 years ago
I'll update my site then (eventually).

apologies for the spam :-/
at least i know about stylesheet sets now ;-)

Comment 8

16 years ago
This sounds like not-a-bug (i.e., INVALID), then, but lemme make sure I'm
on the same page (so to speak), first:

If you want one stylesheet for viewing on the screen (screen.css) and a
different stylesheet for printouts (print.css), you can link to them with

  <link type="text/css" rel="stylesheet" media="screen" href="screen.css"/>
  <link type="text/css" rel="stylesheet" media="print" href="print.css"/>

being sure to use no title="" tags so they always get applied when the
media matches.  Then for browsing, the screen one gets applied, for printing
the print one gets applied, the user doesn't even know there are stylesheets
at work, and everybody's happy.  Right?

This seems to work for me in Mozilla, and also in IE5.1/Mac (modulo some
apparent IE printing bugs), so I'm inclined to think it's correct...
Ken, that's correct.

Marking invalid, since everyone seems to agree that our behavior is the right one...
Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID
(Assignee)

Comment 10

16 years ago
What about comment 6?
What about it?  It seems to be saying that what we do is correct...

Comment 12

15 years ago
*** Bug 183724 has been marked as a duplicate of this bug. ***
I'm confused.  HTML4.01:14.3.1 clearly states:

"User agents must respect media descriptors when applying any style 
sheet."

It seems clear to me that means that even a preferred style sheet should 
apply to the medium for which it's intended.  In other words, I don't see 
why we're ignoring the media descriptor when HTML4.01 says we must 
respect it in all cases.
(Assignee)

Comment 14

15 years ago
We're respecting it by not applying the stylesheet.  However, the algorithm for
choosing the preferred set doesn't consider media attributes, so the preferred
set has no sheets that apply when the medium is screen.
We aren't ignoring it.  We're following it... That's why the style rules are not
applied.

Compare these two situations (lots of needed attrs left out for clarity):

<link title="bar" media="print" href="one">
<link title="foo" media="screen" href="two">

and

<link title="bar" media="print" href="one">
<link title="foo" media="screen" href="two">
<link title="bar" media="screen" href="three">

What style sets should be applied (which is _not_ the same thing as what sheets
should be applied in each style set).
Ah, I see.  I was indeed confused.  Sorry about the spam.

Comment 17

15 years ago
*** Bug 198778 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.