00001
00023 #include "css/cssstyleselector.h"
00024 #include "rendering/render_style.h"
00025 #include "css/css_stylesheetimpl.h"
00026 #include "css/css_ruleimpl.h"
00027 #include "css/css_valueimpl.h"
00028 #include "css/csshelper.h"
00029 #include "rendering/render_object.h"
00030 #include "html/html_documentimpl.h"
00031 #include "html/html_elementimpl.h"
00032 #include "xml/dom_elementimpl.h"
00033 #include "dom/css_rule.h"
00034 #include "dom/css_value.h"
00035 #include "khtml_factory.h"
00036 #include "khtmlpart_p.h"
00037 using namespace khtml;
00038 using namespace DOM;
00039
00040 #include "css/cssproperties.h"
00041 #include "css/cssvalues.h"
00042
00043 #include "misc/khtmllayout.h"
00044 #include "khtml_settings.h"
00045 #include "misc/htmlhashes.h"
00046 #include "misc/helper.h"
00047 #include "misc/loader.h"
00048
00049 #include "rendering/font.h"
00050
00051 #include "khtmlview.h"
00052 #include "khtml_part.h"
00053
00054 #include <kstandarddirs.h>
00055 #include <kcharsets.h>
00056 #include <kglobal.h>
00057 #include <kconfig.h>
00058 #include <qfile.h>
00059 #include <qvaluelist.h>
00060 #include <qstring.h>
00061 #include <qtooltip.h>
00062 #include <kdebug.h>
00063 #include <kurl.h>
00064 #include <assert.h>
00065 #include <qpaintdevicemetrics.h>
00066 #include <stdlib.h>
00067
00068 #define HANDLE_INHERIT(prop, Prop) \
00069 if (isInherit) \
00070 {\
00071 style->set##Prop(parentStyle->prop());\
00072 return;\
00073 }
00074
00075 #define HANDLE_INHERIT_AND_INITIAL(prop, Prop) \
00076 HANDLE_INHERIT(prop, Prop) \
00077 else if (isInitial) \
00078 style->set##Prop(RenderStyle::initial##Prop());
00079
00080 #define HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(prop, Prop, Value) \
00081 HANDLE_INHERIT(prop, Prop) \
00082 else if (isInitial) \
00083 style->set##Prop(RenderStyle::initial##Value());
00084
00085 #define HANDLE_INHERIT_COND(propID, prop, Prop) \
00086 if (id == propID) \
00087 {\
00088 style->set##Prop(parentStyle->prop());\
00089 return;\
00090 }
00091
00092 #define HANDLE_INITIAL_COND(propID, Prop) \
00093 if (id == propID) \
00094 {\
00095 style->set##Prop(RenderStyle::initial##Prop());\
00096 return;\
00097 }
00098
00099 #define HANDLE_INITIAL_COND_WITH_VALUE(propID, Prop, Value) \
00100 if (id == propID) \
00101 {\
00102 style->set##Prop(RenderStyle::initial##Value());\
00103 return;\
00104 }
00105
00106 namespace khtml {
00107
00108 CSSStyleSelectorList *CSSStyleSelector::s_defaultStyle;
00109 CSSStyleSelectorList *CSSStyleSelector::s_defaultQuirksStyle;
00110 CSSStyleSelectorList *CSSStyleSelector::s_defaultPrintStyle;
00111 CSSStyleSheetImpl *CSSStyleSelector::s_defaultSheet;
00112 RenderStyle* CSSStyleSelector::styleNotYetAvailable;
00113 CSSStyleSheetImpl *CSSStyleSelector::s_quirksSheet;
00114
00115 enum PseudoState { PseudoUnknown, PseudoNone, PseudoLink, PseudoVisited};
00116 static PseudoState pseudoState;
00117
00118
00119 CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, StyleSheetListImpl *styleSheets,
00120 const KURL &url, bool _strictParsing )
00121 {
00122 KHTMLView* view = doc->view();
00123
00124 init(view ? view->part()->settings() : 0);
00125
00126 strictParsing = _strictParsing;
00127 m_medium = view ? view->mediaType() : QString("all");
00128
00129 selectors = 0;
00130 selectorCache = 0;
00131 properties = 0;
00132 userStyle = 0;
00133 userSheet = 0;
00134 paintDeviceMetrics = doc->paintDeviceMetrics();
00135
00136 if(paintDeviceMetrics)
00137 computeFontSizes(paintDeviceMetrics, view ? view->part()->zoomFactor() : 100);
00138
00139 if ( !userStyleSheet.isEmpty() ) {
00140 userSheet = new DOM::CSSStyleSheetImpl(doc);
00141 userSheet->parseString( DOMString( userStyleSheet ) );
00142
00143 userStyle = new CSSStyleSelectorList();
00144 userStyle->append( userSheet, m_medium );
00145 }
00146
00147
00148 authorStyle = new CSSStyleSelectorList();
00149
00150
00151 QPtrListIterator<StyleSheetImpl> it( styleSheets->styleSheets );
00152 for ( ; it.current(); ++it ) {
00153 if ( it.current()->isCSSStyleSheet() ) {
00154 authorStyle->append( static_cast<CSSStyleSheetImpl*>( it.current() ), m_medium );
00155 }
00156 }
00157
00158 buildLists();
00159
00160
00161
00162
00163 KURL u = url;
00164
00165 u.setQuery( QString::null );
00166 u.setRef( QString::null );
00167 encodedurl.file = u.url();
00168 int pos = encodedurl.file.findRev('/');
00169 encodedurl.path = encodedurl.file;
00170 if ( pos > 0 ) {
00171 encodedurl.path.truncate( pos );
00172 encodedurl.path += '/';
00173 }
00174 u.setPath( QString::null );
00175 encodedurl.host = u.url();
00176
00177
00178 }
00179
00180 CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
00181 {
00182 init(0L);
00183
00184 KHTMLView *view = sheet->doc()->view();
00185 m_medium = view ? view->mediaType() : "screen";
00186
00187 authorStyle = new CSSStyleSelectorList();
00188 authorStyle->append( sheet, m_medium );
00189 }
00190
00191 void CSSStyleSelector::init(const KHTMLSettings* _settings)
00192 {
00193 element = 0;
00194 settings = _settings;
00195 paintDeviceMetrics = 0;
00196 propsToApply = (CSSOrderedProperty **)malloc(128*sizeof(CSSOrderedProperty *));
00197 pseudoProps = (CSSOrderedProperty **)malloc(128*sizeof(CSSOrderedProperty *));
00198 propsToApplySize = 128;
00199 pseudoPropsSize = 128;
00200 if(!s_defaultStyle) loadDefaultStyle(settings);
00201
00202 defaultStyle = s_defaultStyle;
00203 defaultPrintStyle = s_defaultPrintStyle;
00204 defaultQuirksStyle = s_defaultQuirksStyle;
00205 }
00206
00207 CSSStyleSelector::~CSSStyleSelector()
00208 {
00209 clearLists();
00210 delete authorStyle;
00211 delete userStyle;
00212 delete userSheet;
00213 free(propsToApply);
00214 free(pseudoProps);
00215 }
00216
00217 void CSSStyleSelector::addSheet( CSSStyleSheetImpl *sheet )
00218 {
00219 KHTMLView *view = sheet->doc()->view();
00220 m_medium = view ? view->mediaType() : "screen";
00221 authorStyle->append( sheet, m_medium );
00222 }
00223
00224 void CSSStyleSelector::loadDefaultStyle(const KHTMLSettings *s)
00225 {
00226 if(s_defaultStyle) return;
00227
00228 {
00229 QFile f(locate( "data", "khtml/css/html4.css" ) );
00230 f.open(IO_ReadOnly);
00231
00232 QCString file( f.size()+1 );
00233 int readbytes = f.readBlock( file.data(), f.size() );
00234 f.close();
00235 if ( readbytes >= 0 )
00236 file[readbytes] = '\0';
00237
00238 QString style = QString::fromLatin1( file.data() );
00239 if(s)
00240 style += s->settingsToCSS();
00241 DOMString str(style);
00242
00243 s_defaultSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl * ) 0);
00244 s_defaultSheet->parseString( str );
00245
00246
00247 s_defaultStyle = new CSSStyleSelectorList();
00248 s_defaultStyle->append( s_defaultSheet, "screen" );
00249
00250 s_defaultPrintStyle = new CSSStyleSelectorList();
00251 s_defaultPrintStyle->append( s_defaultSheet, "print" );
00252 }
00253 {
00254 QFile f(locate( "data", "khtml/css/quirks.css" ) );
00255 f.open(IO_ReadOnly);
00256
00257 QCString file( f.size()+1 );
00258 int readbytes = f.readBlock( file.data(), f.size() );
00259 f.close();
00260 if ( readbytes >= 0 )
00261 file[readbytes] = '\0';
00262
00263 QString style = QString::fromLatin1( file.data() );
00264 DOMString str(style);
00265
00266 s_quirksSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl * ) 0);
00267 s_quirksSheet->parseString( str );
00268
00269
00270 s_defaultQuirksStyle = new CSSStyleSelectorList();
00271 s_defaultQuirksStyle->append( s_quirksSheet, "screen" );
00272 }
00273
00274
00275 }
00276
00277 void CSSStyleSelector::clear()
00278 {
00279 delete s_defaultStyle;
00280 delete s_defaultQuirksStyle;
00281 delete s_defaultPrintStyle;
00282 delete s_defaultSheet;
00283 delete styleNotYetAvailable;
00284 s_defaultStyle = 0;
00285 s_defaultQuirksStyle = 0;
00286 s_defaultPrintStyle = 0;
00287 s_defaultSheet = 0;
00288 styleNotYetAvailable = 0;
00289 }
00290
00291 void CSSStyleSelector::reparseConfiguration()
00292 {
00293
00294 s_defaultStyle = 0;
00295 s_defaultQuirksStyle = 0;
00296 s_defaultPrintStyle = 0;
00297 s_defaultSheet = 0;
00298 }
00299
00300 #define MAXFONTSIZES 15
00301
00302 void CSSStyleSelector::computeFontSizes(QPaintDeviceMetrics* paintDeviceMetrics, int zoomFactor)
00303 {
00304 computeFontSizesFor(paintDeviceMetrics, zoomFactor, m_fontSizes, false);
00305 computeFontSizesFor(paintDeviceMetrics, zoomFactor, m_fixedFontSizes, true);
00306 }
00307
00308 void CSSStyleSelector::computeFontSizesFor(QPaintDeviceMetrics* paintDeviceMetrics, int zoomFactor, QValueList<int>& fontSizes, bool isFixed)
00309 {
00310 #ifdef APPLE_CHANGES
00311
00312 const float toPix = 1;
00313 #else
00314 Q_UNUSED( isFixed );
00315
00316
00317 float toPix = paintDeviceMetrics->logicalDpiY()/72.;
00318 if (toPix < 96./72.) toPix = 96./72.;
00319 #endif // ######### fix isFixed code again.
00320
00321 fontSizes.clear();
00322 const float factor = 1.2;
00323 float scale = 1.0 / (factor*factor*factor);
00324 float mediumFontSize;
00325 float minFontSize;
00326 if (!khtml::printpainter) {
00327 scale *= zoomFactor / 100.0;
00328 #ifdef APPLE_CHANGES
00329 if (isFixed)
00330 mediumFontSize = settings->mediumFixedFontSize() * toPix;
00331 else
00332 #endif
00333 mediumFontSize = settings->mediumFontSize() * toPix;
00334 minFontSize = settings->minFontSize() * toPix;
00335 }
00336 else {
00337
00338 mediumFontSize = 12;
00339 minFontSize = 6;
00340 }
00341
00342 for ( int i = 0; i < MAXFONTSIZES; i++ ) {
00343 fontSizes << int(KMAX( mediumFontSize * scale + 0.5f, minFontSize));
00344 scale *= factor;
00345 }
00346 }
00347
00348 #undef MAXFONTSIZES
00349
00350 static inline void bubbleSort( CSSOrderedProperty **b, CSSOrderedProperty **e )
00351 {
00352 while( b < e ) {
00353 bool swapped = false;
00354 CSSOrderedProperty **y = e+1;
00355 CSSOrderedProperty **x = e;
00356 CSSOrderedProperty **swappedPos = 0;
00357 do {
00358 if ( !((**(--x)) < (**(--y))) ) {
00359 swapped = true;
00360 swappedPos = x;
00361 CSSOrderedProperty *tmp = *y;
00362 *y = *x;
00363 *x = tmp;
00364 }
00365 } while( x != b );
00366 if ( !swapped ) break;
00367 b = swappedPos + 1;
00368 }
00369 }
00370
00371 RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e)
00372 {
00373 if (!e->getDocument()->haveStylesheetsLoaded() || !e->getDocument()->view()) {
00374 if (!styleNotYetAvailable) {
00375 styleNotYetAvailable = new RenderStyle();
00376 styleNotYetAvailable->setDisplay(NONE);
00377 styleNotYetAvailable->ref();
00378 }
00379 return styleNotYetAvailable;
00380 }
00381
00382
00383 pseudoState = PseudoUnknown;
00384
00385 element = e;
00386 parentNode = e->parentNode();
00387 parentStyle = ( parentNode && parentNode->renderer()) ? parentNode->renderer()->style() : 0;
00388 view = element->getDocument()->view();
00389 part = view->part();
00390 settings = part->settings();
00391 paintDeviceMetrics = element->getDocument()->paintDeviceMetrics();
00392
00393 style = new RenderStyle();
00394 if( parentStyle )
00395 style->inheritFrom( parentStyle );
00396 else
00397 parentStyle = style;
00398
00399 unsigned int numPropsToApply = 0;
00400 unsigned int numPseudoProps = 0;
00401
00402
00403 int cssTagId = (e->id() & NodeImpl_IdLocalMask);
00404 int smatch = 0;
00405 int schecked = 0;
00406
00407 for ( unsigned int i = 0; i < selectors_size; i++ ) {
00408 int tag = selectors[i]->tag & NodeImpl_IdLocalMask;
00409 if ( cssTagId == tag || tag == 0xffff ) {
00410 ++schecked;
00411
00412 checkSelector( i, e );
00413
00414 if ( selectorCache[i].state == Applies ) {
00415 ++smatch;
00416
00417
00418 for ( unsigned int p = 0; p < selectorCache[i].props_size; p += 2 )
00419 for ( unsigned int j = 0; j < (unsigned int )selectorCache[i].props[p+1]; ++j ) {
00420 if (numPropsToApply >= propsToApplySize ) {
00421 propsToApplySize *= 2;
00422 propsToApply = (CSSOrderedProperty **)realloc( propsToApply, propsToApplySize*sizeof( CSSOrderedProperty * ) );
00423 }
00424 propsToApply[numPropsToApply++] = properties[selectorCache[i].props[p]+j];
00425 }
00426 } else if ( selectorCache[i].state == AppliesPseudo ) {
00427 for ( unsigned int p = 0; p < selectorCache[i].props_size; p += 2 )
00428 for ( unsigned int j = 0; j < (unsigned int) selectorCache[i].props[p+1]; ++j ) {
00429 if (numPseudoProps >= pseudoPropsSize ) {
00430 pseudoPropsSize *= 2;
00431 pseudoProps = (CSSOrderedProperty **)realloc( pseudoProps, pseudoPropsSize*sizeof( CSSOrderedProperty * ) );
00432 }
00433 pseudoProps[numPseudoProps++] = properties[selectorCache[i].props[p]+j];
00434 properties[selectorCache[i].props[p]+j]->pseudoId = (RenderStyle::PseudoId) selectors[i]->pseudoId;
00435 }
00436 }
00437 }
00438 else
00439 selectorCache[i].state = Invalid;
00440
00441 }
00442
00443
00444
00445 numPropsToApply = addInlineDeclarations( e, e->m_styleDecls, numPropsToApply );
00446
00447
00448
00449
00450
00451 bubbleSort( propsToApply, propsToApply+numPropsToApply-1 );
00452 bubbleSort( pseudoProps, pseudoProps+numPseudoProps-1 );
00453
00454
00455
00456 if ( part ) {
00457 fontDirty = false;
00458
00459 if (numPropsToApply ) {
00460 CSSStyleSelector::style = style;
00461 for (unsigned int i = 0; i < numPropsToApply; ++i) {
00462 if ( fontDirty && propsToApply[i]->priority >= (1 << 30) ) {
00463
00464
00465 #ifdef APPLE_CHANGES
00466 checkForGenericFamilyChange(style, parentStyle);
00467 #endif
00468 CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
00469 fontDirty = false;
00470 }
00471 DOM::CSSProperty *prop = propsToApply[i]->prop;
00472
00473
00474 applyRule( prop->m_id, prop->value() );
00475 }
00476 if ( fontDirty ) {
00477 #ifdef APPLE_CHANGES
00478 checkForGenericFamilyChange(style, parentStyle);
00479 #endif
00480 CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
00481 }
00482 }
00483
00484
00485 adjustRenderStyle(style, e);
00486
00487 if ( numPseudoProps ) {
00488 fontDirty = false;
00489
00490 for (unsigned int i = 0; i < numPseudoProps; ++i) {
00491 if ( fontDirty && pseudoProps[i]->priority >= (1 << 30) ) {
00492
00493
00494
00495 RenderStyle *pseudoStyle = style->pseudoStyle;
00496 while ( pseudoStyle ) {
00497 pseudoStyle->htmlFont().update( paintDeviceMetrics );
00498 pseudoStyle = pseudoStyle->pseudoStyle;
00499 }
00500 fontDirty = false;
00501 }
00502
00503 RenderStyle *pseudoStyle;
00504 pseudoStyle = style->getPseudoStyle(pseudoProps[i]->pseudoId);
00505 if (!pseudoStyle)
00506 {
00507 pseudoStyle = style->addPseudoStyle(pseudoProps[i]->pseudoId);
00508 if (pseudoStyle)
00509 pseudoStyle->inheritFrom( style );
00510 }
00511
00512 RenderStyle* oldStyle = style;
00513 RenderStyle* oldParentStyle = parentStyle;
00514 parentStyle = style;
00515 style = pseudoStyle;
00516 if ( pseudoStyle ) {
00517 DOM::CSSProperty *prop = pseudoProps[i]->prop;
00518 applyRule( prop->m_id, prop->value() );
00519 }
00520 style = oldStyle;
00521 parentStyle = oldParentStyle;
00522 }
00523
00524 if ( fontDirty ) {
00525 RenderStyle *pseudoStyle = style->pseudoStyle;
00526 while ( pseudoStyle ) {
00527 pseudoStyle->htmlFont().update( paintDeviceMetrics );
00528 pseudoStyle = pseudoStyle->pseudoStyle;
00529 }
00530 }
00531 }
00532 }
00533
00534
00535 RenderStyle *pseudoStyle = style->pseudoStyle;
00536 while (pseudoStyle) {
00537 adjustRenderStyle(pseudoStyle, 0);
00538 pseudoStyle = pseudoStyle->pseudoStyle;
00539 }
00540
00541
00542 return style;
00543 }
00544
00545 void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, DOM::ElementImpl *e)
00546 {
00547 #ifdef APPLE_CHANGES
00548
00549 style->setOriginalDisplay(style->display());
00550 #endif
00551
00552 if (style->display() != NONE) {
00553
00554
00555
00556
00557 if (!strictParsing && e) {
00558 if (e->id() == ID_TD) {
00559 style->setDisplay(TABLE_CELL);
00560 style->setFloating(FNONE);
00561 }
00562
00563
00564 }
00565
00566
00567
00568
00569
00570 if (style->display() != BLOCK && style->display() != TABLE &&
00571 (style->position() == ABSOLUTE || style->position() == FIXED || style->floating() != FNONE ||
00572 (e && e->getDocument()->documentElement() == e))) {
00573 if (style->display() == INLINE_TABLE)
00574 style->setDisplay(TABLE);
00575
00576
00577 else if (style->display() == LIST_ITEM) {
00578
00579
00580 if (!strictParsing && style->floating() != FNONE)
00581 style->setDisplay(BLOCK);
00582 }
00583 else
00584 style->setDisplay(BLOCK);
00585 }
00586
00587
00588
00589
00590 if (style->display() == TABLE_ROW && style->position() == RELATIVE)
00591 style->setPosition(STATIC);
00592 }
00593
00594
00595
00596 if ( e ) {
00597
00598 if ( e->id() == ID_FRAME ) {
00599 style->setPosition( STATIC );
00600 style->setDisplay( BLOCK );
00601 }
00602 else if ( e->id() == ID_FRAMESET ) {
00603 style->setPosition( STATIC );
00604 }
00605 }
00606
00607
00608
00609 if (style->display() == TABLE || style->display() == INLINE_TABLE || style->display() == RUN_IN
00610 || style->display() == INLINE_BLOCK )
00611 style->setTextDecorationsInEffect(style->textDecoration());
00612 else
00613 style->addToTextDecorationsInEffect(style->textDecoration());
00614 }
00615
00616 unsigned int CSSStyleSelector::addInlineDeclarations(DOM::ElementImpl* e,
00617 DOM::CSSStyleDeclarationImpl *decl,
00618 unsigned int numProps)
00619 {
00620 CSSStyleDeclarationImpl* addDecls = 0;
00621 #ifdef APPLE_CHANGES
00622 if (e->id() == ID_TD || e->id() == ID_TH)
00623 addDecls = e->getAdditionalStyleDecls();
00624 #else
00625 Q_UNUSED( e );
00626 #endif
00627
00628 if (!decl && !addDecls)
00629 return numProps;
00630
00631 QPtrList<CSSProperty>* values = decl ? decl->values() : 0;
00632 QPtrList<CSSProperty>* addValues = addDecls ? addDecls->values() : 0;
00633 if (!values && !addValues)
00634 return numProps;
00635
00636 int firstLen = values ? values->count() : 0;
00637 int secondLen = addValues ? addValues->count() : 0;
00638 int totalLen = firstLen + secondLen;
00639
00640 if (inlineProps.size() < (uint)totalLen)
00641 inlineProps.resize(totalLen + 1);
00642
00643 if (numProps + totalLen >= propsToApplySize ) {
00644 propsToApplySize += propsToApplySize;
00645 propsToApply = (CSSOrderedProperty **)realloc( propsToApply, propsToApplySize*sizeof( CSSOrderedProperty * ) );
00646 }
00647
00648 CSSOrderedProperty *array = (CSSOrderedProperty *)inlineProps.data();
00649 for(int i = 0; i < totalLen; i++)
00650 {
00651 if (i == firstLen)
00652 values = addValues;
00653
00654 CSSProperty *prop = values->at(i >= firstLen ? i - firstLen : i);
00655 Source source = Inline;
00656
00657 if( prop->m_bImportant ) source = InlineImportant;
00658 if( prop->nonCSSHint ) source = NonCSSHint;
00659
00660 bool first;
00661
00662 switch(prop->m_id)
00663 {
00664 case CSS_PROP_FONT_STYLE:
00665 case CSS_PROP_FONT_SIZE:
00666 case CSS_PROP_FONT_WEIGHT:
00667 case CSS_PROP_FONT_FAMILY:
00668 case CSS_PROP_FONT:
00669 case CSS_PROP_COLOR:
00670 case CSS_PROP_BACKGROUND_IMAGE:
00671 case CSS_PROP_DISPLAY:
00672
00673
00674 first = true;
00675 break;
00676 default:
00677 first = false;
00678 break;
00679 }
00680
00681 array->prop = prop;
00682 array->pseudoId = RenderStyle::NOPSEUDO;
00683 array->selector = 0;
00684 array->position = i;
00685 array->priority = (!first << 30) | (source << 24);
00686 propsToApply[numProps++] = array++;
00687 }
00688 return numProps;
00689 }
00690
00691 static bool subject;
00692
00693
00694 static void cleanpath(QString &path)
00695 {
00696 int pos;
00697 while ( (pos = path.find( "/../" )) != -1 ) {
00698 int prev = 0;
00699 if ( pos > 0 )
00700 prev = path.findRev( "/", pos -1 );
00701
00702 if (prev < 0 || (prev > 3 && path.findRev("://", prev-1) == prev-2))
00703 path.remove( pos, 3);
00704 else
00705
00706 path.remove( prev, pos- prev + 3 );
00707 }
00708 pos = 0;
00709
00710
00711
00712
00713
00714 int refPos = -2;
00715 while ( (pos = path.find( "//", pos )) != -1) {
00716 if (refPos == -2)
00717 refPos = path.find("#", 0);
00718 if (refPos > 0 && pos >= refPos)
00719 break;
00720
00721 if ( pos == 0 || path[pos-1] != ':' )
00722 path.remove( pos, 1 );
00723 else
00724 pos += 2;
00725 }
00726 while ( (pos = path.find( "/./" )) != -1)
00727 path.remove( pos, 2 );
00728
00729 }
00730
00731 static void checkPseudoState( const CSSStyleSelector::Encodedurl& encodedurl, DOM::ElementImpl *e )
00732 {
00733 if( e->id() != ID_A ) {
00734 pseudoState = PseudoNone;
00735 return;
00736 }
00737 DOMString attr = e->getAttribute(ATTR_HREF);
00738 if( attr.isNull() ) {
00739 pseudoState = PseudoNone;
00740 return;
00741 }
00742 QConstString cu(attr.unicode(), attr.length());
00743 QString u = cu.string();
00744 if ( !u.contains("://") ) {
00745 if ( u[0] == '/' )
00746 u = encodedurl.host + u;
00747 else if ( u[0] == '#' )
00748 u = encodedurl.file + u;
00749 else
00750 u = encodedurl.path + u;
00751 cleanpath( u );
00752 }
00753
00754 pseudoState = KHTMLFactory::vLinks()->contains( u ) ? PseudoVisited : PseudoLink;
00755 }
00756
00757 void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e)
00758 {
00759 dynamicPseudo = RenderStyle::NOPSEUDO;
00760
00761 NodeImpl *n = e;
00762
00763 selectorCache[ selIndex ].state = Invalid;
00764 CSSSelector *sel = selectors[ selIndex ];
00765
00766
00767 subject = true;
00768
00769
00770
00771
00772 bool onlyHoverActive = (((sel->tag & NodeImpl_IdLocalMask) == NodeImpl_IdLocalMask) &&
00773 (sel->match == CSSSelector::Pseudo &&
00774 (sel->pseudoType() == CSSSelector::PseudoHover ||
00775 sel->pseudoType() == CSSSelector::PseudoActive)));
00776 bool affectedByHover = style->affectedByHoverRules();
00777 bool affectedByActive = style->affectedByActiveRules();
00778
00779
00780 if(!checkOneSelector(sel, e)) return;
00781
00782
00783 CSSSelector::Relation relation = sel->relation;
00784 while((sel = sel->tagHistory))
00785 {
00786 if(!n->isElementNode()) return;
00787 switch(relation)
00788 {
00789 case CSSSelector::Descendant:
00790 {
00791 bool found = false;
00792 while(!found)
00793 {
00794 subject = false;
00795 n = n->parentNode();
00796 if(!n || !n->isElementNode()) return;
00797 ElementImpl *elem = static_cast<ElementImpl *>(n);
00798 if(checkOneSelector(sel, elem)) found = true;
00799 }
00800 break;
00801 }
00802 case CSSSelector::Child:
00803 {
00804 subject = false;
00805 n = n->parentNode();
00806 if (!strictParsing)
00807 while (n && n->implicitNode()) n = n->parentNode();
00808 if(!n || !n->isElementNode()) return;
00809 ElementImpl *elem = static_cast<ElementImpl *>(n);
00810 if(!checkOneSelector(sel, elem)) return;
00811 break;
00812 }
00813 case CSSSelector::Sibling:
00814 {
00815 subject = false;
00816 n = n->previousSibling();
00817 while( n && !n->isElementNode() )
00818 n = n->previousSibling();
00819 if( !n ) return;
00820 ElementImpl *elem = static_cast<ElementImpl *>(n);
00821 if(!checkOneSelector(sel, elem)) return;
00822 break;
00823 }
00824 case CSSSelector::SubSelector:
00825 {
00826 if (onlyHoverActive)
00827 onlyHoverActive = (sel->match == CSSSelector::Pseudo &&
00828 (sel->pseudoType() == CSSSelector::PseudoHover ||
00829 sel->pseudoType() == CSSSelector::PseudoActive));
00830
00831
00832 ElementImpl *elem = static_cast<ElementImpl *>(n);
00833
00834 if ( dynamicPseudo != RenderStyle::NOPSEUDO ) {
00835 return;
00836 }
00837 if(!checkOneSelector(sel, elem)) return;
00838
00839 break;
00840 }
00841 }
00842 relation = sel->relation;
00843 }
00844
00845
00846 if (onlyHoverActive && subject) {
00847 if (pseudoState == PseudoUnknown)
00848 checkPseudoState( encodedurl, e );
00849
00850 if (pseudoState == PseudoNone) {
00851 if (!affectedByHover && style->affectedByHoverRules())
00852 style->setAffectedByHoverRules(false);
00853 if (!affectedByActive && style->affectedByActiveRules())
00854 style->setAffectedByActiveRules(false);
00855 return;
00856 }
00857 }
00858
00859 if ( dynamicPseudo != RenderStyle::NOPSEUDO ) {
00860 selectorCache[selIndex].state = AppliesPseudo;
00861 selectors[ selIndex ]->pseudoId = dynamicPseudo;
00862 } else
00863 selectorCache[ selIndex ].state = Applies;
00864
00865
00866 return;
00867 }
00868
00869 bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl *e)
00870 {
00871 if(!e)
00872 return false;
00873
00874 unsigned int element_id = e->id();
00875 if ( (sel->tag & NodeImpl_IdNSMask) == NodeImpl_IdNSMask ) {
00876
00877 unsigned int sel_id = sel->tag & NodeImpl_IdLocalMask;
00878 if ( (element_id & NodeImpl_IdLocalMask) != sel_id &&
00879 sel_id != NodeImpl_IdLocalMask )
00880 return false;
00881 } else {
00882
00883 if( (element_id & NodeImpl_IdNSMask) != (sel->tag & NodeImpl_IdNSMask) )
00884 return false;
00885 if ( element_id != sel->tag &&
00886 (sel->tag & NodeImpl_IdLocalMask) != NodeImpl_IdLocalMask )
00887 return false;
00888 }
00889
00890 if(sel->attr)
00891 {
00892 unsigned int attr_id = sel->attr;
00893 if ( (attr_id & NodeImpl_IdNSMask ) == NodeImpl_IdNSMask ) {
00894
00895
00896
00897
00898
00899
00900
00901
00902 attr_id &= NodeImpl_IdLocalMask;
00903 }
00904 DOMString value = e->getAttribute(attr_id);
00905 if(value.isNull()) return false;
00906
00907 switch(sel->match)
00908 {
00909 case CSSSelector::Exact:
00910 case CSSSelector::Id:
00911 if( (strictParsing && strcmp(sel->value, value) ) ||
00912 (!strictParsing && strcasecmp(sel->value, value)))
00913 return false;
00914 break;
00915 case CSSSelector::Set:
00916 break;
00917 case CSSSelector::List:
00918 {
00919 int spacePos = value.find(' ', 0);
00920 if (spacePos == -1) {
00921
00922
00923
00924 if( (strictParsing && strcmp(sel->value, value) ) ||
00925 (!strictParsing && strcasecmp(sel->value, value)))
00926 return false;
00927 break;
00928 }
00929
00930
00931 spacePos = sel->value.find(' ');
00932 if (spacePos != -1)
00933 return false;
00934
00935 QString str = value.string();
00936 QString selStr = sel->value.string();
00937 const int selStrlen = selStr.length();
00938 int pos = 0;
00939 for ( ;; ) {
00940 pos = str.find(selStr, pos, strictParsing);
00941 if ( pos == -1 ) return false;
00942 if ( pos == 0 || str[pos-1] == ' ' ) {
00943 uint endpos = pos + selStrlen;
00944 if ( endpos >= str.length() || str[endpos] == ' ' )
00945 break;
00946 }
00947 ++pos;
00948 }
00949 break;
00950 }
00951 case CSSSelector::Contain:
00952 {
00953
00954 QString str = value.string();
00955 QString selStr = sel->value.string();
00956 int pos = str.find(selStr, 0, strictParsing);
00957 if(pos == -1) return false;
00958 break;
00959 }
00960 case CSSSelector::Begin:
00961 {
00962
00963 QString str = value.string();
00964 QString selStr = sel->value.string();
00965 int pos = str.find(selStr, 0, strictParsing);
00966 if(pos != 0) return false;
00967 break;
00968 }
00969 case CSSSelector::End:
00970 {
00971
00972 QString str = value.string();
00973 QString selStr = sel->value.string();
00974 if (strictParsing && !str.endsWith(selStr)) return false;
00975 if (!strictParsing) {
00976 int pos = str.length() - selStr.length();
00977 if (pos < 0 || pos != str.find(selStr, pos, false) )
00978 return false;
00979 }
00980 break;
00981 }
00982 case CSSSelector::Hyphen:
00983 {
00984
00985 QString str = value.string();
00986 QString selStr = sel->value.string();
00987 if(str.length() < selStr.length()) return false;
00988
00989 if(str.find(selStr, 0, strictParsing) != 0) return false;
00990
00991 if(str.length() != selStr.length()
00992 && str[selStr.length()] != '-') return false;
00993 break;
00994 }
00995 case CSSSelector::Pseudo:
00996 case CSSSelector::None:
00997 break;
00998 }
00999 }
01000 if(sel->match == CSSSelector::Pseudo)
01001 {
01002
01003
01004
01005 switch (sel->pseudoType()) {
01006 case CSSSelector::PseudoEmpty:
01007 if (!e->firstChild())
01008 return true;
01009 break;
01010 case CSSSelector::PseudoFirstChild: {
01011
01012 if (e->parentNode() && e->parentNode()->isElementNode()) {
01013 DOM::NodeImpl* n = e->previousSibling();
01014 while ( n && !n->isElementNode() )
01015 n = n->previousSibling();
01016 if ( !n )
01017 return true;
01018 }
01019 break;
01020 }
01021 case CSSSelector::PseudoLastChild: {
01022
01023 if (e->parentNode() && e->parentNode()->isElementNode()) {
01024 DOM::NodeImpl* n = e->nextSibling();
01025 while ( n && !n->isElementNode() )
01026 n = n->nextSibling();
01027 if ( !n )
01028 return true;
01029 }
01030 break;
01031 }
01032 case CSSSelector::PseudoOnlyChild: {
01033
01034 if (e->parentNode() && e->parentNode()->isElementNode()) {
01035 DOM::NodeImpl* n = e->previousSibling();
01036 while ( n && !n->isElementNode() )
01037 n = n->previousSibling();
01038 if ( !n ) {
01039 n = e->nextSibling();
01040 while ( n && !n->isElementNode() )
01041 n = n->nextSibling();
01042 if ( !n )
01043 return true;
01044 }
01045 }
01046 break;
01047 }
01048 case CSSSelector::PseudoFirstLine:
01049 if ( subject ) {
01050 dynamicPseudo=RenderStyle::FIRST_LINE;
01051 return true;
01052 }
01053 break;
01054 case CSSSelector::PseudoFirstLetter:
01055 if ( subject ) {
01056 dynamicPseudo=RenderStyle::FIRST_LETTER;
01057 return true;
01058 }
01059 break;
01060 case CSSSelector::PseudoTarget:
01061 #ifdef APPLE_CHANGES
01062 if (!e->getDocument()->getCSSTarget() &&
01063 e == e->getDocument()->documentElement())
01064 return true;
01065 if (e == e->getDocument()->getCSSTarget())
01066 return true;
01067 #endif
01068 break;
01069 case CSSSelector::PseudoLink:
01070 if ( pseudoState == PseudoUnknown )
01071 checkPseudoState( encodedurl, e );
01072 if ( pseudoState == PseudoLink )
01073 return true;
01074 break;
01075 case CSSSelector::PseudoVisited:
01076 if ( pseudoState == PseudoUnknown )
01077 checkPseudoState( encodedurl, e );
01078 if ( pseudoState == PseudoVisited )
01079 return true;
01080 break;
01081 case CSSSelector::PseudoHover: {
01082
01083
01084 if (strictParsing || e->id() != ID_A || e->hasAnchor()) {
01085 if (element == e)
01086 style->setAffectedByHoverRules(true);
01087 if (e->renderer()) {
01088 if (element != e)
01089 e->renderer()->style()->setAffectedByHoverRules(true);
01090 if (e->renderer()->mouseInside())
01091 return true;
01092 }
01093 }
01094 break;
01095 }
01096 case CSSSelector::PseudoFocus:
01097 if (e && e->focused()) {
01098 return true;
01099 }
01100 break;
01101 case CSSSelector::PseudoActive:
01102
01103
01104 if (strictParsing || e->id() != ID_A || e->hasAnchor()) {
01105 if (element == e)
01106 style->setAffectedByActiveRules(true);
01107 else if (e->renderer())
01108 e->renderer()->style()->setAffectedByActiveRules(true);
01109 if (e->active())
01110 return true;
01111 }
01112 break;
01113 case CSSSelector::PseudoRoot:
01114 if (e == e->getDocument()->documentElement())
01115 return true;
01116 break;
01117 case CSSSelector::PseudoNot: {
01118
01119 for (CSSSelector* subSel = sel->simpleSelector; subSel;
01120 subSel = subSel->tagHistory) {
01121
01122
01123 if (subSel->simpleSelector)
01124 break;
01125 if (!checkOneSelector(subSel, e))
01126 return true;
01127 }
01128 break;
01129 }
01130 case CSSSelector::PseudoSelection:
01131 dynamicPseudo = RenderStyle::SELECTION;
01132 return true;
01133 case CSSSelector::PseudoBefore:
01134 dynamicPseudo = RenderStyle::BEFORE;
01135 return true;
01136 case CSSSelector::PseudoAfter:
01137 dynamicPseudo = RenderStyle::AFTER;
01138 return true;
01139
01140 case CSSSelector::PseudoNotParsed:
01141 assert(false);
01142 break;
01143 case CSSSelector::PseudoLang:
01144
01145 case CSSSelector::PseudoOther:
01146 break;
01147 }
01148 return false;
01149 }
01150
01151 return true;
01152 }
01153
01154 void CSSStyleSelector::clearLists()
01155 {
01156 delete [] selectors;
01157 if ( selectorCache ) {
01158 for ( unsigned int i = 0; i < selectors_size; i++ )
01159 delete [] selectorCache[i].props;
01160
01161 delete [] selectorCache;
01162 }
01163 if ( properties ) {
01164 CSSOrderedProperty **prop = properties;
01165 while ( *prop ) {
01166 delete (*prop);
01167 prop++;
01168 }
01169 delete [] properties;
01170 }
01171 selectors = 0;
01172 properties = 0;
01173 selectorCache = 0;
01174 }
01175
01176
01177 void CSSStyleSelector::buildLists()
01178 {
01179 clearLists();
01180
01181
01182 QPtrList<CSSSelector> selectorList;
01183 CSSOrderedPropertyList propertyList;
01184
01185 if(m_medium == "print" && defaultPrintStyle)
01186 defaultPrintStyle->collect( &selectorList, &propertyList, Default,
01187 Default );
01188 else if(defaultStyle) defaultStyle->collect( &selectorList, &propertyList,
01189 Default, Default );
01190
01191 if (!strictParsing && defaultQuirksStyle)
01192 defaultQuirksStyle->collect( &selectorList, &propertyList, Default, Default );
01193
01194 if(userStyle) userStyle->collect(&selectorList, &propertyList, User, UserImportant );
01195 if(authorStyle) authorStyle->collect(&selectorList, &propertyList, Author, AuthorImportant );
01196
01197 selectors_size = selectorList.count();
01198 selectors = new CSSSelector *[selectors_size];
01199 CSSSelector *s = selectorList.first();
01200 CSSSelector **sel = selectors;
01201 while ( s ) {
01202 *sel = s;
01203 s = selectorList.next();
01204 ++sel;
01205 }
01206
01207 selectorCache = new SelectorCache[selectors_size];
01208 for ( unsigned int i = 0; i < selectors_size; i++ ) {
01209 selectorCache[i].state = Unknown;
01210 selectorCache[i].props_size = 0;
01211 selectorCache[i].props = 0;
01212 }
01213
01214
01215 propertyList.sort();
01216 properties_size = propertyList.count() + 1;
01217 properties = new CSSOrderedProperty *[ properties_size ];
01218 CSSOrderedProperty *p = propertyList.first();
01219 CSSOrderedProperty **prop = properties;
01220 while ( p ) {
01221 *prop = p;
01222 p = propertyList.next();
01223 ++prop;
01224 }
01225 *prop = 0;
01226
01227 unsigned int* offsets = new unsigned int[selectors_size];
01228 if(properties[0])
01229 offsets[properties[0]->selector] = 0;
01230 for(unsigned int p = 1; p < properties_size; ++p) {
01231
01232 if(!properties[p] || (properties[p]->selector != properties[p - 1]->selector)) {
01233 unsigned int sel = properties[p - 1]->selector;
01234 int* newprops = new int[selectorCache[sel].props_size+2];
01235 for ( unsigned int i=0; i < selectorCache[sel].props_size; i++ )
01236 newprops[i] = selectorCache[sel].props[i];
01237
01238 newprops[selectorCache[sel].props_size] = offsets[sel];
01239 newprops[selectorCache[sel].props_size+1] = p - offsets[sel];
01240 delete [] selectorCache[sel].props;
01241 selectorCache[sel].props = newprops;
01242 selectorCache[sel].props_size += 2;
01243
01244 if(properties[p]) {
01245 sel = properties[p]->selector;
01246 offsets[sel] = p;
01247 }
01248 }
01249 }
01250 delete [] offsets;
01251
01252
01253 #if 0
01254
01255 for ( unsigned int sel = 0; sel < selectors_size; ++sel ) {
01256 kdDebug( 6080 ) << "trying for sel: " << sel << endl;
01257 int len = 0;
01258 int offset = 0;
01259 bool matches = false;
01260 for ( unsigned int i = 0; i < selectors_size; i++ ) {
01261 int tag = selectors[i]->tag;
01262 if ( sel != tag && tag != -1 )
01263 selectorCache[i].state = Invalid;
01264 else
01265 selectorCache[i].state = Unknown;
01266
01267 if ( matches != ( selectorCache[i].state == Unknown ) ) {
01268 if ( matches ) {
01269 kdDebug( 6080 ) << "new: offs: " << offset << " len: " << len << endl;
01270 matches = false;
01271 }
01272 else {
01273 matches = true;
01274
01275 len = 0;
01276 }
01277 }
01278 ++len;
01279 }
01280 }
01281 #endif
01282 }
01283
01284
01285
01286
01287
01288 CSSOrderedRule::CSSOrderedRule(DOM::CSSStyleRuleImpl *r, DOM::CSSSelector *s, int _index)
01289 {
01290 rule = r;
01291 if(rule) r->ref();
01292 index = _index;
01293 selector = s;
01294 }
01295
01296 CSSOrderedRule::~CSSOrderedRule()
01297 {
01298 if(rule) rule->deref();
01299 }
01300
01301
01302
01303 CSSStyleSelectorList::CSSStyleSelectorList()
01304 : QPtrList<CSSOrderedRule>()
01305 {
01306 setAutoDelete(true);
01307 }
01308 CSSStyleSelectorList::~CSSStyleSelectorList()
01309 {
01310 }
01311
01312 void CSSStyleSelectorList::append( CSSStyleSheetImpl *sheet,
01313 const DOMString &medium )
01314 {
01315 if(!sheet || !sheet->isCSSStyleSheet()) return;
01316
01317
01318
01319 if( sheet->media() && !sheet->media()->contains( medium ) )
01320 return;
01321
01322 int len = sheet->length();
01323
01324 for(int i = 0; i< len; i++)
01325 {
01326 StyleBaseImpl *item = sheet->item(i);
01327 if(item->isStyleRule())
01328 {
01329 CSSStyleRuleImpl *r = static_cast<CSSStyleRuleImpl *>(item);
01330 QPtrList<CSSSelector> *s = r->selector();
01331 for(int j = 0; j < (int)s->count(); j++)
01332 {
01333 CSSOrderedRule *rule = new CSSOrderedRule(r, s->at(j), count());
01334 QPtrList<CSSOrderedRule>::append(rule);
01335
01336 }
01337 }
01338 else if(item->isImportRule())
01339 {
01340 CSSImportRuleImpl *import = static_cast<CSSImportRuleImpl *>(item);
01341
01342
01343
01344
01345 if( !import->media() || import->media()->contains( medium ) )
01346 {
01347 CSSStyleSheetImpl *importedSheet = import->styleSheet();
01348 append( importedSheet, medium );
01349 }
01350 }
01351 else if( item->isMediaRule() )
01352 {
01353 CSSMediaRuleImpl *r = static_cast<CSSMediaRuleImpl *>( item );
01354 CSSRuleListImpl *rules = r->cssRules();
01355
01356
01357
01358
01359
01360 if( ( !r->media() || r->media()->contains( medium ) ) && rules)
01361 {
01362
01363
01364
01365 for( unsigned j = 0; j < rules->length(); j++ )
01366 {
01367
01368
01369 CSSRuleImpl *childItem = rules->item( j );
01370 if( childItem->isStyleRule() )
01371 {
01372
01373 CSSStyleRuleImpl *styleRule =
01374 static_cast<CSSStyleRuleImpl *>( childItem );
01375
01376 QPtrList<CSSSelector> *s = styleRule->selector();
01377 for( int j = 0; j < ( int ) s->count(); j++ )
01378 {
01379 CSSOrderedRule *orderedRule = new CSSOrderedRule(
01380 styleRule, s->at( j ), count() );
01381 QPtrList<CSSOrderedRule>::append( orderedRule );
01382 }
01383 }
01384 else
01385 {
01386
01387
01388 }
01389 }
01390 }
01391 else
01392 {
01393
01394
01395 }
01396 }
01397
01398 }
01399 }
01400
01401
01402 void CSSStyleSelectorList::collect( QPtrList<CSSSelector> *selectorList, CSSOrderedPropertyList *propList,
01403 Source regular, Source important )
01404 {
01405 CSSOrderedRule *r = first();
01406 while( r ) {
01407 CSSSelector *sel = selectorList->first();
01408 int selectorNum = 0;
01409 while( sel ) {
01410 if ( *sel == *(r->selector) )
01411 break;
01412 sel = selectorList->next();
01413 selectorNum++;
01414 }
01415 if ( !sel )
01416 selectorList->append( r->selector );
01417
01418
01419 propList->append(r->rule->declaration(), selectorNum, r->selector->specificity(), regular, important );
01420 r = next();
01421 }
01422 }
01423
01424
01425
01426 int CSSOrderedPropertyList::compareItems(QPtrCollection::Item i1, QPtrCollection::Item i2)
01427 {
01428 int diff = static_cast<CSSOrderedProperty *>(i1)->priority
01429 - static_cast<CSSOrderedProperty *>(i2)->priority;
01430 return diff ? diff : static_cast<CSSOrderedProperty *>(i1)->position
01431 - static_cast<CSSOrderedProperty *>(i2)->position;
01432 }
01433
01434 void CSSOrderedPropertyList::append(DOM::CSSStyleDeclarationImpl *decl, uint selector, uint specificity,
01435 Source regular, Source important )
01436 {
01437 QPtrList<CSSProperty> *values = decl->values();
01438 if(!values) return;
01439 int len = values->count();
01440 for(int i = 0; i < len; i++)
01441 {
01442 CSSProperty *prop = values->at(i);
01443 Source source = regular;
01444
01445 if( prop->m_bImportant ) source = important;
01446 if( prop->nonCSSHint ) source = NonCSSHint;
01447
01448 bool first = false;
01449
01450 switch(prop->m_id)
01451 {
01452 case CSS_PROP_FONT_STYLE:
01453 case CSS_PROP_FONT_SIZE:
01454 case CSS_PROP_FONT_WEIGHT:
01455 case CSS_PROP_FONT_FAMILY:
01456 case CSS_PROP_FONT:
01457 case CSS_PROP_COLOR:
01458 case CSS_PROP_BACKGROUND_IMAGE:
01459 case CSS_PROP_DISPLAY:
01460
01461
01462 first = true;
01463 break;
01464 default:
01465 break;
01466 }
01467
01468 QPtrList<CSSOrderedProperty>::append(new CSSOrderedProperty(prop, selector,
01469 first, source, specificity,
01470 count() ));
01471 }
01472 }
01473
01474
01475
01476
01477 static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyle *style, QPaintDeviceMetrics *paintDeviceMetrics, bool *ok = 0 )
01478 {
01479 Length l;
01480 if ( !primitiveValue ) {
01481 if ( ok )
01482 *ok = false;
01483 } else {
01484 int type = primitiveValue->primitiveType();
01485 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
01486 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
01487 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
01488 l = Length(int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)), Percent);
01489 else if(type == CSSPrimitiveValue::CSS_NUMBER)
01490 l = Length(int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
01491 else if (type == CSSPrimitiveValue::CSS_HTML_RELATIVE)
01492 l = Length(int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_HTML_RELATIVE)), Relative);
01493 else if ( ok )
01494 *ok = false;
01495 }
01496 return l;
01497 }
01498
01499
01500
01501 struct colorMap {
01502 int css_value;
01503 QRgb color;
01504 };
01505
01506 static const colorMap cmap[] = {
01507 { CSS_VAL_AQUA, 0xFF00FFFF },
01508 { CSS_VAL_BLACK, 0xFF000000 },
01509 { CSS_VAL_BLUE, 0xFF0000FF },
01510 { CSS_VAL_CRIMSON, 0xFFDC143C },
01511 { CSS_VAL_FUCHSIA, 0xFFFF00FF },
01512 { CSS_VAL_GRAY, 0xFF808080 },
01513 { CSS_VAL_GREEN, 0xFF008000 },
01514 { CSS_VAL_INDIGO, 0xFF4B0082 },
01515 { CSS_VAL_LIME, 0xFF00FF00 },
01516 { CSS_VAL_MAROON, 0xFF800000 },
01517 { CSS_VAL_NAVY, 0xFF000080 },
01518 { CSS_VAL_OLIVE, 0xFF808000 },
01519 { CSS_VAL_ORANGE, 0xFFFFA500 },
01520 { CSS_VAL_PURPLE, 0xFF800080 },
01521 { CSS_VAL_RED, 0xFFFF0000 },
01522 { CSS_VAL_SILVER, 0xFFC0C0C0 },
01523 { CSS_VAL_TEAL, 0xFF008080 },
01524 { CSS_VAL_WHITE, 0xFFFFFFFF },
01525 { CSS_VAL_YELLOW, 0xFFFFFF00 },
01526 { CSS_VAL_INVERT, invertedColor },
01527 { CSS_VAL_GREY, 0xff808080 },
01528 { 0, 0 }
01529 };
01530
01531 struct uiColors {
01532 int css_value;
01533 const char * configGroup;
01534 const char * configEntry;
01535 QPalette::ColorGroup group;
01536 QColorGroup::ColorRole role;
01537 };
01538
01539 const char * const wmgroup = "WM";
01540 const char * const generalgroup = "General";
01541
01542
01543
01544
01545 static const uiColors uimap[] = {
01546
01547 { CSS_VAL_ACTIVEBORDER, wmgroup, "background", QPalette::Active, QColorGroup::Light },
01548
01549 { CSS_VAL_ACTIVECAPTION, wmgroup, "background", QPalette::Active, QColorGroup::Text },
01550
01551 { CSS_VAL_CAPTIONTEXT, wmgroup, "activeForeground", QPalette::Active, QColorGroup::Text },
01552
01553 { CSS_VAL_BUTTONFACE, wmgroup, 0, QPalette::Inactive, QColorGroup::Button },
01554
01555 { CSS_VAL_BUTTONHIGHLIGHT, wmgroup, 0, QPalette::Inactive, QColorGroup::Light },
01556
01557 { CSS_VAL_BUTTONSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Shadow },
01558
01559 { CSS_VAL_BUTTONTEXT, wmgroup, "buttonForeground", QPalette::Inactive, QColorGroup::ButtonText },
01560
01561 { CSS_VAL_THREEDDARKSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Dark },
01562
01563 { CSS_VAL_THREEDFACE, wmgroup, 0, QPalette::Inactive, QColorGroup::Button },
01564
01565 { CSS_VAL_THREEDHIGHLIGHT, wmgroup, 0, QPalette::Inactive, QColorGroup::Light },
01566
01567 { CSS_VAL_THREEDLIGHTSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Midlight },
01568
01569 { CSS_VAL_THREEDSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Shadow },
01570
01571
01572 { CSS_VAL_INACTIVEBORDER, wmgroup, "background", QPalette::Disabled, QColorGroup::Background },
01573
01574 { CSS_VAL_INACTIVECAPTION, wmgroup, "inactiveBackground", QPalette::Disabled, QColorGroup::Background },
01575
01576 { CSS_VAL_INACTIVECAPTIONTEXT, wmgroup, "inactiveForeground", QPalette::Disabled, QColorGroup::Text },
01577 { CSS_VAL_GRAYTEXT, wmgroup, 0, QPalette::Disabled, QColorGroup::Text },
01578
01579
01580 { CSS_VAL_MENU, generalgroup, "background", QPalette::Inactive, QColorGroup::Background },
01581
01582 { CSS_VAL_MENUTEXT, generalgroup, "foreground", QPalette::Inactive, QColorGroup::Background },
01583
01584
01585 { CSS_VAL_HIGHLIGHT, generalgroup, "selectBackground", QPalette::Inactive, QColorGroup::Background },
01586
01587
01588 { CSS_VAL_HIGHLIGHTTEXT, generalgroup, "selectForeground", QPalette::Inactive, QColorGroup::Background },
01589
01590
01591 { CSS_VAL_APPWORKSPACE, generalgroup, "background", QPalette::Inactive, QColorGroup::Text },
01592
01593
01594 { CSS_VAL_SCROLLBAR, generalgroup, "background", QPalette::Inactive, QColorGroup::Background },
01595
01596
01597 { CSS_VAL_WINDOW, generalgroup, "windowBackground", QPalette::Inactive, QColorGroup::Background },
01598
01599 { CSS_VAL_WINDOWFRAME, generalgroup, "windowBackground", QPalette::Inactive, QColorGroup::Background },
01600
01601 { CSS_VAL_WINDOWTEXT, generalgroup, "windowForeground", QPalette::Inactive, QColorGroup::Text },
01602 { CSS_VAL_TEXT, generalgroup, 0, QPalette::Inactive, QColorGroup::Text },
01603 { 0, 0, 0, QPalette::NColorGroups, QColorGroup::NColorRoles }
01604 };
01605
01606 static QColor colorForCSSValue( int css_value )
01607 {
01608
01609 const colorMap *col = cmap;
01610 while ( col->css_value && col->css_value != css_value )
01611 ++col;
01612 if ( col->css_value )
01613 return col->color;
01614
01615 const uiColors *uicol = uimap;
01616 while ( uicol->css_value && uicol->css_value != css_value )
01617 ++uicol;
01618 #ifndef APPLE_CHANGES
01619 if ( !uicol->css_value ) {
01620 if ( css_value == CSS_VAL_INFOBACKGROUND )
01621 return QToolTip::palette().inactive().background();
01622 else if ( css_value == CSS_VAL_INFOTEXT )
01623 return QToolTip::palette().inactive().foreground();
01624 else if ( css_value == CSS_VAL_BACKGROUND ) {
01625 KConfig bckgrConfig("kdesktoprc", true, false);
01626 bckgrConfig.setGroup("Desktop0");
01627
01628 return bckgrConfig.readColorEntry("Color1", &qApp->palette().disabled().background());
01629 }
01630 return QColor();
01631 }
01632 #endif
01633
01634 const QPalette &pal = qApp->palette();
01635 QColor c = pal.color( uicol->group, uicol->role );
01636 #ifndef APPLE_CHANGES
01637 if ( uicol->configEntry ) {
01638 KConfig *globalConfig = KGlobal::config();
01639 globalConfig->setGroup( uicol->configGroup );
01640 c = globalConfig->readColorEntry( uicol->configEntry, &c );
01641 }
01642 #endif
01643
01644 return c;
01645 }
01646
01647
01648 void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
01649 {
01650
01651
01652 CSSPrimitiveValueImpl *primitiveValue = 0;
01653 if(value->isPrimitiveValue()) primitiveValue = static_cast<CSSPrimitiveValueImpl *>(value);
01654
01655 Length l;
01656 bool apply = false;
01657
01658 bool isInherit = (parentNode && value->cssValueType() == CSSValue::CSS_INHERIT);
01659 bool isInitial = (value->cssValueType() == CSSValue::CSS_INITIAL) ||
01660 (!parentNode && value->cssValueType() == CSSValue::CSS_INHERIT);
01661
01662
01663
01664
01665 switch(id)
01666 {
01667
01668 case CSS_PROP_BACKGROUND_ATTACHMENT:
01669 HANDLE_INHERIT_AND_INITIAL(backgroundAttachment, BackgroundAttachment)
01670 if(!primitiveValue) break;
01671 switch(primitiveValue->getIdent())
01672 {
01673 case CSS_VAL_FIXED:
01674 {
01675 style->setBackgroundAttachment(false);
01676
01677 if( style->backgroundImage() )
01678 view->useSlowRepaints();
01679 break;
01680 }
01681 case CSS_VAL_SCROLL:
01682 style->setBackgroundAttachment(true);
01683 break;
01684 default:
01685 return;
01686 }
01687 case CSS_PROP_BACKGROUND_REPEAT:
01688 {
01689 HANDLE_INHERIT_AND_INITIAL(backgroundRepeat, BackgroundRepeat)
01690 if(!primitiveValue) return;
01691 switch(primitiveValue->getIdent())
01692 {
01693 case CSS_VAL_REPEAT:
01694 style->setBackgroundRepeat( REPEAT );
01695 break;
01696 case CSS_VAL_REPEAT_X:
01697 style->setBackgroundRepeat( REPEAT_X );
01698 break;
01699 case CSS_VAL_REPEAT_Y:
01700 style->setBackgroundRepeat( REPEAT_Y );
01701 break;
01702 case CSS_VAL_NO_REPEAT:
01703 style->setBackgroundRepeat( NO_REPEAT );
01704 break;
01705 default:
01706 return;
01707 }
01708 }
01709 case CSS_PROP_BORDER_COLLAPSE:
01710 HANDLE_INHERIT_AND_INITIAL(borderCollapse, BorderCollapse)
01711 if(!primitiveValue) break;
01712 switch(primitiveValue->getIdent())
01713 {
01714 case CSS_VAL_COLLAPSE:
01715 style->setBorderCollapse(true);
01716 break;
01717 case CSS_VAL_SEPARATE:
01718 style->setBorderCollapse(false);
01719 break;
01720 default:
01721 return;
01722 }
01723 break;
01724
01725 case CSS_PROP_BORDER_TOP_STYLE:
01726 HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderTopStyle, BorderTopStyle, BorderStyle)
01727 if (!primitiveValue) return;
01728 style->setBorderTopStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
01729 break;
01730 case CSS_PROP_BORDER_RIGHT_STYLE:
01731 HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderRightStyle, BorderRightStyle, BorderStyle)
01732 if (!primitiveValue) return;
01733 style->setBorderRightStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
01734 break;
01735 case CSS_PROP_BORDER_BOTTOM_STYLE:
01736 HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderBottomStyle, BorderBottomStyle, BorderStyle)
01737 if (!primitiveValue) return;
01738 style->setBorderBottomStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
01739 break;
01740 case CSS_PROP_BORDER_LEFT_STYLE:
01741 HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(borderLeftStyle, BorderLeftStyle, BorderStyle)
01742 if (!primitiveValue) return;
01743 style->setBorderLeftStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
01744 break;
01745 case CSS_PROP_OUTLINE_STYLE:
01746 HANDLE_INHERIT_AND_INITIAL_WITH_VALUE(outlineStyle, OutlineStyle, BorderStyle)
01747 if (!primitiveValue) return;
01748 style->setOutlineStyle((EBorderStyle)(primitiveValue->getIdent() - CSS_VAL_NONE));
01749 break;
01750 case CSS_PROP_CAPTION_SIDE:
01751 {
01752 HANDLE_INHERIT_AND_INITIAL(captionSide, CaptionSide)
01753 if(!primitiveValue) break;
01754 ECaptionSide c = RenderStyle::initialCaptionSide();
01755 switch(primitiveValue->getIdent())
01756 {
01757 case CSS_VAL_TOP:
01758 c = CAPTOP; break;
01759 case CSS_VAL_BOTTOM:
01760 c = CAPBOTTOM; break;
01761 default:
01762 return;
01763 }
01764 style->setCaptionSide(c);
01765 return;
01766 }
01767 case CSS_PROP_CLEAR:
01768 {
01769 HANDLE_INHERIT_AND_INITIAL(clear, Clear)
01770 if(!primitiveValue) break;
01771 EClear c = CNONE;
01772 switch(primitiveValue->getIdent())
01773 {
01774 case CSS_VAL_LEFT:
01775 c = CLEFT; break;
01776 case CSS_VAL_RIGHT:
01777 c = CRIGHT; break;
01778 case CSS_VAL_BOTH:
01779 c = CBOTH; break;
01780 case CSS_VAL_NONE:
01781 c = CNONE; break;
01782 default:
01783 return;
01784 }
01785 style->setClear(c);
01786 return;
01787 }
01788 case CSS_PROP_DIRECTION:
01789 {
01790 HANDLE_INHERIT_AND_INITIAL(direction, Direction)
01791 if(!primitiveValue) break;
01792 style->setDirection( (EDirection) (primitiveValue->getIdent() - CSS_VAL_LTR) );
01793 return;
01794 }
01795 case CSS_PROP_DISPLAY:
01796 {
01797 HANDLE_INHERIT_AND_INITIAL(display, Display)
01798 if(!primitiveValue) break;
01799 int id = primitiveValue->getIdent();
01800 style->setDisplay( id == CSS_VAL_NONE ? NONE : EDisplay(id - CSS_VAL_INLINE) );
01801 break;
01802 }
01803
01804 case CSS_PROP_EMPTY_CELLS:
01805 {
01806 HANDLE_INHERIT(emptyCells, EmptyCells);
01807 if (!primitiveValue) break;
01808 int id = primitiveValue->getIdent();
01809 if (id == CSS_VAL_SHOW)
01810 style->setEmptyCells(SHOW);
01811 else if (id == CSS_VAL_HIDE)
01812 style->setEmptyCells(HIDE);
01813 break;
01814 }
01815 case CSS_PROP_FLOAT:
01816 {
01817 HANDLE_INHERIT_AND_INITIAL(floating, Floating)
01818 if(!primitiveValue) return;
01819 EFloat f;
01820 switch(primitiveValue->getIdent())
01821 {
01822 case CSS_VAL_LEFT:
01823 f = FLEFT; break;
01824 case CSS_VAL_RIGHT:
01825 f = FRIGHT; break;
01826 case CSS_VAL_NONE:
01827 case CSS_VAL_CENTER:
01828 f = FNONE; break;
01829 default:
01830 return;
01831 }
01832 if (f!=FNONE && style->display()==LIST_ITEM)
01833 style->setDisplay(BLOCK);
01834
01835 style->setFloating(f);
01836 break;
01837 }
01838
01839 case CSS_PROP_FONT_STYLE:
01840 {
01841 FontDef fontDef = style->htmlFont().fontDef;
01842 if (isInherit)
01843 fontDef.italic = parentStyle->htmlFont().fontDef.italic;
01844 else if (isInitial)
01845 fontDef.italic = false;
01846 else {
01847 if(!primitiveValue) return;
01848 switch(primitiveValue->getIdent()) {
01849 case CSS_VAL_OBLIQUE:
01850
01851 case CSS_VAL_ITALIC:
01852 fontDef.italic = true;
01853 break;
01854 case CSS_VAL_NORMAL:
01855 fontDef.italic = false;
01856 break;
01857 default:
01858 return;
01859 }
01860 }
01861 fontDirty |= style->setFontDef( fontDef );
01862 break;
01863 }
01864
01865
01866 case CSS_PROP_FONT_VARIANT:
01867 {
01868 FontDef fontDef = style->htmlFont().fontDef;
01869 if (isInherit)
01870 fontDef.smallCaps = parentStyle->htmlFont().fontDef.weight;
01871 else if (isInitial)
01872 fontDef.smallCaps = false;
01873 else {
01874 if(!primitiveValue) return;
01875 int id = primitiveValue->getIdent();
01876 if ( id == CSS_VAL_NORMAL )
01877 fontDef.smallCaps = false;
01878 else if ( id == CSS_VAL_SMALL_CAPS )
01879 fontDef.smallCaps = true;
01880 else
01881 return;
01882 }
01883 fontDirty |= style->setFontDef( fontDef );
01884 break;
01885 }
01886
01887 case CSS_PROP_FONT_WEIGHT:
01888 {
01889 FontDef fontDef = style->htmlFont().fontDef;
01890 if (isInherit)
01891 fontDef.weight = parentStyle->htmlFont().fontDef.weight;
01892 else if (isInitial)
01893 fontDef.weight = QFont::Normal;
01894 else {
01895 if(!primitiveValue) return;
01896 if(primitiveValue->getIdent())
01897 {
01898 switch(primitiveValue->getIdent()) {
01899
01900
01901 case CSS_VAL_BOLD:
01902 case CSS_VAL_BOLDER:
01903 case CSS_VAL_600:
01904 case CSS_VAL_700:
01905 case CSS_VAL_800:
01906 case CSS_VAL_900:
01907 fontDef.weight = QFont::Bold;
01908 break;
01909 case CSS_VAL_NORMAL:
01910 case CSS_VAL_LIGHTER:
01911 case CSS_VAL_100:
01912 case CSS_VAL_200:
01913 case CSS_VAL_300:
01914 case CSS_VAL_400:
01915 case CSS_VAL_500:
01916 fontDef.weight = QFont::Normal;
01917 break;
01918 default:
01919 return;
01920 }
01921 }
01922 else
01923 {
01924
01925 }
01926 }
01927 fontDirty |= style->setFontDef( fontDef );
01928 break;
01929 }
01930
01931 case CSS_PROP_LIST_STYLE_POSITION:
01932 {
01933 HANDLE_INHERIT_AND_INITIAL(listStylePosition, ListStylePosition)
01934 if (!primitiveValue) return;
01935 if (primitiveValue->getIdent())
01936 style->setListStylePosition( (EListStylePosition) (primitiveValue->getIdent() - CSS_VAL_OUTSIDE) );
01937 return;
01938 }
01939
01940 case CSS_PROP_LIST_STYLE_TYPE:
01941 {
01942 HANDLE_INHERIT_AND_INITIAL(listStyleType, ListStyleType)
01943 if (!primitiveValue) return;
01944 if (primitiveValue->getIdent())
01945 {
01946 EListStyleType t;
01947 int id = primitiveValue->getIdent();
01948 if ( id == CSS_VAL_NONE) {
01949 t = LNONE;
01950 } else {
01951 t = EListStyleType(id - CSS_VAL_DISC);
01952 }
01953 style->setListStyleType(t);
01954 }
01955 return;
01956 }
01957
01958 case CSS_PROP_OVERFLOW:
01959 {
01960 HANDLE_INHERIT_AND_INITIAL(overflow, Overflow)
01961 if (!primitiveValue) return;
01962 EOverflow o;
01963 switch(primitiveValue->getIdent())
01964 {
01965 case CSS_VAL_VISIBLE:
01966 o = OVISIBLE; break;
01967 case CSS_VAL_HIDDEN:
01968 o = OHIDDEN; break;
01969 case CSS_VAL_SCROLL:
01970 o = OSCROLL; break;
01971 case CSS_VAL_AUTO:
01972 o = OAUTO;
01973 break;
01974 default:
01975 return;
01976 }
01977 style->setOverflow(o);
01978 return;
01979 }
01980 break;
01981 case CSS_PROP_PAGE_BREAK_AFTER:
01982 case CSS_PROP_PAGE_BREAK_BEFORE:
01983 case CSS_PROP_PAGE_BREAK_INSIDE:
01984
01985
01986 break;
01987
01988 case CSS_PROP_POSITION:
01989 {
01990 HANDLE_INHERIT_AND_INITIAL(position, Position)
01991 if (!primitiveValue) return;
01992 EPosition p;
01993 switch(primitiveValue->getIdent())
01994 {
01995 case CSS_VAL_STATIC:
01996 p = STATIC; break;
01997 case CSS_VAL_RELATIVE:
01998 p = RELATIVE; break;
01999 case CSS_VAL_ABSOLUTE:
02000 p = ABSOLUTE; break;
02001 case CSS_VAL_FIXED:
02002 {
02003 view->useSlowRepaints();
02004 p = FIXED;
02005 break;
02006 }
02007 default:
02008 return;
02009 }
02010 style->setPosition(p);
02011 return;
02012 }
02013
02014 case CSS_PROP_TABLE_LAYOUT: {
02015 HANDLE_INHERIT_AND_INITIAL(tableLayout, TableLayout)
02016
02017 if ( !primitiveValue )
02018 return;
02019
02020 ETableLayout l = RenderStyle::initialTableLayout();
02021 switch( primitiveValue->getIdent() ) {
02022 case CSS_VAL_FIXED:
02023 l = TFIXED;
02024
02025 case CSS_VAL_AUTO:
02026 style->setTableLayout( l );
02027 default:
02028 break;
02029 }
02030 break;
02031 }
02032
02033 case CSS_PROP_UNICODE_BIDI: {
02034 HANDLE_INHERIT_AND_INITIAL(unicodeBidi, UnicodeBidi)
02035 switch (primitiveValue->getIdent()) {
02036 case CSS_VAL_NORMAL:
02037 style->setUnicodeBidi(UBNormal);
02038 break;
02039 case CSS_VAL_EMBED:
02040 style->setUnicodeBidi(Embed);
02041 break;
02042 case CSS_VAL_BIDI_OVERRIDE:
02043 style->setUnicodeBidi(Override);
02044 break;
02045 default:
02046 return;
02047 }
02048 break;
02049 }
02050 case CSS_PROP_TEXT_TRANSFORM: {
02051 HANDLE_INHERIT_AND_INITIAL(textTransform, TextTransform)
02052
02053 if(!primitiveValue->getIdent()) return;
02054
02055 ETextTransform tt;
02056 switch(primitiveValue->getIdent()) {
02057 case CSS_VAL_CAPITALIZE: tt = CAPITALIZE; break;
02058 case CSS_VAL_UPPERCASE: tt = UPPERCASE; break;
02059 case CSS_VAL_LOWERCASE: tt = LOWERCASE; break;
02060 case CSS_VAL_NONE:
02061 default: tt = TTNONE; break;
02062 }
02063 style->setTextTransform(tt);
02064 break;
02065 }
02066
02067 case CSS_PROP_VISIBILITY:
02068 {
02069 HANDLE_INHERIT_AND_INITIAL(visibility, Visibility)
02070
02071 switch( primitiveValue->getIdent() ) {
02072 case CSS_VAL_HIDDEN:
02073 style->setVisibility( HIDDEN );
02074 break;
02075 case CSS_VAL_VISIBLE:
02076 style->setVisibility( VISIBLE );
02077 break;
02078 case CSS_VAL_COLLAPSE:
02079 style->setVisibility( COLLAPSE );
02080 default:
02081 break;
02082 }
02083 break;
02084 }
02085 case CSS_PROP_WHITE_SPACE:
02086 HANDLE_INHERIT_AND_INITIAL(whiteSpace, WhiteSpace)
02087
02088 if(!primitiveValue->getIdent()) return;
02089
02090 EWhiteSpace s;
02091 switch(primitiveValue->getIdent()) {
02092 case CSS_VAL__KHTML_NOWRAP:
02093 s = KHTML_NOWRAP;
02094 break;
02095 case CSS_VAL_NOWRAP:
02096 s = NOWRAP;
02097 break;
02098 case CSS_VAL_PRE:
02099 s = PRE;
02100 break;
02101 case CSS_VAL_NORMAL:
02102 default:
02103 s = NORMAL;
02104 break;
02105 }
02106 style->setWhiteSpace(s);
02107 break;
02108
02109 case CSS_PROP_BACKGROUND_POSITION:
02110 if (isInherit) {
02111 style->setBackgroundXPosition(parentStyle->backgroundXPosition());
02112 style->setBackgroundYPosition(parentStyle->backgroundYPosition());
02113 }
02114 else if (isInitial) {
02115 style->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
02116 style->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
02117 }
02118 break;
02119 case CSS_PROP_BACKGROUND_POSITION_X: {
02120 HANDLE_INHERIT_AND_INITIAL(backgroundXPosition, BackgroundXPosition)
02121 if(!primitiveValue) break;
02122 Length l;
02123 int type = primitiveValue->primitiveType();
02124 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02125 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02126 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02127 l = Length((int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02128 else
02129 return;
02130 style->setBackgroundXPosition(l);
02131 break;
02132 }
02133 case CSS_PROP_BACKGROUND_POSITION_Y: {
02134 HANDLE_INHERIT_AND_INITIAL(backgroundYPosition, BackgroundYPosition)
02135 if(!primitiveValue) break;
02136 Length l;
02137 int type = primitiveValue->primitiveType();
02138 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02139 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02140 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02141 l = Length((int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02142 else
02143 return;
02144 style->setBackgroundYPosition(l);
02145 break;
02146 }
02147 case CSS_PROP_BORDER_SPACING:
02148 assert( false );
02149
02150 case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING: {
02151 HANDLE_INHERIT_AND_INITIAL(borderHorizontalSpacing, BorderHorizontalSpacing)
02152 if (!primitiveValue) break;
02153 short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
02154 style->setBorderHorizontalSpacing(spacing);
02155 break;
02156 }
02157 case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING: {
02158 HANDLE_INHERIT_AND_INITIAL(borderVerticalSpacing, BorderVerticalSpacing)
02159 if (!primitiveValue) break;
02160 short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
02161 style->setBorderVerticalSpacing(spacing);
02162 break;
02163 }
02164
02165 case CSS_PROP_CURSOR:
02166 HANDLE_INHERIT_AND_INITIAL(cursor, Cursor)
02167 if(primitiveValue)
02168 style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
02169 break;
02170
02171 case CSS_PROP_BACKGROUND_COLOR:
02172 case CSS_PROP_BORDER_TOP_COLOR:
02173 case CSS_PROP_BORDER_RIGHT_COLOR:
02174 case CSS_PROP_BORDER_BOTTOM_COLOR:
02175 case CSS_PROP_BORDER_LEFT_COLOR:
02176 case CSS_PROP_COLOR:
02177 case CSS_PROP_OUTLINE_COLOR:
02178
02179 case CSS_PROP_SCROLLBAR_FACE_COLOR:
02180 case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
02181 case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
02182 case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
02183 case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
02184 case CSS_PROP_SCROLLBAR_TRACK_COLOR:
02185 case CSS_PROP_SCROLLBAR_ARROW_COLOR:
02186 {
02187 QColor col;
02188 if (isInherit) {
02189 HANDLE_INHERIT_COND(CSS_PROP_BACKGROUND_COLOR, backgroundColor, BackgroundColor)
02190 HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_COLOR, borderTopColor, BorderTopColor)
02191 HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_COLOR, borderBottomColor, BorderBottomColor)
02192 HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_COLOR, borderRightColor, BorderRightColor)
02193 HANDLE_INHERIT_COND(CSS_PROP_BORDER_LEFT_COLOR, borderLeftColor, BorderLeftColor)
02194 HANDLE_INHERIT_COND(CSS_PROP_COLOR, color, Color)
02195 HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_COLOR, outlineColor, OutlineColor)
02196 return;
02197 } else if (isInitial) {
02198
02199
02200
02201 if (id == CSS_PROP_COLOR)
02202 col = RenderStyle::initialColor();
02203 } else {
02204 if(!primitiveValue )
02205 return;
02206 int ident = primitiveValue->getIdent();
02207 if ( ident ) {
02208 if ( ident == CSS_VAL__KHTML_TEXT )
02209 col = element->getDocument()->textColor();
02210 else if ( ident == CSS_VAL_TRANSPARENT )
02211 col = QColor();
02212 else
02213 col = colorForCSSValue( ident );
02214 } else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR ) {
02215 #ifndef APPLE_CHANGES
02216 if(qAlpha(primitiveValue->getRGBColorValue()))
02217 #endif
02218 col.setRgb(primitiveValue->getRGBColorValue());
02219 } else {
02220 return;
02221 }
02222 }
02223
02224 switch(id)
02225 {
02226 case CSS_PROP_BACKGROUND_COLOR:
02227 style->setBackgroundColor(col); break;
02228 case CSS_PROP_BORDER_TOP_COLOR:
02229 style->setBorderTopColor(col); break;
02230 case CSS_PROP_BORDER_RIGHT_COLOR:
02231 style->setBorderRightColor(col); break;
02232 case CSS_PROP_BORDER_BOTTOM_COLOR:
02233 style->setBorderBottomColor(col); break;
02234 case CSS_PROP_BORDER_LEFT_COLOR:
02235 style->setBorderLeftColor(col); break;
02236 case CSS_PROP_COLOR:
02237 style->setColor(col); break;
02238 case CSS_PROP__KHTML_TEXT_DECORATION_COLOR:
02239 style->setTextDecorationColor(col); break;
02240 case CSS_PROP_OUTLINE_COLOR:
02241 style->setOutlineColor(col); break;
02242 #ifndef APPLE_CHANGES
02243 case CSS_PROP_SCROLLBAR_FACE_COLOR:
02244 style->setPaletteColor(QPalette::Active, QColorGroup::Button, col);
02245 style->setPaletteColor(QPalette::Inactive, QColorGroup::Button, col);
02246 break;
02247 case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
02248 style->setPaletteColor(QPalette::Active, QColorGroup::Shadow, col);
02249 style->setPaletteColor(QPalette::Inactive, QColorGroup::Shadow, col);
02250 break;
02251 case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
02252 style->setPaletteColor(QPalette::Active, QColorGroup::Light, col);
02253 style->setPaletteColor(QPalette::Inactive, QColorGroup::Light, col);
02254 break;
02255 case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
02256 break;
02257 case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
02258 style->setPaletteColor(QPalette::Active, QColorGroup::Dark, col);
02259 style->setPaletteColor(QPalette::Inactive, QColorGroup::Dark, col);
02260 break;
02261 case CSS_PROP_SCROLLBAR_TRACK_COLOR:
02262 style->setPaletteColor(QPalette::Active, QColorGroup::Mid, col);
02263 style->setPaletteColor(QPalette::Inactive, QColorGroup::Mid, col);
02264 style->setPaletteColor(QPalette::Active, QColorGroup::Background, col);
02265 style->setPaletteColor(QPalette::Inactive, QColorGroup::Background, col);
02266
02267 case CSS_PROP_SCROLLBAR_BASE_COLOR:
02268 style->setPaletteColor(QPalette::Active, QColorGroup::Base, col);
02269 style->setPaletteColor(QPalette::Inactive, QColorGroup::Base, col);
02270 break;
02271 case CSS_PROP_SCROLLBAR_ARROW_COLOR:
02272 style->setPaletteColor(QPalette::Active, QColorGroup::ButtonText, col);
02273 style->setPaletteColor(QPalette::Inactive, QColorGroup::ButtonText, col);
02274 break;
02275 #endif
02276 default:
02277 return;
02278 }
02279 return;
02280 }
02281 break;
02282
02283 case CSS_PROP_BACKGROUND_IMAGE:
02284 {
02285 HANDLE_INHERIT_AND_INITIAL(backgroundImage, BackgroundImage)
02286 if (!primitiveValue) return;
02287 style->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
02288
02289 break;
02290 }
02291 case CSS_PROP_LIST_STYLE_IMAGE:
02292 {
02293 HANDLE_INHERIT_AND_INITIAL(listStyleImage, ListStyleImage)
02294 if (!primitiveValue) return;
02295 style->setListStyleImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
02296
02297 break;
02298 }
02299
02300
02301 case CSS_PROP_BORDER_TOP_WIDTH:
02302 case CSS_PROP_BORDER_RIGHT_WIDTH:
02303 case CSS_PROP_BORDER_BOTTOM_WIDTH:
02304 case CSS_PROP_BORDER_LEFT_WIDTH:
02305 case CSS_PROP_OUTLINE_WIDTH:
02306 {
02307 if (isInherit) {
02308 HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_WIDTH, borderTopWidth, BorderTopWidth)
02309 HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_WIDTH, borderRightWidth, BorderRightWidth)
02310 HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_WIDTH, borderBottomWidth, BorderBottomWidth)
02311 HANDLE_INHERIT_COND(CSS_PROP_BORDER_LEFT_WIDTH, borderLeftWidth, BorderLeftWidth)
02312 HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_WIDTH, outlineWidth, OutlineWidth)
02313 return;
02314 }
02315 else if (isInitial) {
02316 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_TOP_WIDTH, BorderTopWidth, BorderWidth)
02317 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_RIGHT_WIDTH, BorderRightWidth, BorderWidth)
02318 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_BOTTOM_WIDTH, BorderBottomWidth, BorderWidth)
02319 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_LEFT_WIDTH, BorderLeftWidth, BorderWidth)
02320 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_OUTLINE_WIDTH, OutlineWidth, BorderWidth)
02321 return;
02322 }
02323
02324 if(!primitiveValue) break;
02325 short width = 3;
02326 switch(primitiveValue->getIdent())
02327 {
02328 case CSS_VAL_THIN:
02329 width = 1;
02330 break;
02331 case CSS_VAL_MEDIUM:
02332 width = 3;
02333 break;
02334 case CSS_VAL_THICK:
02335 width = 5;
02336 break;
02337 case CSS_VAL_INVALID:
02338 width = primitiveValue->computeLength(style, paintDeviceMetrics);
02339 break;
02340 default:
02341 return;
02342 }
02343
02344 if(width < 0) return;
02345 switch(id)
02346 {
02347 case CSS_PROP_BORDER_TOP_WIDTH:
02348 style->setBorderTopWidth(width);
02349 break;
02350 case CSS_PROP_BORDER_RIGHT_WIDTH:
02351 style->setBorderRightWidth(width);
02352 break;
02353 case CSS_PROP_BORDER_BOTTOM_WIDTH:
02354 style->setBorderBottomWidth(width);
02355 break;
02356 case CSS_PROP_BORDER_LEFT_WIDTH:
02357 style->setBorderLeftWidth(width);
02358 break;
02359 case CSS_PROP_OUTLINE_WIDTH:
02360 style->setOutlineWidth(width);
02361 break;
02362 default:
02363 return;
02364 }
02365 return;
02366 }
02367
02368 case CSS_PROP_LETTER_SPACING:
02369 case CSS_PROP_WORD_SPACING:
02370 {
02371 if (isInherit) {
02372 HANDLE_INHERIT_COND(CSS_PROP_LETTER_SPACING, letterSpacing, LetterSpacing)
02373 HANDLE_INHERIT_COND(CSS_PROP_WORD_SPACING, wordSpacing, WordSpacing)
02374 return;
02375 } else if (isInitial) {
02376 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_LETTER_SPACING, LetterSpacing, LetterWordSpacing)
02377 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_WORD_SPACING, WordSpacing, LetterWordSpacing)
02378 return;
02379 }
02380 if(!primitiveValue) return;
02381
02382 int width = 0;
02383 if (primitiveValue->getIdent() != CSS_VAL_NORMAL)
02384 width = primitiveValue->computeLength(style, paintDeviceMetrics);
02385
02386 switch(id)
02387 {
02388 case CSS_PROP_LETTER_SPACING:
02389 style->setLetterSpacing(width);
02390 break;
02391 case CSS_PROP_WORD_SPACING:
02392 style->setWordSpacing(width);
02393 break;
02394
02395 default: break;
02396 }
02397 return;
02398 }
02399
02400
02401 case CSS_PROP_MAX_WIDTH:
02402
02403 if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
02404 apply = true;
02405 case CSS_PROP_TOP:
02406 case CSS_PROP_LEFT:
02407 case CSS_PROP_RIGHT:
02408 case CSS_PROP_BOTTOM:
02409 case CSS_PROP_WIDTH:
02410 case CSS_PROP_MIN_WIDTH:
02411 case CSS_PROP_MARGIN_TOP:
02412 case CSS_PROP_MARGIN_RIGHT:
02413 case CSS_PROP_MARGIN_BOTTOM:
02414 case CSS_PROP_MARGIN_LEFT:
02415
02416 if(id != CSS_PROP_MAX_WIDTH && primitiveValue &&
02417 primitiveValue->getIdent() == CSS_VAL_AUTO)
02418 {
02419
02420 apply = true;
02421 }
02422 case CSS_PROP_PADDING_TOP:
02423 case CSS_PROP_PADDING_RIGHT:
02424 case CSS_PROP_PADDING_BOTTOM:
02425 case CSS_PROP_PADDING_LEFT:
02426 case CSS_PROP_TEXT_INDENT:
02427
02428 {
02429 if (isInherit) {
02430 HANDLE_INHERIT_COND(CSS_PROP_MAX_WIDTH, maxWidth, MaxWidth)
02431 HANDLE_INHERIT_COND(CSS_PROP_BOTTOM, bottom, Bottom)
02432 HANDLE_INHERIT_COND(CSS_PROP_TOP, top, Top)
02433 HANDLE_INHERIT_COND(CSS_PROP_LEFT, left, Left)
02434 HANDLE_INHERIT_COND(CSS_PROP_RIGHT, right, Right)
02435 HANDLE_INHERIT_COND(CSS_PROP_WIDTH, width, Width)
02436 HANDLE_INHERIT_COND(CSS_PROP_MIN_WIDTH, minWidth, MinWidth)
02437 HANDLE_INHERIT_COND(CSS_PROP_PADDING_TOP, paddingTop, PaddingTop)
02438 HANDLE_INHERIT_COND(CSS_PROP_PADDING_RIGHT, paddingRight, PaddingRight)
02439 HANDLE_INHERIT_COND(CSS_PROP_PADDING_BOTTOM, paddingBottom, PaddingBottom)
02440 HANDLE_INHERIT_COND(CSS_PROP_PADDING_LEFT, paddingLeft, PaddingLeft)
02441 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_TOP, marginTop, MarginTop)
02442 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_RIGHT, marginRight, MarginRight)
02443 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_BOTTOM, marginBottom, MarginBottom)
02444 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_LEFT, marginLeft, MarginLeft)
02445 HANDLE_INHERIT_COND(CSS_PROP_TEXT_INDENT, textIndent, TextIndent)
02446 return;
02447 } else if (isInitial) {
02448 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MAX_WIDTH, MaxWidth, MaxSize)
02449 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BOTTOM, Bottom, Offset)
02450 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_TOP, Top, Offset)
02451 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_LEFT, Left, Offset)
02452 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_RIGHT, Right, Offset)
02453 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_WIDTH, Width, Size)
02454 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MIN_WIDTH, MinWidth, MinSize)
02455 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_TOP, PaddingTop, Padding)
02456 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_RIGHT, PaddingRight, Padding)
02457 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_BOTTOM, PaddingBottom, Padding)
02458 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_LEFT, PaddingLeft, Padding)
02459 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_TOP, MarginTop, Margin)
02460 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_RIGHT, MarginRight, Margin)
02461 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_BOTTOM, MarginBottom, Margin)
02462 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_LEFT, MarginLeft, Margin)
02463 HANDLE_INITIAL_COND(CSS_PROP_TEXT_INDENT, TextIndent)
02464 return;
02465 }
02466
02467 if (primitiveValue && !apply) {
02468 int type = primitiveValue->primitiveType();
02469 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02470
02471 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed,
02472 primitiveValue->isQuirkValue());
02473 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02474 l = Length((int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02475 else if (type == CSSPrimitiveValue::CSS_HTML_RELATIVE)
02476 l = Length(int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_HTML_RELATIVE)), Relative);
02477 else
02478 return;
02479 apply = true;
02480 }
02481 if(!apply) return;
02482 switch(id)
02483 {
02484 case CSS_PROP_MAX_WIDTH:
02485 style->setMaxWidth(l); break;
02486 case CSS_PROP_BOTTOM:
02487 style->setBottom(l); break;
02488 case CSS_PROP_TOP:
02489 style->setTop(l); break;
02490 case CSS_PROP_LEFT:
02491 style->setLeft(l); break;
02492 case CSS_PROP_RIGHT:
02493 style->setRight(l); break;
02494 case CSS_PROP_WIDTH:
02495 style->setWidth(l); break;
02496 case CSS_PROP_MIN_WIDTH:
02497 style->setMinWidth(l); break;
02498 case CSS_PROP_PADDING_TOP:
02499 style->setPaddingTop(l); break;
02500 case CSS_PROP_PADDING_RIGHT:
02501 style->setPaddingRight(l); break;
02502 case CSS_PROP_PADDING_BOTTOM:
02503 style->setPaddingBottom(l); break;
02504 case CSS_PROP_PADDING_LEFT:
02505 style->setPaddingLeft(l); break;
02506 case CSS_PROP_MARGIN_TOP:
02507 style->setMarginTop(l); break;
02508 case CSS_PROP_MARGIN_RIGHT:
02509 style->setMarginRight(l); break;
02510 case CSS_PROP_MARGIN_BOTTOM:
02511 style->setMarginBottom(l); break;
02512 case CSS_PROP_MARGIN_LEFT:
02513 style->setMarginLeft(l); break;
02514 case CSS_PROP_TEXT_INDENT:
02515 style->setTextIndent(l); break;
02516 default: break;
02517 }
02518 return;
02519 }
02520
02521 case CSS_PROP_MAX_HEIGHT:
02522 if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
02523 apply = true;
02524 case CSS_PROP_HEIGHT:
02525 case CSS_PROP_MIN_HEIGHT:
02526 if(id != CSS_PROP_MAX_HEIGHT && primitiveValue &&
02527 primitiveValue->getIdent() == CSS_VAL_AUTO)
02528 apply = true;
02529 if (isInherit) {
02530 HANDLE_INHERIT_COND(CSS_PROP_MAX_HEIGHT, maxHeight, MaxHeight)
02531 HANDLE_INHERIT_COND(CSS_PROP_HEIGHT, height, Height)
02532 HANDLE_INHERIT_COND(CSS_PROP_MIN_HEIGHT, minHeight, MinHeight)
02533 return;
02534 }
02535 else if (isInitial) {
02536 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MAX_HEIGHT, MaxHeight, MaxSize)
02537 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_HEIGHT, Height, Size)
02538 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MIN_HEIGHT, MinHeight, MinSize)
02539 return;
02540 }
02541
02542 if (primitiveValue && !apply)
02543 {
02544 int type = primitiveValue->primitiveType();
02545 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02546 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02547 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02548 l = Length((int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02549 else
02550 return;
02551 apply = true;
02552 }
02553 if(!apply) return;
02554 switch(id)
02555 {
02556 case CSS_PROP_MAX_HEIGHT:
02557 style->setMaxHeight(l); break;
02558 case CSS_PROP_HEIGHT:
02559 style->setHeight(l); break;
02560 case CSS_PROP_MIN_HEIGHT:
02561 style->setMinHeight(l); break;
02562 default:
02563 return;
02564 }
02565 return;
02566
02567 break;
02568
02569 case CSS_PROP_VERTICAL_ALIGN:
02570 HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
02571 if (!primitiveValue) return;
02572 if (primitiveValue->getIdent()) {
02573 khtml::EVerticalAlign align;
02574
02575 switch(primitiveValue->getIdent())
02576 {
02577 case CSS_VAL_TOP:
02578 align = TOP; break;
02579 case CSS_VAL_BOTTOM:
02580 align = BOTTOM; break;
02581 case CSS_VAL_MIDDLE:
02582 align = MIDDLE; break;
02583 case CSS_VAL_BASELINE:
02584 align = BASELINE; break;
02585 case CSS_VAL_TEXT_BOTTOM:
02586 align = TEXT_BOTTOM; break;
02587 case CSS_VAL_TEXT_TOP:
02588 align = TEXT_TOP; break;
02589 case CSS_VAL_SUB:
02590 align = SUB; break;
02591 case CSS_VAL_SUPER:
02592 align = SUPER; break;
02593 case CSS_VAL__KHTML_BASELINE_MIDDLE:
02594 align = BASELINE_MIDDLE; break;
02595 default:
02596 return;
02597 }
02598 style->setVerticalAlign(align);
02599 return;
02600 } else {
02601 int type = primitiveValue->primitiveType();
02602 Length l;
02603 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02604 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed );
02605 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02606 l = Length( int( primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE) ), Percent );
02607
02608 style->setVerticalAlign( LENGTH );
02609 style->setVerticalAlignLength( l );
02610 }
02611 break;
02612
02613 case CSS_PROP_FONT_SIZE:
02614 {
02615 FontDef fontDef = style->htmlFont().fontDef;
02616 int oldSize;
02617 int size = 0;
02618
02619 float toPix = paintDeviceMetrics->logicalDpiY()/72.;
02620 if (toPix < 96./72.) toPix = 96./72.;
02621
02622 int minFontSize = int(settings->minFontSize() * toPix);
02623
02624 if(parentNode) {
02625 oldSize = parentStyle->font().pixelSize();
02626 } else
02627 oldSize = m_fontSizes[3];
02628
02629 if (isInherit )
02630 size = oldSize;
02631 else if (isInitial)
02632 size = m_fontSizes[3];
02633 else if(primitiveValue->getIdent()) {
02634
02635
02636 #ifdef APPLE_CHANGES
02637 QValueList<int>& fontSizes = (fontDef.genericFamily == FontDef::eMonospace) ?
02638 m_fixedFontSizes : m_fontSizes;
02639 #else
02640 QValueList<int>& fontSizes = m_fontSizes;
02641 #endif
02642 switch(primitiveValue->getIdent())
02643 {
02644 case CSS_VAL_XX_SMALL: size = int( fontSizes[0] ); break;
02645 case CSS_VAL_X_SMALL: size = int( fontSizes[1] ); break;
02646 case CSS_VAL_SMALL: size = int( fontSizes[2] ); break;
02647 case CSS_VAL_MEDIUM: size = int( fontSizes[3] ); break;
02648 case CSS_VAL_LARGE: size = int( fontSizes[4] ); break;
02649 case CSS_VAL_X_LARGE: size = int( fontSizes[5] ); break;
02650 case CSS_VAL_XX_LARGE: size = int( fontSizes[6] ); break;
02651 case CSS_VAL__KHTML_XXX_LARGE: size = ( fontSizes[6]*5 )/3; break;
02652 case CSS_VAL_LARGER:
02653
02654 size = ( oldSize * 5 ) / 4;
02655 break;
02656 case CSS_VAL_SMALLER:
02657 size = ( oldSize * 4 ) / 5;
02658 break;
02659 default:
02660 return;
02661 }
02662
02663 } else {
02664 int type = primitiveValue->primitiveType();
02665 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
02666 if (!khtml::printpainter && element && element->getDocument()->view())
02667 size = int( primitiveValue->computeLengthFloat(parentStyle, paintDeviceMetrics) *
02668 element->getDocument()->view()->part()->zoomFactor() ) / 100;
02669 else
02670 size = int( primitiveValue->computeLengthFloat(parentStyle, paintDeviceMetrics) );
02671 }
02672 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02673 size = int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)
02674 * parentStyle->font().pixelSize()) / 100;
02675 else
02676 return;
02677 }
02678
02679 if(size < 1) return;
02680
02681
02682 if(size < minFontSize ) size = minFontSize;
02683
02684
02685
02686 fontDef.size = size;
02687 fontDirty |= style->setFontDef( fontDef );
02688 return;
02689 }
02690
02691 case CSS_PROP_Z_INDEX:
02692 {
02693 HANDLE_INHERIT(zIndex, ZIndex)
02694 else if (isInitial) {
02695 style->setHasAutoZIndex();
02696 return;
02697 }
02698
02699 if (!primitiveValue)
02700 return;
02701
02702 if (primitiveValue->getIdent() == CSS_VAL_AUTO) {
02703 style->setHasAutoZIndex();
02704 return;
02705 }
02706
02707 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
02708 return;
02709
02710 style->setZIndex((int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_NUMBER));
02711 return;
02712 }
02713
02714
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735 case CSS_PROP_LINE_HEIGHT:
02736 {
02737 HANDLE_INHERIT_AND_INITIAL(lineHeight, LineHeight)
02738 if(!primitiveValue) return;
02739 Length lineHeight;
02740 int type = primitiveValue->primitiveType();
02741 if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
02742 lineHeight = Length( -100, Percent );
02743 else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
02744 #ifdef APPLE_CHANGES
02745 double multiplier = 1.0;
02746
02747
02748 if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && view && view->part()) {
02749 multiplier = view->part()->zoomFactor() / 100.0;
02750 }
02751 lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics, multiplier), Fixed);
02752 #else
02753 lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02754 #endif
02755 } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
02756 lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
02757 else if (type == CSSPrimitiveValue::CSS_NUMBER)
02758 lineHeight = Length(int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
02759 else
02760 return;
02761 style->setLineHeight(lineHeight);
02762 return;
02763 }
02764
02765
02766 case CSS_PROP_TEXT_ALIGN:
02767 {
02768 HANDLE_INHERIT_AND_INITIAL(textAlign, TextAlign)
02769 if (!primitiveValue) return;
02770 if (primitiveValue->getIdent())
02771 style->setTextAlign( (ETextAlign) (primitiveValue->getIdent() - CSS_VAL__KHTML_AUTO) );
02772 return;
02773 }
02774
02775
02776 case CSS_PROP_CLIP:
02777 {
02778 Length top;
02779 Length right;
02780 Length bottom;
02781 Length left;
02782 bool hasClip = true;
02783 if (isInherit) {
02784 if (parentStyle->hasClip()) {
02785 top = parentStyle->clipTop();
02786 right = parentStyle->clipRight();
02787 bottom = parentStyle->clipBottom();
02788 left = parentStyle->clipLeft();
02789 }
02790 else {
02791 hasClip = false;
02792 top = right = bottom = left = Length();
02793 }
02794 } else if (isInitial) {
02795 hasClip = false;
02796 top = right = bottom = left = Length();
02797 } else if ( !primitiveValue ) {
02798 break;
02799 } else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RECT ) {
02800 RectImpl *rect = primitiveValue->getRectValue();
02801 if ( !rect )
02802 break;
02803 top = convertToLength( rect->top(), style, paintDeviceMetrics );
02804 right = convertToLength( rect->right(), style, paintDeviceMetrics );
02805 bottom = convertToLength( rect->bottom(), style, paintDeviceMetrics );
02806 left = convertToLength( rect->left(), style, paintDeviceMetrics );
02807
02808 } else if ( primitiveValue->getIdent() != CSS_VAL_AUTO ) {
02809 break;
02810 }
02811
02812
02813
02814
02815 style->setClip(top, right, bottom, left );
02816 style->setHasClip(hasClip);
02817
02818 break;
02819 }
02820
02821
02822 case CSS_PROP_CONTENT:
02823
02824 {
02825
02826
02827 if (!(style->styleType()==RenderStyle::BEFORE ||
02828 style->styleType()==RenderStyle::AFTER))
02829 break;
02830
02831 if (isInitial) {
02832 if (style->contentData())
02833 style->contentData()->clearContent();
02834 return;
02835 }
02836
02837 if(!value->isValueList()) return;
02838 CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
02839 int len = list->length();
02840
02841 for(int i = 0; i < len; i++) {
02842 CSSValueImpl *item = list->item(i);
02843 if(!item->isPrimitiveValue()) continue;
02844 CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
02845 if(val->primitiveType()==CSSPrimitiveValue::CSS_STRING)
02846 {
02847 style->setContent(val->getStringValue(), i != 0);
02848 }
02849 else if (val->primitiveType()==CSSPrimitiveValue::CSS_ATTR)
02850 {
02851 #ifdef APPLE_CHANGES
02852 int attrID = element->getDocument()->attrId(0, val->getStringValue(), false);
02853 if (attrID)
02854 style->setContent(element->getAttribute(attrID).implementation(), i != 0);
02855 #else
02856 int attrID = element->getDocument()->getId(NodeImpl::AttributeId, val->getStringValue(), false, true);
02857 if (attrID)
02858 style->setContent(element->getAttribute(attrID).implementation(), i != 0);
02859 #endif
02860 }
02861 else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI)
02862 {
02863 CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(val);
02864 style->setContent(image->image(), i != 0);
02865 }
02866
02867 }
02868 break;
02869 }
02870
02871 case CSS_PROP_COUNTER_INCREMENT:
02872
02873 case CSS_PROP_COUNTER_RESET:
02874
02875 break;
02876 case CSS_PROP_FONT_FAMILY:
02877
02878 {
02879 if (isInherit) {
02880 FontDef parentFontDef = parentStyle->htmlFont().fontDef;
02881 FontDef fontDef = style->htmlFont().fontDef;
02882 fontDef.family = parentFontDef.family;
02883 if (style->setFontDef(fontDef))
02884 fontDirty = true;
02885 return;
02886 }
02887 else if (isInitial) {
02888 FontDef fontDef = style->htmlFont().fontDef;
02889 FontDef initialDef = FontDef();
02890 #ifdef APPLE_CHANGES
02891 fontDef.family = initialDef.firstFamily();
02892 #else
02893 fontDef.family = QString::null;
02894 #endif
02895 if (style->setFontDef(fontDef))
02896 fontDirty = true;
02897 return;
02898 }
02899 if(!value->isValueList()) return;
02900 FontDef fontDef = style->htmlFont().fontDef;
02901 CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
02902 int len = list->length();
02903 for(int i = 0; i < len; i++) {
02904 CSSValueImpl *item = list->item(i);
02905 if(!item->isPrimitiveValue()) continue;
02906 CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
02907 QString face;
02908 if( val->primitiveType() == CSSPrimitiveValue::CSS_STRING )
02909 face = static_cast<FontFamilyValueImpl *>(val)->fontName();
02910 else if ( val->primitiveType() == CSSPrimitiveValue::CSS_IDENT ) {
02911 switch( val->getIdent() ) {
02912 case CSS_VAL_SERIF:
02913 face = settings->serifFontName();
02914 break;
02915 case CSS_VAL_SANS_SERIF:
02916 face = settings->sansSerifFontName();
02917 break;
02918 case CSS_VAL_CURSIVE:
02919 face = settings->cursiveFontName();
02920 break;
02921 case CSS_VAL_FANTASY:
02922 face = settings->fantasyFontName();
02923 break;
02924 case CSS_VAL_MONOSPACE:
02925 face = settings->fixedFontName();
02926 break;
02927 default:
02928 return;
02929 }
02930 } else {
02931 return;
02932 }
02933 if ( !face.isEmpty() ) {
02934 fontDef.family = face;
02935 fontDirty |= style->setFontDef( fontDef );
02936 return;
02937 }
02938 }
02939 break;
02940 }
02941 case CSS_PROP_QUOTES:
02942
02943 case CSS_PROP_SIZE:
02944
02945 break;
02946 case CSS_PROP_TEXT_DECORATION: {
02947
02948 HANDLE_INHERIT_AND_INITIAL(textDecoration, TextDecoration)
02949 int t = RenderStyle::initialTextDecoration();
02950 if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE) {
02951
02952 } else {
02953 if(!value->isValueList()) return;
02954 CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
02955 int len = list->length();
02956 for(int i = 0; i < len; i++)
02957 {
02958 CSSValueImpl *item = list->item(i);
02959 if(!item->isPrimitiveValue()) continue;
02960 primitiveValue = static_cast<CSSPrimitiveValueImpl *>(item);
02961 switch(primitiveValue->getIdent())
02962 {
02963 case CSS_VAL_NONE:
02964 t = TDNONE; break;
02965 case CSS_VAL_UNDERLINE:
02966 t |= UNDERLINE; break;
02967 case CSS_VAL_OVERLINE:
02968 t |= OVERLINE; break;
02969 case CSS_VAL_LINE_THROUGH:
02970 t |= LINE_THROUGH; break;
02971 case CSS_VAL_BLINK:
02972 t |= BLINK; break;
02973 default:
02974 return;
02975 }
02976 }
02977 }
02978 style->setTextDecoration(t);
02979 break;
02980 }
02981 case CSS_PROP__KHTML_FLOW_MODE:
02982 HANDLE_INHERIT_AND_INITIAL(flowAroundFloats, FlowAroundFloats)
02983 if (!primitiveValue) return;
02984 if (primitiveValue->getIdent()) {
02985 style->setFlowAroundFloats( primitiveValue->getIdent() == CSS_VAL__KHTML_AROUND_FLOATS );
02986 return;
02987 }
02988 break;
02989 case CSS_PROP__KHTML_USER_INPUT: {
02990 if(value->cssValueType() == CSSValue::CSS_INHERIT)
02991 {
02992 if(!parentNode) return;
02993 style->setUserInput(parentStyle->userInput());
02994
02995 return;
02996 }
02997 if(!primitiveValue) return;
02998 int id = primitiveValue->getIdent();
02999 if (id == CSS_VAL_NONE)
03000 style->setUserInput(UI_NONE);
03001 else
03002 style->setUserInput(EUserInput(id - CSS_VAL_ENABLED));
03003
03004 return;
03005 }
03006
03007
03008 case CSS_PROP_BACKGROUND:
03009 if (isInherit) {
03010 style->setBackgroundColor(parentStyle->backgroundColor());
03011 style->setBackgroundImage(parentStyle->backgroundImage());
03012 style->setBackgroundRepeat(parentStyle->backgroundRepeat());
03013 style->setBackgroundAttachment(parentStyle->backgroundAttachment());
03014 style->setBackgroundXPosition(parentStyle->backgroundXPosition());
03015 style->setBackgroundYPosition(parentStyle->backgroundYPosition());
03016 }
03017 else if (isInitial) {
03018 style->setBackgroundColor(QColor());
03019 style->setBackgroundImage(RenderStyle::initialBackgroundImage());
03020 style->setBackgroundRepeat(RenderStyle::initialBackgroundRepeat());
03021 style->setBackgroundAttachment(RenderStyle::initialBackgroundAttachment());
03022 style->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
03023 style->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
03024 }
03025 break;
03026 case CSS_PROP_BORDER_COLOR:
03027 if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_TRANSPARENT)
03028 {
03029 style->setBorderTopColor(QColor());
03030 style->setBorderBottomColor(QColor());
03031 style->setBorderLeftColor(QColor());
03032 style->setBorderRightColor(QColor());
03033 return;
03034 }
03035 case CSS_PROP_BORDER:
03036 case CSS_PROP_BORDER_STYLE:
03037 case CSS_PROP_BORDER_WIDTH:
03038 if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_COLOR)
03039 {
03040 if (isInherit) {
03041 style->setBorderTopColor(parentStyle->borderTopColor());
03042 style->setBorderBottomColor(parentStyle->borderBottomColor());
03043 style->setBorderLeftColor(parentStyle->borderLeftColor());
03044 style->setBorderRightColor(parentStyle->borderRightColor());
03045 }
03046 else if (isInitial) {
03047 style->setBorderTopColor(QColor());
03048 style->setBorderBottomColor(QColor());
03049 style->setBorderLeftColor(QColor());
03050 style->setBorderRightColor(QColor());
03051 }
03052 }
03053 if (id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_STYLE)
03054 {
03055 if (isInherit) {
03056 style->setBorderTopStyle(parentStyle->borderTopStyle());
03057 style->setBorderBottomStyle(parentStyle->borderBottomStyle());
03058 style->setBorderLeftStyle(parentStyle->borderLeftStyle());
03059 style->setBorderRightStyle(parentStyle->borderRightStyle());
03060 }
03061 else if (isInitial) {
03062 style->setBorderTopStyle(RenderStyle::initialBorderStyle());
03063 style->setBorderBottomStyle(RenderStyle::initialBorderStyle());
03064 style->setBorderLeftStyle(RenderStyle::initialBorderStyle());
03065 style->setBorderRightStyle(RenderStyle::initialBorderStyle());
03066 }
03067 }
03068 if (id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_WIDTH)
03069 {
03070 if (isInherit) {
03071 style->setBorderTopWidth(parentStyle->borderTopWidth());
03072 style->setBorderBottomWidth(parentStyle->borderBottomWidth());
03073 style->setBorderLeftWidth(parentStyle->borderLeftWidth());
03074 style->setBorderRightWidth(parentStyle->borderRightWidth());
03075 }
03076 else if (isInitial) {
03077 style->setBorderTopWidth(RenderStyle::initialBorderWidth());
03078 style->setBorderBottomWidth(RenderStyle::initialBorderWidth());
03079 style->setBorderLeftWidth(RenderStyle::initialBorderWidth());
03080 style->setBorderRightWidth(RenderStyle::initialBorderWidth());
03081 }
03082 }
03083 return;
03084 case CSS_PROP_BORDER_TOP:
03085 if ( isInherit ) {
03086 style->setBorderTopColor(parentStyle->borderTopColor());
03087 style->setBorderTopStyle(parentStyle->borderTopStyle());
03088 style->setBorderTopWidth(parentStyle->borderTopWidth());
03089 } else if (isInitial)
03090 style->resetBorderTop();
03091 return;
03092 case CSS_PROP_BORDER_RIGHT:
03093 if (isInherit) {
03094 style->setBorderRightColor(parentStyle->borderRightColor());
03095 style->setBorderRightStyle(parentStyle->borderRightStyle());
03096 style->setBorderRightWidth(parentStyle->borderRightWidth());
03097 }
03098 else if (isInitial)
03099 style->resetBorderRight();
03100 return;
03101 case CSS_PROP_BORDER_BOTTOM:
03102 if (isInherit) {
03103 style->setBorderBottomColor(parentStyle->borderBottomColor());
03104 style->setBorderBottomStyle(parentStyle->borderBottomStyle());
03105 style->setBorderBottomWidth(parentStyle->borderBottomWidth());
03106 }
03107 else if (isInitial)
03108 style->resetBorderBottom();
03109 return;
03110 case CSS_PROP_BORDER_LEFT:
03111 if (isInherit) {
03112 style->setBorderLeftColor(parentStyle->borderLeftColor());
03113 style->setBorderLeftStyle(parentStyle->borderLeftStyle());
03114 style->setBorderLeftWidth(parentStyle->borderLeftWidth());
03115 }
03116 else if (isInitial)
03117 style->resetBorderLeft();
03118 return;
03119 case CSS_PROP_MARGIN:
03120 if (isInherit) {
03121 style->setMarginTop(parentStyle->marginTop());
03122 style->setMarginBottom(parentStyle->marginBottom());
03123 style->setMarginLeft(parentStyle->marginLeft());
03124 style->setMarginRight(parentStyle->marginRight());
03125 }
03126 else if (isInitial)
03127 style->resetMargin();
03128 return;
03129 case CSS_PROP_PADDING:
03130 if (isInherit) {
03131 style->setPaddingTop(parentStyle->paddingTop());
03132 style->setPaddingBottom(parentStyle->paddingBottom());
03133 style->setPaddingLeft(parentStyle->paddingLeft());
03134 style->setPaddingRight(parentStyle->paddingRight());
03135 }
03136 else if (isInitial)
03137 style->resetPadding();
03138 return;
03139 case CSS_PROP_FONT:
03140 if ( isInherit ) {
03141 FontDef fontDef = parentStyle->htmlFont().fontDef;
03142 style->setLineHeight( parentStyle->lineHeight() );
03143 fontDirty |= style->setFontDef( fontDef );
03144 } else if (isInitial) {
03145 FontDef fontDef;
03146 style->setLineHeight(RenderStyle::initialLineHeight());
03147 if (style->setFontDef( fontDef ))
03148 fontDirty = true;
03149 } else if ( value->isFontValue() ) {
03150 FontValueImpl *font = static_cast<FontValueImpl *>(value);
03151 if ( !font->style || !font->variant || !font->weight ||
03152 !font->size || !font->lineHeight || !font->family )
03153 return;
03154 applyRule( CSS_PROP_FONT_STYLE, font->style );
03155 applyRule( CSS_PROP_FONT_VARIANT, font->variant );
03156 applyRule( CSS_PROP_FONT_WEIGHT, font->weight );
03157 applyRule( CSS_PROP_FONT_SIZE, font->size );
03158
03159
03160
03161
03162 if (fontDirty)
03163 CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
03164
03165 applyRule( CSS_PROP_LINE_HEIGHT, font->lineHeight );
03166 applyRule( CSS_PROP_FONT_FAMILY, font->family );
03167 }
03168 return;
03169
03170 case CSS_PROP_LIST_STYLE:
03171 if (isInherit) {
03172 style->setListStyleType(parentStyle->listStyleType());
03173 style->setListStyleImage(parentStyle->listStyleImage());
03174 style->setListStylePosition(parentStyle->listStylePosition());
03175 }
03176 else if (isInitial) {
03177 style->setListStyleType(RenderStyle::initialListStyleType());
03178 style->setListStyleImage(RenderStyle::initialListStyleImage());
03179 style->setListStylePosition(RenderStyle::initialListStylePosition());
03180 }
03181 break;
03182 case CSS_PROP_OUTLINE:
03183 if (isInherit) {
03184 style->setOutlineWidth(parentStyle->outlineWidth());
03185 style->setOutlineColor(parentStyle->outlineColor());
03186 style->setOutlineStyle(parentStyle->outlineStyle());
03187 }
03188 else if (isInitial)
03189 style->resetOutline();
03190 break;
03191 default:
03192 return;
03193 }
03194 }
03195
03196 #ifdef APPLE_CHANGES
03197 void CSSStyleSelector::checkForGenericFamilyChange(RenderStyle* aStyle, RenderStyle* aParentStyle)
03198 {
03199 const FontDef& childFont = aStyle->htmlFont().fontDef;
03200
03201 if (childFont.sizeSpecified || !aParentStyle)
03202 return;
03203
03204 const FontDef& parentFont = aParentStyle->htmlFont().fontDef;
03205
03206 if (childFont.genericFamily == parentFont.genericFamily)
03207 return;
03208
03209
03210 if (childFont.genericFamily != FontDef::eMonospace &&
03211 parentFont.genericFamily != FontDef::eMonospace)
03212 return;
03213
03214
03215
03216
03217 float size = 0;
03218 int minFontSize = settings->minFontSize();
03219 size = (childFont.genericFamily == FontDef::eMonospace) ? m_fixedFontSizes[3] : m_fontSizes[3];
03220 int isize = (int)size;
03221 if (isize < minFontSize)
03222 isize = minFontSize;
03223
03224 FontDef newFontDef(childFont);
03225 newFontDef.size = isize;
03226 aStyle->setFontDef(newFontDef);
03227 }
03228 #endif
03229
03230 }