aboutsummaryrefslogtreecommitdiff
path: root/dw/textblock_linebreaking.cc
diff options
context:
space:
mode:
authorCameron Paul <cpaul37@gmail.com>2025-06-17 13:36:32 -0500
committerRodrigo Arias Mallo <rodarima@gmail.com>2025-07-07 23:05:28 +0200
commit50121125a0a79658c456ba88816a63e5b836a6ab (patch)
tree9d19202f318fb136e413cad3cacf1676f7b519c6 /dw/textblock_linebreaking.cc
parente3cedc586990f246ad8679a8a91bbfe88a8ac902 (diff)
Fix text-align
Inline elements are now aligned based on the text-align value of their containing element instead of their own text-align value. Block level elements are no longer affected by the text-align property. Fixes: https://github.com/dillo-browser/dillo/issues/410
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r--dw/textblock_linebreaking.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index 1a95cb70..06486c12 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1804,7 +1804,23 @@ void Textblock::alignLine (int lineIndex)
int lineBreakWidth =
this->lineBreakWidth - (line->leftOffset + line->rightOffset);
- switch (firstWord->style->textAlign) {
+ core::style::TextAlignType alignStyle = core::style::TEXT_ALIGN_LEFT;
+
+ /**
+ * Only inline elements should be affected by the text-align property.
+ * While alignStyle will still apply to other elements, the default
+ * value of TEXT_ALIGN_LEFT will have no effect on the alignment.
+ */
+ if (firstWord->style->display == core::style::DISPLAY_INLINE ||
+ firstWord->style->display == core::style::DISPLAY_INLINE_BLOCK) {
+ /**
+ * Elements that *are* affected by text-align are aligned based on
+ * the text-align value of their containing element.
+ */
+ alignStyle = getStyle()->textAlign;
+ }
+
+ switch (alignStyle) {
case core::style::TEXT_ALIGN_LEFT:
DBG_OBJ_MSG ("construct.line", 1,
"first word has 'text-align: left'");