Dillo v3.1.1-99-gf3103cc4
Loading...
Searching...
No Matches
styleengine.hh
Go to the documentation of this file.
1/*
2 * File: styleengine.hh
3 *
4 * Copyright 2008-2009 Johannes Hofmann <Johannes.Hofmann@gmx.de>
5 * Copyright 2024 Rodrigo Arias Mallo <rodarima@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef __STYLEENGINE_HH__
14#define __STYLEENGINE_HH__
15
16class StyleEngine;
17
18#include "dw/core.hh"
19#include "doctree.hh"
20#include "css.hh"
21#include "cssparser.hh"
22
33 private:
45
47 lout::misc::SimpleVector <Node> *stack;
51 float dpmm;
52 float zoom;
54
55 void stackPush ();
56 void stackPop ();
57 void buildUserStyle ();
61 CssPropertyValue value) {
62 Node *n = stack->getRef (stack->size () - 1);
63
64 if (!n->nonCssProperties)
65 n->nonCssProperties = new CssPropertyList (true);
66 n->nonCssProperties->set(name, type, value);
67 }
70 void apply (int i, dw::core::style::StyleAttrs *attrs,
71 CssPropertyList *props, BrowserWindow *bw);
72 bool computeValue (int *dest, CssLength value,
74 bool computeValue (int *dest, CssLength value,
75 dw::core::style::Font *font, int percentageBase);
78 void computeBorderWidth (int *dest, CssProperty *p,
80
81 public:
82 static void init ();
83
85 const DilloUrl *pageUrl, const DilloUrl *baseUrl, float zoom);
86 ~StyleEngine ();
87
88 void parse (DilloHtml *html, DilloUrl *url, const char *buf, int buflen,
89 CssOrigin origin);
90 void startElement (int tag, BrowserWindow *bw);
91 void startElement (const char *tagname, BrowserWindow *bw);
92 void setId (const char *id);
93 const char * getId () { return doctree->top ()->id; };
94 void setClass (const char *klass);
95 void setStyle (const char *style);
96 void endElement (int tag);
97 void setPseudoLink ();
98 void setPseudoVisited ();
100 int value) {
102 v.intVal = value;
103 setNonCssHint (name, type, v);
104 }
106 const char *value) {
108 v.strVal = dStrdup(value);
109 setNonCssHint (name, type, v);
110 }
112 CssLength value) {
114 v.lenVal = value;
115 setNonCssHint (name, type, v);
116 }
117 void inheritNonCssHints ();
118 void clearNonCssHints ();
119 void restyle (BrowserWindow *bw);
120 void inheritBackgroundColor (); /* \todo get rid of this somehow */
126 dw::core::style::Length *bgPositionX,
127 dw::core::style::Length *bgPositionY);
128
130 dw::core::style::Style *s = stack->getRef (stack->size () - 1)->style;
131 if (s)
132 return s;
133 else
134 return style0 (stack->size () - 1, bw);
135 };
136
138 dw::core::style::Style *s = stack->getRef(stack->size()-1)->wordStyle;
139 if (s)
140 return s;
141 else
142 return wordStyle0 (bw);
143 };
144};
145
146#endif
A set of CssStyleSheets.
Definition css.hh:518
A list of CssProperty objects.
Definition css.hh:331
void set(CssPropertyName name, CssValueType type, CssPropertyValue value)
Set property to a given name and type.
Definition css.cc:58
This class holds a CSS property and value pair.
Definition css.hh:305
const char * id
Definition doctree.hh:15
HTML document tree interface.
Definition doctree.hh:48
DoctreeNode * top()
Definition doctree.hh:80
This class provides the glue between HTML parser and CSS subsystem.
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 setNonCssHint(CssPropertyName name, CssValueType type, CssPropertyValue value)
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)
void setNonCssHint(CssPropertyName name, CssValueType type, int value)
lout::misc::SimpleVector< Node > * stack
void setNonCssHint(CssPropertyName name, CssValueType type, const char *value)
void buildUserStyle()
void preprocessAttrs(dw::core::style::StyleAttrs *attrs)
void stackPop()
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...
const char * getId()
dw::core::style::Color * backgroundColor()
DilloUrl * pageUrl
void endElement(int tag)
tell the styleEngine that a html element has ended.
void setPseudoLink()
set the CSS pseudo class :link.
void stackPush()
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::style::Style * wordStyle(BrowserWindow *bw)
DilloUrl * baseUrl
dw::core::Layout * layout
void setNonCssHint(CssPropertyName name, CssValueType type, CssLength value)
void clearNonCssHints()
dw::core::style::Style * backgroundStyle(BrowserWindow *bw)
Similar to StyleEngine::style(), but with backgroundColor set.
Doctree * doctree
CssContext * cssContext
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.
Definition layout.hh:17
CssPropertyName
Definition css.hh:163
CssValueType
Definition css.hh:36
CssOrigin
Definition css.hh:30
char * dStrdup(const char *s)
Definition dlib.c:77
int Length
Type for representing all lengths within dw::core::style.
Definition style.hh:429
Contains the specific data for a single window.
Definition bw.h:27
Definition url.h:88
dw::core::style::Style * wordStyle
DoctreeNode * doctreeNode
dw::core::style::Style * style
dw::core::style::Style * backgroundStyle
CssPropertyList * styleAttrProperties
CssPropertyList * styleAttrPropertiesImportant
CssPropertyList * nonCssProperties
char * strVal
Definition css.hh:263
int32_t intVal
Definition css.hh:261
CssLength lenVal
Definition css.hh:262