Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3584 | sourcerer | 1 | /* |
2 | * This file is part of LibCSS |
||
3 | * Licensed under the MIT License, |
||
4 | * http://www.opensource.org/licenses/mit-license.php |
||
5 | * Copyright 2009 John-Mark Bell |
||
6 | */ |
||
7 | |||
8 | #include "bytecode/bytecode.h" |
||
9 | #include "bytecode/opcodes.h" |
||
10 | #include "select/propset.h" |
||
11 | #include "select/propget.h" |
||
12 | #include "utils/utils.h" |
||
13 | |||
14 | #include "select/properties/properties.h" |
||
15 | #include "select/properties/helpers.h" |
||
16 | |||
17 | css_error css__cascade_font_weight(uint32_t opv, css_style *style, |
||
18 | css_select_state *state) |
||
19 | { |
||
20 | uint16_t value = CSS_FONT_WEIGHT_INHERIT; |
||
21 | |||
22 | UNUSED(style); |
||
23 | |||
24 | if (isInherit(opv) == false) { |
||
25 | switch (getValue(opv)) { |
||
26 | case FONT_WEIGHT_NORMAL: |
||
27 | value = CSS_FONT_WEIGHT_NORMAL; |
||
28 | break; |
||
29 | case FONT_WEIGHT_BOLD: |
||
30 | value = CSS_FONT_WEIGHT_BOLD; |
||
31 | break; |
||
32 | case FONT_WEIGHT_BOLDER: |
||
33 | value = CSS_FONT_WEIGHT_BOLDER; |
||
34 | break; |
||
35 | case FONT_WEIGHT_LIGHTER: |
||
36 | value = CSS_FONT_WEIGHT_LIGHTER; |
||
37 | break; |
||
38 | case FONT_WEIGHT_100: |
||
39 | value = CSS_FONT_WEIGHT_100; |
||
40 | break; |
||
41 | case FONT_WEIGHT_200: |
||
42 | value = CSS_FONT_WEIGHT_200; |
||
43 | break; |
||
44 | case FONT_WEIGHT_300: |
||
45 | value = CSS_FONT_WEIGHT_300; |
||
46 | break; |
||
47 | case FONT_WEIGHT_400: |
||
48 | value = CSS_FONT_WEIGHT_400; |
||
49 | break; |
||
50 | case FONT_WEIGHT_500: |
||
51 | value = CSS_FONT_WEIGHT_500; |
||
52 | break; |
||
53 | case FONT_WEIGHT_600: |
||
54 | value = CSS_FONT_WEIGHT_600; |
||
55 | break; |
||
56 | case FONT_WEIGHT_700: |
||
57 | value = CSS_FONT_WEIGHT_700; |
||
58 | break; |
||
59 | case FONT_WEIGHT_800: |
||
60 | value = CSS_FONT_WEIGHT_800; |
||
61 | break; |
||
62 | case FONT_WEIGHT_900: |
||
63 | value = CSS_FONT_WEIGHT_900; |
||
64 | break; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | if (css__outranks_existing(getOpcode(opv), isImportant(opv), state, |
||
69 | isInherit(opv))) { |
||
70 | return set_font_weight(state->computed, value); |
||
71 | } |
||
72 | |||
73 | return CSS_OK; |
||
74 | } |
||
75 | |||
76 | css_error css__set_font_weight_from_hint(const css_hint *hint, |
||
77 | css_computed_style *style) |
||
78 | { |
||
79 | return set_font_weight(style, hint->status); |
||
80 | } |
||
81 | |||
82 | css_error css__initial_font_weight(css_select_state *state) |
||
83 | { |
||
84 | return set_font_weight(state->computed, CSS_FONT_WEIGHT_NORMAL); |
||
85 | } |
||
86 | |||
87 | css_error css__compose_font_weight(const css_computed_style *parent, |
||
88 | const css_computed_style *child, |
||
89 | css_computed_style *result) |
||
90 | { |
||
91 | uint8_t type = get_font_weight(child); |
||
92 | |||
93 | if (type == CSS_FONT_WEIGHT_INHERIT) { |
||
94 | type = get_font_weight(parent); |
||
95 | } |
||
96 | |||
97 | return set_font_weight(result, type); |
||
98 | } |
||
99 |