CSS: Wrappers for computed style getters that return unsupported values.
We don't yet handle the Flexbox-related values for certain properties.
This commit is contained in:
parent
7fa4b36245
commit
f7f18042bf
|
@ -20,6 +20,7 @@
|
|||
#include <libcss/libcss.h>
|
||||
|
||||
#include "css/dump.h"
|
||||
#include "css/utils.h"
|
||||
|
||||
/**
|
||||
* Dump a fixed point value to the stream in a textual form.
|
||||
|
@ -783,7 +784,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
|
|||
}
|
||||
|
||||
/* display */
|
||||
val = css_computed_display_static(style);
|
||||
val = ns_computed_display_static(style);
|
||||
switch (val) {
|
||||
case CSS_DISPLAY_INLINE:
|
||||
fprintf(stream, "display: inline ");
|
||||
|
@ -1268,7 +1269,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
|
|||
}
|
||||
|
||||
/* min-height */
|
||||
val = css_computed_min_height(style, &len1, &unit1);
|
||||
val = ns_computed_min_height(style, &len1, &unit1);
|
||||
switch (val) {
|
||||
case CSS_MIN_HEIGHT_SET:
|
||||
fprintf(stream, "min-height: ");
|
||||
|
@ -1282,7 +1283,7 @@ void nscss_dump_computed_style(FILE *stream, const css_computed_style *style)
|
|||
}
|
||||
|
||||
/* min-width */
|
||||
val = css_computed_min_width(style, &len1, &unit1);
|
||||
val = ns_computed_min_width(style, &len1, &unit1);
|
||||
switch (val) {
|
||||
case CSS_MIN_WIDTH_SET:
|
||||
fprintf(stream, "min-width: ");
|
||||
|
|
|
@ -46,4 +46,73 @@ css_fixed nscss_len2pt(css_fixed length, css_unit unit);
|
|||
*/
|
||||
css_fixed nscss_len2px(css_fixed length, css_unit unit, const css_computed_style *style);
|
||||
|
||||
|
||||
/**
|
||||
* Temporary helper wrappers for for libcss computed style getter, while
|
||||
* we don't support flexbox related property values.
|
||||
*/
|
||||
|
||||
static inline uint8_t ns_computed_display(
|
||||
const css_computed_style *style, bool root)
|
||||
{
|
||||
uint8_t value = css_computed_display(style, root);
|
||||
|
||||
if (value == CSS_DISPLAY_FLEX) {
|
||||
return CSS_DISPLAY_BLOCK;
|
||||
|
||||
} else if (value == CSS_DISPLAY_INLINE_FLEX) {
|
||||
return CSS_DISPLAY_INLINE_BLOCK;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
static inline uint8_t ns_computed_display_static(
|
||||
const css_computed_style *style)
|
||||
{
|
||||
uint8_t value = css_computed_display_static(style);
|
||||
|
||||
if (value == CSS_DISPLAY_FLEX) {
|
||||
return CSS_DISPLAY_BLOCK;
|
||||
|
||||
} else if (value == CSS_DISPLAY_INLINE_FLEX) {
|
||||
return CSS_DISPLAY_INLINE_BLOCK;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
static inline uint8_t ns_computed_min_height(
|
||||
const css_computed_style *style,
|
||||
css_fixed *length, css_unit *unit)
|
||||
{
|
||||
uint8_t value = css_computed_min_height(style, length, unit);
|
||||
|
||||
if (value == CSS_MIN_HEIGHT_AUTO) {
|
||||
value = CSS_MIN_HEIGHT_SET;
|
||||
*length = 0;
|
||||
*unit = CSS_UNIT_PX;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
static inline uint8_t ns_computed_min_width(
|
||||
const css_computed_style *style,
|
||||
css_fixed *length, css_unit *unit)
|
||||
{
|
||||
uint8_t value = css_computed_min_width(style, length, unit);
|
||||
|
||||
if (value == CSS_MIN_WIDTH_AUTO) {
|
||||
value = CSS_MIN_WIDTH_SET;
|
||||
*length = 0;
|
||||
*unit = CSS_UNIT_PX;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "content/content_protected.h"
|
||||
#include "css/hints.h"
|
||||
#include "css/select.h"
|
||||
#include "css/utils.h"
|
||||
#include "desktop/gui_internal.h"
|
||||
|
||||
#include "render/box.h"
|
||||
|
@ -612,7 +613,7 @@ static void box_construct_generate(dom_node *n, html_content *content,
|
|||
}
|
||||
|
||||
/* create box for this element */
|
||||
computed_display = css_computed_display(style, box_is_root(n));
|
||||
computed_display = ns_computed_display(style, box_is_root(n));
|
||||
if (computed_display == CSS_DISPLAY_BLOCK ||
|
||||
computed_display == CSS_DISPLAY_TABLE) {
|
||||
/* currently only support block level boxes */
|
||||
|
@ -625,7 +626,7 @@ static void box_construct_generate(dom_node *n, html_content *content,
|
|||
}
|
||||
|
||||
/* set box type from computed display */
|
||||
gen->type = box_map[css_computed_display(
|
||||
gen->type = box_map[ns_computed_display(
|
||||
style, box_is_root(n))];
|
||||
|
||||
box_add_child(box, gen);
|
||||
|
@ -831,11 +832,11 @@ bool box_construct_element(struct box_construct_ctx *ctx,
|
|||
if ((css_computed_position(box->style) == CSS_POSITION_ABSOLUTE ||
|
||||
css_computed_position(box->style) ==
|
||||
CSS_POSITION_FIXED) &&
|
||||
(css_computed_display_static(box->style) ==
|
||||
(ns_computed_display_static(box->style) ==
|
||||
CSS_DISPLAY_INLINE ||
|
||||
css_computed_display_static(box->style) ==
|
||||
ns_computed_display_static(box->style) ==
|
||||
CSS_DISPLAY_INLINE_BLOCK ||
|
||||
css_computed_display_static(box->style) ==
|
||||
ns_computed_display_static(box->style) ==
|
||||
CSS_DISPLAY_INLINE_TABLE)) {
|
||||
/* Special case for absolute positioning: make absolute inlines
|
||||
* into inline block so that the boxes are constructed in an
|
||||
|
@ -848,7 +849,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
|
|||
box->type = BOX_BLOCK;
|
||||
} else {
|
||||
/* Normal mapping */
|
||||
box->type = box_map[css_computed_display(box->style,
|
||||
box->type = box_map[ns_computed_display(box->style,
|
||||
props.node_is_root)];
|
||||
}
|
||||
|
||||
|
@ -876,7 +877,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
|
|||
box->styles->styles[CSS_PSEUDO_ELEMENT_BEFORE]);
|
||||
}
|
||||
|
||||
if (box->type == BOX_NONE || (css_computed_display(box->style,
|
||||
if (box->type == BOX_NONE || (ns_computed_display(box->style,
|
||||
props.node_is_root) == CSS_DISPLAY_NONE &&
|
||||
props.node_is_root == false)) {
|
||||
css_select_results_destroy(styles);
|
||||
|
@ -968,7 +969,7 @@ bool box_construct_element(struct box_construct_ctx *ctx,
|
|||
|
||||
box_add_child(props.inline_container, box);
|
||||
} else {
|
||||
if (css_computed_display(box->style, props.node_is_root) ==
|
||||
if (ns_computed_display(box->style, props.node_is_root) ==
|
||||
CSS_DISPLAY_LIST_ITEM) {
|
||||
/* List item: compute marker */
|
||||
if (box_construct_marker(box, props.title, ctx,
|
||||
|
@ -1559,7 +1560,7 @@ bool box_image(BOX_SPECIAL_PARAMS)
|
|||
css_unit wunit = CSS_UNIT_PX;
|
||||
css_unit hunit = CSS_UNIT_PX;
|
||||
|
||||
if (box->style && css_computed_display(box->style,
|
||||
if (box->style && ns_computed_display(box->style,
|
||||
box_is_root(n)) == CSS_DISPLAY_NONE)
|
||||
return true;
|
||||
|
||||
|
@ -1666,7 +1667,7 @@ bool box_object(BOX_SPECIAL_PARAMS)
|
|||
dom_node *c;
|
||||
dom_exception err;
|
||||
|
||||
if (box->style && css_computed_display(box->style,
|
||||
if (box->style && ns_computed_display(box->style,
|
||||
box_is_root(n)) == CSS_DISPLAY_NONE)
|
||||
return true;
|
||||
|
||||
|
@ -2316,7 +2317,7 @@ bool box_iframe(BOX_SPECIAL_PARAMS)
|
|||
struct content_html_iframe *iframe;
|
||||
int i;
|
||||
|
||||
if (box->style && css_computed_display(box->style,
|
||||
if (box->style && ns_computed_display(box->style,
|
||||
box_is_root(n)) == CSS_DISPLAY_NONE)
|
||||
return true;
|
||||
|
||||
|
@ -2551,7 +2552,7 @@ bool box_input(BOX_SPECIAL_PARAMS)
|
|||
corestring_lwc_image)) {
|
||||
gadget->type = GADGET_IMAGE;
|
||||
|
||||
if (box->style && css_computed_display(box->style,
|
||||
if (box->style && ns_computed_display(box->style,
|
||||
box_is_root(n)) != CSS_DISPLAY_NONE &&
|
||||
nsoption_bool(foreground_images) == true) {
|
||||
dom_string *s;
|
||||
|
@ -2887,7 +2888,7 @@ bool box_embed(BOX_SPECIAL_PARAMS)
|
|||
dom_string *src;
|
||||
dom_exception err;
|
||||
|
||||
if (box->style && css_computed_display(box->style,
|
||||
if (box->style && ns_computed_display(box->style,
|
||||
box_is_root(n)) == CSS_DISPLAY_NONE)
|
||||
return true;
|
||||
|
||||
|
|
|
@ -1110,7 +1110,7 @@ layout_find_dimensions(int available_width,
|
|||
css_fixed value = 0;
|
||||
css_unit unit = CSS_UNIT_PX;
|
||||
|
||||
type = css_computed_min_width(style, &value, &unit);
|
||||
type = ns_computed_min_width(style, &value, &unit);
|
||||
|
||||
if (type == CSS_MIN_WIDTH_SET) {
|
||||
if (unit == CSS_UNIT_PCT) {
|
||||
|
@ -1157,7 +1157,7 @@ layout_find_dimensions(int available_width,
|
|||
css_fixed value = 0;
|
||||
css_unit unit = CSS_UNIT_PX;
|
||||
|
||||
type = css_computed_min_height(style, &value, &unit);
|
||||
type = ns_computed_min_height(style, &value, &unit);
|
||||
|
||||
if (type == CSS_MIN_HEIGHT_SET) {
|
||||
if (unit == CSS_UNIT_PCT) {
|
||||
|
@ -2395,7 +2395,7 @@ static bool layout_apply_minmax_height(struct box *box, struct box *container)
|
|||
}
|
||||
|
||||
/* min-height */
|
||||
if (css_computed_min_height(box->style, &value, &unit) ==
|
||||
if (ns_computed_min_height(box->style, &value, &unit) ==
|
||||
CSS_MIN_HEIGHT_SET) {
|
||||
if (unit == CSS_UNIT_PCT) {
|
||||
if (containing_block &&
|
||||
|
|
Loading…
Reference in New Issue