Skip to content

Commit adee45d

Browse files
committed
browser-rs: Kagami mochi on a default page
1 parent 2f0e80a commit adee45d

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

app/browser-rs/src/main.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -57,36 +57,47 @@ fn main() {
5757
let default_page = r#"<html>
5858
<head>
5959
<style>
60-
#id1 {
60+
.leaf {
6161
background-color: green;
6262
height: 5;
6363
width: 5;
6464
}
65+
#leaf1 {
66+
margin-top: 50;
67+
margin-left: 275;
68+
}
69+
#leaf2 {
70+
margin-left: 270;
71+
}
72+
#leaf3 {
73+
margin-left: 265;
74+
}
6575
#id2 {
6676
background-color: orange;
6777
height: 20;
6878
width: 30;
79+
margin-left: 250;
6980
}
7081
#id3 {
7182
background-color: lightgray;
7283
height: 30;
73-
width: 100;
84+
width: 80;
85+
margin-top: 3;
86+
margin-left: 225;
7487
}
7588
#id4 {
7689
background-color: lightgray;
7790
height: 30;
78-
width: 140;
91+
width: 100;
92+
margin-top: 3;
93+
margin-left: 215;
7994
}
8095
</style>
81-
<script>
82-
function test(p1, p2) {
83-
return p1+p2;
84-
}
85-
var a=test(1, 2);
86-
</script>
8796
</head>
8897
<body>
89-
<div id=id1></div>
98+
<div class=leaf id=leaf1></div>
99+
<div class=leaf id=leaf2></div>
100+
<div class=leaf id=leaf3></div>
90101
<div id=id2></div>
91102
<div id=id3></div>
92103
<div id=id4></div>

app/browser-rs/src/renderer/layout/render_tree.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,38 @@ impl RenderObject {
171171
"margin" => {
172172
self.style.margin = match declaration.value {
173173
// TODO: support string (e.g. "auto")
174-
ComponentValue::Keyword(_value) => BoxInfo::new(0, 0, 0, 0),
174+
ComponentValue::Keyword(_value) => self.style.margin.clone(),
175175
ComponentValue::Number(value) => BoxInfo::new(value, value, value, value),
176176
};
177177
}
178+
"margin-top" => {
179+
self.style.margin.top = match declaration.value {
180+
// TODO: support string (e.g. "auto")
181+
ComponentValue::Keyword(_value) => self.style.margin.top,
182+
ComponentValue::Number(value) => value,
183+
};
184+
}
185+
"margin-right" => {
186+
self.style.margin.right = match declaration.value {
187+
// TODO: support string (e.g. "auto")
188+
ComponentValue::Keyword(_value) => self.style.margin.right,
189+
ComponentValue::Number(value) => value,
190+
};
191+
}
192+
"margin-bottom" => {
193+
self.style.margin.bottom = match declaration.value {
194+
// TODO: support string (e.g. "auto")
195+
ComponentValue::Keyword(_value) => self.style.margin.bottom,
196+
ComponentValue::Number(value) => value,
197+
};
198+
}
199+
"margin-left" => {
200+
self.style.margin.left = match declaration.value {
201+
// TODO: support string (e.g. "auto")
202+
ComponentValue::Keyword(_value) => self.style.margin.left,
203+
ComponentValue::Number(value) => value,
204+
};
205+
}
178206
_ => unimplemented!("css property {} is not supported yet", declaration.property,),
179207
}
180208
}

0 commit comments

Comments
 (0)