-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define CssLength as struct instead of int
The int type doesn't have a fixed size, and is only guarantee to hold 16 bits. The current implementation assumes a size of at least 32 bits, an uses three bits to encode the type of information stored in the rest. To add more types of lengths we would need to take more bits from the value itself. A simpler approach is just to use a enumeration to take care of the type of length and a union to encapsulate the different lengths values.
- Loading branch information
Showing
6 changed files
with
95 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* | ||
* Copyright 2004 Sebastian Geerken <[email protected]> | ||
* Copyright 2008-2009 Johannes Hofmann <[email protected]> | ||
* Copyright 2024 Rodrigo Arias Mallo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -988,7 +989,7 @@ bool CssParser::parseValue(CssPropertyName prop, | |
(type == CSS_TYPE_LENGTH_PERCENTAGE_NUMBER || fval == 0.0)) | ||
ret = true; | ||
|
||
val->intVal = CSS_CREATE_LENGTH(fval, lentype); | ||
val->lenVal = CSS_CREATE_LENGTH(fval, lentype); | ||
} | ||
break; | ||
|
||
|
@@ -1091,7 +1092,7 @@ bool CssParser::parseValue(CssPropertyName prop, | |
// possibilities are tested in parallel. | ||
|
||
bool h[2], v[2]; | ||
int pos[2]; | ||
CssLength pos[2]; | ||
h[0] = v[0] = h[1] = v[1] = false; | ||
|
||
// First: collect values in pos[0] and pos[1], and determine whether | ||
|
@@ -1134,10 +1135,10 @@ bool CssParser::parseValue(CssPropertyName prop, | |
// We can assume <length> or <percentage> here ... | ||
CssPropertyValue valTmp; | ||
if (parseValue(prop, CSS_TYPE_LENGTH_PERCENTAGE, &valTmp)) { | ||
pos[i] = valTmp.intVal; | ||
pos[i] = valTmp.lenVal; | ||
ret = true; | ||
} else if (parseValue(prop, CSS_TYPE_SIGNED_LENGTH, &valTmp)) { | ||
pos[i] = valTmp.intVal; | ||
pos[i] = valTmp.lenVal; | ||
ret = true; | ||
} else | ||
// ... but something may still fail. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
/* | ||
* File: html_common.hh | ||
* | ||
* Copyright (C) 2008-2016 Jorge Arellano Cid <[email protected]> | ||
* Copyright (C) 2008-2014 Johannes Hofmann <[email protected]> | ||
* Copyright (C) 2024 Rodrigo Arias Mallo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
*/ | ||
|
||
#ifndef __HTML_COMMON_HH__ | ||
#define __HTML_COMMON_HH__ | ||
|
||
|
@@ -268,7 +281,7 @@ void a_Html_pop_tag(DilloHtml *html, int TagIdx); | |
void a_Html_stash_init(DilloHtml *html); | ||
int32_t a_Html_color_parse(DilloHtml *html, const char *str, | ||
int32_t default_color); | ||
dw::core::style::Length a_Html_parse_length (DilloHtml *html, | ||
CssLength a_Html_parse_length (DilloHtml *html, | ||
const char *attr); | ||
void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize); | ||
bool a_Html_tag_set_valign_attr(DilloHtml *html, | ||
|
Oops, something went wrong.