Remove "known_pagebreaks" from wxHtmlCell::AdjustPagebreak()

This parameter is not actually needed for any reasonable page breaking
algorithm, as it shouldn't care about any previous page breaks except
for the last one, which is already known as "*pagebreak - pageHeight" in
this function.

Removing it will allow to stop using wxArrayInt in the code using this
method and switch to an std::vector<int> instead.

This is not a backwards compatible change, but it seems that there is
very little code actually overriding this function (none could be found
in any open source repositories) and updating it should be as simple as
removing the now unneeded argument.
This commit is contained in:
Vadim Zeitlin
2018-05-24 18:05:58 +02:00
parent c58d81d32d
commit b9b6ccb804
7 changed files with 44 additions and 45 deletions

View File

@@ -157,9 +157,7 @@ wxHtmlCell::GetMouseCursorAt(wxHtmlWindowInterface *window,
bool
wxHtmlCell::AdjustPagebreak(int *pagebreak,
const wxArrayInt& WXUNUSED(known_pagebreaks),
int pageHeight) const
wxHtmlCell::AdjustPagebreak(int *pagebreak, int pageHeight) const
{
// Notice that we always break the cells bigger than the page height here
// as otherwise we wouldn't be able to break them at all.
@@ -697,19 +695,17 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const
bool
wxHtmlContainerCell::AdjustPagebreak(int *pagebreak,
const wxArrayInt& known_pagebreaks,
int pageHeight) const
wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int pageHeight) const
{
if (!m_CanLiveOnPagebreak)
return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, pageHeight);
return wxHtmlCell::AdjustPagebreak(pagebreak, pageHeight);
bool rt = false;
int pbrk = *pagebreak - m_PosY;
for ( wxHtmlCell *c = GetFirstChild(); c; c = c->GetNext() )
{
if (c->AdjustPagebreak(&pbrk, known_pagebreaks, pageHeight))
if (c->AdjustPagebreak(&pbrk, pageHeight))
rt = true;
}
if (rt)

View File

@@ -140,8 +140,7 @@ void wxHtmlDCRenderer::SetStandardFonts(int size,
// else: SetHtmlText() not yet called, no need for relayout
}
int wxHtmlDCRenderer::FindNextPageBreak(const wxArrayInt& known_pagebreaks,
int pos)
int wxHtmlDCRenderer::FindNextPageBreak(int pos)
{
// Stop looking for page breaks if the previous one was already at the end
// of the last page.
@@ -152,7 +151,7 @@ int wxHtmlDCRenderer::FindNextPageBreak(const wxArrayInt& known_pagebreaks,
return wxNOT_FOUND;
int posNext = pos + m_Height;
if ( m_Cells->AdjustPagebreak(&posNext, known_pagebreaks, m_Height) )
if ( m_Cells->AdjustPagebreak(&posNext, m_Height) )
{
// Check that AdjustPagebreak() returns the page break at a strictly
// greater position than that of the previous page, otherwise
@@ -486,7 +485,7 @@ void wxHtmlPrintout::CountPages()
for ( int pos = 0; pos != wxNOT_FOUND; )
{
m_PageBreaks.Add( pos);
pos = m_Renderer.FindNextPageBreak(m_PageBreaks, pos);
pos = m_Renderer.FindNextPageBreak(pos);
}
}

View File

@@ -65,9 +65,7 @@ class wxHtmlPageBreakCell : public wxHtmlCell
public:
wxHtmlPageBreakCell() {}
bool AdjustPagebreak(int* pagebreak,
const wxArrayInt& known_pagebreaks,
int pageHeight) const wxOVERRIDE;
bool AdjustPagebreak(int* pagebreak, int pageHeight) const wxOVERRIDE;
void Draw(wxDC& WXUNUSED(dc),
int WXUNUSED(x), int WXUNUSED(y),
@@ -79,9 +77,7 @@ private:
};
bool
wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak,
const wxArrayInt& WXUNUSED(known_pagebreaks),
int pageHeight) const
wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak, int pageHeight) const
{
// Request a page break at the position of this cell if it's on the current
// page. Note that it's important not to do it unconditionally or we could