Intern Project: PrintBrowser

59 views
Skip to first unread message

Andrew Gozzard

unread,
Nov 30, 2016, 1:11:53 AM11/30/16
to styl...@chromium.org
Hi all,

For my intern project I will be working with nai...@chromium.org to design and implement PrintBrowser mode, a mode in which all pages are rendered as though in print preview. For more information, please see the design doc. Feedback is greatly appreciated.

Cheers,
Gozz

Takayoshi Kochi

unread,
Nov 30, 2016, 2:14:49 AM11/30/16
to Andrew Gozzard, style-dev
What's the difference from developer tool's
Rendering > Emulate CSS media > Print?

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+unsubscribe@chromium.org.
To post to this group, send email to styl...@chromium.org.
To view this discussion on the web, visit https://groups.google.com/a/chromium.org/d/msgid/style-dev/CAJ_xTtadd%3DYY1%3DVqJVPOigaiDNU1x0ivq9P%3D%3DxXANZHCXxQzYA%40mail.gmail.com.



--
Takayoshi Kochi

PhistucK

unread,
Nov 30, 2016, 2:38:50 AM11/30/16
to Takayoshi Kochi, Andrew Gozzard, style-dev
I have already seen bugs where print preview and emulated CSS Media do not show the same result.


PhistucK

Andrew Gozzard

unread,
Nov 30, 2016, 6:01:10 PM11/30/16
to PhistucK, Takayoshi Kochi, style-dev
This method uses the same rendering code as print preview and printing. This gives proper pagination and allows us to build a testing infrastructure for the printing code, something we don't currently have and can't do using emulated CSS media.

Cheers,
Gozz

On Wed, Nov 30, 2016 at 6:38 PM PhistucK <phis...@gmail.com> wrote:
I have already seen bugs where print preview and emulated CSS Media do not show the same result.


PhistucK
On Wed, Nov 30, 2016 at 9:14 AM, Takayoshi Kochi <ko...@chromium.org> wrote:
What's the difference from developer tool's
Rendering > Emulate CSS media > Print?
On Wed, Nov 30, 2016 at 3:11 PM, 'Andrew Gozzard' via style-dev <styl...@chromium.org> wrote:
Hi all,

For my intern project I will be working with nai...@chromium.org to design and implement PrintBrowser mode, a mode in which all pages are rendered as though in print preview. For more information, please see the design doc. Feedback is greatly appreciated.

Cheers,
Gozz

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+...@chromium.org.



--
Takayoshi Kochi

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+...@chromium.org.

To post to this group, send email to styl...@chromium.org.

Naina Raisinghani

unread,
Nov 30, 2016, 11:02:21 PM11/30/16
to Andrew Gozzard, PhistucK, Takayoshi Kochi, style-dev
Hi all, 

@Takayoshi - "Emulate CSS Media - Print" doesn't allow us to test pagination (for e.g. page-break-after) as Gozz mentioned. 

Emulate CSS Media uses a different code path to achieve the results (which may explain the difference PhistucK pointed out). It calls  webViewImpl()->page()->settings().setMediaTypeOverride(media); as can be seen here.

Hope this and Gozz's explanation helps clarify the needs for this project. 

Takayoshi Kochi

unread,
Dec 1, 2016, 2:35:53 AM12/1/16
to Naina Raisinghani, Andrew Gozzard, PhistucK, style-dev
Thanks for clarifications!

I'm wondering that the current print preview is done by once creating a PDF output then kick the PDF viewer
to show in a webview, IIUC - so the project intends to reuse the code and show the generated PDF but without
printing controls, right?

At first I thought the project was to just apply @media print styles (which I guess what devtools does),
and still the page is running animation or interactive (e.g. Gmail) :)

On Thu, Dec 1, 2016 at 1:02 PM, Naina Raisinghani <nai...@chromium.org> wrote:
Hi all, 

@Takayoshi - "Emulate CSS Media - Print" doesn't allow us to test pagination (for e.g. page-break-after) as Gozz mentioned. 

Emulate CSS Media uses a different code path to achieve the results (which may explain the difference PhistucK pointed out). It calls  webViewImpl()->page()->settings().setMediaTypeOverride(media); as can be seen here.

