Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions packages/core/src/renderer/renderToDrawlist/renderTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ export function renderTree(
const styleStack: ResolvedTextStyle[] = [inheritedStyle];
const layoutStack: LayoutTree[] = [layoutTree];
const clipStack: (ClipRect | undefined)[] = [undefined];
const themeByNode = new WeakMap<RuntimeInstance, Theme>();
themeByNode.set(tree, theme);
const themeStack: Theme[] = [theme];

while (nodeStack.length > 0) {
const nodeOrPop = nodeStack.pop();
Expand All @@ -126,6 +125,7 @@ export function renderTree(
continue;
}
if (!nodeOrPop) continue;
const currentTheme = themeStack.pop() ?? theme;
const parentStyle = styleStack.pop();
if (!parentStyle) continue;
const layoutNode = layoutStack.pop();
Expand All @@ -147,7 +147,6 @@ export function renderTree(
continue;
}

const currentTheme = themeByNode.get(node) ?? theme;
let renderTheme = currentTheme;
if (vnode.kind === "themed") {
const props = vnode.props as { theme?: unknown };
Expand All @@ -161,9 +160,7 @@ export function renderTree(
const props = vnode.props as { theme?: unknown };
renderTheme = mergeThemeOverride(currentTheme, props.theme);
}
for (const child of node.children) {
themeByNode.set(child, renderTheme);
}
const nodeStackLenBeforePush = nodeStack.length;

// Depth-first preorder: render node, then its children.
switch (vnode.kind) {
Expand Down Expand Up @@ -409,6 +406,12 @@ export function renderTree(
default:
break;
}

for (let i = nodeStackLenBeforePush; i < nodeStack.length; i++) {
if (nodeStack[i] !== null) {
themeStack.push(renderTheme);
}
}
}

if (DEV_MODE && clipStack.length !== 0) {
Expand Down
8 changes: 7 additions & 1 deletion packages/native/vendor/zireael/src/util/zr_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@
/*
Number of elements in a fixed-size array.

Rejects pointer arguments at compile time.
On compilers with GNU builtins, reject pointer arguments at compile time.
MSVC lacks __builtin_types_compatible_p/__typeof__, so fall back to the
size-based form to keep callsites readable and portable.
*/
#if defined(_MSC_VER) && !defined(__clang__)
#define ZR_ARRAYLEN(arr) (sizeof(arr) / sizeof((arr)[0]))
#else
#define ZR_ARRAYLEN(arr) \
((sizeof(arr) / sizeof((arr)[0])) + \
0u * sizeof(char[1 - 2 * !!__builtin_types_compatible_p(__typeof__(arr), __typeof__(&(arr)[0]))]))
#endif

/*
Generic min/max helpers.
Expand Down
2 changes: 1 addition & 1 deletion vendor/zireael
Loading