Skip to content

Commit 0f023aa

Browse files
committed
feat: -cr-only-if: not-following-inpage-footnote
1 parent 176dba3 commit 0f023aa

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

crengine/src/lvstsheet.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,6 +3075,7 @@ static const char * css_cr_only_if_names[]={
30753075
"inside-inpage-footnote",
30763076
"not-inside-inpage-footnote",
30773077
"following-inpage-footnote",
3078+
"not-following-inpage-footnote",
30783079
"line-height-normal",
30793080
"not-line-height-normal",
30803081
NULL
@@ -3115,6 +3116,7 @@ enum cr_only_if_t {
31153116
cr_only_if_inside_inpage_footnote,
31163117
cr_only_if_not_inside_inpage_footnote,
31173118
cr_only_if_following_inpage_footnote,
3119+
cr_only_if_not_following_inpage_footnote,
31183120
cr_only_if_line_height_normal,
31193121
cr_only_if_not_line_height_normal,
31203122
};
@@ -5366,6 +5368,36 @@ void LVCssDeclaration::apply( css_style_rec_t * style, const ldomNode * node ) c
53665368
prevsibling = prevsibling->getUnboxedPrevSibling(true);
53675369
}
53685370
}
5371+
else if ( only_if == cr_only_if_not_following_inpage_footnote) {
5372+
if ( ! STYLE_HAS_CR_HINT(style, FOOTNOTE_INPAGE)) {
5373+
ldomNode * prevsibling = node->getUnboxedPrevSibling(true);
5374+
while (true) {
5375+
if ( prevsibling == NULL || prevsibling->isNull() ) {
5376+
break;
5377+
}
5378+
5379+
css_style_ref_t prevstyle = prevsibling->getStyle();
5380+
if ( prevstyle.isNull() ) {
5381+
break;
5382+
}
5383+
if ( STYLE_HAS_CR_HINT(prevstyle, FOOTNOTE_INPAGE)) {
5384+
// found a footnote that we are following
5385+
return; // don't apply anything more of this declaration to this style
5386+
}
5387+
if ( ! STYLE_HAS_CR_HINT(prevstyle, EXTEND_FOOTNOTE_INPAGE) ) {
5388+
// if the sibling doesn't have `extend-footnote-inpage` then the chain
5389+
// of footnote extensions has been explicitly broken and we want to stop.
5390+
// Otherwise, we continue to look for an actual footnote node in the
5391+
// siblings before this one.
5392+
break;
5393+
}
5394+
5395+
// NOTE: This needs to skip over text nodes because they don't have a style here that we can check
5396+
// They can still be matched via the `autoBoxing` selector
5397+
prevsibling = prevsibling->getUnboxedPrevSibling(true);
5398+
}
5399+
}
5400+
}
53695401
else if ( only_if == cr_only_if_line_height_normal || only_if == cr_only_if_not_line_height_normal ) {
53705402
if ( const ldomNode * parent_node = node->getParentNode(); style->line_height == css_length_t(css_val_inherited, 0) && parent_node ) {
53715403
const css_style_ref_t parent_style = node->getParentNode()->getStyle();

0 commit comments

Comments
 (0)