Skip to content

[css-page-3] Add orientation descriptor #4491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chrishtr opened this issue Nov 6, 2019 · 33 comments
Closed

[css-page-3] Add orientation descriptor #4491

chrishtr opened this issue Nov 6, 2019 · 33 comments
Labels
css-page-3 Current Work

Comments

@chrishtr
Copy link
Contributor

chrishtr commented Nov 6, 2019

TL;DR
Add the ability to rotate the rendered output of a page, for use in cases such as PDF output, and as a hint to printing code & devices.

Details
Currently, the level 3 paged media spec has a size property. This specifies the per-page constraints on layout.

It would be useful to also have an orientation descriptor, which could have values of portrait and landscape (*). This indicates the orientation of the final rendered page itself, without affecting layout. For example, if content had:

size: letter landscape
orientation: portrait

It would mean to layout the content in landscape layout mode, but then rotate the resulting rendered page sideways. If the print ended up in a PDF, then a user viewing the PDF would see the page visually rendered with height taller than width, and the content rotated 90 degrees.

This is useful in order to customize the visual display of a PDF, which is a very common way to "print" web pages.

(*) Alternatively, it could have three (four?) values: none, rotate-right, rotate-left (, upside-down?)

@xfq @fantasai

@xfq xfq added the css-page-3 Current Work label Nov 7, 2019
@heycam
Copy link
Contributor

heycam commented Dec 11, 2019

No strong opinion on the proposal here. This would map directly to the Rotate entry on the page object in the resulting PDF I guess? (I looked up Prince's documentation expecting there to be some -prince-prefixed way to control this but I couldn't find anything.)

@faceless2
Copy link

faceless2 commented Dec 11, 2019

Printing devices will all rotate the pages to fit the available media anyway, they won't need the hint. Yes, if we were implementing this we'd map to the Rotate entry on the PDF Page object, which can take any multiple of 90 as a valid value.

Presumably the intention here is to try and get all the pages the same size on screen? So if you have a single landscape page halfway through a document, for example, you can rotate it to make it visually the same dimensions as the rest of the document? I can see an argument for that - it would help PDF viewers to choose the initial display settings fo the document. But I can't think of any other reason for this myself.

If that's the intention then I personally prefer "orientation: portrait", which could leave pages that are originally portrait pages untouched and rotate only landscape pages, over "orientation: 90" or "orientation: rotate-right"

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-page-3] Add orientation descriptor.

