Add support for style="page-break-inside:avoid" to wxHTML
Allow using this style to prevent page breaks inside the given <div>.
This commit is contained in:
@@ -102,6 +102,7 @@ All (GUI):
|
|||||||
- Add wxHtmlEasyPrinting::SetPromptMode() (pavel-t).
|
- Add wxHtmlEasyPrinting::SetPromptMode() (pavel-t).
|
||||||
- Fix possible infinite loop in wxHtmlWindow layout (trivia21).
|
- Fix possible infinite loop in wxHtmlWindow layout (trivia21).
|
||||||
- Add "hint" property support to XRC for wxComboBox and wxSearchCtrl.
|
- Add "hint" property support to XRC for wxComboBox and wxSearchCtrl.
|
||||||
|
- Add support for style="page-break-inside:avoid" to <div> in wxHTML.
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -187,6 +187,12 @@ TAG_HANDLER_BEGIN(DIV, "DIV")
|
|||||||
m_WParser->OpenContainer();
|
m_WParser->OpenContainer();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if(style.IsSameAs(wxT("PAGE-BREAK-INSIDE:AVOID"), false))
|
||||||
|
{
|
||||||
|
m_WParser->CloseContainer();
|
||||||
|
m_WParser->OpenContainer()->SetCanLiveOnPagebreak(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Treat other STYLE parameters here when they're supported.
|
// Treat other STYLE parameters here when they're supported.
|
||||||
|
@@ -107,6 +107,74 @@ TEST_CASE("wxHtmlPrintout::Pagination", "[html][print]")
|
|||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
CHECK( CountPages(pr) == 2 );
|
CHECK( CountPages(pr) == 2 );
|
||||||
|
|
||||||
|
// Also test that forbidding page breaks inside a paragraph works: it
|
||||||
|
// should move it entirely to the next page, resulting in one extra page
|
||||||
|
// compared to the version without "page-break-inside: avoid".
|
||||||
|
static const char* const text =
|
||||||
|
"Early in the morning on the fourteenth of the spring month of Nisan the "
|
||||||
|
"Procurator of Judea, Pontius Pilate, in a white cloak lined with blood red, "
|
||||||
|
"emerged with his shuffling cavalryman's walk into the arcade connecting the two "
|
||||||
|
"wings of the palace of Herod the Great. "
|
||||||
|
"\n"
|
||||||
|
"More than anything else in the world the Procurator hated the smell of attar of "
|
||||||
|
"roses. The omens for the day were bad, as this scent had been haunting him "
|
||||||
|
"since dawn. "
|
||||||
|
"\n"
|
||||||
|
"It seemed to the Procurator that the very cypresses and palms in the garden "
|
||||||
|
"were exuding the smell of roses, that this damned stench of roses was even "
|
||||||
|
"mingling with the smell of leather tackle and sweat from his mounted bodyguard. "
|
||||||
|
"\n"
|
||||||
|
"A haze of smoke was drifting toward the arcade across the upper courtyard of "
|
||||||
|
"the garden, coming from the wing at the rear of the palace, the quarters of the "
|
||||||
|
"first cohort of the XII Legion; known as the \"Lightning,\" it had been "
|
||||||
|
"stationed in Jerusalem since the Procurator's arrival. The same oily perfume "
|
||||||
|
"of roses was mixed with the acrid smoke that showed that the centuries' cooks "
|
||||||
|
"had started to prepare breakfast "
|
||||||
|
"\n"
|
||||||
|
"\"Oh, gods, what are you punishing me for?.. No, there's no doubt, I have it "
|
||||||
|
"again, this terrible incurable pain... hemicrania, when half the head aches... "
|
||||||
|
"There's no cure for it, nothing helps... I must try not to move my head...\" "
|
||||||
|
"\n"
|
||||||
|
"A chair had already been placed on the mosaic floor by the fountain; without a "
|
||||||
|
"glance around, the Procurator sat in it and stretched out his hand to one side. "
|
||||||
|
"His secretary deferentially laid a piece of parchment in his hand. Unable to "
|
||||||
|
"restrain a grimace of agony, the Procurator gave a fleeting sideways look at "
|
||||||
|
"its contents, returned the parchment to his secretary and said painfully, \"The "
|
||||||
|
"accused comes from Galilee, does he? Was the case sent to the tetrarch?\" "
|
||||||
|
"\n"
|
||||||
|
"\"Yes, Procurator,\" replied the secretary. \"He declined to confirm the "
|
||||||
|
"finding of the court and passed the Sanhedrin's sentence of death to you for "
|
||||||
|
"confirmation.\" "
|
||||||
|
"\n"
|
||||||
|
"The Procurator's cheek twitched, and he said quietly, \"Bring in the accused.\" "
|
||||||
|
;
|
||||||
|
|
||||||
|
pr.SetHtmlText
|
||||||
|
(
|
||||||
|
wxString::Format
|
||||||
|
(
|
||||||
|
"<img width=\"100\" height=\"600\" src=\"dummy\"/>"
|
||||||
|
"<div>%s</div>"
|
||||||
|
"<br/>"
|
||||||
|
"<img width=\"100\" height=\"600\" src=\"dummy\"/>",
|
||||||
|
text
|
||||||
|
)
|
||||||
|
);
|
||||||
|
CHECK( CountPages(pr) == 2 );
|
||||||
|
|
||||||
|
pr.SetHtmlText
|
||||||
|
(
|
||||||
|
wxString::Format
|
||||||
|
(
|
||||||
|
"<img width=\"100\" height=\"600\" src=\"dummy\"/>"
|
||||||
|
"<div style=\"page-break-inside:avoid\">%s</div>"
|
||||||
|
"<br/>"
|
||||||
|
"<img width=\"100\" height=\"600\" src=\"dummy\"/>",
|
||||||
|
text
|
||||||
|
)
|
||||||
|
);
|
||||||
|
CHECK( CountPages(pr) == 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //wxUSE_HTML
|
#endif //wxUSE_HTML
|
||||||
|
Reference in New Issue
Block a user