# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# html_blockimpl.cpp

    00001
    00024 // -------------------------------------------------------------------------
    00025 //#define DEBUG
    00026 #include "html_blockimpl.h"
    00027 #include "html_documentimpl.h"
    00028 #include "css/cssstyleselector.h"
    00029
    00030 #include "css/cssproperties.h"
    00031 #include "css/cssvalues.h"
    00032 #include "misc/htmlhashes.h"
    00033
    00034 #include <kdebug.h>
    00035
    00036 using namespace khtml;
    00037 using namespace DOM;
    00038
    00039 void HTMLDivElementImpl::parseAttribute(AttributeImpl *attr)
    00040 {
    00041     switch(attr->id())
    00042     {
    00043     case ATTR_ALIGN:
    00044     {
    00045         DOMString v = attr->value();
    00046         if ( strcasecmp( attr->value(), "center" ) == 0 )
    00047             v = "-konq-center";
    00048         addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
    00049         break;
    00050     }
    00051     default:
    00052         HTMLElementImpl::parseAttribute(attr);
    00053     }
    00054 }
    00055
    00056 // -------------------------------------------------------------------------
    00057
    00058 NodeImpl::Id HTMLHRElementImpl::id() const
    00059 {
    00060     return ID_HR;
    00061 }
    00062
    00063 void HTMLHRElementImpl::parseAttribute(AttributeImpl *attr)
    00064 {
    00065     switch( attr->id() )
    00066     {
    00067     case ATTR_ALIGN:
    00068         if ( strcasecmp( attr->value(), "left") != 0) // _not_ equal
    00069             addCSSProperty(CSS_PROP_MARGIN_LEFT, CSS_VAL_AUTO);
    00070         else
    00071             addCSSProperty(CSS_PROP_MARGIN_LEFT, "1px");
    00072         if( strcasecmp( attr->value(), "right") != 0)
    00073             addCSSProperty(CSS_PROP_MARGIN_RIGHT, CSS_VAL_AUTO);
    00074         else
    00075             addCSSProperty(CSS_PROP_MARGIN_RIGHT, "1px");
    00076         break;
    00077     case ATTR_WIDTH:
    00078     {
    00079         if(!attr->val()) break;
    00080         // cheap hack to cause linebreaks
    00081         // khtmltests/html/strange_hr.html
    00082         bool ok;
    00083         int v = attr->val()->toInt(&ok);
    00084         if(ok && !v)
    00085             addCSSLength(CSS_PROP_WIDTH, "1");
    00086         else
    00087             addCSSLength(CSS_PROP_WIDTH, attr->value());
    00088     }
    00089     break;
    00090     default:
    00091         HTMLElementImpl::parseAttribute(attr);
    00092     }
    00093 }
    00094
    00095 // ### make sure we undo what we did during detach
    00096 void HTMLHRElementImpl::attach()
    00097 {
    00098     if (attributes(true /* readonly */)) {
    00099         // there are some attributes, lets check
    00100         DOMString color = getAttribute(ATTR_COLOR);
    00101         DOMStringImpl* si = getAttribute(ATTR_SIZE).implementation();
    00102         int _s =  si ? si->toInt() : -1;
    00103         DOMString n("1");
    00104         if (!color.isNull()) {
    00105             addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
    00106             addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
    00107             addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
    00108             addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
    00109             addCSSProperty(CSS_PROP_BORDER_TOP_WIDTH, DOMString("0"));
    00110             addCSSLength(CSS_PROP_BORDER_BOTTOM_WIDTH, DOMString(si));
    00111             addCSSProperty(CSS_PROP_BORDER_COLOR, color);
    00112         }
    00113         else {
    00114             if (_s > 1 && getAttribute(ATTR_NOSHADE).isNull()) {
    00115                 addCSSProperty(CSS_PROP_BORDER_BOTTOM_WIDTH, n);
    00116                 addCSSProperty(CSS_PROP_BORDER_TOP_WIDTH, n);
    00117                 addCSSProperty(CSS_PROP_BORDER_LEFT_WIDTH, n);
    00118                 addCSSProperty(CSS_PROP_BORDER_RIGHT_WIDTH, n);
    00119                 addCSSLength(CSS_PROP_HEIGHT, DOMString(QString::number(_s-2)));
    00120             }
    00121             else if (_s >= 0) {
    00122                 addCSSProperty(CSS_PROP_BORDER_TOP_WIDTH, DOMString(QString::number(_s)));
    00123                 addCSSProperty(CSS_PROP_BORDER_BOTTOM_WIDTH, DOMString("0"));
    00124             }
    00125         }
    00126         if (_s == 0)
    00127             addCSSProperty(CSS_PROP_MARGIN_BOTTOM, n);
    00128     }
    00129
    00130     HTMLElementImpl::attach();
    00131 }
    00132
    00133 // -------------------------------------------------------------------------
    00134
    00135 long HTMLPreElementImpl::width() const
    00136 {
    00137     // ###
    00138     return 0;
    00139 }
    00140
    00141 void HTMLPreElementImpl::setWidth( long /*w*/ )
    00142 {
    00143     // ###
    00144 }
    00145
    00146

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:33:50 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001