netsurf: branch master updated. release/3.6-425-g6f7b5e3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6f7b5e3f221b4da4ff5da...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6f7b5e3f221b4da4ff5da07...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6f7b5e3f221b4da4ff5da0728...
The branch, master has been updated
via 6f7b5e3f221b4da4ff5da07281e0f2074b9e57fd (commit)
from e431e6181b2cd480fc4ec2fb0d7f7474470d5669 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6f7b5e3f221b4da4ff5...
commit 6f7b5e3f221b4da4ff5da07281e0f2074b9e57fd
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Layout: Fix auto margins to be affected by {min|max}-width constraints.
diff --git a/render/layout.c b/render/layout.c
index 4086c04..d9b108c 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1545,16 +1545,20 @@ layout_solve_width(struct box *box,
/* Find width */
if (width == AUTO) {
- /* any other 'auto' become 0 or the minimum required values */
- if (box->margin[LEFT] == AUTO)
- box->margin[LEFT] = lm;
- if (box->margin[RIGHT] == AUTO)
- box->margin[RIGHT] = rm;
+ int margin_left = box->margin[LEFT];
+ int margin_right = box->margin[RIGHT];
+
+ if (margin_left == AUTO) {
+ margin_left = lm;
+ }
+ if (margin_right == AUTO) {
+ margin_right = rm;
+ }
width = available_width -
- (box->margin[LEFT] + box->border[LEFT].width +
+ (margin_left + box->border[LEFT].width +
box->padding[LEFT] + box->padding[RIGHT] +
- box->border[RIGHT].width + box->margin[RIGHT]);
+ box->border[RIGHT].width + margin_right);
width = width < 0 ? 0 : width;
auto_width = true;
}
@@ -1572,8 +1576,16 @@ layout_solve_width(struct box *box,
}
/* Width was auto, and unconstrained by min/max width, so we're done */
- if (auto_width)
+ if (auto_width) {
+ /* any other 'auto' become 0 or the minimum required values */
+ if (box->margin[LEFT] == AUTO) {
+ box->margin[LEFT] = lm;
+ }
+ if (box->margin[RIGHT] == AUTO) {
+ box->margin[RIGHT] = rm;
+ }
return width;
+ }
/* Width was not auto, or was constrained by min/max width
* Need to compute left/right margins */
-----------------------------------------------------------------------
Summary of changes:
render/layout.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/render/layout.c b/render/layout.c
index 4086c04..d9b108c 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1545,16 +1545,20 @@ layout_solve_width(struct box *box,
/* Find width */
if (width == AUTO) {
- /* any other 'auto' become 0 or the minimum required values */
- if (box->margin[LEFT] == AUTO)
- box->margin[LEFT] = lm;
- if (box->margin[RIGHT] == AUTO)
- box->margin[RIGHT] = rm;
+ int margin_left = box->margin[LEFT];
+ int margin_right = box->margin[RIGHT];
+
+ if (margin_left == AUTO) {
+ margin_left = lm;
+ }
+ if (margin_right == AUTO) {
+ margin_right = rm;
+ }
width = available_width -
- (box->margin[LEFT] + box->border[LEFT].width +
+ (margin_left + box->border[LEFT].width +
box->padding[LEFT] + box->padding[RIGHT] +
- box->border[RIGHT].width + box->margin[RIGHT]);
+ box->border[RIGHT].width + margin_right);
width = width < 0 ? 0 : width;
auto_width = true;
}
@@ -1572,8 +1576,16 @@ layout_solve_width(struct box *box,
}
/* Width was auto, and unconstrained by min/max width, so we're done */
- if (auto_width)
+ if (auto_width) {
+ /* any other 'auto' become 0 or the minimum required values */
+ if (box->margin[LEFT] == AUTO) {
+ box->margin[LEFT] = lm;
+ }
+ if (box->margin[RIGHT] == AUTO) {
+ box->margin[RIGHT] = rm;
+ }
return width;
+ }
/* Width was not auto, or was constrained by min/max width
* Need to compute left/right margins */
--
NetSurf Browser
6 years, 4 months
netsurf: branch master updated. release/3.6-424-ge431e61
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e431e6181b2cd480fc4ec...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e431e6181b2cd480fc4ec2f...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e431e6181b2cd480fc4ec2fb0...
The branch, master has been updated
via e431e6181b2cd480fc4ec2fb0d7f7474470d5669 (commit)
via ad3da6c1393ea69268f545e6581af668b5f337c9 (commit)
via 06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0 (commit)
from 6c726473eff8a352d51e3931356347384bd8686a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e431e6181b2cd480fc4...
commit e431e6181b2cd480fc4ec2fb0d7f7474470d5669
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
RISC OS: Init core hotlist in read-only mode for external hotlist.
Note, the core hotlist is initialised in either normal or read-only
modes. This is done once on application startup. Toggling the
external hotlist option at runtime may cause loss of hotlist changes
made during the session.
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index f84e084..d3ce31c 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1186,7 +1186,9 @@ static nserror gui_init(int argc, char** argv)
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
hotlist_init(nsoption_charp(hotlist_path),
- nsoption_charp(hotlist_save));
+ nsoption_bool(external_hotlists) ?
+ NULL :
+ nsoption_charp(hotlist_save));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ad3da6c1393ea69268f...
commit ad3da6c1393ea69268f545e6581af668b5f337c9
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Core hotlist: Improve hotlist_init documentation.
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index a16b3e8..571f4de 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -40,8 +40,11 @@ struct rect;
* be called before URLs can be added to the hotlist, and before the
* hotlist can be queried to ask if URLs are present in the hotlist.
*
+ * In read-only mode the hotlist can be modified, but changes will not
+ * persist over sessions.
+ *
* \param load_path The path to load hotlist from.
- * \param save_path The path to save hotlist to, or NULL for read-only.
+ * \param save_path The path to save hotlist to, or NULL for read-only mode.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_init(
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=06baaa9f7c037d2aa9d...
commit 06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Core hotlist: A NULL save_path makes the hotlist read-only.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 3e2fced..0f5be77 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -107,7 +107,7 @@ static nserror hotlist_get_temp_path(const char *path, char **temp_path)
/* Save the hotlist to to a file at the given path
*
- * \param path Path to save hostlist file to.
+ * \param path Path to save hotlist file to. NULL path is a no-op.
* \return NSERROR_OK on success, or appropriate error otherwise
*/
static nserror hotlist_save(const char *path)
@@ -115,6 +115,11 @@ static nserror hotlist_save(const char *path)
nserror res = NSERROR_OK;
char *temp_path;
+ /* NULL path is a no-op. */
+ if (path == NULL) {
+ return NSERROR_OK;
+ }
+
/* Get path to export to */
res = hotlist_get_temp_path(path, &temp_path);
if (res != NSERROR_OK) {
@@ -163,7 +168,7 @@ static void hotlist_schedule_save_cb(void *p)
*/
static nserror hotlist_schedule_save(void)
{
- if (hl_ctx.save_scheduled == false) {
+ if (hl_ctx.save_scheduled == false && hl_ctx.save_path != NULL) {
nserror err = guit->misc->schedule(10 * 1000,
hotlist_schedule_save_cb, NULL);
if (err != NSERROR_OK) {
@@ -1285,9 +1290,13 @@ nserror hotlist_init(
hl_ctx.default_folder = NULL;
/* Store the save path */
- hl_ctx.save_path = strdup(save_path);
- if (hl_ctx.save_path == NULL) {
- return NSERROR_NOMEM;
+ if (save_path != NULL) {
+ hl_ctx.save_path = strdup(save_path);
+ if (hl_ctx.save_path == NULL) {
+ return NSERROR_NOMEM;
+ }
+ } else {
+ hl_ctx.save_path = NULL;
}
/* Init. hotlist treeview entry fields */
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index e38eac1..a16b3e8 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -41,7 +41,7 @@ struct rect;
* hotlist can be queried to ask if URLs are present in the hotlist.
*
* \param load_path The path to load hotlist from.
- * \param save_path The path to save hotlist to.
+ * \param save_path The path to save hotlist to, or NULL for read-only.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_init(
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 19 ++++++++++++++-----
desktop/hotlist.h | 5 ++++-
frontends/riscos/gui.c | 4 +++-
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 3e2fced..0f5be77 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -107,7 +107,7 @@ static nserror hotlist_get_temp_path(const char *path, char **temp_path)
/* Save the hotlist to to a file at the given path
*
- * \param path Path to save hostlist file to.
+ * \param path Path to save hotlist file to. NULL path is a no-op.
* \return NSERROR_OK on success, or appropriate error otherwise
*/
static nserror hotlist_save(const char *path)
@@ -115,6 +115,11 @@ static nserror hotlist_save(const char *path)
nserror res = NSERROR_OK;
char *temp_path;
+ /* NULL path is a no-op. */
+ if (path == NULL) {
+ return NSERROR_OK;
+ }
+
/* Get path to export to */
res = hotlist_get_temp_path(path, &temp_path);
if (res != NSERROR_OK) {
@@ -163,7 +168,7 @@ static void hotlist_schedule_save_cb(void *p)
*/
static nserror hotlist_schedule_save(void)
{
- if (hl_ctx.save_scheduled == false) {
+ if (hl_ctx.save_scheduled == false && hl_ctx.save_path != NULL) {
nserror err = guit->misc->schedule(10 * 1000,
hotlist_schedule_save_cb, NULL);
if (err != NSERROR_OK) {
@@ -1285,9 +1290,13 @@ nserror hotlist_init(
hl_ctx.default_folder = NULL;
/* Store the save path */
- hl_ctx.save_path = strdup(save_path);
- if (hl_ctx.save_path == NULL) {
- return NSERROR_NOMEM;
+ if (save_path != NULL) {
+ hl_ctx.save_path = strdup(save_path);
+ if (hl_ctx.save_path == NULL) {
+ return NSERROR_NOMEM;
+ }
+ } else {
+ hl_ctx.save_path = NULL;
}
/* Init. hotlist treeview entry fields */
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index e38eac1..571f4de 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -40,8 +40,11 @@ struct rect;
* be called before URLs can be added to the hotlist, and before the
* hotlist can be queried to ask if URLs are present in the hotlist.
*
+ * In read-only mode the hotlist can be modified, but changes will not
+ * persist over sessions.
+ *
* \param load_path The path to load hotlist from.
- * \param save_path The path to save hotlist to.
+ * \param save_path The path to save hotlist to, or NULL for read-only mode.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_init(
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index f84e084..d3ce31c 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1186,7 +1186,9 @@ static nserror gui_init(int argc, char** argv)
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
hotlist_init(nsoption_charp(hotlist_path),
- nsoption_charp(hotlist_save));
+ nsoption_bool(external_hotlists) ?
+ NULL :
+ nsoption_charp(hotlist_save));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
--
NetSurf Browser
6 years, 4 months
netsurf: branch master updated. release/3.6-421-g6c72647
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6c726473eff8a352d51e3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6c726473eff8a352d51e393...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6c726473eff8a352d51e39313...
The branch, master has been updated
via 6c726473eff8a352d51e3931356347384bd8686a (commit)
from 66602e63277ad0063e7267ea8e32d75da590bceb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6c726473eff8a352d51...
commit 6c726473eff8a352d51e3931356347384bd8686a
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Layout: Implement CSS3 box-sizing property.
Updates user agent CSS to set form element box-sizing properties,
and removes some legacy pre-CSS3 hacks for handling gadget dimensions.
diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79
index 2aee83b..276bc15 100644
--- a/!NetSurf/Resources/CSS,f79
+++ b/!NetSurf/Resources/CSS,f79
@@ -114,13 +114,13 @@ form { display: block; }
input, button { background-color: #fff; color: #000; text-align: left;
font-family: sans-serif; width: auto; height: auto; overflow: hidden;
border: 1px solid #444; padding: 2px 3px; line-height: 1.33;
- margin: 1px; }
+ margin: 1px; box-sizing: border-box; }
input[disabled] { background-color: #ddd; color: #333; }
input[type=button], input[type=reset], input[type=submit], button {
background-color: #d9d9d9; color: #000; text-align: center;
border: 2px outset #d9d9d9; padding: 1px 0.5em; }
input[type=image] { background-color: transparent; color: #000;
- border: none; padding: 0 2px; }
+ border: none; padding: 0 2px; box-sizing: content-box; }
input[type=checkbox], input[type=radio] { background-color: transparent;
border: none; padding: 0 0.1em; }
input[type=file] { background-color: #d9d9d9; color: #000; font-style: italic;
diff --git a/render/layout.c b/render/layout.c
index c92089f..4086c04 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -332,6 +332,7 @@ layout_minmax_line(struct box *first,
for (b = first; b; b = b->next) {
enum css_width_e wtype;
enum css_height_e htype;
+ enum css_box_sizing_e bs;
css_fixed value = 0;
css_unit unit = CSS_UNIT_PX;
@@ -506,6 +507,7 @@ layout_minmax_line(struct box *first,
/* calculate box width */
wtype = css_computed_width(b->style, &value, &unit);
+ bs = css_computed_box_sizing(block->style);
if (wtype == CSS_WIDTH_SET) {
if (unit == CSS_UNIT_PCT) {
/*
@@ -516,6 +518,19 @@ layout_minmax_line(struct box *first,
} else {
width = FIXTOINT(nscss_len2px(value, unit,
b->style));
+
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ fixed = frac = 0;
+ calculate_mbp_width(block->style, LEFT,
+ false, true, true,
+ &fixed, &frac);
+ calculate_mbp_width(block->style, RIGHT,
+ false, true, true,
+ &fixed, &frac);
+ if (width < fixed) {
+ width = fixed;
+ }
+ }
if (width < 0)
width = 0;
}
@@ -541,11 +556,21 @@ layout_minmax_line(struct box *first,
}
fixed = frac = 0;
- calculate_mbp_width(b->style, LEFT, true, true, true,
- &fixed, &frac);
- calculate_mbp_width(b->style, RIGHT, true, true, true,
- &fixed, &frac);
-
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ calculate_mbp_width(b->style, LEFT,
+ true, false, false,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, false, false,
+ &fixed, &frac);
+ } else {
+ calculate_mbp_width(b->style, LEFT,
+ true, true, true,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, true, true,
+ &fixed, &frac);
+ }
if (0 < width + fixed)
width += fixed;
} else if (b->flags & IFRAME) {
@@ -554,13 +579,25 @@ layout_minmax_line(struct box *first,
width = 400;
fixed = frac = 0;
- calculate_mbp_width(b->style, LEFT, true, true, true,
- &fixed, &frac);
- calculate_mbp_width(b->style, RIGHT, true, true, true,
- &fixed, &frac);
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ calculate_mbp_width(b->style, LEFT,
+ true, false, false,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, false, false,
+ &fixed, &frac);
+ } else {
+ calculate_mbp_width(b->style, LEFT,
+ true, true, true,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, true, true,
+ &fixed, &frac);
+ }
if (0 < width + fixed)
width += fixed;
+
} else {
/* form control with no object */
if (width == AUTO)
@@ -667,6 +704,7 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
enum css_height_e htype = CSS_HEIGHT_AUTO;
css_fixed height = 0;
css_unit hunit = CSS_UNIT_PX;
+ enum css_box_sizing_e bs = CSS_BOX_SIZING_CONTENT_BOX;
bool child_has_height = false;
assert(block->type == BOX_BLOCK ||
@@ -680,6 +718,7 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
if (block->style != NULL) {
wtype = css_computed_width(block->style, &width, &wunit);
htype = css_computed_height(block->style, &height, &hunit);
+ bs = css_computed_box_sizing(block->style);
}
/* set whether the minimum width is of any interest for this box */
@@ -800,6 +839,19 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
if (block->type != BOX_TABLE_CELL && wtype == CSS_WIDTH_SET &&
wunit != CSS_UNIT_PCT) {
min = max = FIXTOINT(nscss_len2px(width, wunit, block->style));
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ int border_box_fixed = 0;
+ float border_box_frac = 0;
+ calculate_mbp_width(block->style, LEFT,
+ false, true, true,
+ &border_box_fixed, &border_box_frac);
+ calculate_mbp_width(block->style, RIGHT,
+ false, true, true,
+ &border_box_fixed, &border_box_frac);
+ if (min < border_box_fixed) {
+ min = max = border_box_fixed;
+ }
+ }
}
if (htype == CSS_HEIGHT_SET && hunit != CSS_UNIT_PCT &&
@@ -811,12 +863,8 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
/* add margins, border, padding to min, max widths */
/* Note: we don't know available width here so percentage margin
* and paddings are wrong. */
- if (block->gadget && wtype == CSS_WIDTH_SET &&
- (block->gadget->type == GADGET_SUBMIT ||
- block->gadget->type == GADGET_RESET ||
- block->gadget->type == GADGET_BUTTON)) {
- /* some gadgets with specified width already include border and
- * padding, so just get margin */
+ if (bs == CSS_BOX_SIZING_BORDER_BOX && wtype == CSS_WIDTH_SET) {
+ /* Border and padding included in width, so just get margin */
calculate_mbp_width(block->style, LEFT, true, false, false,
&extra_fixed, &extra_frac);
calculate_mbp_width(block->style, RIGHT, true, false, false,
@@ -850,12 +898,11 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
/**
- * Under some circumstances, specified dimensions for form elements include
- * borders and padding.
+ * Adjust a specified width or height for the box-sizing property.
+ *
+ * This turns the specified dimension into a content-box dimension.
*
* \param box gadget to adjust dimensions of
- * \param percentage whether the gadget has its dimension specified as a
- * percentage
* \param available_width width of containing block
* \param setwidth set true if the dimension to be tweaked is a width,
* else set false for a height
@@ -863,25 +910,29 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
* updated to new value after consideration of
* gadget properties.
*/
-static void layout_tweak_form_dimensions(struct box *box, bool percentage,
- int available_width, bool setwidth, int *dimension)
+static void layout_handle_box_sizing(
+ struct box *box,
+ int available_width,
+ bool setwidth,
+ int *dimension)
{
- int fixed = 0;
- float frac = 0;
+ enum css_box_sizing_e bs;
+
+ assert(box && box->style);
- assert(box && box->gadget);
+ bs = css_computed_box_sizing(box->style);
+
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ int orig = *dimension;
+ int fixed = 0;
+ float frac = 0;
- /* specified gadget widths include borders and padding in some
- * cases */
- if (percentage || box->gadget->type == GADGET_SUBMIT ||
- box->gadget->type == GADGET_RESET ||
- box->gadget->type == GADGET_BUTTON) {
calculate_mbp_width(box->style, setwidth ? LEFT : TOP,
false, true, true, &fixed, &frac);
calculate_mbp_width(box->style, setwidth ? RIGHT : BOTTOM,
false, true, true, &fixed, &frac);
- *dimension -= frac * available_width + fixed;
- *dimension = *dimension > 0 ? *dimension : 0;
+ orig -= frac * available_width + fixed;
+ *dimension = orig > 0 ? orig : 0;
}
}
@@ -921,7 +972,6 @@ layout_find_dimensions(int available_width,
{
struct box *containing_block = NULL;
unsigned int i;
- bool percentage;
if (width) {
enum css_width_e wtype;
@@ -942,13 +992,9 @@ layout_find_dimensions(int available_width,
*width = AUTO;
}
- /* specified gadget widths include borders and padding in some
- * cases */
- if (box->gadget && *width != AUTO) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, true, width);
+ if (*width != AUTO) {
+ layout_handle_box_sizing(box, available_width,
+ true, width);
}
}
@@ -1034,13 +1080,9 @@ layout_find_dimensions(int available_width,
*height = AUTO;
}
- /* specified gadget heights include borders and padding in
- * some cases */
- if (box->gadget && *height != AUTO) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, false, height);
+ if (*height != AUTO) {
+ layout_handle_box_sizing(box, available_width,
+ false, height);
}
}
@@ -1064,13 +1106,9 @@ layout_find_dimensions(int available_width,
*max_width = -1;
}
- /* specified gadget widths include borders and padding in some
- * cases */
- if (box->gadget && *max_width != -1) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, true, max_width);
+ if (*max_width != -1) {
+ layout_handle_box_sizing(box, available_width,
+ true, max_width);
}
}
@@ -1094,13 +1132,9 @@ layout_find_dimensions(int available_width,
*min_width = 0;
}
- /* specified gadget widths include borders and padding in some
- * cases */
- if (box->gadget && *min_width != 0) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, true, min_width);
+ if (*min_width != 0) {
+ layout_handle_box_sizing(box, available_width,
+ true, min_width);
}
}
-----------------------------------------------------------------------
Summary of changes:
!NetSurf/Resources/CSS,f79 | 4 +-
render/layout.c | 154 +++++++++++++++++++++++++++-----------------
2 files changed, 96 insertions(+), 62 deletions(-)
diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79
index 2aee83b..276bc15 100644
--- a/!NetSurf/Resources/CSS,f79
+++ b/!NetSurf/Resources/CSS,f79
@@ -114,13 +114,13 @@ form { display: block; }
input, button { background-color: #fff; color: #000; text-align: left;
font-family: sans-serif; width: auto; height: auto; overflow: hidden;
border: 1px solid #444; padding: 2px 3px; line-height: 1.33;
- margin: 1px; }
+ margin: 1px; box-sizing: border-box; }
input[disabled] { background-color: #ddd; color: #333; }
input[type=button], input[type=reset], input[type=submit], button {
background-color: #d9d9d9; color: #000; text-align: center;
border: 2px outset #d9d9d9; padding: 1px 0.5em; }
input[type=image] { background-color: transparent; color: #000;
- border: none; padding: 0 2px; }
+ border: none; padding: 0 2px; box-sizing: content-box; }
input[type=checkbox], input[type=radio] { background-color: transparent;
border: none; padding: 0 0.1em; }
input[type=file] { background-color: #d9d9d9; color: #000; font-style: italic;
diff --git a/render/layout.c b/render/layout.c
index c92089f..4086c04 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -332,6 +332,7 @@ layout_minmax_line(struct box *first,
for (b = first; b; b = b->next) {
enum css_width_e wtype;
enum css_height_e htype;
+ enum css_box_sizing_e bs;
css_fixed value = 0;
css_unit unit = CSS_UNIT_PX;
@@ -506,6 +507,7 @@ layout_minmax_line(struct box *first,
/* calculate box width */
wtype = css_computed_width(b->style, &value, &unit);
+ bs = css_computed_box_sizing(block->style);
if (wtype == CSS_WIDTH_SET) {
if (unit == CSS_UNIT_PCT) {
/*
@@ -516,6 +518,19 @@ layout_minmax_line(struct box *first,
} else {
width = FIXTOINT(nscss_len2px(value, unit,
b->style));
+
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ fixed = frac = 0;
+ calculate_mbp_width(block->style, LEFT,
+ false, true, true,
+ &fixed, &frac);
+ calculate_mbp_width(block->style, RIGHT,
+ false, true, true,
+ &fixed, &frac);
+ if (width < fixed) {
+ width = fixed;
+ }
+ }
if (width < 0)
width = 0;
}
@@ -541,11 +556,21 @@ layout_minmax_line(struct box *first,
}
fixed = frac = 0;
- calculate_mbp_width(b->style, LEFT, true, true, true,
- &fixed, &frac);
- calculate_mbp_width(b->style, RIGHT, true, true, true,
- &fixed, &frac);
-
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ calculate_mbp_width(b->style, LEFT,
+ true, false, false,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, false, false,
+ &fixed, &frac);
+ } else {
+ calculate_mbp_width(b->style, LEFT,
+ true, true, true,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, true, true,
+ &fixed, &frac);
+ }
if (0 < width + fixed)
width += fixed;
} else if (b->flags & IFRAME) {
@@ -554,13 +579,25 @@ layout_minmax_line(struct box *first,
width = 400;
fixed = frac = 0;
- calculate_mbp_width(b->style, LEFT, true, true, true,
- &fixed, &frac);
- calculate_mbp_width(b->style, RIGHT, true, true, true,
- &fixed, &frac);
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ calculate_mbp_width(b->style, LEFT,
+ true, false, false,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, false, false,
+ &fixed, &frac);
+ } else {
+ calculate_mbp_width(b->style, LEFT,
+ true, true, true,
+ &fixed, &frac);
+ calculate_mbp_width(b->style, RIGHT,
+ true, true, true,
+ &fixed, &frac);
+ }
if (0 < width + fixed)
width += fixed;
+
} else {
/* form control with no object */
if (width == AUTO)
@@ -667,6 +704,7 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
enum css_height_e htype = CSS_HEIGHT_AUTO;
css_fixed height = 0;
css_unit hunit = CSS_UNIT_PX;
+ enum css_box_sizing_e bs = CSS_BOX_SIZING_CONTENT_BOX;
bool child_has_height = false;
assert(block->type == BOX_BLOCK ||
@@ -680,6 +718,7 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
if (block->style != NULL) {
wtype = css_computed_width(block->style, &width, &wunit);
htype = css_computed_height(block->style, &height, &hunit);
+ bs = css_computed_box_sizing(block->style);
}
/* set whether the minimum width is of any interest for this box */
@@ -800,6 +839,19 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
if (block->type != BOX_TABLE_CELL && wtype == CSS_WIDTH_SET &&
wunit != CSS_UNIT_PCT) {
min = max = FIXTOINT(nscss_len2px(width, wunit, block->style));
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ int border_box_fixed = 0;
+ float border_box_frac = 0;
+ calculate_mbp_width(block->style, LEFT,
+ false, true, true,
+ &border_box_fixed, &border_box_frac);
+ calculate_mbp_width(block->style, RIGHT,
+ false, true, true,
+ &border_box_fixed, &border_box_frac);
+ if (min < border_box_fixed) {
+ min = max = border_box_fixed;
+ }
+ }
}
if (htype == CSS_HEIGHT_SET && hunit != CSS_UNIT_PCT &&
@@ -811,12 +863,8 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
/* add margins, border, padding to min, max widths */
/* Note: we don't know available width here so percentage margin
* and paddings are wrong. */
- if (block->gadget && wtype == CSS_WIDTH_SET &&
- (block->gadget->type == GADGET_SUBMIT ||
- block->gadget->type == GADGET_RESET ||
- block->gadget->type == GADGET_BUTTON)) {
- /* some gadgets with specified width already include border and
- * padding, so just get margin */
+ if (bs == CSS_BOX_SIZING_BORDER_BOX && wtype == CSS_WIDTH_SET) {
+ /* Border and padding included in width, so just get margin */
calculate_mbp_width(block->style, LEFT, true, false, false,
&extra_fixed, &extra_frac);
calculate_mbp_width(block->style, RIGHT, true, false, false,
@@ -850,12 +898,11 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
/**
- * Under some circumstances, specified dimensions for form elements include
- * borders and padding.
+ * Adjust a specified width or height for the box-sizing property.
+ *
+ * This turns the specified dimension into a content-box dimension.
*
* \param box gadget to adjust dimensions of
- * \param percentage whether the gadget has its dimension specified as a
- * percentage
* \param available_width width of containing block
* \param setwidth set true if the dimension to be tweaked is a width,
* else set false for a height
@@ -863,25 +910,29 @@ layout_minmax_block(struct box *block, const struct gui_layout_table *font_func)
* updated to new value after consideration of
* gadget properties.
*/
-static void layout_tweak_form_dimensions(struct box *box, bool percentage,
- int available_width, bool setwidth, int *dimension)
+static void layout_handle_box_sizing(
+ struct box *box,
+ int available_width,
+ bool setwidth,
+ int *dimension)
{
- int fixed = 0;
- float frac = 0;
+ enum css_box_sizing_e bs;
+
+ assert(box && box->style);
- assert(box && box->gadget);
+ bs = css_computed_box_sizing(box->style);
+
+ if (bs == CSS_BOX_SIZING_BORDER_BOX) {
+ int orig = *dimension;
+ int fixed = 0;
+ float frac = 0;
- /* specified gadget widths include borders and padding in some
- * cases */
- if (percentage || box->gadget->type == GADGET_SUBMIT ||
- box->gadget->type == GADGET_RESET ||
- box->gadget->type == GADGET_BUTTON) {
calculate_mbp_width(box->style, setwidth ? LEFT : TOP,
false, true, true, &fixed, &frac);
calculate_mbp_width(box->style, setwidth ? RIGHT : BOTTOM,
false, true, true, &fixed, &frac);
- *dimension -= frac * available_width + fixed;
- *dimension = *dimension > 0 ? *dimension : 0;
+ orig -= frac * available_width + fixed;
+ *dimension = orig > 0 ? orig : 0;
}
}
@@ -921,7 +972,6 @@ layout_find_dimensions(int available_width,
{
struct box *containing_block = NULL;
unsigned int i;
- bool percentage;
if (width) {
enum css_width_e wtype;
@@ -942,13 +992,9 @@ layout_find_dimensions(int available_width,
*width = AUTO;
}
- /* specified gadget widths include borders and padding in some
- * cases */
- if (box->gadget && *width != AUTO) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, true, width);
+ if (*width != AUTO) {
+ layout_handle_box_sizing(box, available_width,
+ true, width);
}
}
@@ -1034,13 +1080,9 @@ layout_find_dimensions(int available_width,
*height = AUTO;
}
- /* specified gadget heights include borders and padding in
- * some cases */
- if (box->gadget && *height != AUTO) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, false, height);
+ if (*height != AUTO) {
+ layout_handle_box_sizing(box, available_width,
+ false, height);
}
}
@@ -1064,13 +1106,9 @@ layout_find_dimensions(int available_width,
*max_width = -1;
}
- /* specified gadget widths include borders and padding in some
- * cases */
- if (box->gadget && *max_width != -1) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, true, max_width);
+ if (*max_width != -1) {
+ layout_handle_box_sizing(box, available_width,
+ true, max_width);
}
}
@@ -1094,13 +1132,9 @@ layout_find_dimensions(int available_width,
*min_width = 0;
}
- /* specified gadget widths include borders and padding in some
- * cases */
- if (box->gadget && *min_width != 0) {
- percentage = unit == CSS_UNIT_PCT;
-
- layout_tweak_form_dimensions(box, percentage,
- available_width, true, min_width);
+ if (*min_width != 0) {
+ layout_handle_box_sizing(box, available_width,
+ true, min_width);
}
}
--
NetSurf Browser
6 years, 5 months
libcss: branch master updated. release/0.6.1-36-ga0d2da3
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libcss.git/shortlog/a0d2da319d3c13549e24ac...
...commit http://git.netsurf-browser.org/libcss.git/commit/a0d2da319d3c13549e24ac01...
...tree http://git.netsurf-browser.org/libcss.git/tree/a0d2da319d3c13549e24ac012c...
The branch, master has been updated
via a0d2da319d3c13549e24ac012c9dbb2b22fdb957 (commit)
via ab5bd6f9d75878740cfe98581bdd8f8ba614853d (commit)
via 49a4a4c5f92389c5180eca43c6cdc607d370408a (commit)
via 21a424653c148ca966012826064f8b5db5afc93f (commit)
via 8d583fbe94b801353faec8e3a5a6729e3fe767a5 (commit)
via 24f23765517bd02445835dd543a07b1a883ca316 (commit)
via 37f8bbcef048c8274553b4f313f3aa222ce5c49d (commit)
via ded51e3eec1f74a60185e7f2ecc3bcef8502b99a (commit)
via ed0b3a8c9d3549fb0a66372d4bbd3566138c2a06 (commit)
from 4729f01919b7ba3f99abfea8900931616fbb8320 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=a0d2da319d3c13549e24...
commit a0d2da319d3c13549e24ac012c9dbb2b22fdb957
Merge: 4729f01 ab5bd6f
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Merge branch 'tlsa/box-sizing'
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=ab5bd6f9d75878740cfe...
commit ab5bd6f9d75878740cfe98581bdd8f8ba614853d
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Tests: Add box-sizing selection tests.
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index e28ccb3..ff8bbe1 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -5243,3 +5243,203 @@ writing-mode: horizontal-tb
z-index: auto
#reset
+#tree
+| div*
+#ua
+div { box-sizing: inherit; }
+#user
+#errors
+#expected
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: content-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+float: none
+font-family: sans-serif
+font-size: 12pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+left: auto
+letter-spacing: normal
+line-height: normal
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
+
+#tree
+| div*
+#ua
+div { box-sizing: inherit; }
+#user
+div { box-sizing: border-box; }
+#errors
+#expected
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: border-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+float: none
+font-family: sans-serif
+font-size: 12pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+left: auto
+letter-spacing: normal
+line-height: normal
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=49a4a4c5f92389c5180e...
commit 49a4a4c5f92389c5180eca43c6cdc607d370408a
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Tests: Dump box-sizing property in selection tests.
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index 5ab7d7a..e28ccb3 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -26,6 +26,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -129,6 +130,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -236,6 +238,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -344,6 +347,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -452,6 +456,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -560,6 +565,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -658,6 +664,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -757,6 +764,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -856,6 +864,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -954,6 +963,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1057,6 +1067,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1160,6 +1171,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1264,6 +1276,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1371,6 +1384,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1477,6 +1491,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1589,6 +1604,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1701,6 +1717,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1813,6 +1830,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1929,6 +1947,7 @@ border-right-width: 2px
border-bottom-width: 4px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2044,6 +2063,7 @@ border-right-width: 2em
border-bottom-width: 4px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2157,6 +2177,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2269,6 +2290,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2381,6 +2403,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2493,6 +2516,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2605,6 +2629,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2717,6 +2742,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2829,6 +2855,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2941,6 +2968,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3053,6 +3081,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3165,6 +3194,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3277,6 +3307,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3389,6 +3420,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3501,6 +3533,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3613,6 +3646,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3725,6 +3759,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3837,6 +3872,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3949,6 +3985,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4061,6 +4098,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4173,6 +4211,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4285,6 +4324,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4397,6 +4437,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4502,6 +4543,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4607,6 +4649,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4712,6 +4755,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4814,6 +4858,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4917,6 +4962,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: avoid
break-before: column
break-inside: auto
@@ -5020,6 +5066,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: avoid-page
break-before: always
break-inside: auto
@@ -5123,6 +5170,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: avoid-page
break-before: always
break-inside: avoid
diff --git a/test/dump_computed.h b/test/dump_computed.h
index 8efd2ca..eb9d522 100644
--- a/test/dump_computed.h
+++ b/test/dump_computed.h
@@ -715,6 +715,27 @@ static void dump_computed_style(const css_computed_style *style, char *buf,
ptr += wrote;
*len -= wrote;
+ /* box-sizing */
+ val = css_computed_box_sizing(style);
+ switch (val) {
+ case CSS_BOX_SIZING_INHERIT:
+ wrote = snprintf(ptr, *len, "box-sizing: inherit\n");
+ break;
+ case CSS_BOX_SIZING_CONTENT_BOX:
+ wrote = snprintf(ptr, *len, "box-sizing: content-box\n");
+ break;
+ case CSS_BOX_SIZING_BORDER_BOX:
+ wrote = snprintf(ptr, *len, "box-sizing: border-box\n");
+ break;
+ default:
+ wrote = 0;
+ printf("DISASTER!\n");
+ assert(0);
+ break;
+ }
+ ptr += wrote;
+ *len -= wrote;
+
/* break-after */
val = css_computed_break_after(style);
switch (val) {
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=21a424653c148ca96601...
commit 21a424653c148ca966012826064f8b5db5afc93f
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Interface: Add public API for getting box-sizing from computed style.
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index c7e77e0..e15d0b0 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -203,6 +203,9 @@ uint8_t css_computed_border_left_color(
const css_computed_style *style,
css_color *color);
+uint8_t css_computed_box_sizing(
+ const css_computed_style *style);
+
uint8_t css_computed_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit);
diff --git a/src/select/computed.c b/src/select/computed.c
index 2efc8a7..23f7ea4 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -632,6 +632,11 @@ uint8_t css_computed_border_left_color(const css_computed_style *style,
return get_border_left_color(style, color);
}
+uint8_t css_computed_box_sizing(const css_computed_style *style)
+{
+ return get_box_sizing(style);
+}
+
uint8_t css_computed_height(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=8d583fbe94b801353fae...
commit 8d583fbe94b801353faec8e3a5a6729e3fe767a5
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Selection: Add support for the CSS3 box-sizing property.
diff --git a/src/select/computed.h b/src/select/computed.h
index f77bda2..d2301f5 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -159,8 +159,9 @@ struct css_computed_style_i {
* unicode_bidi 2
* visibility 2
* white_space 3
+ * box_sizing 2
* ---
- * 84 bits
+ * 86 bits
*
* Colours are 32bits of AARRGGBB
* Dimensions are encoded as a fixed point value + 4 bits of unit data
@@ -250,7 +251,7 @@ struct css_computed_style_i {
* 21 mmmmmccc min-width | clear
* 22 tttttxxx padding-top | overflow-x
* 23 rrrrrppp padding-right | position
- * 24 bbbbbo.. padding-bottom | opacity | <unused>
+ * 24 bbbbboss padding-bottom | opacity | box-sizing
* 25 lllllttt padding-left | text-transform
* 26 tttttwww text-indent | white-space
* 27 bbbbbbbb background-position
diff --git a/src/select/properties/box_sizing.c b/src/select/properties/box_sizing.c
index 357dd3c..91c475d 100644
--- a/src/select/properties/box_sizing.c
+++ b/src/select/properties/box_sizing.c
@@ -17,20 +17,24 @@
css_error css__cascade_box_sizing(uint32_t opv, css_style *style,
css_select_state *state)
{
+ uint16_t value = CSS_BOX_SIZING_INHERIT;
+
UNUSED(style);
if (isInherit(opv) == false) {
switch (getValue(opv)) {
case BOX_SIZING_CONTENT_BOX:
+ value = CSS_BOX_SIZING_CONTENT_BOX;
+ break;
case BOX_SIZING_BORDER_BOX:
- /** \todo convert to public values */
+ value = CSS_BOX_SIZING_BORDER_BOX;
break;
}
}
if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
isInherit(opv))) {
- /** \todo set computed value */
+ return set_box_sizing(state->computed, value);
}
return CSS_OK;
@@ -39,17 +43,12 @@ css_error css__cascade_box_sizing(uint32_t opv, css_style *style,
css_error css__set_box_sizing_from_hint(const css_hint *hint,
css_computed_style *style)
{
- UNUSED(hint);
- UNUSED(style);
-
- return CSS_OK;
+ return set_box_sizing(style, hint->status);
}
css_error css__initial_box_sizing(css_select_state *state)
{
- UNUSED(state);
-
- return CSS_OK;
+ return set_box_sizing(state->computed, CSS_BOX_SIZING_CONTENT_BOX);
}
css_error css__compose_box_sizing(
@@ -57,10 +56,12 @@ css_error css__compose_box_sizing(
const css_computed_style *child,
css_computed_style *result)
{
- UNUSED(parent);
- UNUSED(child);
- UNUSED(result);
+ uint8_t type = get_box_sizing(child);
- return CSS_OK;
+ if (type == CSS_BOX_SIZING_INHERIT) {
+ type = get_box_sizing(parent);
+ }
+
+ return set_box_sizing(result, type);
}
diff --git a/src/select/propget.h b/src/select/propget.h
index 5552e39..6719443 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -1268,6 +1268,23 @@ static inline uint8_t get_background_attachment(
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_INDEX
+#define BOX_SIZING_INDEX 34
+#define BOX_SIZING_SHIFT 0
+#define BOX_SIZING_MASK 0x3
+static inline uint8_t get_box_sizing(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef BOX_SIZING_MASK
+#undef BOX_SIZING_SHIFT
+#undef BOX_SIZING_INDEX
+
#define BORDER_COLLAPSE_INDEX 13
#define BORDER_COLLAPSE_SHIFT 0
#define BORDER_COLLAPSE_MASK 0x3
diff --git a/src/select/propset.h b/src/select/propset.h
index 76e4fe6..3f4038c 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -1361,6 +1361,24 @@ static inline css_error set_background_attachment(
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_INDEX
+#define BOX_SIZING_INDEX 34
+#define BOX_SIZING_SHIFT 0
+#define BOX_SIZING_MASK 0x3
+static inline css_error set_box_sizing(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->i.bits[BOX_SIZING_INDEX];
+
+ /* 2bits: type */
+ *bits = (*bits & ~BOX_SIZING_MASK) |
+ ((type & 0x3) << BOX_SIZING_SHIFT);
+
+ return CSS_OK;
+}
+#undef BOX_SIZING_MASK
+#undef BOX_SIZING_SHIFT
+#undef BOX_SIZING_INDEX
+
#define BORDER_COLLAPSE_INDEX 13
#define BORDER_COLLAPSE_SHIFT 0
#define BORDER_COLLAPSE_MASK 0x3
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=24f23765517bd0244583...
commit 24f23765517bd02445835dd543a07b1a883ca316
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Tests: Add parser tests for box-sizing.
diff --git a/test/data/parse2/tests1.dat b/test/data/parse2/tests1.dat
index 40d1ab6..30afea8 100644
--- a/test/data/parse2/tests1.dat
+++ b/test/data/parse2/tests1.dat
@@ -148,3 +148,36 @@
| cursor: url('foo.png'), url('bar.gif'), pointer
#reset
+#data
+* { box-sizing: border-box; }
+#errors
+#expected
+| *
+| box-sizing: border-box
+#reset
+
+#data
+* { box-sizing: content-box; }
+#errors
+#expected
+| *
+| box-sizing: content-box
+#reset
+
+#data
+* { box-sizing: inherit; }
+#errors
+#expected
+| *
+| box-sizing: inherit
+#reset
+
+#data
+* { box-sizing: border-box; max-width: 2em }
+#errors
+#expected
+| *
+| box-sizing: border-box
+| max-width: 2em
+#reset
+
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=37f8bbcef048c8274553...
commit 37f8bbcef048c8274553b4f313f3aa222ce5c49d
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Tests: Add support for dumping the box-sizing property.
diff --git a/test/dump.h b/test/dump.h
index fe53f69..872c850 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -478,6 +478,7 @@ static const char *opcode_names[] = {
"column-width",
"writing-mode",
"overflow-y",
+ "box-sizing",
};
static void dump_css_fixed(css_fixed f, char **ptr)
@@ -976,6 +977,16 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
break;
}
break;
+ case CSS_PROP_BOX_SIZING:
+ switch (value) {
+ case BOX_SIZING_CONTENT_BOX:
+ *ptr += sprintf(*ptr, "content-box");
+ break;
+ case BOX_SIZING_BORDER_BOX:
+ *ptr += sprintf(*ptr, "border-box");
+ break;
+ }
+ break;
case CSS_PROP_BORDER_TOP_STYLE:
case CSS_PROP_BORDER_RIGHT_STYLE:
case CSS_PROP_BORDER_BOTTOM_STYLE:
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=ded51e3eec1f74a60185...
commit ded51e3eec1f74a60185e7f2ecc3bcef8502b99a
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Tests: Add box-sizing bytecode unit tests.
diff --git a/test/data/parse/properties.dat b/test/data/parse/properties.dat
index 7fcf137..3dcb5a4 100644
--- a/test/data/parse/properties.dat
+++ b/test/data/parse/properties.dat
@@ -4791,3 +4791,61 @@ p:before { content: open-quote url('http://picodrive.acornarcade.com/') " : " at
| 0x0008046f
#reset
+##
+## 71 - box-sizing
+##
+
+#data
+* { box-sizing: content-box; }
+#errors
+#expected
+| 1 *
+| 0x00000071
+#reset
+
+#data
+* { box-sizing: border-box; }
+#errors
+#expected
+| 1 *
+| 0x00040071
+#reset
+
+#data
+* { box-sizing: inherit; }
+#errors
+#expected
+| 1 *
+| 0x00000871
+#reset
+
+#data
+* { box-sizing: content-box !important; }
+#errors
+#expected
+| 1 *
+| 0x00000471
+#reset
+
+#data
+* { box-sizing: border-box !important; }
+#errors
+#expected
+| 1 *
+| 0x00040471
+#reset
+
+#data
+* { box-sizing: inherit !important; }
+#errors
+#expected
+| 1 *
+| 0x00000c71
+#reset
+
+#data
+* { box-sizing: none; }
+#errors
+#expected
+| 1 *
+#reset
commitdiff http://git.netsurf-browser.org/libcss.git/commit/?id=ed0b3a8c9d3549fb0a66...
commit ed0b3a8c9d3549fb0a66372d4bbd3566138c2a06
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Parsing: Add support for parsing the CSS3 box-sizing property.
diff --git a/docs/Bytecode b/docs/Bytecode
index 3f53d71..f2d10cc 100644
--- a/docs/Bytecode
+++ b/docs/Bytecode
@@ -1249,5 +1249,11 @@ Opcodes
3 => auto,
other => Reserved for future expansion.
-71-3ff - Reserved for future expansion.
+71 - box-sizing
+ <value> (14bits) :
+ 0 => content-box,
+ 1 => border-box,
+ other => Reserved for future expansion.
+
+72-3ff - Reserved for future expansion.
diff --git a/include/libcss/properties.h b/include/libcss/properties.h
index 0840f6f..06c033f 100644
--- a/include/libcss/properties.h
+++ b/include/libcss/properties.h
@@ -127,6 +127,7 @@ enum css_properties_e {
CSS_PROP_COLUMN_WIDTH = 0x06e,
CSS_PROP_WRITING_MODE = 0x06f,
CSS_PROP_OVERFLOW_Y = 0x070,
+ CSS_PROP_BOX_SIZING = 0x071,
CSS_N_PROPERTIES
};
@@ -209,6 +210,12 @@ enum css_bottom_e {
CSS_BOTTOM_AUTO = 0x2
};
+enum css_box_sizing_e {
+ CSS_BOX_SIZING_INHERIT = 0x0,
+ CSS_BOX_SIZING_CONTENT_BOX = 0x1,
+ CSS_BOX_SIZING_BORDER_BOX = 0x2
+};
+
enum css_break_after_e {
CSS_BREAK_AFTER_INHERIT = 0x0,
CSS_BREAK_AFTER_AUTO = 0x1,
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 4f80142..64ea482 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -103,6 +103,11 @@ enum op_bottom {
BOTTOM_AUTO = 0x0000
};
+enum op_box_sizing {
+ BOX_SIZING_CONTENT_BOX = 0x0000,
+ BOX_SIZING_BORDER_BOX = 0x0001
+};
+
enum op_break_after {
BREAK_AFTER_AUTO = 0x0000,
BREAK_AFTER_ALWAYS = 0x0001,
diff --git a/src/parse/properties/properties.c b/src/parse/properties/properties.c
index 49933cd..f32e374 100644
--- a/src/parse/properties/properties.c
+++ b/src/parse/properties/properties.c
@@ -42,6 +42,7 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_border_top_width,
css__parse_border_width,
css__parse_bottom,
+ css__parse_box_sizing,
css__parse_break_after,
css__parse_break_before,
css__parse_break_inside,
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index 4417cb6..60d5536 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -215,3 +215,5 @@ column_span:CSS_PROP_COLUMN_SPAN IDENT:( INHERIT: NONE:0,COLUMN_SPAN_NONE ALL:0,
column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: AUTO:0,COLUMN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_WIDTH_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ||unit&UNIT_PCT LENGTH_UNIT:)
writing_mode:CSS_PROP_WRITING_MODE IDENT:( INHERIT: HORIZONTAL_TB:0,WRITING_MODE_HORIZONTAL_TB VERTICAL_RL:0,WRITING_MODE_VERTICAL_RL VERTICAL_LR:0,WRITING_MODE_VERTICAL_LR IDENT:)
+
+box_sizing:CSS_PROP_BOX_SIZING IDENT:( INHERIT: CONTENT_BOX:0,BOX_SIZING_CONTENT_BOX BORDER_BOX:0,BOX_SIZING_BORDER_BOX IDENT:)
diff --git a/src/parse/properties/properties.h b/src/parse/properties/properties.h
index cf80761..e7b2bf7 100644
--- a/src/parse/properties/properties.h
+++ b/src/parse/properties/properties.h
@@ -112,6 +112,9 @@ css_error css__parse_border_width(css_language *c,
css_error css__parse_bottom(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
+css_error css__parse_box_sizing(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
css_error css__parse_break_after(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index 2c166a0..dd6bee4 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -112,6 +112,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "border-top-width", SLEN("border-top-width") },
{ "border-width", SLEN("border-width") },
{ "bottom", SLEN("bottom") },
+ { "box-sizing", SLEN("box-sizing") },
{ "break-after", SLEN("break-after") },
{ "break-before", SLEN("break-before") },
{ "break-inside", SLEN("break-inside") },
@@ -412,6 +413,8 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "horizontal-tb", SLEN("horizontal-tb") },
{ "vertical-rl", SLEN("vertical-rl") },
{ "vertical-lr", SLEN("vertical-lr") },
+ { "content-box", SLEN("content-box") },
+ { "border-box", SLEN("border-box") },
{ "aliceblue", SLEN("aliceblue") },
{ "antiquewhite", SLEN("antiquewhite") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index c686a91..1203c22 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -46,9 +46,9 @@ enum {
BORDER_LEFT_WIDTH, BORDER_RIGHT, BORDER_RIGHT_COLOR,
BORDER_RIGHT_STYLE, BORDER_RIGHT_WIDTH, BORDER_SPACING,
BORDER_STYLE, BORDER_TOP, BORDER_TOP_COLOR, BORDER_TOP_STYLE,
- BORDER_TOP_WIDTH, BORDER_WIDTH, BOTTOM, BREAK_AFTER, BREAK_BEFORE,
- BREAK_INSIDE, CAPTION_SIDE, CLEAR, CLIP, COLOR, COLUMNS, COLUMN_COUNT,
- COLUMN_FILL, COLUMN_GAP, COLUMN_RULE, COLUMN_RULE_COLOR,
+ BORDER_TOP_WIDTH, BORDER_WIDTH, BOTTOM, BOX_SIZING, BREAK_AFTER,
+ BREAK_BEFORE, BREAK_INSIDE, CAPTION_SIDE, CLEAR, CLIP, COLOR, COLUMNS,
+ COLUMN_COUNT, COLUMN_FILL, COLUMN_GAP, COLUMN_RULE, COLUMN_RULE_COLOR,
COLUMN_RULE_STYLE, COLUMN_RULE_WIDTH, COLUMN_SPAN, COLUMN_WIDTH,
CONTENT, COUNTER_INCREMENT, COUNTER_RESET, CUE, CUE_AFTER, CUE_BEFORE,
CURSOR, DIRECTION, DISPLAY, ELEVATION, EMPTY_CELLS, LIBCSS_FLOAT, FONT,
@@ -97,7 +97,8 @@ enum {
LINE_THROUGH, BLINK, RGB, RGBA, HSL, HSLA, LIBCSS_LEFT, LIBCSS_CENTER,
LIBCSS_RIGHT, CURRENTCOLOR, ODD, EVEN, SRC, LOCAL, INITIAL,
FORMAT, WOFF, TRUETYPE, OPENTYPE, EMBEDDED_OPENTYPE, SVG, COLUMN,
- AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL, VERTICAL_LR,
+ AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL,
+ VERTICAL_LR, CONTENT_BOX, BORDER_BOX,
/* Named colours */
FIRST_COLOUR,
diff --git a/src/select/dispatch.c b/src/select/dispatch.c
index 326da58..7af9000 100644
--- a/src/select/dispatch.c
+++ b/src/select/dispatch.c
@@ -582,5 +582,10 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
PROPERTY_FUNCS(overflow_y),
0,
GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(box_sizing),
+ 0,
+ GROUP_NORMAL
}
};
diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile
index ce3ddfa..288eda9 100644
--- a/src/select/properties/Makefile
+++ b/src/select/properties/Makefile
@@ -21,6 +21,7 @@ border_top_color.c \
border_top_style.c \
border_top_width.c \
bottom.c \
+box_sizing.c \
break_after.c \
break_before.c \
break_inside.c \
diff --git a/src/select/properties/box_sizing.c b/src/select/properties/box_sizing.c
new file mode 100644
index 0000000..357dd3c
--- /dev/null
+++ b/src/select/properties/box_sizing.c
@@ -0,0 +1,66 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_box_sizing(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case BOX_SIZING_CONTENT_BOX:
+ case BOX_SIZING_BORDER_BOX:
+ /** \todo convert to public values */
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ /** \todo set computed value */
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_box_sizing_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ UNUSED(hint);
+ UNUSED(style);
+
+ return CSS_OK;
+}
+
+css_error css__initial_box_sizing(css_select_state *state)
+{
+ UNUSED(state);
+
+ return CSS_OK;
+}
+
+css_error css__compose_box_sizing(
+ const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ UNUSED(parent);
+ UNUSED(child);
+ UNUSED(result);
+
+ return CSS_OK;
+}
+
diff --git a/src/select/properties/properties.h b/src/select/properties/properties.h
index f0ab29d..a1ab49f 100644
--- a/src/select/properties/properties.h
+++ b/src/select/properties/properties.h
@@ -42,6 +42,7 @@ PROPERTY_FUNCS(border_right_width);
PROPERTY_FUNCS(border_bottom_width);
PROPERTY_FUNCS(border_left_width);
PROPERTY_FUNCS(bottom);
+PROPERTY_FUNCS(box_sizing);
PROPERTY_FUNCS(break_after);
PROPERTY_FUNCS(break_before);
PROPERTY_FUNCS(break_inside);
-----------------------------------------------------------------------
Summary of changes:
docs/Bytecode | 8 +-
include/libcss/computed.h | 3 +
include/libcss/properties.h | 7 +
src/bytecode/opcodes.h | 5 +
src/parse/properties/properties.c | 1 +
src/parse/properties/properties.gen | 2 +
src/parse/properties/properties.h | 3 +
src/parse/propstrings.c | 3 +
src/parse/propstrings.h | 9 +-
src/select/computed.c | 5 +
src/select/computed.h | 5 +-
src/select/dispatch.c | 5 +
src/select/properties/Makefile | 1 +
src/select/properties/box_sizing.c | 67 ++++++++++
src/select/properties/properties.h | 1 +
src/select/propget.h | 17 +++
src/select/propset.h | 18 +++
test/data/parse/properties.dat | 58 ++++++++
test/data/parse2/tests1.dat | 33 +++++
test/data/select/tests1.dat | 248 +++++++++++++++++++++++++++++++++++
test/dump.h | 11 ++
test/dump_computed.h | 21 +++
22 files changed, 524 insertions(+), 7 deletions(-)
create mode 100644 src/select/properties/box_sizing.c
diff --git a/docs/Bytecode b/docs/Bytecode
index 3f53d71..f2d10cc 100644
--- a/docs/Bytecode
+++ b/docs/Bytecode
@@ -1249,5 +1249,11 @@ Opcodes
3 => auto,
other => Reserved for future expansion.
-71-3ff - Reserved for future expansion.
+71 - box-sizing
+ <value> (14bits) :
+ 0 => content-box,
+ 1 => border-box,
+ other => Reserved for future expansion.
+
+72-3ff - Reserved for future expansion.
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index c7e77e0..e15d0b0 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -203,6 +203,9 @@ uint8_t css_computed_border_left_color(
const css_computed_style *style,
css_color *color);
+uint8_t css_computed_box_sizing(
+ const css_computed_style *style);
+
uint8_t css_computed_height(
const css_computed_style *style,
css_fixed *length, css_unit *unit);
diff --git a/include/libcss/properties.h b/include/libcss/properties.h
index 0840f6f..06c033f 100644
--- a/include/libcss/properties.h
+++ b/include/libcss/properties.h
@@ -127,6 +127,7 @@ enum css_properties_e {
CSS_PROP_COLUMN_WIDTH = 0x06e,
CSS_PROP_WRITING_MODE = 0x06f,
CSS_PROP_OVERFLOW_Y = 0x070,
+ CSS_PROP_BOX_SIZING = 0x071,
CSS_N_PROPERTIES
};
@@ -209,6 +210,12 @@ enum css_bottom_e {
CSS_BOTTOM_AUTO = 0x2
};
+enum css_box_sizing_e {
+ CSS_BOX_SIZING_INHERIT = 0x0,
+ CSS_BOX_SIZING_CONTENT_BOX = 0x1,
+ CSS_BOX_SIZING_BORDER_BOX = 0x2
+};
+
enum css_break_after_e {
CSS_BREAK_AFTER_INHERIT = 0x0,
CSS_BREAK_AFTER_AUTO = 0x1,
diff --git a/src/bytecode/opcodes.h b/src/bytecode/opcodes.h
index 4f80142..64ea482 100644
--- a/src/bytecode/opcodes.h
+++ b/src/bytecode/opcodes.h
@@ -103,6 +103,11 @@ enum op_bottom {
BOTTOM_AUTO = 0x0000
};
+enum op_box_sizing {
+ BOX_SIZING_CONTENT_BOX = 0x0000,
+ BOX_SIZING_BORDER_BOX = 0x0001
+};
+
enum op_break_after {
BREAK_AFTER_AUTO = 0x0000,
BREAK_AFTER_ALWAYS = 0x0001,
diff --git a/src/parse/properties/properties.c b/src/parse/properties/properties.c
index 49933cd..f32e374 100644
--- a/src/parse/properties/properties.c
+++ b/src/parse/properties/properties.c
@@ -42,6 +42,7 @@ const css_prop_handler property_handlers[LAST_PROP + 1 - FIRST_PROP] =
css__parse_border_top_width,
css__parse_border_width,
css__parse_bottom,
+ css__parse_box_sizing,
css__parse_break_after,
css__parse_break_before,
css__parse_break_inside,
diff --git a/src/parse/properties/properties.gen b/src/parse/properties/properties.gen
index 4417cb6..60d5536 100644
--- a/src/parse/properties/properties.gen
+++ b/src/parse/properties/properties.gen
@@ -215,3 +215,5 @@ column_span:CSS_PROP_COLUMN_SPAN IDENT:( INHERIT: NONE:0,COLUMN_SPAN_NONE ALL:0,
column_width:CSS_PROP_COLUMN_WIDTH IDENT:( INHERIT: AUTO:0,COLUMN_WIDTH_AUTO IDENT:) LENGTH_UNIT:( UNIT_PX:COLUMN_WIDTH_SET DISALLOW:unit&UNIT_ANGLE||unit&UNIT_TIME||unit&UNIT_FREQ||unit&UNIT_PCT LENGTH_UNIT:)
writing_mode:CSS_PROP_WRITING_MODE IDENT:( INHERIT: HORIZONTAL_TB:0,WRITING_MODE_HORIZONTAL_TB VERTICAL_RL:0,WRITING_MODE_VERTICAL_RL VERTICAL_LR:0,WRITING_MODE_VERTICAL_LR IDENT:)
+
+box_sizing:CSS_PROP_BOX_SIZING IDENT:( INHERIT: CONTENT_BOX:0,BOX_SIZING_CONTENT_BOX BORDER_BOX:0,BOX_SIZING_BORDER_BOX IDENT:)
diff --git a/src/parse/properties/properties.h b/src/parse/properties/properties.h
index cf80761..e7b2bf7 100644
--- a/src/parse/properties/properties.h
+++ b/src/parse/properties/properties.h
@@ -112,6 +112,9 @@ css_error css__parse_border_width(css_language *c,
css_error css__parse_bottom(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
+css_error css__parse_box_sizing(css_language *c,
+ const parserutils_vector *vector, int *ctx,
+ css_style *result);
css_error css__parse_break_after(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style *result);
diff --git a/src/parse/propstrings.c b/src/parse/propstrings.c
index 2c166a0..dd6bee4 100644
--- a/src/parse/propstrings.c
+++ b/src/parse/propstrings.c
@@ -112,6 +112,7 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "border-top-width", SLEN("border-top-width") },
{ "border-width", SLEN("border-width") },
{ "bottom", SLEN("bottom") },
+ { "box-sizing", SLEN("box-sizing") },
{ "break-after", SLEN("break-after") },
{ "break-before", SLEN("break-before") },
{ "break-inside", SLEN("break-inside") },
@@ -412,6 +413,8 @@ const stringmap_entry stringmap[LAST_KNOWN] = {
{ "horizontal-tb", SLEN("horizontal-tb") },
{ "vertical-rl", SLEN("vertical-rl") },
{ "vertical-lr", SLEN("vertical-lr") },
+ { "content-box", SLEN("content-box") },
+ { "border-box", SLEN("border-box") },
{ "aliceblue", SLEN("aliceblue") },
{ "antiquewhite", SLEN("antiquewhite") },
diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h
index c686a91..1203c22 100644
--- a/src/parse/propstrings.h
+++ b/src/parse/propstrings.h
@@ -46,9 +46,9 @@ enum {
BORDER_LEFT_WIDTH, BORDER_RIGHT, BORDER_RIGHT_COLOR,
BORDER_RIGHT_STYLE, BORDER_RIGHT_WIDTH, BORDER_SPACING,
BORDER_STYLE, BORDER_TOP, BORDER_TOP_COLOR, BORDER_TOP_STYLE,
- BORDER_TOP_WIDTH, BORDER_WIDTH, BOTTOM, BREAK_AFTER, BREAK_BEFORE,
- BREAK_INSIDE, CAPTION_SIDE, CLEAR, CLIP, COLOR, COLUMNS, COLUMN_COUNT,
- COLUMN_FILL, COLUMN_GAP, COLUMN_RULE, COLUMN_RULE_COLOR,
+ BORDER_TOP_WIDTH, BORDER_WIDTH, BOTTOM, BOX_SIZING, BREAK_AFTER,
+ BREAK_BEFORE, BREAK_INSIDE, CAPTION_SIDE, CLEAR, CLIP, COLOR, COLUMNS,
+ COLUMN_COUNT, COLUMN_FILL, COLUMN_GAP, COLUMN_RULE, COLUMN_RULE_COLOR,
COLUMN_RULE_STYLE, COLUMN_RULE_WIDTH, COLUMN_SPAN, COLUMN_WIDTH,
CONTENT, COUNTER_INCREMENT, COUNTER_RESET, CUE, CUE_AFTER, CUE_BEFORE,
CURSOR, DIRECTION, DISPLAY, ELEVATION, EMPTY_CELLS, LIBCSS_FLOAT, FONT,
@@ -97,7 +97,8 @@ enum {
LINE_THROUGH, BLINK, RGB, RGBA, HSL, HSLA, LIBCSS_LEFT, LIBCSS_CENTER,
LIBCSS_RIGHT, CURRENTCOLOR, ODD, EVEN, SRC, LOCAL, INITIAL,
FORMAT, WOFF, TRUETYPE, OPENTYPE, EMBEDDED_OPENTYPE, SVG, COLUMN,
- AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL, VERTICAL_LR,
+ AVOID_PAGE, AVOID_COLUMN, BALANCE, HORIZONTAL_TB, VERTICAL_RL,
+ VERTICAL_LR, CONTENT_BOX, BORDER_BOX,
/* Named colours */
FIRST_COLOUR,
diff --git a/src/select/computed.c b/src/select/computed.c
index 2efc8a7..23f7ea4 100644
--- a/src/select/computed.c
+++ b/src/select/computed.c
@@ -632,6 +632,11 @@ uint8_t css_computed_border_left_color(const css_computed_style *style,
return get_border_left_color(style, color);
}
+uint8_t css_computed_box_sizing(const css_computed_style *style)
+{
+ return get_box_sizing(style);
+}
+
uint8_t css_computed_height(const css_computed_style *style,
css_fixed *length, css_unit *unit)
{
diff --git a/src/select/computed.h b/src/select/computed.h
index f77bda2..d2301f5 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -159,8 +159,9 @@ struct css_computed_style_i {
* unicode_bidi 2
* visibility 2
* white_space 3
+ * box_sizing 2
* ---
- * 84 bits
+ * 86 bits
*
* Colours are 32bits of AARRGGBB
* Dimensions are encoded as a fixed point value + 4 bits of unit data
@@ -250,7 +251,7 @@ struct css_computed_style_i {
* 21 mmmmmccc min-width | clear
* 22 tttttxxx padding-top | overflow-x
* 23 rrrrrppp padding-right | position
- * 24 bbbbbo.. padding-bottom | opacity | <unused>
+ * 24 bbbbboss padding-bottom | opacity | box-sizing
* 25 lllllttt padding-left | text-transform
* 26 tttttwww text-indent | white-space
* 27 bbbbbbbb background-position
diff --git a/src/select/dispatch.c b/src/select/dispatch.c
index 326da58..7af9000 100644
--- a/src/select/dispatch.c
+++ b/src/select/dispatch.c
@@ -582,5 +582,10 @@ struct prop_table prop_dispatch[CSS_N_PROPERTIES] = {
PROPERTY_FUNCS(overflow_y),
0,
GROUP_NORMAL
+ },
+ {
+ PROPERTY_FUNCS(box_sizing),
+ 0,
+ GROUP_NORMAL
}
};
diff --git a/src/select/properties/Makefile b/src/select/properties/Makefile
index ce3ddfa..288eda9 100644
--- a/src/select/properties/Makefile
+++ b/src/select/properties/Makefile
@@ -21,6 +21,7 @@ border_top_color.c \
border_top_style.c \
border_top_width.c \
bottom.c \
+box_sizing.c \
break_after.c \
break_before.c \
break_inside.c \
diff --git a/src/select/properties/box_sizing.c b/src/select/properties/box_sizing.c
new file mode 100644
index 0000000..91c475d
--- /dev/null
+++ b/src/select/properties/box_sizing.c
@@ -0,0 +1,67 @@
+/*
+ * This file is part of LibCSS
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2017 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+#include "bytecode/bytecode.h"
+#include "bytecode/opcodes.h"
+#include "select/propset.h"
+#include "select/propget.h"
+#include "utils/utils.h"
+
+#include "select/properties/properties.h"
+#include "select/properties/helpers.h"
+
+css_error css__cascade_box_sizing(uint32_t opv, css_style *style,
+ css_select_state *state)
+{
+ uint16_t value = CSS_BOX_SIZING_INHERIT;
+
+ UNUSED(style);
+
+ if (isInherit(opv) == false) {
+ switch (getValue(opv)) {
+ case BOX_SIZING_CONTENT_BOX:
+ value = CSS_BOX_SIZING_CONTENT_BOX;
+ break;
+ case BOX_SIZING_BORDER_BOX:
+ value = CSS_BOX_SIZING_BORDER_BOX;
+ break;
+ }
+ }
+
+ if (css__outranks_existing(getOpcode(opv), isImportant(opv), state,
+ isInherit(opv))) {
+ return set_box_sizing(state->computed, value);
+ }
+
+ return CSS_OK;
+}
+
+css_error css__set_box_sizing_from_hint(const css_hint *hint,
+ css_computed_style *style)
+{
+ return set_box_sizing(style, hint->status);
+}
+
+css_error css__initial_box_sizing(css_select_state *state)
+{
+ return set_box_sizing(state->computed, CSS_BOX_SIZING_CONTENT_BOX);
+}
+
+css_error css__compose_box_sizing(
+ const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ uint8_t type = get_box_sizing(child);
+
+ if (type == CSS_BOX_SIZING_INHERIT) {
+ type = get_box_sizing(parent);
+ }
+
+ return set_box_sizing(result, type);
+}
+
diff --git a/src/select/properties/properties.h b/src/select/properties/properties.h
index f0ab29d..a1ab49f 100644
--- a/src/select/properties/properties.h
+++ b/src/select/properties/properties.h
@@ -42,6 +42,7 @@ PROPERTY_FUNCS(border_right_width);
PROPERTY_FUNCS(border_bottom_width);
PROPERTY_FUNCS(border_left_width);
PROPERTY_FUNCS(bottom);
+PROPERTY_FUNCS(box_sizing);
PROPERTY_FUNCS(break_after);
PROPERTY_FUNCS(break_before);
PROPERTY_FUNCS(break_inside);
diff --git a/src/select/propget.h b/src/select/propget.h
index 5552e39..6719443 100644
--- a/src/select/propget.h
+++ b/src/select/propget.h
@@ -1268,6 +1268,23 @@ static inline uint8_t get_background_attachment(
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_INDEX
+#define BOX_SIZING_INDEX 34
+#define BOX_SIZING_SHIFT 0
+#define BOX_SIZING_MASK 0x3
+static inline uint8_t get_box_sizing(
+ const css_computed_style *style)
+{
+ uint8_t bits = style->i.bits[BOX_SIZING_INDEX];
+ bits &= BOX_SIZING_MASK;
+ bits >>= BOX_SIZING_SHIFT;
+
+ /* 2bits: type */
+ return bits;
+}
+#undef BOX_SIZING_MASK
+#undef BOX_SIZING_SHIFT
+#undef BOX_SIZING_INDEX
+
#define BORDER_COLLAPSE_INDEX 13
#define BORDER_COLLAPSE_SHIFT 0
#define BORDER_COLLAPSE_MASK 0x3
diff --git a/src/select/propset.h b/src/select/propset.h
index 76e4fe6..3f4038c 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -1361,6 +1361,24 @@ static inline css_error set_background_attachment(
#undef BACKGROUND_ATTACHMENT_SHIFT
#undef BACKGROUND_ATTACHMENT_INDEX
+#define BOX_SIZING_INDEX 34
+#define BOX_SIZING_SHIFT 0
+#define BOX_SIZING_MASK 0x3
+static inline css_error set_box_sizing(
+ css_computed_style *style, uint8_t type)
+{
+ uint8_t *bits = &style->i.bits[BOX_SIZING_INDEX];
+
+ /* 2bits: type */
+ *bits = (*bits & ~BOX_SIZING_MASK) |
+ ((type & 0x3) << BOX_SIZING_SHIFT);
+
+ return CSS_OK;
+}
+#undef BOX_SIZING_MASK
+#undef BOX_SIZING_SHIFT
+#undef BOX_SIZING_INDEX
+
#define BORDER_COLLAPSE_INDEX 13
#define BORDER_COLLAPSE_SHIFT 0
#define BORDER_COLLAPSE_MASK 0x3
diff --git a/test/data/parse/properties.dat b/test/data/parse/properties.dat
index 7fcf137..3dcb5a4 100644
--- a/test/data/parse/properties.dat
+++ b/test/data/parse/properties.dat
@@ -4791,3 +4791,61 @@ p:before { content: open-quote url('http://picodrive.acornarcade.com/') " : " at
| 0x0008046f
#reset
+##
+## 71 - box-sizing
+##
+
+#data
+* { box-sizing: content-box; }
+#errors
+#expected
+| 1 *
+| 0x00000071
+#reset
+
+#data
+* { box-sizing: border-box; }
+#errors
+#expected
+| 1 *
+| 0x00040071
+#reset
+
+#data
+* { box-sizing: inherit; }
+#errors
+#expected
+| 1 *
+| 0x00000871
+#reset
+
+#data
+* { box-sizing: content-box !important; }
+#errors
+#expected
+| 1 *
+| 0x00000471
+#reset
+
+#data
+* { box-sizing: border-box !important; }
+#errors
+#expected
+| 1 *
+| 0x00040471
+#reset
+
+#data
+* { box-sizing: inherit !important; }
+#errors
+#expected
+| 1 *
+| 0x00000c71
+#reset
+
+#data
+* { box-sizing: none; }
+#errors
+#expected
+| 1 *
+#reset
diff --git a/test/data/parse2/tests1.dat b/test/data/parse2/tests1.dat
index 40d1ab6..30afea8 100644
--- a/test/data/parse2/tests1.dat
+++ b/test/data/parse2/tests1.dat
@@ -148,3 +148,36 @@
| cursor: url('foo.png'), url('bar.gif'), pointer
#reset
+#data
+* { box-sizing: border-box; }
+#errors
+#expected
+| *
+| box-sizing: border-box
+#reset
+
+#data
+* { box-sizing: content-box; }
+#errors
+#expected
+| *
+| box-sizing: content-box
+#reset
+
+#data
+* { box-sizing: inherit; }
+#errors
+#expected
+| *
+| box-sizing: inherit
+#reset
+
+#data
+* { box-sizing: border-box; max-width: 2em }
+#errors
+#expected
+| *
+| box-sizing: border-box
+| max-width: 2em
+#reset
+
diff --git a/test/data/select/tests1.dat b/test/data/select/tests1.dat
index 5ab7d7a..ff8bbe1 100644
--- a/test/data/select/tests1.dat
+++ b/test/data/select/tests1.dat
@@ -26,6 +26,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -129,6 +130,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -236,6 +238,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -344,6 +347,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -452,6 +456,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -560,6 +565,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -658,6 +664,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -757,6 +764,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -856,6 +864,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -954,6 +963,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1057,6 +1067,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1160,6 +1171,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1264,6 +1276,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1371,6 +1384,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1477,6 +1491,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1589,6 +1604,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1701,6 +1717,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1813,6 +1830,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -1929,6 +1947,7 @@ border-right-width: 2px
border-bottom-width: 4px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2044,6 +2063,7 @@ border-right-width: 2em
border-bottom-width: 4px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2157,6 +2177,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2269,6 +2290,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2381,6 +2403,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2493,6 +2516,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2605,6 +2629,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2717,6 +2742,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2829,6 +2855,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -2941,6 +2968,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3053,6 +3081,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3165,6 +3194,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3277,6 +3307,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3389,6 +3420,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3501,6 +3533,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3613,6 +3646,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3725,6 +3759,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3837,6 +3872,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -3949,6 +3985,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4061,6 +4098,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4173,6 +4211,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4285,6 +4324,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4397,6 +4437,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4502,6 +4543,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4607,6 +4649,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4712,6 +4755,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4814,6 +4858,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: auto
break-before: auto
break-inside: auto
@@ -4917,6 +4962,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: avoid
break-before: column
break-inside: auto
@@ -5020,6 +5066,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: avoid-page
break-before: always
break-inside: auto
@@ -5123,6 +5170,7 @@ border-right-width: 2px
border-bottom-width: 2px
border-left-width: 2px
bottom: auto
+box-sizing: content-box
break-after: avoid-page
break-before: always
break-inside: avoid
@@ -5195,3 +5243,203 @@ writing-mode: horizontal-tb
z-index: auto
#reset
+#tree
+| div*
+#ua
+div { box-sizing: inherit; }
+#user
+#errors
+#expected
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: content-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+float: none
+font-family: sans-serif
+font-size: 12pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+left: auto
+letter-spacing: normal
+line-height: normal
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
+
+#tree
+| div*
+#ua
+div { box-sizing: inherit; }
+#user
+div { box-sizing: border-box; }
+#errors
+#expected
+background-attachment: scroll
+background-color: #00000000
+background-image: none
+background-position: 0% 0%
+background-repeat: repeat
+border-collapse: separate
+border-spacing: 0px 0px
+border-top-color: #ff000000
+border-right-color: #ff000000
+border-bottom-color: #ff000000
+border-left-color: #ff000000
+border-top-style: none
+border-right-style: none
+border-bottom-style: none
+border-left-style: none
+border-top-width: 2px
+border-right-width: 2px
+border-bottom-width: 2px
+border-left-width: 2px
+bottom: auto
+box-sizing: border-box
+break-after: auto
+break-before: auto
+break-inside: auto
+caption-side: top
+clear: none
+clip: auto
+color: #ff000000
+column-count: auto
+column-fill: balance
+column-gap: normal
+column-rule-color: #ff000000
+column-rule-style: none
+column-rule-width: 2px
+column-span: none
+column-width: auto
+content: normal
+counter-increment: none
+counter-reset: none
+cursor: auto
+direction: ltr
+display: inline
+empty-cells: show
+float: none
+font-family: sans-serif
+font-size: 12pt
+font-style: normal
+font-variant: normal
+font-weight: normal
+height: auto
+left: auto
+letter-spacing: normal
+line-height: normal
+list-style-image: none
+list-style-position: outside
+list-style-type: disc
+margin-top: 0px
+margin-right: 0px
+margin-bottom: 0px
+margin-left: 0px
+max-height: none
+max-width: none
+min-height: 0px
+min-width: 0px
+opacity: 1.000
+outline-color: invert
+outline-style: none
+outline-width: 2px
+overflow-x: visible
+overflow-y: visible
+padding-top: 0px
+padding-right: 0px
+padding-bottom: 0px
+padding-left: 0px
+position: static
+quotes: none
+right: auto
+table-layout: auto
+text-align: default
+text-decoration: none
+text-indent: 0px
+text-transform: none
+top: auto
+unicode-bidi: normal
+vertical-align: baseline
+visibility: visible
+white-space: normal
+width: auto
+word-spacing: normal
+writing-mode: horizontal-tb
+z-index: auto
+#reset
diff --git a/test/dump.h b/test/dump.h
index fe53f69..872c850 100644
--- a/test/dump.h
+++ b/test/dump.h
@@ -478,6 +478,7 @@ static const char *opcode_names[] = {
"column-width",
"writing-mode",
"overflow-y",
+ "box-sizing",
};
static void dump_css_fixed(css_fixed f, char **ptr)
@@ -976,6 +977,16 @@ void dump_bytecode(css_style *style, char **ptr, uint32_t depth)
break;
}
break;
+ case CSS_PROP_BOX_SIZING:
+ switch (value) {
+ case BOX_SIZING_CONTENT_BOX:
+ *ptr += sprintf(*ptr, "content-box");
+ break;
+ case BOX_SIZING_BORDER_BOX:
+ *ptr += sprintf(*ptr, "border-box");
+ break;
+ }
+ break;
case CSS_PROP_BORDER_TOP_STYLE:
case CSS_PROP_BORDER_RIGHT_STYLE:
case CSS_PROP_BORDER_BOTTOM_STYLE:
diff --git a/test/dump_computed.h b/test/dump_computed.h
index 8efd2ca..eb9d522 100644
--- a/test/dump_computed.h
+++ b/test/dump_computed.h
@@ -715,6 +715,27 @@ static void dump_computed_style(const css_computed_style *style, char *buf,
ptr += wrote;
*len -= wrote;
+ /* box-sizing */
+ val = css_computed_box_sizing(style);
+ switch (val) {
+ case CSS_BOX_SIZING_INHERIT:
+ wrote = snprintf(ptr, *len, "box-sizing: inherit\n");
+ break;
+ case CSS_BOX_SIZING_CONTENT_BOX:
+ wrote = snprintf(ptr, *len, "box-sizing: content-box\n");
+ break;
+ case CSS_BOX_SIZING_BORDER_BOX:
+ wrote = snprintf(ptr, *len, "box-sizing: border-box\n");
+ break;
+ default:
+ wrote = 0;
+ printf("DISASTER!\n");
+ assert(0);
+ break;
+ }
+ ptr += wrote;
+ *len -= wrote;
+
/* break-after */
val = css_computed_break_after(style);
switch (val) {
--
Cascading Style Sheets library
6 years, 5 months
netsurf: branch master updated. release/3.6-420-g66602e6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/66602e63277ad0063e726...
...commit http://git.netsurf-browser.org/netsurf.git/commit/66602e63277ad0063e7267e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/66602e63277ad0063e7267ea8...
The branch, master has been updated
via 66602e63277ad0063e7267ea8e32d75da590bceb (commit)
from 87ed0904e0dd1fec1b204f64db760aa65fad2cd6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=66602e63277ad0063e7...
commit 66602e63277ad0063e7267ea8e32d75da590bceb
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fixup errors introduced in set_scroll API change
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 18816c4..7eacda7 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -242,7 +242,7 @@ static void ami_do_redraw(struct gui_window_2 *g);
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin);
static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy);
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
+static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect);
static void gui_window_remove_caret(struct gui_window *g);
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip);
//static void amiga_window_invalidate_area(struct gui_window *g, const struct rect *restrict rect);
@@ -1494,6 +1494,7 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
{
struct IBox *bbox;
int x, y;
+ struct rect rect;
if(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true)
{
@@ -1560,8 +1561,9 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
}
ami_gui_free_space_box(bbox);
-
- gui_window_set_scroll(gwin->gw, xs, ys);
+ rect.x0 = rect.x1 = xs;
+ rect.y0 = rect.y1 = ys;
+ gui_window_set_scroll(gwin->gw, &rect);
}
}
}
@@ -2561,12 +2563,15 @@ static BOOL ami_gui_event(void *w)
if(drag_x_move || drag_y_move)
{
+ struct rect rect;
+
gui_window_get_scroll(gwin->gw,
&gwin->gw->scrollx, &gwin->gw->scrolly);
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx + drag_x_move,
- gwin->gw->scrolly + drag_y_move);
+ rect.x0 = rect.x1 = gwin->gw->scrollx + drag_x_move;
+ rect.y0 = rect.y1 = gwin->gw->scrolly + drag_y_move;
+
+ gui_window_set_scroll(gwin->gw, &rect);
}
// ReplyMsg((struct Message *)message);
@@ -2921,11 +2926,15 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
if(redraw)
{
+ struct rect rect;
+
ami_plot_clear_bbox(gwin->win->RPort, bbox);
browser_window_update(gwin->gw->bw, false);
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx, gwin->gw->scrolly);
+ rect.x0 = rect.x1 = gwin->gw->scrollx;
+ rect.y0 = rect.y1 = gwin->gw->scrolly;
+
+ gui_window_set_scroll(gwin->gw, &rect);
gwin->redraw_scroll = false;
browser_window_refresh_url_bar(gwin->gw->bw);
@@ -4981,25 +4990,33 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r
* \param rect The rectangle to ensure is shown.
* \return NSERROR_OK on success or apropriate error code.
*/
-static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
struct IBox *bbox;
int width, height;
nserror res;
+ int sx = 0, sy = 0;
if(!g) {
return NSERROR_BAD_PARAMETER;
}
- if(!g->bw ||
- browser_window_has_content(g->bw) == false) return;
+ if(!g->bw || browser_window_has_content(g->bw) == false) {
+ return NSERROR_BAD_PARAMETER;
+ }
- if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ res = ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox);
+ if(res != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
- return;
+ return res;
}
- if(sx < 0) sx=0;
- if(sy < 0) sy=0;
+ if (rect->x0 > 0) {
+ sx = rect->x0;
+ }
+ if (rect->y0 > 0) {
+ sy = rect->y0;
+ }
browser_window_get_extents(g->bw, false, &width, &height);
@@ -5037,6 +5054,7 @@ static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *re
g->scrollx = sx;
g->scrolly = sy;
}
+ return NSERROR_OK;
}
static void gui_window_update_extent(struct gui_window *g)
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 2121d94..8acb20a 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -1049,16 +1049,20 @@ static nserror
gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
//CALLED();
- if (g->view == NULL)
- return;
- if (!g->view->LockLooper())
- return;
+ if (g->view == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (!g->view->LockLooper()) {
+ return NSERROR_BAD_PARAMETER;
+ }
#warning XXX: report to view frame ?
- if (g->view->ScrollBar(B_HORIZONTAL))
+ if (g->view->ScrollBar(B_HORIZONTAL)) {
g->view->ScrollBar(B_HORIZONTAL)->SetValue(rect->x0);
- if (g->view->ScrollBar(B_VERTICAL))
+ }
+ if (g->view->ScrollBar(B_VERTICAL)) {
g->view->ScrollBar(B_VERTICAL)->SetValue(rect->y0);
+ }
g->view->UnlockLooper();
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/gui.c | 48 +++++++++++++++++++++++++++++++--------------
frontends/beos/window.cpp | 16 +++++++++------
2 files changed, 43 insertions(+), 21 deletions(-)
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 18816c4..7eacda7 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -242,7 +242,7 @@ static void ami_do_redraw(struct gui_window_2 *g);
static void ami_schedule_redraw_remove(struct gui_window_2 *gwin);
static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *restrict sy);
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy);
+static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect);
static void gui_window_remove_caret(struct gui_window *g);
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height, const struct rect *clip);
//static void amiga_window_invalidate_area(struct gui_window *g, const struct rect *restrict rect);
@@ -1494,6 +1494,7 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
{
struct IBox *bbox;
int x, y;
+ struct rect rect;
if(ami_mouse_to_ns_coords(gwin, &x, &y, -1, -1) == true)
{
@@ -1560,8 +1561,9 @@ static void ami_gui_scroll_internal(struct gui_window_2 *gwin, int xs, int ys)
}
ami_gui_free_space_box(bbox);
-
- gui_window_set_scroll(gwin->gw, xs, ys);
+ rect.x0 = rect.x1 = xs;
+ rect.y0 = rect.y1 = ys;
+ gui_window_set_scroll(gwin->gw, &rect);
}
}
}
@@ -2561,12 +2563,15 @@ static BOOL ami_gui_event(void *w)
if(drag_x_move || drag_y_move)
{
+ struct rect rect;
+
gui_window_get_scroll(gwin->gw,
&gwin->gw->scrollx, &gwin->gw->scrolly);
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx + drag_x_move,
- gwin->gw->scrolly + drag_y_move);
+ rect.x0 = rect.x1 = gwin->gw->scrollx + drag_x_move;
+ rect.y0 = rect.y1 = gwin->gw->scrolly + drag_y_move;
+
+ gui_window_set_scroll(gwin->gw, &rect);
}
// ReplyMsg((struct Message *)message);
@@ -2921,11 +2926,15 @@ void ami_switch_tab(struct gui_window_2 *gwin, bool redraw)
if(redraw)
{
+ struct rect rect;
+
ami_plot_clear_bbox(gwin->win->RPort, bbox);
browser_window_update(gwin->gw->bw, false);
- gui_window_set_scroll(gwin->gw,
- gwin->gw->scrollx, gwin->gw->scrolly);
+ rect.x0 = rect.x1 = gwin->gw->scrollx;
+ rect.y0 = rect.y1 = gwin->gw->scrolly;
+
+ gui_window_set_scroll(gwin->gw, &rect);
gwin->redraw_scroll = false;
browser_window_refresh_url_bar(gwin->gw->bw);
@@ -4981,25 +4990,33 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r
* \param rect The rectangle to ensure is shown.
* \return NSERROR_OK on success or apropriate error code.
*/
-static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
struct IBox *bbox;
int width, height;
nserror res;
+ int sx = 0, sy = 0;
if(!g) {
return NSERROR_BAD_PARAMETER;
}
- if(!g->bw ||
- browser_window_has_content(g->bw) == false) return;
+ if(!g->bw || browser_window_has_content(g->bw) == false) {
+ return NSERROR_BAD_PARAMETER;
+ }
- if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
+ res = ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox);
+ if(res != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
- return;
+ return res;
}
- if(sx < 0) sx=0;
- if(sy < 0) sy=0;
+ if (rect->x0 > 0) {
+ sx = rect->x0;
+ }
+ if (rect->y0 > 0) {
+ sy = rect->y0;
+ }
browser_window_get_extents(g->bw, false, &width, &height);
@@ -5037,6 +5054,7 @@ static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *re
g->scrollx = sx;
g->scrolly = sy;
}
+ return NSERROR_OK;
}
static void gui_window_update_extent(struct gui_window *g)
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index 2121d94..8acb20a 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -1049,16 +1049,20 @@ static nserror
gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
//CALLED();
- if (g->view == NULL)
- return;
- if (!g->view->LockLooper())
- return;
+ if (g->view == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if (!g->view->LockLooper()) {
+ return NSERROR_BAD_PARAMETER;
+ }
#warning XXX: report to view frame ?
- if (g->view->ScrollBar(B_HORIZONTAL))
+ if (g->view->ScrollBar(B_HORIZONTAL)) {
g->view->ScrollBar(B_HORIZONTAL)->SetValue(rect->x0);
- if (g->view->ScrollBar(B_VERTICAL))
+ }
+ if (g->view->ScrollBar(B_VERTICAL)) {
g->view->ScrollBar(B_VERTICAL)->SetValue(rect->y0);
+ }
g->view->UnlockLooper();
--
NetSurf Browser
6 years, 5 months
netsurf: branch master updated. release/3.6-419-g87ed090
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/87ed0904e0dd1fec1b204...
...commit http://git.netsurf-browser.org/netsurf.git/commit/87ed0904e0dd1fec1b204f6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/87ed0904e0dd1fec1b204f64d...
The branch, master has been updated
via 87ed0904e0dd1fec1b204f64db760aa65fad2cd6 (commit)
via 5fba1fb94d875a849d3c9092943406b7cab4d27a (commit)
via c100a332855260901f34f4ae1bfc94693c8f3801 (commit)
via 2de6386da2eee0438d481d33c28591a303959506 (commit)
via 0f039b44212d312fa6920ec60e59df1313182913 (commit)
via a696720cd605439be5473de209531c5113f47a97 (commit)
via db9b829df2a7c1676da131f5fe66f106af2ba14a (commit)
via db549331f7523fbbfe0460b8adb540838f582cec (commit)
via cbc60a906ae74869f133bfdacbadccddd3239ba1 (commit)
via 87066f9f8dbad2416c53f70497aeb7c940ccb239 (commit)
from 7bbf2a9ca0cd418f64b001b87f77c779433119fe (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=87ed0904e0dd1fec1b2...
commit 87ed0904e0dd1fec1b204f64db760aa65fad2cd6
Merge: 7bbf2a9 5fba1fb
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Merge branch 'vince/scroll-api'
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5fba1fb94d875a849d3...
commit 5fba1fb94d875a849d3c9092943406b7cab4d27a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update windows frontend for set_scroll API change
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index 0bd1bae..4540b12 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -137,8 +137,10 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
- win32_window_set_scroll(gw, gw->scrollx, gw->scrolly +
- gw->requestscrolly + si.nPos - mem);
+ struct rect rect;
+ rect.x0 = rect.x1 = gw->scrollx;
+ rect.y0 = rect.y1 = gw->scrolly + gw->requestscrolly + si.nPos - mem;
+ win32_window_set_scroll(gw, &rect);
}
return 0;
@@ -201,9 +203,10 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
- win32_window_set_scroll(gw,
- gw->scrollx + gw->requestscrollx + si.nPos - mem,
- gw->scrolly);
+ struct rect rect;
+ rect.x0 = rect.x1 = gw->scrollx + gw->requestscrollx + si.nPos - mem;
+ rect.y0 = rect.y1 = gw->scrolly;
+ win32_window_set_scroll(gw, &rect);
}
return 0;
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 829067b..6ba61c5 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -923,7 +923,7 @@ win32_window_invalidate_area(struct gui_window *gw, const struct rect *rect)
*/
static void nsws_set_scale(struct gui_window *gw, float scale)
{
- int x, y;
+ struct rect rect;
assert(gw != NULL);
@@ -931,8 +931,8 @@ static void nsws_set_scale(struct gui_window *gw, float scale)
return;
}
- x = gw->scrollx;
- y = gw->scrolly;
+ rect.x0 = rect.x1 = gw->scrollx;
+ rect.y0 = rect.y1 = gw->scrolly;
gw->scale = scale;
@@ -941,7 +941,7 @@ static void nsws_set_scale(struct gui_window *gw, float scale)
}
win32_window_invalidate_area(gw, NULL);
- win32_window_set_scroll(gw, x, y);
+ win32_window_set_scroll(gw, &rect);
}
@@ -1338,7 +1338,7 @@ nsws_window_resize(struct gui_window *gw,
WPARAM wparam,
LPARAM lparam)
{
- int x, y;
+ struct rect rect;
RECT rstatus, rtool;
if ((gw->toolbar == NULL) ||
@@ -1351,7 +1351,7 @@ nsws_window_resize(struct gui_window *gw,
GetClientRect(gw->toolbar, &rtool);
GetWindowRect(gw->statusbar, &rstatus);
- win32_window_get_scroll(gw, &x, &y);
+ win32_window_get_scroll(gw, &rect.x0, &rect.y0);
gw->width = LOWORD(lparam);
gw->height = HIWORD(lparam) - (rtool.bottom - rtool.top) - (rstatus.bottom - rstatus.top);
@@ -1365,7 +1365,7 @@ nsws_window_resize(struct gui_window *gw,
}
nsws_window_update_forward_back(gw);
- win32_window_set_scroll(gw, x, y);
+ win32_window_set_scroll(gw, &rect);
if (gw->toolbar != NULL) {
SendMessage(gw->toolbar, TB_SETSTATE,
@@ -1830,40 +1830,39 @@ bool nsws_window_go(HWND hwnd, const char *urltxt)
/* exported interface documented in windows/window.h */
-void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
+nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
SCROLLINFO si;
- nserror err;
+ nserror res;
int height;
int width;
POINT p;
- if ((w == NULL) || (w->bw == NULL))
- return;
-
- err = browser_window_get_extents(w->bw, true, &width, &height);
- if (err != NSERROR_OK) {
- return;
+ if ((gw == NULL) || (gw->bw == NULL)) {
+ return NSERROR_BAD_PARAMETER;
}
- /*LOG("scroll sx,sy:%d,%d x,y:%d,%d w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height);*/
+ res = browser_window_get_extents(gw->bw, true, &width, &height);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* The resulting gui window scroll must remain within the
* windows bounding box.
*/
- if (sx < 0) {
- w->requestscrollx = -w->scrollx;
- } else if (sx > (width - w->width)) {
- w->requestscrollx = (width - w->width) - w->scrollx;
+ if (rect->x0 < 0) {
+ gw->requestscrollx = -gw->scrollx;
+ } else if (rect->x0 > (width - gw->width)) {
+ gw->requestscrollx = (width - gw->width) - gw->scrollx;
} else {
- w->requestscrollx = sx - w->scrollx;
+ gw->requestscrollx = rect->x0 - gw->scrollx;
}
- if (sy < 0) {
- w->requestscrolly = -w->scrolly;
- } else if (sy > (height - w->height)) {
- w->requestscrolly = (height - w->height) - w->scrolly;
+ if (rect->y0 < 0) {
+ gw->requestscrolly = -gw->scrolly;
+ } else if (rect->y0 > (height - gw->height)) {
+ gw->requestscrolly = (height - gw->height) - gw->scrolly;
} else {
- w->requestscrolly = sy - w->scrolly;
+ gw->requestscrolly = rect->y0 - gw->scrolly;
}
/*LOG("requestscroll x,y:%d,%d", w->requestscrollx, w->requestscrolly);*/
@@ -1873,10 +1872,10 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = height - 1;
- si.nPage = w->height;
- si.nPos = max(w->scrolly + w->requestscrolly, 0);
- si.nPos = min(si.nPos, height - w->height);
- SetScrollInfo(w->drawingarea, SB_VERT, &si, TRUE);
+ si.nPage = gw->height;
+ si.nPos = max(gw->scrolly + gw->requestscrolly, 0);
+ si.nPos = min(si.nPos, height - gw->height);
+ SetScrollInfo(gw->drawingarea, SB_VERT, &si, TRUE);
/*LOG("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos);*/
/* set the horizontal scroll offset */
@@ -1884,30 +1883,31 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = width -1;
- si.nPage = w->width;
- si.nPos = max(w->scrollx + w->requestscrollx, 0);
- si.nPos = min(si.nPos, width - w->width);
- SetScrollInfo(w->drawingarea, SB_HORZ, &si, TRUE);
+ si.nPage = gw->width;
+ si.nPos = max(gw->scrollx + gw->requestscrollx, 0);
+ si.nPos = min(si.nPos, width - gw->width);
+ SetScrollInfo(gw->drawingarea, SB_HORZ, &si, TRUE);
/*LOG("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos);*/
/* Set caret position */
GetCaretPos(&p);
- HideCaret(w->drawingarea);
- SetCaretPos(p.x - w->requestscrollx, p.y - w->requestscrolly);
- ShowCaret(w->drawingarea);
+ HideCaret(gw->drawingarea);
+ SetCaretPos(p.x - gw->requestscrollx, p.y - gw->requestscrolly);
+ ShowCaret(gw->drawingarea);
RECT r, redraw;
r.top = 0;
- r.bottom = w->height + 1;
+ r.bottom = gw->height + 1;
r.left = 0;
- r.right = w->width + 1;
- ScrollWindowEx(w->drawingarea, - w->requestscrollx, - w->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE);
+ r.right = gw->width + 1;
+ ScrollWindowEx(gw->drawingarea, - gw->requestscrollx, - gw->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE);
/*LOG("ScrollWindowEx %d, %d", - w->requestscrollx, - w->requestscrolly);*/
- w->scrolly += w->requestscrolly;
- w->scrollx += w->requestscrollx;
- w->requestscrollx = 0;
- w->requestscrolly = 0;
+ gw->scrolly += gw->requestscrolly;
+ gw->scrollx += gw->requestscrollx;
+ gw->requestscrollx = 0;
+ gw->requestscrolly = 0;
+ return NSERROR_OK;
}
diff --git a/frontends/windows/window.h b/frontends/windows/window.h
index d927c28..3cdb9ae 100644
--- a/frontends/windows/window.h
+++ b/frontends/windows/window.h
@@ -73,6 +73,7 @@ struct gui_window {
struct gui_window *next, *prev; /**< global linked list */
};
+struct rect;
/**
* Obtain gui window structure from window handle.
@@ -91,13 +92,17 @@ struct gui_window *nsws_get_gui_window(HWND hwnd);
bool nsws_window_go(HWND hwnd, const char *urltxt);
/**
- * scroll the window
+ * Set the scroll position of a win32 browser window.
*
- * \param w The win32 gui window to scroll.
- * \param sx the new 'absolute' horizontal scroll location
- * \param sy the new 'absolute' vertical scroll location
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The win32 implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw The win32 gui window to scroll.
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
*/
-void win32_window_set_scroll(struct gui_window *w, int sx, int sy);
+nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect);
/**
* Create the main browser window class.
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c100a332855260901f3...
commit c100a332855260901f34f4ae1bfc94693c8f3801
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update riscos frontend for set_scroll API change
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 1d5c093..3496d4b 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -806,124 +806,118 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
/**
- * Set the scroll position of a browser window.
+ * Set the scroll position of a riscos browser window.
*
- * \param g gui_window to scroll
- * \param sx point to place at top-left of window
- * \param sy point to place at top-left of window
- */
-
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
-{
- wimp_window_state state;
- os_error *error;
-
- assert(g);
-
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- state.xscroll = sx * 2 * g->scale;
- state.yscroll = -sy * 2 * g->scale;
- if (g->toolbar)
- state.yscroll += ro_toolbar_full_height(g->toolbar);
- ro_gui_window_open(PTR_WIMP_OPEN(&state));
-}
-
-
-/**
- * Scrolls the specified area of a browser window into view.
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
*
- * \param g gui_window to scroll
- * \param x0 left point to ensure visible
- * \param y0 bottom point to ensure visible
- * \param x1 right point to ensure visible
- * \param y1 top point to ensure visible
+ * \param g gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
*/
-static void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1)
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
wimp_window_state state;
os_error *error;
- int cx0, cy0, width, height;
- int padding_available;
int toolbar_height = 0;
- int correction;
assert(g);
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ LOG("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
- return;
+ return NSERROR_BAD_PARAMETER;
}
- if (g->toolbar)
+ if (g->toolbar) {
toolbar_height = ro_toolbar_full_height(g->toolbar);
-
- x0 = x0 * 2 * g->scale;
- y0 = y0 * 2 * g->scale;
- x1 = x1 * 2 * g->scale;
- y1 = y1 * 2 * g->scale;
-
- cx0 = state.xscroll;
- cy0 = -state.yscroll + toolbar_height;
- width = state.visible.x1 - state.visible.x0;
- height = state.visible.y1 - state.visible.y0 - toolbar_height;
-
- /* make sure we're visible */
- correction = (x1 - cx0 - width);
- if (correction > 0)
- cx0 += correction;
- correction = (y1 - cy0 - height);
- if (correction > 0)
- cy0 += correction;
- if (x0 < cx0)
- cx0 = x0;
- if (y0 < cy0)
- cy0 = y0;
-
- /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
- padding_available = (width - x1 + x0) / 2;
- if (padding_available > 0) {
- if (padding_available > SCROLL_VISIBLE_PADDING)
- padding_available = SCROLL_VISIBLE_PADDING;
- correction = (cx0 + width - x1);
- if (correction < padding_available)
- cx0 += padding_available;
- correction = (x0 - cx0);
- if (correction < padding_available)
- cx0 -= padding_available;
- }
- padding_available = (height - y1 + y0) / 2;
- if (padding_available > 0) {
- if (padding_available > SCROLL_VISIBLE_PADDING)
- padding_available = SCROLL_VISIBLE_PADDING;
- correction = (cy0 + height - y1);
- if (correction < padding_available)
- cy0 += padding_available;
- correction = (y0 - cy0);
- if (correction < padding_available)
- cy0 -= padding_available;
}
- state.xscroll = cx0;
- state.yscroll = -cy0 + toolbar_height;
+ if ((rect->x0 == rect->x1) && (rect->y0 == rect->y1)) {
+ /* scroll to top */
+ state.xscroll = rect->x0 * 2 * g->scale;
+ state.yscroll = (-rect->y0 * 2 * g->scale) + toolbar_height;
+ } else {
+ /* scroll area into view with padding */
+ int x0, y0, x1, y1;
+ int cx0, cy0, width, height;
+ int padding_available;
+ int correction;
+
+ x0 = rect->x0 * 2 * g->scale;
+ y0 = rect->y0 * 2 * g->scale;
+ x1 = rect->x1 * 2 * g->scale;
+ y1 = rect->y1 * 2 * g->scale;
+
+ cx0 = state.xscroll;
+ cy0 = -state.yscroll + toolbar_height;
+ width = state.visible.x1 - state.visible.x0;
+ height = state.visible.y1 - state.visible.y0 - toolbar_height;
+
+ /* make sure we're visible */
+ correction = (x1 - cx0 - width);
+ if (correction > 0) {
+ cx0 += correction;
+ }
+ correction = (y1 - cy0 - height);
+ if (correction > 0) {
+ cy0 += correction;
+ }
+ if (x0 < cx0) {
+ cx0 = x0;
+ }
+ if (y0 < cy0) {
+ cy0 = y0;
+ }
+
+ /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
+ padding_available = (width - x1 + x0) / 2;
+ if (padding_available > 0) {
+ if (padding_available > SCROLL_VISIBLE_PADDING) {
+ padding_available = SCROLL_VISIBLE_PADDING;
+ }
+ correction = (cx0 + width - x1);
+ if (correction < padding_available) {
+ cx0 += padding_available;
+ }
+ correction = (x0 - cx0);
+ if (correction < padding_available) {
+ cx0 -= padding_available;
+ }
+ }
+ padding_available = (height - y1 + y0) / 2;
+ if (padding_available > 0) {
+ if (padding_available > SCROLL_VISIBLE_PADDING) {
+ padding_available = SCROLL_VISIBLE_PADDING;
+ }
+ correction = (cy0 + height - y1);
+ if (correction < padding_available) {
+ cy0 += padding_available;
+ }
+ correction = (y0 - cy0);
+ if (correction < padding_available) {
+ cy0 -= padding_available;
+ }
+ }
+
+ state.xscroll = cx0;
+ state.yscroll = -cy0 + toolbar_height;
+ }
ro_gui_window_open(PTR_WIMP_OPEN(&state));
+
+ return NSERROR_OK;
}
/**
* Find the current dimensions of a browser window's content area.
*
- * \param g gui_window to measure
- * \param width receives width of window
+ * \param gw gui window to measure
+ * \param width receives width of window
* \param height receives height of window
* \param scaled whether to return scaled values
*/
@@ -4988,7 +4982,6 @@ static struct gui_window_table window_table = {
.remove_caret = gui_window_remove_caret,
.save_link = gui_window_save_link,
.drag_start = gui_window_drag_start,
- .scroll_visible = gui_window_scroll_visible,
.scroll_start = gui_window_scroll_start,
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2de6386da2eee0438d4...
commit 2de6386da2eee0438d481d33c28591a303959506
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update monkey frontend for set_scroll API change
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index 8d5154e..93360aa 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -112,7 +112,7 @@ gui_window_set_title(struct gui_window *g, const char *title)
/**
* Find the current dimensions of a monkey browser window content area.
*
- * \param gw The gui window to measure content area of.
+ * \param g The gui window to measure content area of.
* \param width receives width of window
* \param height receives height of window
* \param scaled whether to return scaled values
@@ -154,14 +154,29 @@ gui_window_stop_throbber(struct gui_window *g)
fprintf(stdout, "WINDOW STOP_THROBBER WIN %u\n", g->win_num);
}
-static void
-gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+
+/**
+ * Set the scroll position of a monkey browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
- g->scrollx = sx;
- g->scrolly = sy;
- fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy);
+ gw->scrollx = rect->x0;
+ gw->scrolly = rect->y0;
+
+ fprintf(stdout, "WINDOW SET_SCROLL WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
+ gw->win_num, rect->x0, rect->y0, rect->x1, rect->y1);
+ return NSERROR_OK;
}
+
/**
* Invalidates an area of a monkey browser window
*
@@ -298,13 +313,6 @@ gui_window_scroll_start(struct gui_window *g)
return true;
}
-static void
-gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- fprintf(stdout, "WINDOW SCROLL_VISIBLE WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
- g->win_num, x0, y0, x1, y1);
-}
static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
@@ -527,7 +535,6 @@ static struct gui_window_table window_table = {
.remove_caret = gui_window_remove_caret,
.drag_start = gui_window_drag_start,
.save_link = gui_window_save_link,
- .scroll_visible = gui_window_scroll_visible,
.scroll_start = gui_window_scroll_start,
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=0f039b44212d312fa69...
commit 0f039b44212d312fa6920ec60e59df1313182913
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update GTK frontend for set_scroll API change
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index ecd6d0a..78a6f62 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1041,11 +1041,25 @@ static void gui_window_set_status(struct gui_window *g, const char *text)
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a gtk browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The GTK implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout);
- gdouble vlower, vpage, vupper, hlower, hpage, hupper, x = (double)sx, y = (double)sy;
+ gdouble vlower, vpage, vupper, hlower, hpage, hupper;
+ gdouble x = (gdouble)rect->x0;
+ gdouble y = (gdouble)rect->y0;
assert(vadj);
assert(hadj);
@@ -1053,17 +1067,23 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
g_object_get(vadj, "page-size", &vpage, "lower", &vlower, "upper", &vupper, NULL);
g_object_get(hadj, "page-size", &hpage, "lower", &hlower, "upper", &hupper, NULL);
- if (x < hlower)
+ if (x < hlower) {
x = hlower;
- if (x > (hupper - hpage))
+ }
+ if (x > (hupper - hpage)) {
x = hupper - hpage;
- if (y < vlower)
+ }
+ if (y < vlower) {
y = vlower;
- if (y > (vupper - vpage))
+ }
+ if (y > (vupper - vpage)) {
y = vupper - vpage;
+ }
gtk_adjustment_set_value(vadj, y);
gtk_adjustment_set_value(hadj, x);
+
+ return NSERROR_OK;
}
static void gui_window_update_extent(struct gui_window *g)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a696720cd605439be54...
commit a696720cd605439be5473de209531c5113f47a97
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update framebuffer frontend for set_scroll API change
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 0221a8e..062cb56 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -1807,7 +1807,7 @@ gui_window_destroy(struct gui_window *gw)
/**
* Invalidates an area of a framebuffer browser window
*
- * \param gw The netsurf window being invalidated.
+ * \param g The netsurf window being invalidated.
* \param rect area to redraw or NULL for the entire window area
* \return NSERROR_OK on success or appropriate error code
*/
@@ -1844,16 +1844,29 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-static void
-gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
+/**
+ * Set the scroll position of a framebuffer browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The framebuffer implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
float scale = browser_window_get_scale(gw->bw);
assert(bwidget);
- widget_scroll_x(gw, sx * scale, true);
- widget_scroll_y(gw, sy * scale, true);
+ widget_scroll_x(gw, rect->x0 * scale, true);
+ widget_scroll_y(gw, rect->y0 * scale, true);
+
+ return NSERROR_OK;
}
@@ -1867,16 +1880,16 @@ gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
* \return NSERROR_OK on sucess and width and height updated.
*/
static nserror
-gui_window_get_dimensions(struct gui_window *g,
+gui_window_get_dimensions(struct gui_window *gw,
int *width,
int *height,
bool scaled)
{
- *width = fbtk_get_width(g->browser);
- *height = fbtk_get_height(g->browser);
+ *width = fbtk_get_width(gw->browser);
+ *height = fbtk_get_height(gw->browser);
if (scaled) {
- float scale = browser_window_get_scale(g->bw);
+ float scale = browser_window_get_scale(gw->bw);
*width /= scale;
*height /= scale;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=db9b829df2a7c1676da...
commit db9b829df2a7c1676da131f5fe66f106af2ba14a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update beos frontend for set_scroll API change
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index f3d63da..2121d94 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -981,7 +981,7 @@ void nsbeos_redraw_caret(struct gui_window *g)
/**
* Invalidate an area of a beos browser window
*
- * \param gw The netsurf window being invalidated.
+ * \param g The netsurf window being invalidated.
* \param rect area to redraw or NULL for entrire window area.
* \return NSERROR_OK or appropriate error code.
*/
@@ -1034,7 +1034,19 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a beos browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The beos implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param g gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
//CALLED();
if (g->view == NULL)
@@ -1044,11 +1056,13 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
#warning XXX: report to view frame ?
if (g->view->ScrollBar(B_HORIZONTAL))
- g->view->ScrollBar(B_HORIZONTAL)->SetValue(sx);
+ g->view->ScrollBar(B_HORIZONTAL)->SetValue(rect->x0);
if (g->view->ScrollBar(B_VERTICAL))
- g->view->ScrollBar(B_VERTICAL)->SetValue(sy);
+ g->view->ScrollBar(B_VERTICAL)->SetValue(rect->y0);
g->view->UnlockLooper();
+
+ return NSERROR_OK;
}
@@ -1315,7 +1329,7 @@ struct gui_clipboard_table *beos_clipboard_table = &clipboard_table;
/**
* Find the current dimensions of a beos browser window content area.
*
- * \param gw The gui window to measure content area of.
+ * \param g The gui window to measure content area of.
* \param width receives width of window
* \param height receives height of window
* \param scaled whether to return scaled values
@@ -1361,7 +1375,6 @@ static struct gui_window_table window_table = {
gui_window_stop_throbber,
NULL, //drag_start
NULL, //save_link
- NULL, //scroll_visible
NULL, //scroll_start
gui_window_new_content,
NULL, //create_form_select_menu
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=db549331f7523fbbfe0...
commit db549331f7523fbbfe0460b8adb540838f582cec
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Update atari frontend for set_scroll API change
diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index cdea953..4876d31 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -424,17 +424,30 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
return( true );
}
-static void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
+/**
+ * Set the scroll position of a atari browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The atari implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
- if ( (w == NULL)
- || (w->browser->bw == NULL)
- || (!browser_window_has_content(w->browser->bw)))
- return;
+ if ((gw == NULL) ||
+ (gw->browser->bw == NULL) ||
+ (!browser_window_has_content(gw->browser->bw))) {
+ return NSERROR_BAD_PARAMETER;
+ }
- LOG("scroll (gui_window: %p) %d, %d\n", w, sx, sy);
- window_scroll_by(w->root, sx, sy);
- return;
+ LOG("scroll (gui_window: %p) %d, %d\n", gw, rect->x0, rect->y0);
+ window_scroll_by(gw->root, rect->x0, rect->y0);
+ return NSERROR_OK;
}
/**
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cbc60a906ae74869f13...
commit cbc60a906ae74869f133bfdacbadccddd3239ba1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
update amiga frontend to new set_scroll API
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index bf3102a..18816c4 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4970,13 +4970,28 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r
return true;
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a amiga browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The amiga implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
struct IBox *bbox;
int width, height;
+ nserror res;
- if(!g) return;
- if(!g->bw || browser_window_has_content(g->bw) == false) return;
+ if(!g) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if(!g->bw ||
+ browser_window_has_content(g->bw) == false) return;
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=87066f9f8dbad2416c5...
commit 87066f9f8dbad2416c53f70497aeb7c940ccb239
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
simplify the browser window operations by removing scroll API
The browser window scrollingAPI was duplicated in window operation
table, this simplifies it to a single set_scroll API.
diff --git a/desktop/browser.c b/desktop/browser.c
index 73a86c2..4b6a5bb 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -586,36 +586,33 @@ static void browser_window_set_selection(struct browser_window *bw,
top->selection.read_only = read_only;
}
-/* exported interface, documented in browser.h */
-void browser_window_scroll_visible(struct browser_window *bw,
- const struct rect *rect)
-{
- assert(bw != NULL);
+/**
+ * Set the scroll position of a browser window.
+ *
+ * scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+browser_window_set_scroll(struct browser_window *bw,
+ const struct rect *rect)
+{
if (bw->window != NULL) {
- /* Front end window */
- guit->window->scroll_visible(bw->window,
- rect->x0, rect->y0, rect->x1, rect->y1);
- } else {
- /* Core managed browser window */
- if (bw->scroll_x != NULL)
- scrollbar_set(bw->scroll_x, rect->x0, false);
- if (bw->scroll_y != NULL)
- scrollbar_set(bw->scroll_y, rect->y0, false);
+ return guit->window->set_scroll(bw->window, rect);
}
-}
-/* exported interface, documented in browser.h */
-void browser_window_set_scroll(struct browser_window *bw, int x, int y)
-{
- if (bw->window != NULL) {
- guit->window->set_scroll(bw->window, x, y);
- } else {
- if (bw->scroll_x != NULL)
- scrollbar_set(bw->scroll_x, x, false);
- if (bw->scroll_y != NULL)
- scrollbar_set(bw->scroll_y, y, false);
+ if (bw->scroll_x != NULL) {
+ scrollbar_set(bw->scroll_x, rect->x0, false);
}
+ if (bw->scroll_y != NULL) {
+ scrollbar_set(bw->scroll_y, rect->y0, false);
+ }
+
+ return NSERROR_OK;
}
/**
@@ -1610,25 +1607,28 @@ browser_window_callback(hlcache_handle *c,
break;
case CONTENT_MSG_SCROLL:
+ {
+ struct rect rect = {
+ .x0 = event->data.scroll.x0,
+ .y0 = event->data.scroll.y0,
+ };
+
/* Content wants to be scrolled */
- if (bw->current_content != c)
+ if (bw->current_content != c) {
break;
+ }
if (event->data.scroll.area) {
- struct rect rect = {
- .x0 = event->data.scroll.x0,
- .y0 = event->data.scroll.y0,
- .x1 = event->data.scroll.x1,
- .y1 = event->data.scroll.y1
- };
- browser_window_scroll_visible(bw, &rect);
+ rect.x1 = event->data.scroll.x1;
+ rect.y1 = event->data.scroll.y1;
} else {
- browser_window_set_scroll(bw,
- event->data.scroll.x0,
- event->data.scroll.y0);
+ rect.x1 = event->data.scroll.x0;
+ rect.y1 = event->data.scroll.y0;
}
+ browser_window_set_scroll(bw, &rect);
break;
+ }
case CONTENT_MSG_DRAGSAVE:
{
@@ -2324,13 +2324,48 @@ void browser_window_set_dimensions(struct browser_window *bw,
}
+/**
+ * scroll to a fragment if present
+ *
+ * \param bw browser window
+ * \return true if the scroll was sucessful
+ */
+static bool frag_scroll(struct browser_window *bw)
+{
+ struct rect rect;
+
+ if (bw->frag_id == NULL) {
+ return false;
+ }
+
+ if (!html_get_id_offset(bw->current_content,
+ bw->frag_id,
+ &rect.x0,
+ &rect.y0)) {
+ return false;
+ }
+
+ rect.x1 = rect.x0;
+ rect.y1 = rect.y0;
+ if (browser_window_set_scroll(bw, &rect) == NSERROR_OK) {
+ return true;
+ }
+ return false;
+}
+
/* Exported interface, documented in browser.h */
void browser_window_update(struct browser_window *bw, bool scroll_to_top)
{
- int x, y;
+ static const struct rect zrect = {
+ .x0 = 0,
+ .y0 = 0,
+ .x1 = 0,
+ .y1 = 0
+ };
- if (bw->current_content == NULL)
+ if (bw->current_content == NULL) {
return;
+ }
switch (bw->browser_window_type) {
@@ -2343,13 +2378,9 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id &&
- html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
- browser_window_set_scroll(bw, x, y);
- } else {
+ if (!frag_scroll(bw)) {
if (scroll_to_top) {
- browser_window_set_scroll(bw, 0, 0);
+ browser_window_set_scroll(bw, &zrect);
}
}
@@ -2364,15 +2395,13 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
browser_window_update_extent(bw);
- if (scroll_to_top)
- browser_window_set_scroll(bw, 0, 0);
+ if (scroll_to_top) {
+ browser_window_set_scroll(bw, &zrect);
+ }
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id && html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
- browser_window_set_scroll(bw, x, y);
- }
+ frag_scroll(bw);
html_redraw_a_box(bw->parent->current_content, bw->box);
break;
@@ -2382,15 +2411,13 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
struct rect rect;
browser_window_update_extent(bw);
- if (scroll_to_top)
- browser_window_set_scroll(bw, 0, 0);
+ if (scroll_to_top) {
+ browser_window_set_scroll(bw, &zrect);
+ }
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id && html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
- browser_window_set_scroll(bw, x, y);
- }
+ frag_scroll(bw);
rect.x0 = scrollbar_get_offset(bw->scroll_x);
rect.y0 = scrollbar_get_offset(bw->scroll_y);
@@ -3078,17 +3105,19 @@ void browser_window_mouse_track(struct browser_window *bw,
browser_window_resize_frame(bw, bw->x + x, bw->y + y);
} else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
/* mouse movement since drag started */
- int scrollx = bw->drag.start_x - x;
- int scrolly = bw->drag.start_y - y;
+ struct rect rect;
+
+ rect.x0 = bw->drag.start_x - x;
+ rect.y0 = bw->drag.start_y - y;
/* new scroll offsets */
- scrollx += bw->drag.start_scroll_x;
- scrolly += bw->drag.start_scroll_y;
+ rect.x0 += bw->drag.start_scroll_x;
+ rect.y0 += bw->drag.start_scroll_y;
- bw->drag.start_scroll_x = scrollx;
- bw->drag.start_scroll_y = scrolly;
+ bw->drag.start_scroll_x = rect.x1 = rect.x0;
+ bw->drag.start_scroll_y = rect.y1 = rect.y0;
- browser_window_set_scroll(bw, scrollx, scrolly);
+ browser_window_set_scroll(bw, &rect);
} else {
assert(c != NULL);
content_mouse_track(c, bw, mouse, x, y);
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 559823d..ca9eff1 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -82,12 +82,6 @@ static void gui_default_window_set_icon(struct gui_window *g,
{
}
-static void gui_default_window_scroll_visible(struct gui_window *g,
- int x0, int y0,
- int x1, int y1)
-{
- guit->window->set_scroll(g, x0, y0);
-}
static void gui_default_window_new_content(struct gui_window *g)
{
@@ -212,9 +206,6 @@ static nserror verify_window_register(struct gui_window_table *gwt)
if (gwt->save_link == NULL) {
gwt->save_link = gui_default_window_save_link;
}
- if (gwt->scroll_visible == NULL) {
- gwt->scroll_visible = gui_default_window_scroll_visible;
- }
if (gwt->new_content == NULL) {
gwt->new_content = gui_default_window_new_content;
}
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index c56cf55..567e314 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -572,26 +572,6 @@ void browser_window_get_position(struct browser_window *bw, bool root,
*/
void browser_window_set_position(struct browser_window *bw, int x, int y);
-/**
- * Scroll the browser window to display the passed area
- *
- * \param bw browser window to scroll
- * \param rect area to display
- */
-void browser_window_scroll_visible(struct browser_window *bw,
- const struct rect *rect);
-
-/**
- * Set scroll offsets for a browser window.
- *
- * \param bw The browser window
- * \param x The x scroll offset to set
- * \param y The y scroll offset to set
- *
- * \todo Do we really need this and browser_window_scroll_visible?
- * Ditto for gui_window_* variants.
- */
-void browser_window_set_scroll(struct browser_window *bw, int x, int y);
/**
* Set drag type for a browser window, and inform front end
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index b9a6863..81fc067 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -136,11 +136,20 @@ struct gui_window_table {
/**
* Set the scroll position of a browser window.
*
- * \param g gui_window to scroll
- * \param sx point to place at top-left of window
- * \param sy point to place at top-left of window
+ * scrolls the viewport to ensure the specified rectangle of
+ * the content is shown.
+ * If the rectangle is of zero size i.e. x0 == x1 and y0 == y1
+ * the contents will be scrolled so the specified point in the
+ * content is at the top of the viewport.
+ * If the size of the rectangle is non zero the frontend may
+ * add padding or center the defined area or it may simply
+ * align as in the zero size rectangle
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
*/
- void (*set_scroll)(struct gui_window *g, int sx, int sy);
+ nserror (*set_scroll)(struct gui_window *gw, const struct rect *rect);
/**
@@ -267,20 +276,6 @@ struct gui_window_table {
*/
nserror (*save_link)(struct gui_window *g, struct nsurl *url, const char *title);
- /**
- * Scrolls the specified area of a browser window into view.
- *
- * @todo investigate if this can be merged with set_scroll
- * which is what the default implementation used by most
- * toolkits uses.
- *
- * \param g gui_window to scroll
- * \param x0 left point to ensure visible
- * \param y0 bottom point to ensure visible
- * \param x1 right point to ensure visible
- * \param y1 top point to ensure visible
- */
- void (*scroll_visible)(struct gui_window *g, int x0, int y0, int x1, int y1);
/**
* Starts drag scrolling of a browser window
-----------------------------------------------------------------------
Summary of changes:
desktop/browser.c | 155 +++++++++++++++++++--------------
desktop/gui_factory.c | 9 --
frontends/amiga/gui.c | 21 ++++-
frontends/atari/gui.c | 29 ++++--
frontends/beos/window.cpp | 25 ++++--
frontends/framebuffer/gui.c | 31 +++++--
frontends/gtk/window.c | 32 +++++--
frontends/monkey/browser.c | 35 +++++---
frontends/riscos/window.c | 179 ++++++++++++++++++--------------------
frontends/windows/drawable.c | 13 +--
frontends/windows/window.c | 88 +++++++++----------
frontends/windows/window.h | 15 ++--
include/netsurf/browser_window.h | 20 -----
include/netsurf/window.h | 31 +++----
14 files changed, 380 insertions(+), 303 deletions(-)
diff --git a/desktop/browser.c b/desktop/browser.c
index 73a86c2..4b6a5bb 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -586,36 +586,33 @@ static void browser_window_set_selection(struct browser_window *bw,
top->selection.read_only = read_only;
}
-/* exported interface, documented in browser.h */
-void browser_window_scroll_visible(struct browser_window *bw,
- const struct rect *rect)
-{
- assert(bw != NULL);
+/**
+ * Set the scroll position of a browser window.
+ *
+ * scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+browser_window_set_scroll(struct browser_window *bw,
+ const struct rect *rect)
+{
if (bw->window != NULL) {
- /* Front end window */
- guit->window->scroll_visible(bw->window,
- rect->x0, rect->y0, rect->x1, rect->y1);
- } else {
- /* Core managed browser window */
- if (bw->scroll_x != NULL)
- scrollbar_set(bw->scroll_x, rect->x0, false);
- if (bw->scroll_y != NULL)
- scrollbar_set(bw->scroll_y, rect->y0, false);
+ return guit->window->set_scroll(bw->window, rect);
}
-}
-/* exported interface, documented in browser.h */
-void browser_window_set_scroll(struct browser_window *bw, int x, int y)
-{
- if (bw->window != NULL) {
- guit->window->set_scroll(bw->window, x, y);
- } else {
- if (bw->scroll_x != NULL)
- scrollbar_set(bw->scroll_x, x, false);
- if (bw->scroll_y != NULL)
- scrollbar_set(bw->scroll_y, y, false);
+ if (bw->scroll_x != NULL) {
+ scrollbar_set(bw->scroll_x, rect->x0, false);
}
+ if (bw->scroll_y != NULL) {
+ scrollbar_set(bw->scroll_y, rect->y0, false);
+ }
+
+ return NSERROR_OK;
}
/**
@@ -1610,25 +1607,28 @@ browser_window_callback(hlcache_handle *c,
break;
case CONTENT_MSG_SCROLL:
+ {
+ struct rect rect = {
+ .x0 = event->data.scroll.x0,
+ .y0 = event->data.scroll.y0,
+ };
+
/* Content wants to be scrolled */
- if (bw->current_content != c)
+ if (bw->current_content != c) {
break;
+ }
if (event->data.scroll.area) {
- struct rect rect = {
- .x0 = event->data.scroll.x0,
- .y0 = event->data.scroll.y0,
- .x1 = event->data.scroll.x1,
- .y1 = event->data.scroll.y1
- };
- browser_window_scroll_visible(bw, &rect);
+ rect.x1 = event->data.scroll.x1;
+ rect.y1 = event->data.scroll.y1;
} else {
- browser_window_set_scroll(bw,
- event->data.scroll.x0,
- event->data.scroll.y0);
+ rect.x1 = event->data.scroll.x0;
+ rect.y1 = event->data.scroll.y0;
}
+ browser_window_set_scroll(bw, &rect);
break;
+ }
case CONTENT_MSG_DRAGSAVE:
{
@@ -2324,13 +2324,48 @@ void browser_window_set_dimensions(struct browser_window *bw,
}
+/**
+ * scroll to a fragment if present
+ *
+ * \param bw browser window
+ * \return true if the scroll was sucessful
+ */
+static bool frag_scroll(struct browser_window *bw)
+{
+ struct rect rect;
+
+ if (bw->frag_id == NULL) {
+ return false;
+ }
+
+ if (!html_get_id_offset(bw->current_content,
+ bw->frag_id,
+ &rect.x0,
+ &rect.y0)) {
+ return false;
+ }
+
+ rect.x1 = rect.x0;
+ rect.y1 = rect.y0;
+ if (browser_window_set_scroll(bw, &rect) == NSERROR_OK) {
+ return true;
+ }
+ return false;
+}
+
/* Exported interface, documented in browser.h */
void browser_window_update(struct browser_window *bw, bool scroll_to_top)
{
- int x, y;
+ static const struct rect zrect = {
+ .x0 = 0,
+ .y0 = 0,
+ .x1 = 0,
+ .y1 = 0
+ };
- if (bw->current_content == NULL)
+ if (bw->current_content == NULL) {
return;
+ }
switch (bw->browser_window_type) {
@@ -2343,13 +2378,9 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id &&
- html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
- browser_window_set_scroll(bw, x, y);
- } else {
+ if (!frag_scroll(bw)) {
if (scroll_to_top) {
- browser_window_set_scroll(bw, 0, 0);
+ browser_window_set_scroll(bw, &zrect);
}
}
@@ -2364,15 +2395,13 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
browser_window_update_extent(bw);
- if (scroll_to_top)
- browser_window_set_scroll(bw, 0, 0);
+ if (scroll_to_top) {
+ browser_window_set_scroll(bw, &zrect);
+ }
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id && html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
- browser_window_set_scroll(bw, x, y);
- }
+ frag_scroll(bw);
html_redraw_a_box(bw->parent->current_content, bw->box);
break;
@@ -2382,15 +2411,13 @@ void browser_window_update(struct browser_window *bw, bool scroll_to_top)
struct rect rect;
browser_window_update_extent(bw);
- if (scroll_to_top)
- browser_window_set_scroll(bw, 0, 0);
+ if (scroll_to_top) {
+ browser_window_set_scroll(bw, &zrect);
+ }
/* if frag_id exists, then try to scroll to it */
/** @todo don't do this if the user has scrolled */
- if (bw->frag_id && html_get_id_offset(bw->current_content,
- bw->frag_id, &x, &y)) {
- browser_window_set_scroll(bw, x, y);
- }
+ frag_scroll(bw);
rect.x0 = scrollbar_get_offset(bw->scroll_x);
rect.y0 = scrollbar_get_offset(bw->scroll_y);
@@ -3078,17 +3105,19 @@ void browser_window_mouse_track(struct browser_window *bw,
browser_window_resize_frame(bw, bw->x + x, bw->y + y);
} else if (bw->drag.type == DRAGGING_PAGE_SCROLL) {
/* mouse movement since drag started */
- int scrollx = bw->drag.start_x - x;
- int scrolly = bw->drag.start_y - y;
+ struct rect rect;
+
+ rect.x0 = bw->drag.start_x - x;
+ rect.y0 = bw->drag.start_y - y;
/* new scroll offsets */
- scrollx += bw->drag.start_scroll_x;
- scrolly += bw->drag.start_scroll_y;
+ rect.x0 += bw->drag.start_scroll_x;
+ rect.y0 += bw->drag.start_scroll_y;
- bw->drag.start_scroll_x = scrollx;
- bw->drag.start_scroll_y = scrolly;
+ bw->drag.start_scroll_x = rect.x1 = rect.x0;
+ bw->drag.start_scroll_y = rect.y1 = rect.y0;
- browser_window_set_scroll(bw, scrollx, scrolly);
+ browser_window_set_scroll(bw, &rect);
} else {
assert(c != NULL);
content_mouse_track(c, bw, mouse, x, y);
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index 559823d..ca9eff1 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -82,12 +82,6 @@ static void gui_default_window_set_icon(struct gui_window *g,
{
}
-static void gui_default_window_scroll_visible(struct gui_window *g,
- int x0, int y0,
- int x1, int y1)
-{
- guit->window->set_scroll(g, x0, y0);
-}
static void gui_default_window_new_content(struct gui_window *g)
{
@@ -212,9 +206,6 @@ static nserror verify_window_register(struct gui_window_table *gwt)
if (gwt->save_link == NULL) {
gwt->save_link = gui_default_window_save_link;
}
- if (gwt->scroll_visible == NULL) {
- gwt->scroll_visible = gui_default_window_scroll_visible;
- }
if (gwt->new_content == NULL) {
gwt->new_content = gui_default_window_new_content;
}
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index bf3102a..18816c4 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -4970,13 +4970,28 @@ static bool gui_window_get_scroll(struct gui_window *g, int *restrict sx, int *r
return true;
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a amiga browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The amiga implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
struct IBox *bbox;
int width, height;
+ nserror res;
- if(!g) return;
- if(!g->bw || browser_window_has_content(g->bw) == false) return;
+ if(!g) {
+ return NSERROR_BAD_PARAMETER;
+ }
+ if(!g->bw ||
+ browser_window_has_content(g->bw) == false) return;
if(ami_gui_get_space_box((Object *)g->shared->objects[GID_BROWSER], &bbox) != NSERROR_OK) {
amiga_warn_user("NoMemory", "");
diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c
index cdea953..4876d31 100644
--- a/frontends/atari/gui.c
+++ b/frontends/atari/gui.c
@@ -424,17 +424,30 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
return( true );
}
-static void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
+/**
+ * Set the scroll position of a atari browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The atari implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
- if ( (w == NULL)
- || (w->browser->bw == NULL)
- || (!browser_window_has_content(w->browser->bw)))
- return;
+ if ((gw == NULL) ||
+ (gw->browser->bw == NULL) ||
+ (!browser_window_has_content(gw->browser->bw))) {
+ return NSERROR_BAD_PARAMETER;
+ }
- LOG("scroll (gui_window: %p) %d, %d\n", w, sx, sy);
- window_scroll_by(w->root, sx, sy);
- return;
+ LOG("scroll (gui_window: %p) %d, %d\n", gw, rect->x0, rect->y0);
+ window_scroll_by(gw->root, rect->x0, rect->y0);
+ return NSERROR_OK;
}
/**
diff --git a/frontends/beos/window.cpp b/frontends/beos/window.cpp
index f3d63da..2121d94 100644
--- a/frontends/beos/window.cpp
+++ b/frontends/beos/window.cpp
@@ -981,7 +981,7 @@ void nsbeos_redraw_caret(struct gui_window *g)
/**
* Invalidate an area of a beos browser window
*
- * \param gw The netsurf window being invalidated.
+ * \param g The netsurf window being invalidated.
* \param rect area to redraw or NULL for entrire window area.
* \return NSERROR_OK or appropriate error code.
*/
@@ -1034,7 +1034,19 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a beos browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The beos implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param g gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
//CALLED();
if (g->view == NULL)
@@ -1044,11 +1056,13 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
#warning XXX: report to view frame ?
if (g->view->ScrollBar(B_HORIZONTAL))
- g->view->ScrollBar(B_HORIZONTAL)->SetValue(sx);
+ g->view->ScrollBar(B_HORIZONTAL)->SetValue(rect->x0);
if (g->view->ScrollBar(B_VERTICAL))
- g->view->ScrollBar(B_VERTICAL)->SetValue(sy);
+ g->view->ScrollBar(B_VERTICAL)->SetValue(rect->y0);
g->view->UnlockLooper();
+
+ return NSERROR_OK;
}
@@ -1315,7 +1329,7 @@ struct gui_clipboard_table *beos_clipboard_table = &clipboard_table;
/**
* Find the current dimensions of a beos browser window content area.
*
- * \param gw The gui window to measure content area of.
+ * \param g The gui window to measure content area of.
* \param width receives width of window
* \param height receives height of window
* \param scaled whether to return scaled values
@@ -1361,7 +1375,6 @@ static struct gui_window_table window_table = {
gui_window_stop_throbber,
NULL, //drag_start
NULL, //save_link
- NULL, //scroll_visible
NULL, //scroll_start
gui_window_new_content,
NULL, //create_form_select_menu
diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c
index 0221a8e..062cb56 100644
--- a/frontends/framebuffer/gui.c
+++ b/frontends/framebuffer/gui.c
@@ -1807,7 +1807,7 @@ gui_window_destroy(struct gui_window *gw)
/**
* Invalidates an area of a framebuffer browser window
*
- * \param gw The netsurf window being invalidated.
+ * \param g The netsurf window being invalidated.
* \param rect area to redraw or NULL for the entire window area
* \return NSERROR_OK on success or appropriate error code
*/
@@ -1844,16 +1844,29 @@ gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
-static void
-gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
+/**
+ * Set the scroll position of a framebuffer browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The framebuffer implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
struct browser_widget_s *bwidget = fbtk_get_userpw(gw->browser);
float scale = browser_window_get_scale(gw->bw);
assert(bwidget);
- widget_scroll_x(gw, sx * scale, true);
- widget_scroll_y(gw, sy * scale, true);
+ widget_scroll_x(gw, rect->x0 * scale, true);
+ widget_scroll_y(gw, rect->y0 * scale, true);
+
+ return NSERROR_OK;
}
@@ -1867,16 +1880,16 @@ gui_window_set_scroll(struct gui_window *gw, int sx, int sy)
* \return NSERROR_OK on sucess and width and height updated.
*/
static nserror
-gui_window_get_dimensions(struct gui_window *g,
+gui_window_get_dimensions(struct gui_window *gw,
int *width,
int *height,
bool scaled)
{
- *width = fbtk_get_width(g->browser);
- *height = fbtk_get_height(g->browser);
+ *width = fbtk_get_width(gw->browser);
+ *height = fbtk_get_height(gw->browser);
if (scaled) {
- float scale = browser_window_get_scale(g->bw);
+ float scale = browser_window_get_scale(gw->bw);
*width /= scale;
*height /= scale;
}
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index ecd6d0a..78a6f62 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1041,11 +1041,25 @@ static void gui_window_set_status(struct gui_window *g, const char *text)
}
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+/**
+ * Set the scroll position of a gtk browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The GTK implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
GtkAdjustment *hadj = nsgtk_layout_get_hadjustment(g->layout);
- gdouble vlower, vpage, vupper, hlower, hpage, hupper, x = (double)sx, y = (double)sy;
+ gdouble vlower, vpage, vupper, hlower, hpage, hupper;
+ gdouble x = (gdouble)rect->x0;
+ gdouble y = (gdouble)rect->y0;
assert(vadj);
assert(hadj);
@@ -1053,17 +1067,23 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
g_object_get(vadj, "page-size", &vpage, "lower", &vlower, "upper", &vupper, NULL);
g_object_get(hadj, "page-size", &hpage, "lower", &hlower, "upper", &hupper, NULL);
- if (x < hlower)
+ if (x < hlower) {
x = hlower;
- if (x > (hupper - hpage))
+ }
+ if (x > (hupper - hpage)) {
x = hupper - hpage;
- if (y < vlower)
+ }
+ if (y < vlower) {
y = vlower;
- if (y > (vupper - vpage))
+ }
+ if (y > (vupper - vpage)) {
y = vupper - vpage;
+ }
gtk_adjustment_set_value(vadj, y);
gtk_adjustment_set_value(hadj, x);
+
+ return NSERROR_OK;
}
static void gui_window_update_extent(struct gui_window *g)
diff --git a/frontends/monkey/browser.c b/frontends/monkey/browser.c
index 8d5154e..93360aa 100644
--- a/frontends/monkey/browser.c
+++ b/frontends/monkey/browser.c
@@ -112,7 +112,7 @@ gui_window_set_title(struct gui_window *g, const char *title)
/**
* Find the current dimensions of a monkey browser window content area.
*
- * \param gw The gui window to measure content area of.
+ * \param g The gui window to measure content area of.
* \param width receives width of window
* \param height receives height of window
* \param scaled whether to return scaled values
@@ -154,14 +154,29 @@ gui_window_stop_throbber(struct gui_window *g)
fprintf(stdout, "WINDOW STOP_THROBBER WIN %u\n", g->win_num);
}
-static void
-gui_window_set_scroll(struct gui_window *g, int sx, int sy)
+
+/**
+ * Set the scroll position of a monkey browser window.
+ *
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
+ *
+ * \param gw gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
+ */
+static nserror
+gui_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
- g->scrollx = sx;
- g->scrolly = sy;
- fprintf(stdout, "WINDOW SET_SCROLL WIN %u X %d Y %d\n", g->win_num, sx, sy);
+ gw->scrollx = rect->x0;
+ gw->scrolly = rect->y0;
+
+ fprintf(stdout, "WINDOW SET_SCROLL WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
+ gw->win_num, rect->x0, rect->y0, rect->x1, rect->y1);
+ return NSERROR_OK;
}
+
/**
* Invalidates an area of a monkey browser window
*
@@ -298,13 +313,6 @@ gui_window_scroll_start(struct gui_window *g)
return true;
}
-static void
-gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
- int x1, int y1)
-{
- fprintf(stdout, "WINDOW SCROLL_VISIBLE WIN %u X0 %d Y0 %d X1 %d Y1 %d\n",
- g->win_num, x0, y0, x1, y1);
-}
static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
@@ -527,7 +535,6 @@ static struct gui_window_table window_table = {
.remove_caret = gui_window_remove_caret,
.drag_start = gui_window_drag_start,
.save_link = gui_window_save_link,
- .scroll_visible = gui_window_scroll_visible,
.scroll_start = gui_window_scroll_start,
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c
index 1d5c093..3496d4b 100644
--- a/frontends/riscos/window.c
+++ b/frontends/riscos/window.c
@@ -806,124 +806,118 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
/**
- * Set the scroll position of a browser window.
+ * Set the scroll position of a riscos browser window.
*
- * \param g gui_window to scroll
- * \param sx point to place at top-left of window
- * \param sy point to place at top-left of window
- */
-
-static void gui_window_set_scroll(struct gui_window *g, int sx, int sy)
-{
- wimp_window_state state;
- os_error *error;
-
- assert(g);
-
- state.w = g->window;
- error = xwimp_get_window_state(&state);
- if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
- ro_warn_user("WimpError", error->errmess);
- return;
- }
-
- state.xscroll = sx * 2 * g->scale;
- state.yscroll = -sy * 2 * g->scale;
- if (g->toolbar)
- state.yscroll += ro_toolbar_full_height(g->toolbar);
- ro_gui_window_open(PTR_WIMP_OPEN(&state));
-}
-
-
-/**
- * Scrolls the specified area of a browser window into view.
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown.
*
- * \param g gui_window to scroll
- * \param x0 left point to ensure visible
- * \param y0 bottom point to ensure visible
- * \param x1 right point to ensure visible
- * \param y1 top point to ensure visible
+ * \param g gui window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
*/
-static void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1)
+static nserror
+gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
{
wimp_window_state state;
os_error *error;
- int cx0, cy0, width, height;
- int padding_available;
int toolbar_height = 0;
- int correction;
assert(g);
state.w = g->window;
error = xwimp_get_window_state(&state);
if (error) {
- LOG("xwimp_get_window_state: 0x%x: %s", error->errnum, error->errmess);
+ LOG("xwimp_get_window_state: 0x%x: %s",
+ error->errnum, error->errmess);
ro_warn_user("WimpError", error->errmess);
- return;
+ return NSERROR_BAD_PARAMETER;
}
- if (g->toolbar)
+ if (g->toolbar) {
toolbar_height = ro_toolbar_full_height(g->toolbar);
-
- x0 = x0 * 2 * g->scale;
- y0 = y0 * 2 * g->scale;
- x1 = x1 * 2 * g->scale;
- y1 = y1 * 2 * g->scale;
-
- cx0 = state.xscroll;
- cy0 = -state.yscroll + toolbar_height;
- width = state.visible.x1 - state.visible.x0;
- height = state.visible.y1 - state.visible.y0 - toolbar_height;
-
- /* make sure we're visible */
- correction = (x1 - cx0 - width);
- if (correction > 0)
- cx0 += correction;
- correction = (y1 - cy0 - height);
- if (correction > 0)
- cy0 += correction;
- if (x0 < cx0)
- cx0 = x0;
- if (y0 < cy0)
- cy0 = y0;
-
- /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
- padding_available = (width - x1 + x0) / 2;
- if (padding_available > 0) {
- if (padding_available > SCROLL_VISIBLE_PADDING)
- padding_available = SCROLL_VISIBLE_PADDING;
- correction = (cx0 + width - x1);
- if (correction < padding_available)
- cx0 += padding_available;
- correction = (x0 - cx0);
- if (correction < padding_available)
- cx0 -= padding_available;
- }
- padding_available = (height - y1 + y0) / 2;
- if (padding_available > 0) {
- if (padding_available > SCROLL_VISIBLE_PADDING)
- padding_available = SCROLL_VISIBLE_PADDING;
- correction = (cy0 + height - y1);
- if (correction < padding_available)
- cy0 += padding_available;
- correction = (y0 - cy0);
- if (correction < padding_available)
- cy0 -= padding_available;
}
- state.xscroll = cx0;
- state.yscroll = -cy0 + toolbar_height;
+ if ((rect->x0 == rect->x1) && (rect->y0 == rect->y1)) {
+ /* scroll to top */
+ state.xscroll = rect->x0 * 2 * g->scale;
+ state.yscroll = (-rect->y0 * 2 * g->scale) + toolbar_height;
+ } else {
+ /* scroll area into view with padding */
+ int x0, y0, x1, y1;
+ int cx0, cy0, width, height;
+ int padding_available;
+ int correction;
+
+ x0 = rect->x0 * 2 * g->scale;
+ y0 = rect->y0 * 2 * g->scale;
+ x1 = rect->x1 * 2 * g->scale;
+ y1 = rect->y1 * 2 * g->scale;
+
+ cx0 = state.xscroll;
+ cy0 = -state.yscroll + toolbar_height;
+ width = state.visible.x1 - state.visible.x0;
+ height = state.visible.y1 - state.visible.y0 - toolbar_height;
+
+ /* make sure we're visible */
+ correction = (x1 - cx0 - width);
+ if (correction > 0) {
+ cx0 += correction;
+ }
+ correction = (y1 - cy0 - height);
+ if (correction > 0) {
+ cy0 += correction;
+ }
+ if (x0 < cx0) {
+ cx0 = x0;
+ }
+ if (y0 < cy0) {
+ cy0 = y0;
+ }
+
+ /* try to give a SCROLL_VISIBLE_PADDING border of space around us */
+ padding_available = (width - x1 + x0) / 2;
+ if (padding_available > 0) {
+ if (padding_available > SCROLL_VISIBLE_PADDING) {
+ padding_available = SCROLL_VISIBLE_PADDING;
+ }
+ correction = (cx0 + width - x1);
+ if (correction < padding_available) {
+ cx0 += padding_available;
+ }
+ correction = (x0 - cx0);
+ if (correction < padding_available) {
+ cx0 -= padding_available;
+ }
+ }
+ padding_available = (height - y1 + y0) / 2;
+ if (padding_available > 0) {
+ if (padding_available > SCROLL_VISIBLE_PADDING) {
+ padding_available = SCROLL_VISIBLE_PADDING;
+ }
+ correction = (cy0 + height - y1);
+ if (correction < padding_available) {
+ cy0 += padding_available;
+ }
+ correction = (y0 - cy0);
+ if (correction < padding_available) {
+ cy0 -= padding_available;
+ }
+ }
+
+ state.xscroll = cx0;
+ state.yscroll = -cy0 + toolbar_height;
+ }
ro_gui_window_open(PTR_WIMP_OPEN(&state));
+
+ return NSERROR_OK;
}
/**
* Find the current dimensions of a browser window's content area.
*
- * \param g gui_window to measure
- * \param width receives width of window
+ * \param gw gui window to measure
+ * \param width receives width of window
* \param height receives height of window
* \param scaled whether to return scaled values
*/
@@ -4988,7 +4982,6 @@ static struct gui_window_table window_table = {
.remove_caret = gui_window_remove_caret,
.save_link = gui_window_save_link,
.drag_start = gui_window_drag_start,
- .scroll_visible = gui_window_scroll_visible,
.scroll_start = gui_window_scroll_start,
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
diff --git a/frontends/windows/drawable.c b/frontends/windows/drawable.c
index 0bd1bae..4540b12 100644
--- a/frontends/windows/drawable.c
+++ b/frontends/windows/drawable.c
@@ -137,8 +137,10 @@ nsws_drawable_vscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
GetScrollInfo(hwnd, SB_VERT, &si);
if (si.nPos != mem) {
- win32_window_set_scroll(gw, gw->scrollx, gw->scrolly +
- gw->requestscrolly + si.nPos - mem);
+ struct rect rect;
+ rect.x0 = rect.x1 = gw->scrollx;
+ rect.y0 = rect.y1 = gw->scrolly + gw->requestscrolly + si.nPos - mem;
+ win32_window_set_scroll(gw, &rect);
}
return 0;
@@ -201,9 +203,10 @@ nsws_drawable_hscroll(struct gui_window *gw, HWND hwnd, WPARAM wparam)
SetScrollInfo(hwnd, SB_HORZ, &si, TRUE);
GetScrollInfo(hwnd, SB_HORZ, &si);
if (si.nPos != mem) {
- win32_window_set_scroll(gw,
- gw->scrollx + gw->requestscrollx + si.nPos - mem,
- gw->scrolly);
+ struct rect rect;
+ rect.x0 = rect.x1 = gw->scrollx + gw->requestscrollx + si.nPos - mem;
+ rect.y0 = rect.y1 = gw->scrolly;
+ win32_window_set_scroll(gw, &rect);
}
return 0;
diff --git a/frontends/windows/window.c b/frontends/windows/window.c
index 829067b..6ba61c5 100644
--- a/frontends/windows/window.c
+++ b/frontends/windows/window.c
@@ -923,7 +923,7 @@ win32_window_invalidate_area(struct gui_window *gw, const struct rect *rect)
*/
static void nsws_set_scale(struct gui_window *gw, float scale)
{
- int x, y;
+ struct rect rect;
assert(gw != NULL);
@@ -931,8 +931,8 @@ static void nsws_set_scale(struct gui_window *gw, float scale)
return;
}
- x = gw->scrollx;
- y = gw->scrolly;
+ rect.x0 = rect.x1 = gw->scrollx;
+ rect.y0 = rect.y1 = gw->scrolly;
gw->scale = scale;
@@ -941,7 +941,7 @@ static void nsws_set_scale(struct gui_window *gw, float scale)
}
win32_window_invalidate_area(gw, NULL);
- win32_window_set_scroll(gw, x, y);
+ win32_window_set_scroll(gw, &rect);
}
@@ -1338,7 +1338,7 @@ nsws_window_resize(struct gui_window *gw,
WPARAM wparam,
LPARAM lparam)
{
- int x, y;
+ struct rect rect;
RECT rstatus, rtool;
if ((gw->toolbar == NULL) ||
@@ -1351,7 +1351,7 @@ nsws_window_resize(struct gui_window *gw,
GetClientRect(gw->toolbar, &rtool);
GetWindowRect(gw->statusbar, &rstatus);
- win32_window_get_scroll(gw, &x, &y);
+ win32_window_get_scroll(gw, &rect.x0, &rect.y0);
gw->width = LOWORD(lparam);
gw->height = HIWORD(lparam) - (rtool.bottom - rtool.top) - (rstatus.bottom - rstatus.top);
@@ -1365,7 +1365,7 @@ nsws_window_resize(struct gui_window *gw,
}
nsws_window_update_forward_back(gw);
- win32_window_set_scroll(gw, x, y);
+ win32_window_set_scroll(gw, &rect);
if (gw->toolbar != NULL) {
SendMessage(gw->toolbar, TB_SETSTATE,
@@ -1830,40 +1830,39 @@ bool nsws_window_go(HWND hwnd, const char *urltxt)
/* exported interface documented in windows/window.h */
-void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
+nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect)
{
SCROLLINFO si;
- nserror err;
+ nserror res;
int height;
int width;
POINT p;
- if ((w == NULL) || (w->bw == NULL))
- return;
-
- err = browser_window_get_extents(w->bw, true, &width, &height);
- if (err != NSERROR_OK) {
- return;
+ if ((gw == NULL) || (gw->bw == NULL)) {
+ return NSERROR_BAD_PARAMETER;
}
- /*LOG("scroll sx,sy:%d,%d x,y:%d,%d w.h:%d,%d",sx,sy,w->scrollx,w->scrolly, width,height);*/
+ res = browser_window_get_extents(gw->bw, true, &width, &height);
+ if (res != NSERROR_OK) {
+ return res;
+ }
/* The resulting gui window scroll must remain within the
* windows bounding box.
*/
- if (sx < 0) {
- w->requestscrollx = -w->scrollx;
- } else if (sx > (width - w->width)) {
- w->requestscrollx = (width - w->width) - w->scrollx;
+ if (rect->x0 < 0) {
+ gw->requestscrollx = -gw->scrollx;
+ } else if (rect->x0 > (width - gw->width)) {
+ gw->requestscrollx = (width - gw->width) - gw->scrollx;
} else {
- w->requestscrollx = sx - w->scrollx;
+ gw->requestscrollx = rect->x0 - gw->scrollx;
}
- if (sy < 0) {
- w->requestscrolly = -w->scrolly;
- } else if (sy > (height - w->height)) {
- w->requestscrolly = (height - w->height) - w->scrolly;
+ if (rect->y0 < 0) {
+ gw->requestscrolly = -gw->scrolly;
+ } else if (rect->y0 > (height - gw->height)) {
+ gw->requestscrolly = (height - gw->height) - gw->scrolly;
} else {
- w->requestscrolly = sy - w->scrolly;
+ gw->requestscrolly = rect->y0 - gw->scrolly;
}
/*LOG("requestscroll x,y:%d,%d", w->requestscrollx, w->requestscrolly);*/
@@ -1873,10 +1872,10 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = height - 1;
- si.nPage = w->height;
- si.nPos = max(w->scrolly + w->requestscrolly, 0);
- si.nPos = min(si.nPos, height - w->height);
- SetScrollInfo(w->drawingarea, SB_VERT, &si, TRUE);
+ si.nPage = gw->height;
+ si.nPos = max(gw->scrolly + gw->requestscrolly, 0);
+ si.nPos = min(si.nPos, height - gw->height);
+ SetScrollInfo(gw->drawingarea, SB_VERT, &si, TRUE);
/*LOG("SetScrollInfo VERT min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos);*/
/* set the horizontal scroll offset */
@@ -1884,30 +1883,31 @@ void win32_window_set_scroll(struct gui_window *w, int sx, int sy)
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = width -1;
- si.nPage = w->width;
- si.nPos = max(w->scrollx + w->requestscrollx, 0);
- si.nPos = min(si.nPos, width - w->width);
- SetScrollInfo(w->drawingarea, SB_HORZ, &si, TRUE);
+ si.nPage = gw->width;
+ si.nPos = max(gw->scrollx + gw->requestscrollx, 0);
+ si.nPos = min(si.nPos, width - gw->width);
+ SetScrollInfo(gw->drawingarea, SB_HORZ, &si, TRUE);
/*LOG("SetScrollInfo HORZ min:%d max:%d page:%d pos:%d", si.nMin, si.nMax, si.nPage, si.nPos);*/
/* Set caret position */
GetCaretPos(&p);
- HideCaret(w->drawingarea);
- SetCaretPos(p.x - w->requestscrollx, p.y - w->requestscrolly);
- ShowCaret(w->drawingarea);
+ HideCaret(gw->drawingarea);
+ SetCaretPos(p.x - gw->requestscrollx, p.y - gw->requestscrolly);
+ ShowCaret(gw->drawingarea);
RECT r, redraw;
r.top = 0;
- r.bottom = w->height + 1;
+ r.bottom = gw->height + 1;
r.left = 0;
- r.right = w->width + 1;
- ScrollWindowEx(w->drawingarea, - w->requestscrollx, - w->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE);
+ r.right = gw->width + 1;
+ ScrollWindowEx(gw->drawingarea, - gw->requestscrollx, - gw->requestscrolly, &r, NULL, NULL, &redraw, SW_INVALIDATE);
/*LOG("ScrollWindowEx %d, %d", - w->requestscrollx, - w->requestscrolly);*/
- w->scrolly += w->requestscrolly;
- w->scrollx += w->requestscrollx;
- w->requestscrollx = 0;
- w->requestscrolly = 0;
+ gw->scrolly += gw->requestscrolly;
+ gw->scrollx += gw->requestscrollx;
+ gw->requestscrollx = 0;
+ gw->requestscrolly = 0;
+ return NSERROR_OK;
}
diff --git a/frontends/windows/window.h b/frontends/windows/window.h
index d927c28..3cdb9ae 100644
--- a/frontends/windows/window.h
+++ b/frontends/windows/window.h
@@ -73,6 +73,7 @@ struct gui_window {
struct gui_window *next, *prev; /**< global linked list */
};
+struct rect;
/**
* Obtain gui window structure from window handle.
@@ -91,13 +92,17 @@ struct gui_window *nsws_get_gui_window(HWND hwnd);
bool nsws_window_go(HWND hwnd, const char *urltxt);
/**
- * scroll the window
+ * Set the scroll position of a win32 browser window.
*
- * \param w The win32 gui window to scroll.
- * \param sx the new 'absolute' horizontal scroll location
- * \param sy the new 'absolute' vertical scroll location
+ * Scrolls the viewport to ensure the specified rectangle of the
+ * content is shown. The win32 implementation scrolls the contents so
+ * the specified point in the content is at the top of the viewport.
+ *
+ * \param gw The win32 gui window to scroll.
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
*/
-void win32_window_set_scroll(struct gui_window *w, int sx, int sy);
+nserror win32_window_set_scroll(struct gui_window *gw, const struct rect *rect);
/**
* Create the main browser window class.
diff --git a/include/netsurf/browser_window.h b/include/netsurf/browser_window.h
index c56cf55..567e314 100644
--- a/include/netsurf/browser_window.h
+++ b/include/netsurf/browser_window.h
@@ -572,26 +572,6 @@ void browser_window_get_position(struct browser_window *bw, bool root,
*/
void browser_window_set_position(struct browser_window *bw, int x, int y);
-/**
- * Scroll the browser window to display the passed area
- *
- * \param bw browser window to scroll
- * \param rect area to display
- */
-void browser_window_scroll_visible(struct browser_window *bw,
- const struct rect *rect);
-
-/**
- * Set scroll offsets for a browser window.
- *
- * \param bw The browser window
- * \param x The x scroll offset to set
- * \param y The y scroll offset to set
- *
- * \todo Do we really need this and browser_window_scroll_visible?
- * Ditto for gui_window_* variants.
- */
-void browser_window_set_scroll(struct browser_window *bw, int x, int y);
/**
* Set drag type for a browser window, and inform front end
diff --git a/include/netsurf/window.h b/include/netsurf/window.h
index b9a6863..81fc067 100644
--- a/include/netsurf/window.h
+++ b/include/netsurf/window.h
@@ -136,11 +136,20 @@ struct gui_window_table {
/**
* Set the scroll position of a browser window.
*
- * \param g gui_window to scroll
- * \param sx point to place at top-left of window
- * \param sy point to place at top-left of window
+ * scrolls the viewport to ensure the specified rectangle of
+ * the content is shown.
+ * If the rectangle is of zero size i.e. x0 == x1 and y0 == y1
+ * the contents will be scrolled so the specified point in the
+ * content is at the top of the viewport.
+ * If the size of the rectangle is non zero the frontend may
+ * add padding or center the defined area or it may simply
+ * align as in the zero size rectangle
+ *
+ * \param gw gui_window to scroll
+ * \param rect The rectangle to ensure is shown.
+ * \return NSERROR_OK on success or apropriate error code.
*/
- void (*set_scroll)(struct gui_window *g, int sx, int sy);
+ nserror (*set_scroll)(struct gui_window *gw, const struct rect *rect);
/**
@@ -267,20 +276,6 @@ struct gui_window_table {
*/
nserror (*save_link)(struct gui_window *g, struct nsurl *url, const char *title);
- /**
- * Scrolls the specified area of a browser window into view.
- *
- * @todo investigate if this can be merged with set_scroll
- * which is what the default implementation used by most
- * toolkits uses.
- *
- * \param g gui_window to scroll
- * \param x0 left point to ensure visible
- * \param y0 bottom point to ensure visible
- * \param x1 right point to ensure visible
- * \param y1 top point to ensure visible
- */
- void (*scroll_visible)(struct gui_window *g, int x0, int y0, int x1, int y1);
/**
* Starts drag scrolling of a browser window
--
NetSurf Browser
6 years, 5 months
netsurf: branch master updated. release/3.6-409-g7bbf2a9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7bbf2a9ca0cd418f64b00...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7bbf2a9ca0cd418f64b001b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7bbf2a9ca0cd418f64b001b87...
The branch, master has been updated
via 7bbf2a9ca0cd418f64b001b87f77c779433119fe (commit)
from ebcc27c330654d4408bd3aec34795f849c07e02f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7bbf2a9ca0cd418f64b...
commit 7bbf2a9ca0cd418f64b001b87f77c779433119fe
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
HTML layout: Extend :after pseudo element handling to cover display:table.
This is used in a common clearfix variant.
http://nicolasgallagher.com/micro-clearfix-hack/
diff --git a/render/box_construct.c b/render/box_construct.c
index f2d0413..d0ffd9d 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -594,6 +594,7 @@ static void box_construct_generate(dom_node *n, html_content *content,
struct box *box, const css_computed_style *style)
{
struct box *gen = NULL;
+ enum css_display_e computed_display;
const css_computed_content_item *c_item;
/* Nothing to generate if the parent box is not a block */
@@ -611,8 +612,10 @@ static void box_construct_generate(dom_node *n, html_content *content,
}
/* create box for this element */
- if (css_computed_display(style, box_is_root(n)) == CSS_DISPLAY_BLOCK) {
- /* currently only support block level elements */
+ computed_display = css_computed_display(style, box_is_root(n));
+ if (computed_display == CSS_DISPLAY_BLOCK ||
+ computed_display == CSS_DISPLAY_TABLE) {
+ /* currently only support block level boxes */
/** \todo Not wise to drop const from the computed style */
gen = box_create(NULL, (css_computed_style *) style,
-----------------------------------------------------------------------
Summary of changes:
render/box_construct.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/render/box_construct.c b/render/box_construct.c
index f2d0413..d0ffd9d 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -594,6 +594,7 @@ static void box_construct_generate(dom_node *n, html_content *content,
struct box *box, const css_computed_style *style)
{
struct box *gen = NULL;
+ enum css_display_e computed_display;
const css_computed_content_item *c_item;
/* Nothing to generate if the parent box is not a block */
@@ -611,8 +612,10 @@ static void box_construct_generate(dom_node *n, html_content *content,
}
/* create box for this element */
- if (css_computed_display(style, box_is_root(n)) == CSS_DISPLAY_BLOCK) {
- /* currently only support block level elements */
+ computed_display = css_computed_display(style, box_is_root(n));
+ if (computed_display == CSS_DISPLAY_BLOCK ||
+ computed_display == CSS_DISPLAY_TABLE) {
+ /* currently only support block level boxes */
/** \todo Not wise to drop const from the computed style */
gen = box_create(NULL, (css_computed_style *) style,
--
NetSurf Browser
6 years, 5 months
netsurf: branch master updated. release/3.6-408-gebcc27c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ebcc27c330654d4408bd3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ebcc27c330654d4408bd3ae...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ebcc27c330654d4408bd3aec3...
The branch, master has been updated
via ebcc27c330654d4408bd3aec34795f849c07e02f (commit)
from 4b76d2096d4622fed8641b24f9dfe4ce782e307e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ebcc27c330654d4408b...
commit ebcc27c330654d4408bd3aec34795f849c07e02f
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Box tree dump: If box has element, include element name in dump.
diff --git a/render/box.c b/render/box.c
index 11a24e7..77cc15b 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1048,7 +1048,7 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
if (box->title)
fprintf(stream, " [%s]", box->title);
if (box->id)
- fprintf(stream, " <%s>", lwc_string_data(box->id));
+ fprintf(stream, " ID:%s", lwc_string_data(box->id));
if (box->type == BOX_INLINE || box->type == BOX_INLINE_END)
fprintf(stream, " inline_end %p", box->inline_end);
if (box->float_children)
@@ -1071,6 +1071,13 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
box->col[i].min, box->col[i].max);
fprintf(stream, ")");
}
+ if (box->node != NULL) {
+ dom_string *name;
+ if (dom_node_get_node_name(box->node, &name) == DOM_NO_ERR) {
+ fprintf(stream, " <%s>", dom_string_data(name));
+ dom_string_unref(name);
+ }
+ }
fprintf(stream, "\n");
if (box->list_marker) {
-----------------------------------------------------------------------
Summary of changes:
render/box.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/render/box.c b/render/box.c
index 11a24e7..77cc15b 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1048,7 +1048,7 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
if (box->title)
fprintf(stream, " [%s]", box->title);
if (box->id)
- fprintf(stream, " <%s>", lwc_string_data(box->id));
+ fprintf(stream, " ID:%s", lwc_string_data(box->id));
if (box->type == BOX_INLINE || box->type == BOX_INLINE_END)
fprintf(stream, " inline_end %p", box->inline_end);
if (box->float_children)
@@ -1071,6 +1071,13 @@ void box_dump(FILE *stream, struct box *box, unsigned int depth, bool style)
box->col[i].min, box->col[i].max);
fprintf(stream, ")");
}
+ if (box->node != NULL) {
+ dom_string *name;
+ if (dom_node_get_node_name(box->node, &name) == DOM_NO_ERR) {
+ fprintf(stream, " <%s>", dom_string_data(name));
+ dom_string_unref(name);
+ }
+ }
fprintf(stream, "\n");
if (box->list_marker) {
--
NetSurf Browser
6 years, 5 months