1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! Block-level layout for the `<a>` (anchor / hyperlink) element.
//!
//! An anchor with an explicit block-level display participates in block flow
//! (e.g. `<aside><a style="display: block">Dashboard</a></aside>`). An anchor
//! without that declaration remains in the parent's inline flow; the inline
//! path is handled by [`crate::layout::layoutbox::collect_runs`]. Flex items
//! are also handled here when the flex formatter supplies a pre-allocated
//! rectangle, because flex items are blockified by their container.
//!
//! Both paths apply the same browser-style user-agent defaults — blue
//! foreground and an underlined text-decoration — whenever neither an author
//! rule nor an inherited value has declared the matching property. The block
//! path injects these defaults into a cloned [`Node`] before delegating to
//! [`layout_block`]; the inline path applies the same defaults through
//! `collect_runs`' local `fg` / `style` variables without touching shared state.
use Arc;
use crate::;
/// Build a [`LayoutBox`] for an `<a>` element when it is a direct block-level
/// child of another block container.
///
/// Honors CSS `width` / `padding` / `border` / `margin` like any other block;
/// the only element-specific behaviour is the user-agent default styling
/// applied by `apply_a_ua_defaults`. Returns `None` for any non-`<a>` node
/// so the registry falls through to the next handler.
/// Inject the browser-style `<a>` defaults into `css_attr` when the cascade
/// has not already recorded a value.
///
/// `is_set` returns `true` for any value the cascade has populated — explicit
/// author rules *and* inherited values from ancestors — so the defaults never
/// override something the author declared. The mutation is idempotent: a
/// second pass sees `is_set == true` and skips the insert, so re-running the
/// layout (e.g. after an interactive refresh) does not stomp on anything.