-
Notifications
You must be signed in to change notification settings - Fork 3
/
iphtml.pas.bak
16023 lines (14761 loc) · 456 KB
/
iphtml.pas.bak
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
{******************************************************************}
{* IPHTML.PAS - HTML Browser and associated classes *}
{******************************************************************}
{ $Id: iphtml.pas 53090 2016-10-10 21:21:38Z maxim $ }
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Turbo Power Internet Professional
*
* The Initial Developer of the Original Code is
* TurboPower Software
*
* Portions created by the Initial Developer are Copyright (C) 2000-2002
* the Initial Developer. All Rights Reserved.
*
* 09/29/2007 DefaultTypeFace and FixedTypeFace are enabled
* FactBAParag: Incremental factor for space between lines
* default value is 1,
* proof it with values of 0.5 = {... margin-top: 0.5em; margin-bottom: 0.5em; }
* Delphi: adjustments
* 10/01/2007 TextWidth of an anchor (<a name="XXXX">), before = TextWidth (' ') now is only 1
* Delphi: adjustments (crush when TIpHtmlPanelH was run-time created)
* 10/03/2007 Delphi: supports jpg, png, etc
*
* Contributor(s):
*
* adem baba <[email protected]>
*
* ***** END LICENSE BLOCK ***** *)
{ Global defines potentially affecting this unit }
{$I IPDEFINE.INC}
{off $DEFINE IP_LAZARUS_DBG}
unit IpHtml;
interface
uses
{$IFDEF IP_LAZARUS}
//MemCheck,
Types, contnrs,
LCLType, GraphType, LCLProc, LCLIntf, LResources, LMessages, LCLMemManager,
Translations, FileUtil, LConvEncoding, LazUTF8,
IpHtmlTabList,
{$ELSE}
Windows,
{$ENDIF}
Messages, SysUtils, Classes, Graphics,
{$IFDEF IP_LAZARUS}
{$IFDEF UseGifImageUnit}
GifImage,
{$ELSE}
IpAnim,
{$IFDEF AndersGIFImage }
IpAnAGif,
{$ENDIF}
{$IFDEF ImageLibGIFImage }
IpAnImgL,
{$ENDIF}
{$ENDIF}
{$IFDEF UsePNGGraphic}
IpPNGImg,
{$ENDIF}
{$ELSE}
GIFImage, JPeg,
{$ENDIF}
TypInfo,
GraphUtil, Controls, StdCtrls, ExtCtrls, Buttons, Forms, ClipBrd, Dialogs,
IpConst, IpStrms, IpUtils, iphtmlprop, IpMsg;
type
{$IFNDEF IP_LAZARUS}
PtrInt = Longint;
{$ENDIF}
{Note: Some of the code below relies on the fact that
the end tag (when present) immediately follows the start tag.}
{$I iphtmlgenerated.inc}
const
IPMAXFRAMES = 256; {maximum number of frames in a single frameset}
MAXINTS = 4096; {buffer size - this should be way more than needed}
TINTARRGROWFACTOR = 64;
DEFAULT_PRINTMARGIN = 0.5; {inches}
FONTSIZESVALUSARRAY : array[0..6] of integer = (8,10,12,14,18,24,36);
MAXWORDS = 65536;
ZOOM_TO_FIT = 0;
ZOOM_TO_FIT_WIDTH = -1;
ZOOM_TO_FIT_HEIGHT = -2;
type
{$IFDEF IP_LAZARUS}
TIpEnumItemsMethod = TLCLEnumItemsMethod;
TIpHtmlPoolManager = class(TLCLNonFreeMemManager)
public
constructor Create(TheItemSize, MaxItems : DWord);
function NewItm : Pointer;
end;
{$ELSE}
TIpEnumItemsMethod = procedure(Item: Pointer) of object;
TIpHtmlPoolManager = class
private
Root : Pointer;
{Top : Pointer;}
NextPage : Pointer;
Next : Pointer;
InternalSize : DWord;
Critical : TRtlCriticalSection;
procedure Grow;
public
constructor Create(ItemSize, MaxItems : DWord);
destructor Destroy; override;
function NewItm : Pointer;
procedure EnumerateItems(Method: TIpEnumItemsMethod);
end;
{$ENDIF}
TIpHtml = class;
{$IFDEF IP_LAZARUS}
TIpAbstractHtmlDataProvider = class;
{$DEFINE CSS_INTERFACE}
{$I ipcss.inc}
{$UNDEF CSS_INTERFACE}
{$ENDIF}
TIpHtmlInteger = class(TPersistent)
{ Integer property which can be scaled}
private
FValue : Integer;
FChange: TNotifyEvent;
procedure DoChange;
function GetValue: Integer;
procedure SetValue(const Value: Integer);
public
constructor Create(AValue: Integer);
property Value: Integer read GetValue write SetValue;
property OnChange: TNotifyEvent read FChange write FChange;
end;
TIpHtmlPixelsType = (hpUndefined, hpAbsolute);
TIpHtmlPixels = class(TPersistent)
private
FValue : Integer;
FPixelsType : TIpHtmlPixelsType;
FChange: TNotifyEvent;
procedure DoChange;
function GetValue: Integer;
procedure SetPixelsType(const Value: TIpHtmlPixelsType);
procedure SetValue(const Value: Integer);
public
property Value: Integer read GetValue write SetValue;
property PixelsType: TIpHtmlPixelsType read FPixelsType write SetPixelsType;
property OnChange: TNotifyEvent read FChange write FChange;
end;
TIpHtmlLengthType = (hlUndefined, hlAbsolute, hlPercent);
TIpHtmlLength = class(TPersistent)
private
FLengthValue: Integer;
FLengthType: TIpHtmlLengthType;
FChange: TNotifyEvent;
procedure SetLengthType(const Value: TIpHtmlLengthType);
procedure SetLengthValue(const Value: Integer);
function GetLengthValue: Integer;
procedure DoChange;
public
property LengthValue : Integer read GetLengthValue write SetLengthValue;
property LengthType : TIpHtmlLengthType read FLengthType write SetLengthType;
property OnChange: TNotifyEvent read FChange write FChange;
end;
TIpHtmlMultiLengthType = (hmlUndefined, hmlAbsolute, hmlPercent, hmlRelative);
TIpHtmlMultiLength = class(TPersistent)
private
FLengthValue : Integer;
FLengthType : TIpHtmlMultiLengthType;
function GetLengthValue: Integer;
public
property LengthValue: Integer read GetLengthValue write FLengthValue;
property LengthType: TIpHtmlMultiLengthType read FLengthType write FLengthType;
end;
TIpHtmlMultiLengthList = class(TPersistent)
private
List: {$ifdef IP_LAZARUS}TFPList{$else}TList{$endif};
function GetEntries: Integer;
function GetValues(Index: Integer): TIpHtmlMultiLength;
public
constructor Create;
destructor Destroy; override;
property Values[Index: Integer]: TIpHtmlMultiLength read GetValues;
procedure AddEntry(Value: TIpHtmlMultiLength);
procedure Clear;
property Entries: Integer read GetEntries;
end;
TIpHtmlRelSizeType = (hrsUnspecified, hrsAbsolute, hrsRelative);
TIpHtmlRelSize = class(TPersistent)
private
FChange: TNotifyEvent;
FSizeType : TIpHtmlRelSizeType;
FValue : Integer;
procedure SetSizeType(const Value: TIpHtmlRelSizeType);
procedure SetValue(const Value: Integer);
procedure DoChange;
public
property SizeType : TIpHtmlRelSizeType read FSizeType write SetSizeType;
property Value : Integer read FValue write SetValue;
property OnChange: TNotifyEvent read FChange write FChange;
end;
TIpHtmlNode = class;
TIpHtmlNodeCore = class;
TIpHtmlNodeBlock = class;
TIpHtmlNodeAlignInline = class;
{ TIpHtmlBaseLayouter }
TIpHtmlNodeIterator = procedure (ANode: TIpHtmlNode; AProps: TIpHtmlProps;
var Done: Boolean);
// Abstract base class for the HTML Layout engine
TIpHtmlBaseLayouter = class
protected
FOwner : TIpHtmlNodeCore;
FElementQueue : TFPList;
FCurProps : TIpHtmlProps;
FBlockMin, FBlockMax : Integer;
function GetProps: TIpHtmlProps;
procedure RemoveLeadingLFs;
procedure RemoveDuplicateLFs;
public
FPageRect : TRect;
constructor Create(AOwner: TIpHtmlNodeCore); virtual;
destructor Destroy; override;
procedure ClearWordList;
// Used by TIpHtmlNodeBlock descendants: Layout, CalcMinMaxPropWidth, Render
procedure Layout(RenderProps: TIpHtmlProps; TargetRect: TRect); virtual; abstract;
procedure CalcMinMaxPropWidth(RenderProps: TIpHtmlProps;
var aMin, aMax: Integer); virtual; abstract;
procedure Render(RenderProps: TIpHtmlProps); virtual; abstract;
procedure IterateParents(AProc: TIpHtmlNodeIterator);
public
property Props : TIpHtmlProps read GetProps;
end;
TIpHtmlBaseLayouterClass = class of TIpHtmlBaseLayouter;
TIntArr = class;
{ TIpHtmlBaseTableLayouter }
// Abstract base class for layout methods of a HTML table
TIpHtmlBaseTableLayouter = class(TIpHtmlBaseLayouter)
protected
FMin, FMax : Integer;
FTableWidth: Integer;
FCellSpacing: Integer;
FCellPadding: Integer;
FRowSp : TIntArr; // dynamic flag used for row spanning
public
constructor Create(AOwner: TIpHtmlNodeCore); override;
destructor Destroy; override;
// Used by TIpHtmlNodeTABLE
procedure ResetSize;
procedure CalcMinMaxColTableWidth(RenderProps: TIpHtmlProps;
var Min, Max: Integer); virtual; abstract;
procedure CalcSize(ParentWidth: Integer; RenderProps: TIpHtmlProps); virtual; abstract;
function GetColCount: Integer; virtual; abstract;
end;
TIpHtmlBaseTableLayouterClass = class of TIpHtmlBaseTableLayouter;
TElementType = (etWord, etObject, etSoftLF, etHardLF, etClearLeft,
etClearRight, etClearBoth, etIndent, etOutdent, etSoftHyphen);
TIpHtmlElement = record
ElementType : TElementType;
AnsiWord: string;
IsBlank : Integer;
SizeProp: TIpHtmlPropA;
Size: TSize;
WordRect2 : TRect;
Props : TIpHtmlProps;
Owner : TIpHtmlNode;
{$IFDEF IP_LAZARUS}
IsSelected: boolean;
{$ENDIF}
end;
PIpHtmlElement = ^TIpHtmlElement;
TRectMethod = procedure(const R : TRect) of object;
TIpHtmlNodeEnumProc = procedure(Node: TIpHtmlNode; const UserData: Pointer) of object;
TIpHtmlNodeClass = class of TIpHtmlNode;
{abstract base node}
TIpHtmlNode = class(TPersistent)
protected
FOwner : TIpHtml;
FParentNode : TIpHtmlNode;
procedure ScreenLine(StartPoint, EndPoint: TPoint; const Width: Integer; const Color: TColor);
procedure ScreenRect(R : TRect; const Color : TColor);
{$IFDEF IP_LAZARUS}
procedure ScreenFrame(R : TRect; Raised: boolean);
{$ENDIF}
procedure ScreenPolygon(Points : array of TPoint; const Color : TColor);
function PagePtToScreen(const Pt: TPoint): TPoint;
procedure Enqueue; virtual;
procedure EnqueueElement(const Entry: PIpHtmlElement); virtual;
function ElementQueueIsEmpty: Boolean; virtual;
procedure ReportDrawRects(M : TRectMethod); virtual;
procedure ReportCurDrawRects(Owner: TIpHtmlNode; M : TRectMethod); virtual;
procedure ReportMapRects(M : TRectMethod); virtual;
procedure Invalidate; virtual;
procedure InvalidateSize; virtual;
procedure SubmitRequest; virtual;
procedure ResetRequest; virtual;
function GetHint: string; virtual;
procedure CreateControl(Parent : TWinControl); virtual;
procedure MakeVisible; virtual;
procedure UnmarkControl; virtual;
procedure HideUnmarkedControl; virtual;
procedure EnumChildren(EnumProc: TIpHtmlNodeEnumProc; UserData: Pointer); virtual;
procedure AppendSelection(var S : string; var Completed: Boolean); virtual;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
function ExpParentWidth: Integer; virtual;
procedure ImageChange(NewPicture : TPicture); virtual;
function PageRectToScreen(const Rect : TRect; var ScreenRect: TRect): Boolean;
procedure GetAttributes(Target: TStrings; IncludeValues, IncludeBlanks: Boolean);
procedure SetAttributeValue(const AttrName, NewValue: string);
procedure SetProps(const RenderProps: TIpHtmlProps); virtual;
public
property Owner : TIpHtml read FOwner;
property ParentNode : TIpHtmlNode read FParentNode;
end;
TIpHtmlNodeNv = class(TIpHtmlNode)
protected
procedure EnqueueElement(const Entry: PIpHtmlElement); override;
function ElementQueueIsEmpty: Boolean; override;
procedure ReportDrawRects(M : TRectMethod); override;
procedure Invalidate; override;
procedure InvalidateSize; override;
procedure Enqueue; override;
public
procedure SetProps(const RenderProps: TIpHtmlProps); override;
end;
TIpHtmlNodeMulti = class(TIpHtmlNode)
private
FProps: TIpHtmlProps;
FChildren : {$ifdef IP_LAZARUS}TFPList{$else}TList{$endif};
function GetChildNode(Index: Integer): TIpHtmlNode;
function GetChildCount: Integer;
protected
procedure ReportDrawRects(M : TRectMethod); override;
procedure ReportMapRects(M : TRectMethod); override;
procedure AppendSelection(var S : string; var Completed: Boolean); override;
procedure EnumChildren(EnumProc: TIpHtmlNodeEnumProc; UserData: Pointer); override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
public
property ChildCount : Integer read GetChildCount;
property ChildNode[Index : Integer] : TIpHtmlNode read GetChildNode;
property Props : TIpHtmlProps read FProps;
end;
{ TIpHtmlNodeCore }
TIpHtmlNodeCore = class(TIpHtmlNodeMulti)
private
{$IFDEF IP_LAZARUS}
FInlineCSSProps: TCSSProps; // props from the style attribute
FCombinedCSSProps: TCSSProps; // props from all matching CSS selectors plus inline CSS combined
FHoverPropsLookupDone: Boolean;
FHoverPropsRef: TCSSProps; // props for :hover (this is only a cached reference, we don't own it)
{$ENDIF}
FElementName: String;
FStyle: string;
FClassId: string;
FTitle: string;
FId: string;
protected
procedure ParseBaseProps(aOwner : TIpHtml);
{$IFDEF IP_LAZARUS}
function SelectCSSFont(const aFont: string): string;
procedure ApplyCSSProps(const ACSSProps: TCSSProps; const props: TIpHtmlProps);
function ElementName: String;
function GetFontSizeFromCSS(CurrentFontSize:Integer; aFontSize: string):Integer;
{$ENDIF}
public
{$IFDEF IP_LAZARUS}
destructor Destroy; override;
procedure LoadAndApplyCSSProps; virtual;
{$ENDIF}
property ClassId : string read FClassId write FClassId;
property Id : string read FId write FId;
property Style : string read FStyle write FStyle;
property Title : string read FTitle write FTitle;
{$IFDEF IP_LAZARUS}
property InlineCSS: TCSSProps read FInlineCSSProps write FInlineCSSProps;
{$ENDIF}
end;
TIpHtmlNodeInline = class(TIpHtmlNodeCore)
protected
procedure EnqueueElement(const Entry: PIpHtmlElement); override;
function ElementQueueIsEmpty: Boolean; override;
procedure Invalidate; override;
end;
TIpHtmlImageAlign = (hiaTop, hiaMiddle, hiaBottom, hiaLeft, hiaRight, hiaCenter);
TIpHtmlNodeAlignInline = class(TIpHtmlNodeInline)
private
FAlignment: TIpHtmlImageAlign;
protected
Element : PIpHtmlElement;
procedure SetRect(TargetRect: TRect); virtual;
procedure SetAlignment(const Value: TIpHtmlImageAlign);
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Draw(Block: TIpHtmlNodeBlock); virtual; abstract;
procedure Enqueue; override;
procedure CalcMinMaxWidth(var Min, Max: Integer); virtual; abstract;
function GetDim(ParentWidth: Integer): TSize; virtual; abstract;
public
property Align : TIpHtmlImageAlign read FAlignment write SetAlignment;
end;
TIpHtmlNodeControl = class(TIpHtmlNodeAlignInline)
protected
FControl : TWinControl;
Shown : Boolean;
FAlt: string;
procedure HideUnmarkedControl; override;
procedure UnmarkControl; override;
procedure AddValues(NameList, ValueList : TStringList); virtual; abstract;
procedure Reset; virtual; abstract;
function Successful: Boolean; virtual; abstract;
function adjustFromCss: boolean;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Draw(Block: TIpHtmlNodeBlock); override;
function GetDim(ParentWidth: Integer): TSize; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
public
property Control: TWinControl read FControl;
property Alt : string read FAlt write FAlt;
end;
// Used by TIpHtmlNodeBlock
TWordInfo = record
BaseX : Integer;
BOff : Integer;
CurAsc : Integer;
Sz : TSize;
VA : TIpHtmlVAlign3;
Hs : Integer;
end;
PWordInfo = ^TWordInfo;
TWordList = array[0..Pred(MAXWORDS)] of TWordInfo;
PWordList = ^TWordList;
{ TIpHtmlNodeBlock }
TIpHtmlNodeBlock = class(TIpHtmlNodeCore)
private
function GetPageRect: TRect;
protected
FLayouter : TIpHtmlBaseLayouter;
FLastW, FLastH : Integer;
FBackground : string;
FBgColor : TColor;
FTextColor : TColor;
procedure EnqueueElement(const Entry: PIpHtmlElement); override;
function ElementQueueIsEmpty: Boolean; override;
procedure CalcMinMaxPropWidth(RenderProps: TIpHtmlProps; var aMin, aMax: Integer); virtual;
procedure Invalidate; override;
function GetHeight(const RenderProps: TIpHtmlProps; const Width: Integer): Integer;
procedure InvalidateSize; override;
procedure ReportCurDrawRects(aOwner: TIpHtmlNode; M : TRectMethod); override;
procedure AppendSelection(var S : string; var Completed: Boolean); override;
procedure SetBackground(const AValue: string);
procedure SetBgColor(const AValue: TColor);
procedure SetTextColor(const AValue: TColor);
public
constructor Create(ParentNode : TIpHtmlNode; LayouterClass: TIpHtmlBaseLayouterClass); overload;
constructor Create(ParentNode : TIpHtmlNode); overload;
destructor Destroy; override;
procedure Layout(RenderProps: TIpHtmlProps; const TargetRect : TRect); virtual;
procedure Render(RenderProps: TIpHtmlProps); virtual;
function Level0: Boolean;
{$IFDEF IP_LAZARUS}
procedure LoadAndApplyCSSProps; override;
{$ENDIF}
public
property Layouter : TIpHtmlBaseLayouter read FLayouter;
property Background : string read FBackground write SetBackground;
property BgColor : TColor read FBgColor write SetBgColor;
property TextColor : TColor read FTextColor write SetTextColor;
property PageRect : TRect read GetPageRect;
end;
TIpHtmlDirection = (hdLTR, hdRTL);
TIpHtmlNodeHEAD = class(TIpHtmlNodeMulti)
private
FProfile: string;
FLang: string;
FDir: TIpHtmlDirection;
public
property Dir : TIpHtmlDirection read FDir write FDir;
property Lang : string read FLang write FLang;
property Profile : string read FProfile write FProfile;
end;
{ TIpHtmlNodeText }
TIpHtmlNodeText = class(TIpHtmlNode)
private
FEscapedText : string;
FFirstW : Boolean;
function GetAnsiText: string;
procedure SetAnsiText(const Value: string);
procedure SetEscapedText(const Value: string);
procedure AddAWord(StartP: PAnsiChar);
function CutAndAddWord(StartP, EndP: PAnsiChar): PAnsiChar;
procedure DoPreformattedWords(N: PAnsiChar);
procedure DoNormalWords(N: PAnsiChar);
procedure BuildWordList;
protected
PropsR : TIpHtmlProps; {reference}
procedure ReportDrawRects(M : TRectMethod); override;
procedure Enqueue; override;
procedure EnqueueElement(const Entry: PIpHtmlElement); override;
function ElementQueueIsEmpty: Boolean; override;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
public
property ANSIText : string read GetAnsiText write SetAnsiText;
property EscapedText : string read FEscapedText write SetEscapedText;
end;
{ TIpHtmlNodeGenInline }
TIpHtmlNodeGenInline = class(TIpHtmlNodeInline)
protected
Props: TIpHtmlProps;
procedure ApplyProps(const RenderProps: TIpHtmlProps); virtual; abstract;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
end;
TIpHtmlNodeFONT = class(TIpHtmlNodeGenInline)
private
FSize: TIpHtmlRelSize;
FFace: string;
FColor: TColor;
procedure SetColor(const Value: TColor);
procedure SetFace(const Value: string);
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
procedure SizeChanged(Sender: TObject);
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
property Color : TColor read FColor write SetColor;
property Face : string read FFace write SetFace;
property Size : TIpHtmlRelSize read FSize write FSize;
end;
TIpHtmlNodeSTYLE = class(TIpHtmlNodeMulti)
private
FMedia: string;
FTitle: string;
{$IFDEF IP_LAZARUS}
FType: string;
{$ENDIF}
protected
procedure EnqueueElement(const Entry: PIpHtmlElement); override;
function ElementQueueIsEmpty: Boolean; override;
public
property Media : string read FMedia write FMedia;
property Title : string read FTitle write FTitle;
{$IFDEF IP_LAZARUS}
property Type_ : string read FType write FType;
{$ENDIF}
end;
TIpHtmlNodeSCRIPT = class(TIpHtmlNodeNv);
TIpHtmlNodeNOSCRIPT = class(TIpHtmlNodeInline);
TIpHtmlHeaderSize = 1..6;
TIpHtmlNodeHeader = class(TIpHtmlNodeInline)
private
FAlign : TIpHtmlAlign;
FSize : TIpHtmlHeaderSize;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
public
property Align : TIpHtmlAlign read FAlign write FAlign;
property Size : TIpHtmlHeaderSize read FSize write FSize;
end;
TIpHtmlNodeP = class(TIpHtmlNodeInline)
private
FAlign : TIpHtmlAlign;
procedure SetAlign(const Value: TIpHtmlAlign);
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
public
property Align : TIpHtmlAlign read FAlign write SetAlign;
end;
TIpHtmlNodeADDRESS = class(TIpHtmlNodeInline);
TIpHtmlULType = (ulDisc, ulSquare, ulCircle);
TIpHtmlNodeList = class(TIpHtmlNodeInline)
private
FCompact : Boolean;
FListType : TIpHtmlULType;
procedure SetListType(const Value: TIpHtmlULType);
public
procedure Enqueue; override;
property Compact : Boolean read FCompact write FCompact;
property ListType : TIpHtmlULType read FListType write SetListType;
end;
TIpHtmlNodeUL = class(TIpHtmlNodeList);
TIpHtmlNodeDIR = class(TIpHtmlNodeList);
TIpHtmlNodeMENU = class(TIpHtmlNodeList);
TIpHtmlOLStyle = (olArabic, olLowerAlpha, olUpperAlpha, olLowerRoman, olUpperRoman);
TIpHtmlNodeOL = class(TIpHtmlNodeInline)
private
FCompact : Boolean;
FStart : Integer;
FOLStyle : TIpHtmlOLStyle;
procedure SetStart(const Value: Integer);
procedure SetOLStyle(const Value: TIpHtmlOLStyle);
protected
Counter : Integer;
function GetNumString : string;
public
procedure Enqueue; override;
property Compact : Boolean read FCompact write FCompact;
property Start : Integer read FStart write SetStart;
property Style : TIpHtmlOLStyle read FOLStyle write SetOLStyle;
end;
TIpHtmlNodeLI = class(TIpHtmlNodeAlignInline)
private
FCompact: Boolean;
FListType : TIpHtmlULType;
FValue : Integer;
procedure SetListType(const Value: TIpHtmlULType);
procedure SetValue(const Value: Integer);
protected
WordEntry : PIpHtmlElement;
function GrossDrawRect: TRect;
public
constructor Create(ParentNode : TIpHtmlNode);
procedure Draw(Block: TIpHtmlNodeBlock); override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
function GetDim(ParentWidth: Integer): TSize; override;
public
property Compact : Boolean read FCompact write FCompact;
property ListType : TIpHtmlULType read FListType write SetListType;
property Value : Integer read FValue write SetValue;
end;
TIpHtmlFormMethod = (hfmGet, hfmPost);
TIpHtmlNodeFORM = class(TIpHtmlNodeInline)
private
FAccept: string;
FAcceptCharset: string;
FName: string;
FEnctype: string;
FAction: string;
FMethod: TIpHtmlFormMethod;
protected
procedure AddChild(Node: TIpHtmlNode; const UserData: Pointer);
procedure ResetControl(Node: TIpHtmlNode; const UserData: Pointer);
procedure ResetRequest; override;
{$IFNDEF HtmlWithoutHttp}
procedure SubmitRequest; override;
{$ENDIF}
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure ResetForm;
procedure SubmitForm;
property Accept : string read FAccept write FAccept;
property AcceptCharset : string read FAcceptCharset write FAcceptCharset;
property Action : string read FAction write FAction;
property Enctype : string read FEnctype write FEnctype;
property Method : TIpHtmlFormMethod read FMethod write FMethod;
property Name : string read FName write FName;
end;
TIpHtmlNodeHtml = class(TIpHtmlNodeMulti)
private
FLang: string;
FVersion: string;
FDir: TIpHtmlDirection;
protected
function HasBodyNode : Boolean;
procedure CalcMinMaxHtmlWidth(const RenderProps: TIpHtmlProps; var Min, Max: Integer);
function GetHeight(const RenderProps: TIpHtmlProps; const Width: Integer): Integer;
public
procedure Layout(const RenderProps: TIpHtmlProps; const TargetRect : TRect);
procedure Render(RenderProps: TIpHtmlProps);
property Dir : TIpHtmlDirection read FDir write FDir;
property Lang : string read FLang write FLang;
property Version : string read FVersion write FVersion;
end;
TIpHtmlNodeTITLE = class(TIpHtmlNodeNv)
private
FTitle: string;
public
property Title : string read FTitle write FTitle;
end;
{ TIpHtmlNodeBODY }
TIpHtmlNodeBODY = class(TIpHtmlNodeBlock)
private
FLink : TColor;
FVLink : TColor;
FALink : TColor;
procedure SetAlink(const Value: TColor);
procedure SetLink(const Value: TColor);
procedure SetVlink(const Value: TColor);
protected
BGPicture : TPicture;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure ImageChange(NewPicture : TPicture); override;
{$IFDEF IP_LAZARUS}
procedure LoadAndApplyCSSProps; override;
procedure Render(RenderProps: TIpHtmlProps); override;
{$ENDIF}
property ALink : TColor read Falink write SetAlink;
property Link : TColor read FLink write SetLink;
property VLink : TColor read FVLink write SetVlink;
end;
TIpHtmlNodeNOFRAMES = class(TIpHtmlNodeCore);
TIpHtmlNodeFRAMESET = class(TIpHtmlNodeCore)
private
FCols: TIpHtmlMultiLengthList;
FRows: TIpHtmlMultiLengthList;
public
destructor Destroy; override;
property Cols : TIpHtmlMultiLengthList read FCols write FCols;
property Rows : TIpHtmlMultiLengthList read FRows write FRows;
end;
TIpHtmlFrameScrolling = (hfsAuto, hfsYes, hfsNo);
TIpHtmlNodeFRAME = class(TIpHtmlNodeCore)
private
FFrameBorder: Integer;
FLongDesc: string;
FMarginHeight: Integer;
FMarginWidth: Integer;
FName: string;
FNoResize: Boolean;
FScrolling: TIpHtmlFrameScrolling;
FSrc: string;
procedure SetFrameBorder(const Value: Integer);
procedure SetMarginHeight(const Value: Integer);
procedure SetMarginWidth(const Value: Integer);
procedure SetScrolling(const Value: TIpHtmlFrameScrolling);
public
property FrameBorder : Integer read FFrameBorder write SetFrameBorder;
property LongDesc : string read FLongDesc write FLongDesc;
property MarginHeight : Integer read FMarginHeight write SetMarginHeight;
property MarginWidth : Integer read FMarginWidth write SetMarginWidth;
property Name : string read FName write FName;
property NoResize : Boolean read FNoResize write FNoResize;
property Scrolling : TIpHtmlFrameScrolling read FScrolling write SetScrolling;
property Src : string read FSrc write FSrc;
end;
TIpHtmlFrame = class;
TIpHtmlNodeIFRAME = class(TIpHtmlNodeControl)
private
FAlign: TIpHtmlAlign;
FFrameBorder: Integer;
FHeight: TIpHtmlLength;
FLongDesc: string;
FMarginHeight: Integer;
FMarginWidth: Integer;
FName: string;
FScrolling: TIpHtmlFrameScrolling;
FSrc: string;
FWidth: TIpHtmlLength;
FFrame : TIpHtmlFrame;
procedure SetAlign(const Value: TIpHtmlAlign);
procedure SetFrameBorder(const Value: Integer);
procedure SetMarginHeight(const Value: Integer);
procedure SetMarginWidth(const Value: Integer);
procedure SetScrolling(const Value: TIpHtmlFrameScrolling);
protected
procedure CreateControl(Parent : TWinControl); override;
function Successful: Boolean; override;
procedure AddValues(NameList, ValueList : TStringList); override;
procedure Reset; override;
procedure WidthChanged(Sender: TObject);
public
destructor Destroy; override;
property Align : TIpHtmlAlign read FAlign write SetAlign;
property Frame: TIpHtmlFrame read FFrame;
property FrameBorder : Integer read FFrameBorder write SetFrameBorder;
property Height : TIpHtmlLength read FHeight write FHeight;
property LongDesc : string read FLongDesc write FLongDesc;
property MarginHeight : Integer read FMarginHeight write SetMarginHeight;
property MarginWidth : Integer read FMarginWidth write SetMarginWidth;
property Name : string read FName write FName;
property Scrolling : TIpHtmlFrameScrolling read FScrolling write SetScrolling;
property Src : string read FSrc write FSrc;
property Width : TIpHtmlLength read FWidth write FWidth;
end;
TIpHtmlNodeDL = class(TIpHtmlNodeInline)
private
FCompact : Boolean;
public
constructor Create(ParentNode : TIpHtmlNode);
procedure Enqueue; override;
property Compact : Boolean read FCompact write FCompact;
end;
TIpHtmlNodeDT = class(TIpHtmlNodeInline)
public
constructor Create(ParentNode : TIpHtmlNode);
procedure Enqueue; override;
end;
TIpHtmlNodeDD = class(TIpHtmlNodeInline)
public
constructor Create(ParentNode : TIpHtmlNode);
procedure Enqueue; override;
end;
TIpHtmlNodePRE = class(TIpHtmlNodeInline)
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
end;
TIpHtmlNodeDIV = class(TIpHtmlNodeInline)
private
FAlign : TIpHtmlAlign;
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Enqueue; override;
procedure SetProps(const RenderProps: TIpHtmlProps); override;
property Align : TIpHtmlAlign read FAlign write FAlign;
end;
{ TIpHtmlNodeSPAN }
TIpHtmlNodeSPAN = class(TIpHtmlNodeGenInline)
private
FAlign : TIpHtmlAlign;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
constructor Create(ParentNode: TIpHtmlNode);
property Align : TIpHtmlAlign read FAlign write FAlign;
end;
TIpHtmlNodeBLINK = class(TIpHtmlNodeInline);
TIpHtmlNodeBLOCKQUOTE = class(TIpHtmlNodeInline)
public
procedure Enqueue; override;
end;
TIpHtmlNodeQ = class(TIpHtmlNodeInline);
TIpHtmlNodeINS = class(TIpHtmlNodeGenInline)
private
FCite: string;
FDateTime: string;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
property Cite : string read FCite write FCite;
property DateTime : string read FDateTime write FDateTime;
end;
TIpHtmlNodeDEL = class(TIpHtmlNodeGenInline)
private
FCite: string;
FDateTime: string;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
property Cite : string read FCite write FCite;
property DateTime : string read FDateTime write FDateTime;
end;
TIpHtmlFontStyles = (hfsTT, hfsI, hfsB, hfsU, hfsSTRIKE, hfsS,
hfsBIG, hfsSMALL, hfsSUB, hfsSUP);
TIpHtmlNodeFontStyle = class(TIpHtmlNodeGenInline)
private
FHFStyle : TIpHtmlFontStyles;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
property Style : TIpHtmlFontStyles read FHFStyle write FHFStyle;
end;
TIpHtmlPhraseStyle = (hpsEM, hpsSTRONG, hpsDFN, hpsCODE, hpsSAMP,
hpsKBD, hpsVAR, hpsCITE, hpsABBR, hpsACRONYM);
TIpHtmlNodePhrase = class(TIpHtmlNodeGenInline)
private
FPhrStyle : TIpHtmlPhraseStyle;
protected
procedure ApplyProps(const RenderProps: TIpHtmlProps); override;
public
property Style : TIpHtmlPhraseStyle read FPhrStyle write FPhrStyle;
end;
TIpHtmlNodeHR = class(TIpHtmlNodeAlignInline)
private
FColor: TColor;
FNoShade : Boolean;
FSize : TIpHtmlInteger;
FWidth : TIpHtmlLength;
protected
SizeWidth : TIpHtmlPixels;
FDim : TSize;
function GrossDrawRect: TRect;
procedure WidthChanged(Sender: TObject);
public
constructor Create(ParentNode : TIpHtmlNode);
destructor Destroy; override;
procedure Draw(Block: TIpHtmlNodeBlock); override;
procedure CalcMinMaxWidth(var Min, Max: Integer); override;
procedure Enqueue; override;
function GetDim(ParentWidth: Integer): TSize; override;
public
property Color : TColor read FColor write FColor;
property NoShade : Boolean read FNoShade write FNoShade;
property Size : TIpHtmlInteger read FSize write FSize;
property Width : TIpHtmlLength read FWidth write FWidth;
end;
TIpHtmlBreakClear = (hbcNone, hbcLeft, hbcRight, hbcAll);