Hope this and Gozz's explanation helps clarify the needs for this project. 
On Thu, Dec 1, 2016 at 10:01 AM 'Andrew Gozzard' via style-dev <styl...@chromium.org> wrote:
This method uses the same rendering code as print preview and printing. This gives proper pagination and allows us to build a testing infrastructure for the printing code, something we don't currently have and can't do using emulated CSS media.

Cheers,
Gozz

On Wed, Nov 30, 2016 at 6:38 PM PhistucK <phis...@gmail.com> wrote:
I have already seen bugs where print preview and emulated CSS Media do not show the same result.


PhistucK
On Wed, Nov 30, 2016 at 9:14 AM, Takayoshi Kochi <ko...@chromium.org> wrote:
What's the difference from developer tool's
Rendering > Emulate CSS media > Print?
On Wed, Nov 30, 2016 at 3:11 PM, 'Andrew Gozzard' via style-dev <styl...@chromium.org> wrote:
Hi all,

For my intern project I will be working with nai...@chromium.org to design and implement PrintBrowser mode, a mode in which all pages are rendered as though in print preview. For more information, please see the design doc. Feedback is greatly appreciated.

Cheers,
Gozz

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+unsubscribe@chromium.org.



--
Takayoshi Kochi

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+unsubscribe@chromium.org.

To post to this group, send email to styl...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+unsubscribe@chromium.org.

--
You received this message because you are subscribed to the Google Groups "style-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to style-dev+unsubscribe@chromium.org.

To post to this group, send email to styl...@chromium.org.

Tien-Ren Chen

unread,
Dec 1, 2016, 6:51:24 PM12/1/16
to Andrew Gozzard, PhistucK, Takayoshi Kochi, style-dev
One technical difficulty off top of my head is fixed-positioned
elements. On printed media fixed-pos elements are painted repeatedly
on each page [1][2].

**** Some background around paging ****
In our current implementation, paging shares the same code base as
multi-column blocks [3]. For example, let's say we have sheet size of
US Letter (8.5" x 11") with 0.5" margin, in 150 DPI. The page size
would be 1275px x 1650px, and the initial containing block for
fixed-pos elements would be (75, 75, 1125, 1500). If the document end
up having 3 pages, the document size would be 1275px x 4950px, with an
imaginary block flow of 1125px x 4500px splitted into 3 fragments,
pasted at (75, 75), (75, 1725), and (75, 3375) respectively.

**** Back to printing fixed-pos element ****
As mentioned at the top, fixed-pos elements need to be printed
repeatedly on each page. This is NOT implemented by duplicating
multiple layout objects. Instead, it is done by scrolling an imaginary
viewport. The process of printing works like scrollTo(0, 0) --->
paint() ---> scrollTo(0, 1650) ---> paint() ---> scrollTo(0, 3300) -->
paint(). For this to work in normal compositing rendering pipeline,
some non-trivial works will need to be done.

Don't get me wrong, I'm not discouraging you to do this. I found the
proposal very valuable and looks like an exciting project to me. Just
giving you a heads-up. Don't hesitate to ask if you need help in
layout / paint / compositing area. :)


[1] https://www.w3.org/TR/CSS21/visuren.html#fixed-positioning
[2] As a side note, fixed-pos elements should also use the content
area of each page box for layout. CSS allows different padding and
border for each page through pseudo selector thus the layout of
fixed-pos element can be different on each page. I don't think we
implemented that correctly as of today.
[3] https://www.w3.org/TR/css3-multicol/

On Wed, Nov 30, 2016 at 3:00 PM, 'Andrew Gozzard' via style-dev
> https://groups.google.com/a/chromium.org/d/msgid/style-dev/CAJ_xTtboh9bbiKvEk%2BSupvEzuehp-6aEuDOsrCLZ%2BEr88%3Dm2RQ%40mail.gmail.com.

mauro...@gmail.com

unread,
Jul 1, 2018, 5:58:37 AM7/1/18
to style-dev
Great work! This seems implemented now under the --enable-print-browser flag. But pagination doesn't seem to work? In fact I cannot scroll at all, or how do I switch to the next page? Is pagination something that's still in the works or am I doing it wrong? Thanks for your time!

btw. I cannot access the linked design doc since I don't have permission..
Reply all
Reply to author
Forward
0 new messages