Skip to content

Commit c837e3f

Browse files
google-labs-jules[bot]lws-team
authored andcommitted
lhp: dlo: fix inline element layout regression
- Corrects the logic in `LHPCB_CONTENT` to prevent `box.w` from being incorrectly expanded to full screen width for inline elements. The condition `if (!box.w.whole && (!lhp_is_inline(ps) || ps->forced_inline))` was flawed as it forced expansion for all forced-inline elements. - Replaces the flawed condition with `if (!box.w.whole && !lhp_is_inline(ps))`, ensuring width expansion is restricted to block-level elements. - Adds `lhp_tag_cmp` for case-insensitive HTML tag matching to ensure tags like `<SPAN>` are correctly identified and processed as inline. - Marks `<span>` as `forced_inline` to ensure it is treated as an inline element, preventing fallback to block behavior.
1 parent 4490048 commit c837e3f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/misc/dlo/dlo-lhp.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ static const struct {
9999
{ "span", 4 },
100100
};
101101

102+
static int
103+
lhp_tag_cmp(const char *buf, const char *name, size_t len)
104+
{
105+
while (len--) {
106+
char c1 = *buf++, c2 = *name++;
107+
108+
if (c1 >= 'A' && c1 <= 'Z')
109+
c1 = (char)(c1 + 'a' - 'A');
110+
if (c2 >= 'A' && c2 <= 'Z')
111+
c2 = (char)(c2 + 'a' - 'A');
112+
113+
if (c1 != c2)
114+
return 1;
115+
}
116+
return 0;
117+
}
118+
102119
static int
103120
lhp_is_inline(lhp_pstack_t *ps)
104121
{
@@ -621,9 +638,10 @@ lhp_displaylist_layout(lhp_ctx_t *ctx, char reason)
621638
elem_match = 0;
622639
for (n = 0; n < (int)LWS_ARRAY_SIZE(elems); n++)
623640
if (ctx->npos == elems[n].elem_len &&
624-
!memcmp(ctx->buf, elems[n].elem, elems[n].elem_len))
641+
!lhp_tag_cmp(ctx->buf, elems[n].elem, elems[n].elem_len))
625642
elem_match = n + 1;
626643

644+
627645
switch (reason) {
628646
case LHPCB_CONSTRUCTED:
629647
case LHPCB_DESTRUCTED:
@@ -1276,7 +1294,7 @@ lhp_displaylist_layout(lhp_ctx_t *ctx, char reason)
12761294
lws_csp_px(ps_con->css_padding[CCPAS_RIGHT], ps_con));
12771295
}
12781296

1279-
if (!box.w.whole && !ps->forced_inline)
1297+
if (!box.w.whole)
12801298
lws_fx_sub(&box.w, &ctx->ic.wh_px[0], &box.x);
12811299
assert(ps_con);
12821300

0 commit comments

Comments
 (0)