diff options
-rw-r--r-- | src/css.cc | 70 | ||||
-rw-r--r-- | src/css.hh | 3 | ||||
-rw-r--r-- | src/styleengine.cc | 68 | ||||
-rw-r--r-- | src/styleengine.hh | 2 |
4 files changed, 70 insertions, 73 deletions
@@ -11,11 +11,9 @@ #include <stdio.h> #include "../dlib/dlib.h" -#include "misc.h" #include "msg.h" #include "html_common.hh" #include "css.hh" -#include "cssparser.hh" using namespace dw::core::style; @@ -500,9 +498,6 @@ void CssStyleSheet::apply (CssPropertyList *props, CssContext::CssContext () { pos = 0; - - buildUserAgentStyle (); - buildUserStyle (); } /** @@ -547,68 +542,3 @@ void CssContext::addRule (CssSelector *sel, CssPropertyList *props, sheet[order].addRule (rule); } } - -/** - * \brief Create the user agent style. - * - * The user agent style defines how dillo renders HTML in the absence of - * author or user styles. - */ -void CssContext::buildUserAgentStyle () { - const char *cssBuf = - "body {margin: 5px}" - "big {font-size: 1.17em}" - "blockquote, dd {margin-left: 40px; margin-right: 40px}" - "center {text-align: center}" - "dt {font-weight: bolder}" - ":link {color: blue; text-decoration: underline; cursor: pointer}" - ":visited {color: #800080; text-decoration: underline; cursor: pointer}" - "h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder}" - "i, em, cite, address, var {font-style: italic}" - ":link img, :visited img {border: 1px solid}" - "frameset, ul, ol, dir {margin-left: 40px}" - "h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0}" - "h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0}" - "h3 {font-size: 1.17em; margin-top: .83em; margin-bottom: 0}" - "h4 {margin-top: 1.12em; margin-bottom: 0}" - "h5 {font-size: 0.83em; margin-top: 1.5em; margin-bottom: 0}" - "h6 {font-size: 0.75em; margin-top: 1.67em; margin-bottom: 0}" - "hr {width: 100%; border: 1px inset}" - "li {margin-top: 0.1em}" - "pre {white-space: pre}" - "ol {list-style-type: decimal}" - "ul {list-style-type: disc}" - "ul ul {list-style-type: circle}" - "ul ul ul {list-style-type: square}" - "ul ul ul ul {list-style-type: disc}" - "u {text-decoration: underline}" - "small, sub, sup {font-size: 0.83em}" - "sub {vertical-align: sub}" - "sup {vertical-align: super}" - "s, strike, del {text-decoration: line-through}" - "table {border-spacing: 2px}" - "td, th {padding: 2px}" - "thead, tbody, tfoot {vertical-align: middle}" - "th {font-weight: bolder; text-align: center}" - "code, tt, pre, samp, kbd {font-family: monospace}" - /* WORKAROUND: Reset font properties in tables as some - * pages rely on it (e.g. gmail). - * http://developer.mozilla.org/En/Fixing_Table_Inheritance_in_Quirks_Mode - * has a detailed description of the issue. - */ - "table, caption {font-size: medium; font-weight: normal}"; - - CssParser::parse (NULL, NULL, this, cssBuf, strlen (cssBuf), - CSS_ORIGIN_USER_AGENT); -} - -void CssContext::buildUserStyle () { - Dstr *style; - char *filename = dStrconcat(dGethomedir(), "/.dillo/style.css", NULL); - - if ((style = a_Misc_file2dstr(filename))) { - CssParser::parse (NULL,NULL,this,style->str, style->len,CSS_ORIGIN_USER); - dStr_free (style, 1); - } - dFree (filename); -} @@ -461,9 +461,6 @@ class CssContext { CssStyleSheet sheet[CSS_PRIMARY_USER_IMPORTANT + 1]; int pos; - void buildUserAgentStyle (); - void buildUserStyle (); - public: CssContext (); diff --git a/src/styleengine.cc b/src/styleengine.cc index 3f674dec..7ca398a9 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -12,6 +12,7 @@ #include "../dlib/dlib.h" #include "msg.h" #include "prefs.h" +#include "misc.h" #include "html_common.hh" #include "styleengine.hh" @@ -25,6 +26,8 @@ StyleEngine::StyleEngine (dw::core::Layout *layout) { doctree = new Doctree (); stack = new lout::misc::SimpleVector <Node> (1); cssContext = new CssContext (); + buildUserAgentStyle (); + buildUserStyle (); this->layout = layout; importDepth = 0; @@ -807,3 +810,68 @@ void StyleEngine::parse (DilloHtml *html, DilloUrl *url, const char *buf, CssParser::parse (html, url, cssContext, buf, buflen, origin); importDepth--; } + +/** + * \brief Create the user agent style. + * + * The user agent style defines how dillo renders HTML in the absence of + * author or user styles. + */ +void StyleEngine::buildUserAgentStyle () { + const char *cssBuf = + "body {margin: 5px}" + "big {font-size: 1.17em}" + "blockquote, dd {margin-left: 40px; margin-right: 40px}" + "center {text-align: center}" + "dt {font-weight: bolder}" + ":link {color: blue; text-decoration: underline; cursor: pointer}" + ":visited {color: #800080; text-decoration: underline; cursor: pointer}" + "h1, h2, h3, h4, h5, h6, b, strong {font-weight: bolder}" + "i, em, cite, address, var {font-style: italic}" + ":link img, :visited img {border: 1px solid}" + "frameset, ul, ol, dir {margin-left: 40px}" + "h1 {font-size: 2em; margin-top: .67em; margin-bottom: 0}" + "h2 {font-size: 1.5em; margin-top: .75em; margin-bottom: 0}" + "h3 {font-size: 1.17em; margin-top: .83em; margin-bottom: 0}" + "h4 {margin-top: 1.12em; margin-bottom: 0}" + "h5 {font-size: 0.83em; margin-top: 1.5em; margin-bottom: 0}" + "h6 {font-size: 0.75em; margin-top: 1.67em; margin-bottom: 0}" + "hr {width: 100%; border: 1px inset}" + "li {margin-top: 0.1em}" + "pre {white-space: pre}" + "ol {list-style-type: decimal}" + "ul {list-style-type: disc}" + "ul ul {list-style-type: circle}" + "ul ul ul {list-style-type: square}" + "ul ul ul ul {list-style-type: disc}" + "u {text-decoration: underline}" + "small, sub, sup {font-size: 0.83em}" + "sub {vertical-align: sub}" + "sup {vertical-align: super}" + "s, strike, del {text-decoration: line-through}" + "table {border-spacing: 2px}" + "td, th {padding: 2px}" + "thead, tbody, tfoot {vertical-align: middle}" + "th {font-weight: bolder; text-align: center}" + "code, tt, pre, samp, kbd {font-family: monospace}" + /* WORKAROUND: Reset font properties in tables as some + * pages rely on it (e.g. gmail). + * http://developer.mozilla.org/En/Fixing_Table_Inheritance_in_Quirks_Mode + * has a detailed description of the issue. + */ + "table, caption {font-size: medium; font-weight: normal}"; + + CssParser::parse (NULL, NULL, cssContext, cssBuf, strlen (cssBuf), + CSS_ORIGIN_USER_AGENT); +} + +void StyleEngine::buildUserStyle () { + Dstr *style; + char *filename = dStrconcat(dGethomedir(), "/.dillo/style.css", NULL); + + if ((style = a_Misc_file2dstr(filename))) { + CssParser::parse (NULL,NULL,cssContext,style->str, style->len,CSS_ORIGIN_USER); + dStr_free (style, 1); + } + dFree (filename); +} diff --git a/src/styleengine.hh b/src/styleengine.hh index b73a8b5f..7cca1475 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -36,6 +36,8 @@ class StyleEngine { Doctree *doctree; int importDepth; + void buildUserAgentStyle (); + void buildUserStyle (); dw::core::style::Style *style0 (int i); dw::core::style::Style *wordStyle0 (); inline void setNonCssHint(CssPropertyName name, CssValueType type, |