annotate src/styleengine.hh @ 1035:474b9814a8fa

support CSS @import directive
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Wed, 08 Apr 2009 16:33:02 +0200
parents 36d9fee90159
children 4ed33b76809c
rev   line source
497
96713a0f5d8b css.[ch][ch] -> styleengine.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 495
diff changeset
1 #ifndef __STYLEENGINE_HH__
96713a0f5d8b css.[ch][ch] -> styleengine.[ch][ch]
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 495
diff changeset
2 #define __STYLEENGINE_HH__
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
3
1035
474b9814a8fa support CSS @import directive
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 990
diff changeset
4 class StyleEngine;
474b9814a8fa support CSS @import directive
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 990
diff changeset
5
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
6 #include "dw/core.hh"
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 499
diff changeset
7 #include "doctree.hh"
506
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
8 #include "css.hh"
643
eb0279297fde hook up <style>...</style> parsing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 631
diff changeset
9 #include "cssparser.hh"
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
10
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
11 class StyleEngine : public Doctree {
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
12 private:
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
13 class Node : public DoctreeNode {
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
14 public:
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
15 dw::core::style::Style *style;
644
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
16 dw::core::style::Style *wordStyle;
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
17 const char *styleAttribute;
615
d0694361ecd0 add workaround for table row coloring
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 598
diff changeset
18 bool inheritBackgroundColor;
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
19 };
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
20
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
21 dw::core::Layout *layout;
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
22 lout::misc::SimpleVector <Node> *stack;
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
23 CssContext *cssContext;
763
df8153796f48 initial implementation of a CSS selector matching optimization
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 713
diff changeset
24 int num;
1035
474b9814a8fa support CSS @import directive
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 990
diff changeset
25 int importDepth;
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
26
590
eb1072890045 setNonCssProperties() -> setNonCssHints()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 589
diff changeset
27 dw::core::style::Style *style0 (CssPropertyList *nonCssHints = NULL);
644
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
28 dw::core::style::Style *wordStyle0 (CssPropertyList *nonCssHints = NULL);
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
29 void apply (dw::core::style::StyleAttrs *attrs, CssPropertyList *props);
693
478dfc078e12 make StyleEngine::computeValue() and computeLength() return bool
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 679
diff changeset
30 bool computeValue (int *dest, CssLength value, dw::core::style::Font *font);
478dfc078e12 make StyleEngine::computeValue() and computeLength() return bool
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 679
diff changeset
31 bool computeValue (int *dest, CssLength value, dw::core::style::Font *font,
990
36d9fee90159 whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 982
diff changeset
32 int percentageBase);
36d9fee90159 whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 982
diff changeset
33 bool computeLength (dw::core::style::Length *dest, CssLength value,
36d9fee90159 whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 982
diff changeset
34 dw::core::style::Font *font);
506
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
35
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
36 public:
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
37 StyleEngine (dw::core::Layout *layout);
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
38 ~StyleEngine ();
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 901
diff changeset
39
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
40 /* Doctree interface */
506
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
41 inline const DoctreeNode *top () {
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
42 return stack->getRef (stack->size () - 1);
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
43 };
506
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
44
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
45 inline const DoctreeNode *parent (const DoctreeNode *n) {
631
4c9f7f03caf0 fix DocTree implementation in StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 615
diff changeset
46 if (n->depth > 1)
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
47 return stack->getRef (n->depth - 1);
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
48 else
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
49 return NULL;
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
50 };
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
51
1035
474b9814a8fa support CSS @import directive
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 990
diff changeset
52 void parse (DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin);
598
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
53 void startElement (int tag);
982
d04d960da3f4 remove bg_color dillorc option
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 956
diff changeset
54 void startElement (const char *tagname);
598
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
55 void setId (const char *id);
901
f44e88b06200 fix check for name/id mismatch (noticed by corvid)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 895
diff changeset
56 const char * getId () { return top ()->id; };
598
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
57 void setClass (const char *klass);
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
58 void setStyle (const char *style);
495
7224de9c34b7 add StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 493
diff changeset
59 void endElement (int tag);
679
14ce954d98c0 inherit pseudo classes "link" and "visited"
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 664
diff changeset
60 void setPseudoLink ();
14ce954d98c0 inherit pseudo classes "link" and "visited"
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 664
diff changeset
61 void setPseudoVisited ();
590
eb1072890045 setNonCssProperties() -> setNonCssHints()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 589
diff changeset
62 void setNonCssHints (CssPropertyList *nonCssHints);
664
109eaf60aea2 add comment about inheritBackgroundColor()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 659
diff changeset
63 void inheritBackgroundColor (); /* \todo get rid of this somehow */
956
dd46fa6ceb94 fix missing background color for ComplexButton (noticed by corvid)
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 930
diff changeset
64 dw::core::style::Style *backgroundStyle ();
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
65
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
66 inline dw::core::style::Style *style () {
506
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
67 dw::core::style::Style *s = stack->getRef (stack->size () - 1)->style;
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
68 if (s)
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
69 return s;
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
70 else
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
71 return style0 ();
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
72 };
990
36d9fee90159 whitespace
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 982
diff changeset
73
644
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
74 inline dw::core::style::Style *wordStyle () {
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
75 dw::core::style::Style *s = stack->getRef (stack->size () - 1)->wordStyle;
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
76 if (s)
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
77 return s;
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
78 else
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
79 return wordStyle0 ();
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
80 };
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
81 };
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
82
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
83 #endif