The full IRC log of that discussion <dael> Topic: [css-page-3] Add orientation descriptor
<dael> github: https://github.com//issues/4491
<fantasai> Issue for use cases at https://github.com//issues/4585
<dael> chrishtr: Way to rotate page w/o changing layout. Different rotation in PDF is the use case. Intended is to set rotate descriptor in PDF.
<dael> florian: Wouldn't do anything if print to actual paper?
<dael> chrishtr: Right
<dael> florian: Sure
<fremy> sounds useful
<dael> TabAtkins: Reasonable to me. Not sure if it's better to do explicit direction keywords or portait. Happy to advance
<dael> florian: Suspect picking direction is useful
<dael> chrishtr: I can imagine left or right depending on visual preference
<dael> florian: If you're not controlling...no, I guess MQ. If you don't decide if the whole should be portrait or landscape you can use MQ to decide a section
<dael> fantasai: I don't think prtrait vs landscape is sufficient b/c you might want to rotate +90 or -90. You want to rotate entire page
<dael> dbaron: This would be clearer with examples as to what is and isn't rotated
<dael> florian: No effect to layout, just set a flag in PDF
<dael> dbaron: Not just that. Could use examples saying this pair of size and oritentation should look like this. In terms of what PDF looks like vs page and content orientation
<dael> chrishtr: I can add example
<dael> AmeliaBR: Would be helpful. I think...visually for me is a PDF mostly portait and we want to display a page in landscape or is it that page is layout in landscape but display as portrait. Which cases?
<dael> fantasai: Things relevent here is reltationship of content to page box. Headers and footers to page box. Orientation of page box itself.
<dael> fantasai: I can interpret this is 2 ways. Only changes oritientation of page, but header is still at top or it layouts entire content incl. header and then rotates. I'm not sure about it.
<dael> florian: Some section sin landscape can handle with page sizing. Don't need something to change aspect ratio of some pages
<dael> AmeliaBR: But having headers match other pages is the missing
<fantasai> The landscape keyword on size doesn't affect orientation
<dael> florian: I thought it was print the 3rd page rotated 90deg. Examples would help
<fantasai> it's a shortcut for sizing
<dael> chrishtr: That's what I intended. Hand't thought detail on header/footer
<florian> s/print the 3rd page rotated 90deg/print normally, then physically rotate the 3rd piece of paper/
<dael> Rossen_: Intended for anything outside page. Could this be used in regular HTML? Thinking of ePub where people might want similar control. Why is this PDF specific?
<fantasai> Not PDF-specific, but @page specific
<dael> Rossen_: Kinda goes back to lack of examples. What is this intended to solve? I clearly hear PDF. I don't believe we want per page control. In summary it goes back to getting clearer examples in proposal
<myles> q+
<Rossen_> ack fantasai
<dael> fantasai: I want to clarify landscape keyword on size is just a shortcut to say I want 11x8.5. Please don't confuse orientation with that keyword.
<dael> fantasai: Second point, I think we want it to apply to more than PDFs. Proposal is descriptor on @page rule which talks about page box for paged media.
<dauwhe> q?
<dael> florian: I think it applies to most but not all paged media. Doesn't apply to paper b/c if you're printing to paper how you position the pages is out of our control. But if you're in a PDF that's different b/c renderer can decide how to layout pages.
<dael> fantasai: In terms of some pages oriented one way vs another we have a feature that allows us to assign content to different types of pages. This section is on legal where rest is on letter. An orientation descriptor lets you do somehting similar where this chapter is landscape. That falls from existing fucntionality
<dael> TabAtkins: It is appriclable to paper. Controlling which direction the landscape grapth is in a paper book is worthwhile. Printer will auto rotate but if you have it oriented you stick with that.
<dael> florian: I was thinking of home printer, but yes if you're binding that makes sense
<dael> myles: You guys said much of what I would say. We have a size descriptor already. If goal is to let your big table be printing on landscape you can do that. only value is what TabAtkins said where for printed context it tells the printer what to do. For PDF it's no effect b/c you can do the use case. Only way this makes sense if if it's no effect on PDFs
<Rossen_> ack myles
<dael> TabAtkins: Makes sense ofr PDF. If layout in landscape but want to display PDF as portrait you can do that
<dael> AmeliaBR: Overrides the default PDF view where if it's landscape it displays landscape. Forces to show in the printed book fasion
<dael> myles: Why would anyone want that?
<dael> TabAtkins: DnD books for example that have a wide table. Page is pointed vertically. Want to have PDF match look of book is reasonable
<dael> myles: Don't have have to turn your computer to read it?
<dael> TabAtkins: Sure
<dael> AmeliaBR: Other case of content in landscape but headers in portrain you can do with writing mode
<dael> florian: Can't do by page can you?
<dael> AmeliaBR: You can say this section has vertical writing mode and that effects content
<dael> TabAtkins: As we come to end of hour, seems like some disagreements about when applicable. Seems reasonable to do. Open question as to if it changes header position. Good to look at use cases to see which the use cases prefer. If it's mixed we can look at a switch
<dael> florian: So if page margin boxes areorthogonal to content
<dael> fantasai: yes
<dael> florian: Can't you do that with writing modes?
<dael> fantasai: Yes
<dael> Rossen_: chrishtr will you add the use cases? Or TabAtkins ?
<dael> TabAtkins: I volunteer chrishtr are tribute
<dael> fantasai: It's not just page margin boxes this effects Question is do we disassociate content from the concept of t/b/l/r from the page's concept or are we rotating the whole page? Does that oage's concept of t/b/l/r match the content's
<dael> TabAtkins: Don't think can lay out a top margin box that would layout as a tall skinny thing. Need to know if layout into tall skinny or squat wide.
<dael> fantasai: Separate thing
<dael> florian: My udnerstanding is it rotates the whole page. And then use writing modes etc to make changes
<dael> fantasai: Prop easiest
<astearns> s/are tribute/as tribute/
<fantasai> I think also we agree that 'orientation' should take 4 orientations, not just landscape/portrait
<dael> Rossen_: We're at the hour please add thoughts to the issue.
<dael> Rossen_: We've got 2 issues left that we'll start with next week
<fantasai> and probably should use syntax consistent with 'image-orientation' even though it's awkward

@AmeliaBR
Copy link
Contributor

An example of the case of rotated content within portrait page layout. Again, I think this is handled by writing-mode on the rotated table:

Screenshot of two PDF pages: left page has regular horizontal text, right page has a large table rotated. Footers and margins are the same in both.

@AmeliaBR
Copy link
Contributor

In contrast, the use case being discussed here is where the complete layout of certain pages (headers/footers, and any margins defined for the page) uses a different orientation from the rest, but you want to display all the pages oriented as they would come out of the printer. As Tab says, this would also ensure that when printing & binding they are oriented as intended. (And therefore, the property would need to distinguish between rotated clockwise vs counterclockwise!)

But… I couldn't find any good examples of that type of PDF in a quick poke around my computer.

@AmeliaBR
Copy link
Contributor

I thought of another use case: imagine the book layout above, with headers/footers in portrait mode, since that looks best for printing. But for viewing the digital file, it would be much more useful if the PDF pages were displayed in landscape mode, so that the table isn't sideways on your screen.

