Commit Graph

4314 Commits

Author SHA1 Message Date
Martín Lucas Golini
0c742d6431 Fix Windows build. 2026-05-21 21:25:19 -03:00
Martín Lucas Golini
ed333b3839 Optimization in RichText and added benchmark. 2026-05-21 19:19:47 -03:00
Martín Lucas Golini
ca56d7d935 Should fix build in some envs. 2026-05-21 14:10:29 -03:00
Martín Lucas Golini
c834f82566 Huge RichText refactor to improve inline-box support. Still WIP. 2026-05-21 12:22:49 -03:00
Martín Lucas Golini
dd2134b0d0 Fix unit-tests build. 2026-05-21 01:02:06 -03:00
Martín Lucas Golini
71bea09f2d Added UITabWidgetSplitter (what should have been the UICodeEditorSplitter). 2026-05-21 00:30:33 -03:00
Martín Lucas Golini
0defa0ada3 Fix hex color string parsing.
UIMarkdownView now uses the HTMLFormatter::HTMLtoXML.
Removed formatting hack to force strict XML from HTML, now we should always use HTMLFormatter::HTMLtoXML.
2026-05-20 01:39:05 -03:00
Martín Lucas Golini
7daca81bd6 Allow to select the default "New Tab Position" (SpartanJ/ecode#904) from the settings menu at Settings -> Document -> Global Settings -> New Tab Position.
| Option | Behavior |
	| --- | --- |
	| **`afterActive`** | Opens immediately to the right of your currently focused tab. *(VS Code default)* |
	| **`last`** | Opens at the very end of the entire tab bar, to the right of all open tabs. |
	| **`first`** | Opens at the very beginning of the tab bar, to the far left. |
	| **`leftOfActive`** | Opens immediately to the left of your currently focused tab. |
2026-05-19 20:38:24 -03:00
Martín Lucas Golini
d27590753a Don't let <head> participate in layouting. 2026-05-19 18:49:38 -03:00
Martín Lucas Golini
ea1a148b30 Fix a possible crash when loading fonts. 2026-05-19 02:04:48 -03:00
Martín Lucas Golini
9d8dc55445 Fix crash when displaying signature help (SpartanJ/ecode#902). 2026-05-19 01:40:10 -03:00
Martín Lucas Golini
e5c5b77c2c Fix fixed tr height not being applied. 2026-05-18 19:05:00 -03:00
Martín Lucas Golini
97fc336955 Fix: When build is triggered with unsaved files don't display the file save dialog for files that are just in text buffer.
Fix: Ctrl+W does not close the tab in Build Settings: Added Event::OnFocusWithin so the tab widget registers that event to setCurrenWidget in UICodeEditorSplitter.
2026-05-18 01:08:14 -03:00
Martín Lucas Golini
8cfedc4590 Added alignment-baseline and vertical-align support in RichText and all its consumers. 2026-05-17 21:54:08 -03:00
Martín Lucas Golini
f22ce3f8d2 Fix some draw invalidation issues. 2026-05-17 03:21:15 -03:00
Martín Lucas Golini
afe3df0650 Improve baseline aligment in inline-blocks.
Improved html architecture documentation.
2026-05-17 03:19:08 -03:00
Martín Lucas Golini
e223ed6d3c Initial support for HTML element tags: details and summary. 2026-05-16 22:23:31 -03:00
Martín Lucas Golini
702f995608 Add support for data attributes and CSS selectors using them. 2026-05-16 19:23:48 -03:00
Martín Lucas Golini
acc27edd8a Fix macOS tests (it was a driver bug ¬¬) 2026-05-16 14:18:46 -03:00
Martín Lucas Golini
3dadd58ce1 Various fixes for HTML compat layer. 2026-05-16 03:26:55 -03:00
Martín Lucas Golini
a580b3b97b Try luck with the complexLayout2 test (macOS CI is failing with no reason). 2026-05-15 23:41:41 -03:00
Martín Lucas Golini
9086a58524 Fixed responseHeaderLineLargerThanReceiveBuffer test on Windows.
Some extra minor fixes.
2026-05-15 22:29:56 -03:00
Martín Lucas Golini
a6b9f39ac3 Several crashes fixes for HTML loading. 2026-05-15 18:59:51 -03:00
Martín Lucas Golini
852adaa2c5 CSS Block Semantics plan executed. 2026-05-15 02:42:05 -03:00
Martín Lucas Golini
1af86f9110 Merge branch 'feature/system-font-resolver' into develop 2026-05-15 01:52:29 -03:00
Martín Lucas Golini
4c25197e85 Thread-safety. 2026-05-15 01:10:44 -03:00
Martín Lucas Golini
6c7b513494 More clean up. 2026-05-15 00:54:06 -03:00
Martín Lucas Golini
af88532361 Nit. 2026-05-15 00:26:33 -03:00
Martín Lucas Golini
d6906d2ebf A few nits. 2026-05-14 22:07:34 -03:00
Martín Lucas Golini
368510cdff Fix Android build.
A few adjustments in the tests.
2026-05-14 21:58:40 -03:00
Martín Lucas Golini
b440f0e2a2 Fixes for Haiku and all fallbacks. 2026-05-15 00:10:40 +00:00
Martín Lucas Golini
b00547655d Some mingw build fixes for my local build. 2026-05-14 19:27:16 -03:00
Martín Lucas Golini
5b7804dc32 Fixes and improvements. 2026-05-14 13:59:27 -03:00
Martín Lucas Golini
65068c1b45 compilation fix 2026-05-14 13:14:14 -03:00
Martín Lucas Golini
3824bb9c8a Try fixes. 2026-05-14 12:56:14 -03:00
Martín Lucas Golini
138c6eb30e Merge branch 'develop' into feature/system-font-resolver 2026-05-14 02:29:04 -03:00
Martín Lucas Golini
f815d99489 Some extra fixes.
fontconfig is now loaded at runtime.
2026-05-14 02:28:48 -03:00
Martín Lucas Golini
1b34eb7b2f Fix small text collapse bug. 2026-05-14 01:43:27 -03:00
Martín Lucas Golini
359dc8f157 block and inline-block layouter fixes, added a plan for a definitive fix in block layouter. 2026-05-14 01:33:00 -03:00
Martín Lucas Golini
828adf581d Initial work on the system font resolver. 2026-05-13 23:59:36 -03:00
Martín Lucas Golini
4b58b2f61b Fix line-height. 2026-05-13 12:53:40 -03:00
Martín Lucas Golini
7be0f28c31 Fix text collapsing in UITextSpan. 2026-05-13 11:54:30 -03:00
Martín Lucas Golini
1b263a531b Do not set broken colors. 2026-05-13 01:52:57 -03:00
Martín Lucas Golini
ae0150ae75 Fix inline-blocks with fixed size. 2026-05-13 01:43:03 -03:00
Martín Lucas Golini
9f257c6fef CSS: Inline-block layout, line-height inheritance, and font shorthand fixes
Core problem
Three interconnected bugs caused incorrect rendering of display: inline-block elements:
1. Inline-block elements with explicit width/height (e.g. share buttons with width: 20px; height: 20px) had zero dimensions — their internal children were never laid out.
2. Text-based inline-blocks (e.g. <a href="...">Download</a> styled as display: inline-block) were affected by an incorrect font shorthand that failed to reset line-height to normal, allowing an inherited line-height: 10 on <body> to inflate element heights via the line box strut.
3. Inline-block elements with long text did not wrap atomically to the next line when they exceeded the container width.
Changes by file
include/eepp/graphics/richtext.hpp / src/eepp/graphics/richtext.cpp
- Added lineHeight (Float) and isAtomic (bool) fields to SpanBlock. The lineHeight field provides per-span line-height overriding the global mLineHeight — this is used by inline-block spans to set their line height to the font's em height rather than inheriting the container's line-height. The isAtomic flag marks a span as an atomic inline-level box: during RichText Pass 1 (both the non-float and float-aware paths), atomic spans check whether the full text width plus margins fits on the current line; if not, they push to the next line before any text wrapping occurs. This matches the CSS behavior where an inline-block drops to a new line as an opaque unit rather than having its text wrap within the parent line.
- Updated addSpan() to accept lineHeight and isAtomic parameters (with defaults of 0 and false to preserve existing call sites).
- Added per-span line-height priority (3-tier cascade): a span's own lineHeight takes precedence over the global mLineHeight, which takes precedence over the font's intrinsic line spacing. This ensures inline-block spans use font em height (set by UIRichText::rebuildRichText), pure inline text uses the container's line-height, and all fall back to font metrics.
- Added line box strut in Pass 2 (both paths): line.height = std::max(line.height, mLineHeight) ensures every line box respects the containing block's line-height, per CSS 2.1 §10.8.1. Previously a line box's height was determined solely by the tallest inline element on that line; now the container's line-height acts as a minimum.
- Propagated pText->lineHeight and pText->isAtomic through to the SpanBlock construction in RenderSpan creation in both the non-float and float-aware paths, so the per-span values persist from addSpan() through to layout.
include/eepp/ui/uitextspan.hpp / src/eepp/ui/uitextspan.cpp
- isMergeable() now returns true for both CSSDisplay::Inline and CSSDisplay::InlineBlock. Previously only Inline was mergeable. This allows text-based inline-block content to participate in the parent container's RichText flow (baseline-aligned), while the widget still draws its own border and background independently.
- Added isInlineBlock() helper method that returns mDisplay == CSSDisplay::InlineBlock, used by callers throughout the layouter and RichText code to distinguish inline-block treatment from pure inline.
- Fixed drawBorder(): inline-block widgets now draw their border at the widget bounds (mScreenPos, mSize) without expanding by padding, because padding has already been incorporated into the widget's size via the RichText bounds expansion. Pure inline spans continue to draw the border expanded by padding (the old behavior).
src/eepp/ui/uirichtext.cpp
- In rebuildRichText(), inline-block widgets are now handled via two distinct code paths:
  - Text-based inline-block (has its own text content): treated as mergeable — text flows into the parent container's RichText as a SpanBlock with isAtomic = true for atomic line-wrapping, and the span's lineHeight set to the font's em height. Padding and margins are propagated through the SpanBlock. The widget's size and hit-boxes are computed from the parent RichText's layout (via BlockLayouter::positionRichTextChildren bounds expansion).
  - Inline-block without text (has only child widgets, e.g. share buttons containing nested <span> elements): diverted to the CustomBlock path — the widget runs its own BlockLayouter::updateLayout() to process internal children and determine its intrinsic size, and is added to the parent's RichText as a CustomBlock (atomic inline-level box). This ensures inner children are properly laid out rather than left at zero dimensions.
- Whitespace collapse logic around inline-block spans now accounts for whether the adjacent nodes are inline, preventing incorrect stripping of leading/trailing spaces.
src/eepp/ui/blocklayouter.cpp
- BlockLayouter::updateLayout(): the early return for mergeable widgets now makes an exception for inline-block widgets that have no text of their own — these still need their internal children laid out, so the layouter proceeds rather than returning early.
- BlockLayouter::positionRichTextChildren(): inline-block widgets are processed in two ways depending on whether they have text:
  - Text-based: bounds computed from the parent RichText's span positions, expanded by padding. The widget's position and size are set from these bounds.
  - No-text (CustomBlock): positioned via getNextCustomSpan() from the parent RichText's CustomBlock spans, with padding expansion for bounds.

  Both paths expand the widget's pixel bounds by padding for inline-block styling. A bool handled flag replaces the previous goto-based control flow.
- Added bounds and hit-box padding expansion for inline-block widgets in the CustomBlock positioning path (previously only the mergeable path had this).
src/eepp/ui/css/stylesheetspecification.cpp
- Fixed font shorthand registration: changed the component list from { font-style, font-size, line-spacing, font-family } to { font-style, font-weight, font-size, line-height, font-family }. The line-spacing property does not participate in the font shorthand per the CSS Fonts specification (§3.1); line-height does.
- Fixed font shorthand parser:
  - font-weight keywords (bold, bolder, lighter) are now emitted as a separate font-weight property instead of being incorrectly merged into the font-style property string.
  - When the font shorthand does not include an explicit /line-height value, the parser now always emits line-height: normal to reset any previously inherited line-height. Previously it emitted nothing, allowing an inherited line-height (e.g. line-height: 10 on <body>) to leak into child elements that used the font shorthand.
src/tests/unit_tests/uihtml_tests.cpp
- Added UIRichText.anchorPadding test: verifies that an inline-block <a> tag with padding and border renders correctly at the expected size (81×28 px for "Download" text in 11px Noto Sans with padding: 6px 14px and border: 1px solid), using both pixel-diff comparison and explicit size assertions. The HTML uses line-height: 1.5 on <body> and font: 11px on the inline-block anchor.
- Added UIRichText.anchorPaddingLineHeight test: same layout but with line-height: 10 on <body>, verifying that the per-span line-height prevents the inherited line-height: 10 from inflating the inline-block anchor's dimensions.
- Added UIBackground.InlineBlockImageSpans test: verifies that inline-block <a> elements with fixed width/height (20×20 px share buttons) and nested child <span> elements (with display: block and text-indent: -9999px) have non-zero dimensions and render correctly with pixel-diff comparison. This covers the CustomBlock path for inline-blocks without text of their own.
2026-05-13 00:49:36 -03:00
Martín Lucas Golini
eaa82411c3 Improve @font-face font loading.
Added new flag UI_CREATING_NODE that will be used for performance optimizations.
2026-05-12 01:51:35 -03:00
Martín Lucas Golini
0f8d930e80 Add support for --var: var(--other-var).
Reset global definition for body and html elements when new styles are loaded (required when these elements have only variable definitions).
2026-05-11 21:22:49 -03:00
Martín Lucas Golini
4fa495f0e1 Fix CSS parsing issues with media queries and imports.
Added sup and sub html elements.
2026-05-11 19:00:58 -03:00
Martín Lucas Golini
2557f3c0be Added HTML label element support. 2026-05-11 16:28:49 -03:00
Martín Lucas Golini
bd9e70fb83 Fixes in how we process the CSS selector specificity.
Fixes in selector rule parser.
Stub implementation for attributes filter in CSS.
Fixes in `background-position` and `background` shorthand parsers.
Added a few HTML elements tags.
Added body default left and right margin.
2026-05-11 14:43:24 -03:00