refactor(core): remove Child from layout_delizia
What changed, and why it matters
This is a straightforward internal code cleanup in the bootloader user interface of Trezor firmware. It removes a wrapper type called Child that tracked whether child UI components needed repainting. The commit message explains that the bootloader screen is redrawn after every event anyway, so the tracking wrapper served no purpose. There is no user-visible behavior change and no security fix.
No security action needed. Treat as normal refactoring during code review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors three Rust UI components in core/embed/rust/src/ui/layout_delizia to store child components (Label, Button) directly instead of wrapping them in Child
Changed components
core/embed/rust/src/ui/layout_delizia/bootloader/intro.rscore/embed/rust/src/ui/layout_delizia/bootloader/menu.rscore/embed/rust/src/ui/layout_delizia/component/bl_confirm.rsInspect captured patch +53 / −68
### core/embed/rust/src/ui/layout_delizia/bootloader/intro.rs
@@ -6,7 +6,7 @@ use super::super::theme::bootloader::{
CONTENT_PADDING, CORNER_BUTTON_AREA, MENU32, TEXT_NORMAL, TEXT_WARNING, TITLE_AREA,
};
use crate::strutil::TString;
-use crate::ui::component::{Child, Component, Event, EventCtx, Label, Pad};
+use crate::ui::component::{Component, Event, EventCtx, Label, Pad};
use crate::ui::constant::screen;
use crate::ui::display::Icon;
use crate::ui::geometry::{Alignment, Insets, Point, Rect};
@@ -21,33 +21,29 @@ pub enum IntroMsg {
pub struct Intro<'a> {
bg: Pad,
- title: Child<Label<'a>>,
- menu: Child<Button>,
- host: Child<Button>,
- text: Child<Label<'a>>,
- warn: Option<Child<Label<'a>>>,
+ title: Label<'a>,
+ menu: Button,
+ host: Button,
+ text: Label<'a>,
+ warn: Option<Label<'a>>,
}
impl<'a> Intro<'a> {
pub fn new(title: TString<'a>, content: TString<'a>, fw_ok: bool) -> Self {
Self {
bg: Pad::with_background(BLD_BG),
- title: Child::new(Label::left_aligned(title, text_title(BLD_BG)).vertically_centered()),
- menu: Child::new(
- Button::with_icon(Icon::new(MENU32))
- .styled(button_bld_menu())
- .with_expanded_touch_area(Insets::uniform(13)),
- ),
- host: Child::new(
- Button::with_text("INITIATE CONNECTION".into())
- .styled(button_bld())
- .with_text_align(Alignment::Center),
- ),
- text: Child::new(Label::left_aligned(content, TEXT_NORMAL).vertically_centered()),
- warn: (!fw_ok).then_some(Child::new(
+ title: Label::left_aligned(title, text_title(BLD_BG)).vertically_centered(),
+ menu: Button::with_icon(Icon::new(MENU32))
+ .styled(button_bld_menu())
+ .with_expanded_touch_area(Insets::uniform(13)),
+ host: Button::with_text("INITIATE CONNECTION".into())
+ .styled(button_bld())
+ .with_text_align(Alignment::Center),
+ text: Label::left_aligned(content, TEXT_NORMAL).vertically_centered(),
+ warn: (!fw_ok).then_some(
Label::new("FIRMWARE CORRUPTED".into(), Alignment::Start, TEXT_WARNING)
.vertically_centered(),
- )),
+ ),
}
}
}
@@ -111,7 +107,7 @@ impl crate::trace::Trace for Intro<'_> {
fn trace(&self, t: &mut dyn crate::trace::Tracer) {
t.component("Intro");
t.child("title", &self.title);
- t.string("screen_content", *self.text.inner().text());
+ t.string("screen_content", *self.text.text());
if let Some(warn) = &self.warn {
t.child("warning", warn);
}
### core/embed/rust/src/ui/layout_delizia/bootloader/menu.rs
@@ -4,7 +4,7 @@ use super::super::theme::bootloader::{
button_bld, button_bld_menu, text_title, BLD_BG, BUTTON_HEIGHT, CONTENT_PADDING,
CORNER_BUTTON_AREA, CORNER_BUTTON_TOUCH_EXPANSION, FIRE24, REFRESH24, TITLE_AREA, X32,
};
-use crate::ui::component::{Child, Component, Event, EventCtx, Label, Pad};
+use crate::ui::component::{Component, Event, EventCtx, Label, Pad};
use crate::ui::constant::{screen, WIDTH};
use crate::ui::display::Icon;
use crate::ui::geometry::{Insets, Point, Rect};
@@ -23,10 +23,10 @@ pub enum MenuMsg {
pub struct Menu {
bg: Pad,
- title: Child<Label<'static>>,
- close: Child<Button>,
- reboot: Child<Button>,
- reset: Child<Button>,
+ title: Label<'static>,
+ close: Button,
+ reboot: Button,
+ reset: Button,
}
impl Menu {
@@ -36,16 +36,13 @@ impl Menu {
Self {
bg: Pad::with_background(BLD_BG),
- title: Child::new(
- Label::left_aligned("BOOTLOADER".into(), text_title(BLD_BG)).vertically_centered(),
- ),
- close: Child::new(
- Button::with_icon(Icon::new(X32))
- .styled(button_bld_menu())
- .with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
- ),
- reboot: Child::new(Button::with_icon_and_text(content_reboot).styled(button_bld())),
- reset: Child::new(Button::with_icon_and_text(content_reset).styled(button_bld())),
+ title: Label::left_aligned("BOOTLOADER".into(), text_title(BLD_BG))
+ .vertically_centered(),
+ close: Button::with_icon(Icon::new(X32))
+ .styled(button_bld_menu())
+ .with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
+ reboot: Button::with_icon_and_text(content_reboot).styled(button_bld()),
+ reset: Button::with_icon_and_text(content_reset).styled(button_bld()),
}
}
}
### core/embed/rust/src/ui/layout_delizia/component/bl_confirm.rs
@@ -7,7 +7,7 @@ use super::theme::WHITE;
use super::ButtonMsg::Clicked;
use super::{Button, ButtonStyleSheet};
use crate::strutil::TString;
-use crate::ui::component::{Child, Component, ComponentExt, Event, EventCtx, Label, Pad};
+use crate::ui::component::{Component, ComponentExt, Event, EventCtx, Label, Pad};
use crate::ui::constant::screen;
use crate::ui::display::{Color, Icon};
use crate::ui::geometry::{Alignment2D, Insets, Offset, Point, Rect};
@@ -34,21 +34,21 @@ pub enum ConfirmTitle {
}
pub struct ConfirmInfo<'a> {
- pub title: Child<Label<'a>>,
- pub text: Child<Label<'a>>,
- pub info_button: Child<Button>,
- pub close_button: Child<Button>,
+ pub title: Label<'a>,
+ pub text: Label<'a>,
+ pub info_button: Button,
+ pub close_button: Button,
}
pub struct Confirm<'a> {
bg: Pad,
content_pad: Pad,
bg_color: Color,
title: ConfirmTitle,
- message: Child<Label<'a>>,
- alert: Option<Child<Label<'static>>>,
- left_button: Child<Button>,
- right_button: Child<Button>,
+ message: Label<'a>,
+ alert: Option<Label<'static>>,
+ left_button: Button,
+ right_button: Button,
info: Option<ConfirmInfo<'a>>,
show_info: bool,
}
@@ -66,17 +66,17 @@ impl<'a> Confirm<'a> {
content_pad: Pad::with_background(bg_color),
bg_color,
title,
- message: Child::new(message.vertically_centered()),
- left_button: Child::new(left_button),
- right_button: Child::new(right_button),
+ message: message.vertically_centered(),
+ left_button,
+ right_button,
alert: None,
info: None,
show_info: false,
}
}
pub fn with_alert(mut self, alert: Label<'static>) -> Self {
- self.alert = Some(Child::new(alert.vertically_centered()));
+ self.alert = Some(alert.vertically_centered());
self
}
@@ -87,22 +87,14 @@ impl<'a> Confirm<'a> {
menu_button: ButtonStyleSheet,
) -> Self {
self.info = Some(ConfirmInfo {
- title: Child::new(
- Label::left_aligned(title, text_title(self.bg_color)).vertically_centered(),
- ),
- text: Child::new(
- Label::left_aligned(text, text_fingerprint(self.bg_color)).vertically_centered(),
- ),
- info_button: Child::new(
- Button::with_icon(Icon::new(INFO32))
- .styled(menu_button)
- .with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
- ),
- close_button: Child::new(
- Button::with_icon(Icon::new(X32))
- .styled(menu_button)
- .with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
- ),
+ title: Label::left_aligned(title, text_title(self.bg_color)).vertically_centered(),
+ text: Label::left_aligned(text, text_fingerprint(self.bg_color)).vertically_centered(),
+ info_button: Button::with_icon(Icon::new(INFO32))
+ .styled(menu_button)
+ .with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
+ close_button: Button::with_icon(Icon::new(X32))
+ .styled(menu_button)
+ .with_expanded_touch_area(Insets::uniform(CORNER_BUTTON_TOUCH_EXPANSION)),
});
self
}
@@ -132,7 +124,7 @@ impl Component for Confirm<'_> {
};
if self.alert.is_some() {
- let message_height = self.message.inner().text_height(content_area.width());
+ let message_height = self.message.text_height(content_area.width());
self.message.place(Rect::from_top_left_and_size(
content_area.top_left(),
Offset::new(content_area.width(), message_height),
@@ -235,14 +227,14 @@ impl crate::trace::Trace for Confirm<'_> {
Some(info) if self.show_info => {
t.bool("show_info", true);
t.child("title", &info.title);
- t.string("screen_content", *info.text.inner().text());
+ t.string("screen_content", *info.text.text());
t.child("close", &info.close_button);
}
_ => {
if let ConfirmTitle::Text(title) = &self.title {
t.child("title", title);
}
- t.string("screen_content", *self.message.inner().text());
+ t.string("screen_content", *self.message.text());
if let Some(alert) = &self.alert {
t.child("alert", alert);
}Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.