How would that work with these new descriptors?

@faceless2
Copy link

This sort of thing (lets call this "image 2")?

twoup

I had a look. We have thousands of PDF here but I have struggled to find an example of what this issue describes it's trying to achieve. Generally, if you have a landscape page in the middle of a generally portrait document, it's displayed as landscape.

The idea in Amelias third comment, immediately above, is more common: the page has been laid out entirely in portrait, but with some of the content sideways. You then want to rotate that page from portrait to landscape to get it the right way up, like this one (lets call this "image 3"):
twoup2

@Crissov
Copy link
Contributor

Crissov commented Dec 11, 2019

I can think of a surprisingly well-known case where the original viewing condition of the medium is portrait (or spread), but for special pages, the medium needs to be rotated by a quarter-turn although the viewing mode and page layout remains portrait: centerfolds. In some cases, i.e. gatefolds, they are not folded at all, but a magazine with A4-spread has an full-sheet A3 poster in the middle.

Is that covered by this issue?

@astearns astearns removed the Agenda+ label Dec 17, 2019
@chrishtr
Copy link
Contributor Author

Sorry for the long delay, I got caught up in many other issues.

TL;DR:

Introduce a new orientation descriptor. It has three values: default, rotate-right, and rotate-left. In the case of PDF output, it is expected to map directly to the Rotate PDF command.

Purpose: apply rotation to PDF output in cases where the most important content has a different orientation than the one from layout.

Semantics: the entire content of the page is rotated when orientation is applied, including headers and footers and margins. Layout of the page contents, including aspects such as mixed orientation or writing mode, is unaffected.

In cases where page content has mixed orientation, such as headers and footers differing from page contents rotation, this will result in the header being drawn "sideways" in a PDF display, but as mentioned in the use-case analysis below, this is desirable.


Detailed comments below.

Some printing folks in Chrome also looked through various data sets and found examples similar to the ones mentioned in previous comments. They also didn't find examples of the entire page rotating with headers, without already drawing the content in a layout PDF page. Instead, it can be common to have content whose internal sizing fits better to landscape than portrait, so as to have two rotations in the same page. The reasons include:

  1. tabular data that is better presented with those dimensions
  2. large images that are wider than they are tall
  3. bitmaps generated by an external formatting system, such as an advanced word processor, or external offline or "legacy" system that generates content

In addition, the headers and footers often have orientations that conflict with the orientation of the content, because the printed page is meant to be presented in a book or pamphlet with a single orientation for each page. The reader of the book is expected to turn it when reading the rotated sub-content.

The original motivation for filing this issue was use case 3. In particular, a word processor such as Google Docs has a different layout and formatting system than the web, and for these reasons performs its own layout and may even draw the results to Canvas instead of DOM elements. On top of this, such "web-based" word processors can often support page sizings that are more advanced or specialized than the user agent's. (*)

(*) Examples: Chromium and WebKit only have limited support for variable-size/shape pagination. OTOH, a word processor often wants to be able to print mixed page sizes and orientations. Regardless, however, it's easy to see that there are plenty of offline, legacy or otherwise non- "web-based" word processors or content generation systems that are unable to generate DOM output, but that nevertheless benefit from being integrated into web content for viewing or printing.

@tabatkins
Copy link
Member

So just to ensure I'm understanding this right:

I have a paged document that's mostly portrait, but I've got a wide table on one page that is best displayed landscape. I set up my @page rules appropriately for this, so the table will break onto a size: landscape; page on its own.

When viewed as a PDF, every page flows vertically, as normal for English, and the headers and footers on every page agree with the flow of the content - on the portrait pages, @top is along the shorter edge; on the landscape pages, @top is along the longer edge.

When printed, because the printer doesn't reorient the sheets of paper internally, they'll all be arranged portrait-style in the printed stack, and the landscape pages (both the content and the margin areas) will be "sideways", with the reader expected to turn the entire book to read those pages.

So this orientation descriptor can be used to force the PDF rendering to conform to that of the printed rendering, right? On all my landscape pages, I can set orientation to "rotate-left" or "rotate-right" depending on whether the page is :left or :right, and it'll render exactly as it would in the stack-of-paper.

That's the intended behavior?

@chrishtr
Copy link
Contributor Author

So this orientation descriptor can be used to force the PDF rendering to conform to that of the printed rendering, right? On all my landscape pages, I can set orientation to "rotate-left" or "rotate-right" depending on whether the page is :left or :right, and it'll render exactly as it would in the stack-of-paper.

It's the other way around. As far as the layout engine of the browser would be concerned, each page has a base layout size of portrait, and would be laid out accordingly. Therefore, without an orientation descriptor, the tabular pages would look sideways be hard to read. With orientation, the PDF output would know to rotate that page to the preferred orientation of the most important (i.e. the tabular) content.

