/
Document.h
1584 lines (1230 loc) · 57 KB
/
Document.h
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
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* (C) 2006 Alexey Proskuryakov (ap@webkit.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* 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 Document_h
#define Document_h
#include "CollectionType.h"
#include "Color.h"
#include "ContainerNode.h"
#include "DOMTimeStamp.h"
#include "DocumentEventQueue.h"
#include "DocumentTiming.h"
#include "IconURL.h"
#include "InspectorCounters.h"
#include "IntRect.h"
#include "MutationObserver.h"
#include "PageVisibilityState.h"
#include "PlatformScreen.h"
#include "QualifiedName.h"
#include "ReferrerPolicy.h"
#include "ScriptExecutionContext.h"
#include "StringWithDirection.h"
#include "Timer.h"
#include "TreeScope.h"
#include "ViewportArguments.h"
#include <wtf/Deque.h>
#include <wtf/FixedArray.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class AXObjectCache;
class Attr;
class CDATASection;
class CSSStyleDeclaration;
class CSSStyleSheet;
class CachedCSSStyleSheet;
class CachedResourceLoader;
class CachedScript;
class CanvasRenderingContext;
class CharacterData;
class Comment;
class ContextFeatures;
class DOMImplementation;
class DOMNamedFlowCollection;
class DOMSelection;
class DOMWindow;
class Database;
class DatabaseThread;
class DocumentFragment;
class DocumentLoader;
class DocumentMarkerController;
class DocumentParser;
class DocumentSharedObjectPool;
class DocumentStyleSheetCollection;
class DocumentType;
class DocumentWeakReference;
class Element;
class EntityReference;
class Event;
class EventListener;
class FloatRect;
class FloatQuad;
class FormController;
class Frame;
class FrameView;
class HTMLCanvasElement;
class HTMLCollection;
class HTMLAllCollection;
class HTMLDocument;
class HTMLElement;
class HTMLFrameOwnerElement;
class HTMLHeadElement;
class HTMLIFrameElement;
class HTMLMapElement;
class HTMLNameCollection;
class HitTestRequest;
class HitTestResult;
class IntPoint;
class LayoutPoint;
class LayoutRect;
class LiveNodeListBase;
class DOMWrapperWorld;
class JSNode;
class Locale;
class MediaCanStartListener;
class MediaQueryList;
class MediaQueryMatcher;
class MouseEventWithHitTestResults;
class NamedFlowCollection;
class NodeFilter;
class NodeIterator;
class Page;
class PlatformMouseEvent;
class ProcessingInstruction;
class Range;
class RegisteredEventListener;
class RenderArena;
class RenderView;
class RenderFullScreen;
class ScriptableDocumentParser;
class ScriptElementData;
class ScriptRunner;
class SecurityOrigin;
class SelectorQueryCache;
class SerializedScriptValue;
class SegmentedString;
class Settings;
class StyleResolver;
class StyleSheet;
class StyleSheetContents;
class StyleSheetList;
class Text;
class TextResourceDecoder;
class TreeWalker;
class WebKitNamedFlow;
class XMLHttpRequest;
class XPathEvaluator;
class XPathExpression;
class XPathNSResolver;
class XPathResult;
#if ENABLE(SVG)
class SVGDocumentExtensions;
#endif
#if ENABLE(XSLT)
class TransformSource;
#endif
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
struct AnnotatedRegionValue;
#endif
#if ENABLE(TOUCH_EVENTS)
class Touch;
class TouchList;
#endif
#if ENABLE(REQUEST_ANIMATION_FRAME)
class RequestAnimationFrameCallback;
class ScriptedAnimationController;
#endif
#if ENABLE(MICRODATA)
class MicroDataItemList;
#endif
#if ENABLE(LINK_PRERENDER)
class Prerenderer;
#endif
#if ENABLE(TEXT_AUTOSIZING)
class TextAutosizer;
#endif
#if ENABLE(CSP_NEXT)
class DOMSecurityPolicy;
#endif
typedef int ExceptionCode;
enum PageshowEventPersistence {
PageshowEventNotPersisted = 0,
PageshowEventPersisted = 1
};
enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded };
enum NodeListInvalidationType {
DoNotInvalidateOnAttributeChanges = 0,
InvalidateOnClassAttrChange,
InvalidateOnIdNameAttrChange,
InvalidateOnNameAttrChange,
InvalidateOnForAttrChange,
InvalidateForFormControls,
InvalidateOnHRefAttrChange,
InvalidateOnItemAttrChange,
InvalidateOnAnyAttrChange,
};
const int numNodeListInvalidationTypes = InvalidateOnAnyAttrChange + 1;
class Document : public ContainerNode, public TreeScope, public ScriptExecutionContext {
public:
static PassRefPtr<Document> create(Frame* frame, const KURL& url)
{
return adoptRef(new Document(frame, url, false, false));
}
static PassRefPtr<Document> createXHTML(Frame* frame, const KURL& url)
{
return adoptRef(new Document(frame, url, true, false));
}
virtual ~Document();
MediaQueryMatcher* mediaQueryMatcher();
using ContainerNode::ref;
using ContainerNode::deref;
// Nodes belonging to this document hold guard references -
// these are enough to keep the document from being destroyed, but
// not enough to keep it from removing its children. This allows a
// node that outlives its document to still have a valid document
// pointer without introducing reference cycles.
void guardRef()
{
ASSERT(!m_deletionHasBegun);
++m_guardRefCount;
}
void guardDeref()
{
ASSERT(!m_deletionHasBegun);
--m_guardRefCount;
if (!m_guardRefCount && !refCount()) {
#ifndef NDEBUG
m_deletionHasBegun = true;
#endif
delete this;
}
}
Element* getElementById(const AtomicString& id) const;
virtual bool canContainRangeEndPoint() const { return true; }
Element* getElementByAccessKey(const String& key);
void invalidateAccessKeyMap();
SelectorQueryCache* selectorQueryCache();
// DOM methods & attributes for Document
DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
DEFINE_ATTRIBUTE_EVENT_LISTENER(contextmenu);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dblclick);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragenter);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragover);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragleave);
DEFINE_ATTRIBUTE_EVENT_LISTENER(drop);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(drag);
DEFINE_ATTRIBUTE_EVENT_LISTENER(dragend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(input);
DEFINE_ATTRIBUTE_EVENT_LISTENER(invalid);
DEFINE_ATTRIBUTE_EVENT_LISTENER(keydown);
DEFINE_ATTRIBUTE_EVENT_LISTENER(keypress);
DEFINE_ATTRIBUTE_EVENT_LISTENER(keyup);
DEFINE_ATTRIBUTE_EVENT_LISTENER(mousedown);
DEFINE_ATTRIBUTE_EVENT_LISTENER(mousemove);
DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseout);
DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseover);
DEFINE_ATTRIBUTE_EVENT_LISTENER(mouseup);
DEFINE_ATTRIBUTE_EVENT_LISTENER(mousewheel);
DEFINE_ATTRIBUTE_EVENT_LISTENER(scroll);
DEFINE_ATTRIBUTE_EVENT_LISTENER(select);
DEFINE_ATTRIBUTE_EVENT_LISTENER(submit);
DEFINE_ATTRIBUTE_EVENT_LISTENER(blur);
DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
DEFINE_ATTRIBUTE_EVENT_LISTENER(focus);
DEFINE_ATTRIBUTE_EVENT_LISTENER(load);
DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
// WebKit extensions
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
DEFINE_ATTRIBUTE_EVENT_LISTENER(cut);
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
DEFINE_ATTRIBUTE_EVENT_LISTENER(copy);
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
DEFINE_ATTRIBUTE_EVENT_LISTENER(paste);
DEFINE_ATTRIBUTE_EVENT_LISTENER(reset);
DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(selectionchange);
#if ENABLE(TOUCH_EVENTS)
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
#endif
#if ENABLE(FULLSCREEN_API)
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenerror);
#endif
#if ENABLE(POINTER_LOCK)
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitpointerlockchange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitpointerlockerror);
#endif
#if ENABLE(PAGE_VISIBILITY_API)
DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitvisibilitychange);
#endif
void setViewportArguments(const ViewportArguments& viewportArguments) { m_viewportArguments = viewportArguments; }
ViewportArguments viewportArguments() const { return m_viewportArguments; }
#ifndef NDEBUG
bool didDispatchViewportPropertiesChanged() const { return m_didDispatchViewportPropertiesChanged; }
#endif
void setReferrerPolicy(ReferrerPolicy referrerPolicy) { m_referrerPolicy = referrerPolicy; }
ReferrerPolicy referrerPolicy() const { return m_referrerPolicy; }
DocumentType* doctype() const { return m_docType.get(); }
DOMImplementation* implementation();
Element* documentElement() const
{
return m_documentElement.get();
}
virtual PassRefPtr<Element> createElement(const AtomicString& tagName, ExceptionCode&);
PassRefPtr<DocumentFragment> createDocumentFragment();
PassRefPtr<Text> createTextNode(const String& data);
PassRefPtr<Comment> createComment(const String& data);
PassRefPtr<CDATASection> createCDATASection(const String& data, ExceptionCode&);
PassRefPtr<ProcessingInstruction> createProcessingInstruction(const String& target, const String& data, ExceptionCode&);
PassRefPtr<Attr> createAttribute(const String& name, ExceptionCode&);
PassRefPtr<Attr> createAttributeNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&, bool shouldIgnoreNamespaceChecks = false);
PassRefPtr<EntityReference> createEntityReference(const String& name, ExceptionCode&);
PassRefPtr<Node> importNode(Node* importedNode, ExceptionCode& ec) { return importNode(importedNode, true, ec); }
PassRefPtr<Node> importNode(Node* importedNode, bool deep, ExceptionCode&);
virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser);
bool cssStickyPositionEnabled() const;
bool cssRegionsEnabled() const;
#if ENABLE(CSS_REGIONS)
PassRefPtr<DOMNamedFlowCollection> webkitGetNamedFlows();
#endif
NamedFlowCollection* namedFlows();
bool regionBasedColumnsEnabled() const;
bool cssGridLayoutEnabled() const;
/**
* Retrieve all nodes that intersect a rect in the window's document, until it is fully enclosed by
* the boundaries of a node.
*
* @param centerX x reference for the rectangle in CSS pixels
* @param centerY y reference for the rectangle in CSS pixels
* @param topPadding How much to expand the top of the rectangle
* @param rightPadding How much to expand the right of the rectangle
* @param bottomPadding How much to expand the bottom of the rectangle
* @param leftPadding How much to expand the left of the rectangle
* @param ignoreClipping whether or not to ignore the root scroll frame when retrieving the element.
* If false, this method returns null for coordinates outside of the viewport.
*/
PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding,
unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent) const;
Element* elementFromPoint(int x, int y) const;
PassRefPtr<Range> caretRangeFromPoint(int x, int y);
String readyState() const;
String defaultCharset() const;
String inputEncoding() const { return Document::encoding(); }
String charset() const { return Document::encoding(); }
String characterSet() const { return Document::encoding(); }
String encoding() const;
void setCharset(const String&);
void setContent(const String&);
String suggestedMIMEType() const;
String contentLanguage() const { return m_contentLanguage; }
void setContentLanguage(const String&);
String xmlEncoding() const { return m_xmlEncoding; }
String xmlVersion() const { return m_xmlVersion; }
enum StandaloneStatus { StandaloneUnspecified, Standalone, NotStandalone };
bool xmlStandalone() const { return m_xmlStandalone == Standalone; }
StandaloneStatus xmlStandaloneStatus() const { return static_cast<StandaloneStatus>(m_xmlStandalone); }
bool hasXMLDeclaration() const { return m_hasXMLDeclaration; }
void setXMLEncoding(const String& encoding) { m_xmlEncoding = encoding; } // read-only property, only to be set from XMLDocumentParser
void setXMLVersion(const String&, ExceptionCode&);
void setXMLStandalone(bool, ExceptionCode&);
void setHasXMLDeclaration(bool hasXMLDeclaration) { m_hasXMLDeclaration = hasXMLDeclaration ? 1 : 0; }
String documentURI() const { return m_documentURI; }
void setDocumentURI(const String&);
virtual KURL baseURI() const;
#if ENABLE(PAGE_VISIBILITY_API)
String webkitVisibilityState() const;
bool webkitHidden() const;
void dispatchVisibilityStateChangeEvent();
#endif
#if ENABLE(CSP_NEXT)
DOMSecurityPolicy* securityPolicy();
#endif
PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&);
PassRefPtr<HTMLCollection> images();
PassRefPtr<HTMLCollection> embeds();
PassRefPtr<HTMLCollection> plugins(); // an alias for embeds() required for the JS DOM bindings.
PassRefPtr<HTMLCollection> applets();
PassRefPtr<HTMLCollection> links();
PassRefPtr<HTMLCollection> forms();
PassRefPtr<HTMLCollection> anchors();
PassRefPtr<HTMLCollection> scripts();
PassRefPtr<HTMLCollection> all();
PassRefPtr<HTMLCollection> windowNamedItems(const AtomicString& name);
PassRefPtr<HTMLCollection> documentNamedItems(const AtomicString& name);
// Other methods (not part of DOM)
bool isHTMLDocument() const { return m_isHTML; }
bool isXHTMLDocument() const { return m_isXHTML; }
virtual bool isImageDocument() const { return false; }
#if ENABLE(SVG)
virtual bool isSVGDocument() const { return false; }
bool hasSVGRootNode() const;
#else
static bool isSVGDocument() { return false; }
static bool hasSVGRootNode() { return false; }
#endif
virtual bool isPluginDocument() const { return false; }
virtual bool isMediaDocument() const { return false; }
virtual bool isFrameSet() const { return false; }
bool isSrcdocDocument() const { return m_isSrcdocDocument; }
StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
bool isViewSource() const { return m_isViewSource; }
void setIsViewSource(bool);
bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
StyleResolver* styleResolver()
{
if (!m_styleResolver)
createStyleResolver();
return m_styleResolver.get();
}
void notifyRemovePendingSheetIfNeeded();
bool haveStylesheetsLoaded() const;
// This is a DOM function.
StyleSheetList* styleSheets();
DocumentStyleSheetCollection* styleSheetCollection() { return m_styleSheetCollection.get(); }
bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
/**
* Called when one or more stylesheets in the document may have been added, removed or changed.
*
* Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
* document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
* <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
* constructed from these which is used to create the a new style selector which collates all of the stylesheets
* found and is used to calculate the derived styles for all rendering objects.
*/
void styleResolverChanged(StyleResolverUpdateFlag);
void didAccessStyleResolver();
void evaluateMediaQueryList();
// Never returns 0.
FormController* formController();
Vector<String> formElementsState() const;
void setStateForNewFormElements(const Vector<String>&);
FrameView* view() const; // can be NULL
Frame* frame() const { return m_frame; } // can be NULL
Page* page() const; // can be NULL
Settings* settings() const; // can be NULL
PassRefPtr<Range> createRange();
PassRefPtr<NodeIterator> createNodeIterator(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
PassRefPtr<TreeWalker> createTreeWalker(Node* root, unsigned whatToShow,
PassRefPtr<NodeFilter>, bool expandEntityReferences, ExceptionCode&);
// Special support for editing
PassRefPtr<CSSStyleDeclaration> createCSSStyleDeclaration();
PassRefPtr<Text> createEditingTextNode(const String&);
void recalcStyle(StyleChange = NoChange);
bool childNeedsAndNotInStyleRecalc();
void updateStyleIfNeeded();
void updateLayout();
void updateLayoutIgnorePendingStylesheets();
PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
PassRefPtr<RenderStyle> styleForPage(int pageIndex);
// Returns true if page box (margin boxes and page borders) is visible.
bool isPageBoxVisible(int pageIndex);
// Returns the preferred page size and margins in pixels, assuming 96
// pixels per inch. pageSize, marginTop, marginRight, marginBottom,
// marginLeft must be initialized to the default values that are used if
// auto is specified.
void pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft);
static void updateStyleForAllDocuments(); // FIXME: Try to reduce the # of calls to this function.
CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader.get(); }
virtual void attach();
virtual void detach();
void prepareForDestruction();
// Override ScriptExecutionContext methods to do additional work
virtual void suspendActiveDOMObjects(ActiveDOMObject::ReasonForSuspension) OVERRIDE;
virtual void resumeActiveDOMObjects() OVERRIDE;
RenderArena* renderArena() { return m_renderArena.get(); }
// Implemented in RenderView.h to avoid a cyclic header dependency this just
// returns renderer so callers can avoid verbose casts.
RenderView* renderView() const;
// Shadow the implementations on Node to provide faster access for documents.
RenderObject* renderer() const { return m_renderer; }
void setRenderer(RenderObject* renderer)
{
m_renderer = renderer;
Node::setRenderer(renderer);
}
void clearAXObjectCache();
AXObjectCache* axObjectCache() const;
bool axObjectCacheExists() const;
// to get visually ordered hebrew and arabic pages right
void setVisuallyOrdered();
bool visuallyOrdered() const { return m_visuallyOrdered; }
DocumentLoader* loader() const;
void open(Document* ownerDocument = 0);
void implicitOpen();
// close() is the DOM API document.close()
void close();
// In some situations (see the code), we ignore document.close().
// explicitClose() bypass these checks and actually tries to close the
// input stream.
void explicitClose();
// implicitClose() actually does the work of closing the input stream.
void implicitClose();
void cancelParsing();
void write(const SegmentedString& text, Document* ownerDocument = 0);
void write(const String& text, Document* ownerDocument = 0);
void writeln(const String& text, Document* ownerDocument = 0);
bool wellFormed() const { return m_wellFormed; }
const KURL& url() const { return m_url; }
void setURL(const KURL&);
// To understand how these concepts relate to one another, please see the
// comments surrounding their declaration.
const KURL& baseURL() const { return m_baseURL; }
void setBaseURLOverride(const KURL&);
const KURL& baseURLOverride() const { return m_baseURLOverride; }
const KURL& baseElementURL() const { return m_baseElementURL; }
const String& baseTarget() const { return m_baseTarget; }
void processBaseElement();
KURL completeURL(const String&) const;
KURL completeURL(const String&, const KURL& baseURLOverride) const;
virtual String userAgent(const KURL&) const;
virtual void disableEval(const String& errorMessage);
bool canNavigate(Frame* targetFrame);
Frame* findUnsafeParentScrollPropagationBoundary();
CSSStyleSheet* elementSheet();
virtual PassRefPtr<DocumentParser> createParser();
DocumentParser* parser() const { return m_parser.get(); }
ScriptableDocumentParser* scriptableDocumentParser() const;
bool printing() const { return m_printing; }
void setPrinting(bool p) { m_printing = p; }
bool paginatedForScreen() const { return m_paginatedForScreen; }
void setPaginatedForScreen(bool p) { m_paginatedForScreen = p; }
bool paginated() const { return printing() || paginatedForScreen(); }
enum CompatibilityMode { QuirksMode, LimitedQuirksMode, NoQuirksMode };
virtual void setCompatibilityModeFromDoctype() { }
void setCompatibilityMode(CompatibilityMode m);
void lockCompatibilityMode() { m_compatibilityModeLocked = true; }
CompatibilityMode compatibilityMode() const { return m_compatibilityMode; }
String compatMode() const;
bool inQuirksMode() const { return m_compatibilityMode == QuirksMode; }
bool inLimitedQuirksMode() const { return m_compatibilityMode == LimitedQuirksMode; }
bool inNoQuirksMode() const { return m_compatibilityMode == NoQuirksMode; }
enum ReadyState {
Loading,
Interactive,
Complete
};
void setReadyState(ReadyState);
void setParsing(bool);
bool parsing() const { return m_bParsing; }
int minimumLayoutDelay();
bool shouldScheduleLayout();
bool isLayoutTimerActive();
int elapsedTime() const;
void setTextColor(const Color& color) { m_textColor = color; }
Color textColor() const { return m_textColor; }
const Color& linkColor() const { return m_linkColor; }
const Color& visitedLinkColor() const { return m_visitedLinkColor; }
const Color& activeLinkColor() const { return m_activeLinkColor; }
void setLinkColor(const Color& c) { m_linkColor = c; }
void setVisitedLinkColor(const Color& c) { m_visitedLinkColor = c; }
void setActiveLinkColor(const Color& c) { m_activeLinkColor = c; }
void resetLinkColor();
void resetVisitedLinkColor();
void resetActiveLinkColor();
MouseEventWithHitTestResults prepareMouseEvent(const HitTestRequest&, const LayoutPoint&, const PlatformMouseEvent&);
/* Newly proposed CSS3 mechanism for selecting alternate
stylesheets using the DOM. May be subject to change as
spec matures. - dwh
*/
String preferredStylesheetSet() const;
String selectedStylesheetSet() const;
void setSelectedStylesheetSet(const String&);
bool setFocusedNode(PassRefPtr<Node>);
Node* focusedNode() const { return m_focusedNode.get(); }
void getFocusableNodes(Vector<RefPtr<Node> >&);
// The m_ignoreAutofocus flag specifies whether or not the document has been changed by the user enough
// for WebCore to ignore the autofocus attribute on any form controls
bool ignoreAutofocus() const { return m_ignoreAutofocus; };
void setIgnoreAutofocus(bool shouldIgnore = true) { m_ignoreAutofocus = shouldIgnore; };
void setHoverNode(PassRefPtr<Node>);
Node* hoverNode() const { return m_hoverNode.get(); }
void setActiveNode(PassRefPtr<Node>);
Node* activeNode() const { return m_activeNode.get(); }
void focusedNodeRemoved();
void removeFocusedNodeOfSubtree(Node*, bool amongChildrenOnly = false);
void hoveredNodeDetached(Node*);
void activeChainNodeDetached(Node*);
void updateHoverActiveState(const HitTestRequest&, HitTestResult&);
// Updates for :target (CSS3 selector).
void setCSSTarget(Element*);
Element* cssTarget() const { return m_cssTarget; }
void scheduleForcedStyleRecalc();
void scheduleStyleRecalc();
void unscheduleStyleRecalc();
bool hasPendingStyleRecalc() const;
bool hasPendingForcedStyleRecalc() const;
void styleRecalcTimerFired(Timer<Document>*);
void registerNodeList(LiveNodeListBase*);
void unregisterNodeList(LiveNodeListBase*);
bool shouldInvalidateNodeListCaches(const QualifiedName* attrName = 0) const;
void invalidateNodeListCaches(const QualifiedName* attrName);
void attachNodeIterator(NodeIterator*);
void detachNodeIterator(NodeIterator*);
void moveNodeIteratorsToNewDocument(Node*, Document*);
void attachRange(Range*);
void detachRange(Range*);
void updateRangesAfterChildrenChanged(ContainerNode*);
// nodeChildrenWillBeRemoved is used when removing all node children at once.
void nodeChildrenWillBeRemoved(ContainerNode*);
// nodeWillBeRemoved is only safe when removing one node at a time.
void nodeWillBeRemoved(Node*);
bool canReplaceChild(Node* newChild, Node* oldChild);
void textInserted(Node*, unsigned offset, unsigned length);
void textRemoved(Node*, unsigned offset, unsigned length);
void textNodesMerged(Text* oldNode, unsigned offset);
void textNodeSplit(Text* oldNode);
void createDOMWindow();
void takeDOMWindowFrom(Document*);
DOMWindow* domWindow() const { return m_domWindow.get(); }
// In DOM Level 2, the Document's DOMWindow is called the defaultView.
DOMWindow* defaultView() const { return domWindow(); }
// Helper functions for forwarding DOMWindow event related tasks to the DOMWindow if it exists.
void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
EventListener* getWindowAttributeEventListener(const AtomicString& eventType);
void dispatchWindowEvent(PassRefPtr<Event>, PassRefPtr<EventTarget> = 0);
void dispatchWindowLoadEvent();
PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&);
// keep track of what types of event listeners are registered, so we don't
// dispatch events unnecessarily
enum ListenerType {
DOMSUBTREEMODIFIED_LISTENER = 1,
DOMNODEINSERTED_LISTENER = 1 << 1,
DOMNODEREMOVED_LISTENER = 1 << 2,
DOMNODEREMOVEDFROMDOCUMENT_LISTENER = 1 << 3,
DOMNODEINSERTEDINTODOCUMENT_LISTENER = 1 << 4,
DOMCHARACTERDATAMODIFIED_LISTENER = 1 << 5,
OVERFLOWCHANGED_LISTENER = 1 << 6,
ANIMATIONEND_LISTENER = 1 << 7,
ANIMATIONSTART_LISTENER = 1 << 8,
ANIMATIONITERATION_LISTENER = 1 << 9,
TRANSITIONEND_LISTENER = 1 << 10,
BEFORELOAD_LISTENER = 1 << 11,
SCROLL_LISTENER = 1 << 12
// 3 bits remaining
};
bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
void addListenerTypeIfNeeded(const AtomicString& eventType);
#if ENABLE(MUTATION_OBSERVERS)
bool hasMutationObserversOfType(MutationObserver::MutationType type) const
{
return m_mutationObserverTypes & type;
}
bool hasMutationObservers() const { return m_mutationObserverTypes; }
void addMutationObserverTypes(MutationObserverOptions types) { m_mutationObserverTypes |= types; }
#endif
CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
int nodeAbsIndex(Node*);
Node* nodeWithAbsIndex(int absIndex);
/**
* Handles a HTTP header equivalent set by a meta tag using <meta http-equiv="..." content="...">. This is called
* when a meta tag is encountered during document parsing, and also when a script dynamically changes or adds a meta
* tag. This enables scripts to use meta tags to perform refreshes and set expiry dates in addition to them being
* specified in a HTML file.
*
* @param equiv The http header name (value of the meta tag's "equiv" attribute)
* @param content The header value (value of the meta tag's "content" attribute)
*/
void processHttpEquiv(const String& equiv, const String& content);
void processViewport(const String& features, ViewportArguments::Type origin);
void updateViewportArguments();
void processReferrerPolicy(const String& policy);
// Returns the owning element in the parent document.
// Returns 0 if this is the top level document.
HTMLFrameOwnerElement* ownerElement() const;
HTMLIFrameElement* seamlessParentIFrame() const;
bool shouldDisplaySeamlesslyWithParent() const;
// Used by DOM bindings; no direction known.
String title() const { return m_title.string(); }
void setTitle(const String&);
void setTitleElement(const StringWithDirection&, Element* titleElement);
void removeTitle(Element* titleElement);
String cookie(ExceptionCode&) const;
void setCookie(const String&, ExceptionCode&);
String referrer() const;
String domain() const;
void setDomain(const String& newDomain, ExceptionCode&);
String lastModified() const;
// The cookieURL is used to query the cookie database for this document's
// cookies. For example, if the cookie URL is http://example.com, we'll
// use the non-Secure cookies for example.com when computing
// document.cookie.
//
// Q: How is the cookieURL different from the document's URL?
// A: The two URLs are the same almost all the time. However, if one
// document inherits the security context of another document, it
// inherits its cookieURL but not its URL.
//
const KURL& cookieURL() const { return m_cookieURL; }
void setCookieURL(const KURL& url) { m_cookieURL = url; }
// The firstPartyForCookies is used to compute whether this document
// appears in a "third-party" context for the purpose of third-party
// cookie blocking. The document is in a third-party context if the
// cookieURL and the firstPartyForCookies are from different hosts.
//
// Note: Some ports (including possibly Apple's) only consider the
// document in a third-party context if the cookieURL and the
// firstPartyForCookies have a different registry-controlled
// domain.
//
const KURL& firstPartyForCookies() const { return m_firstPartyForCookies; }
void setFirstPartyForCookies(const KURL& url) { m_firstPartyForCookies = url; }
// The following implements the rule from HTML 4 for what valid names are.
// To get this right for all the XML cases, we probably have to improve this or move it
// and make it sensitive to the type of document.
static bool isValidName(const String&);
// The following breaks a qualified name into a prefix and a local name.
// It also does a validity check, and returns false if the qualified name
// is invalid. It also sets ExceptionCode when name is invalid.
static bool parseQualifiedName(const String& qualifiedName, String& prefix, String& localName, ExceptionCode&);
// Checks to make sure prefix and namespace do not conflict (per DOM Core 3)
static bool hasValidNamespaceForElements(const QualifiedName&);
static bool hasValidNamespaceForAttributes(const QualifiedName&);
HTMLElement* body() const;
void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
HTMLHeadElement* head();
DocumentMarkerController* markers() const { return m_markers.get(); }
bool directionSetOnDocumentElement() const { return m_directionSetOnDocumentElement; }
bool writingModeSetOnDocumentElement() const { return m_writingModeSetOnDocumentElement; }
void setDirectionSetOnDocumentElement(bool b) { m_directionSetOnDocumentElement = b; }
void setWritingModeSetOnDocumentElement(bool b) { m_writingModeSetOnDocumentElement = b; }
bool execCommand(const String& command, bool userInterface = false, const String& value = String());
bool queryCommandEnabled(const String& command);
bool queryCommandIndeterm(const String& command);
bool queryCommandState(const String& command);
bool queryCommandSupported(const String& command);
String queryCommandValue(const String& command);
KURL openSearchDescriptionURL();
// designMode support
enum InheritedBool { off = false, on = true, inherit };
void setDesignMode(InheritedBool value);
InheritedBool getDesignMode() const;
bool inDesignMode() const;
Document* parentDocument() const;
Document* topDocument() const;
int docID() const { return m_docID; }
ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
#if ENABLE(XSLT)
void applyXSLTransform(ProcessingInstruction* pi);
PassRefPtr<Document> transformSourceDocument() { return m_transformSourceDocument; }
void setTransformSourceDocument(Document* doc) { m_transformSourceDocument = doc; }
void setTransformSource(PassOwnPtr<TransformSource>);
TransformSource* transformSource() const { return m_transformSource.get(); }
#endif
void incDOMTreeVersion() { m_domTreeVersion = ++s_globalTreeVersion; }
uint64_t domTreeVersion() const { return m_domTreeVersion; }
void setDocType(PassRefPtr<DocumentType>);
// XPathEvaluator methods
PassRefPtr<XPathExpression> createExpression(const String& expression,
XPathNSResolver* resolver,
ExceptionCode& ec);
PassRefPtr<XPathNSResolver> createNSResolver(Node *nodeResolver);
PassRefPtr<XPathResult> evaluate(const String& expression,
Node* contextNode,
XPathNSResolver* resolver,
unsigned short type,
XPathResult* result,
ExceptionCode& ec);
enum PendingSheetLayout { NoLayoutWithPendingSheets, DidLayoutWithPendingSheets, IgnoreLayoutWithPendingSheets };
bool didLayoutWithPendingStylesheets() const { return m_pendingSheetLayout == DidLayoutWithPendingSheets; }
bool hasNodesWithPlaceholderStyle() const { return m_hasNodesWithPlaceholderStyle; }
void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; }
const Vector<IconURL>& iconURLs();
void addIconURL(const String& url, const String& mimeType, const String& size, IconType);
void setUseSecureKeyboardEntryWhenActive(bool);
bool useSecureKeyboardEntryWhenActive() const;
void updateFocusAppearanceSoon(bool restorePreviousSelection);
void cancelFocusAppearanceUpdate();
// Extension for manipulating canvas drawing contexts for use in CSS
CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
HTMLCanvasElement* getCSSCanvasElement(const String& name);
bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
void parseDNSPrefetchControlHeader(const String&);
virtual void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously.
virtual void suspendScriptedAnimationControllerCallbacks();
virtual void resumeScriptedAnimationControllerCallbacks();
void windowScreenDidChange(PlatformDisplayID);
virtual void finishedParsing();
bool inPageCache() const { return m_inPageCache; }
void setInPageCache(bool flag);
// Elements can register themselves for the "documentWillSuspendForPageCache()" and
// "documentDidResumeFromPageCache()" callbacks
void registerForPageCacheSuspensionCallbacks(Element*);
void unregisterForPageCacheSuspensionCallbacks(Element*);
void documentWillBecomeInactive();
void documentWillSuspendForPageCache();
void documentDidResumeFromPageCache();
void registerForMediaVolumeCallbacks(Element*);
void unregisterForMediaVolumeCallbacks(Element*);
void mediaVolumeDidChange();
void registerForPrivateBrowsingStateChangedCallbacks(Element*);
void unregisterForPrivateBrowsingStateChangedCallbacks(Element*);
void storageBlockingStateDidChange();
void privateBrowsingStateDidChange();
void setShouldCreateRenderers(bool);
bool shouldCreateRenderers();
void setDecoder(PassRefPtr<TextResourceDecoder>);
TextResourceDecoder* decoder() const { return m_decoder.get(); }
String displayStringModifiedByEncoding(const String&) const;
PassRefPtr<StringImpl> displayStringModifiedByEncoding(PassRefPtr<StringImpl>) const;
void displayBufferModifiedByEncoding(LChar* buffer, unsigned len) const
{
displayBufferModifiedByEncodingInternal(buffer, len);
}
void displayBufferModifiedByEncoding(UChar* buffer, unsigned len) const
{
displayBufferModifiedByEncodingInternal(buffer, len);
}
// Quirk for the benefit of Apple's Dictionary application.