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 if(!primitiveValue) break;
02036 switch (primitiveValue->getIdent()) {
02037
case CSS_VAL_NORMAL:
02038 style->setUnicodeBidi(UBNormal);
02039
break;
02040
case CSS_VAL_EMBED:
02041 style->setUnicodeBidi(Embed);
02042
break;
02043
case CSS_VAL_BIDI_OVERRIDE:
02044 style->setUnicodeBidi(Override);
02045
break;
02046
default:
02047
return;
02048 }
02049
break;
02050 }
02051
case CSS_PROP_TEXT_TRANSFORM: {
02052 HANDLE_INHERIT_AND_INITIAL(textTransform, TextTransform)
02053 if(!primitiveValue) break;
02054 if(!primitiveValue->getIdent()) return;
02055
02056 ETextTransform tt;
02057 switch(primitiveValue->getIdent()) {
02058
case CSS_VAL_CAPITALIZE: tt = CAPITALIZE;
break;
02059
case CSS_VAL_UPPERCASE: tt = UPPERCASE;
break;
02060
case CSS_VAL_LOWERCASE: tt = LOWERCASE;
break;
02061
case CSS_VAL_NONE:
02062
default: tt = TTNONE;
break;
02063 }
02064 style->setTextTransform(tt);
02065
break;
02066 }
02067
02068
case CSS_PROP_VISIBILITY:
02069 {
02070 HANDLE_INHERIT_AND_INITIAL(visibility, Visibility)
02071 if(!primitiveValue) break;
02072 switch( primitiveValue->getIdent() ) {
02073
case CSS_VAL_HIDDEN:
02074 style->setVisibility( HIDDEN );
02075
break;
02076
case CSS_VAL_VISIBLE:
02077 style->setVisibility( VISIBLE );
02078
break;
02079
case CSS_VAL_COLLAPSE:
02080 style->setVisibility( COLLAPSE );
02081
default:
02082
break;
02083 }
02084
break;
02085 }
02086
case CSS_PROP_WHITE_SPACE:
02087 HANDLE_INHERIT_AND_INITIAL(whiteSpace, WhiteSpace)
02088 if(!primitiveValue) break;
02089 if(!primitiveValue->getIdent()) return;
02090
02091 EWhiteSpace s;
02092 switch(primitiveValue->getIdent()) {
02093
case CSS_VAL__KHTML_NOWRAP:
02094 s = KHTML_NOWRAP;
02095
break;
02096
case CSS_VAL_NOWRAP:
02097 s = NOWRAP;
02098
break;
02099
case CSS_VAL_PRE:
02100 s = PRE;
02101
break;
02102
case CSS_VAL_NORMAL:
02103
default:
02104 s = NORMAL;
02105
break;
02106 }
02107 style->setWhiteSpace(s);
02108
break;
02109
02110
case CSS_PROP_BACKGROUND_POSITION:
02111
if (isInherit) {
02112 style->setBackgroundXPosition(parentStyle->backgroundXPosition());
02113 style->setBackgroundYPosition(parentStyle->backgroundYPosition());
02114 }
02115
else if (isInitial) {
02116 style->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
02117 style->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
02118 }
02119
break;
02120
case CSS_PROP_BACKGROUND_POSITION_X: {
02121 HANDLE_INHERIT_AND_INITIAL(backgroundXPosition, BackgroundXPosition)
02122 if(!primitiveValue) break;
02123 Length l;
02124
int type = primitiveValue->primitiveType();
02125 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02126 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02127 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02128 l = Length((
int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02129 else
02130 return;
02131 style->setBackgroundXPosition(l);
02132 break;
02133 }
02134 case CSS_PROP_BACKGROUND_POSITION_Y: {
02135 HANDLE_INHERIT_AND_INITIAL(backgroundYPosition, BackgroundYPosition)
02136 if(!primitiveValue) break;
02137 Length l;
02138
int type = primitiveValue->primitiveType();
02139 if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02140 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02141 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02142 l = Length((
int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02143 else
02144 return;
02145 style->setBackgroundYPosition(l);
02146 break;
02147 }
02148 case CSS_PROP_BORDER_SPACING:
02149 assert( false );
02150
02151 case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING: {
02152 HANDLE_INHERIT_AND_INITIAL(borderHorizontalSpacing, BorderHorizontalSpacing)
02153 if (!primitiveValue) break;
02154
short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
02155 style->setBorderHorizontalSpacing(spacing);
02156 break;
02157 }
02158 case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING: {
02159 HANDLE_INHERIT_AND_INITIAL(borderVerticalSpacing, BorderVerticalSpacing)
02160 if (!primitiveValue) break;
02161
short spacing = primitiveValue->computeLength(style, paintDeviceMetrics);
02162 style->setBorderVerticalSpacing(spacing);
02163 break;
02164 }
02165
02166 case CSS_PROP_CURSOR:
02167 HANDLE_INHERIT_AND_INITIAL(cursor, Cursor)
02168 if(primitiveValue)
02169 style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
02170 break;
02171
02172 case CSS_PROP_BACKGROUND_COLOR:
02173 case CSS_PROP_BORDER_TOP_COLOR:
02174 case CSS_PROP_BORDER_RIGHT_COLOR:
02175 case CSS_PROP_BORDER_BOTTOM_COLOR:
02176 case CSS_PROP_BORDER_LEFT_COLOR:
02177 case CSS_PROP_COLOR:
02178 case CSS_PROP_OUTLINE_COLOR:
02179
02180 case CSS_PROP_SCROLLBAR_FACE_COLOR:
02181 case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
02182 case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
02183 case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
02184 case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
02185 case CSS_PROP_SCROLLBAR_TRACK_COLOR:
02186 case CSS_PROP_SCROLLBAR_ARROW_COLOR:
02187 {
02188
QColor col;
02189
if (isInherit) {
02190 HANDLE_INHERIT_COND(CSS_PROP_BACKGROUND_COLOR, backgroundColor, BackgroundColor)
02191 HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_COLOR, borderTopColor, BorderTopColor)
02192 HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_COLOR, borderBottomColor, BorderBottomColor)
02193 HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_COLOR, borderRightColor, BorderRightColor)
02194 HANDLE_INHERIT_COND(CSS_PROP_BORDER_LEFT_COLOR, borderLeftColor, BorderLeftColor)
02195 HANDLE_INHERIT_COND(CSS_PROP_COLOR, color, Color)
02196 HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_COLOR, outlineColor, OutlineColor)
02197 return;
02198 } else if (isInitial) {
02199
02200
02201
02202
if (
id == CSS_PROP_COLOR)
02203 col = RenderStyle::initialColor();
02204 }
else {
02205
if(!primitiveValue )
02206
return;
02207
int ident = primitiveValue->getIdent();
02208
if ( ident ) {
02209
if ( ident == CSS_VAL__KHTML_TEXT )
02210 col = element->getDocument()->textColor();
02211
else if ( ident == CSS_VAL_TRANSPARENT )
02212 col =
QColor();
02213
else
02214 col = colorForCSSValue( ident );
02215 }
else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR ) {
02216
#ifndef APPLE_CHANGES
02217
if(qAlpha(primitiveValue->getRGBColorValue()))
02218
#endif
02219
col.setRgb(primitiveValue->getRGBColorValue());
02220 }
else {
02221
return;
02222 }
02223 }
02224
02225
switch(
id)
02226 {
02227
case CSS_PROP_BACKGROUND_COLOR:
02228 style->setBackgroundColor(col);
break;
02229
case CSS_PROP_BORDER_TOP_COLOR:
02230 style->setBorderTopColor(col);
break;
02231
case CSS_PROP_BORDER_RIGHT_COLOR:
02232 style->setBorderRightColor(col);
break;
02233
case CSS_PROP_BORDER_BOTTOM_COLOR:
02234 style->setBorderBottomColor(col);
break;
02235
case CSS_PROP_BORDER_LEFT_COLOR:
02236 style->setBorderLeftColor(col);
break;
02237
case CSS_PROP_COLOR:
02238 style->setColor(col);
break;
02239
case CSS_PROP__KHTML_TEXT_DECORATION_COLOR:
02240 style->setTextDecorationColor(col);
break;
02241
case CSS_PROP_OUTLINE_COLOR:
02242 style->setOutlineColor(col);
break;
02243
#ifndef APPLE_CHANGES
02244
case CSS_PROP_SCROLLBAR_FACE_COLOR:
02245 style->setPaletteColor(QPalette::Active, QColorGroup::Button, col);
02246 style->setPaletteColor(QPalette::Inactive, QColorGroup::Button, col);
02247
break;
02248
case CSS_PROP_SCROLLBAR_SHADOW_COLOR:
02249 style->setPaletteColor(QPalette::Active, QColorGroup::Shadow, col);
02250 style->setPaletteColor(QPalette::Inactive, QColorGroup::Shadow, col);
02251
break;
02252
case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:
02253 style->setPaletteColor(QPalette::Active, QColorGroup::Light, col);
02254 style->setPaletteColor(QPalette::Inactive, QColorGroup::Light, col);
02255
break;
02256
case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:
02257
break;
02258
case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:
02259 style->setPaletteColor(QPalette::Active, QColorGroup::Dark, col);
02260 style->setPaletteColor(QPalette::Inactive, QColorGroup::Dark, col);
02261
break;
02262
case CSS_PROP_SCROLLBAR_TRACK_COLOR:
02263 style->setPaletteColor(QPalette::Active, QColorGroup::Mid, col);
02264 style->setPaletteColor(QPalette::Inactive, QColorGroup::Mid, col);
02265 style->setPaletteColor(QPalette::Active, QColorGroup::Background, col);
02266 style->setPaletteColor(QPalette::Inactive, QColorGroup::Background, col);
02267
02268
case CSS_PROP_SCROLLBAR_BASE_COLOR:
02269 style->setPaletteColor(QPalette::Active, QColorGroup::Base, col);
02270 style->setPaletteColor(QPalette::Inactive, QColorGroup::Base, col);
02271
break;
02272
case CSS_PROP_SCROLLBAR_ARROW_COLOR:
02273 style->setPaletteColor(QPalette::Active, QColorGroup::ButtonText, col);
02274 style->setPaletteColor(QPalette::Inactive, QColorGroup::ButtonText, col);
02275
break;
02276
#endif
02277
default:
02278
return;
02279 }
02280
return;
02281 }
02282
break;
02283
02284
case CSS_PROP_BACKGROUND_IMAGE:
02285 {
02286 HANDLE_INHERIT_AND_INITIAL(backgroundImage, BackgroundImage)
02287 if (!primitiveValue) return;
02288 style->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
02289
02290 break;
02291 }
02292 case CSS_PROP_LIST_STYLE_IMAGE:
02293 {
02294 HANDLE_INHERIT_AND_INITIAL(listStyleImage, ListStyleImage)
02295 if (!primitiveValue) return;
02296 style->setListStyleImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
02297
02298 break;
02299 }
02300
02301
02302 case CSS_PROP_BORDER_TOP_WIDTH:
02303 case CSS_PROP_BORDER_RIGHT_WIDTH:
02304 case CSS_PROP_BORDER_BOTTOM_WIDTH:
02305 case CSS_PROP_BORDER_LEFT_WIDTH:
02306 case CSS_PROP_OUTLINE_WIDTH:
02307 {
02308
if (isInherit) {
02309 HANDLE_INHERIT_COND(CSS_PROP_BORDER_TOP_WIDTH, borderTopWidth, BorderTopWidth)
02310 HANDLE_INHERIT_COND(CSS_PROP_BORDER_RIGHT_WIDTH, borderRightWidth, BorderRightWidth)
02311 HANDLE_INHERIT_COND(CSS_PROP_BORDER_BOTTOM_WIDTH, borderBottomWidth, BorderBottomWidth)
02312 HANDLE_INHERIT_COND(CSS_PROP_BORDER_LEFT_WIDTH, borderLeftWidth, BorderLeftWidth)
02313 HANDLE_INHERIT_COND(CSS_PROP_OUTLINE_WIDTH, outlineWidth, OutlineWidth)
02314 return;
02315 }
02316 else if (isInitial) {
02317 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_TOP_WIDTH, BorderTopWidth, BorderWidth)
02318 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_RIGHT_WIDTH, BorderRightWidth, BorderWidth)
02319 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_BOTTOM_WIDTH, BorderBottomWidth, BorderWidth)
02320 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BORDER_LEFT_WIDTH, BorderLeftWidth, BorderWidth)
02321 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_OUTLINE_WIDTH, OutlineWidth, BorderWidth)
02322 return;
02323 }
02324
02325 if(!primitiveValue) break;
02326
short width = 3;
02327 switch(primitiveValue->getIdent())
02328 {
02329
case CSS_VAL_THIN:
02330 width = 1;
02331
break;
02332
case CSS_VAL_MEDIUM:
02333 width = 3;
02334
break;
02335
case CSS_VAL_THICK:
02336 width = 5;
02337
break;
02338
case CSS_VAL_INVALID:
02339 {
02340
double widthd = primitiveValue->computeLengthFloat(style, paintDeviceMetrics);
02341 width = (
int)widthd;
02342
02343
02344
if (width == 0 && widthd >= 0.025) width++;
02345
break;
02346 }
02347
default:
02348
return;
02349 }
02350
02351
if(width < 0)
return;
02352
switch(
id)
02353 {
02354
case CSS_PROP_BORDER_TOP_WIDTH:
02355 style->setBorderTopWidth(width);
02356
break;
02357
case CSS_PROP_BORDER_RIGHT_WIDTH:
02358 style->setBorderRightWidth(width);
02359
break;
02360
case CSS_PROP_BORDER_BOTTOM_WIDTH:
02361 style->setBorderBottomWidth(width);
02362
break;
02363
case CSS_PROP_BORDER_LEFT_WIDTH:
02364 style->setBorderLeftWidth(width);
02365
break;
02366
case CSS_PROP_OUTLINE_WIDTH:
02367 style->setOutlineWidth(width);
02368
break;
02369
default:
02370
return;
02371 }
02372
return;
02373 }
02374
02375
case CSS_PROP_LETTER_SPACING:
02376
case CSS_PROP_WORD_SPACING:
02377 {
02378
if (isInherit) {
02379 HANDLE_INHERIT_COND(CSS_PROP_LETTER_SPACING, letterSpacing, LetterSpacing)
02380 HANDLE_INHERIT_COND(CSS_PROP_WORD_SPACING, wordSpacing, WordSpacing)
02381 return;
02382 } else if (isInitial) {
02383 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_LETTER_SPACING, LetterSpacing, LetterWordSpacing)
02384 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_WORD_SPACING, WordSpacing, LetterWordSpacing)
02385 return;
02386 }
02387 if(!primitiveValue) return;
02388
02389
int width = 0;
02390 if (primitiveValue->getIdent() != CSS_VAL_NORMAL)
02391 width = primitiveValue->computeLength(style, paintDeviceMetrics);
02392
02393 switch(
id)
02394 {
02395
case CSS_PROP_LETTER_SPACING:
02396 style->setLetterSpacing(width);
02397
break;
02398
case CSS_PROP_WORD_SPACING:
02399 style->setWordSpacing(width);
02400
break;
02401
02402
default:
break;
02403 }
02404
return;
02405 }
02406
02407
02408
case CSS_PROP_MAX_WIDTH:
02409
02410
if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
02411 apply =
true;
02412
case CSS_PROP_TOP:
02413
case CSS_PROP_LEFT:
02414
case CSS_PROP_RIGHT:
02415
case CSS_PROP_BOTTOM:
02416
case CSS_PROP_WIDTH:
02417
case CSS_PROP_MIN_WIDTH:
02418
case CSS_PROP_MARGIN_TOP:
02419
case CSS_PROP_MARGIN_RIGHT:
02420
case CSS_PROP_MARGIN_BOTTOM:
02421
case CSS_PROP_MARGIN_LEFT:
02422
02423
if(
id != CSS_PROP_MAX_WIDTH && primitiveValue &&
02424 primitiveValue->getIdent() == CSS_VAL_AUTO)
02425 {
02426
02427 apply =
true;
02428 }
02429
case CSS_PROP_PADDING_TOP:
02430
case CSS_PROP_PADDING_RIGHT:
02431
case CSS_PROP_PADDING_BOTTOM:
02432
case CSS_PROP_PADDING_LEFT:
02433
case CSS_PROP_TEXT_INDENT:
02434
02435 {
02436
if (isInherit) {
02437 HANDLE_INHERIT_COND(CSS_PROP_MAX_WIDTH, maxWidth, MaxWidth)
02438 HANDLE_INHERIT_COND(CSS_PROP_BOTTOM, bottom, Bottom)
02439 HANDLE_INHERIT_COND(CSS_PROP_TOP, top, Top)
02440 HANDLE_INHERIT_COND(CSS_PROP_LEFT, left, Left)
02441 HANDLE_INHERIT_COND(CSS_PROP_RIGHT, right, Right)
02442 HANDLE_INHERIT_COND(CSS_PROP_WIDTH, width, Width)
02443 HANDLE_INHERIT_COND(CSS_PROP_MIN_WIDTH, minWidth, MinWidth)
02444 HANDLE_INHERIT_COND(CSS_PROP_PADDING_TOP, paddingTop, PaddingTop)
02445 HANDLE_INHERIT_COND(CSS_PROP_PADDING_RIGHT, paddingRight, PaddingRight)
02446 HANDLE_INHERIT_COND(CSS_PROP_PADDING_BOTTOM, paddingBottom, PaddingBottom)
02447 HANDLE_INHERIT_COND(CSS_PROP_PADDING_LEFT, paddingLeft, PaddingLeft)
02448 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_TOP, marginTop, MarginTop)
02449 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_RIGHT, marginRight, MarginRight)
02450 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_BOTTOM, marginBottom, MarginBottom)
02451 HANDLE_INHERIT_COND(CSS_PROP_MARGIN_LEFT, marginLeft, MarginLeft)
02452 HANDLE_INHERIT_COND(CSS_PROP_TEXT_INDENT, textIndent, TextIndent)
02453 return;
02454 } else if (isInitial) {
02455 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MAX_WIDTH, MaxWidth, MaxSize)
02456 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_BOTTOM, Bottom, Offset)
02457 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_TOP, Top, Offset)
02458 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_LEFT, Left, Offset)
02459 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_RIGHT, Right, Offset)
02460 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_WIDTH, Width, Size)
02461 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MIN_WIDTH, MinWidth, MinSize)
02462 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_TOP, PaddingTop, Padding)
02463 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_RIGHT, PaddingRight, Padding)
02464 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_BOTTOM, PaddingBottom, Padding)
02465 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_PADDING_LEFT, PaddingLeft, Padding)
02466 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_TOP, MarginTop, Margin)
02467 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_RIGHT, MarginRight, Margin)
02468 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_BOTTOM, MarginBottom, Margin)
02469 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MARGIN_LEFT, MarginLeft, Margin)
02470 HANDLE_INITIAL_COND(CSS_PROP_TEXT_INDENT, TextIndent)
02471 return;
02472 }
02473
02474 if (primitiveValue && !apply) {
02475
int type = primitiveValue->primitiveType();
02476
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02477
02478 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed,
02479 primitiveValue->isQuirkValue());
02480
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02481 l = Length((
int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02482
else if (type == CSSPrimitiveValue::CSS_HTML_RELATIVE)
02483 l = Length(
int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_HTML_RELATIVE)), Relative);
02484
else
02485
return;
02486 apply =
true;
02487 }
02488
if(!apply)
return;
02489
switch(
id)
02490 {
02491
case CSS_PROP_MAX_WIDTH:
02492 style->setMaxWidth(l);
break;
02493
case CSS_PROP_BOTTOM:
02494 style->setBottom(l);
break;
02495
case CSS_PROP_TOP:
02496 style->setTop(l);
break;
02497
case CSS_PROP_LEFT:
02498 style->setLeft(l);
break;
02499
case CSS_PROP_RIGHT:
02500 style->setRight(l);
break;
02501
case CSS_PROP_WIDTH:
02502 style->setWidth(l);
break;
02503
case CSS_PROP_MIN_WIDTH:
02504 style->setMinWidth(l);
break;
02505
case CSS_PROP_PADDING_TOP:
02506 style->setPaddingTop(l);
break;
02507
case CSS_PROP_PADDING_RIGHT:
02508 style->setPaddingRight(l);
break;
02509
case CSS_PROP_PADDING_BOTTOM:
02510 style->setPaddingBottom(l);
break;
02511
case CSS_PROP_PADDING_LEFT:
02512 style->setPaddingLeft(l);
break;
02513
case CSS_PROP_MARGIN_TOP:
02514 style->setMarginTop(l);
break;
02515
case CSS_PROP_MARGIN_RIGHT:
02516 style->setMarginRight(l);
break;
02517
case CSS_PROP_MARGIN_BOTTOM:
02518 style->setMarginBottom(l);
break;
02519
case CSS_PROP_MARGIN_LEFT:
02520 style->setMarginLeft(l);
break;
02521
case CSS_PROP_TEXT_INDENT:
02522 style->setTextIndent(l);
break;
02523
default:
break;
02524 }
02525
return;
02526 }
02527
02528
case CSS_PROP_MAX_HEIGHT:
02529
if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
02530 apply =
true;
02531
case CSS_PROP_HEIGHT:
02532
case CSS_PROP_MIN_HEIGHT:
02533
if(
id != CSS_PROP_MAX_HEIGHT && primitiveValue &&
02534 primitiveValue->getIdent() == CSS_VAL_AUTO)
02535 apply =
true;
02536
if (isInherit) {
02537 HANDLE_INHERIT_COND(CSS_PROP_MAX_HEIGHT, maxHeight, MaxHeight)
02538 HANDLE_INHERIT_COND(CSS_PROP_HEIGHT, height, Height)
02539 HANDLE_INHERIT_COND(CSS_PROP_MIN_HEIGHT, minHeight, MinHeight)
02540 return;
02541 }
02542 else if (isInitial) {
02543 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MAX_HEIGHT, MaxHeight, MaxSize)
02544 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_HEIGHT, Height, Size)
02545 HANDLE_INITIAL_COND_WITH_VALUE(CSS_PROP_MIN_HEIGHT, MinHeight, MinSize)
02546 return;
02547 }
02548
02549 if (primitiveValue && !apply)
02550 {
02551
int type = primitiveValue->primitiveType();
02552
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02553 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02554
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02555 l = Length((
int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
02556
else
02557
return;
02558 apply =
true;
02559 }
02560
if(!apply)
return;
02561
switch(
id)
02562 {
02563
case CSS_PROP_MAX_HEIGHT:
02564 style->setMaxHeight(l);
break;
02565
case CSS_PROP_HEIGHT:
02566 style->setHeight(l);
break;
02567
case CSS_PROP_MIN_HEIGHT:
02568 style->setMinHeight(l);
break;
02569
default:
02570
return;
02571 }
02572
return;
02573
02574
break;
02575
02576
case CSS_PROP_VERTICAL_ALIGN:
02577 HANDLE_INHERIT_AND_INITIAL(verticalAlign, VerticalAlign)
02578 if (!primitiveValue) return;
02579 if (primitiveValue->getIdent()) {
02580 khtml::EVerticalAlign align;
02581
02582
switch(primitiveValue->getIdent())
02583 {
02584
case CSS_VAL_TOP:
02585 align = TOP;
break;
02586
case CSS_VAL_BOTTOM:
02587 align = BOTTOM;
break;
02588
case CSS_VAL_MIDDLE:
02589 align = MIDDLE;
break;
02590
case CSS_VAL_BASELINE:
02591 align = BASELINE;
break;
02592
case CSS_VAL_TEXT_BOTTOM:
02593 align = TEXT_BOTTOM;
break;
02594
case CSS_VAL_TEXT_TOP:
02595 align = TEXT_TOP;
break;
02596
case CSS_VAL_SUB:
02597 align = SUB;
break;
02598
case CSS_VAL_SUPER:
02599 align = SUPER;
break;
02600
case CSS_VAL__KHTML_BASELINE_MIDDLE:
02601 align = BASELINE_MIDDLE;
break;
02602
default:
02603
return;
02604 }
02605 style->setVerticalAlign(align);
02606
return;
02607 }
else {
02608
int type = primitiveValue->primitiveType();
02609 Length l;
02610
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
02611 l = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed );
02612
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02613 l = Length(
int( primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE) ), Percent );
02614
02615 style->setVerticalAlign( LENGTH );
02616 style->setVerticalAlignLength( l );
02617 }
02618
break;
02619
02620
case CSS_PROP_FONT_SIZE:
02621 {
02622 FontDef fontDef = style->htmlFont().fontDef;
02623
int oldSize;
02624
int size = 0;
02625
02626
float toPix = paintDeviceMetrics->logicalDpiY()/72.;
02627
if (toPix < 96./72.) toPix = 96./72.;
02628
02629
int minFontSize = int(settings->
minFontSize() * toPix);
02630
02631
if(parentNode) {
02632 oldSize = parentStyle->font().pixelSize();
02633 }
else
02634 oldSize = m_fontSizes[3];
02635
02636
if (isInherit )
02637 size = oldSize;
02638
else if (isInitial)
02639 size = m_fontSizes[3];
02640
else if(primitiveValue->getIdent()) {
02641
02642
02643
#ifdef APPLE_CHANGES
02644
QValueList<int>& fontSizes = (fontDef.genericFamily == FontDef::eMonospace) ?
02645 m_fixedFontSizes : m_fontSizes;
02646
#else
02647
QValueList<int>& fontSizes = m_fontSizes;
02648
#endif
02649
switch(primitiveValue->getIdent())
02650 {
02651
case CSS_VAL_XX_SMALL: size = int( fontSizes[0] );
break;
02652
case CSS_VAL_X_SMALL: size = int( fontSizes[1] );
break;
02653
case CSS_VAL_SMALL: size = int( fontSizes[2] );
break;
02654
case CSS_VAL_MEDIUM: size = int( fontSizes[3] );
break;
02655
case CSS_VAL_LARGE: size = int( fontSizes[4] );
break;
02656
case CSS_VAL_X_LARGE: size = int( fontSizes[5] );
break;
02657
case CSS_VAL_XX_LARGE: size = int( fontSizes[6] );
break;
02658
case CSS_VAL__KHTML_XXX_LARGE: size = ( fontSizes[6]*5 )/3;
break;
02659
case CSS_VAL_LARGER:
02660
02661 size = ( oldSize * 5 ) / 4;
02662
break;
02663
case CSS_VAL_SMALLER:
02664 size = ( oldSize * 4 ) / 5;
02665
break;
02666
default:
02667
return;
02668 }
02669
02670 }
else {
02671
int type = primitiveValue->primitiveType();
02672
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
02673
if (!khtml::printpainter && element && element->getDocument()->view())
02674 size = int( primitiveValue->computeLengthFloat(parentStyle, paintDeviceMetrics) *
02675 element->getDocument()->view()->part()->zoomFactor() ) / 100;
02676
else
02677 size = int( primitiveValue->computeLengthFloat(parentStyle, paintDeviceMetrics) );
02678 }
02679
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
02680 size = int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)
02681 * parentStyle->font().pixelSize()) / 100;
02682
else
02683
return;
02684 }
02685
02686
if(size < 1)
return;
02687
02688
02689
if(size < minFontSize ) size = minFontSize;
02690
02691
02692
02693 fontDef.size = size;
02694 fontDirty |= style->setFontDef( fontDef );
02695
return;
02696 }
02697
02698
case CSS_PROP_Z_INDEX:
02699 {
02700 HANDLE_INHERIT(zIndex, ZIndex)
02701 else if (isInitial) {
02702 style->setHasAutoZIndex();
02703
return;
02704 }
02705
02706
if (!primitiveValue)
02707
return;
02708
02709
if (primitiveValue->getIdent() == CSS_VAL_AUTO) {
02710 style->setHasAutoZIndex();
02711
return;
02712 }
02713
02714
if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_NUMBER)
02715
return;
02716
02717 style->setZIndex((
int)primitiveValue->floatValue(CSSPrimitiveValue::CSS_NUMBER));
02718
return;
02719 }
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
case CSS_PROP_LINE_HEIGHT:
02743 {
02744 HANDLE_INHERIT_AND_INITIAL(lineHeight, LineHeight)
02745 if(!primitiveValue) return;
02746 Length lineHeight;
02747
int type = primitiveValue->primitiveType();
02748 if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
02749 lineHeight = Length( -100, Percent );
02750 else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
02751
#ifdef APPLE_CHANGES
02752
double multiplier = 1.0;
02753
02754
02755
if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && view && view->
part()) {
02756 multiplier = view->
part()->
zoomFactor() / 100.0;
02757 }
02758 lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics, multiplier), Fixed);
02759
#else
02760
lineHeight = Length(primitiveValue->computeLength(style, paintDeviceMetrics), Fixed);
02761
#endif
02762
}
else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
02763 lineHeight = Length( ( style->font().pixelSize() * int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)) ) / 100, Fixed );
02764
else if (type == CSSPrimitiveValue::CSS_NUMBER)
02765 lineHeight = Length(
int(primitiveValue->floatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
02766
else
02767
return;
02768 style->setLineHeight(lineHeight);
02769
return;
02770 }
02771
02772
02773
case CSS_PROP_TEXT_ALIGN:
02774 {
02775 HANDLE_INHERIT_AND_INITIAL(textAlign, TextAlign)
02776 if (!primitiveValue) return;
02777 if (primitiveValue->getIdent())
02778 style->setTextAlign( (ETextAlign) (primitiveValue->getIdent() - CSS_VAL__KHTML_AUTO) );
02779 return;
02780 }
02781
02782
02783 case CSS_PROP_CLIP:
02784 {
02785 Length top;
02786 Length right;
02787 Length bottom;
02788 Length left;
02789
bool hasClip =
true;
02790
if (isInherit) {
02791
if (parentStyle->hasClip()) {
02792 top = parentStyle->clipTop();
02793 right = parentStyle->clipRight();
02794 bottom = parentStyle->clipBottom();
02795 left = parentStyle->clipLeft();
02796 }
02797
else {
02798 hasClip =
false;
02799 top = right = bottom = left = Length();
02800 }
02801 }
else if (isInitial) {
02802 hasClip =
false;
02803 top = right = bottom = left = Length();
02804 }
else if ( !primitiveValue ) {
02805
break;
02806 }
else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RECT ) {
02807 RectImpl *rect = primitiveValue->getRectValue();
02808
if ( !rect )
02809
break;
02810 top = convertToLength( rect->top(), style, paintDeviceMetrics );
02811 right = convertToLength( rect->right(), style, paintDeviceMetrics );
02812 bottom = convertToLength( rect->bottom(), style, paintDeviceMetrics );
02813 left = convertToLength( rect->left(), style, paintDeviceMetrics );
02814
02815 }
else if ( primitiveValue->getIdent() != CSS_VAL_AUTO ) {
02816
break;
02817 }
02818
02819
02820
02821
02822 style->setClip(top, right, bottom, left );
02823 style->setHasClip(hasClip);
02824
02825
break;
02826 }
02827
02828
02829
case CSS_PROP_CONTENT:
02830
02831 {
02832
02833
02834
if (!(style->styleType()==RenderStyle::BEFORE ||
02835 style->styleType()==RenderStyle::AFTER))
02836
break;
02837
02838
if (isInitial) {
02839
if (style->contentData())
02840 style->contentData()->clearContent();
02841
return;
02842 }
02843
02844
if(!value->isValueList())
return;
02845 CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
02846
int len = list->length();
02847
02848
for(
int i = 0; i < len; i++) {
02849 CSSValueImpl *item = list->item(i);
02850
if(!item->isPrimitiveValue())
continue;
02851 CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
02852
if(val->primitiveType()==CSSPrimitiveValue::CSS_STRING)
02853 {
02854 style->setContent(val->getStringValue(), i != 0);
02855 }
02856
else if (val->primitiveType()==CSSPrimitiveValue::CSS_ATTR)
02857 {
02858
#ifdef APPLE_CHANGES
02859
int attrID = element->getDocument()->attrId(0, val->getStringValue(),
false);
02860
if (attrID)
02861 style->setContent(element->getAttribute(attrID).implementation(), i != 0);
02862
#else
02863
int attrID = element->getDocument()->getId(NodeImpl::AttributeId, val->getStringValue(),
false,
true);
02864
if (attrID)
02865 style->setContent(element->getAttribute(attrID).implementation(), i != 0);
02866
#endif
02867
}
02868
else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI)
02869 {
02870 CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(val);
02871 style->setContent(image->image(), i != 0);
02872 }
02873
02874 }
02875
break;
02876 }
02877
02878
case CSS_PROP_COUNTER_INCREMENT:
02879
02880
case CSS_PROP_COUNTER_RESET:
02881
02882
break;
02883
case CSS_PROP_FONT_FAMILY:
02884
02885 {
02886
if (isInherit) {
02887 FontDef parentFontDef = parentStyle->htmlFont().fontDef;
02888 FontDef fontDef = style->htmlFont().fontDef;
02889 fontDef.family = parentFontDef.family;
02890
if (style->setFontDef(fontDef))
02891 fontDirty =
true;
02892
return;
02893 }
02894
else if (isInitial) {
02895 FontDef fontDef = style->htmlFont().fontDef;
02896 FontDef initialDef = FontDef();
02897
#ifdef APPLE_CHANGES
02898
fontDef.family = initialDef.firstFamily();
02899
#else
02900
fontDef.family = QString::null;
02901
#endif
02902
if (style->setFontDef(fontDef))
02903 fontDirty =
true;
02904
return;
02905 }
02906
if(!value->isValueList())
return;
02907 FontDef fontDef = style->htmlFont().fontDef;
02908 CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
02909
int len = list->length();
02910
for(
int i = 0; i < len; i++) {
02911 CSSValueImpl *item = list->item(i);
02912
if(!item->isPrimitiveValue())
continue;
02913 CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
02914
QString face;
02915
if( val->primitiveType() == CSSPrimitiveValue::CSS_STRING )
02916 face = static_cast<FontFamilyValueImpl *>(val)->fontName();
02917
else if ( val->primitiveType() == CSSPrimitiveValue::CSS_IDENT ) {
02918
switch( val->getIdent() ) {
02919
case CSS_VAL_SERIF:
02920 face = settings->
serifFontName();
02921
break;
02922
case CSS_VAL_SANS_SERIF:
02923 face = settings->
sansSerifFontName();
02924
break;
02925
case CSS_VAL_CURSIVE:
02926 face = settings->
cursiveFontName();
02927
break;
02928
case CSS_VAL_FANTASY:
02929 face = settings->
fantasyFontName();
02930
break;
02931
case CSS_VAL_MONOSPACE:
02932 face = settings->
fixedFontName();
02933
break;
02934
default:
02935
return;
02936 }
02937 }
else {
02938
return;
02939 }
02940
if ( !face.isEmpty() ) {
02941 fontDef.family = face;
02942 fontDirty |= style->setFontDef( fontDef );
02943
return;
02944 }
02945 }
02946
break;
02947 }
02948
case CSS_PROP_QUOTES:
02949
02950
case CSS_PROP_SIZE:
02951
02952
break;
02953
case CSS_PROP_TEXT_DECORATION: {
02954
02955 HANDLE_INHERIT_AND_INITIAL(textDecoration, TextDecoration)
02956 int t = RenderStyle::initialTextDecoration();
02957 if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE) {
02958
02959 }
else {
02960
if(!value->isValueList())
return;
02961 CSSValueListImpl *list = static_cast<CSSValueListImpl *>(value);
02962
int len = list->length();
02963
for(
int i = 0; i < len; i++)
02964 {
02965 CSSValueImpl *item = list->item(i);
02966
if(!item->isPrimitiveValue())
continue;
02967 primitiveValue = static_cast<CSSPrimitiveValueImpl *>(item);
02968
switch(primitiveValue->getIdent())
02969 {
02970
case CSS_VAL_NONE:
02971 t = TDNONE;
break;
02972
case CSS_VAL_UNDERLINE:
02973 t |= UNDERLINE;
break;
02974
case CSS_VAL_OVERLINE:
02975 t |= OVERLINE;
break;
02976
case CSS_VAL_LINE_THROUGH:
02977 t |= LINE_THROUGH;
break;
02978
case CSS_VAL_BLINK:
02979 t |= BLINK;
break;
02980
default:
02981
return;
02982 }
02983 }
02984 }
02985 style->setTextDecoration(t);
02986
break;
02987 }
02988
case CSS_PROP__KHTML_FLOW_MODE:
02989 HANDLE_INHERIT_AND_INITIAL(flowAroundFloats, FlowAroundFloats)
02990 if (!primitiveValue) return;
02991 if (primitiveValue->getIdent()) {
02992 style->setFlowAroundFloats( primitiveValue->getIdent() == CSS_VAL__KHTML_AROUND_FLOATS );
02993
return;
02994 }
02995
break;
02996
case CSS_PROP__KHTML_USER_INPUT: {
02997
if(value->cssValueType() == CSSValue::CSS_INHERIT)
02998 {
02999
if(!parentNode)
return;
03000 style->setUserInput(parentStyle->userInput());
03001
03002
return;
03003 }
03004
if(!primitiveValue)
return;
03005
int id = primitiveValue->getIdent();
03006
if (
id == CSS_VAL_NONE)
03007 style->setUserInput(UI_NONE);
03008
else
03009 style->setUserInput(EUserInput(
id - CSS_VAL_ENABLED));
03010
03011
return;
03012 }
03013
03014
03015
case CSS_PROP_BACKGROUND:
03016
if (isInherit) {
03017 style->setBackgroundColor(parentStyle->backgroundColor());
03018 style->setBackgroundImage(parentStyle->backgroundImage());
03019 style->setBackgroundRepeat(parentStyle->backgroundRepeat());
03020 style->setBackgroundAttachment(parentStyle->backgroundAttachment());
03021 style->setBackgroundXPosition(parentStyle->backgroundXPosition());
03022 style->setBackgroundYPosition(parentStyle->backgroundYPosition());
03023 }
03024
else if (isInitial) {
03025 style->setBackgroundColor(
QColor());
03026 style->setBackgroundImage(RenderStyle::initialBackgroundImage());
03027 style->setBackgroundRepeat(RenderStyle::initialBackgroundRepeat());
03028 style->setBackgroundAttachment(RenderStyle::initialBackgroundAttachment());
03029 style->setBackgroundXPosition(RenderStyle::initialBackgroundXPosition());
03030 style->setBackgroundYPosition(RenderStyle::initialBackgroundYPosition());
03031 }
03032
break;
03033
case CSS_PROP_BORDER_COLOR:
03034
if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_TRANSPARENT)
03035 {
03036 style->setBorderTopColor(
QColor());
03037 style->setBorderBottomColor(
QColor());
03038 style->setBorderLeftColor(
QColor());
03039 style->setBorderRightColor(
QColor());
03040
return;
03041 }
03042
case CSS_PROP_BORDER:
03043
case CSS_PROP_BORDER_STYLE:
03044
case CSS_PROP_BORDER_WIDTH:
03045
if(
id == CSS_PROP_BORDER ||
id == CSS_PROP_BORDER_COLOR)
03046 {
03047
if (isInherit) {
03048 style->setBorderTopColor(parentStyle->borderTopColor());
03049 style->setBorderBottomColor(parentStyle->borderBottomColor());
03050 style->setBorderLeftColor(parentStyle->borderLeftColor());
03051 style->setBorderRightColor(parentStyle->borderRightColor());
03052 }
03053
else if (isInitial) {
03054 style->setBorderTopColor(
QColor());
03055 style->setBorderBottomColor(
QColor());
03056 style->setBorderLeftColor(
QColor());
03057 style->setBorderRightColor(
QColor());
03058 }
03059 }
03060
if (
id == CSS_PROP_BORDER ||
id == CSS_PROP_BORDER_STYLE)
03061 {
03062
if (isInherit) {
03063 style->setBorderTopStyle(parentStyle->borderTopStyle());
03064 style->setBorderBottomStyle(parentStyle->borderBottomStyle());
03065 style->setBorderLeftStyle(parentStyle->borderLeftStyle());
03066 style->setBorderRightStyle(parentStyle->borderRightStyle());
03067 }
03068
else if (isInitial) {
03069 style->setBorderTopStyle(RenderStyle::initialBorderStyle());
03070 style->setBorderBottomStyle(RenderStyle::initialBorderStyle());
03071 style->setBorderLeftStyle(RenderStyle::initialBorderStyle());
03072 style->setBorderRightStyle(RenderStyle::initialBorderStyle());
03073 }
03074 }
03075
if (
id == CSS_PROP_BORDER ||
id == CSS_PROP_BORDER_WIDTH)
03076 {
03077
if (isInherit) {
03078 style->setBorderTopWidth(parentStyle->borderTopWidth());
03079 style->setBorderBottomWidth(parentStyle->borderBottomWidth());
03080 style->setBorderLeftWidth(parentStyle->borderLeftWidth());
03081 style->setBorderRightWidth(parentStyle->borderRightWidth());
03082 }
03083
else if (isInitial) {
03084 style->setBorderTopWidth(RenderStyle::initialBorderWidth());
03085 style->setBorderBottomWidth(RenderStyle::initialBorderWidth());
03086 style->setBorderLeftWidth(RenderStyle::initialBorderWidth());
03087 style->setBorderRightWidth(RenderStyle::initialBorderWidth());
03088 }
03089 }
03090
return;
03091
case CSS_PROP_BORDER_TOP:
03092
if ( isInherit ) {
03093 style->setBorderTopColor(parentStyle->borderTopColor());
03094 style->setBorderTopStyle(parentStyle->borderTopStyle());
03095 style->setBorderTopWidth(parentStyle->borderTopWidth());
03096 }
else if (isInitial)
03097 style->resetBorderTop();
03098
return;
03099
case CSS_PROP_BORDER_RIGHT:
03100
if (isInherit) {
03101 style->setBorderRightColor(parentStyle->borderRightColor());
03102 style->setBorderRightStyle(parentStyle->borderRightStyle());
03103 style->setBorderRightWidth(parentStyle->borderRightWidth());
03104 }
03105
else if (isInitial)
03106 style->resetBorderRight();
03107
return;
03108
case CSS_PROP_BORDER_BOTTOM:
03109
if (isInherit) {
03110 style->setBorderBottomColor(parentStyle->borderBottomColor());
03111 style->setBorderBottomStyle(parentStyle->borderBottomStyle());
03112 style->setBorderBottomWidth(parentStyle->borderBottomWidth());
03113 }
03114
else if (isInitial)
03115 style->resetBorderBottom();
03116
return;
03117
case CSS_PROP_BORDER_LEFT:
03118
if (isInherit) {
03119 style->setBorderLeftColor(parentStyle->borderLeftColor());
03120 style->setBorderLeftStyle(parentStyle->borderLeftStyle());
03121 style->setBorderLeftWidth(parentStyle->borderLeftWidth());
03122 }
03123
else if (isInitial)
03124 style->resetBorderLeft();
03125
return;
03126
case CSS_PROP_MARGIN:
03127
if (isInherit) {
03128 style->setMarginTop(parentStyle->marginTop());
03129 style->setMarginBottom(parentStyle->marginBottom());
03130 style->setMarginLeft(parentStyle->marginLeft());
03131 style->setMarginRight(parentStyle->marginRight());
03132 }
03133
else if (isInitial)
03134 style->resetMargin();
03135
return;
03136
case CSS_PROP_PADDING:
03137
if (isInherit) {
03138 style->setPaddingTop(parentStyle->paddingTop());
03139 style->setPaddingBottom(parentStyle->paddingBottom());
03140 style->setPaddingLeft(parentStyle->paddingLeft());
03141 style->setPaddingRight(parentStyle->paddingRight());
03142 }
03143
else if (isInitial)
03144 style->resetPadding();
03145
return;
03146
case CSS_PROP_FONT:
03147
if ( isInherit ) {
03148 FontDef fontDef = parentStyle->htmlFont().fontDef;
03149 style->setLineHeight( parentStyle->lineHeight() );
03150 fontDirty |= style->setFontDef( fontDef );
03151 }
else if (isInitial) {
03152 FontDef fontDef;
03153 style->setLineHeight(RenderStyle::initialLineHeight());
03154
if (style->setFontDef( fontDef ))
03155 fontDirty =
true;
03156 }
else if ( value->isFontValue() ) {
03157 FontValueImpl *font = static_cast<FontValueImpl *>(value);
03158
if ( !font->style || !font->variant || !font->weight ||
03159 !font->size || !font->lineHeight || !font->family )
03160
return;
03161 applyRule( CSS_PROP_FONT_STYLE, font->style );
03162 applyRule( CSS_PROP_FONT_VARIANT, font->variant );
03163 applyRule( CSS_PROP_FONT_WEIGHT, font->weight );
03164 applyRule( CSS_PROP_FONT_SIZE, font->size );
03165
03166
03167
03168
03169
if (fontDirty)
03170 CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
03171
03172 applyRule( CSS_PROP_LINE_HEIGHT, font->lineHeight );
03173 applyRule( CSS_PROP_FONT_FAMILY, font->family );
03174 }
03175
return;
03176
03177
case CSS_PROP_LIST_STYLE:
03178
if (isInherit) {
03179 style->setListStyleType(parentStyle->listStyleType());
03180 style->setListStyleImage(parentStyle->listStyleImage());
03181 style->setListStylePosition(parentStyle->listStylePosition());
03182 }
03183
else if (isInitial) {
03184 style->setListStyleType(RenderStyle::initialListStyleType());
03185 style->setListStyleImage(RenderStyle::initialListStyleImage());
03186 style->setListStylePosition(RenderStyle::initialListStylePosition());
03187 }
03188
break;
03189
case CSS_PROP_OUTLINE:
03190
if (isInherit) {
03191 style->setOutlineWidth(parentStyle->outlineWidth());
03192 style->setOutlineColor(parentStyle->outlineColor());
03193 style->setOutlineStyle(parentStyle->outlineStyle());
03194 }
03195
else if (isInitial)
03196 style->resetOutline();
03197
break;
03198
default:
03199
return;
03200 }
03201 }
03202
03203
#ifdef APPLE_CHANGES
03204
void CSSStyleSelector::checkForGenericFamilyChange(RenderStyle* aStyle, RenderStyle* aParentStyle)
03205 {
03206
const FontDef& childFont = aStyle->htmlFont().fontDef;
03207
03208
if (childFont.sizeSpecified || !aParentStyle)
03209
return;
03210
03211
const FontDef& parentFont = aParentStyle->htmlFont().fontDef;
03212
03213
if (childFont.genericFamily == parentFont.genericFamily)
03214
return;
03215
03216
03217
if (childFont.genericFamily != FontDef::eMonospace &&
03218 parentFont.genericFamily != FontDef::eMonospace)
03219
return;
03220
03221
03222
03223
03224
float size = 0;
03225
int minFontSize = settings->
minFontSize();
03226 size = (childFont.genericFamily == FontDef::eMonospace) ? m_fixedFontSizes[3] : m_fontSizes[3];
03227
int isize = (
int)size;
03228
if (isize < minFontSize)
03229 isize = minFontSize;
03230
03231 FontDef newFontDef(childFont);
03232 newFontDef.size = isize;
03233 aStyle->setFontDef(newFontDef);
03234 }
03235
#endif
03236
03237 }