@tabatkins
Copy link
Member

Okay, so the case is that the thing assembling the pages knows how to produce a page of content that's "sideways" (landscape-oriented content, but using size: portrait); the margins are then all portrait-oriented (@top along the short edge), regardless of the page content's orientation.

Then, for the purpose of viewing in a browser, you can set orientation on the "sideways" pages to flip them into landscape, so they're easier to view as a PDF; the margins are then "sideways" (still along the shorter edge) but that's less important than making the page viewable without rotating your head or your device 90deg.

Okay, so I accept this as being a reasonable solution for your case 3 (legacy system outputting portrait-oriented bitmaps for pages), but it's completely backwards for cases 1 (wide table) and 2 (wide image), which both want to use size: landscape on those pages during layout; they just want the margins to be portrait-oriented instead, so that during printing (when all the pages are arranged portrait-oriented) all the margin boxes are consistent. As currently described, they instead have to use an ordinary size: portrait page, but set writing-mode to a vertical value, which is a hacky thing to do in horizontal text.

It also means that we're privileging the "view as printed/bound" case over the "view on the web" cases, requiring the author to know they have to intervene with the orientation property to get the page content to display correctly on the web (or PDF). I think we should be doing the opposite, and making web-viewing correct by default (that is, using size: landscape on landscape pages), and then have this feature be able to set the margins to the intended orientation. Tooling (like Docs) trying to use this feature can output either way, so optimizing for them doesn't matter here.

So I think it should instead be pointed as a margin-orienting feature, like margin-orientation: default | rotate-left | rotate-right, with rotate-left meaning that the margin boxes are all rotated to the left and laid out that way (so @top is along the left side of the page, and laid out like vertical-lr), etc. This would also inform printing software to use the same rotation for the entire page by default, so that the margin boxes are consistent across pages.

Then the "legacy tools output portrait-oriented bitmaps" would use this by putting the intended-landscape image on a size: landscape page, hopefully with the image produced landscape to start with (or at worst, using image-orientation to rotate the portrait image into landscape), and then margin-orientation: rotate-* to indicate which shorter side should be the "top" when printing.

Thoughts?

@chrishtr
Copy link
Contributor Author

It also means that we're privileging the "view as printed/bound" case over the "view on the web" cases

The orientation descriptor is just for printed output. I think it's ok to have a few CSS properties that are just for controlling printing. Printing is part of the web after all. These orientation descriptors should only be within an @media print section.

For a "view on the web" mode of the same site, if there is content that is best viewed with a landscape aspect ratio, then the site should just lay out the content in a landscape manner; there are many ways to do that already. What is different about printing (or PDF viewing) is that there is a physical or virtual page that is external to the web on which content is printed. The system that might view a PDF can't re-do layout, it can only rotate around the page.

Then the "legacy tools output portrait-oriented bitmaps" would use this by putting the intended-landscape image on a size: landscape page

In addition to my other arguments about why this is not the best way to do it, there is a very practical one, which I alluded to in my previous comment when I said the "limited support". To support size: landscape properly without violating specs is very difficult, and a multi-year project for Chromium. I'm presuming the same is true of other UAs to greater or lesser extent.

@chrishtr
Copy link
Contributor Author

What is different about printing (or PDF viewing) is that there is a physical or virtual page that is external to the web on which content is printed. The system that might view a PDF can't re-do layout, it can only rotate around the page.

Also, in the use cases I mentioned, there is an explicit need for the printed output on paper to differ from an "expected view rotation" when viewed digitally in a PDF viewer.

@faceless2
Copy link

The only use-case described so far seems to be to "undo" the layout decisions made by some layout engines that rotate landscape content into a portrait format. Have I understood that correctly?

Are there any use-cases for this property beyond that? Without being able to describe a situation where a member of the general public might use this, it seems a little... specialized for a property baked into a public specification.

I also wonder how the following would work:

  1. Content with "position: fixed" which appears on every page? Is that rotated or not?
  2. Backgrounds promoted from the HTML body or the :root to the page context? Rotated or not?

@chrishtr
Copy link
Contributor Author

@faceless2

The only use-case described so far seems to be to "undo" the layout decisions made by some layout engines that rotate landscape content into a portrait format. Have I understood that correctly?

I don't think that's accurate. The use case is to apply a rotation to the "most important" direction of text, in cases where there are multiple orientations on the same page for printed output.

To your questions about deciding whether certain parts of the page should be rotated or not - I think that's not the best way to think about it. It's that the page has a particular printed output that includes rotated text in various combinations, for multiple reasons. orientation doesn't say how to rotate various pieces of content in different ways, there are already mechanisms for that. It just says which orientation is the most useful way to view a particular page.

@faceless2
Copy link

