dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

styleengine.cc
Go to the documentation of this file.
1 /*
2  * File: styleengine.cc
3  *
4  * Copyright 2008-2009 Johannes Hofmann <Johannes.Hofmann@gmx.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  */
11 
12 #include "../dlib/dlib.h"
13 #include "msg.h"
14 #include "prefs.h"
15 #include "misc.h"
16 #include "html_common.hh"
17 #include "styleengine.hh"
18 #include "web.hh"
19 #include "capi.h"
20 
21 using namespace lout::misc;
22 using namespace dw::core::style;
23 
34 {
35  int clientKey;
36 
37 public:
38  StyleImageDeletionReceiver (int clientKey);
40 
41  void deleted (lout::signal::ObservedObject *object);
42 };
43 
45 {
46  this->clientKey = clientKey;
47 }
48 
50 {
51 }
52 
54 {
55  a_Capi_stop_client (clientKey, 0);
56  delete this;
57 }
58 
59 // ----------------------------------------------------------------------
60 
62  const DilloUrl *pageUrl, const DilloUrl *baseUrl) {
63  StyleAttrs style_attrs;
64  FontAttrs font_attrs;
65 
66  doctree = new Doctree ();
67  stack = new lout::misc::SimpleVector <Node> (1);
68  cssContext = new CssContext ();
69  buildUserStyle ();
70  this->layout = layout;
71  this->pageUrl = pageUrl ? a_Url_dup(pageUrl) : NULL;
72  this->baseUrl = baseUrl ? a_Url_dup(baseUrl) : NULL;
73  importDepth = 0;
74 
75  stackPush ();
76  Node *n = stack->getLastRef ();
77 
78  /* Create a dummy font, attribute, and tag for the bottom of the stack. */
79  font_attrs.name = prefs.font_sans_serif;
80  font_attrs.size = roundInt(14 * prefs.font_factor);
81  if (font_attrs.size < prefs.font_min_size)
82  font_attrs.size = prefs.font_min_size;
83  if (font_attrs.size > prefs.font_max_size)
84  font_attrs.size = prefs.font_max_size;
85  font_attrs.weight = 400;
86  font_attrs.style = FONT_STYLE_NORMAL;
87  font_attrs.letterSpacing = 0;
88  font_attrs.fontVariant = FONT_VARIANT_NORMAL;
89 
90  style_attrs.initValues ();
91  style_attrs.font = Font::create (layout, &font_attrs);
92  style_attrs.color = Color::create (layout, 0);
93  style_attrs.backgroundColor = Color::create (layout, prefs.bg_color);
94 
95  n->style = Style::create (&style_attrs);
96 }
97 
99  while (doctree->top ())
100  endElement (doctree->top ()->element);
101 
102  stackPop (); // dummy node on the bottom of the stack
103  assert (stack->size () == 0);
104 
105  a_Url_free(pageUrl);
106  a_Url_free(baseUrl);
107 
108  delete stack;
109  delete doctree;
110  delete cssContext;
111 }
112 
114  static const Node emptyNode = {
115  NULL, NULL, NULL, NULL, NULL, NULL, false, false, NULL
116  };
117 
118  stack->setSize (stack->size () + 1, emptyNode);
119 }
120 
122  Node *n = stack->getRef (stack->size () - 1);
123 
124  delete n->styleAttrProperties;
126  delete n->nonCssProperties;
127  if (n->style)
128  n->style->unref ();
129  if (n->wordStyle)
130  n->wordStyle->unref ();
131  if (n->backgroundStyle)
132  n->backgroundStyle->unref ();
133  stack->setSize (stack->size () - 1);
134 }
135 
139 void StyleEngine::startElement (int element, BrowserWindow *bw) {
140  style (bw); // ensure that style of current node is computed
141 
142  stackPush ();
143  Node *n = stack->getLastRef ();
144  DoctreeNode *dn = doctree->push ();
145 
146  dn->element = element;
147  n->doctreeNode = dn;
148  if (stack->size () > 1)
149  n->displayNone = stack->getRef (stack->size () - 2)->displayNone;
150 }
151 
152 void StyleEngine::startElement (const char *tagname, BrowserWindow *bw) {
153  startElement (a_Html_tag_index (tagname), bw);
154 }
155 
156 void StyleEngine::setId (const char *id) {
157  DoctreeNode *dn = doctree->top ();
158  assert (dn->id == NULL);
159  dn->id = dStrdup (id);
160 }
161 
165 static lout::misc::SimpleVector<char *> *splitStr (const char *str, char sep) {
166  const char *p1 = NULL;
169 
170  for (;; str++) {
171  if (*str != '\0' && *str != sep) {
172  if (!p1)
173  p1 = str;
174  } else if (p1) {
175  list->increase ();
176  list->set (list->size () - 1, dStrndup (p1, str - p1));
177  p1 = NULL;
178  }
179 
180  if (*str == '\0')
181  break;
182  }
183 
184  return list;
185 }
186 
187 void StyleEngine::setClass (const char *klass) {
188  DoctreeNode *dn = doctree->top ();
189  assert (dn->klass == NULL);
190  dn->klass = splitStr (klass, ' ');
191 }
192 
193 void StyleEngine::setStyle (const char *styleAttr) {
194  Node *n = stack->getRef (stack->size () - 1);
195  assert (n->styleAttrProperties == NULL);
196  // parse style information from style="" attribute, if it exists
197  if (styleAttr && prefs.parse_embedded_css) {
198  n->styleAttrProperties = new CssPropertyList (true);
200 
201  CssParser::parseDeclarationBlock (baseUrl, styleAttr, strlen (styleAttr),
204  }
205 }
206 
213  Node *pn = stack->getRef (stack->size () - 2);
214 
215  if (pn->nonCssProperties) {
216  Node *n = stack->getRef (stack->size () - 1);
217  CssPropertyList *origNonCssProperties = n->nonCssProperties;
218 
220 
221  if (origNonCssProperties) // original nonCssProperties have precedence
222  origNonCssProperties->apply (n->nonCssProperties);
223 
224  delete origNonCssProperties;
225  }
226 }
227 
229  Node *n = stack->getRef (stack->size () - 1);
230 
231  delete n->nonCssProperties;
232  n->nonCssProperties = NULL;
233 }
234 
242  stack->getRef (stack->size () - 1)->inheritBackgroundColor = true;
243 }
244 
246  for (int i = 1; i < stack->size (); i++) {
247  Node *n = stack->getRef (i);
248 
249  if (n->style && n->style->backgroundColor)
250  return n->style->backgroundColor;
251  }
252 
253  return NULL;
254 }
255 
259  dw::core::style::Length *bgPositionX,
260  dw::core::style::Length *bgPositionY) {
261  for (int i = 1; i < stack->size (); i++) {
262  Node *n = stack->getRef (i);
263 
264  if (n->style && n->style->backgroundImage) {
265  *bgRepeat = n->style->backgroundRepeat;
266  *bgAttachment = n->style->backgroundAttachment;
267  *bgPositionX = n->style->backgroundPositionX;
268  *bgPositionY = n->style->backgroundPositionY;
269  return n->style->backgroundImage;
270  }
271  }
272 
273  return NULL;
274 }
275 
280  DoctreeNode *dn = doctree->top ();
281  dn->pseudo = "link";
282 }
283 
288  DoctreeNode *dn = doctree->top ();
289  dn->pseudo = "visited";
290 }
291 
295 void StyleEngine::endElement (int element) {
296  assert (element == doctree->top ()->element);
297 
298  stackPop ();
299  doctree->pop ();
300 }
301 
303  /* workaround for styling of inline elements */
304  if (stack->getRef (stack->size () - 2)->inheritBackgroundColor) {
305  attrs->backgroundColor =
306  stack->getRef (stack->size () - 2)->style->backgroundColor;
307  attrs->backgroundImage =
308  stack->getRef (stack->size () - 2)->style->backgroundImage;
309  attrs->backgroundRepeat =
310  stack->getRef (stack->size () - 2)->style->backgroundRepeat;
311  attrs->backgroundAttachment =
312  stack->getRef (stack->size () - 2)->style->backgroundAttachment;
313  attrs->backgroundPositionX =
314  stack->getRef (stack->size () - 2)->style->backgroundPositionX;
315  attrs->backgroundPositionY =
316  stack->getRef (stack->size () - 2)->style->backgroundPositionY;
317 
318  attrs->valign = stack->getRef (stack->size () - 2)->style->valign;
319  }
320  attrs->borderColor.top = (Color *) -1;
321  attrs->borderColor.bottom = (Color *) -1;
322  attrs->borderColor.left = (Color *) -1;
323  attrs->borderColor.right = (Color *) -1;
324  /* initial value of border-width is 'medium' */
325  attrs->borderWidth.top = 2;
326  attrs->borderWidth.bottom = 2;
327  attrs->borderWidth.left = 2;
328  attrs->borderWidth.right = 2;
329 }
330 
332  /* if border-color is not specified, use color as computed value */
333  if (attrs->borderColor.top == (Color *) -1)
334  attrs->borderColor.top = attrs->color;
335  if (attrs->borderColor.bottom == (Color *) -1)
336  attrs->borderColor.bottom = attrs->color;
337  if (attrs->borderColor.left == (Color *) -1)
338  attrs->borderColor.left = attrs->color;
339  if (attrs->borderColor.right == (Color *) -1)
340  attrs->borderColor.right = attrs->color;
341  /* computed value of border-width is 0 if border-style
342  is 'none' or 'hidden' */
343  if (attrs->borderStyle.top == BORDER_NONE ||
344  attrs->borderStyle.top == BORDER_HIDDEN)
345  attrs->borderWidth.top = 0;
346  if (attrs->borderStyle.bottom == BORDER_NONE ||
347  attrs->borderStyle.bottom == BORDER_HIDDEN)
348  attrs->borderWidth.bottom = 0;
349  if (attrs->borderStyle.left == BORDER_NONE ||
350  attrs->borderStyle.left == BORDER_HIDDEN)
351  attrs->borderWidth.left = 0;
352  if (attrs->borderStyle.right == BORDER_NONE ||
353  attrs->borderStyle.right == BORDER_HIDDEN)
354  attrs->borderWidth.right = 0;
355 }
356 
360 void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
361  BrowserWindow *bw) {
362  FontAttrs fontAttrs = *attrs->font;
363  Font *parentFont = stack->get (i - 1).style->font;
364  char *c, *fontName;
365  int lineHeight;
366  DilloUrl *imgUrl = NULL;
367 
368  /* Determine font first so it can be used to resolve relative lengths. */
369  for (int j = 0; j < props->size (); j++) {
370  CssProperty *p = props->getRef (j);
371 
372  switch (p->name) {
374  // Check font names in comma separated list.
375  // Note, that p->value.strVal is modified, so that in future calls
376  // the matching font name can be used directly.
377  fontName = NULL;
378  while (p->value.strVal) {
379  if ((c = strchr(p->value.strVal, ',')))
380  *c = '\0';
381  dStrstrip(p->value.strVal);
382 
383  if (dStrAsciiCasecmp (p->value.strVal, "serif") == 0)
384  fontName = prefs.font_serif;
385  else if (dStrAsciiCasecmp (p->value.strVal, "sans-serif") == 0)
386  fontName = prefs.font_sans_serif;
387  else if (dStrAsciiCasecmp (p->value.strVal, "cursive") == 0)
388  fontName = prefs.font_cursive;
389  else if (dStrAsciiCasecmp (p->value.strVal, "fantasy") == 0)
390  fontName = prefs.font_fantasy;
391  else if (dStrAsciiCasecmp (p->value.strVal, "monospace") == 0)
392  fontName = prefs.font_monospace;
393  else if (Font::exists(layout, p->value.strVal))
394  fontName = p->value.strVal;
395 
396  if (fontName) { // font found
397  fontAttrs.name = fontName;
398  break;
399  } else if (c) { // try next from list
400  memmove(p->value.strVal, c + 1, strlen(c + 1) + 1);
401  } else { // no font found
402  break;
403  }
404  }
405 
406  break;
408  if (p->type == CSS_TYPE_ENUM) {
409  switch (p->value.intVal) {
411  fontAttrs.size = roundInt(8.1 * prefs.font_factor);
412  break;
414  fontAttrs.size = roundInt(9.7 * prefs.font_factor);
415  break;
416  case CSS_FONT_SIZE_SMALL:
417  fontAttrs.size = roundInt(11.7 * prefs.font_factor);
418  break;
420  fontAttrs.size = roundInt(14.0 * prefs.font_factor);
421  break;
422  case CSS_FONT_SIZE_LARGE:
423  fontAttrs.size = roundInt(16.8 * prefs.font_factor);
424  break;
426  fontAttrs.size = roundInt(20.2 * prefs.font_factor);
427  break;
429  fontAttrs.size = roundInt(24.2 * prefs.font_factor);
430  break;
432  fontAttrs.size = roundInt(fontAttrs.size * 0.83);
433  break;
435  fontAttrs.size = roundInt(fontAttrs.size * 1.2);
436  break;
437  default:
438  assert(false); // invalid font-size enum
439  }
440  } else {
441  computeValue (&fontAttrs.size, p->value.intVal, parentFont,
442  parentFont->size);
443  }
444 
445  if (fontAttrs.size < prefs.font_min_size)
446  fontAttrs.size = prefs.font_min_size;
447  if (fontAttrs.size > prefs.font_max_size)
448  fontAttrs.size = prefs.font_max_size;
449 
450  break;
452  fontAttrs.style = (FontStyle) p->value.intVal;
453  break;
455 
456  if (p->type == CSS_TYPE_ENUM) {
457  switch (p->value.intVal) {
459  fontAttrs.weight = 700;
460  break;
462  fontAttrs.weight += 300;
463  break;
465  fontAttrs.weight = 100;
466  break;
468  fontAttrs.weight -= 300;
469  break;
471  fontAttrs.weight = 400;
472  break;
473  default:
474  assert(false); // invalid font weight value
475  break;
476  }
477  } else {
478  fontAttrs.weight = p->value.intVal;
479  }
480 
481  if (fontAttrs.weight < 100)
482  fontAttrs.weight = 100;
483  if (fontAttrs.weight > 900)
484  fontAttrs.weight = 900;
485 
486  break;
488  if (p->type == CSS_TYPE_ENUM) {
490  fontAttrs.letterSpacing = 0;
491  }
492  } else {
493  computeValue (&fontAttrs.letterSpacing, p->value.intVal,
494  parentFont, parentFont->size);
495  }
496 
497  /* Limit letterSpacing to reasonable values to avoid overflows e.g,
498  * when measuring word width.
499  */
500  if (fontAttrs.letterSpacing > 1000)
501  fontAttrs.letterSpacing = 1000;
502  else if (fontAttrs.letterSpacing < -1000)
503  fontAttrs.letterSpacing = -1000;
504  break;
506  fontAttrs.fontVariant = (FontVariant) p->value.intVal;
507  break;
508  default:
509  break;
510  }
511  }
512 
513  attrs->font = Font::create (layout, &fontAttrs);
514 
515  for (int j = 0; j < props->size (); j++) {
516  CssProperty *p = props->getRef (j);
517 
518  switch (p->name) {
519  /* \todo missing cases */
521  attrs->backgroundAttachment =
523  break;
525  if (prefs.allow_white_bg || p->value.intVal != 0xffffff)
526  attrs->backgroundColor = Color::create(layout, p->value.intVal);
527  else
528  attrs->backgroundColor =
529  Color::create(layout, prefs.white_bg_replacement);
530  break;
532  // p->value.strVal should be absolute, so baseUrl is not needed
533  imgUrl = a_Url_new (p->value.strVal, NULL);
534  break;
536  computeLength (&attrs->backgroundPositionX, p->value.posVal->posX,
537  attrs->font);
538  computeLength (&attrs->backgroundPositionY, p->value.posVal->posY,
539  attrs->font);
540  break;
543  break;
546  break;
548  attrs->borderColor.top = (p->type == CSS_TYPE_ENUM) ? NULL :
549  Color::create (layout, p->value.intVal);
550  break;
552  attrs->borderColor.bottom = (p->type == CSS_TYPE_ENUM) ? NULL :
553  Color::create (layout, p->value.intVal);
554  break;
556  attrs->borderColor.left = (p->type == CSS_TYPE_ENUM) ? NULL :
557  Color::create (layout, p->value.intVal);
558  break;
560  attrs->borderColor.right = (p->type == CSS_TYPE_ENUM) ? NULL :
561  Color::create (layout, p->value.intVal);
562  break;
564  attrs->borderStyle.bottom = (BorderStyle) p->value.intVal;
565  break;
567  attrs->borderStyle.left = (BorderStyle) p->value.intVal;
568  break;
570  attrs->borderStyle.right = (BorderStyle) p->value.intVal;
571  break;
573  attrs->borderStyle.top = (BorderStyle) p->value.intVal;
574  break;
576  computeBorderWidth (&attrs->borderWidth.bottom, p, attrs->font);
577  break;
579  computeBorderWidth (&attrs->borderWidth.left, p, attrs->font);
580  break;
582  computeBorderWidth (&attrs->borderWidth.right, p, attrs->font);
583  break;
585  computeBorderWidth (&attrs->borderWidth.top, p, attrs->font);
586  break;
588  computeValue (&attrs->hBorderSpacing, p->value.intVal,attrs->font);
589  computeValue (&attrs->vBorderSpacing, p->value.intVal,attrs->font);
590  break;
591  case CSS_PROPERTY_COLOR:
592  attrs->color = Color::create (layout, p->value.intVal);
593  break;
594  case CSS_PROPERTY_CURSOR:
595  attrs->cursor = (Cursor) p->value.intVal;
596  break;
598  attrs->display = (DisplayType) p->value.intVal;
599  if (attrs->display == DISPLAY_NONE)
600  stack->getRef (i)->displayNone = true;
601  break;
603  if (p->type == CSS_TYPE_ENUM) { //only valid enum value is "normal"
605  } else if (p->type == CSS_TYPE_LENGTH_PERCENTAGE_NUMBER) {
607  attrs->lineHeight =
609  } else if (computeValue (&lineHeight, p->value.intVal,
610  attrs->font, attrs->font->size)) {
611  attrs->lineHeight = createAbsLength(lineHeight);
612  }
613  }
614  break;
617  break;
619  attrs->listStyleType = (ListStyleType) p->value.intVal;
620  break;
622  computeValue (&attrs->margin.bottom, p->value.intVal, attrs->font);
623  if (attrs->margin.bottom < 0) // \todo fix negative margins in dw/*
624  attrs->margin.bottom = 0;
625  break;
627  computeValue (&attrs->margin.left, p->value.intVal, attrs->font);
628  if (attrs->margin.left < 0) // \todo fix negative margins in dw/*
629  attrs->margin.left = 0;
630  break;
632  computeValue (&attrs->margin.right, p->value.intVal, attrs->font);
633  if (attrs->margin.right < 0) // \todo fix negative margins in dw/*
634  attrs->margin.right = 0;
635  break;
637  computeValue (&attrs->margin.top, p->value.intVal, attrs->font);
638  if (attrs->margin.top < 0) // \todo fix negative margins in dw/*
639  attrs->margin.top = 0;
640  break;
642  computeValue (&attrs->padding.top, p->value.intVal, attrs->font);
643  break;
645  computeValue (&attrs->padding.bottom, p->value.intVal,attrs->font);
646  break;
648  computeValue (&attrs->padding.left, p->value.intVal, attrs->font);
649  break;
651  computeValue (&attrs->padding.right, p->value.intVal, attrs->font);
652  break;
654  attrs->textAlign = (TextAlignType) p->value.intVal;
655  break;
657  attrs->textDecoration |= p->value.intVal;
658  break;
660  computeLength (&attrs->textIndent, p->value.intVal, attrs->font);
661  break;
663  attrs->textTransform = (TextTransform) p->value.intVal;
664  break;
666  attrs->valign = (VAlignType) p->value.intVal;
667  break;
669  attrs->whiteSpace = (WhiteSpace) p->value.intVal;
670  break;
671  case CSS_PROPERTY_WIDTH:
672  computeLength (&attrs->width, p->value.intVal, attrs->font);
673  break;
674  case CSS_PROPERTY_HEIGHT:
675  computeLength (&attrs->height, p->value.intVal, attrs->font);
676  break;
678  if (p->type == CSS_TYPE_ENUM) {
680  attrs->wordSpacing = 0;
681  }
682  } else {
683  computeValue(&attrs->wordSpacing, p->value.intVal, attrs->font);
684  }
685 
686  /* Limit to reasonable values to avoid overflows */
687  if (attrs->wordSpacing > 1000)
688  attrs->wordSpacing = 1000;
689  else if (attrs->wordSpacing < -1000)
690  attrs->wordSpacing = -1000;
691  break;
692  case PROPERTY_X_LINK:
693  attrs->x_link = p->value.intVal;
694  break;
695  case PROPERTY_X_LANG:
696  attrs->x_lang[0] = D_ASCII_TOLOWER(p->value.strVal[0]);
697  if (attrs->x_lang[0])
698  attrs->x_lang[1] = D_ASCII_TOLOWER(p->value.strVal[1]);
699  else
700  attrs->x_lang[1] = 0;
701  break;
702  case PROPERTY_X_IMG:
703  attrs->x_img = p->value.intVal;
704  break;
705  case PROPERTY_X_TOOLTIP:
706  attrs->x_tooltip = Tooltip::create(layout, p->value.strVal);
707  break;
708  default:
709  break;
710  }
711  }
712 
713  if (imgUrl && prefs.load_background_images &&
714  !stack->getRef (i)->displayNone &&
715  !(URL_FLAGS(pageUrl) & URL_SpamSafe))
716  {
717  attrs->backgroundImage = StyleImage::create();
718  DilloImage *image =
719  a_Image_new(layout,
720  (void*)attrs->backgroundImage
721  ->getMainImgRenderer(),
722  0xffffff);
723 
724  // we use the pageUrl as requester to prevent cross
725  // domain requests as specified in domainrc
726  DilloWeb *web = a_Web_new(bw, imgUrl, pageUrl);
727  web->Image = image;
728  a_Image_ref(image);
729  web->flags |= WEB_Image;
730 
731  int clientKey;
732  if ((clientKey = a_Capi_open_url(web, NULL, NULL)) != 0) {
733  a_Bw_add_client(bw, clientKey, 0);
734  a_Bw_add_url(bw, imgUrl);
736  (new StyleImageDeletionReceiver (clientKey));
737  }
738  }
739  a_Url_free (imgUrl);
740 }
741 
745 bool StyleEngine::computeValue (int *dest, CssLength value, Font *font) {
746  static float dpmm;
747 
748  if (dpmm == 0.0)
749  dpmm = layout->dpiX () / 25.4; /* assume dpiX == dpiY */
750 
751  switch (CSS_LENGTH_TYPE (value)) {
752  case CSS_LENGTH_TYPE_PX:
753  *dest = (int) CSS_LENGTH_VALUE (value);
754  return true;
755  case CSS_LENGTH_TYPE_MM:
756  *dest = roundInt (CSS_LENGTH_VALUE (value) * dpmm);
757  return true;
758  case CSS_LENGTH_TYPE_EM:
759  *dest = roundInt (CSS_LENGTH_VALUE (value) * font->size);
760  return true;
761  case CSS_LENGTH_TYPE_EX:
762  *dest = roundInt (CSS_LENGTH_VALUE(value) * font->xHeight);
763  return true;
765  // length values other than 0 without unit are only allowed
766  // in special cases (line-height) and have to be handled
767  // separately.
768  assert ((int) CSS_LENGTH_VALUE (value) == 0);
769  *dest = 0;
770  return true;
771  default:
772  break;
773  }
774 
775  return false;
776 }
777 
778 bool StyleEngine::computeValue (int *dest, CssLength value, Font *font,
779  int percentageBase) {
781  *dest = roundInt (CSS_LENGTH_VALUE (value) * percentageBase);
782  return true;
783  } else
784  return computeValue (dest, value, font);
785 }
786 
788  CssLength value, Font *font) {
789  int v;
790 
792  *dest = createPerLength (CSS_LENGTH_VALUE (value));
793  return true;
794  } else if (CSS_LENGTH_TYPE (value) == CSS_LENGTH_TYPE_AUTO) {
796  return true;
797  } else if (computeValue (&v, value, font)) {
798  *dest = createAbsLength (v);
799  return true;
800  }
801 
802  return false;
803 }
804 
806  dw::core::style::Font *font) {
807  if (p->type == CSS_TYPE_ENUM) {
808  switch (p->value.intVal) {
810  *dest = 1;
811  break;
813  *dest = 2;
814  break;
816  *dest = 3;
817  break;
818  default:
819  assert(false);
820  }
821  } else {
822  computeValue (dest, p->value.intVal, font);
823  }
824 }
825 
832  if (!stack->getRef (stack->size () - 1)->backgroundStyle) {
833  StyleAttrs attrs = *style (bw);
834 
835  for (int i = stack->size () - 1; i >= 0 && ! attrs.backgroundColor; i--)
836  attrs.backgroundColor = stack->getRef (i)->style->backgroundColor;
837 
838  assert (attrs.backgroundColor);
839  stack->getRef (stack->size () - 1)->backgroundStyle =
840  Style::create (&attrs);
841  }
842  return stack->getRef (stack->size () - 1)->backgroundStyle;
843 }
844 
851  CssPropertyList props, *styleAttrProperties, *styleAttrPropertiesImportant;
852  CssPropertyList *nonCssProperties;
853  // get previous style from the stack
854  StyleAttrs attrs = *stack->getRef (i - 1)->style;
855 
856  // Ensure that StyleEngine::style0() has not been called before for
857  // this element.
858  // Style computation is expensive so limit it as much as possible.
859  // If this assertion is hit, you need to rearrange the code that is
860  // doing styleEngine calls to call setNonCssHint() before calling
861  // style() or wordStyle() for each new element.
862  assert (stack->getRef (i)->style == NULL);
863 
864  // reset values that are not inherited according to CSS
865  attrs.resetValues ();
866  preprocessAttrs (&attrs);
867 
868  styleAttrProperties = stack->getRef (i)->styleAttrProperties;
869  styleAttrPropertiesImportant = stack->getRef(i)->styleAttrPropertiesImportant;
870  nonCssProperties = stack->getRef (i)->nonCssProperties;
871 
872  // merge style information
873  cssContext->apply (&props, doctree, stack->getRef(i)->doctreeNode,
874  styleAttrProperties, styleAttrPropertiesImportant,
875  nonCssProperties);
876 
877  // apply style
878  apply (i, &attrs, &props, bw);
879 
880  postprocessAttrs (&attrs);
881 
882  stack->getRef (i)->style = Style::create (&attrs);
883 
884  return stack->getRef (i)->style;
885 }
886 
888  StyleAttrs attrs = *style (bw);
889  attrs.resetValues ();
890 
891  if (stack->getRef (stack->size() - 1)->inheritBackgroundColor) {
892  attrs.backgroundColor = style (bw)->backgroundColor;
893  attrs.backgroundImage = style (bw)->backgroundImage;
894  attrs.backgroundRepeat = style (bw)->backgroundRepeat;
895  attrs.backgroundAttachment = style (bw)->backgroundAttachment;
896  attrs.backgroundPositionX = style (bw)->backgroundPositionX;
897  attrs.backgroundPositionY = style (bw)->backgroundPositionY;
898  }
899 
900  attrs.valign = style (bw)->valign;
901 
902  stack->getRef(stack->size() - 1)->wordStyle = Style::create(&attrs);
903  return stack->getRef (stack->size () - 1)->wordStyle;
904 }
905 
914  for (int i = 1; i < stack->size (); i++) {
915  Node *n = stack->getRef (i);
916  if (n->style) {
917  n->style->unref ();
918  n->style = NULL;
919  }
920  if (n->wordStyle) {
921  n->wordStyle->unref ();
922  n->wordStyle = NULL;
923  }
924  if (n->backgroundStyle) {
925  n->backgroundStyle->unref ();
926  n->backgroundStyle = NULL;
927  }
928 
929  style0 (i, bw);
930  }
931 }
932 
933 void StyleEngine::parse (DilloHtml *html, DilloUrl *url, const char *buf,
934  int buflen, CssOrigin origin) {
935  if (importDepth > 10) { // avoid looping with recursive @import directives
936  MSG_WARN("Maximum depth of CSS @import reached--ignoring stylesheet.\n");
937  return;
938  }
939 
940  importDepth++;
941  CssParser::parse (html, url, cssContext, buf, buflen, origin);
942  importDepth--;
943 }
944 
952  const char *cssBuf =
953  "body {margin: 5px}"
954  "big {font-size: 1.17em}"
955  "blockquote, dd {margin-left: 40px; margin-right: 40px}"
956  "center {text-align: center}"
957  "dt {font-weight: bolder}"
958  ":link {color: blue; text-decoration: underline; cursor: pointer}"
959  ":visited {color: #800080; text-decoration: underline; cursor: pointer}"
960  "h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder}"
961  "address, article, aside, center, div, figure, figcaption, footer,"
962  " h1, h2, h3, h4, h5, h6, header, nav, ol, p, pre, section, ul"
963  " {display: block}"
964  "i, em, cite, address, var {font-style: italic}"
965  ":link img, :visited img {border: 1px solid}"
966  "frameset, ul, ol, dir {margin-left: 40px}"
967  /* WORKAROUND: It should be margin: 1em 0
968  * but as we don't collapse these margins yet, it
969  * look better like this.
970  */
971  "p {margin: 0.5em 0}"
972  "figure {margin: 1em 40px}"
973  "h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0}"
974  "h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0}"
975  "h3 {font-size: 1.17em; margin-top: .83em; margin-bottom: 0}"
976  "h4 {margin-top: 1.12em; margin-bottom: 0}"
977  "h5 {font-size: 0.83em; margin-top: 1.5em; margin-bottom: 0}"
978  "h6 {font-size: 0.75em; margin-top: 1.67em; margin-bottom: 0}"
979  "hr {width: 100%; border: 1px inset}"
980  "li {margin-top: 0.1em; display: list-item}"
981  "pre {white-space: pre}"
982  "ol {list-style-type: decimal}"
983  "ul {list-style-type: disc}"
984  "ul ul {list-style-type: circle}"
985  "ul ul ul {list-style-type: square}"
986  "ul ul ul ul {list-style-type: disc}"
987  "ins, u {text-decoration: underline}"
988  "small, sub, sup {font-size: 0.83em}"
989  "sub {vertical-align: sub}"
990  "sup {vertical-align: super}"
991  "s, strike, del {text-decoration: line-through}"
992  /* HTML5 spec notes that mark styling "is just a suggestion and can be
993  * changed based on implementation feedback"
994  */
995  "mark {background: yellow; color: black;}"
996  "table {border-spacing: 2px}"
997  "td, th {padding: 2px}"
998  "thead, tbody, tfoot {vertical-align: middle}"
999  "th {font-weight: bolder; text-align: center}"
1000  "code, tt, pre, samp, kbd {font-family: monospace}"
1001  /* WORKAROUND: Reset font properties in tables as some
1002  * pages rely on it (e.g. gmail).
1003  * http://developer.mozilla.org/En/Fixing_Table_Inheritance_in_Quirks_Mode
1004  * has a detailed description of the issue.
1005  */
1006  "table, caption {font-size: medium; font-weight: normal}";
1007 
1008  CssContext context;
1009  CssParser::parse (NULL, NULL, &context, cssBuf, strlen (cssBuf),
1011 }
1012 
1014  Dstr *style;
1015  char *filename = dStrconcat(dGethomedir(), "/.dillo/style.css", NULL);
1016 
1017  if ((style = a_Misc_file2dstr(filename))) {
1018  CssParser::parse (NULL,NULL,cssContext,style->str, style->len,CSS_ORIGIN_USER);
1019  dStr_free (style, 1);
1020  }
1021  dFree (filename);
1022 }
dw::core::style::StyleAttrs::initValues
void initValues()
Definition: style.cc:58
dw::core::style::StyleAttrs::textTransform
TextTransform textTransform
Definition: style.hh:505
dStr_free
void dStr_free(Dstr *ds, int all)
Definition: dlib.c:335
Doctree
HTML document tree interface.
Definition: doctree.hh:48
_DilloWeb
Definition: web.hh:24
StyleEngine::Node::styleAttrProperties
CssPropertyList * styleAttrProperties
Definition: styleengine.hh:23
CssParser::parse
static void parse(DilloHtml *html, const DilloUrl *baseUrl, CssContext *context, const char *buf, int buflen, CssOrigin origin)
Definition: cssparser.cc:1712
CSS_LENGTH_TYPE_PX
Definition: css.hh:79
CSS_PROPERTY_FONT_SIZE
Definition: css.hh:180
dw::core::style::StyleAttrs::top
Color * top
Definition: style.hh:512
dw::core::style::StyleAttrs::backgroundPositionY
Length backgroundPositionY
Definition: style.hh:500
dw::core::style::Cursor
Cursor
Definition: style.hh:198
CSS_PROPERTY_BORDER_LEFT_COLOR
Definition: css.hh:156
CSS_FONT_SIZE_SMALLER
Definition: css.hh:267
CSS_FONT_SIZE_XX_SMALL
Definition: css.hh:269
DoctreeNode::element
int element
Definition: doctree.hh:12
dw::core::style::WhiteSpace
WhiteSpace
Definition: style.hh:343
a_Url_free
void a_Url_free(DilloUrl *url)
Definition: url.c:192
dw::core::style::StyleAttrs::right
Color * right
Definition: style.hh:512
dw::core::style::FontAttrs::style
FontStyle style
Definition: style.hh:646
CssProperty
This class holds a CSS property and value pair.
Definition: css.hh:286
CSS_PROPERTY_BACKGROUND_COLOR
Definition: css.hh:148
BrowserWindow
Definition: bw.h:15
dw::core::style::StyleAttrs::height
Length height
Definition: style.hh:508
CSS_PROPERTY_BORDER_RIGHT_WIDTH
Definition: css.hh:161
CssBackgroundPosition::posY
int32_t posY
Definition: css.hh:239
CSS_BORDER_WIDTH_THICK
Definition: css.hh:251
CssParser::parseDeclarationBlock
static void parseDeclarationBlock(const DilloUrl *baseUrl, const char *buf, int buflen, CssPropertyList *props, CssPropertyList *propsImortant)
Definition: cssparser.cc:1744
lout::misc::SimpleVector::getRef
T * getRef(int i) const
Return the reference of one element.
Definition: misc.hh:166
StyleImageDeletionReceiver
Definition: styleengine.cc:32
CSS_TYPE_ENUM
Definition: css.hh:26
StyleEngine::inheritBackgroundColor
void inheritBackgroundColor()
Use of the background color of the parent style as default. This is only used in table code to allow ...
Definition: styleengine.cc:241
StyleEngine::preprocessAttrs
void preprocessAttrs(dw::core::style::StyleAttrs *attrs)
Definition: styleengine.cc:302
PROPERTY_X_IMG
Definition: css.hh:232
CSS_PROPERTY_BORDER_RIGHT_STYLE
Definition: css.hh:160
CSS_FONT_WEIGHT_LIGHTER
Definition: css.hh:258
dw::core::style::StyleAttrs::width
Length width
Definition: style.hh:508
lout::misc::SimpleVector::increase
void increase()
Increase the vector size by one.
Definition: misc.hh:136
DilloPrefs::font_fantasy
char * font_fantasy
Definition: prefs.h:98
dw::core::style::LENGTH_AUTO
Represents "auto" lengths.
Definition: style.hh:454
dw::core::style::TextAlignType
TextAlignType
Definition: style.hh:246
StyleImageDeletionReceiver::StyleImageDeletionReceiver
StyleImageDeletionReceiver(int clientKey)
Definition: styleengine.cc:44
dw::core::style::StyleAttrs::margin
Box margin
Definition: style.hh:510
dw::core::style::BorderCollapse
BorderCollapse
Definition: style.hh:216
dw::core::style::StyleAttrs::x_lang
char x_lang[2]
Definition: style.hh:524
dw::core::style::Color
Definition: style.hh:709
a_Web_new
DilloWeb * a_Web_new(BrowserWindow *bw, const DilloUrl *url, const DilloUrl *requester)
Definition: web.cc:119
CSS_PROPERTY_TEXT_TRANSFORM
Definition: css.hh:218
StyleImageDeletionReceiver::clientKey
int clientKey
Definition: styleengine.cc:35
DilloPrefs::bg_color
int32_t bg_color
Definition: prefs.h:52
CSS_PROPERTY_BACKGROUND_REPEAT
Definition: css.hh:151
dw::core::style::StyleAttrs::backgroundColor
Color * backgroundColor
Definition: style.hh:495
splitStr
static lout::misc::SimpleVector< char * > * splitStr(const char *str, char sep)
split a string at sep chars and return a SimpleVector of strings
Definition: styleengine.cc:165
dw::core::style::StyleAttrs::cursor
Cursor cursor
Definition: style.hh:519
CssProperty::name
short name
Definition: css.hh:289
dw::core::style::StyleAttrs::borderCollapse
BorderCollapse borderCollapse
Definition: style.hh:511
CSS_PROPERTY_TEXT_INDENT
Definition: css.hh:216
WEB_Image
#define WEB_Image
Definition: web.hh:17
msg.h
PROPERTY_X_LINK
Definition: css.hh:230
StyleEngine::computeBorderWidth
void computeBorderWidth(int *dest, CssProperty *p, dw::core::style::Font *font)
Definition: styleengine.cc:805
CSS_LETTER_SPACING_NORMAL
Definition: css.hh:275
DoctreeNode::id
const char * id
Definition: doctree.hh:15
dw::core::style::StyleAttrs::lineHeight
Length lineHeight
Definition: style.hh:508
dFree
void dFree(void *mem)
Definition: dlib.c:66
dStrconcat
char * dStrconcat(const char *s1,...)
Definition: dlib.c:100
CssProperty::type
short type
Definition: css.hh:290
DilloPrefs::load_background_images
bool_t load_background_images
Definition: prefs.h:91
dw::core::style::FontAttrs::weight
int weight
Definition: style.hh:643
lout::misc
Miscellaneous stuff, which does not fit anywhere else.
Definition: misc.cc:31
CSS_FONT_SIZE_LARGER
Definition: css.hh:264
a_Image_ref
void a_Image_ref(DilloImage *Image)
Definition: image.cc:96
dw::core::style::StyleAttrs::display
DisplayType display
Definition: style.hh:515
CSS_FONT_WEIGHT_BOLDER
Definition: css.hh:256
dw::core::style::StyleAttrs::listStylePosition
ListStylePosition listStylePosition
Definition: style.hh:517
CSS_PROPERTY_DISPLAY
Definition: css.hh:176
CSS_WORD_SPACING_NORMAL
Definition: css.hh:279
dw::core::style::StyleAttrs::whiteSpace
WhiteSpace whiteSpace
Definition: style.hh:516
D_ASCII_TOLOWER
#define D_ASCII_TOLOWER(c)
Definition: dlib.h:37
CSS_PROPERTY_BACKGROUND_ATTACHMENT
Definition: css.hh:147
StyleEngine::backgroundStyle
dw::core::style::Style * backgroundStyle(BrowserWindow *bw)
Similar to StyleEngine::style(), but with backgroundColor set. A normal style might have backgroundCo...
Definition: styleengine.cc:831
dw::core::style::StyleAttrs::resetValues
void resetValues()
Reset those style attributes to their standard values, which are not inherited, according to CSS.
Definition: style.cc:98
CSS_PROPERTY_MARGIN_RIGHT
Definition: css.hh:195
CSS_FONT_SIZE_MEDIUM
Definition: css.hh:265
StyleEngine::setPseudoVisited
void setPseudoVisited()
set the CSS pseudo class :visited.
Definition: styleengine.cc:287
dw::core::style::StyleAttrs::backgroundRepeat
BackgroundRepeat backgroundRepeat
Definition: style.hh:497
DoctreeNode
Definition: doctree.hh:6
Dstr::str
char * str
Definition: dlib.h:105
CSS_FONT_SIZE_X_SMALL
Definition: css.hh:271
dw::core::style::Box::right
int right
Definition: style.hh:467
prefs.h
dw::core::style::FontAttrs::letterSpacing
int letterSpacing
Definition: style.hh:644
CssPropertyList::apply
void apply(CssPropertyList *props)
Merge properties into argument property list.
Definition: css.cc:87
DilloPrefs::parse_embedded_css
bool_t parse_embedded_css
Definition: prefs.h:93
dw::core::style::BorderStyle
BorderStyle
Definition: style.hh:221
lout::signal::ObservedObject::connectDeletion
void connectDeletion(DeletionReceiver *receiver)
Definition: signal.hh:302
URL_SpamSafe
#define URL_SpamSafe
Definition: url.h:41
CSS_PROPERTY_BORDER_BOTTOM_COLOR
Definition: css.hh:152
CSS_PROPERTY_LIST_STYLE_POSITION
Definition: css.hh:191
dStrndup
char * dStrndup(const char *s, size_t sz)
Definition: dlib.c:86
dw::core::style::FontAttrs
Definition: style.hh:638
dw::core::style::StyleImage::getMainImgRenderer
ImgRenderer * getMainImgRenderer()
Definition: style.hh:842
StyleEngine::Node::styleAttrPropertiesImportant
CssPropertyList * styleAttrPropertiesImportant
Definition: styleengine.hh:24
CSS_PROPERTY_FONT_WEIGHT
Definition: css.hh:185
StyleEngine::postprocessAttrs
void postprocessAttrs(dw::core::style::StyleAttrs *attrs)
Definition: styleengine.cc:331
DilloHtml
Definition: html_common.hh:131
DoctreeNode::klass
lout::misc::SimpleVector< char * > * klass
Definition: doctree.hh:13
URL_FLAGS
#define URL_FLAGS(u)
Definition: url.h:82
StyleEngine::inheritNonCssHints
void inheritNonCssHints()
Instruct StyleEngine to use the nonCssHints from parent element This is only used for tables where no...
Definition: styleengine.cc:212
CSS_PROPERTY_BORDER_TOP_WIDTH
Definition: css.hh:165
lout::misc::SimpleVector::size
int size() const
Return the number of elements put into this vector.
Definition: misc.hh:119
CssOrigin
CssOrigin
Definition: css.hh:17
CSS_PROPERTY_PADDING_LEFT
Definition: css.hh:208
dw::core::style::BackgroundAttachment
BackgroundAttachment
Definition: style.hh:241
StyleEngine::buildUserStyle
void buildUserStyle()
Definition: styleengine.cc:1013
styleengine.hh
dw::core::style::StyleAttrs::listStyleType
ListStyleType listStyleType
Definition: style.hh:518
CSS_FONT_WEIGHT_NORMAL
Definition: css.hh:259
dw::core::style::FontAttrs::name
const char * name
Definition: style.hh:641
StyleImageDeletionReceiver::deleted
void deleted(lout::signal::ObservedObject *object)
Definition: styleengine.cc:53
CSS_TYPE_LENGTH_PERCENTAGE_NUMBER
Definition: css.hh:39
StyleEngine::clearNonCssHints
void clearNonCssHints()
Definition: styleengine.cc:228
StyleEngine::stackPop
void stackPop()
Definition: styleengine.cc:121
CSS_PROPERTY_TEXT_ALIGN
Definition: css.hh:214
CSS_PROPERTY_PADDING_RIGHT
Definition: css.hh:209
misc.h
dw::core::style::StyleAttrs::borderStyle
struct dw::core::style::StyleAttrs::@14 borderStyle
CSS_ORIGIN_USER_AGENT
Definition: css.hh:18
CSS_PROPERTY_HEIGHT
Definition: css.hh:186
dw::core::style::StyleAttrs::padding
Box padding
Definition: style.hh:510
dw::core::style::StyleAttrs::vBorderSpacing
int vBorderSpacing
Definition: style.hh:507
CSS_PROPERTY_BORDER_LEFT_WIDTH
Definition: css.hh:158
CSS_PROPERTY_BORDER_BOTTOM_WIDTH
Definition: css.hh:154
a_Capi_open_url
int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData)
Definition: capi.c:379
lout::misc::SimpleVector::set
void set(int i, T t)
Store an object in the vector.
Definition: misc.hh:222
CSS_BORDER_WIDTH_THIN
Definition: css.hh:249
CSS_PROPERTY_BORDER_TOP_COLOR
Definition: css.hh:163
CSS_PROPERTY_FONT_VARIANT
Definition: css.hh:184
StyleEngine::Node::doctreeNode
DoctreeNode * doctreeNode
Definition: styleengine.hh:31
CSS_PROPERTY_BORDER_BOTTOM_STYLE
Definition: css.hh:153
DilloPrefs::allow_white_bg
bool_t allow_white_bg
Definition: prefs.h:50
dw::core::style::FontStyle
FontStyle
Definition: style.hh:324
StyleEngine::~StyleEngine
~StyleEngine()
Definition: styleengine.cc:98
CSS_PROPERTY_PADDING_BOTTOM
Definition: css.hh:207
dStrAsciiCasecmp
int dStrAsciiCasecmp(const char *s1, const char *s2)
Definition: dlib.c:201
StyleEngine::Node::backgroundStyle
dw::core::style::Style * backgroundStyle
Definition: styleengine.hh:28
CSS_PROPERTY_WORD_SPACING
Definition: css.hh:225
DilloPrefs::font_monospace
char * font_monospace
Definition: prefs.h:99
StyleEngine::setClass
void setClass(const char *klass)
Definition: styleengine.cc:187
StyleEngine::endElement
void endElement(int tag)
tell the styleEngine that a html element has ended.
Definition: styleengine.cc:295
dw::core::style::Font
Definition: style.hh:656
dw::core::style::FONT_STYLE_NORMAL
Definition: style.hh:325
CSS_PROPERTY_MARGIN_TOP
Definition: css.hh:196
CssLength
int CssLength
Definition: css.hh:75
CSS_PROPERTY_COLOR
Definition: css.hh:170
a_Url_new
DilloUrl * a_Url_new(const char *url_str, const char *base_url)
Definition: url.c:359
CSS_LENGTH_TYPE_EM
Definition: css.hh:82
CSS_BORDER_WIDTH_MEDIUM
Definition: css.hh:250
StyleEngine::restyle
void restyle(BrowserWindow *bw)
Recompute all style information from scratch This is used to take into account CSS styles for the HTM...
Definition: styleengine.cc:913
CSS_FONT_SIZE_XX_LARGE
Definition: css.hh:268
dw::core::style::StyleAttrs::borderColor
struct dw::core::style::StyleAttrs::@13 borderColor
dw::core::style::StyleAttrs::backgroundAttachment
BackgroundAttachment backgroundAttachment
Definition: style.hh:498
CSS_FONT_WEIGHT_LIGHT
Definition: css.hh:257
dw::core::style::StyleAttrs::textAlign
TextAlignType textAlign
Definition: style.hh:502
a_Capi_stop_client
void a_Capi_stop_client(int Key, int force)
Definition: capi.c:601
CSS_PROPERTY_LETTER_SPACING
Definition: css.hh:188
dw::core::Layout
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
StyleEngine::apply
void apply(int i, dw::core::style::StyleAttrs *attrs, CssPropertyList *props, BrowserWindow *bw)
Make changes to StyleAttrs attrs according to CssPropertyList props.
Definition: styleengine.cc:360
StyleEngine::backgroundImage
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)
Definition: styleengine.cc:257
StyleEngine::setStyle
void setStyle(const char *style)
Definition: styleengine.cc:193
CssPropertyValue::strVal
char * strVal
Definition: css.hh:244
dw::core::style::VAlignType
VAlignType
Definition: style.hh:254
_DilloImage
Definition: image.hh:46
CssProperty::value
CssPropertyValue value
Definition: css.hh:291
StyleEngine::stackPush
void stackPush()
Definition: styleengine.cc:113
StyleEngine::computeLength
bool computeLength(dw::core::style::Length *dest, CssLength value, dw::core::style::Font *font)
Definition: styleengine.cc:787
StyleEngine::Node::displayNone
bool displayNone
Definition: styleengine.hh:30
CSS_LENGTH_TYPE
CssLengthType CSS_LENGTH_TYPE(CssLength l)
Definition: css.hh:122
StyleEngine::Node::wordStyle
dw::core::style::Style * wordStyle
Definition: styleengine.hh:27
Dstr::len
int len
Definition: dlib.h:104
dw::core::style::createPerLength
Length createPerLength(double v)
Returns a percentage, v is relative to 1, not to 100.
Definition: style.hh:395
dw::core::style::Style::unref
void unref()
Definition: style.hh:599
StyleEngine::init
static void init()
Create the user agent style.
Definition: styleengine.cc:951
CSS_FONT_WEIGHT_BOLD
Definition: css.hh:255
dw::core::style::StyleAttrs::left
Color * left
Definition: style.hh:512
StyleImageDeletionReceiver::~StyleImageDeletionReceiver
~StyleImageDeletionReceiver()
Definition: styleengine.cc:49
CSS_PROPERTY_BORDER_TOP_STYLE
Definition: css.hh:164
a_Bw_add_client
void a_Bw_add_client(BrowserWindow *bw, int Key, int Root)
Definition: bw.c:123
CSS_PROPERTY_BORDER_LEFT_STYLE
Definition: css.hh:157
dGethomedir
char * dGethomedir()
Definition: dlib.c:904
CSS_LENGTH_TYPE_EX
Definition: css.hh:83
CSS_LENGTH_TYPE_NONE
Definition: css.hh:78
StyleEngine::setId
void setId(const char *id)
Definition: styleengine.cc:156
CSS_PROPERTY_BORDER_RIGHT_COLOR
Definition: css.hh:159
prefs
DilloPrefs prefs
Definition: prefs.c:31
dw::core::style::StyleAttrs::hBorderSpacing
int hBorderSpacing
Definition: style.hh:507
html_common.hh
CSS_FONT_SIZE_SMALL
Definition: css.hh:266
DilloPrefs::font_cursive
char * font_cursive
Definition: prefs.h:97
dw::core::style::FONT_VARIANT_NORMAL
Definition: style.hh:331
Dstr
Definition: dlib.h:102
dw::core::style::Box::top
int top
Definition: style.hh:467
dw::core::style::StyleAttrs::x_tooltip
Tooltip * x_tooltip
Definition: style.hh:523
DilloPrefs::font_sans_serif
char * font_sans_serif
Definition: prefs.h:96
dw::core::style::StyleAttrs::textDecoration
int textDecoration
Definition: style.hh:493
CssBackgroundPosition::posX
int32_t posX
Definition: css.hh:238
dw::core::style::ListStylePosition
ListStylePosition
Definition: style.hh:295
a_Url_dup
DilloUrl * a_Url_dup(const DilloUrl *ori)
Definition: url.c:422
CSS_PROPERTY_BACKGROUND_IMAGE
Definition: css.hh:149
CSS_PROPERTY_FONT_FAMILY
Definition: css.hh:179
dw::core::style::StyleAttrs::borderWidth
Box borderWidth
Definition: style.hh:510
StyleEngine::wordStyle0
dw::core::style::Style * wordStyle0(BrowserWindow *bw)
Definition: styleengine.cc:887
PROPERTY_X_LANG
Definition: css.hh:231
CSS_PROPERTY_VERTICAL_ALIGN
Definition: css.hh:221
a_Misc_file2dstr
Dstr * a_Misc_file2dstr(const char *filename)
Definition: misc.c:464
dw::core::style::TextTransform
TextTransform
Definition: style.hh:265
dw::core::style::DISPLAY_NONE
Definition: style.hh:280
CSS_PROPERTY_BACKGROUND_POSITION
Definition: css.hh:150
dw::core::style::Font::xHeight
int xHeight
Definition: style.hh:675
CssContext
A set of CssStyleSheets.
Definition: css.hh:504
dw::core::style::StyleAttrs::font
Font * font
Definition: style.hh:492
a_Bw_add_url
void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
Definition: bw.c:204
DilloPrefs::font_max_size
int32_t font_max_size
Definition: prefs.h:72
lout::signal::ObservedObject
An observed object has a signal emitter, which tells the receivers, when the object is deleted.
Definition: signal.hh:274
StyleEngine::StyleEngine
StyleEngine(dw::core::Layout *layout, const DilloUrl *pageUrl, const DilloUrl *baseUrl)
Definition: styleengine.cc:61
dw::core::style::StyleAttrs::wordSpacing
int wordSpacing
Definition: style.hh:507
CSS_PROPERTY_BORDER_SPACING
Definition: css.hh:162
dw::core::style::StyleAttrs::bottom
Color * bottom
Definition: style.hh:512
dw::core::style::Length
int Length
Type for representing all lengths within dw::core::style.
Definition: style.hh:389
CSS_PROPERTY_MARGIN_BOTTOM
Definition: css.hh:193
StyleEngine::Node::nonCssProperties
CssPropertyList * nonCssProperties
Definition: styleengine.hh:25
CSS_PROPERTY_WIDTH
Definition: css.hh:224
dw::core::style::StyleAttrs::backgroundImage
StyleImage * backgroundImage
Definition: style.hh:496
dw::core::style::StyleAttrs::x_img
int x_img
Definition: style.hh:522
StyleEngine::startElement
void startElement(int tag, BrowserWindow *bw)
tell the styleEngine that a new html element has started.
Definition: styleengine.cc:139
CssPropertyValue::intVal
int32_t intVal
Definition: css.hh:243
CSS_PROPERTY_LINE_HEIGHT
Definition: css.hh:189
dw::core::style::FontVariant
FontVariant
Definition: style.hh:330
CSS_PROPERTY_CURSOR
Definition: css.hh:174
CSS_PROPERTY_BORDER_COLLAPSE
Definition: css.hh:155
CssPropertyList
A list of CssProperty objects.
Definition: css.hh:312
dw::core::style::StyleAttrs::color
Color * color
Definition: style.hh:495
dw::core::style::StyleAttrs::x_link
int x_link
Definition: style.hh:521
dw::core::style::DisplayType
DisplayType
Definition: style.hh:275
dw::core::style::StyleAttrs
Definition: style.hh:489
capi.h
dw::core::style::FontAttrs::size
int size
Definition: style.hh:642
CSS_ORIGIN_USER
Definition: css.hh:19
StyleEngine::Node
Definition: styleengine.hh:22
lout::misc::roundInt
int roundInt(double d)
Definition: misc.hh:41
dw::core::style::Box::bottom
int bottom
Definition: style.hh:467
web.hh
DoctreeNode::pseudo
const char * pseudo
Definition: doctree.hh:14
DilloPrefs::font_min_size
int32_t font_min_size
Definition: prefs.h:73
CSS_PROPERTY_MARGIN_LEFT
Definition: css.hh:194
dStrdup
char * dStrdup(const char *s)
Definition: dlib.c:75
StyleEngine::backgroundColor
dw::core::style::Color * backgroundColor()
Definition: styleengine.cc:245
StyleEngine::Node::style
dw::core::style::Style * style
Definition: styleengine.hh:26
MSG_WARN
#define MSG_WARN(...)
Definition: msg.h:27
CSS_LENGTH_TYPE_PERCENTAGE
Definition: css.hh:84
StyleEngine::parse
void parse(DilloHtml *html, DilloUrl *url, const char *buf, int buflen, CssOrigin origin)
Definition: styleengine.cc:933
dw::core::style
Anything related to Dillo Widget styles is defined here.
Definition: style.cc:35
lout::signal::ObservedObject::DeletionReceiver
Definition: signal.hh:277
StyleEngine::computeValue
bool computeValue(int *dest, CssLength value, dw::core::style::Font *font)
Resolve relative lengths to absolute values.
Definition: styleengine.cc:745
CSS_PROPERTY_LIST_STYLE_TYPE
Definition: css.hh:192
dw::core::style::StyleAttrs::backgroundPositionX
Length backgroundPositionX
Definition: style.hh:499
CssPropertyValue::posVal
CssBackgroundPosition * posVal
Definition: css.hh:245
StyleEngine::style0
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...
Definition: styleengine.cc:850
dw::core::style::StyleAttrs::textIndent
Length textIndent
Definition: style.hh:508
dw::core::style::BackgroundRepeat
BackgroundRepeat
Definition: style.hh:234
a_Html_tag_index
int a_Html_tag_index(const char *tag)
Definition: html.cc:3621
CSS_PROPERTY_TEXT_DECORATION
Definition: css.hh:215
DilloUrl
Definition: url.h:91
dw::core::style::Box::left
int left
Definition: style.hh:467
CSS_LENGTH_TYPE_AUTO
Definition: css.hh:87
lout::misc::SimpleVector
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
Definition: misc.hh:71
dw::core::style::FontAttrs::fontVariant
FontVariant fontVariant
Definition: style.hh:645
dw::core::style::Style
Definition: style.hh:571
CSS_FONT_SIZE_LARGE
Definition: css.hh:263
CSS_PROPERTY_PADDING_TOP
Definition: css.hh:210
DilloPrefs::font_serif
char * font_serif
Definition: prefs.h:95
a_Image_new
DilloImage * a_Image_new(void *layout, void *img_rndr, int32_t bg_color)
Definition: image.cc:33
dw::core::style::BORDER_HIDDEN
Definition: style.hh:223
dw::core::style::StyleAttrs::valign
VAlignType valign
Definition: style.hh:503
dw::core::style::ListStyleType
ListStyleType
Definition: style.hh:300
StyleEngine::setPseudoLink
void setPseudoLink()
set the CSS pseudo class :link.
Definition: styleengine.cc:279
dw::core::style::createAbsLength
Length createAbsLength(int n)
Returns a length of n pixels.
Definition: style.hh:392
CSS_LENGTH_VALUE
float CSS_LENGTH_VALUE(CssLength l)
Definition: css.hh:126
CSS_PROPERTY_FONT_STYLE
Definition: css.hh:183
DilloPrefs::font_factor
double font_factor
Definition: prefs.h:71
DilloPrefs::white_bg_replacement
int32_t white_bg_replacement
Definition: prefs.h:51
dw::core::style::BORDER_NONE
Definition: style.hh:222
dw::core::style::StyleImage
Definition: style.hh:740
PROPERTY_X_TOOLTIP
Definition: css.hh:233
CSS_FONT_SIZE_X_LARGE
Definition: css.hh:270
dStrstrip
char * dStrstrip(char *s)
Definition: dlib.c:120
CSS_PROPERTY_WHITE_SPACE
Definition: css.hh:223
CSS_LENGTH_TYPE_MM
Definition: css.hh:80