Fix page-break-inside:avoid to work for nested tags too
The initial version was too naïve and didn't work correctly if the <div> with this style had nested elements.
This commit is contained in:
@@ -55,6 +55,8 @@ is split into base and GUI libraries.
|
|||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
|
<!-- Avoid page breaks inside individual version change logs -->
|
||||||
|
<div style="page-break-inside:avoid">
|
||||||
<H2>Release 2.1.11 (final)</H2>
|
<H2>Release 2.1.11 (final)</H2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@@ -71,18 +73,22 @@ combined base/GUI library for GUI applications only.
|
|||||||
<li>Rewritten timer.cpp, possible wxChrono class.
|
<li>Rewritten timer.cpp, possible wxChrono class.
|
||||||
<li>Bug tracking system in place.
|
<li>Bug tracking system in place.
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
|
<div style="page-break-inside:avoid">
|
||||||
<H4>Release 2.1.12</H4>
|
<H4>Release 2.1.12</H4>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Release date: January 9th, 2000
|
<li>Release date: January 9th, 2000
|
||||||
<li>Miscellaneous fixes and small enhancements.
|
<li>Miscellaneous fixes and small enhancements.
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
|
<div style="page-break-inside:avoid">
|
||||||
<H4>Release 2.1.13</H4>
|
<H4>Release 2.1.13</H4>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@@ -90,6 +96,7 @@ combined base/GUI library for GUI applications only.
|
|||||||
<li>Miscellaneous fixes and small enhancements.
|
<li>Miscellaneous fixes and small enhancements.
|
||||||
<li>wxDateTime class in beta.
|
<li>wxDateTime class in beta.
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
@@ -102,6 +109,7 @@ combined base/GUI library for GUI applications only.
|
|||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
|
<div style="page-break-inside:avoid">
|
||||||
<H2>Release 2.2.x (final)</H2>
|
<H2>Release 2.2.x (final)</H2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@@ -109,15 +117,18 @@ combined base/GUI library for GUI applications only.
|
|||||||
<li>Unicode compilation working in wxGTK and wxMSW.
|
<li>Unicode compilation working in wxGTK and wxMSW.
|
||||||
<li>wxDateTime class.
|
<li>wxDateTime class.
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
|
<div style="page-break-inside:avoid">
|
||||||
<H2>Release 2.3.x (final)</H2>
|
<H2>Release 2.3.x (final)</H2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Release date: unknown
|
<li>Release date: unknown
|
||||||
<li>WinCE port available.
|
<li>WinCE port available.
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
|
|
||||||
|
@@ -189,9 +189,32 @@ TAG_HANDLER_BEGIN(DIV, "DIV")
|
|||||||
}
|
}
|
||||||
else if(style.IsSameAs(wxT("PAGE-BREAK-INSIDE:AVOID"), false))
|
else if(style.IsSameAs(wxT("PAGE-BREAK-INSIDE:AVOID"), false))
|
||||||
{
|
{
|
||||||
|
// As usual, reuse the current container if it's empty.
|
||||||
|
wxHtmlContainerCell *c = m_WParser->GetContainer();
|
||||||
|
if (c->GetFirstChild() != NULL)
|
||||||
|
{
|
||||||
|
// If not, open a new one.
|
||||||
m_WParser->CloseContainer();
|
m_WParser->CloseContainer();
|
||||||
m_WParser->OpenContainer()->SetCanLiveOnPagebreak(false);
|
c = m_WParser->OpenContainer();
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
// Force this container to live entirely on the same page.
|
||||||
|
c->SetCanLiveOnPagebreak(false);
|
||||||
|
|
||||||
|
// Use a nested container so that nested tags that close and
|
||||||
|
// reopen a container again close this one, but still remain
|
||||||
|
// inside the outer "unbreakable" container.
|
||||||
|
m_WParser->OpenContainer();
|
||||||
|
|
||||||
|
ParseInner(tag);
|
||||||
|
|
||||||
|
// Close both the inner and the outer containers and reopen the
|
||||||
|
// new current one.
|
||||||
|
m_WParser->CloseContainer();
|
||||||
|
m_WParser->CloseContainer();
|
||||||
|
m_WParser->OpenContainer();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -121,52 +121,52 @@ TEST_CASE("wxHtmlPrintout::Pagination", "[html][print]")
|
|||||||
// should move it entirely to the next page, resulting in one extra page
|
// should move it entirely to the next page, resulting in one extra page
|
||||||
// compared to the version without "page-break-inside: avoid".
|
// compared to the version without "page-break-inside: avoid".
|
||||||
static const char* const text =
|
static const char* const text =
|
||||||
"Early in the morning on the fourteenth of the spring month of Nisan the "
|
"Early in the morning on the fourteenth of the spring month of Nisan the<br>"
|
||||||
"Procurator of Judea, Pontius Pilate, in a white cloak lined with blood red, "
|
"Procurator of Judea, Pontius Pilate, in a white cloak lined with blood red,<br>"
|
||||||
"emerged with his shuffling cavalryman's walk into the arcade connecting the two "
|
"emerged with his shuffling cavalryman's walk into the arcade connecting the two<br>"
|
||||||
"wings of the palace of Herod the Great. "
|
"wings of the palace of Herod the Great.<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"More than anything else in the world the Procurator hated the smell of attar of "
|
"More than anything else in the world the Procurator hated the smell of attar of<br>"
|
||||||
"roses. The omens for the day were bad, as this scent had been haunting him "
|
"roses. The omens for the day were bad, as this scent had been haunting him<br>"
|
||||||
"since dawn. "
|
"since dawn.<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"It seemed to the Procurator that the very cypresses and palms in the garden "
|
"It seemed to the Procurator that the very cypresses and palms in the garden<br>"
|
||||||
"were exuding the smell of roses, that this damned stench of roses was even "
|
"were exuding the smell of roses, that this damned stench of roses was even<br>"
|
||||||
"mingling with the smell of leather tackle and sweat from his mounted bodyguard. "
|
"mingling with the smell of leather tackle and sweat from his mounted bodyguard.<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"A haze of smoke was drifting toward the arcade across the upper courtyard of "
|
"A haze of smoke was drifting toward the arcade across the upper courtyard of<br>"
|
||||||
"the garden, coming from the wing at the rear of the palace, the quarters of the "
|
"the garden, coming from the wing at the rear of the palace, the quarters of the<br>"
|
||||||
"first cohort of the XII Legion; known as the \"Lightning,\" it had been "
|
"first cohort of the XII Legion; known as the \"Lightning,\" it had been<br>"
|
||||||
"stationed in Jerusalem since the Procurator's arrival. The same oily perfume "
|
"stationed in Jerusalem since the Procurator's arrival. The same oily perfume<br>"
|
||||||
"of roses was mixed with the acrid smoke that showed that the centuries' cooks "
|
"of roses was mixed with the acrid smoke that showed that the centuries' cooks<br>"
|
||||||
"had started to prepare breakfast "
|
"had started to prepare breakfast<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"\"Oh, gods, what are you punishing me for?.. No, there's no doubt, I have it "
|
"\"Oh, gods, what are you punishing me for?.. No, there's no doubt, I have it<br>"
|
||||||
"again, this terrible incurable pain... hemicrania, when half the head aches... "
|
"again, this terrible incurable pain... hemicrania, when half the head aches...<br>"
|
||||||
"There's no cure for it, nothing helps... I must try not to move my head...\" "
|
"There's no cure for it, nothing helps... I must try not to move my head...\"<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"A chair had already been placed on the mosaic floor by the fountain; without a "
|
"A chair had already been placed on the mosaic floor by the fountain; without a<br>"
|
||||||
"glance around, the Procurator sat in it and stretched out his hand to one side. "
|
"glance around, the Procurator sat in it and stretched out his hand to one side.<br>"
|
||||||
"His secretary deferentially laid a piece of parchment in his hand. Unable to "
|
"His secretary deferentially laid a piece of parchment in his hand. Unable to<br>"
|
||||||
"restrain a grimace of agony, the Procurator gave a fleeting sideways look at "
|
"restrain a grimace of agony, the Procurator gave a fleeting sideways look at<br>"
|
||||||
"its contents, returned the parchment to his secretary and said painfully, \"The "
|
"its contents, returned the parchment to his secretary and said painfully, \"The<br>"
|
||||||
"accused comes from Galilee, does he? Was the case sent to the tetrarch?\" "
|
"accused comes from Galilee, does he? Was the case sent to the tetrarch?\"<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"\"Yes, Procurator,\" replied the secretary. \"He declined to confirm the "
|
"\"Yes, Procurator,\" replied the secretary. \"He declined to confirm the<br>"
|
||||||
"finding of the court and passed the Sanhedrin's sentence of death to you for "
|
"finding of the court and passed the Sanhedrin's sentence of death to you for<br>"
|
||||||
"confirmation.\" "
|
"confirmation.\"<br>"
|
||||||
"\n"
|
"<br>"
|
||||||
"The Procurator's cheek twitched, and he said quietly, \"Bring in the accused.\" "
|
"The Procurator's cheek twitched, and he said quietly, \"Bring in the accused.\"<br>"
|
||||||
;
|
;
|
||||||
|
|
||||||
pr.SetHtmlText
|
pr.SetHtmlText
|
||||||
(
|
(
|
||||||
wxString::Format
|
wxString::Format
|
||||||
(
|
(
|
||||||
"<img width=\"100\" height=\"600\" src=\"dummy\"/>"
|
"<img width=\"100\" height=\"500\" src=\"dummy\"/>"
|
||||||
"<div>%s</div>"
|
"<div>%s</div>"
|
||||||
"<br/>"
|
"<br/>"
|
||||||
"<img width=\"100\" height=\"600\" src=\"dummy\"/>",
|
"<img width=\"100\" height=\"400\" src=\"dummy\"/>",
|
||||||
text
|
text
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -176,10 +176,10 @@ TEST_CASE("wxHtmlPrintout::Pagination", "[html][print]")
|
|||||||
(
|
(
|
||||||
wxString::Format
|
wxString::Format
|
||||||
(
|
(
|
||||||
"<img width=\"100\" height=\"600\" src=\"dummy\"/>"
|
"<img width=\"100\" height=\"500\" src=\"dummy\"/>"
|
||||||
"<div style=\"page-break-inside:avoid\">%s</div>"
|
"<div style=\"page-break-inside:avoid\">%s</div>"
|
||||||
"<br/>"
|
"<br/>"
|
||||||
"<img width=\"100\" height=\"600\" src=\"dummy\"/>",
|
"<img width=\"100\" height=\"400\" src=\"dummy\"/>",
|
||||||
text
|
text
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user