fix cssrendering_box bug.
initialization mistake.
@@ -51,10 +51,6 @@ | ||
51 | 51 | LOCAL VOID cssrendering_basebox_appendchild(cssrendering_basebox_t *box, cssrendering_basebox_t *child) |
52 | 52 | { |
53 | 53 | treebase_node_appendchild(&box->base, &child->base); |
54 | - box->content_edge.c.left = 0; | |
55 | - box->content_edge.c.top = 0; | |
56 | - box->content_edge.c.right = 0; | |
57 | - box->content_edge.c.bottom = 0; | |
58 | 54 | } |
59 | 55 | |
60 | 56 | LOCAL VOID cssrendering_basebox_setuserdata(cssrendering_basebox_t *box, VP data) |
@@ -66,6 +62,10 @@ | ||
66 | 62 | { |
67 | 63 | treebase_node_initialize(&box->base); |
68 | 64 | box->type = type; |
65 | + box->content_edge.c.left = 0; | |
66 | + box->content_edge.c.top = 0; | |
67 | + box->content_edge.c.right = 0; | |
68 | + box->content_edge.c.bottom = 0; | |
69 | 69 | box->userdata = NULL; |
70 | 70 | } |
71 | 71 |
@@ -302,9 +302,105 @@ | ||
302 | 302 | return ret; |
303 | 303 | } |
304 | 304 | |
305 | +LOCAL UNITTEST_RESULT test_cssrendering_blockbox_appendchild1() | |
306 | +{ | |
307 | + cssrendering_blockbox_t root; | |
308 | + cssrendering_anonymousbox_t anon; | |
309 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
310 | + | |
311 | + cssrendering_blockbox_initialize(&root); | |
312 | + cssrendering_anonymousbox_initialize(&anon); | |
313 | + | |
314 | + root.base.content_edge = (cssmetric_rectangle_t){{0, 0, 100, 100}}; | |
315 | + cssrendering_blockbox_appendanonymouschild(&root, &anon); | |
316 | + | |
317 | + if (root.base.content_edge.c.left != 0) { | |
318 | + result = UNITTEST_RESULT_FAIL; | |
319 | + } | |
320 | + if (root.base.content_edge.c.top != 0) { | |
321 | + result = UNITTEST_RESULT_FAIL; | |
322 | + } | |
323 | + if (root.base.content_edge.c.right != 100) { | |
324 | + result = UNITTEST_RESULT_FAIL; | |
325 | + } | |
326 | + if (root.base.content_edge.c.bottom != 100) { | |
327 | + result = UNITTEST_RESULT_FAIL; | |
328 | + } | |
329 | + | |
330 | + cssrendering_anonymousbox_finalize(&anon); | |
331 | + cssrendering_blockbox_finalize(&root); | |
332 | + | |
333 | + return result; | |
334 | +} | |
335 | + | |
336 | +LOCAL UNITTEST_RESULT test_cssrendering_blockbox_appendchild2() | |
337 | +{ | |
338 | + cssrendering_blockbox_t root; | |
339 | + cssrendering_blockbox_t child; | |
340 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
341 | + | |
342 | + cssrendering_blockbox_initialize(&root); | |
343 | + cssrendering_blockbox_initialize(&child); | |
344 | + | |
345 | + root.base.content_edge = (cssmetric_rectangle_t){{0, 0, 100, 100}}; | |
346 | + cssrendering_blockbox_appendblockchild(&root, &child); | |
347 | + | |
348 | + if (root.base.content_edge.c.left != 0) { | |
349 | + result = UNITTEST_RESULT_FAIL; | |
350 | + } | |
351 | + if (root.base.content_edge.c.top != 0) { | |
352 | + result = UNITTEST_RESULT_FAIL; | |
353 | + } | |
354 | + if (root.base.content_edge.c.right != 100) { | |
355 | + result = UNITTEST_RESULT_FAIL; | |
356 | + } | |
357 | + if (root.base.content_edge.c.bottom != 100) { | |
358 | + result = UNITTEST_RESULT_FAIL; | |
359 | + } | |
360 | + | |
361 | + cssrendering_blockbox_finalize(&child); | |
362 | + cssrendering_blockbox_finalize(&root); | |
363 | + | |
364 | + return result; | |
365 | +} | |
366 | + | |
367 | +LOCAL UNITTEST_RESULT test_cssrendering_anonymousbox_appendchild1() | |
368 | +{ | |
369 | + cssrendering_anonymousbox_t anon; | |
370 | + cssrendering_linebox_t line; | |
371 | + UNITTEST_RESULT result = UNITTEST_RESULT_PASS; | |
372 | + | |
373 | + cssrendering_anonymousbox_initialize(&anon); | |
374 | + cssrendering_linebox_initialize(&line); | |
375 | + | |
376 | + anon.base.content_edge = (cssmetric_rectangle_t){{0, 0, 100, 100}}; | |
377 | + cssrendering_anonymousbox_appendchild(&anon, &line); | |
378 | + | |
379 | + if (anon.base.content_edge.c.left != 0) { | |
380 | + result = UNITTEST_RESULT_FAIL; | |
381 | + } | |
382 | + if (anon.base.content_edge.c.top != 0) { | |
383 | + result = UNITTEST_RESULT_FAIL; | |
384 | + } | |
385 | + if (anon.base.content_edge.c.right != 100) { | |
386 | + result = UNITTEST_RESULT_FAIL; | |
387 | + } | |
388 | + if (anon.base.content_edge.c.bottom != 100) { | |
389 | + result = UNITTEST_RESULT_FAIL; | |
390 | + } | |
391 | + | |
392 | + cssrendering_linebox_finalize(&line); | |
393 | + cssrendering_anonymousbox_finalize(&anon); | |
394 | + | |
395 | + return result; | |
396 | +} | |
397 | + | |
305 | 398 | EXPORT VOID test_cssrendering_box_main(unittest_driver_t *driver) |
306 | 399 | { |
307 | 400 | UNITTEST_DRIVER_REGIST(driver, test_cssrendering_drawtraversal_1); |
308 | 401 | UNITTEST_DRIVER_REGIST(driver, test_cssrendering_drawtraversal_2); |
309 | 402 | UNITTEST_DRIVER_REGIST(driver, test_cssrendering_hittraversal_1); |
403 | + UNITTEST_DRIVER_REGIST(driver, test_cssrendering_blockbox_appendchild1); | |
404 | + UNITTEST_DRIVER_REGIST(driver, test_cssrendering_blockbox_appendchild2); | |
405 | + UNITTEST_DRIVER_REGIST(driver, test_cssrendering_anonymousbox_appendchild1); | |
310 | 406 | } |