1/*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1.  Redistributions of source code must retain the above copyright
10 *     notice, this list of conditions and the following disclaimer.
11 * 2.  Redistributions in binary form must reproduce the above copyright
12 *     notice, this list of conditions and the following disclaimer in the
13 *     documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27[
28    NoInterfaceObject,
29] interface Internals {
30    DOMString address(Node node);
31
32    [RaisesException] DOMString elementRenderTreeAsText(Element element);
33    boolean isPreloaded(DOMString url);
34    boolean isLoadingFromMemoryCache(DOMString url);
35
36    [RaisesException] unsigned long numberOfScopedHTMLStyleChildren(Node scope);
37    [RaisesException] CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node);
38
39#if defined(ENABLE_SHADOW_DOM) && ENABLE_SHADOW_DOM
40    [RaisesException] ShadowRoot ensureShadowRoot(Element host);
41    [RaisesException] ShadowRoot createShadowRoot(Element host);
42    [RaisesException] ShadowRoot shadowRoot(Element host);
43#else
44    [RaisesException] Node ensureShadowRoot(Element host);
45    [RaisesException] Node createShadowRoot(Element host);
46    [RaisesException] Node shadowRoot(Element host);
47#endif
48    [RaisesException] DOMString shadowRootType(Node root);
49    [RaisesException] Element includerFor(Node node);
50    [RaisesException] DOMString shadowPseudoId(Element element);
51    [RaisesException] void setShadowPseudoId(Element element, DOMString id);
52    [RaisesException] Element createContentElement();
53    [RaisesException] boolean isValidContentSelect(Element contentElement);
54    [RaisesException] Node treeScopeRootNode(Node node);
55    [RaisesException] Node parentTreeScope(Node node);
56
57    // CSS Animation testing.
58    unsigned long numberOfActiveAnimations();
59    [RaisesException] void suspendAnimations(Document document);
60    [RaisesException] void resumeAnimations(Document document);
61    [RaisesException] boolean animationsAreSuspended(in Document document);
62    [RaisesException] boolean pauseAnimationAtTimeOnElement(DOMString animationName, double pauseTime, Element element);
63    [RaisesException] boolean pauseAnimationAtTimeOnPseudoElement(DOMString animationName, double pauseTime, Element element, DOMString pseudoId);
64
65    // CSS Transition testing.
66    [RaisesException] boolean pauseTransitionAtTimeOnElement(DOMString propertyName, double pauseTime, Element element);
67    [RaisesException] boolean pauseTransitionAtTimeOnPseudoElement(DOMString property, double pauseTime, Element element, DOMString pseudoId);
68
69    [RaisesException] Node nextSiblingByWalker(Node node);
70    [RaisesException] Node firstChildByWalker(Node node);
71    [RaisesException] Node lastChildByWalker(Node node);
72    [RaisesException] Node nextNodeByWalker(Node node);
73    [RaisesException] Node previousNodeByWalker(Node node);
74
75    [RaisesException] boolean attached(Node node);
76
77    DOMString visiblePlaceholder(Element element);
78#if defined(ENABLE_INPUT_TYPE_COLOR) && ENABLE_INPUT_TYPE_COLOR
79    void selectColorInColorChooser(Element element, DOMString colorValue);
80#endif
81    [RaisesException] DOMString[] formControlStateOfPreviousHistoryItem();
82    [RaisesException] void setFormControlStateOfPreviousHistoryItem(sequence<DOMString> values);
83
84    [RaisesException] ClientRect absoluteCaretBounds();
85
86    [RaisesException] ClientRect boundingBox(Element element);
87
88    [RaisesException] ClientRectList inspectorHighlightRects(Document document);
89
90    [RaisesException] unsigned long markerCountForNode(Node node, DOMString markerType);
91    [RaisesException] Range markerRangeForNode(Node node, DOMString markerType, unsigned long index);
92    [RaisesException] DOMString markerDescriptionForNode(Node node, DOMString markerType, unsigned long index);
93    void addTextMatchMarker(Range range, boolean isActive);
94
95    [RaisesException] void setScrollViewPosition(Document document, long x, long y);
96
97    [RaisesException] void setPagination(Document document, DOMString mode, long gap, optional long pageLength);
98
99    [RaisesException] DOMString configurationForViewport(Document document,
100                                       float devicePixelRatio,
101                                       long deviceWidth,
102                                       long deviceHeight,
103                                       long availableWidth,
104                                       long availableHeight);
105
106    [RaisesException] boolean wasLastChangeUserEdit(Element textField);
107    [RaisesException] boolean elementShouldAutoComplete(Element inputElement);
108    [RaisesException] DOMString suggestedValue(Element inputElement);
109    [RaisesException] void setSuggestedValue(Element inputElement, DOMString value);
110    [RaisesException] void setEditingValue(Element inputElement, DOMString value);
111    [RaisesException] void setAutofilled(Element inputElement, boolean enabled);
112
113    [RaisesException] void paintControlTints(Document document);
114
115    [RaisesException] void scrollElementToRect(Element element, long x, long y, long w, long h);
116
117    [RaisesException] Range rangeFromLocationAndLength(Element scope, long rangeLocation, long rangeLength);
118    [RaisesException] unsigned long locationFromRange(Element scope, Range range);
119    [RaisesException] unsigned long lengthFromRange(Element scope, Range range);
120    [RaisesException] DOMString rangeAsText(Range range);
121
122    [RaisesException] void setDelegatesScrolling(boolean enabled, Document document);
123#if defined(ENABLE_TOUCH_ADJUSTMENT) && ENABLE_TOUCH_ADJUSTMENT
124    [RaisesException] WebKitPoint touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document document);
125    [RaisesException] Node touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document document);
126    [RaisesException] WebKitPoint touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document document);
127    [RaisesException] Node touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document document);
128    [RaisesException] ClientRect bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document document);
129#endif
130
131    [RaisesException] long lastSpellCheckRequestSequence(Document document);
132    [RaisesException] long lastSpellCheckProcessedSequence(Document document);
133
134    sequence<DOMString> userPreferredLanguages();
135    void setUserPreferredLanguages(sequence<DOMString> languages);
136
137    [RaisesException] unsigned long wheelEventHandlerCount(Document document);
138    [RaisesException] unsigned long touchEventHandlerCount(Document document);
139#if defined(ENABLE_TOUCH_EVENT_TRACKING) && ENABLE_TOUCH_EVENT_TRACKING
140    [RaisesException] ClientRectList touchEventTargetClientRects(Document document);
141#endif
142
143    [RaisesException] NodeList nodesFromRect(Document document, long x, long y,
144        unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding,
145        boolean ignoreClipping, boolean allowShadowContent, boolean allowChildFrameContent);
146
147    void emitInspectorDidBeginFrame();
148    void emitInspectorDidCancelFrame();
149
150    [RaisesException] boolean hasSpellingMarker(Document document, long from, long length);
151    [RaisesException] boolean hasGrammarMarker(Document document, long from, long length);
152    [RaisesException] boolean hasAutocorrectedMarker(Document document, long from, long length);
153    [RaisesException] void setContinuousSpellCheckingEnabled(boolean enabled);
154    [RaisesException] void setAutomaticQuoteSubstitutionEnabled(boolean enabled);
155    [RaisesException] void setAutomaticLinkDetectionEnabled(boolean enabled);
156    [RaisesException] void setAutomaticDashSubstitutionEnabled(boolean enabled);
157    [RaisesException] void setAutomaticTextReplacementEnabled(boolean enabled);
158    [RaisesException] void setAutomaticSpellingCorrectionEnabled(boolean enabled);
159
160    [RaisesException] boolean isOverwriteModeEnabled(Document document);
161    [RaisesException] void toggleOverwriteModeEnabled(Document document);
162
163    [RaisesException] unsigned long numberOfScrollableAreas(Document document);
164
165    [RaisesException] boolean isPageBoxVisible(Document document, long pageNumber);
166
167    readonly attribute InternalSettings settings;
168    readonly attribute unsigned long workerThreadCount;
169
170    // Flags for layerTreeAsText.
171    const unsigned short LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1;
172    const unsigned short LAYER_TREE_INCLUDES_TILE_CACHES = 2;
173    const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 4;
174    const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 8;
175    [RaisesException] DOMString layerTreeAsText(Document document, optional unsigned short flags);
176
177    [RaisesException] DOMString scrollingStateTreeAsText(Document document);
178    [RaisesException] DOMString mainThreadScrollingReasons(Document document);
179    [RaisesException] ClientRectList nonFastScrollableRects(Document document);
180
181    [RaisesException] DOMString repaintRectsAsText(Document document);
182
183    [RaisesException] void garbageCollectDocumentResources(Document document);
184
185    void allowRoundingHacks();
186
187    void insertAuthorCSS(Document document, DOMString css);
188    void insertUserCSS(Document document, DOMString css);
189
190#if defined(ENABLE_BATTERY_STATUS) && ENABLE_BATTERY_STATUS
191    [RaisesException] void setBatteryStatus(Document document, DOMString eventType, boolean charging, double chargingTime, double dischargingTime, double level);
192#endif
193
194#if defined(ENABLE_NETWORK_INFO) && ENABLE_NETWORK_INFO
195    [RaisesException] void setNetworkInformation(Document document, DOMString eventType, double bandwidth, boolean metered);
196#endif
197
198#if defined(ENABLE_PROXIMITY_EVENTS) && ENABLE_PROXIMITY_EVENTS
199    [RaisesException] void setDeviceProximity(Document document, DOMString eventType, double value, double min, double max);
200#endif
201
202    [Conditional=INSPECTOR] unsigned long numberOfLiveNodes();
203    [Conditional=INSPECTOR] unsigned long numberOfLiveDocuments();
204    [Conditional=INSPECTOR] sequence<DOMString> consoleMessageArgumentCounts(Document document);
205    [Conditional=INSPECTOR] DOMWindow openDummyInspectorFrontend(DOMString url);
206    [Conditional=INSPECTOR] void closeDummyInspectorFrontend();
207    [Conditional=INSPECTOR, RaisesException] void setInspectorResourcesDataSizeLimits(long maximumResourcesContentSize, long maximumSingleResourceContentSize);
208    [Conditional=INSPECTOR, RaisesException] void setJavaScriptProfilingEnabled(boolean creates);
209
210    DOMString counterValue(Element element);
211    long pageNumber(Element element, optional float pageWidth, optional float pageHeight);
212    DOMString[] shortcutIconURLs(Document document);
213    DOMString[] allIconURLs(Document document);
214    long numberOfPages(optional double pageWidthInPixels, optional double pageHeightInPixels);
215    [RaisesException] DOMString pageProperty(DOMString propertyName, long pageNumber);
216    [RaisesException] DOMString pageSizeAndMarginsInPixels(long pageIndex, long width, long height, long marginTop, long marginRight, long marginBottom, long marginLeft);
217
218    [RaisesException] void setPageScaleFactor(float scaleFactor, long x, long y);
219
220    void setHeaderHeight(Document document, float height);
221    void setFooterHeight(Document document, float height);
222
223#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
224    void webkitWillEnterFullScreenForElement(Document document, Element element);
225    void webkitDidEnterFullScreenForElement(Document document, Element element);
226    void webkitWillExitFullScreenForElement(Document document, Element element);
227    void webkitDidExitFullScreenForElement(Document document, Element element);
228#endif
229
230    void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme);
231    void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(DOMString scheme);
232
233    MallocStatistics mallocStatistics();
234    TypeConversions typeConversions();
235    MemoryInfo memoryInfo();
236
237    DOMString[] getReferencedFilePaths();
238
239    // These functions both reset the tracked repaint rects. They are inteded to be used in the following order:
240    //  startTrackingRepaints, repaintRectsAsText, stopTrackingRepaints.
241    [RaisesException] void startTrackingRepaints(Document document);
242    [RaisesException] void stopTrackingRepaints(Document document);
243
244    // |node| should be Document, HTMLIFrameElement, or unspecified.
245    // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is
246    // specified without security checks. Unspecified means this document.
247    [RaisesException] void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(optional Node node);
248
249    // Returns a string with information about the mouse cursor used at the specified client location.
250    [RaisesException] DOMString getCurrentCursorInfo(Document document);
251
252    [RaisesException] DOMString markerTextForListItem(Element element);
253
254    SerializedScriptValue deserializeBuffer(ArrayBuffer buffer);
255    ArrayBuffer serializeObject(SerializedScriptValue obj);
256
257    void setUsesOverlayScrollbars(boolean enabled);
258
259    void forceReload(boolean endToEnd);
260
261    [Conditional=VIDEO] void simulateAudioInterruption(Node node);
262
263    [Conditional=ENCRYPTED_MEDIA_V2] void initializeMockCDM();
264
265    [Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer();
266
267    [RaisesException] DOMString getImageSourceURL(Element element);
268
269    [Conditional=VIDEO_TRACK, RaisesException] DOMString captionsStyleSheetOverride();
270    [Conditional=VIDEO_TRACK, RaisesException] void setCaptionsStyleSheetOverride(DOMString override);
271    [Conditional=VIDEO_TRACK, RaisesException] void setPrimaryAudioTrackLanguageOverride(DOMString language);
272    [Conditional=VIDEO_TRACK, RaisesException] void setCaptionDisplayMode(DOMString mode);
273
274    [Conditional=VIDEO] TimeRanges createTimeRanges(Float32Array startTimes, Float32Array
275     endTimes);
276    [Conditional=VIDEO] double closestTimeToTimeRanges(double time, TimeRanges ranges);
277
278    boolean isSelectPopupVisible(Node node);
279
280    [RaisesException] ClientRect selectionBounds();
281};
282