help with implementing page-break-after: avoid for H1 tags

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

help with implementing page-break-after: avoid for H1 tags

Patrick Law
Hi Mozilla Developers,

I just started doing coding fore firefox/gecko and would appreciate some
pointers to get me started.

I am trying to implement page-break-after:avoid for richer print pagination
for H1 tag in firefox.

I wonder if you anyone can point me to the right directions for where to
look and maybe what I need to do in the code in firefox/gecko.

I have looked at nsBlookFrame.cpp and try to figure out the code but it is a
bit of a learning curve.

What I believe is needed here is to find out whether a frame is the last one
on the page
and at the same time the frame has page-break-after:avoid set in the display
style then if that is the case,
back track and put a page break frame right before the element (provided
that no another style attribute prevents this from happening)
So I would try to insert a page break frame until there is a frame back
enough that allows me to do that.

This is all very high level thoughts.

I appreciate if you can give me some pointers in anyway and tell me which
files I should look at first.

Thanks in advance.
Patrick
[hidden email]
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: help with implementing page-break-after: avoid for H1 tags

Eli Friedman
Hi,

(I'm not completely sure how new you are to Mozilla hacking, so there
might be some stuff you already know.)

I think nsSimplePageSequence, nsPageFrame, and nsPageContentFrame might
be a better place to start to see how the current page breaking works.
Also, lxr.mozilla.org is very useful for browsing code because of
hyperlinking and fast searches.

Quick description of breaking: when a block-level frame doesn't fit, it
tells the reflow mechanism that it doesn't fit; then, a new page is
created, a continuation of the frame that didn't fit is put onto the new
page, and reflow continues.

One subtlety to the system is that a continuation is always created for
a frame that is at the end of a page and doesn't completely fit, even if
none of it actually fits.

You probably want to look at bug 24000 to see what sort of changes you
need to make; keep in mind that patch was written quite a while ago.
You'll probably need to change the style handling so that it actually
stores the parsed value properly.

This isn't the easiest code to dive into, so don't worry if you're
having trouble understanding it.

Also, if you're looking for something easier to start with to get used
to Mozilla code, you might want to look at
http://www.mozilla.org/contribute/hacking/first-bugs/.

-Eli

Patrick Law wrote:

> Hi Mozilla Developers,
>
> I just started doing coding fore firefox/gecko and would appreciate some
> pointers to get me started.
>
> I am trying to implement page-break-after:avoid for richer print pagination
> for H1 tag in firefox.
>
> I wonder if you anyone can point me to the right directions for where to
> look and maybe what I need to do in the code in firefox/gecko.
>
> I have looked at nsBlookFrame.cpp and try to figure out the code but it
> is a
> bit of a learning curve.
>
> What I believe is needed here is to find out whether a frame is the last
> one
> on the page
> and at the same time the frame has page-break-after:avoid set in the
> display
> style then if that is the case,
> back track and put a page break frame right before the element (provided
> that no another style attribute prevents this from happening)
> So I would try to insert a page break frame until there is a frame back
> enough that allows me to do that.
>
> This is all very high level thoughts.
>
> I appreciate if you can give me some pointers in anyway and tell me which
> files I should look at first.
>
> Thanks in advance.
> Patrick
> [hidden email]
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout