Page break position from layout code

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

Page break position from layout code

Gecko Embedding
Hi,

Iam a newbie w.r.t Gecko code hacking.Iam trying to identify the exact
position (dom element) at which page break occured.

I looked at nsSimplePageSequenceFrame , nsPageContentFrame.

Can someone tell me where exactly

1. I can get the dom element at which page break occurs.
2. The offset left and top in the document at which page break occurs.

for instance if I can print page 1 occurs at offsetTop and offsetLet
so and so.From which I can take the dom element.


Thanks in Advance,
Krithika

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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

> Hi,
>
> Iam a newbie w.r.t Gecko code hacking.Iam trying to identify the exact
> position (dom element) at which page break occured.
>
> I looked at nsSimplePageSequenceFrame , nsPageContentFrame.
>
> Can someone tell me where exactly
>
> 1. I can get the dom element at which page break occurs.
> 2. The offset left and top in the document at which page break occurs.
>
> for instance if I can print page 1 occurs at offsetTop and offsetLet
> so and so.From which I can take the dom element.
>
>
> Thanks in Advance,
> Krithika
>

You should be able to get the print preview PresShell from a
DocumentViewer if it is in print preview mode. You can use that to get
at the frame tree using GetPrimaryFrameFor or simply starting at the
root using GetRootFrame.  Each page has its own frame, so you should be
able to figure out what page an element starts on pretty easily.  Use
GetNextContinuation, and you can find the page an element ends on.  Use
GetOffsetToExternal, and you can find the coordinates of a frame
relative to another frame, for example a page frame.  It's a little
confusing, but you should be able to get any rendering information you need.

Of course, this is only accessible from C++, and nsIPresShell and
nsIFrame can and will change frequently between releases.  That said, it
should work.

For 1.9, I'm planning some changes that'll make it easier to get at the
print presentation; that's still in the early planning stages, though.

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

Re: Page break position from layout code

Gecko Embedding
On Mar 28, 12:42 pm, Eli Friedman <[hidden email]> wrote:

> krithika wrote:
> > Hi,
>
> > Iam a newbie w.r.t Gecko code hacking.Iam trying to identify the exact
> > position (dom element) at which page break occured.
>
> > I looked at nsSimplePageSequenceFrame , nsPageContentFrame.
>
> > Can someone tell me where exactly
>
> > 1. I can get the dom element at which page break occurs.
> > 2. The offset left and top in the document at which page break occurs.
>
> > for instance if I can print page 1 occurs at offsetTop and offsetLet
> > so and so.From which I can take the dom element.
>
> > Thanks in Advance,
> > Krithika
>
> You should be able to get the print preview PresShell from a
> DocumentViewer if it is in print preview mode. You can use that to get
> at the frame tree using GetPrimaryFrameFor or simply starting at the
> root using GetRootFrame.  Each page has its own frame, so you should be
> able to figure out what page an element starts on pretty easily.  Use
> GetNextContinuation, and you can find the page an element ends on.  Use
> GetOffsetToExternal, and you can find the coordinates of a frame
> relative to another frame, for example a page frame.  It's a little
> confusing, but you should be able to get any rendering information you need.
>
> Of course, this is only accessible from C++, and nsIPresShell and
> nsIFrame can and will change frequently between releases.  That said, it
> should work.
>
> For 1.9, I'm planning some changes that'll make it easier to get at the
> print presentation; that's still in the early planning stages, though.
>
> -Eli

Hi,

Thanks for your inputs.We are modifying cpp sources.I tried the
same .I do a PrintPreview from my embedding code and
DocumentViewerImpl printpreview gets called and I obtained nsPresShell
and rootframe as shown below.

I need to know.

1. Is this the right place to get nsPresShell ?
2. if Yes I am not clear about how to get dom element where page
breaks from this.

Need your help.

Thanks in Advance,
Krithika

NS_IMETHODIMP
DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32
aPageNum)
{

  printf("DocumentViewerImpl preview navigate to page : %d
\n",aPageNum);

  nsIPresShell* presShell;
  nsresult result = NS_OK;
  result=GetPresShell(&presShell);
  if(NS_SUCCEEDED(result))
  {
    if(presShell)
    {
      printf("nsPresShell from DocumentViewerImpl %p\n",presShell);
      printf("nsFrameManager from presShell %p\n",presShell-
>FrameManager());
      nsIFrame* rootFrame = presShell->GetRootFrame();
      // came up to this point
      printf("nsIFrame root frame %p\n",rootFrame);
     // not sure how to get element where page ends and starts

    }
    else printf("nsPresShell from DocumentViewerImpl is null\n");
  }
  else printf("nsPreShell from DocumentViewerImpl Failed\n");
.....


}

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

Re: Page break position from layout code

Eli Friedman
There's some code that does some stuff similar to what you're asking in
nsPrintEngine::GetPageRangeForSelection.  You can use
nsIPresShell::GetPrimaryFrameFor to get the primary frame for a content
node, and nsIFrame::GetContent to get the content for a frame.  Note
that one piece of content may correspond to multiple frames, so things
can get a bit complicated in some cases.

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

Re: Page break position from layout code

Gecko Embedding
On Mar 29, 12:22 pm, Eli Friedman <[hidden email]> wrote:
> There's some code that does some stuff similar to what you're asking in
> nsPrintEngine::GetPageRangeForSelection.  You can use
> nsIPresShell::GetPrimaryFrameFor to get the primary frame for a content
> node, and nsIFrame::GetContent to get the content for a frame.  Note
> that one piece of content may correspond to multiple frames, so things
> can get a bit complicated in some cases.
>
> -Eli


Hi,

Iam still not clear.Can you clarify the following for me?

1. Do you mean to say I should not be doing stuff in nsDocumentViewer
printpreviewnavigate method?If yes where exactly will I get the
presShell corresponding to printpreview page contents.
2. The problem in the code I presented is that if I do a rootFrame
GetContent() it is null.GetPrimaryFrame requires content.

>From your ealier mail I was hoping to get the page starting element
easily.

Iam clueless please help.

regards,
Krithika





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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

> On Mar 29, 12:22 pm, Eli Friedman <[hidden email]> wrote:
>> There's some code that does some stuff similar to what you're asking in
>> nsPrintEngine::GetPageRangeForSelection.  You can use
>> nsIPresShell::GetPrimaryFrameFor to get the primary frame for a content
>> node, and nsIFrame::GetContent to get the content for a frame.  Note
>> that one piece of content may correspond to multiple frames, so things
>> can get a bit complicated in some cases.
>>
>> -Eli
>
>
> Hi,
>
> Iam still not clear.Can you clarify the following for me?
>
> 1. Do you mean to say I should not be doing stuff in nsDocumentViewer
> printpreviewnavigate method?If yes where exactly will I get the
> presShell corresponding to printpreview page contents.

I wasn't attempting to make any suggestion as to where you should be
doing stuff; I was just suggesting you read the code in
nsPrintEngine::GetPageRangeForSelection because it seemed like it might
be helpful.

> 2. The problem in the code I presented is that if I do a rootFrame
> GetContent() it is null.GetPrimaryFrame requires content.

Yeah; what are you trying to do?  You can get the root content off of an
nsIDocument or nsIDOMDocument, and call GetPrimaryFrameFor on that.

>>From your ealier mail I was hoping to get the page starting element
> easily.
>
> Iam clueless please help.
>
> regards,
> Krithika
>
>
>
>
>
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: Page break position from layout code

Gecko Embedding
I tried looking in to nsPrintEngine.cpp code and the routine you
mentioned.But Iam finding this quite complex.

preShell I get maps only to the document or frames of the document.Iam
unable to make any progress.

My experiments with nsDocumentViewer:PrintPreviewNavigate is also
failing to give me the preview page content.

Which is the  point at which a document is split in to pages as in
Print Preview?I need to hook in at that point.

>From a PageFrame how do I get the first DOM element and last DOM
element of that page?

Thanks in Advance

regards,
Krithika


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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

> I tried looking in to nsPrintEngine.cpp code and the routine you
> mentioned.But Iam finding this quite complex.
>
> preShell I get maps only to the document or frames of the document.Iam
> unable to make any progress.
>
> My experiments with nsDocumentViewer:PrintPreviewNavigate is also
> failing to give me the preview page content.
>
> Which is the  point at which a document is split in to pages as in
> Print Preview?I need to hook in at that point.

Hmm, first off, are you using a trunk build?  Some stuff has changed a
bit there, so that you'll have to get the prescontext from the printengine.

The place where the page splits actually get calculated is the call to
InitialReflow in nsPrintEngine::ReflowPrintObject.

If you have a debug build, the functions in nsIFrameDebug might be useful.

Quick approximate summary of the frame tree for print preview:  the root
frame is the viewport.  The only child of that is the root scroll frame.
  The only child of that is the page sequence frame.  The children of
that are the page frames.  Each page frame has one child, an
nsPageContentFrame.  The page content frame contain the content on each
page.  The most common frames are nsBlockFrame, nsInlineFrame, and
nsTextFrame, which get created for normal textual content.

When a content element doesn't fit on one page, the frame gets split.
Therefore, a content node can have frames on multiple pages.  The
splitting happens during reflow.

The frame tree is a bit confusing to get used to, so try not to get
frustrated.

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

Re: Page break position from layout code

Gecko Embedding
On Mar 30, 12:25 am, Eli Friedman <[hidden email]> wrote:

> krithika wrote:
> > I tried looking in to nsPrintEngine.cpp code and the routine you
> > mentioned.But Iam finding this quite complex.
>
> > preShell I get maps only to the document or frames of the document.Iam
> > unable to make any progress.
>
> > My experiments with nsDocumentViewer:PrintPreviewNavigate is also
> > failing to give me the preview page content.
>
> > Which is the  point at which a document is split in to pages as in
> > Print Preview?I need to hook in at that point.
>
> Hmm, first off, are you using a trunk build?  Some stuff has changed a
> bit there, so that you'll have to get the prescontext from the printengine.
>
> The place where the page splits actually get calculated is the call to
> InitialReflow in nsPrintEngine::ReflowPrintObject.
>
> If you have a debug build, the functions in nsIFrameDebug might be useful.
>
> Quick approximate summary of the frame tree for print preview:  the root
> frame is the viewport.  The only child of that is the root scroll frame.
>   The only child of that is the page sequence frame.  The children of
> that are the page frames.  Each page frame has one child, an
> nsPageContentFrame.  The page content frame contain the content on each
> page.  The most common frames are nsBlockFrame, nsInlineFrame, and
> nsTextFrame, which get created for normal textual content.
>
> When a content element doesn't fit on one page, the frame gets split.
> Therefore, a content node can have frames on multiple pages.  The
> splitting happens during reflow.
>
> The frame tree is a bit confusing to get used to, so try not to get
> frustrated.
>
> -Eli

Hi,

Thanks for the explanation.It clarified lot of things for me.I have
made some progress.

As you can see I obtained pageContentFrame .But now the problem is the
content is always that of the first page.

When I print all the objects I find that till firstPageElem they are
different but when it comes to content it is the same.
Is contentPage->GetFirstChild(nsnull) the right one to do to get Page
Content.

Hope Iam clear.

Thanks in Advance,
Krithika


================

   for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
>GetNextSibling())
    {
     nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
     nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
      nsPageContentFrame* contentPage =
NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
      nsIFrame* firstPageElem=  contentPage-
>GetFirstChild(nsnull);
      nsIContent* cont = firstPageElem->GetContent();
      ...
      //process Content to get page start element and end element
details
    }





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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
>> GetNextSibling())
>     {
>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
>       nsPageContentFrame* contentPage =
> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
>       nsIFrame* firstPageElem=  contentPage-
>> GetFirstChild(nsnull);
>       nsIContent* cont = firstPageElem->GetContent();
>       ...
>       //process Content to get page start element and end element
> details
>     }

Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.

In a normal situation (without any fixed-position elements), the only
direct child of a page content frame is going to be a continuation of
the frame associated with the root content node, since all the content
in a document is a child of the root content node.  If you're interested
in where paragraphs and stuff split in an HTML document, you're going to
have to go down deeper into the frame tree.

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

Re: Page break position from layout code

Gecko Embedding
On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:

> krithika wrote:
> >    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
> >> GetNextSibling())
> >     {
> >      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
> >      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
> >       nsPageContentFrame* contentPage =
> > NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
> >       nsIFrame* firstPageElem=  contentPage-
> >> GetFirstChild(nsnull);
> >       nsIContent* cont = firstPageElem->GetContent();
> >       ...
> >       //process Content to get page start element and end element
> > details
> >     }
>
> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
>
> In a normal situation (without any fixed-position elements), the only
> direct child of a page content frame is going to be a continuation of
> the frame associated with the root content node, since all the content
> in a document is a child of the root content node.  If you're interested
> in where paragraphs and stuff split in an HTML document, you're going to
> have to go down deeper into the frame tree.
>
> -Eli

I tried mFrames , but is protected. Can this be accessed from
somewhere.?

How do I iterate frame tree?

Will it give me the indication of where page breaks?

Iam lost again.

thanks & regards,
Krithika







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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

> On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
>> krithika wrote:
>>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
>>>> GetNextSibling())
>>>     {
>>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
>>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
>>>       nsPageContentFrame* contentPage =
>>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
>>>       nsIFrame* firstPageElem=  contentPage-
>>>> GetFirstChild(nsnull);
>>>       nsIContent* cont = firstPageElem->GetContent();
>>>       ...
>>>       //process Content to get page start element and end element
>>> details
>>>     }
>> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
>>
>> In a normal situation (without any fixed-position elements), the only
>> direct child of a page content frame is going to be a continuation of
>> the frame associated with the root content node, since all the content
>> in a document is a child of the root content node.  If you're interested
>> in where paragraphs and stuff split in an HTML document, you're going to
>> have to go down deeper into the frame tree.
>>
>> -Eli
>
> I tried mFrames , but is protected. Can this be accessed from
> somewhere.?
>
> How do I iterate frame tree?
>
> Will it give me the indication of where page breaks?
>
> Iam lost again.
>
> thanks & regards,
> Krithika

The normal way to navigate the frame tree is to use
GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
iterate over the list of children (sibling frames are in a singly-linked
list), not attempting to directly access other frames' frame list.

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

Re: Page break position from layout code

Gecko Embedding
On Mar 31, 1:50 am, Eli Friedman <[hidden email]> wrote:

> krithika wrote:
> > On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
> >> krithika wrote:
> >>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
> >>>> GetNextSibling())
> >>>     {
> >>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
> >>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
> >>>       nsPageContentFrame* contentPage =
> >>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
> >>>       nsIFrame* firstPageElem=  contentPage-
> >>>> GetFirstChild(nsnull);
> >>>       nsIContent* cont = firstPageElem->GetContent();
> >>>       ...
> >>>       //process Content to get page start element and end element
> >>> details
> >>>     }
> >> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
>
> >> In a normal situation (without any fixed-position elements), the only
> >> direct child of a page content frame is going to be a continuation of
> >> the frame associated with the root content node, since all the content
> >> in a document is a child of the root content node.  If you're interested
> >> in where paragraphs and stuff split in an HTML document, you're going to
> >> have to go down deeper into the frame tree.
>
> >> -Eli
>
> > I tried mFrames , but is protected. Can this be accessed from
> > somewhere.?
>
> > How do I iterate frame tree?
>
> > Will it give me the indication of where page breaks?
>
> > Iam lost again.
>
> > thanks & regards,
> > Krithika
>
> The normal way to navigate the frame tree is to use
> GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
> iterate over the list of children (sibling frames are in a singly-linked
> list), not attempting to directly access other frames' frame list.
>
> -Eli

Hi,

After I get AreaFrame from nsPageContentFrame Iam unable to iterate it
through.GetNextSibling always returns null.

How do I proceed in this case?

regards,
Krithika



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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

> On Mar 31, 1:50 am, Eli Friedman <[hidden email]> wrote:
>> krithika wrote:
>>> On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
>>>> krithika wrote:
>>>>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
>>>>>> GetNextSibling())
>>>>>     {
>>>>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
>>>>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
>>>>>       nsPageContentFrame* contentPage =
>>>>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
>>>>>       nsIFrame* firstPageElem=  contentPage-
>>>>>> GetFirstChild(nsnull);
>>>>>       nsIContent* cont = firstPageElem->GetContent();
>>>>>       ...
>>>>>       //process Content to get page start element and end element
>>>>> details
>>>>>     }
>>>> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
>>>> In a normal situation (without any fixed-position elements), the only
>>>> direct child of a page content frame is going to be a continuation of
>>>> the frame associated with the root content node, since all the content
>>>> in a document is a child of the root content node.  If you're interested
>>>> in where paragraphs and stuff split in an HTML document, you're going to
>>>> have to go down deeper into the frame tree.
>>>> -Eli
>>> I tried mFrames , but is protected. Can this be accessed from
>>> somewhere.?
>>> How do I iterate frame tree?
>>> Will it give me the indication of where page breaks?
>>> Iam lost again.
>>> thanks & regards,
>>> Krithika
>> The normal way to navigate the frame tree is to use
>> GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
>> iterate over the list of children (sibling frames are in a singly-linked
>> list), not attempting to directly access other frames' frame list.
>>
>> -Eli
>
> Hi,
>
> After I get AreaFrame from nsPageContentFrame Iam unable to iterate it
> through.GetNextSibling always returns null.
>
> How do I proceed in this case?
>
> regards,
> Krithika
>
>
>

The pages aren't connected together through the sibling list.  You can
use GetNextContinuation() to find continuations for blocks (i.e. frames
with the same content).  Or you can just go back up the tree and use
GetNextSibling to get the next page.

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

Re: Page break position from layout code

Gecko Embedding
On Apr 2, 10:01 am, Eli Friedman <[hidden email]> wrote:

> krithika wrote:
> > On Mar 31, 1:50 am, Eli Friedman <[hidden email]> wrote:
> >> krithika wrote:
> >>> On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
> >>>> krithika wrote:
> >>>>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
> >>>>>> GetNextSibling())
> >>>>>     {
> >>>>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
> >>>>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
> >>>>>       nsPageContentFrame* contentPage =
> >>>>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
> >>>>>       nsIFrame* firstPageElem=  contentPage-
> >>>>>> GetFirstChild(nsnull);
> >>>>>       nsIContent* cont = firstPageElem->GetContent();
> >>>>>       ...
> >>>>>       //process Content to get page start element and end element
> >>>>> details
> >>>>>     }
> >>>> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
> >>>> In a normal situation (without any fixed-position elements), the only
> >>>> direct child of a page content frame is going to be a continuation of
> >>>> the frame associated with the root content node, since all the content
> >>>> in a document is a child of the root content node.  If you're interested
> >>>> in where paragraphs and stuff split in an HTML document, you're going to
> >>>> have to go down deeper into the frame tree.
> >>>> -Eli
> >>> I tried mFrames , but is protected. Can this be accessed from
> >>> somewhere.?
> >>> How do I iterate frame tree?
> >>> Will it give me the indication of where page breaks?
> >>> Iam lost again.
> >>> thanks & regards,
> >>> Krithika
> >> The normal way to navigate the frame tree is to use
> >> GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
> >> iterate over the list of children (sibling frames are in a singly-linked
> >> list), not attempting to directly access other frames' frame list.
>
> >> -Eli
>
> > Hi,
>
> > After I get AreaFrame from nsPageContentFrame Iam unable to iterate it
> > through.GetNextSibling always returns null.
>
> > How do I proceed in this case?
>
> > regards,
> > Krithika
>
> The pages aren't connected together through the sibling list.  You can
> use GetNextContinuation() to find continuations for blocks (i.e. frames
> with the same content).  Or you can just go back up the tree and use
> GetNextSibling to get the next page.
>
> -Eli

I have a for loop to navigate to next page.I only what to iterate
individual page content.


>From PageContentFrame I recursively do a GetFirstChild(nsnull) and I
am trying to print the frame type and content child count of those
frames.

For each page the first two frames are identical and subsequent frames
differ.
// all pages have this first and then frame type and content changes.
Page Element FrameType: AreaFrame
content child count 2
==================================
Page Element FrameType: BlockFrame
content child count 55
==================================


I am unable to understand this behaviour basically becos of my poor
understanding of how these frames are arranged is inside of each
PageContentFrame.

Can you throw some light on this?.

Thanks,
Krithika











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

Re: Page break position from layout code

Eli Friedman
krithika wrote:

