13#include "../dlib/dlib.h"
33class StyleImageDeletionReceiver:
39 StyleImageDeletionReceiver (
int clientKey);
40 ~StyleImageDeletionReceiver ();
45StyleImageDeletionReceiver::StyleImageDeletionReceiver (
int clientKey)
47 this->clientKey = clientKey;
50StyleImageDeletionReceiver::~StyleImageDeletionReceiver ()
69 stack =
new lout::misc::SimpleVector <Node> (1);
107 assert (
stack->size () == 0);
118 static const Node emptyNode = {
119 NULL, NULL, NULL, NULL, NULL, NULL,
false,
false, NULL
122 stack->setSize (
stack->size () + 1, emptyNode);
152 if (
stack->size () > 1)
162 assert (dn->
id == NULL);
170 const char *p1 = NULL;
175 if (*str !=
'\0' && *str != sep) {
193 assert (dn->
klass == NULL);
225 if (origNonCssProperties)
228 delete origNonCssProperties;
250 for (
int i = 1; i <
stack->size (); i++) {
265 for (
int i = 1; i <
stack->size (); i++) {
308 if (
stack->getRef (
stack->size () - 2)->inheritBackgroundColor) {
310 stack->getRef (
stack->size () - 2)->style->backgroundColor;
312 stack->getRef (
stack->size () - 2)->style->backgroundImage;
314 stack->getRef (
stack->size () - 2)->style->backgroundRepeat;
316 stack->getRef (
stack->size () - 2)->style->backgroundAttachment;
318 stack->getRef (
stack->size () - 2)->style->backgroundPositionX;
320 stack->getRef (
stack->size () - 2)->style->backgroundPositionY;
373 for (
int j = 0; j < props->
size (); j++) {
401 fontAttrs.
name = fontName;
404 memmove(p->
value.
strVal, c + 1, strlen(c + 1) + 1);
485 if (fontAttrs.
weight < 100)
487 if (fontAttrs.
weight > 900)
498 parentFont, parentFont->
size);
519 for (
int j = 0; j < props->
size (); j++) {
610 stack->getRef (i)->displayNone =
true;
760 !
stack->getRef (i)->displayNone &&
782 (
new StyleImageDeletionReceiver (clientKey));
811 if (
stack->size() < 2) {
848 int percentageBase) {
901 if (!
stack->getRef (
stack->size () - 1)->backgroundStyle) {
908 stack->getRef (
stack->size () - 1)->backgroundStyle =
911 return stack->getRef (
stack->size () - 1)->backgroundStyle;
920 CssPropertyList props, *styleAttrProperties, *styleAttrPropertiesImportant;
931 assert (
stack->getRef (i)->style == NULL);
937 styleAttrProperties =
stack->
getRef (i)->styleAttrProperties;
938 styleAttrPropertiesImportant =
stack->
getRef(i)->styleAttrPropertiesImportant;
939 nonCssProperties =
stack->
getRef (i)->nonCssProperties;
943 styleAttrProperties, styleAttrPropertiesImportant,
947 apply (i, &attrs, &props, bw);
953 return stack->getRef (i)->style;
960 if (
stack->getRef (
stack->size() - 1)->inheritBackgroundColor) {
972 return stack->getRef (
stack->size () - 1)->wordStyle;
983 for (
int i = 1; i <
stack->size (); i++) {
1005 MSG_WARN(
"Maximum depth of CSS @import reached--ignoring stylesheet.\n");
1021 const char *cssBuf =
1022 "body {margin: 5px}"
1023 "big {font-size: 1.17em}"
1024 "blockquote, dd {margin-left: 40px; margin-right: 40px}"
1025 "center {text-align: center}"
1026 "dt {font-weight: bolder}"
1027 ":link {color: blue; text-decoration: underline; cursor: pointer}"
1028 ":visited {color: #800080; text-decoration: underline; cursor: pointer}"
1029 "h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder}"
1030 "address, article, aside, center, div, figure, figcaption, footer,"
1031 " h1, h2, h3, h4, h5, h6, header, main, nav, ol, p, pre, section, ul"
1033 "i, em, cite, address, var {font-style: italic}"
1034 "frameset, ul, ol, dir {margin-left: 40px}"
1039 "p {margin: 0.5em 0}"
1040 "figure {margin: 1em 40px}"
1041 "h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0}"
1042 "h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0}"
1043 "h3 {font-size: 1.17em; margin-top: .83em; margin-bottom: 0}"
1044 "h4 {margin-top: 1.12em; margin-bottom: 0}"
1045 "h5 {font-size: 0.83em; margin-top: 1.5em; margin-bottom: 0}"
1046 "h6 {font-size: 0.75em; margin-top: 1.67em; margin-bottom: 0}"
1047 "hr {width: 100%; border: 1px inset}"
1048 "li {margin-top: 0.1em; display: list-item}"
1049 "pre {white-space: pre}"
1050 "ol {list-style-type: decimal}"
1051 "ul {list-style-type: disc}"
1052 "ul ul {list-style-type: circle}"
1053 "ul ul ul {list-style-type: square}"
1054 "ul ul ul ul {list-style-type: disc}"
1055 "ins, u {text-decoration: underline}"
1056 "small, sub, sup {font-size: 0.83em}"
1057 "sub {vertical-align: sub}"
1058 "sup {vertical-align: super}"
1059 "s, strike, del {text-decoration: line-through}"
1063 "mark {background: yellow; color: black;}"
1064 "table {border-spacing: 2px}"
1065 "td, th {padding: 2px}"
1066 "thead, tbody, tfoot {vertical-align: middle}"
1067 "th {font-weight: bolder; text-align: center}"
1068 "code, tt, pre, samp, kbd {font-family: monospace}"
1074 "table, caption {font-size: medium; font-weight: normal}";
void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
Add an URL to the browser window's list.
void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
Add a reference to a cache-client.
int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
Most used function for requesting a URL.
void a_Capi_stop_client(int Key, int force)
Remove a client from the cache client queue.
void apply(CssPropertyList *props, Doctree *docTree, DoctreeNode *node, CssPropertyList *tagStyle, CssPropertyList *tagStyleImportant, CssPropertyList *nonCssHints)
Apply a CSS context to a property list.
static void parseDeclarationBlock(const DilloUrl *baseUrl, const char *buf, int buflen, CssPropertyList *props, CssPropertyList *propsImortant)
static void parse(DilloHtml *html, const DilloUrl *baseUrl, CssContext *context, const char *buf, int buflen, CssOrigin origin)
A list of CssProperty objects.
void apply(CssPropertyList *props)
Merge properties into argument property list.
This class holds a CSS property and value pair.
lout::misc::SimpleVector< char * > * klass
HTML document tree interface.
void parse(DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin)
void setPseudoVisited()
set the CSS pseudo class :visited.
void restyle(BrowserWindow *bw)
Recompute all style information from scratch This is used to take into account CSS styles for the HTM...
void apply(int i, dw::core::style::StyleAttrs *attrs, CssPropertyList *props, BrowserWindow *bw)
Make changes to StyleAttrs attrs according to CssPropertyList props.
void startElement(int tag, BrowserWindow *bw)
tell the styleEngine that a new html element has started.
void setId(const char *id)
dw::core::style::Style * style(BrowserWindow *bw)
lout::misc::SimpleVector< Node > * stack
void preprocessAttrs(dw::core::style::StyleAttrs *attrs)
dw::core::style::Style * wordStyle0(BrowserWindow *bw)
dw::core::style::Style * style0(int i, BrowserWindow *bw)
Create a new style object based on the previously opened / closed HTML elements and the nonCssPropert...
dw::core::style::Color * backgroundColor()
void endElement(int tag)
tell the styleEngine that a html element has ended.
void setPseudoLink()
set the CSS pseudo class :link.
bool computeValue(int *dest, CssLength value, dw::core::style::Font *font)
Resolve relative lengths to absolute values.
void computeBorderWidth(int *dest, CssProperty *p, dw::core::style::Font *font)
void setStyle(const char *style)
void setClass(const char *klass)
bool computeLength(dw::core::style::Length *dest, CssLength value, dw::core::style::Font *font)
dw::core::Layout * layout
StyleEngine(dw::core::Layout *layout, const DilloUrl *pageUrl, const DilloUrl *baseUrl, float zoom)
dw::core::style::Style * backgroundStyle(BrowserWindow *bw)
Similar to StyleEngine::style(), but with backgroundColor set.
void inheritBackgroundColor()
Use of the background color of the parent style as default.
void postprocessAttrs(dw::core::style::StyleAttrs *attrs)
static void init()
Create the user agent style.
void inheritNonCssHints()
Instruct StyleEngine to use the nonCssHints from parent element This is only used for tables where no...
dw::core::style::StyleImage * backgroundImage(dw::core::style::BackgroundRepeat *bgRepeat, dw::core::style::BackgroundAttachment *bgAttachment, dw::core::style::Length *bgPositionX, dw::core::style::Length *bgPositionY)
The central class for managing and drawing a widget tree.
static Color * create(Layout *layout, int color)
static bool exists(Layout *layout, const char *name)
static Font * create(Layout *layout, FontAttrs *attrs)
ListStyleType listStyleType
ListStylePosition listStylePosition
TextTransform textTransform
StyleImage * backgroundImage
Length backgroundPositionY
BackgroundRepeat backgroundRepeat
struct dw::core::style::StyleAttrs::@20 borderColor
BackgroundAttachment backgroundAttachment
BorderCollapse borderCollapse
struct dw::core::style::StyleAttrs::@21 borderStyle
void resetValues()
Reset those style attributes to their standard values, which are not inherited, according to CSS.
Length backgroundPositionX
ImgRenderer * getMainImgRenderer()
static StyleImage * create()
static Style * create(StyleAttrs *attrs)
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
void increase()
Increase the vector size by one.
void set(int i, T t)
Store an object in the vector.
int size() const
Return the number of elements put into this vector.
T * getRef(int i) const
Return the reference of one element.
virtual void deleted(ObservedObject *object)=0
An observed object has a signal emitter, which tells the receivers, when the object is deleted.
void connectDeletion(DeletionReceiver *receiver)
@ CSS_WORD_SPACING_NORMAL
@ CSS_FONT_WEIGHT_LIGHTER
@ CSS_LETTER_SPACING_NORMAL
@ CSS_BORDER_WIDTH_MEDIUM
@ CSS_PROPERTY_PADDING_TOP
@ CSS_PROPERTY_LIST_STYLE_TYPE
@ CSS_PROPERTY_MARGIN_BOTTOM
@ CSS_PROPERTY_LETTER_SPACING
@ CSS_PROPERTY_BORDER_RIGHT_STYLE
@ CSS_PROPERTY_BORDER_BOTTOM_COLOR
@ CSS_PROPERTY_MARGIN_RIGHT
@ CSS_PROPERTY_BORDER_TOP_COLOR
@ CSS_PROPERTY_BORDER_LEFT_COLOR
@ CSS_PROPERTY_LIST_STYLE_POSITION
@ CSS_PROPERTY_BORDER_RIGHT_WIDTH
@ CSS_PROPERTY_BACKGROUND_REPEAT
@ CSS_PROPERTY_FONT_VARIANT
@ CSS_PROPERTY_BORDER_LEFT_WIDTH
@ CSS_PROPERTY_PADDING_BOTTOM
@ CSS_PROPERTY_BACKGROUND_ATTACHMENT
@ CSS_PROPERTY_MIN_HEIGHT
@ CSS_PROPERTY_MAX_HEIGHT
@ CSS_PROPERTY_MARGIN_LEFT
@ CSS_PROPERTY_BORDER_COLLAPSE
@ CSS_PROPERTY_BORDER_RIGHT_COLOR
@ CSS_PROPERTY_BORDER_TOP_WIDTH
@ CSS_PROPERTY_MARGIN_TOP
@ CSS_PROPERTY_PADDING_RIGHT
@ CSS_PROPERTY_TEXT_TRANSFORM
@ CSS_PROPERTY_PADDING_LEFT
@ CSS_PROPERTY_VERTICAL_ALIGN
@ CSS_PROPERTY_BORDER_SPACING
@ CSS_PROPERTY_BORDER_LEFT_STYLE
@ CSS_PROPERTY_TEXT_ALIGN
@ CSS_PROPERTY_BACKGROUND_IMAGE
@ CSS_PROPERTY_BORDER_TOP_STYLE
@ CSS_PROPERTY_FONT_STYLE
@ CSS_PROPERTY_TEXT_INDENT
@ CSS_PROPERTY_BACKGROUND_COLOR
@ CSS_PROPERTY_WHITE_SPACE
@ CSS_PROPERTY_LINE_HEIGHT
@ CSS_PROPERTY_WORD_SPACING
@ CSS_PROPERTY_BORDER_BOTTOM_STYLE
@ CSS_PROPERTY_TEXT_DECORATION
@ CSS_PROPERTY_BORDER_BOTTOM_WIDTH
@ CSS_PROPERTY_BACKGROUND_POSITION
@ CSS_PROPERTY_FONT_FAMILY
@ CSS_PROPERTY_FONT_WEIGHT
@ CSS_TYPE_ENUM
Value is i, if represented by enum_symbols[i].
@ CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
CssLengthType CSS_LENGTH_TYPE(CssLength l)
@ CSS_LENGTH_TYPE_MM
"cm", "in", "pt" and "pc" are converted into millimeters.
@ CSS_LENGTH_TYPE_PERCENTAGE
@ CSS_LENGTH_TYPE_AUTO
This can be used as a simple value.
float CSS_LENGTH_VALUE(CssLength l)
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
int dStrAsciiCasecmp(const char *s1, const char *s2)
char * dStrstrip(char *s)
Remove leading and trailing whitespace.
char * dStrdup(const char *s)
void dStr_free(Dstr *ds, int all)
Free a dillo string.
char * dStrndup(const char *s, size_t sz)
char * dGethomedir(void)
Return the home directory in a static string (don't free)
#define D_ASCII_TOLOWER(c)
int a_Html_tag_index(const char *tag)
Get 'tag' index.
Dstr * a_Misc_file2dstr(const char *filename)
Load a local file into a dStr.
Anything related to Dillo Widget styles is defined here.
Length createPerLength(double v)
Returns a percentage, v is relative to 1, not to 100.
int Length
Type for representing all lengths within dw::core::style.
Length createAbsLength(int n)
Returns a length of n pixels.
@ Z_INDEX_AUTO
'z-index' is stored as int; use this for the value 'auto'.
@ LENGTH_AUTO
Represents "auto" lengths.
Miscellaneous stuff, which does not fit anywhere else.
DilloPrefs prefs
Global Data.
void a_Image_ref(DilloImage *Image)
Add a reference to an Image struct Do nothing if the argument is NULL.
DilloImage * a_Image_new(void *layout, void *img_rndr, int32_t bg_color, int32_t fg_color)
Create and initialize a new image structure.
Contains the specific data for a single window.
bool_t parse_embedded_css
int32_t white_bg_replacement
bool_t load_background_images
dw::core::style::Style * wordStyle
DoctreeNode * doctreeNode
dw::core::style::Style * style
dw::core::style::Style * backgroundStyle
CssPropertyList * styleAttrProperties
CssPropertyList * styleAttrPropertiesImportant
CssPropertyList * nonCssProperties
int flags
Additional info.
DilloImage * Image
For image urls [reference].
static lout::misc::SimpleVector< char * > * splitStr(const char *str, char sep)
split a string at sep chars and return a SimpleVector of strings
CssBackgroundPosition * posVal
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
DilloUrl * a_Url_new(const char *url_str, const char *base_url)
Transform (and resolve) an URL string into the respective DilloURL.
DilloUrl * a_Url_dup(const DilloUrl *ori)
Duplicate a Url structure.
DilloWeb * a_Web_new(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *requester)
Allocate and set safe values for a DilloWeb structure.