#9935: page-break-before:always doesn't work in tables

View: New views
10 Messages — Rating Filter:   Alert me  

#9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935>

#9935: page-break-before:always doesn't work in tables
---------------------------------------------------------------------------+
 Reporter:  djstauffer                                                     |       Owner:      
     Type:  defect                                                         |      Status:  new  
 Priority:  normal                                                         |   Milestone:      
Component:  wxHtml                                                         |     Version:  2.8.8
 Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak  |   Blockedby:      
    Patch:  1                                                              |    Blocking:      
---------------------------------------------------------------------------+
 I have an application which was written using wxWidgets 2.4.2 which I am
 porting to wxWidgets 2.8.7 (2.8.7 was the latest version available when I
 started the port).

 The application is currently run on Windows XP.

 This application generates and displays HTML documents.  In order to allow
 for smooth page breaks when those documents are printed, it uses page-
 break-before:always in a style attribute of a div tag whereever it wants a
 page break to appear.

 Often these page breaks are generated from within an HTML table,
 specifically, from within a TD tag inside the table.  Here is an example
 document:

 <html>
 <body>

 first page text

 <table>
   <tr>
     <td>
       <div style="page-break-before:always"></div>
         second page text
     </td>
   </tr>
 </table>

 </body>
 </html>

 The desired effect would be that "first page text" appears on the first
 page of the printed document, and "second page text" would appear on the
 second page.  Obviously this is a trivial example which has been trimmed
 down to only that which is needed to demonstrate the problem.

 If you run the htmlprinting.exe application from the wxWidgets samples (
 samples/html/printing ) and open a file containing the above sample
 document, then select File -> Preview, you will notice that "first page
 text" and "second page text" both appear on the first page (at least, if
 you use a recent version of wxWidgets, that is what will happen).  In
 version 2.4.2 of wxWidgets, a print preview will place the two lines of
 text on separate pages (as expected).

 In the previous version of our application (the one that was built with
 wxWidgets 2.4.2), page breaks within table tags appear exactly where you'd
 expect them.  In the 2.8.7 port, none of the page breaks within tables
 actually render a page break (HTML text continues on directly below the
 text immediately preceeding the page-break-before:always.

 According section 13.3 of the CSS 2.1 spec, page-break-before:always
 should be allowed in any block-level elements (
 http://www.w3.org/TR/CSS21/page.html ).  The only list of block-level
 elements I could find says that the TD tag is a block level element:
 (http://www.highdots.com/css-editor/html_tutorial/block.html).  Even if
 this is not the case, the DIV tag is a block-level element according to
 the CSS 2.1 spec, so I believe the above HTML document should render as
 expected when printed (with the second line of text on the second page).

 I was able to find the change in the wxWidgets code (between versions
 2.4.2 and 2.8.7) which appears to have caused the difference in printing
 between them.  The change appears in the src/html/m_layout.cpp file in the
 wxHtmlPageBreakCell::AdjustPagebreak function.  In the 2.4.2 version,
 total_height is calculated by walking up the tree of objects, and adding
 the y position of each parent all the way up the heirarchy.  In the 2.8.7
 version, the first parent's y position is added to the result of a call to
 that parent's GetHeight() function.  For whatever reason, the 2.8.7
 version of the code does not work correctly.  Interestingly enough, the
 2.8.7 version of the code occurs in the 2.4.2 version, but it is commented
 out and replaced with the version that walks up the heirarchy.

 Putting back the original code from the 2.4.2 version in 2.8.7 corrects
 the problem, and the HTML prints as expected.

 I checked out the 2.8.8 version of wxWidgets and found that it also had
 the same code in m_layout.cpp.  I've created a patch for that version, and
 that is what I'm submitting here.

 DJ Stauffer


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:1>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:                                                              
      Type:  defect      |      Status:  new                                                          
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  1                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------

Comment(by vaclavslavik):

 Replying to [ticket:9935 djstauffer]:
 > Putting back the original code from the 2.4.2 version in 2.8.7 corrects
 the problem, and the HTML prints as expected.

 If the code was changed, more likely than not there was some ''reason''
 for it. Reverting it back without understanding the change (`svn blame` is
 useful here...) would not be a good idea.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:1>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:2>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:                                                              
      Type:  defect      |      Status:  new                                                          
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  1                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------

Comment(by djstauffer):

 Fair enough.

 I've spent a decent amount of time trying to find the commit where these
 changes were made, and I have so far come up empty handed.  I am not the
 original developer of the application I am porting, and I don't have the
 original source tarball he/she used for the version of wxWidgets the app
 was previously compiled against -- I only have the contents of the
 tarball.  The readme file led me to believe it was version 2.4.2.
 However, after looking over the changes.txt again, it appears it may be
 from 2.4.3 or later (2.4.3 is listed in the "OTHER CHANGES" section).

 It looks like all of this happened around the time that the wxWidgets
 project switched to using subversion instead of cvs.  I've looked in both
 the subversion and cvs repositories, and all the 2.4.3 tags/branches that
 I've looked at do not have the modified code.  It is possible that the
 previous developer made the changes him/herself, but I highly doubt it.

 The m_layout.cpp file has a header pointing to a commit of yours from
 June, 2003:

 // Name:        m_layout.cpp
 // Purpose:     wxHtml module for basic paragraphs/layout handling
 // Author:      Vaclav Slavik
 // RCS-ID:      $Id: m_layout.cpp,v 1.16.2.7 2003/06/09 17:06:40 VS Exp $
 // Copyright:   (c) 1999 Vaclav Slavik
 // Licence:     wxWindows Licence

 However, when I browsed cvs.wxwidgets.org to find a matching version
 number (1.16.2.7), the code with the do() loop was not there.  So at this
 point I am at a loss as to how to find where the change was made so that I
 can try to understand it.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:2>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:3>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:                                                              
      Type:  defect      |      Status:  new                                                          
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  1                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------

Comment(by djstauffer):

 According to the CVS Tag files I've found lying around, this code was
 checked out from the CVS branch "TWX_2_4_BRANCH".  However, I can't find
 an equivalent branch name in svn, nor can I find a m_layout.cpp file for
 that branch anywhere on cvs.wxwidgets.org.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:3>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:4>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:                                                              
      Type:  defect      |      Status:  new                                                          
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  0                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------
Changes (by vadz):

  * patch:  1 => 0


Comment:

 Replying to [comment:3 djstauffer]:
 > According to the CVS Tag files I've found lying around, this code was
 checked out from the CVS branch "TWX_2_4_BRANCH".

 "T" is for "Tag" and the name of the branch is just `WX_2_4_BRANCH`. You
 can
 see it
 [http://svn.wxwidgets.org/viewvc/wx/wxWidgets/branches/WX_2_4_BRANCH/src/html/m_layout.cpp?view=log
 there] or even
 [http://trac.wxwidgets.org/browser/wxWidgets/trunk/src/html/m_layout.cpp
 right here] (select 2.4 branch in the "Visit" combobox).


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:4>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:5>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:                                                              
      Type:  defect      |      Status:  new                                                          
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  0                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------

Comment(by djstauffer):

 Thanks.

 The code in the m_layout.cpp that I have doesn't match any of the
 revisions in WX_2_4_BRANCH (I had already looked at that branch in the
 subversion repository).  I suspect perhaps the previous developer applied
 a patch from another source, so perhaps this is a wild goose chase.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:5>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:6>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:                                                              
      Type:  defect      |      Status:  new                                                          
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  1                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------
Changes (by vadz):

  * patch:  0 => 1


Comment:

 Restoring the patch checkbox as it seems that this could possibly be a
 valid patch and not just reversion back to an old version.

 I don't know the code enough to say if the patch is correct or not though.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:6>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:7>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:  vaclavslavik                                                
      Type:  defect      |      Status:  accepted                                                    
  Priority:  normal      |   Milestone:                                                              
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:              |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  1                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------
Changes (by vaclavslavik):

  * owner:  => vaclavslavik
  * status:  new => accepted


Comment:

 Replying to [comment:6 vadz]:

 > Restoring the patch checkbox as it seems that this could possibly be a
 valid patch

 I was going to say that myself. I'm not 100% sure yet, but it does look
 like a correct fix. Having some real-life test data for the bug would be
 nice...


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:7>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:8>

#9935: page-break-before:always doesn't work in tables
-----------------------------+----------------------------------------------
  Reporter:  djstauffer      |       Owner:  vaclavslavik                                                
      Type:  defect          |      Status:  portneeded                                                  
  Priority:  normal          |   Milestone:  2.8.10                                                      
 Component:  wxHtml          |     Version:  2.8.8                                                        
Resolution:  port to stable  |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:                  |       Patch:  1                                                            
  Blocking:                  |  
-----------------------------+----------------------------------------------
Changes (by vaclavslavik):

  * status:  accepted => portneeded
  * resolution:  => port to stable
  * milestone:  => 2.8.10


Comment:

 I applied the patch to the trunk, thanks! (To be backported to 2.8 in
 2.8.10.)


--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:8>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev

Re: #9935: page-break-before:always doesn't work in tables

by wxTrac :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:9>

#9935: page-break-before:always doesn't work in tables
-------------------------+--------------------------------------------------
  Reporter:  djstauffer  |       Owner:  vaclavslavik                                                
      Type:  defect      |      Status:  closed                                                      
  Priority:  normal      |   Milestone:  2.8.10                                                      
 Component:  wxHtml      |     Version:  2.8.8                                                        
Resolution:  fixed       |    Keywords:  page-break-before:always wxHtmlPageBreakCell  AdjustPagebreak
 Blockedby:              |       Patch:  1                                                            
  Blocking:              |  
-------------------------+--------------------------------------------------
Changes (by vaclavslavik):

  * status:  portneeded => closed
  * resolution:  port to stable => fixed



--
Ticket URL: <http://trac.wxwidgets.org/ticket/9935#comment:9>
_______________________________________________
wx-dev mailing list
wx-dev@...
http://lists.wxwidgets.org/mailman/listinfo/wx-dev
LightInTheBox - Buy quality products at wholesale price!