[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.24
[framework/web/webkit-efl.git] / Source / WebCore / testing / Internals.h
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1.  Redistributions of source code must retain the above copyright
9  *     notice, this list of conditions and the following disclaimer.
10  * 2.  Redistributions in binary form must reproduce the above copyright
11  *     notice, this list of conditions and the following disclaimer in the
12  *     documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef Internals_h
27 #define Internals_h
28
29 #include "FrameDestructionObserver.h"
30 #include "NodeList.h"
31 #include "PlatformString.h"
32 #include <wtf/PassRefPtr.h>
33 #include <wtf/RefCounted.h>
34 #include <wtf/text/WTFString.h>
35
36 namespace WebCore {
37
38 class ClientRect;
39 class ClientRectList;
40 class Document;
41 class DocumentMarker;
42 class Element;
43 class InternalSettings;
44 class Node;
45 class Range;
46 class ShadowRoot;
47 class WebKitPoint;
48
49 typedef int ExceptionCode;
50
51 class Internals : public RefCounted<Internals>,
52                   public FrameDestructionObserver {
53 public:
54     static PassRefPtr<Internals> create(Document*);
55     virtual ~Internals();
56
57     void reset(Document*);
58
59     String elementRenderTreeAsText(Element*, ExceptionCode&);
60
61     String address(Node*);
62
63     bool isPreloaded(Document*, const String& url);
64
65     size_t numberOfScopedHTMLStyleChildren(const Node*, ExceptionCode&) const;
66
67 #if ENABLE(SHADOW_DOM)
68     typedef ShadowRoot ShadowRootIfShadowDOMEnabledOrNode;
69 #else
70     typedef Node ShadowRootIfShadowDOMEnabledOrNode;
71 #endif
72     ShadowRootIfShadowDOMEnabledOrNode* ensureShadowRoot(Element* host, ExceptionCode&);
73     ShadowRootIfShadowDOMEnabledOrNode* shadowRoot(Element* host, ExceptionCode&);
74     ShadowRootIfShadowDOMEnabledOrNode* youngestShadowRoot(Element* host, ExceptionCode&);
75     ShadowRootIfShadowDOMEnabledOrNode* oldestShadowRoot(Element* host, ExceptionCode&);
76     ShadowRootIfShadowDOMEnabledOrNode* youngerShadowRoot(Node* shadow, ExceptionCode&);
77     ShadowRootIfShadowDOMEnabledOrNode* olderShadowRoot(Node* shadow, ExceptionCode&);
78     Element* includerFor(Node*, ExceptionCode&);
79     String shadowPseudoId(Element*, ExceptionCode&);
80     PassRefPtr<Element> createContentElement(Document*, ExceptionCode&);
81     Element* getElementByIdInShadowRoot(Node* shadowRoot, const String& id, ExceptionCode&);
82     bool isValidContentSelect(Element* insertionPoint, ExceptionCode&);
83     Node* treeScopeRootNode(Node*, ExceptionCode&);
84
85     bool attached(Node*, ExceptionCode&);
86
87     // FIXME: Rename these functions if walker is prefered.
88     Node* nextSiblingByWalker(Node*, ExceptionCode&);
89     Node* firstChildByWalker(Node*, ExceptionCode&);
90     Node* lastChildByWalker(Node*, ExceptionCode&);
91     Node* nextNodeByWalker(Node*, ExceptionCode&);
92     Node* previousNodeByWalker(Node*, ExceptionCode&);
93
94     String visiblePlaceholder(Element*);
95 #if ENABLE(INPUT_TYPE_COLOR)
96     void selectColorInColorChooser(Element*, const String& colorValue);
97 #endif
98
99     PassRefPtr<ClientRect> absoluteCaretBounds(Document*, ExceptionCode&);
100
101     PassRefPtr<ClientRect> boundingBox(Element*, ExceptionCode&);
102
103     PassRefPtr<ClientRectList> inspectorHighlightRects(Document*, ExceptionCode&);
104
105     void setBackgroundBlurOnNode(Node*, int blurLength, ExceptionCode&);
106
107     unsigned markerCountForNode(Node*, const String&, ExceptionCode&);
108     PassRefPtr<Range> markerRangeForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);
109     String markerDescriptionForNode(Node*, const String& markerType, unsigned index, ExceptionCode&);
110
111     void setScrollViewPosition(Document*, long x, long y, ExceptionCode&);
112
113     void setPagination(Document*, const String& mode, int gap, ExceptionCode&);
114
115     bool wasLastChangeUserEdit(Element* textField, ExceptionCode&);
116     String suggestedValue(Element* inputElement, ExceptionCode&);
117     void setSuggestedValue(Element* inputElement, const String&, ExceptionCode&);
118     void setEditingValue(Element* inputElement, const String&, ExceptionCode&);
119     void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&);
120
121     void paintControlTints(Document*, ExceptionCode&);
122
123     PassRefPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionCode&);
124     unsigned locationFromRange(Element* scope, const Range*, ExceptionCode&);
125     unsigned lengthFromRange(Element* scope, const Range*, ExceptionCode&);
126     String rangeAsText(const Range*, ExceptionCode&);
127
128     void setDelegatesScrolling(bool enabled, Document*, ExceptionCode&);
129 #if ENABLE(TOUCH_ADJUSTMENT)
130     PassRefPtr<WebKitPoint> touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document*, ExceptionCode&);
131     Node* touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document*, ExceptionCode&);
132     PassRefPtr<ClientRect> bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document*, ExceptionCode&);
133 #endif
134
135     int lastSpellCheckRequestSequence(Document*, ExceptionCode&);
136     int lastSpellCheckProcessedSequence(Document*, ExceptionCode&);
137     
138     Vector<String> userPreferredLanguages() const;
139     void setUserPreferredLanguages(const Vector<String>&);
140
141     void setShouldDisplayTrackKind(Document*, const String& kind, bool, ExceptionCode&);
142     bool shouldDisplayTrackKind(Document*, const String& kind, ExceptionCode&);
143
144     unsigned wheelEventHandlerCount(Document*, ExceptionCode&);
145     unsigned touchEventHandlerCount(Document*, ExceptionCode&);
146
147     PassRefPtr<NodeList> nodesFromRect(Document*, int x, int y, unsigned topPadding, unsigned rightPadding,
148         unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allowShadowContent, ExceptionCode&) const;
149
150     void emitInspectorDidBeginFrame();
151     void emitInspectorDidCancelFrame();
152
153     bool hasSpellingMarker(Document*, int from, int length, ExceptionCode&);
154     bool hasGrammarMarker(Document*, int from, int length, ExceptionCode&);
155
156     unsigned numberOfScrollableAreas(Document*, ExceptionCode&);
157
158     bool isPageBoxVisible(Document*, int pageNumber, ExceptionCode&);
159
160     static const char* internalsId;
161
162     InternalSettings* settings() const { return m_settings.get(); }
163
164     void setBatteryStatus(Document*, const String& eventType, bool charging, double chargingTime, double dischargingTime, double level, ExceptionCode&);
165
166     void setNetworkInformation(Document*, const String& eventType, long bandwidth, bool metered, ExceptionCode&);
167
168     void suspendAnimations(Document*, ExceptionCode&) const;
169     void resumeAnimations(Document*, ExceptionCode&) const;
170
171     void allowRoundingHacks() const;
172
173 #if ENABLE(INSPECTOR)
174     unsigned numberOfLiveNodes() const;
175     unsigned numberOfLiveDocuments() const;
176     Vector<String> consoleMessageArgumentCounts(Document*) const;
177 #endif
178
179 #if ENABLE(FULLSCREEN_API)
180     void webkitWillEnterFullScreenForElement(Document*, Element*);
181     void webkitDidEnterFullScreenForElement(Document*, Element*);
182     void webkitWillExitFullScreenForElement(Document*, Element*);
183     void webkitDidExitFullScreenForElement(Document*, Element*);
184 #endif
185
186 private:
187     explicit Internals(Document*);
188     DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
189     void resetDefaultsToConsistentValues();
190
191     RefPtr<InternalSettings> m_settings;
192 };
193
194 } // namespace WebCore
195
196 #endif