OK. I'm not hugely invested in this one way or another so I will say my piece and go away.

I'm struggling because I can't imagine a general use-case that demonstrates how to get content onto the page that isn't already upright, according to its "most important direction", in the first place.

  • extra wide table? Make the page landscape.
  • landscape format image? Make the page landscape.

In both cases you would have to work much harder to display this content sideways on a portrait page. For a large image, for example, you'd have to override image-orientation, or apply a rotation transform to it. Making a large table come out sideways? Well I suppose you could try with writing-mode and transform.

I can see that there might be some value in rotating the margin content in this case - for example, in Amelia's example above, if I were tasked with laying this table out in CSS I'd make it a landscape page. But if I knew it was being destined for a printed book, I might want to rotate the margin content by 90°, so when it's printed and bound, in portrait, the margin content is the right way up.

I think that's the opposite of your suggested purpose, but I suppose it's literally a question of perspective so perhaps it will do as a use-case.


For background: underlying my concerns is that the "Rotate" parameter in PDF is not great. It's not a simple Affine transformation - it rotates the page content, yes, and the coordinates of any annotations on the page. But the internal contents of those annotations are further rotated to try to keep them up the right way up. This doesn't matter if all you're doing is putting out static content, but if you're creating a PDF with form fields on it then creating the page with the correct orientation in the first place is a lot cleaner than creating the page sideways and setting "Rotate" to 90 or (worse) 180.

Clearly your intent is not to replace size: A4 landscape with size: A4; orientation: rotate-right. That's good, but I am slightly concerned that if this property enters the spec, that's precisely what people will use it for. For that reason, I'd lean towards something like Tab's suggestion of margin-orientation myself.

@chrishtr
Copy link
Contributor Author

  • extra wide table? Make the page landscape.
  • landscape format image? Make the page landscape.

If the page is landscape then headers will also be landscape, right? Which is not desired.

@tabatkins
Copy link
Member

The orientation descriptor is just for printed output.

As far as I can tell from your use-case description and described behavior, it's the exact opposite. From your description of the use-case, it's for when you're rendering to a PDF or other page-based screen media. In the case you described, all the pages are size: portrait already, and thus suitable for immediately printing with no additional work; you use orientation to get the supposed-to-be-landscape pages to be shown in landscape on screen.

My suggested inversion was the "just for printed output" version, where screen/PDF display works correctly by default (by using size properly), and then you use margin-orientation to rotate how the margins are laid out so they're in a desirable spot when printing.