> On Apr 2, 10:01 am, Eli Friedman <[hidden email]> wrote:
>> krithika wrote:
>>> On Mar 31, 1:50 am, Eli Friedman <[hidden email]> wrote:
>>>> krithika wrote:
>>>>> On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
>>>>>> krithika wrote:
>>>>>>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
>>>>>>>> GetNextSibling())
>>>>>>>     {
>>>>>>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
>>>>>>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
>>>>>>>       nsPageContentFrame* contentPage =
>>>>>>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
>>>>>>>       nsIFrame* firstPageElem=  contentPage-
>>>>>>>> GetFirstChild(nsnull);
>>>>>>>       nsIContent* cont = firstPageElem->GetContent();
>>>>>>>       ...
>>>>>>>       //process Content to get page start element and end element
>>>>>>> details
>>>>>>>     }
>>>>>> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
>>>>>> In a normal situation (without any fixed-position elements), the only
>>>>>> direct child of a page content frame is going to be a continuation of
>>>>>> the frame associated with the root content node, since all the content
>>>>>> in a document is a child of the root content node.  If you're interested
>>>>>> in where paragraphs and stuff split in an HTML document, you're going to
>>>>>> have to go down deeper into the frame tree.
>>>>>> -Eli
>>>>> I tried mFrames , but is protected. Can this be accessed from
>>>>> somewhere.?
>>>>> How do I iterate frame tree?
>>>>> Will it give me the indication of where page breaks?
>>>>> Iam lost again.
>>>>> thanks & regards,
>>>>> Krithika
>>>> The normal way to navigate the frame tree is to use
>>>> GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
>>>> iterate over the list of children (sibling frames are in a singly-linked
>>>> list), not attempting to directly access other frames' frame list.
>>>> -Eli
>>> Hi,
>>> After I get AreaFrame from nsPageContentFrame Iam unable to iterate it
>>> through.GetNextSibling always returns null.
>>> How do I proceed in this case?
>>> regards,
>>> Krithika
>> The pages aren't connected together through the sibling list.  You can
>> use GetNextContinuation() to find continuations for blocks (i.e. frames
>> with the same content).  Or you can just go back up the tree and use
>> GetNextSibling to get the next page.
>>
>> -Eli
>
> I have a for loop to navigate to next page.I only what to iterate
> individual page content.
>
>
>>From PageContentFrame I recursively do a GetFirstChild(nsnull) and I
> am trying to print the frame type and content child count of those
> frames.
>
> For each page the first two frames are identical and subsequent frames
> differ.
> // all pages have this first and then frame type and content changes.
> Page Element FrameType: AreaFrame
> content child count 2
> ==================================
> Page Element FrameType: BlockFrame
> content child count 55
> ==================================
>
>
> I am unable to understand this behaviour basically becos of my poor
> understanding of how these frames are arranged is inside of each
> PageContentFrame.
>
> Can you throw some light on this?.
>
> Thanks,
> Krithika

Tree for a simple HTML document like
<html><body>
<p>Para 1
<p>Para 2
...
<p>Para 20
PageFrame
     PageContentFrame
         AreaFrame content: html
             BlockFrame content: body
                 BlockFrame content: p
                     TextFrame content: #text "Para 1"
                 BlockFrame content: p
                     TextFrame content: #text "Para 2"
...
PageFrame
     PageContentFrame
         AreaFrame content: html (continuation)
             BlockFrame content: body (continuation)
                 BlockFrame content: p
                     TextFrame content: #text "Para 20"

Continuations are special because they correspond to the same content as
a previous frame.  They're linked together through GetNextContinuation
and GetPrevContinuation.

nsIFrameDebug contains some methods that let you dump frame trees; that
could be helpful for understanding what's going on.
_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout
Reply | Threaded
Open this post in threaded view
|

Re: Page break position from layout code

Gecko Embedding
On Apr 2, 1:54 pm, Eli Friedman <[hidden email]> wrote:

> krithika wrote:
> > On Apr 2, 10:01 am, Eli Friedman <[hidden email]> wrote:
> >> krithika wrote:
> >>> On Mar 31, 1:50 am, Eli Friedman <[hidden email]> wrote:
> >>>> krithika wrote:
> >>>>> On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
> >>>>>> krithika wrote:
> >>>>>>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
> >>>>>>>> GetNextSibling())
> >>>>>>>     {
> >>>>>>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
> >>>>>>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
> >>>>>>>       nsPageContentFrame* contentPage =
> >>>>>>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
> >>>>>>>       nsIFrame* firstPageElem=  contentPage-
> >>>>>>>> GetFirstChild(nsnull);
> >>>>>>>       nsIContent* cont = firstPageElem->GetContent();
> >>>>>>>       ...
> >>>>>>>       //process Content to get page start element and end element
> >>>>>>> details
> >>>>>>>     }
> >>>>>> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
> >>>>>> In a normal situation (without any fixed-position elements), the only
> >>>>>> direct child of a page content frame is going to be a continuation of
> >>>>>> the frame associated with the root content node, since all the content
> >>>>>> in a document is a child of the root content node.  If you're interested
> >>>>>> in where paragraphs and stuff split in an HTML document, you're going to
> >>>>>> have to go down deeper into the frame tree.
> >>>>>> -Eli
> >>>>> I tried mFrames , but is protected. Can this be accessed from
> >>>>> somewhere.?
> >>>>> How do I iterate frame tree?
> >>>>> Will it give me the indication of where page breaks?
> >>>>> Iam lost again.
> >>>>> thanks & regards,
> >>>>> Krithika
> >>>> The normal way to navigate the frame tree is to use
> >>>> GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
> >>>> iterate over the list of children (sibling frames are in a singly-linked
> >>>> list), not attempting to directly access other frames' frame list.
> >>>> -Eli
> >>> Hi,
> >>> After I get AreaFrame from nsPageContentFrame Iam unable to iterate it
> >>> through.GetNextSibling always returns null.
> >>> How do I proceed in this case?
> >>> regards,
> >>> Krithika
> >> The pages aren't connected together through the sibling list.  You can
> >> use GetNextContinuation() to find continuations for blocks (i.e. frames
> >> with the same content).  Or you can just go back up the tree and use
> >> GetNextSibling to get the next page.
>
> >> -Eli
>
> > I have a for loop to navigate to next page.I only what to iterate
> > individual page content.
>
> >>From PageContentFrame I recursively do a GetFirstChild(nsnull) and I
> > am trying to print the frame type and content child count of those
> > frames.
>
> > For each page the first two frames are identical and subsequent frames
> > differ.
> > // all pages have this first and then frame type and content changes.
> > Page Element FrameType: AreaFrame
> > content child count 2
> > ==================================
> > Page Element FrameType: BlockFrame
> > content child count 55
> > ==================================
>
> > I am unable to understand this behaviour basically becos of my poor
> > understanding of how these frames are arranged is inside of each
> > PageContentFrame.
>
> > Can you throw some light on this?.
>
> > Thanks,
> > Krithika
>
> Tree for a simple HTML document like
> <html><body>
> <p>Para 1
> <p>Para 2
> ...
> <p>Para 20
> PageFrame
>      PageContentFrame
>          AreaFrame content: html
>              BlockFrame content: body
>                  BlockFrame content: p
>                      TextFrame content: #text "Para 1"
>                  BlockFrame content: p
>                      TextFrame content: #text "Para 2"
> ...
> PageFrame
>      PageContentFrame
>          AreaFrame content: html (continuation)
>              BlockFrame content: body (continuation)
>                  BlockFrame content: p
>                      TextFrame content: #text "Para 20"
>
> Continuations are special because they correspond to the same content as
> a previous frame.  They're linked together through GetNextContinuation
> and GetPrevContinuation.
>
> nsIFrameDebug contains some methods that let you dump frame trees; that
> could be helpful for understanding what's going on.


Thanks a lot.It cleared up all my doubts.Iam able to reach the last
frame of each page to do my manipulation.


regards,
Krithika

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

Re: Page break position from layout code

Gecko Embedding
On Apr 3, 3:23 pm, "krithika" <[hidden email]> wrote:

