annotate src/styleengine.hh @ 658:ea961706be66

use CssLength type
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Tue, 09 Dec 2008 18:48:47 +0100
parents 9e4ad941cbdc
children 920e6090d6d6
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
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
4 #include "dw/core.hh"
501
424e4f409636 add doctree.hh
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 499
diff changeset
5 #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
6 #include "css.hh"
643
eb0279297fde hook up <style>...</style> parsing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 631
diff changeset
7 #include "cssparser.hh"
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
8
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
9 class StyleEngine : public Doctree {
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
10 private:
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
11 class Node : public DoctreeNode {
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
12 public:
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
13 dw::core::style::Style *style;
644
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
14 dw::core::style::Style *wordStyle;
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
15 const char *styleAttribute;
615
d0694361ecd0 add workaround for table row coloring
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 598
diff changeset
16 bool inheritBackgroundColor;
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
17 };
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
18
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
19 dw::core::Layout *layout;
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
20 lout::misc::SimpleVector <Node> *stack;
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
21 CssContext *cssContext;
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
22
590
eb1072890045 setNonCssProperties() -> setNonCssHints()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 589
diff changeset
23 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
24 dw::core::style::Style *wordStyle0 (CssPropertyList *nonCssHints = NULL);
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
25 void apply (dw::core::style::StyleAttrs *attrs, CssPropertyList *props);
575
13bbef5403a2 use CssLength in computeValue
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 573
diff changeset
26 int computeValue (CssLength value, dw::core::style::Font *font);
658
ea961706be66 use CssLength type
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 644
diff changeset
27 dw::core::style::Length computeLength (CssLength value, 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
28
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
29 public:
509
fd2454cd0120 pass Layout to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 506
diff changeset
30 StyleEngine (dw::core::Layout *layout);
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
31 ~StyleEngine ();
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
32
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
33 /* 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
34 inline const DoctreeNode *top () {
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
35 return stack->getRef (stack->size () - 1);
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
36 };
506
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
37
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
38 inline const DoctreeNode *parent (const DoctreeNode *n) {
631
4c9f7f03caf0 fix DocTree implementation in StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 615
diff changeset
39 if (n->depth > 1)
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
40 return stack->getRef (n->depth - 1);
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
41 else
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
42 return NULL;
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
43 };
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
44
643
eb0279297fde hook up <style>...</style> parsing
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 631
diff changeset
45 void parse (const char *buf, int buflen, int order_count, CssOrigin origin);
598
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
46 void startElement (int tag);
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
47 void setId (const char *id);
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
48 void setClass (const char *klass);
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
49 void setStyle (const char *style);
495
7224de9c34b7 add StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 493
diff changeset
50 void endElement (int tag);
598
4ff90b6242f9 fix id, class, style attribute handling
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 590
diff changeset
51 void setPseudo (const char *pseudo);
590
eb1072890045 setNonCssProperties() -> setNonCssHints()
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 589
diff changeset
52 void setNonCssHints (CssPropertyList *nonCssHints);
615
d0694361ecd0 add workaround for table row coloring
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 598
diff changeset
53 void inheritBackgroundColor ();
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
54
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
55 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
56 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
57 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
58 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
59 else
03de2284bfa6 switch to original enum names from dillo-0.8.0-css-3
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 503
diff changeset
60 return style0 ();
503
00b31843839b implement various apply() methods
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 501
diff changeset
61 };
644
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
62 inline dw::core::style::Style *wordStyle () {
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
63 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
64 if (s)
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
65 return s;
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
66 else
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
67 return wordStyle0 ();
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
68 };
9e4ad941cbdc add wordStyle() method to StyleEngine
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 643
diff changeset
69
493
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
70 };
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
71
03e0cacbb994 add css.hh css.cc
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents:
diff changeset
72 #endif