-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow calculating a nicer normal line-height #603
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3129,7 +3129,14 @@ lString32 renderListItemMarker( ldomNode * enode, int & marker_width, int * fina | |
if (line_h < 0) { // -1, not specified by caller: find it out from the node | ||
if ( style->line_height.type == css_val_unspecified && | ||
style->line_height.value == css_generic_normal ) { | ||
line_h = font->getHeight(); // line-height: normal | ||
int em = font->getSize(); | ||
if ( style->cr_normal_line_height.type == css_val_unspecified && | ||
style->cr_normal_line_height.value == css_generic_normal ) { | ||
line_h = font->getHeight(); // line-height: normal | ||
} | ||
else { | ||
line_h = lengthToPx(enode, style->cr_normal_line_height, em, em, true); | ||
} | ||
} | ||
else { | ||
int em = font->getSize(); | ||
|
@@ -3400,7 +3407,13 @@ void renderFinalBlock( ldomNode * enode, LFormattedText * txform, RenderRectAcce | |
// Only "normal" uses enode->getFont()->getHeight() | ||
if ( style->line_height.type == css_val_unspecified && | ||
style->line_height.value == css_generic_normal ) { | ||
line_h = enode->getFont()->getHeight(); // line-height: normal | ||
if ( style->cr_normal_line_height.type == css_val_unspecified && | ||
style->cr_normal_line_height.value == css_generic_normal ) { | ||
line_h = enode->getFont()->getHeight(); // line-height: normal | ||
} | ||
else { | ||
line_h = lengthToPx(enode, style->cr_normal_line_height, em, em, true); | ||
} | ||
} | ||
else { | ||
// In all other cases (%, em, unitless/unspecified), we can just scale 'em', | ||
|
@@ -4584,6 +4597,8 @@ void copystyle( css_style_ref_t source, css_style_ref_t dest ) | |
dest->content = source->content ; | ||
dest->cr_hint.type = source->cr_hint.type ; | ||
dest->cr_hint.value = source->cr_hint.value ; | ||
dest->cr_normal_line_height.type = source->cr_normal_line_height.type ; | ||
dest->cr_normal_line_height.value = source->cr_normal_line_height.value ; | ||
} | ||
|
||
// Only used by renderBlockElementLegacy() | ||
|
@@ -7455,7 +7470,13 @@ void renderBlockElementEnhanced( FlowState * flow, ldomNode * enode, int x, int | |
int line_h; | ||
if ( style->line_height.type == css_val_unspecified && | ||
style->line_height.value == css_generic_normal ) { | ||
line_h = enode->getFont()->getHeight(); // line-height: normal | ||
if ( style->cr_normal_line_height.type == css_val_unspecified && | ||
style->cr_normal_line_height.value == css_generic_normal ) { | ||
line_h = enode->getFont()->getHeight(); // line-height: normal | ||
} | ||
else { | ||
line_h = lengthToPx(enode, style->cr_normal_line_height, em, em, true); | ||
} | ||
} | ||
else { | ||
// In all other cases (%, em, unitless/unspecified), we can just | ||
|
@@ -11205,6 +11226,9 @@ void setNodeStyle( ldomNode * enode, css_style_ref_t parent_style, LVFontRef par | |
break; | ||
} | ||
} | ||
if (pstyle->cr_normal_line_height.type == css_val_inherited) { | ||
pstyle->cr_normal_line_height = parent_style->cr_normal_line_height; // inherit as-is | ||
} | ||
Comment on lines
11227
to
+11231
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just asking in case you did wonder and your brain worked better than mine: |
||
|
||
// vertical_align: computed value: "for percentage and length values, the absolute length, otherwise the keyword as specified" | ||
// Not inherited by default (html5.css has TR,TD,TH explicitely set to "vertical-align: inherit", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can shove the
int em = font->getSize();
in theelse {}
branch.