> On Apr 2, 1:54 pm, Eli Friedman <[hidden email]> wrote:
>
>
>
> > krithika wrote:
> > > On Apr 2, 10:01 am, Eli Friedman <[hidden email]> wrote:
> > >> krithika wrote:
> > >>> On Mar 31, 1:50 am, Eli Friedman <[hidden email]> wrote:
> > >>>> krithika wrote:
> > >>>>> On Mar 30, 4:31 pm, Eli Friedman <[hidden email]> wrote:
> > >>>>>> krithika wrote:
> > >>>>>>>    for (nsIFrame* page = mFrames.FirstChild(); page; page = page-
> > >>>>>>>> GetNextSibling())
> > >>>>>>>     {
> > >>>>>>>      nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, page);
> > >>>>>>>      nsIFrame* contentFrame = pf->GetFirstChild(nsnull);
> > >>>>>>>       nsPageContentFrame* contentPage =
> > >>>>>>> NS_STATIC_CAST(nsPageContentFrame*, contentFrame);
> > >>>>>>>       nsIFrame* firstPageElem=  contentPage-
> > >>>>>>>> GetFirstChild(nsnull);
> > >>>>>>>       nsIContent* cont = firstPageElem->GetContent();
> > >>>>>>>       ...
> > >>>>>>>       //process Content to get page start element and end element
> > >>>>>>> details
> > >>>>>>>     }
> > >>>>>> Hmm, I'm assuming mFrames is the child frame list for nsSimplePageSequence.
> > >>>>>> In a normal situation (without any fixed-position elements), the only
> > >>>>>> direct child of a page content frame is going to be a continuation of
> > >>>>>> the frame associated with the root content node, since all the content
> > >>>>>> in a document is a child of the root content node.  If you're interested
> > >>>>>> in where paragraphs and stuff split in an HTML document, you're going to
> > >>>>>> have to go down deeper into the frame tree.
> > >>>>>> -Eli
> > >>>>> I tried mFrames , but is protected. Can this be accessed from
> > >>>>> somewhere.?
> > >>>>> How do I iterate frame tree?
> > >>>>> Will it give me the indication of where page breaks?
> > >>>>> Iam lost again.
> > >>>>> thanks & regards,
> > >>>>> Krithika
> > >>>> The normal way to navigate the frame tree is to use
> > >>>> GetFirstChild(nsnull) to get the primary child, then GetNextSibling() to
> > >>>> iterate over the list of children (sibling frames are in a singly-linked
> > >>>> list), not attempting to directly access other frames' frame list.
> > >>>> -Eli
> > >>> Hi,
> > >>> After I get AreaFrame from nsPageContentFrame Iam unable to iterate it
> > >>> through.GetNextSibling always returns null.
> > >>> How do I proceed in this case?
> > >>> regards,
> > >>> Krithika
> > >> The pages aren't connected together through the sibling list.  You can
> > >> use GetNextContinuation() to find continuations for blocks (i.e. frames
> > >> with the same content).  Or you can just go back up the tree and use
> > >> GetNextSibling to get the next page.
>
> > >> -Eli
>
> > > I have a for loop to navigate to next page.I only what to iterate
> > > individual page content.
>
> > >>From PageContentFrame I recursively do a GetFirstChild(nsnull) and I
> > > am trying to print the frame type and content child count of those
> > > frames.
>
> > > For each page the first two frames are identical and subsequent frames
> > > differ.
> > > // all pages have this first and then frame type and content changes.
> > > Page Element FrameType: AreaFrame
> > > content child count 2
> > > ==================================
> > > Page Element FrameType: BlockFrame
> > > content child count 55
> > > ==================================
>
> > > I am unable to understand this behaviour basically becos of my poor
> > > understanding of how these frames are arranged is inside of each
> > > PageContentFrame.
>
> > > Can you throw some light on this?.
>
> > > Thanks,
> > > Krithika
>
> > Tree for a simple HTML document like
> > <html><body>
> > <p>Para 1
> > <p>Para 2
> > ...
> > <p>Para 20
> > PageFrame
> >      PageContentFrame
> >          AreaFrame content: html
> >              BlockFrame content: body
> >                  BlockFrame content: p
> >                      TextFrame content: #text "Para 1"
> >                  BlockFrame content: p
> >                      TextFrame content: #text "Para 2"
> > ...
> > PageFrame
> >      PageContentFrame
> >          AreaFrame content: html (continuation)
> >              BlockFrame content: body (continuation)
> >                  BlockFrame content: p
> >                      TextFrame content: #text "Para 20"
>
> > Continuations are special because they correspond to the same content as
> > a previous frame.  They're linked together through GetNextContinuation
> > and GetPrevContinuation.
>
> > nsIFrameDebug contains some methods that let you dump frame trees; that
> > could be helpful for understanding what's going on.
>
> Thanks a lot.It cleared up all my doubts.Iam able to reach the last
> frame of each page to do my manipulation.
>
> regards,
> Krithika


Hi,

I need some more information.Is there a way to find out the text at
which page break occurs.As you said we get the whole content and
unable to identify the text at which break occurs.

regards,
Krithika

_______________________________________________
dev-tech-layout mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-layout