(@faceless2 hits on this independently, realizing that the semantics they find reasonable are the opposite of what's being presented here.)

To support size: landscape properly without violating specs is very difficult, and a multi-year project for Chromium.

Okay, that's a completely different use-case, and one we can talk about reasonably, but has nothing to do with the other use-cases based on observable behavior of a conforming implementation.

If the use-case is "we don't expect to ever actually implement @page { size: ...; }, at least not for a very long time, but we'd like to be able to have pages that are hacking in landscape-orientation by rendering sideways be oriented 'as intended' when printed to PDF", then the described approach might be reasonable. But then I'd want to be much, much clearer that this is a temporary solution that has better technical solutions that just haven't been implemented yet, and would claim a scarier and less generic name for the property as a result. orientation is definitely not an appropriate name for this sort of "feature B to deal with the fact that feature A isn't implemented" feature.

@chrishtr
Copy link
Contributor Author

As far as I can tell from your use-case description and described behavior, it's the exact opposite. From your description of the use-case, it's for when you're rendering to a PDF or other page-based screen media. In the case you described, all the pages are size: portrait already, and thus suitable for immediately printing with no additional work; you use orientation to get the supposed-to-be-landscape pages to be shown in landscape on screen.

When I said "for printed output", I mean that the printing use case. PDF generation is a kind of printing, it's not "view on the web".

My suggested inversion was the "just for printed output" version, where screen/PDF display works correctly by default (by using size properly), and then you use margin-orientation to rotate how the margins are laid out so they're in a desirable spot when printing.

Browsers don't have any distinction between PDF and non-PDF printed output, do they? PDF output is an implementation detail of the user agent outside of the control of the web developer.

If the use-case is ...

This is another motivation, yes. However, I don't agree with the notion that this is a hack. The other proposed solutions, as far as I can tell, imply a very large amount of implementation work (even more than just implementing full fragmentation, because there is the proposed additional feature of rotating headers and footers differently than the page layout). Therefore this solution is has positive design points for the (valid, non-hack) use-cases stated.

@faceless2
Copy link

faceless2 commented Feb 26, 2020

If the page is landscape then headers will also be landscape, right? Which is not desired.

I think that's false (i.e. it is desired) if the page is being displayed as landscape on screen - the pages are oriented to match their "most important direction", all the text is up the right way, no-one has to turn their head sideways to read anything.

But I think it's true if the page is being printed and bound into a book where all the pages are going to wind up as portrait regardless of their original orientation. In that case, yes, as I mentioned before I can see this being a use-case for some sort of parameter. But again, I would personally lean towards the concept of "rotating the margin content sideways" rather than "rotating the page content sideways".

@chrishtr
Copy link
Contributor Author

I think that's false (i.e. it is desired) if the page is being displayed as landscape on screen - the pages are oriented to match their "most important direction", all the text is up the right way, no-one has to turn their head sideways to read anything.

I see your point that it's more readable on a screen to see everything in the same orientation. But the use case here is a PDF preview of printing, which is outside the control of the web platform, and therefore requires some parameter to help it out. Right?

@faceless2
Copy link

Sure - you've convinced me that some sort of parameter indicating a page is to be oriented contrary to it's "most important direction" is probably useful. I'm imagining the printed material, you're imagining the screen preview of the same, but I think we're finally on the same page (badum tish).

@tabatkins
Copy link
Member

Browsers don't have any distinction between PDF and non-PDF printed output, do they? PDF output is an implementation detail of the user agent outside of the control of the web developer.

They don't expose any distinction, no. But this feature distinguishes those two cases; your proposed 'orientation' has no effect on paper output (it continues to be portrait-oriented) and only affects PDF output. My counter margin-orientation does the exact same, just in reverse.

This is another motivation, yes. However, I don't agree with the notion that this is a hack. The other proposed solutions, as far as I can tell, imply a very large amount of implementation work (even more than just implementing full fragmentation, because there is the proposed additional feature of rotating headers and footers differently than the page layout). Therefore this solution is has positive design points for the (valid, non-hack) use-cases stated.

It's absolutely a hack, because it requires you to write your content in the wrong orientation for screen, to get this desired display when printing. Using 'writing-mode' to make a table lay out "sideways" so that, when printed, it'll get landscape dimensions from a size: portrait page, is definitely a hack. The correct way to do all of this is as I described: lay out your table normally, break it onto a size:landscape page for printing, and then use some theoretical feature along these lines to ensure the margins are in the desired orientation when paper-printing.

I understand that actually doing breaking across different-sized fragmentainers/pages is still far off in our impl (Ian says ~2 years), so if we want to address this use-case in the short-term we'll need something hackier like this, and I'm fine with that. I just want a different name to emphasize that fact! orientation is too prime of a name to use for a "we're doing X because we haven't implemented Y yet" feature.

I'm not sure what the name should be though. :(

@chrishtr
Copy link
Contributor Author

I just want a different name to emphasize that fact! orientation is too prime of a name to use for a "we're doing X because we haven't implemented Y yet" feature.

However, there are other legitimate use-cases that will remain even after such features appear in the future (as mentioned earlier, and @faceless2 agreed are legitimate.

How about rotate: none | left | right?

@tabatkins
Copy link
Member

However, there are other legitimate use-cases that will remain even after such features appear in the future

Yup, I also agree that having the ability to dictate the relative rotation of the page content vs the margins is worthwhile in the future. My ideal to achieve the use-case here is:

table.big {
 page: big-table;
}
@page big-table {
 size: landscape;
 mismatched-orientation: rotate-out;
}

...which would be normal on screen, would show a landscape page in PDF (with @top on either the left or right), and would be printed on portrait paper such that the @top margin is on top, and the table is rotated in the "out" direction (right on right pages, left on left pages).

How about rotate: none | left | right?

Maybe? Given how targeted this is at the PDF use-case, maybe pdf-rotate?

@faceless2
Copy link

Both orientation and rotate seem - as Tab puts it - "too prime a name" for what is, in the long term, going to be a bit of an edge-case property.

Not quite sure about pdf-rotate either - if someone is targetting, I don't know, PostScript or TIFF, they might still want to do the same. I think if you want values of "left" or "right" or "90deg" or "-90deg" then has to be something-rotation - if you want values of "portrait" or "landscape" then it should be something-orientation.

  • Putting lots of pages together to prepare for print is called "assembly" - how about "assembly-rotation" or "assembly-rotate"?
  • "print-rotate"? Easily understood this would apply to print-preview as well.
  • "page-rotate"? Getting a bit close to "rotate" perhaps
  • "orientation-correction"? No one's going to reach for that one instead of "size", that's for sure.

@chrishtr
Copy link
Contributor Author

chrishtr commented Mar 2, 2020

Thanks for offering suggestions.

"print-rotate", "page-rotate" and"orientation-correction" all sound reasonable to me!

I don't think it's good to put a particular output format like "pdf" in the name.

@tabatkins
Copy link
Member

Yeah, I wasn't happy with pdf-rotate either. page-rotate seems good to me; you're literally rotating the page itself, but nothing else changes about the layout or display.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-page-3] Add orientation descriptor, and agreed to the following:

  • RESOLVED: Name this page-orientation with values rotate-left and rotate-right
The full IRC log of that discussion <dael> Topic: [css-page-3] Add orientation descriptor
<dael> github: https://github.com//issues/4491
<dael> chrishtr: Discussed in Dec. Can add to a named page to control rotation in printed output.
<dael> chrishtr: Use cases are to provide orientation for dominant content direction when multi direction. Second it allow dev to provide mixed rotations for UA that don't support other page rotation parts
<dael> chrishtr: I think some consensus use cases make sense.
<dael> chrishtr: Discussion on name
<dael> chrishtr: Check for consensus and then do name
<fantasai> https://github.com//issues/4491#issuecomment-590613842
<dael> fantasai: Not clear on the behavior of this. I read TabAtkins comment that makes sense but you said it's not that
<dael> TabAtkins: What happens is in cases where printed output but you control how pages are displaded, aka pdf, adjusts how they're oriented in that display.
<dael> TabAtkins: You can have a whole bunch of portrait and then some are landscape
<dael> fantasai: Example in comment. Doc with a table, assign table to landscape with features we have. Printer the landscape is oriented to portrait. When open a PDF you get a bunch of portrait pages and a landscape for the page that has a table which is upright for me on the screen. THat's without this property. Current behavior
<bkardell_> https://docs.google.com/document/d/1plEqcBz_6ApmtWYCSRxwOANgF5aGoAL2B0s_9PSQJF0/edit#heading=h.zd7icrtuskjo
<dael> fantasai: Prop is to rotate the landscape so it's sidewas and you have to turn your head to read?
<dael> TabAtkins: It's something else
<dael> fantasai: What is the default that should happen right now?
<dael> TabAtkins: Ideally you do what you desc. Wide table you force to a named page and say landscape
<dael> TabAtkins: In scenario today where browsers do not have ability to do diff size page sin layout what you instead do is layout everything as portrait. If that means putting out bitmaps or whatever it all comes out as portrait.
<dael> TabAtkins: This feature then says if you're output to a pdf go ahead and rotate. This is a the good feature isn't impl so let's put in this feature for now. It'll be a few years before browser can address properly
<dael> fantasai: Okay, I think I understand. So this rotates whole paper including headers
<dael> TabAtkins: Correct.
<bkardell_> q+
<dael> TabAtkins: When browser can control paper orientation is this property
<astearns> ack bkardell_
<dael> fantasai: Use case you're bringing up is you pre-rotate and then rotate back to get effect of if we had portrait/landscape
<dael> TabAtkins: Correct
<dael> bkardell_: I shared a google doc from gsuites that talked about uses involving mixed orientations. Is that included here?
<dael> chrishtr: mixed means some landscape and some portrait. Use case from TabAtkins is a browser that doesn't fully support to still be able to output.
<dael> bkardell_: I see that in issue. THanks
<fantasai> s/Use case/So your original comment is correct, and the additional use case/
<fantasai> s/pre-rotate/pre-rotate using writing-mode or transform or something/
<dael> astearns: Currently for output formats that can handle layout orientation. When browser can layout as a landscape page owuld this property start applying to on screen?
<dael> fantasai: No
<dael> TabAtkins: Not unless display in paged format which generally don't
<dael> chrishtr: If site applies page:landscape and rotate:left you get things that look sideways. Shouldn't do that. SHould only apply rotate for layout of printed mode
<dael> astearns: I'm thinking of paged view on tablet. Currently...if you had this you could layout such that someone can rotate screen and get better view of horz content
<dael> chrishtr: Cases where drown by dev layout but paginated layout?
<dael> astearns: Future browser with paginated ux
<dael> TabAtkins: Got it. Depends on if it allows rotation of pages. If wants to be more like printed it would not respect. BUt if it's just layout onto desktop screen it would respect this property and rotate the page for you
<dael> chrishtr: If you consider pdf viewer on tablet you can imagine browser to integrate with pdf viewer to not respect this and expect you to rotate. It's an option impl could choose
<dael> fantasai: It's a good point astearns and we should write up that situation
<dael> astearns: I've got people with defined opinions on pdf viewers we can consult
<dael> TabAtkins: Want to make sure it's clear in description where this applies. Paginated viewing and makes sense to author oritentation of page based on user preference not device orientation. Happy to work together to make sure text looks good
<dael> astearns: Other questions or opinions on basic design before we do naming?
<dael> astearns: Let's talk names
<dael> astearns: My opinion is page-rotate makes sense since talking pagination
<dael> chrishtr: Makes sense to me
<dael> astearns: Other opinions?
<dael> astearns: We're not setting anything in stone. I think for now go with page-rotate and with issue discussion
<dael> fantasai: page-rotate or page-orient. rotate left and right makes sense
<dael> TabAtkins: I like rotate because it's spinning. I would accept orientation
<dael> fantasai: I think that was my opinion until PDF cases where this is a hint about correct orientation but you might not honor that. It's hint about orientation but not a command to rotate. I'm not super clear
<dael> astearns: In order to prevent a verb should it be page-rotation?
<fantasai> s/PDF cases/astearn's examples,/
<dael> astearns: Seems like we're at a lull. Should we resolve on name page-rotation?
<dael> fantasai: Have rotate property
<dael> TabAtkins: But it's a rotate function. There's a reason for it to be a verb when we normally have adjectives
<dael> fantasai: I feel inconsistency is not great
<dael> dholbert: Rotate sounds like an angle rather then keyword
<dael> TabAtkins: Breaking with rotate is good
<dael> TabAtkins: Page-oreitnetation
<dael> chris: People talk about page orientation
<dael> chris: page-orientation rotate-left and rotate-right?
<dael> astearns: Makes sense. Rotate seems angle
<dael> astearns: page-orientation with values rotate-left and rotate-right
<dael> dholbert: Don't love rotate-left b/c sounds like clockwise and counter clockwise. Left is direction rather then rotation. It's translation
<dael> chrishtr: left is 90deg rather then rotate
<dael> dholbert: Suggests counterclockwise
<dael> astearns: And easier to spell
<dael> astearns: Other concerns?
<dael> astearns: Objections?
<dael> RESOLVED: Name this page-orientation with values rotate-left and rotate-right
<dael> astearns: Anything else you wanted on this chrishtr ?
<dael> chrishtr: That's it, thank you

@fantasai
Copy link
Collaborator

fantasai commented Mar 5, 2020

Should we be aligning on the value space for image-orientation? https://www.w3.org/TR/css-images-3/#the-image-orientation Or perhaps borrow from text-orientation and use the prefix sideways- instead of rotate-?

Also page-orientation: none is a bit nonsensical, if we're going with keywords maybe upright to match text-orientation?

@tabatkins
Copy link
Member

Yeah, with "orientation" "none" doesn't make sense. "upright" works for me.

("page-rotate: none" was more reasonable)

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2020
This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2020
This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue May 7, 2020
This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}
blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this issue May 7, 2020
This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}
JTensai pushed a commit to JTensai/csswg-drafts that referenced this issue May 13, 2020
* [css-page] Add page-orientation descriptor. Fixes w3c#4491.

