1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
|
/*
* This file is part of the DOM implementation for KDE.
*
* Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000-2003 Dirk Mueller (mueller@kde.org)
* (C) 2003-2005 Apple Computer, Inc.
* (C) 2004-2006 Allan Sandfeld Jensen (kde@carewolf.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef RENDERSTYLE_H
#define RENDERSTYLE_H
/*
* WARNING:
* --------
*
* The order of the values in the enums have to agree with the order specified
* in cssvalues.in, otherwise some optimizations in the parser will fail,
* and produce invaliud results.
*/
#include <tqcolor.h>
#include <tqfont.h>
#include <tqfontmetrics.h>
#include <tqptrlist.h>
#include <tqpalette.h>
#include <tqapplication.h>
#include "dom/dom_misc.h"
#include "dom/dom_string.h"
#include "misc/tdehtmllayout.h"
#include "misc/shared.h"
#include "rendering/font.h"
#include <assert.h>
#define SET_VAR(group,variable,value) \
if (!(group->variable == value)) \
group.access()->variable = value;
#ifndef ENABLE_DUMP
#ifndef NDEBUG
#define ENABLE_DUMP 1
#endif
#endif
namespace DOM {
class DOMStringImpl;
class ShadowValueImpl;
class QuotesValueImpl;
class CounterImpl;
class CSSValueListImpl;
class CounterActImpl;
}
namespace tdehtml {
class CachedImage;
class CachedObject;
template <class DATA>
class DataRef
{
public:
DataRef()
{
data=0;
}
DataRef( const DataRef<DATA> &d )
{
data = d.data;
data->ref();
}
~DataRef()
{
if(data) data->deref();
}
const DATA* operator->() const
{
return data;
}
const DATA* get() const
{
return data;
}
DATA* access()
{
if (!data->hasOneRef())
{
data->deref();
data = new DATA(*data);
data->ref();
}
return data;
}
void init()
{
data = new DATA;
data->ref();
}
DataRef<DATA>& operator=(const DataRef<DATA>& d)
{
if (data==d.data)
return *this;
if (data)
data->deref();
data = d.data;
data->ref();
return *this;
}
bool operator == ( const DataRef<DATA> &o ) const {
return (*data == *(o.data) );
}
bool operator != ( const DataRef<DATA> &o ) const {
return (*data != *(o.data) );
}
private:
DATA* data;
};
//------------------------------------------------
//------------------------------------------------
// Box model attributes. Not inherited.
struct LengthBox
{
LengthBox()
{
}
LengthBox( LengthType t )
: left( t ), right ( t ), top( t ), bottom( t ) {}
Length left;
Length right;
Length top;
Length bottom;
Length& operator=(Length& len)
{
left=len;
right=len;
top=len;
bottom=len;
return len;
}
bool operator==(const LengthBox& o) const
{
return left==o.left && right==o.right && top==o.top && bottom==o.bottom;
}
bool nonZero() const { return left.value() || right.value() || top.value() || bottom.value(); }
};
enum EPosition {
STATIC, RELATIVE, ABSOLUTE, FIXED
};
enum EFloat {
FNONE = 0, FLEFT = 0x01, FRIGHT = 0x02, FLEFT_ALIGN = 0x05, FRIGHT_ALIGN = 0x06
};
enum EWordWrap {
WWNORMAL = 0, WWBREAKWORD = 0x01
};
//------------------------------------------------
// Border attributes. Not inherited.
// These have been defined in the order of their precedence for border-collapsing. Do
// not change this order!
enum EBorderStyle {
BNATIVE, BNONE, BHIDDEN, INSET, GROOVE, RIDGE, OUTSET, DOTTED, DASHED, SOLID, DOUBLE
};
class BorderValue
{
public:
BorderValue() : width( 3 ), style( BNONE ) {}
TQColor color;
unsigned short width : 12;
EBorderStyle style : 6;
bool nonZero(bool checkStyle = true) const {
return width != 0 && !(checkStyle && style == BNONE);
}
bool isTransparent() const {
return color.isValid() && tqAlpha(color.rgb()) == 0;
}
bool operator==(const BorderValue& o) const
{
return width==o.width && style==o.style && color==o.color;
}
bool operator!=(const BorderValue& o) const
{
return !(*this == o);
}
};
class OutlineValue : public BorderValue
{
public:
OutlineValue()
{
_offset = 0;
_auto = false;
}
bool operator==(const OutlineValue& o) const
{
return width==o.width && style==o.style && color==o.color && _offset == o._offset && _auto == o._auto;
}
bool operator!=(const OutlineValue& o) const
{
return !(*this == o);
}
int _offset;
bool _auto;
};
enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };
struct CollapsedBorderValue
{
CollapsedBorderValue() :border(0), precedence(BOFF) {}
CollapsedBorderValue(const BorderValue* b, EBorderPrecedence p) :border(b), precedence(p) {}
int width() const { return border && border->nonZero() ? border->width : 0; }
EBorderStyle style() const { return border ? border->style : BHIDDEN; }
bool exists() const { return border; }
TQColor color() const { return border ? border->color : TQColor(); }
bool isTransparent() const { return border ? border->isTransparent() : true; }
bool operator==(const CollapsedBorderValue& o) const
{
if (!border) return !o.border;
if (!o.border) return false;
return *border == *o.border && precedence == o.precedence;
}
const BorderValue* border;
EBorderPrecedence precedence;
};
class BorderData : public Shared<BorderData>
{
public:
BorderValue left;
BorderValue right;
BorderValue top;
BorderValue bottom;
bool hasBorder() const
{
return left.nonZero() || right.nonZero() || top.nonZero() || bottom.nonZero();
}
unsigned short borderLeftWidth() const {
if (left.style == BNONE || left.style == BHIDDEN || left.style == BNATIVE)
return 0;
return left.width;
}
unsigned short borderRightWidth() const {
if (right.style == BNONE || right.style == BHIDDEN || right.style == BNATIVE)
return 0;
return right.width;
}
unsigned short borderTopWidth() const {
if (top.style == BNONE || top.style == BHIDDEN || top.style == BNATIVE)
return 0;
return top.width;
}
unsigned short borderBottomWidth() const {
if (bottom.style == BNONE || bottom.style == BHIDDEN || bottom.style == BNATIVE)
return 0;
return bottom.width;
}
bool operator==(const BorderData& o) const
{
return left==o.left && right==o.right && top==o.top && bottom==o.bottom;
}
};
class StyleSurroundData : public Shared<StyleSurroundData>
{
public:
StyleSurroundData();
StyleSurroundData(const StyleSurroundData& o );
bool operator==(const StyleSurroundData& o) const;
bool operator!=(const StyleSurroundData& o) const {
return !(*this == o);
}
bool hasSamePBMData(const StyleSurroundData& o) const {
return (margin == o.margin) && (padding == o.padding) && (border == o.border);
}
LengthBox offset;
LengthBox margin;
LengthBox padding;
BorderData border;
};
//------------------------------------------------
// Box attributes. Not inherited.
enum EBoxSizing {
BORDER_BOX, CONTENT_BOX
};
class StyleBoxData : public Shared<StyleBoxData>
{
public:
StyleBoxData();
StyleBoxData(const StyleBoxData& o );
// copy and assignment
// StyleBoxData(const StyleBoxData &other);
// const StyleBoxData &operator = (const StyleBoxData &other);
bool operator==(const StyleBoxData& o) const;
bool operator!=(const StyleBoxData& o) const {
return !(*this == o);
}
Length width;
Length height;
Length min_width;
Length max_width;
Length min_height;
Length max_height;
Length vertical_align;
EBoxSizing box_sizing;
signed int z_index :31;
bool z_auto : 1;
};
//------------------------------------------------
// Random visual rendering model attributes. Not inherited.
enum EOverflow {
OVISIBLE, OHIDDEN, OSCROLL, OAUTO, OMARQUEE
};
enum EVerticalAlign {
BASELINE, MIDDLE, SUB, SUPER, TEXT_TOP,
TEXT_BOTTOM, TOP, BOTTOM, BASELINE_MIDDLE, LENGTH
};
enum EClear{
CNONE = 0, CLEFT = 1, CRIGHT = 2, CBOTH = 3
};
enum ETableLayout {
TAUTO, TFIXED
};
enum EUnicodeBidi {
UBNormal, Embed, Override
};
class StyleVisualData : public Shared<StyleVisualData>
{
public:
StyleVisualData();
~StyleVisualData();
StyleVisualData(const StyleVisualData& o );
bool operator==( const StyleVisualData &o ) const {
return ( clip == o.clip &&
palette == o.palette );
}
bool operator!=( const StyleVisualData &o ) const {
return !(*this == o);
}
LengthBox clip;
unsigned textDecoration : 4; // Text decorations defined *only* by this element.
TQPalette palette; //widget styling with IE attributes
};
//------------------------------------------------
enum EBackgroundBox {
BGBORDER, BGPADDING, BGCONTENT
};
enum EBackgroundRepeat {
REPEAT, REPEAT_X, REPEAT_Y, NO_REPEAT
};
struct LengthSize {
Length width;
Length height;
};
struct BackgroundLayer {
public:
BackgroundLayer();
~BackgroundLayer();
CachedImage* backgroundImage() const { return m_image; }
Length backgroundXPosition() const { return m_xPosition; }
Length backgroundYPosition() const { return m_yPosition; }
bool backgroundAttachment() const { return m_bgAttachment; }
EBackgroundBox backgroundClip() const { return m_bgClip; }
EBackgroundBox backgroundOrigin() const { return m_bgOrigin; }
EBackgroundRepeat backgroundRepeat() const { return m_bgRepeat; }
LengthSize backgroundSize() const { return m_backgroundSize; }
BackgroundLayer* next() const { return m_next; }
BackgroundLayer* next() { return m_next; }
bool isBackgroundImageSet() const { return m_imageSet; }
bool isBackgroundXPositionSet() const { return m_xPosSet; }
bool isBackgroundYPositionSet() const { return m_yPosSet; }
bool isBackgroundAttachmentSet() const { return m_attachmentSet; }
bool isBackgroundClipSet() const { return m_clipSet; }
bool isBackgroundOriginSet() const { return m_originSet; }
bool isBackgroundRepeatSet() const { return m_repeatSet; }
bool isBackgroundSizeSet() const { return m_backgroundSizeSet; }
void setBackgroundImage(CachedImage* i) { m_image = i; m_imageSet = true; }
void setBackgroundXPosition(const Length& l) { m_xPosition = l; m_xPosSet = true; }
void setBackgroundYPosition(const Length& l) { m_yPosition = l; m_yPosSet = true; }
void setBackgroundAttachment(bool b) { m_bgAttachment = b; m_attachmentSet = true; }
void setBackgroundClip(EBackgroundBox b) { m_bgClip = b; m_clipSet = true; }
void setBackgroundOrigin(EBackgroundBox b) { m_bgOrigin = b; m_originSet = true; }
void setBackgroundRepeat(EBackgroundRepeat r) { m_bgRepeat = r; m_repeatSet = true; }
void setBackgroundSize(const LengthSize& b) { m_backgroundSize = b; m_backgroundSizeSet = true; }
void clearBackgroundImage() { m_imageSet = false; }
void clearBackgroundXPosition() { m_xPosSet = false; }
void clearBackgroundYPosition() { m_yPosSet = false; }
void clearBackgroundAttachment() { m_attachmentSet = false; }
void clearBackgroundClip() { m_clipSet = false; }
void clearBackgroundOrigin() { m_originSet = false; }
void clearBackgroundRepeat() { m_repeatSet = false; }
void clearBackgroundSize() { m_backgroundSizeSet = false; }
void setNext(BackgroundLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
BackgroundLayer& operator=(const BackgroundLayer& o);
BackgroundLayer(const BackgroundLayer& o);
bool operator==(const BackgroundLayer& o) const;
bool operator!=(const BackgroundLayer& o) const {
return !(*this == o);
}
bool containsImage(CachedImage* c) const { if (c == m_image) return true; if (m_next) return m_next->containsImage(c); return false; }
bool hasImage() const {
if (m_image)
return true;
return m_next ? m_next->hasImage() : false;
}
bool hasFixedImage() const {
if (m_image && !m_bgAttachment)
return true;
return m_next ? m_next->hasFixedImage() : false;
}
void fillUnsetProperties();
void cullEmptyLayers();
CachedImage* m_image;
Length m_xPosition;
Length m_yPosition;
bool m_bgAttachment : 1;
EBackgroundBox m_bgClip : 2;
EBackgroundBox m_bgOrigin : 2;
EBackgroundRepeat m_bgRepeat : 2;
LengthSize m_backgroundSize;
bool m_imageSet : 1;
bool m_attachmentSet : 1;
bool m_clipSet : 1;
bool m_originSet : 1;
bool m_repeatSet : 1;
bool m_xPosSet : 1;
bool m_yPosSet : 1;
bool m_backgroundSizeSet : 1;
BackgroundLayer* m_next;
};
class StyleBackgroundData : public Shared<StyleBackgroundData>
{
public:
StyleBackgroundData();
~StyleBackgroundData() {}
StyleBackgroundData(const StyleBackgroundData& o );
bool operator==(const StyleBackgroundData& o) const;
bool operator!=(const StyleBackgroundData &o) const {
return !(*this == o);
}
BackgroundLayer m_background;
TQColor m_color;
OutlineValue m_outline;
};
enum EQuoteContent {
NO_QUOTE = 0, OPEN_QUOTE, CLOSE_QUOTE, NO_OPEN_QUOTE, NO_CLOSE_QUOTE
};
enum ContentType {
CONTENT_NONE = 0, CONTENT_NORMAL, CONTENT_OBJECT,
CONTENT_TEXT, CONTENT_COUNTER, CONTENT_QUOTE
};
struct ContentData {
ContentData() : _contentType( CONTENT_NONE ), _nextContent(0) {}
ContentData(const ContentData& o);
~ContentData();
void clearContent();
DOM::DOMStringImpl* contentText()
{ if (_contentType == CONTENT_TEXT) return _content.text; return 0; }
CachedObject* contentObject()
{ if (_contentType == CONTENT_OBJECT) return _content.object; return 0; }
DOM::CounterImpl* contentCounter()
{ if (_contentType == CONTENT_COUNTER) return _content.counter; return 0; }
EQuoteContent contentQuote()
{ if (_contentType == CONTENT_QUOTE) return _content.quote; return NO_QUOTE; }
ContentType _contentType;
union {
CachedObject* object;
DOM::DOMStringImpl* text;
DOM::CounterImpl* counter;
EQuoteContent quote;
} _content ;
ContentData* _nextContent;
};
class StyleGeneratedData : public Shared<StyleGeneratedData>
{
public:
StyleGeneratedData();
~StyleGeneratedData();
StyleGeneratedData(const StyleGeneratedData& o );
bool operator==(const StyleGeneratedData& o) const;
bool operator!=(const StyleGeneratedData &o) const {
return !(*this == o);
}
bool contentDataEquivalent(const StyleGeneratedData* otherStyle) const;
bool counterDataEquivalent(const StyleGeneratedData* otherStyle) const;
ContentData *content;
DOM::CSSValueListImpl *counter_reset;
DOM::CSSValueListImpl *counter_increment;
};
//------------------------------------------------
// CSS3 Marquee Properties
enum EMarqueeBehavior { MNONE, MSCROLL, MSLIDE, MALTERNATE, MUNFURL };
enum EMarqueeDirection { MAUTO = 0, MLEFT = 1, MRIGHT = -1, MUP = 2, MDOWN = -2, MFORWARD = 3, MBACKWARD = -3 };
class StyleMarqueeData : public Shared<StyleMarqueeData>
{
public:
StyleMarqueeData();
StyleMarqueeData(const StyleMarqueeData& o);
bool operator==(const StyleMarqueeData& o) const;
bool operator!=(const StyleMarqueeData& o) const {
return !(*this == o);
}
Length increment;
int speed;
int loops; // -1 means infinite.
EMarqueeBehavior behavior : 3;
EMarqueeDirection direction : 3;
};
// This struct holds information about shadows for the text-shadow and box-shadow properties.
struct ShadowData {
ShadowData(int _x, int _y, int _blur, const TQColor& _color)
:x(_x), y(_y), blur(_blur), color(_color), next(0) {}
ShadowData(const ShadowData& o);
~ShadowData() { delete next; }
bool operator==(const ShadowData& o) const;
bool operator!=(const ShadowData &o) const {
return !(*this == o);
}
int x;
int y;
int blur;
TQColor color;
ShadowData* next;
};
// This struct is for rarely used non-inherited CSS3 properties. By grouping them together,
// we save space, and only allocate this object when someone actually uses
// a non-inherited CSS3 property.
class StyleCSS3NonInheritedData : public Shared<StyleCSS3NonInheritedData>
{
public:
StyleCSS3NonInheritedData();
~StyleCSS3NonInheritedData() {}
StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o);
bool operator==(const StyleCSS3NonInheritedData& o) const;
bool operator!=(const StyleCSS3NonInheritedData &o) const {
return !(*this == o);
}
float opacity; // Whether or not we're transparent.
#ifdef APPLE_CHANGES // ### we don't have those (yet)
DataRef<StyleFlexibleBoxData> flexibleBox; // Flexible box properties
#endif
DataRef<StyleMarqueeData> marquee; // Marquee properties
};
// This struct is for rarely used inherited CSS3 properties. By grouping them together,
// we save space, and only allocate this object when someone actually uses
// an inherited CSS3 property.
class StyleCSS3InheritedData : public Shared<StyleCSS3InheritedData>
{
public:
StyleCSS3InheritedData();
~StyleCSS3InheritedData();
StyleCSS3InheritedData(const StyleCSS3InheritedData& o);
bool operator==(const StyleCSS3InheritedData& o) const;
bool operator!=(const StyleCSS3InheritedData &o) const {
return !(*this == o);
}
bool shadowDataEquivalent(const StyleCSS3InheritedData& o) const;
ShadowData* textShadow; // Our text shadow information for shadowed text drawing.
#ifdef APPLE_CHANGES
EUserModify userModify : 2; // Flag used for editing state
bool textSizeAdjust : 1; // An Apple extension. Not really CSS3 but not worth making a new struct over.
#endif
EWordWrap wordWrap : 1;
private:
StyleCSS3InheritedData &operator=(const StyleCSS3InheritedData &);
};
//------------------------------------------------
// Inherited attributes.
//
// the inherited-decoration and inherited-shadow attributes
// are inherited from the
// first parent which is block level
//
enum EWhiteSpace {
NORMAL, PRE, NOWRAP, PRE_WRAP, PRE_LINE, TDEHTML_NOWRAP
};
enum ETextAlign {
TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, TDEHTML_LEFT, TDEHTML_RIGHT, TDEHTML_CENTER
};
enum ETextTransform {
CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
};
enum EDirection {
LTR, RTL
};
enum ETextDecoration {
TDNONE = 0x0 , UNDERLINE = 0x1, OVERLINE = 0x2, LINE_THROUGH= 0x4, BLINK = 0x8
};
enum EPageBreak {
PBAUTO, PBALWAYS, PBAVOID,
/* reserved for later use: */
PBLEFT, PBRIGHT
};
class StyleInheritedData : public Shared<StyleInheritedData>
{
StyleInheritedData& operator=(const StyleInheritedData&);
public:
StyleInheritedData();
~StyleInheritedData();
StyleInheritedData(const StyleInheritedData& o );
bool operator==(const StyleInheritedData& o) const;
bool operator != ( const StyleInheritedData &o ) const {
return !(*this == o);
}
Length indent;
// could be packed in a short but doesn't
// make a difference currently because of padding
Length line_height;
CachedImage *style_image;
tdehtml::Font font;
TQColor color;
short border_hspacing;
short border_vspacing;
// Paged media properties.
short widows;
short orphans;
DOM::QuotesValueImpl* quotes;
};
enum EEmptyCell {
SHOW, HIDE
};
enum ECaptionSide {
CAPTOP, CAPBOTTOM, CAPLEFT, CAPRIGHT
};
enum EListStyleType {
// Symbols:
LDISC, LCIRCLE, LSQUARE, LBOX, LDIAMOND,
// Numeric:
LDECIMAL, DECIMAL_LEADING_ZERO, ARABIC_INDIC, LAO, PERSIAN, URDU, THAI, TIBETAN,
// Algorithmic:
LOWER_ROMAN, UPPER_ROMAN, HEBREW, ARMENIAN, GEORGIAN,
// Ideographic:
CJK_IDEOGRAPHIC, JAPANESE_FORMAL, JAPANESE_INFORMAL,
SIMP_CHINESE_FORMAL, SIMP_CHINESE_INFORMAL, TRAD_CHINESE_FORMAL, TRAD_CHINESE_INFORMAL,
// Alphabetic:
LOWER_GREEK, UPPER_GREEK, LOWER_ALPHA, LOWER_LATIN, UPPER_ALPHA, UPPER_LATIN,
HIRAGANA, KATAKANA, HIRAGANA_IROHA, KATAKANA_IROHA,
// Special:
LNONE
};
inline bool isListStyleCounted(EListStyleType type)
{
switch(type) {
case LDISC: case LCIRCLE: case LSQUARE: case LBOX: case LDIAMOND:
case LNONE:
return false;
default:
return true;
}
}
enum EListStylePosition { OUTSIDE, INSIDE };
enum EVisibility { VISIBLE, HIDDEN, COLLAPSE };
enum ECursor {
CURSOR_AUTO, CURSOR_CROSS, CURSOR_DEFAULT, CURSOR_POINTER, CURSOR_PROGRESS, CURSOR_MOVE,
CURSOR_E_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_N_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE,
CURSOR_S_RESIZE, CURSOR_W_RESIZE, CURSOR_TEXT, CURSOR_WAIT, CURSOR_HELP
};
enum EUserInput {
UI_ENABLED, UI_DISABLED, UI_NONE
};
//------------------------------------------------
enum EDisplay {
INLINE, BLOCK, LIST_ITEM, RUN_IN,
COMPACT, INLINE_BLOCK, TABLE, INLINE_TABLE,
TABLE_ROW_GROUP, TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW,
TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL,
TABLE_CAPTION, NONE
};
class RenderStyle : public Shared<RenderStyle>
{
friend class CSSStyleSelector;
public:
TDE_EXPORT static void cleanup();
// pseudo elements
enum PseudoId {
NOPSEUDO, FIRST_LINE, FIRST_LETTER, SELECTION,
BEFORE, AFTER, REPLACED, MARKER
};
protected:
// !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp
// inherit
struct InheritedFlags {
// 64 bit inherited, update unused when adding to the struct, or the operator will break.
bool operator==( const InheritedFlags &other ) const
{ return _iflags ==other._iflags; }
bool operator!=( const InheritedFlags &other ) const
{ return _iflags != other._iflags; }
union {
struct {
EEmptyCell _empty_cells : 1 ;
ECaptionSide _caption_side : 2;
EListStyleType _list_style_type : 6;
EListStylePosition _list_style_position :1;
EVisibility _visibility : 2;
ETextAlign _text_align : 4;
ETextTransform _text_transform : 2;
unsigned _text_decorations : 4;
ECursor _cursor_style : 5;
EDirection _direction : 1;
bool _border_collapse : 1 ;
EWhiteSpace _white_space : 3;
// non CSS2 inherited
bool _visuallyOrdered : 1;
bool _htmlHacks :1;
EUserInput _user_input : 2;
bool _page_break_inside : 1; // AUTO/AVOID
unsigned int unused : 27;
} f;
TQ_UINT64 _iflags;
};
} inherited_flags;
// don't inherit
struct NonInheritedFlags {
// 64 bit non-inherited, update unused when adding to the struct, or the operator will break.
bool operator==( const NonInheritedFlags &other ) const
{ return _niflags == other._niflags; }
bool operator!=( const NonInheritedFlags &other ) const
{ return _niflags != other._niflags; }
union {
struct {
EDisplay _display : 5;
EDisplay _originalDisplay: 5;
EOverflow _overflowX : 4 ;
EOverflow _overflowY : 4 ;
EVerticalAlign _vertical_align : 4;
EClear _clear : 2;
EPosition _position : 2;
EFloat _floating : 3;
ETableLayout _table_layout : 1;
bool _flowAroundFloats :1;
EPageBreak _page_break_before : 3;
EPageBreak _page_break_after : 3;
PseudoId _styleType : 4;
bool _hasClip : 1;
unsigned _pseudoBits : 8;
EUnicodeBidi _unicodeBidi : 2;
// non CSS2 non-inherited
bool _textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
unsigned int unused : 11;
} f;
TQ_UINT64 _niflags;
};
} noninherited_flags;
// non-inherited attributes
DataRef<StyleBoxData> box;
DataRef<StyleVisualData> visual;
DataRef<StyleBackgroundData> background;
DataRef<StyleSurroundData> surround;
DataRef<StyleGeneratedData> generated;
DataRef<StyleCSS3NonInheritedData> css3NonInheritedData;
// inherited attributes
DataRef<StyleCSS3InheritedData> css3InheritedData;
DataRef<StyleInheritedData> inherited;
// list of associated pseudo styles
RenderStyle* pseudoStyle;
// !END SYNC!
// static default style
static RenderStyle* _default;
private:
RenderStyle(const RenderStyle*) {}
protected:
void setBitDefaults()
{
inherited_flags.f._empty_cells = initialEmptyCells();
inherited_flags.f._caption_side = initialCaptionSide();
inherited_flags.f._list_style_type = initialListStyleType();
inherited_flags.f._list_style_position = initialListStylePosition();
inherited_flags.f._visibility = initialVisibility();
inherited_flags.f._text_align = initialTextAlign();
inherited_flags.f._text_transform = initialTextTransform();
inherited_flags.f._text_decorations = initialTextDecoration();
inherited_flags.f._cursor_style = initialCursor();
inherited_flags.f._direction = initialDirection();
inherited_flags.f._border_collapse = initialBorderCollapse();
inherited_flags.f._white_space = initialWhiteSpace();
inherited_flags.f._visuallyOrdered = false;
inherited_flags.f._htmlHacks=false;
inherited_flags.f._user_input = UI_NONE;
inherited_flags.f._page_break_inside = true;
inherited_flags.f.unused = 0;
noninherited_flags._niflags = 0L; // for safety: without this, the equality method sometimes
// makes use of uninitialised bits according to valgrind
noninherited_flags.f._display = noninherited_flags.f._originalDisplay = initialDisplay();
noninherited_flags.f._overflowX = initialOverflowX();
noninherited_flags.f._overflowY = initialOverflowY();
noninherited_flags.f._vertical_align = initialVerticalAlign();
noninherited_flags.f._clear = initialClear();
noninherited_flags.f._position = initialPosition();
noninherited_flags.f._floating = initialFloating();
noninherited_flags.f._table_layout = initialTableLayout();
noninherited_flags.f._flowAroundFloats= initialFlowAroundFloats();
noninherited_flags.f._page_break_before = initialPageBreak();
noninherited_flags.f._page_break_after = initialPageBreak();
noninherited_flags.f._styleType = NOPSEUDO;
noninherited_flags.f._hasClip = false;
noninherited_flags.f._pseudoBits = 0;
noninherited_flags.f._unicodeBidi = initialUnicodeBidi();
noninherited_flags.f._textOverflow = initialTextOverflow();
noninherited_flags.f.unused = 0;
}
public:
RenderStyle();
// used to create the default style.
RenderStyle(bool);
RenderStyle(const RenderStyle&);
~RenderStyle();
void inheritFrom(const RenderStyle* inheritParent);
PseudoId styleType() const { return noninherited_flags.f._styleType; }
void setStyleType(PseudoId pi) { noninherited_flags.f._styleType = pi; }
bool isGenerated() const {
if (styleType() == AFTER || styleType() == BEFORE || styleType() == MARKER || styleType() == REPLACED)
return true;
else
return false;
}
bool hasPseudoStyle(PseudoId pi) const;
void setHasPseudoStyle(PseudoId pi, bool b=true);
RenderStyle* getPseudoStyle(PseudoId pi) const;
RenderStyle* addPseudoStyle(PseudoId pi);
void removePseudoStyle(PseudoId pi);
bool operator==(const RenderStyle& other) const;
bool isFloating() const { return !(noninherited_flags.f._floating == FNONE); }
bool hasMargin() const { return surround->margin.nonZero(); }
bool hasBorder() const { return surround->border.hasBorder(); }
bool hasOffset() const { return surround->offset.nonZero(); }
bool hasBackground() const {
if (backgroundColor().isValid() && tqAlpha(backgroundColor().rgb()) > 0)
return true;
else
return background->m_background.hasImage();
}
bool hasFixedBackgroundImage() const { return background->m_background.hasFixedImage(); }
bool visuallyOrdered() const { return inherited_flags.f._visuallyOrdered; }
void setVisuallyOrdered(bool b) { inherited_flags.f._visuallyOrdered = b; }
// attribute getter methods
EDisplay display() const { return noninherited_flags.f._display; }
EDisplay originalDisplay() const { return noninherited_flags.f._originalDisplay; }
Length left() const { return surround->offset.left; }
Length right() const { return surround->offset.right; }
Length top() const { return surround->offset.top; }
Length bottom() const { return surround->offset.bottom; }
EPosition position() const { return noninherited_flags.f._position; }
EFloat floating() const { return noninherited_flags.f._floating; }
Length width() const { return box->width; }
Length height() const { return box->height; }
Length minWidth() const { return box->min_width; }
Length maxWidth() const { return box->max_width; }
Length minHeight() const { return box->min_height; }
Length maxHeight() const { return box->max_height; }
const BorderData& border() const { return surround->border; }
const BorderValue& borderLeft() const { return surround->border.left; }
const BorderValue& borderRight() const { return surround->border.right; }
const BorderValue& borderTop() const { return surround->border.top; }
const BorderValue& borderBottom() const { return surround->border.bottom; }
unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
EBorderStyle borderLeftStyle() const { return surround->border.left.style; }
const TQColor& borderLeftColor() const { return surround->border.left.color; }
bool borderLeftIsTransparent() const { return surround->border.left.isTransparent(); }
unsigned short borderRightWidth() const { return surround->border.borderRightWidth(); }
EBorderStyle borderRightStyle() const { return surround->border.right.style; }
const TQColor& borderRightColor() const { return surround->border.right.color; }
bool borderRightIsTransparent() const { return surround->border.right.isTransparent(); }
unsigned short borderTopWidth() const { return surround->border.borderTopWidth(); }
EBorderStyle borderTopStyle() const { return surround->border.top.style; }
const TQColor& borderTopColor() const { return surround->border.top.color; }
bool borderTopIsTransparent() const { return surround->border.top.isTransparent(); }
unsigned short borderBottomWidth() const { return surround->border.borderBottomWidth(); }
EBorderStyle borderBottomStyle() const { return surround->border.bottom.style; }
const TQColor& borderBottomColor() const { return surround->border.bottom.color; }
bool borderBottomIsTransparent() const { return surround->border.bottom.isTransparent(); }
unsigned short outlineSize() const { return outlineWidth() + outlineOffset(); }
unsigned short outlineWidth() const
{ if(background->m_outline.style == BNONE || background->m_outline.style == BHIDDEN) return 0;
else return background->m_outline.width; }
EBorderStyle outlineStyle() const { return background->m_outline.style; }
bool outlineStyleIsAuto() const { return background->m_outline._auto; }
const TQColor & outlineColor() const { return background->m_outline.color; }
EOverflow overflowX() const { return noninherited_flags.f._overflowX; }
EOverflow overflowY() const { return noninherited_flags.f._overflowY; }
bool hidesOverflow() const {
// either both overflow are visible or none are
return overflowX() != OVISIBLE;
}
EVisibility visibility() const { return inherited_flags.f._visibility; }
EVerticalAlign verticalAlign() const { return noninherited_flags.f._vertical_align; }
Length verticalAlignLength() const { return box->vertical_align; }
Length clipLeft() const { return visual->clip.left; }
Length clipRight() const { return visual->clip.right; }
Length clipTop() const { return visual->clip.top; }
Length clipBottom() const { return visual->clip.bottom; }
LengthBox clip() const { return visual->clip; }
bool hasClip() const { return noninherited_flags.f._hasClip; }
EUnicodeBidi unicodeBidi() const { return noninherited_flags.f._unicodeBidi; }
EClear clear() const { return noninherited_flags.f._clear; }
ETableLayout tableLayout() const { return noninherited_flags.f._table_layout; }
const TQFont & font() const { return inherited->font.f; }
// use with care. call font->update() after modifications
const Font &htmlFont() { return inherited->font; }
const TQFontMetrics & fontMetrics() const { return inherited->font.fm; }
const TQColor & color() const { return inherited->color; }
Length textIndent() const { return inherited->indent; }
ETextAlign textAlign() const { return inherited_flags.f._text_align; }
ETextTransform textTransform() const { return inherited_flags.f._text_transform; }
int textDecorationsInEffect() const { return inherited_flags.f._text_decorations; }
int textDecoration() const { return visual->textDecoration; }
int wordSpacing() const { return inherited->font.wordSpacing; }
int letterSpacing() const { return inherited->font.letterSpacing; }
EDirection direction() const { return inherited_flags.f._direction; }
Length lineHeight() const { return inherited->line_height; }
EWhiteSpace whiteSpace() const { return inherited_flags.f._white_space; }
bool autoWrap() const {
if (whiteSpace() == NORMAL || whiteSpace() == PRE_WRAP || whiteSpace() == PRE_LINE)
return true;
// nowrap | pre
return false;
}
bool preserveLF() const {
if (whiteSpace() == PRE || whiteSpace() == PRE_WRAP || whiteSpace() == PRE_LINE)
return true;
// normal | nowrap
return false;
}
bool preserveWS() const {
if (whiteSpace() == PRE || whiteSpace() == PRE_WRAP)
return true;
// normal | nowrap | pre-line
return false;
}
const TQColor & backgroundColor() const { return background->m_color; }
CachedImage *backgroundImage() const { return background->m_background.m_image; }
EBackgroundRepeat backgroundRepeat() const { return background->m_background.m_bgRepeat; }
bool backgroundAttachment() const { return background->m_background.m_bgAttachment; }
Length backgroundXPosition() const { return background->m_background.m_xPosition; }
Length backgroundYPosition() const { return background->m_background.m_yPosition; }
BackgroundLayer* accessBackgroundLayers() { return &(background.access()->m_background); }
const BackgroundLayer* backgroundLayers() const { return &(background->m_background); }
// returns true for collapsing borders, false for separate borders
bool borderCollapse() const { return inherited_flags.f._border_collapse; }
short borderHorizontalSpacing() const { return inherited->border_hspacing; }
short borderVerticalSpacing() const { return inherited->border_vspacing; }
EEmptyCell emptyCells() const { return inherited_flags.f._empty_cells; }
ECaptionSide captionSide() const { return inherited_flags.f._caption_side; }
EListStyleType listStyleType() const { return inherited_flags.f._list_style_type; }
CachedImage *listStyleImage() const { return inherited->style_image; }
EListStylePosition listStylePosition() const { return inherited_flags.f._list_style_position; }
Length marginTop() const { return surround->margin.top; }
Length marginBottom() const { return surround->margin.bottom; }
Length marginLeft() const { return surround->margin.left; }
Length marginRight() const { return surround->margin.right; }
Length paddingTop() const { return surround->padding.top; }
Length paddingBottom() const { return surround->padding.bottom; }
Length paddingLeft() const { return surround->padding.left; }
Length paddingRight() const { return surround->padding.right; }
ECursor cursor() const { return inherited_flags.f._cursor_style; }
short widows() const { return inherited->widows; }
short orphans() const { return inherited->orphans; }
bool pageBreakInside() const { return inherited_flags.f._page_break_inside; }
EPageBreak pageBreakBefore() const { return noninherited_flags.f._page_break_before; }
EPageBreak pageBreakAfter() const { return noninherited_flags.f._page_break_after; }
DOM::QuotesValueImpl* quotes() const { return inherited->quotes; }
TQString openQuote(int level) const;
TQString closeQuote(int level) const;
// CSS3 Getter Methods
EBoxSizing boxSizing() const { return box->box_sizing; }
int outlineOffset() const {
if (background->m_outline.style == BNONE || background->m_outline.style == BHIDDEN) return 0;
return background->m_outline._offset;
}
ShadowData* textShadow() const { return css3InheritedData->textShadow; }
EWordWrap wordWrap() const { return css3InheritedData->wordWrap; }
float opacity() { return css3NonInheritedData->opacity; }
EUserInput userInput() const { return inherited_flags.f._user_input; }
Length marqueeIncrement() { return css3NonInheritedData->marquee->increment; }
int marqueeSpeed() { return css3NonInheritedData->marquee->speed; }
int marqueeLoopCount() { return css3NonInheritedData->marquee->loops; }
EMarqueeBehavior marqueeBehavior() { return css3NonInheritedData->marquee->behavior; }
EMarqueeDirection marqueeDirection() { return css3NonInheritedData->marquee->direction; }
bool textOverflow() const { return noninherited_flags.f._textOverflow; }
// End CSS3 Getters
// attribute setter methods
void setDisplay(EDisplay v) { noninherited_flags.f._display = v; }
void setOriginalDisplay(EDisplay v) { noninherited_flags.f._originalDisplay = v; }
void setPosition(EPosition v) { noninherited_flags.f._position = v; }
void setFloating(EFloat v) { noninherited_flags.f._floating = v; }
void setLeft(Length v) { SET_VAR(surround,offset.left,v) }
void setRight(Length v) { SET_VAR(surround,offset.right,v) }
void setTop(Length v) { SET_VAR(surround,offset.top,v) }
void setBottom(Length v){ SET_VAR(surround,offset.bottom,v) }
void setWidth(Length v) { SET_VAR(box,width,v) }
void setHeight(Length v) { SET_VAR(box,height,v) }
void setMinWidth(Length v) { SET_VAR(box,min_width,v) }
void setMaxWidth(Length v) { SET_VAR(box,max_width,v) }
void setMinHeight(Length v) { SET_VAR(box,min_height,v) }
void setMaxHeight(Length v) { SET_VAR(box,max_height,v) }
void resetBorderTop() { SET_VAR(surround, border.top, BorderValue()) }
void resetBorderRight() { SET_VAR(surround, border.right, BorderValue()) }
void resetBorderBottom() { SET_VAR(surround, border.bottom, BorderValue()) }
void resetBorderLeft() { SET_VAR(surround, border.left, BorderValue()) }
void resetOutline() { SET_VAR(background, m_outline, OutlineValue()) }
void setBackgroundColor(const TQColor& v) { SET_VAR(background, m_color, v) }
void setBorderLeftWidth(unsigned short v) { SET_VAR(surround,border.left.width,v) }
void setBorderLeftStyle(EBorderStyle v) { SET_VAR(surround,border.left.style,v) }
void setBorderLeftColor(const TQColor & v) { SET_VAR(surround,border.left.color,v) }
void setBorderRightWidth(unsigned short v) { SET_VAR(surround,border.right.width,v) }
void setBorderRightStyle(EBorderStyle v) { SET_VAR(surround,border.right.style,v) }
void setBorderRightColor(const TQColor & v) { SET_VAR(surround,border.right.color,v) }
void setBorderTopWidth(unsigned short v) { SET_VAR(surround,border.top.width,v) }
void setBorderTopStyle(EBorderStyle v) { SET_VAR(surround,border.top.style,v) }
void setBorderTopColor(const TQColor & v) { SET_VAR(surround,border.top.color,v) }
void setBorderBottomWidth(unsigned short v) { SET_VAR(surround,border.bottom.width,v) }
void setBorderBottomStyle(EBorderStyle v) { SET_VAR(surround,border.bottom.style,v) }
void setBorderBottomColor(const TQColor & v) { SET_VAR(surround,border.bottom.color,v) }
void setOutlineWidth(unsigned short v) { SET_VAR(background,m_outline.width,v) }
void setOutlineStyle(EBorderStyle v, bool isAuto = false)
{
SET_VAR(background,m_outline.style,v)
SET_VAR(background,m_outline._auto, isAuto)
}
void setOutlineColor(const TQColor & v) { SET_VAR(background,m_outline.color,v) }
void setOverflowX(EOverflow v) { noninherited_flags.f._overflowX = v; }
void setOverflowY(EOverflow v) { noninherited_flags.f._overflowY = v; }
void setVisibility(EVisibility v) { inherited_flags.f._visibility = v; }
void setVerticalAlign(EVerticalAlign v) { noninherited_flags.f._vertical_align = v; }
void setVerticalAlignLength(Length l) { SET_VAR(box, vertical_align, l ) }
void setClipLeft(Length v) { SET_VAR(visual,clip.left,v) }
void setClipRight(Length v) { SET_VAR(visual,clip.right,v) }
void setClipTop(Length v) { SET_VAR(visual,clip.top,v) }
void setClipBottom(Length v) { SET_VAR(visual,clip.bottom,v) }
void setClip( Length top, Length right, Length bottom, Length left );
void setHasClip( bool b ) { noninherited_flags.f._hasClip = b; }
void setUnicodeBidi( EUnicodeBidi b ) { noninherited_flags.f._unicodeBidi = b; }
void setClear(EClear v) { noninherited_flags.f._clear = v; }
void setTableLayout(ETableLayout v) { noninherited_flags.f._table_layout = v; }
bool setFontDef(const tdehtml::FontDef & v) {
// bah, this doesn't compare pointers. broken! (Dirk)
if (!(inherited->font.fontDef == v)) {
inherited.access()->font = Font( v );
return true;
}
return false;
}
void setColor(const TQColor & v) { SET_VAR(inherited,color,v) }
void setTextIndent(Length v) { SET_VAR(inherited,indent,v) }
void setTextAlign(ETextAlign v) { inherited_flags.f._text_align = v; }
void setTextTransform(ETextTransform v) { inherited_flags.f._text_transform = v; }
void addToTextDecorationsInEffect(int v) { inherited_flags.f._text_decorations |= v; }
void setTextDecorationsInEffect(int v) { inherited_flags.f._text_decorations = v; }
void setTextDecoration(unsigned v) { SET_VAR(visual, textDecoration, v); }
void setDirection(EDirection v) { inherited_flags.f._direction = v; }
void setLineHeight(Length v) { SET_VAR(inherited,line_height,v) }
void setWhiteSpace(EWhiteSpace v) { inherited_flags.f._white_space = v; }
void setWordSpacing(int v) { SET_VAR(inherited,font.wordSpacing,v) }
void setLetterSpacing(int v) { SET_VAR(inherited,font.letterSpacing,v) }
void clearBackgroundLayers() { background.access()->m_background = BackgroundLayer(); }
void inheritBackgroundLayers(const BackgroundLayer& parent) { background.access()->m_background = parent; }
void adjustBackgroundLayers();
void setBorderCollapse(bool collapse) { inherited_flags.f._border_collapse = collapse; }
void setBorderHorizontalSpacing(short v) { SET_VAR(inherited,border_hspacing,v) }
void setBorderVerticalSpacing(short v) { SET_VAR(inherited,border_vspacing,v) }
void setEmptyCells(EEmptyCell v) { inherited_flags.f._empty_cells = v; }
void setCaptionSide(ECaptionSide v) { inherited_flags.f._caption_side = v; }
void setListStyleType(EListStyleType v) { inherited_flags.f._list_style_type = v; }
void setListStyleImage(CachedImage *v) { SET_VAR(inherited,style_image,v)}
void setListStylePosition(EListStylePosition v) { inherited_flags.f._list_style_position = v; }
void resetMargin() { SET_VAR(surround, margin, LengthBox(Fixed)) }
void setMarginTop(Length v) { SET_VAR(surround,margin.top,v) }
void setMarginBottom(Length v) { SET_VAR(surround,margin.bottom,v) }
void setMarginLeft(Length v) { SET_VAR(surround,margin.left,v) }
void setMarginRight(Length v) { SET_VAR(surround,margin.right,v) }
void resetPadding() { SET_VAR(surround, padding, LengthBox(Variable)) }
void setPaddingTop(Length v) { SET_VAR(surround,padding.top,v) }
void setPaddingBottom(Length v) { SET_VAR(surround,padding.bottom,v) }
void setPaddingLeft(Length v) { SET_VAR(surround,padding.left,v) }
void setPaddingRight(Length v) { SET_VAR(surround,padding.right,v) }
void setCursor( ECursor c ) { inherited_flags.f._cursor_style = c; }
bool htmlHacks() const { return inherited_flags.f._htmlHacks; }
void setHtmlHacks(bool b=true) { inherited_flags.f._htmlHacks = b; }
bool flowAroundFloats() const { return noninherited_flags.f._flowAroundFloats; }
void setFlowAroundFloats(bool b=true) { noninherited_flags.f._flowAroundFloats = b; }
int zIndex() const { return box->z_auto? 0 : box->z_index; }
void setZIndex(int v) { SET_VAR(box,z_auto,false ); SET_VAR(box, z_index, v); }
bool hasAutoZIndex() const { return box->z_auto; }
void setHasAutoZIndex() { SET_VAR(box, z_auto, true ); }
void setWidows(short w) { SET_VAR(inherited, widows, w); }
void setOrphans(short o) { SET_VAR(inherited, orphans, o); }
void setPageBreakInside(bool b) { inherited_flags.f._page_break_inside = b; }
void setPageBreakBefore(EPageBreak b) { noninherited_flags.f._page_break_before = b; }
void setPageBreakAfter(EPageBreak b) { noninherited_flags.f._page_break_after = b; }
void setQuotes(DOM::QuotesValueImpl* q);
// CSS3 Setters
void setBoxSizing( EBoxSizing b ) { SET_VAR(box,box_sizing,b); }
void setOutlineOffset(unsigned short v) { SET_VAR(background,m_outline._offset,v) }
void setWordWrap(EWordWrap w) { SET_VAR(css3InheritedData, wordWrap, w); }
void setTextShadow(ShadowData* val, bool add=false);
void setOpacity(float f) { SET_VAR(css3NonInheritedData, opacity, f); }
void setUserInput(EUserInput ui) { inherited_flags.f._user_input = ui; }
void setMarqueeIncrement(const Length& f) { SET_VAR(css3NonInheritedData.access()->marquee, increment, f); }
void setMarqueeSpeed(int f) { SET_VAR(css3NonInheritedData.access()->marquee, speed, f); }
void setMarqueeDirection(EMarqueeDirection d) { SET_VAR(css3NonInheritedData.access()->marquee, direction, d); }
void setMarqueeBehavior(EMarqueeBehavior b) { SET_VAR(css3NonInheritedData.access()->marquee, behavior, b); }
void setMarqueeLoopCount(int i) { SET_VAR(css3NonInheritedData.access()->marquee, loops, i); }
void setTextOverflow(bool b) { noninherited_flags.f._textOverflow = b; }
// End CSS3 Setters
TQPalette palette() const { return visual->palette; }
void setPaletteColor(TQPalette::ColorGroup g, TQColorGroup::ColorRole r, const TQColor& c);
void resetPalette() // Called when the desktop color scheme changes.
{
const_cast<StyleVisualData *>(visual.get())->palette = TQApplication::palette();
}
bool useNormalContent() const { return generated->content == 0; }
ContentData* contentData() const { return generated->content; }
bool contentDataEquivalent(const RenderStyle* otherStyle) const
{
return generated->contentDataEquivalent(otherStyle->generated.get());
}
void addContent(DOM::DOMStringImpl* s);
void addContent(CachedObject* o);
void addContent(DOM::CounterImpl* c);
void addContent(EQuoteContent q);
void setContentNone();
void setContentNormal();
void setContentData(ContentData* content);
DOM::CSSValueListImpl* counterReset() const { return generated->counter_reset; }
DOM::CSSValueListImpl* counterIncrement() const { return generated->counter_increment; }
void setCounterReset(DOM::CSSValueListImpl* v);
void setCounterIncrement(DOM::CSSValueListImpl* v);
bool hasCounterReset(const DOM::DOMString& c) const;
bool hasCounterIncrement(const DOM::DOMString& c) const;
short counterReset(const DOM::DOMString& c) const;
short counterIncrement(const DOM::DOMString& c) const;
bool inheritedNotEqual( RenderStyle *other ) const;
enum Diff { Equal, NonVisible = Equal, Visible, Position, Layout, CbLayout };
Diff diff( const RenderStyle *other ) const;
bool isDisplayReplacedType() {
return display() == INLINE_BLOCK ||/* display() == INLINE_BOX ||*/ display() == INLINE_TABLE;
}
bool isDisplayInlineType() {
return display() == INLINE || isDisplayReplacedType();
}
bool isOriginalDisplayInlineType() {
return originalDisplay() == INLINE || originalDisplay() == INLINE_BLOCK ||
/*originalDisplay() == INLINE_BOX ||*/ originalDisplay() == INLINE_TABLE;
}
#ifdef ENABLE_DUMP
TQString createDiff( const RenderStyle &parent ) const;
#endif
// Initial values for all the properties
static bool initialBackgroundAttachment() { return true; }
static EBackgroundBox initialBackgroundClip() { return BGBORDER; }
static EBackgroundBox initialBackgroundOrigin() { return BGPADDING; }
static EBackgroundRepeat initialBackgroundRepeat() { return REPEAT; }
static LengthSize initialBackgroundSize() { return LengthSize(); }
static bool initialBorderCollapse() { return false; }
static EBorderStyle initialBorderStyle() { return BNONE; }
static ECaptionSide initialCaptionSide() { return CAPTOP; }
static EClear initialClear() { return CNONE; }
static EDirection initialDirection() { return LTR; }
static EDisplay initialDisplay() { return INLINE; }
static EEmptyCell initialEmptyCells() { return SHOW; }
static EFloat initialFloating() { return FNONE; }
static EWordWrap initialWordWrap() { return WWNORMAL; }
static EListStylePosition initialListStylePosition() { return OUTSIDE; }
static EListStyleType initialListStyleType() { return LDISC; }
static EOverflow initialOverflowX() { return OVISIBLE; }
static EOverflow initialOverflowY() { return OVISIBLE; }
static EPageBreak initialPageBreak() { return PBAUTO; }
static bool initialPageBreakInside() { return true; }
static EPosition initialPosition() { return STATIC; }
static ETableLayout initialTableLayout() { return TAUTO; }
static EUnicodeBidi initialUnicodeBidi() { return UBNormal; }
static DOM::QuotesValueImpl* initialQuotes() { return 0; }
static EBoxSizing initialBoxSizing() { return CONTENT_BOX; }
static ETextTransform initialTextTransform() { return TTNONE; }
static EVisibility initialVisibility() { return VISIBLE; }
static EWhiteSpace initialWhiteSpace() { return NORMAL; }
static Length initialBackgroundXPosition() { return Length(); }
static Length initialBackgroundYPosition() { return Length(); }
static short initialBorderHorizontalSpacing() { return 0; }
static short initialBorderVerticalSpacing() { return 0; }
static ECursor initialCursor() { return CURSOR_AUTO; }
static TQColor initialColor() { return TQt::black; }
static CachedImage* initialBackgroundImage() { return 0; }
static CachedImage* initialListStyleImage() { return 0; }
static unsigned short initialBorderWidth() { return 3; }
static int initialLetterWordSpacing() { return 0; }
static Length initialSize() { return Length(); }
static Length initialMinSize() { return Length(0, Fixed); }
static Length initialMaxSize() { return Length(UNDEFINED, Fixed); }
static Length initialOffset() { return Length(); }
static Length initialMargin() { return Length(Fixed); }
static Length initialPadding() { return Length(Variable); }
static Length initialTextIndent() { return Length(Fixed); }
static EVerticalAlign initialVerticalAlign() { return BASELINE; }
static int initialWidows() { return 2; }
static int initialOrphans() { return 2; }
static Length initialLineHeight() { return Length(-100, Percent); }
static ETextAlign initialTextAlign() { return TAAUTO; }
static ETextDecoration initialTextDecoration() { return TDNONE; }
static bool initialFlowAroundFloats() { return false; }
static int initialOutlineOffset() { return 0; }
static float initialOpacity() { return 1.0f; }
static int initialMarqueeLoopCount() { return -1; }
static int initialMarqueeSpeed() { return 85; }
static Length initialMarqueeIncrement() { return Length(6, Fixed); }
static EMarqueeBehavior initialMarqueeBehavior() { return MSCROLL; }
static EMarqueeDirection initialMarqueeDirection() { return MAUTO; }
static bool initialTextOverflow() { return false; }
};
class RenderPageStyle {
friend class CSSStyleSelector;
public:
enum PageType { NO_PAGE = 0, ANY_PAGE, FIRST_PAGE, LEFT_PAGES, RIGHT_PAGES };
RenderPageStyle();
~RenderPageStyle();
PageType pageType() { return m_pageType; }
RenderPageStyle* getPageStyle(PageType type);
RenderPageStyle* addPageStyle(PageType type);
void removePageStyle(PageType type);
Length marginTop() const { return margin.top; }
Length marginBottom() const { return margin.bottom; }
Length marginLeft() const { return margin.left; }
Length marginRight() const { return margin.right; }
Length pageWidth() const { return m_pageWidth; }
Length pageHeight() const { return m_pageHeight; }
void setMarginTop(Length v) { margin.top = v; }
void setMarginBottom(Length v) { margin.bottom = v; }
void setMarginLeft(Length v) { margin.left = v; }
void setMarginRight(Length v) { margin.right = v; }
void setPageWidth(Length v) { m_pageWidth = v; }
void setPageHeight(Length v) { m_pageHeight = v; }
protected:
RenderPageStyle *next;
PageType m_pageType;
LengthBox margin;
Length m_pageWidth;
Length m_pageHeight;
};
} // namespace
#endif
|