* [css-page-3] Change ID to avoid clash.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 15, 2020
…only

Automatic update from web-platform-tests
Add page-orientation descriptor.

This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}

--

wpt-commits: f8ad4cf5d37166c24ef2b464414b3ebee59595ac
wpt-pr: 23454
xeonchen pushed a commit to xeonchen/gecko that referenced this issue May 15, 2020
…only

Automatic update from web-platform-tests
Add page-orientation descriptor.

This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}

--

wpt-commits: f8ad4cf5d37166c24ef2b464414b3ebee59595ac
wpt-pr: 23454
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue May 20, 2020
…only

Automatic update from web-platform-tests
Add page-orientation descriptor.

This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}

--

wpt-commits: f8ad4cf5d37166c24ef2b464414b3ebee59595ac
wpt-pr: 23454
xeonchen pushed a commit to xeonchen/gecko that referenced this issue May 20, 2020
…only

Automatic update from web-platform-tests
Add page-orientation descriptor.

This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}

--

wpt-commits: f8ad4cf5d37166c24ef2b464414b3ebee59595ac
wpt-pr: 23454
@mstensho
Copy link
Contributor

mstensho commented Jun 5, 2020

bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this issue May 1, 2025
…only

Automatic update from web-platform-tests
Add page-orientation descriptor.

This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}

--

wpt-commits: f8ad4cf5d37166c24ef2b464414b3ebee59595ac
wpt-pr: 23454
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this issue May 1, 2025
…only

Automatic update from web-platform-tests
Add page-orientation descriptor.

This will be supported in @page rules to set the orientation of a page
(without affecting layout). Typically to be used together with named
pages (or @page :first, etc.)

See https://drafts.csswg.org/css-page-3/#page-orientation-prop and
w3c/csswg-drafts#4491

The tests added have some failures, due to crbug.com/1079212 and
crbug.com/1079214

Bug: 1053768
Change-Id: I96f93e3e34beee92b4c30f65d7e46498a8110464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2187211
Reviewed-by: Rune Lillesveen <[email protected]>
Reviewed-by: Anders Hartvoll Ruud <[email protected]>
Reviewed-by: Chris Harrelson <[email protected]>
Commit-Queue: Chris Harrelson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766534}

--

wpt-commits: f8ad4cf5d37166c24ef2b464414b3ebee59595ac
wpt-pr: 23454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-page-3 Current Work
Projects
None yet
Development

No branches or pull requests