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    DoNotCheckConstants,
29    WillBeGarbageCollected,
30] interface Internals {
31    DOMString address(Node node);
32
33    GCObservation observeGC(any observed);
34
35    [RaisesException] DOMString elementRenderTreeAsText(Element element);
36    boolean isPreloaded(DOMString url);
37    boolean isLoadingFromMemoryCache(DOMString url);
38
39    void crash();
40
41    void setStyleResolverStatsEnabled(boolean enabled);
42    [RaisesException] DOMString styleResolverStatsReport();
43    [RaisesException] DOMString styleResolverStatsTotalsReport();
44
45    [RaisesException] boolean isSharingStyle(Element element1, Element element2);
46
47    [RaisesException] CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node);
48
49    [RaisesException] ShadowRoot shadowRoot(Element host);
50    [RaisesException] ShadowRoot youngestShadowRoot(Element host);
51    [RaisesException] ShadowRoot oldestShadowRoot(Element host);
52    [RaisesException] ShadowRoot youngerShadowRoot(Node root);
53
54    [RaisesException] DOMString shadowRootType(Node root);
55    [RaisesException] boolean hasShadowInsertionPoint(Node root);
56    [RaisesException] boolean hasContentElement(Node root);
57    [RaisesException] unsigned long countElementShadow(Node Root);
58    [RaisesException] DOMString shadowPseudoId(Element element);
59    [RaisesException] void setShadowPseudoId(Element element, DOMString id);
60    [RaisesException] boolean isValidContentSelect(Element contentElement);
61    [RaisesException] Node treeScopeRootNode(Node node);
62    [RaisesException] Node parentTreeScope(Node node);
63    [RaisesException] boolean hasSelectorForIdInShadow(Element host, DOMString id);
64    [RaisesException] boolean hasSelectorForClassInShadow(Element host, DOMString className);
65    [RaisesException] boolean hasSelectorForAttributeInShadow(Element host, DOMString attributeName);
66    [RaisesException] boolean hasSelectorForPseudoClassInShadow(Element host, DOMString pseudoClass);
67    [RaisesException] unsigned short compareTreeScopePosition(Node treeScope1, Node treeScope2);
68    [RaisesException] unsigned long updateStyleAndReturnAffectedElementCount();
69    [RaisesException] unsigned long needsLayoutCount();
70
71    // CSS Animation and Transition testing.
72    unsigned long numberOfActiveAnimations();
73    [RaisesException] void pauseAnimations(double pauseTime);
74
75    [RaisesException] Node nextSiblingByWalker(Node node);
76    [RaisesException] Node firstChildByWalker(Node node);
77    [RaisesException] Node lastChildByWalker(Node node);
78    [RaisesException] Node nextNodeByWalker(Node node);
79    [RaisesException] Node previousNodeByWalker(Node node);
80
81    DOMString visiblePlaceholder(Element element);
82
83    void selectColorInColorChooser(Element element, DOMString colorValue);
84
85    // If the argument is omitted, the top-level document is used.
86    boolean hasAutofocusRequest(optional Document document);
87    [RaisesException] DOMString[] formControlStateOfHistoryItem();
88    [RaisesException] void setFormControlStateOfHistoryItem(sequence<DOMString> values);
89    [RaisesException] void setEnableMockPagePopup(boolean enabled);
90    readonly attribute PagePopupController pagePopupController;
91
92    [RaisesException] ClientRect unscaledViewportRect();
93
94    [RaisesException] ClientRect absoluteCaretBounds();
95
96    [RaisesException] ClientRect boundingBox(Element element);
97
98    [RaisesException] unsigned long markerCountForNode(Node node, DOMString markerType);
99    [RaisesException] unsigned long activeMarkerCountForNode(Node node);
100    [RaisesException] Range markerRangeForNode(Node node, DOMString markerType, unsigned long index);
101    [RaisesException] DOMString markerDescriptionForNode(Node node, DOMString markerType, unsigned long index);
102    void addTextMatchMarker(Range range, boolean isActive);
103    [RaisesException] void setMarkersActive(Node node, unsigned long startOffset, unsigned long endOffset, boolean active);
104    [RaisesException] void setMarkedTextMatchesAreHighlighted(Document document, boolean highlight);
105
106    [RaisesException] void setScrollViewPosition(Document document, long x, long y);
107
108    [RaisesException] DOMString viewportAsText(Document document,
109                                               float devicePixelRatio,
110                                               long availableWidth,
111                                               long availableHeight);
112
113    [RaisesException] boolean wasLastChangeUserEdit(Element textField);
114    [RaisesException] boolean elementShouldAutoComplete(Element inputElement);
115    [RaisesException] DOMString suggestedValue(Element inputElement);
116    [RaisesException] void setSuggestedValue(Element inputElement, DOMString value);
117    [RaisesException] void setEditingValue(Element inputElement, DOMString value);
118    [RaisesException] void setAutofilled(Element inputElement, boolean enabled);
119
120    [RaisesException] void scrollElementToRect(Element element, long x, long y, long w, long h);
121
122    [RaisesException] Range rangeFromLocationAndLength(Element scope, long rangeLocation, long rangeLength);
123    [RaisesException] unsigned long locationFromRange(Element scope, Range range);
124    [RaisesException] unsigned long lengthFromRange(Element scope, Range range);
125    [RaisesException] DOMString rangeAsText(Range range);
126
127    [RaisesException] WebKitPoint touchPositionAdjustedToBestClickableNode(long x, long y, long width, long height, Document document);
128    [RaisesException] Node touchNodeAdjustedToBestClickableNode(long x, long y, long width, long height, Document document);
129    [RaisesException] WebKitPoint touchPositionAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document document);
130    [RaisesException] Node touchNodeAdjustedToBestContextMenuNode(long x, long y, long width, long height, Document document);
131    [RaisesException] ClientRect bestZoomableAreaForTouchPoint(long x, long y, long width, long height, Document document);
132
133    [RaisesException] long lastSpellCheckRequestSequence(Document document);
134    [RaisesException] long lastSpellCheckProcessedSequence(Document document);
135
136    sequence<DOMString> userPreferredLanguages();
137    void setUserPreferredLanguages(sequence<DOMString> languages);
138
139    [RaisesException] unsigned long activeDOMObjectCount(Document document);
140    [RaisesException] unsigned long wheelEventHandlerCount(Document document);
141    [RaisesException] unsigned long scrollEventHandlerCount(Document document);
142    [RaisesException] unsigned long touchEventHandlerCount(Document document);
143    [RaisesException] LayerRectList touchEventTargetLayerRects(Document document);
144
145
146    [RaisesException] NodeList nodesFromRect(Document document, long x, long y,
147        unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding,
148        boolean ignoreClipping, boolean allowShadowContent, boolean allowChildFrameContent);
149
150    void emitInspectorDidBeginFrame(optional long frameId);
151    void emitInspectorDidCancelFrame();
152
153    [RaisesException] boolean hasSpellingMarker(Document document, long from, long length);
154    [RaisesException] boolean hasGrammarMarker(Document document, long from, long length);
155    [RaisesException] void setContinuousSpellCheckingEnabled(boolean enabled);
156
157    [RaisesException] boolean isOverwriteModeEnabled(Document document);
158    [RaisesException] void toggleOverwriteModeEnabled(Document document);
159
160    [RaisesException] unsigned long numberOfScrollableAreas(Document document);
161
162    [RaisesException] boolean isPageBoxVisible(Document document, long pageNumber);
163
164    readonly attribute InternalSettings settings;
165    readonly attribute InternalProfilers profilers;
166    readonly attribute InternalRuntimeFlags runtimeFlags;
167    readonly attribute unsigned long workerThreadCount;
168
169    // Flags for layerTreeAsText.
170    // The values of these constants must be kept in sync with the values of LayerTreeAsTextBehaviorFlags in GraphicsLayerClient.h.
171    const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 2;
172    const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 4;
173    const unsigned short LAYER_TREE_INCLUDES_ROOT_LAYER = 8;
174    const unsigned short LAYER_TREE_INCLUDES_CLIP_AND_SCROLL_PARENTS = 16;
175    [RaisesException] DOMString layerTreeAsText(Document document, optional unsigned short flags);
176    [RaisesException] DOMString elementLayerTreeAsText(Element element, optional unsigned short flags);
177
178    [RaisesException] boolean scrollsWithRespectTo(Element element1, Element element2);
179    [RaisesException] boolean isUnclippedDescendant(Element element);
180
181    [RaisesException] DOMString scrollingStateTreeAsText(Document document);
182    [RaisesException] DOMString mainThreadScrollingReasons(Document document);
183    [RaisesException] ClientRectList nonFastScrollableRects(Document document);
184
185    [RaisesException] DOMString repaintRectsAsText(Document document);
186    [RaisesException] ClientRectList repaintRects(Element element);
187
188    [RaisesException] void garbageCollectDocumentResources(Document document);
189    void evictAllResources();
190
191    void allowRoundingHacks();
192
193    unsigned long numberOfLiveNodes();
194    unsigned long numberOfLiveDocuments();
195    DOMString dumpRefCountedInstanceCounts();
196    sequence<DOMString> consoleMessageArgumentCounts(Document document);
197    unsigned long[] setMemoryCacheCapacities(unsigned long minDeadBytes, unsigned long maxDeadBytes, unsigned long totalBytes);
198    [RaisesException] void setInspectorResourcesDataSizeLimits(long maximumResourcesContentSize, long maximumSingleResourceContentSize);
199
200    DOMString counterValue(Element element);
201    long pageNumber(Element element, optional float pageWidth, optional float pageHeight);
202    DOMString[] shortcutIconURLs(Document document);
203    DOMString[] allIconURLs(Document document);
204    long numberOfPages(optional double pageWidthInPixels, optional double pageHeightInPixels);
205    [RaisesException] DOMString pageProperty(DOMString propertyName, long pageNumber);
206    [RaisesException] DOMString pageSizeAndMarginsInPixels(long pageIndex, long width, long height, long marginTop, long marginRight, long marginBottom, long marginLeft);
207
208    [RaisesException] void setDeviceScaleFactor(float scaleFactor);
209
210    [RaisesException] void setIsCursorVisible(Document document, boolean isVisible);
211
212    void webkitWillEnterFullScreenForElement(Document document, Element element);
213    void webkitDidEnterFullScreenForElement(Document document, Element element);
214    void webkitWillExitFullScreenForElement(Document document, Element element);
215    void webkitDidExitFullScreenForElement(Document document, Element element);
216
217    void mediaPlayerRequestFullscreen(HTMLMediaElement mediaElement);
218
219    void registerURLSchemeAsBypassingContentSecurityPolicy(DOMString scheme);
220    void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(DOMString scheme);
221
222    MallocStatistics mallocStatistics();
223    TypeConversions typeConversions();
224
225    DOMString[] getReferencedFilePaths();
226
227    // These functions both reset the tracked repaint rects. They are inteded to be used in the following order:
228    //  startTrackingRepaints, repaintRectsAsText, stopTrackingRepaints.
229    [RaisesException] void startTrackingRepaints(Document document);
230    [RaisesException] void stopTrackingRepaints(Document document);
231
232    // |node| should be Document, HTMLIFrameElement, or unspecified.
233    // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is
234    // specified without security checks. Unspecified means this document.
235    [RaisesException] void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(optional Node node);
236
237    [RaisesException] void forceFullRepaint(Document document);
238
239    // Returns a list of draggable/non-draggable regions in the document.
240    [RaisesException] ClientRectList draggableRegions(Document document);
241    [RaisesException] ClientRectList nonDraggableRegions(Document document);
242
243    // Returns a string with information about the mouse cursor used at the specified client location.
244    [RaisesException] DOMString getCurrentCursorInfo(Document document);
245
246    [RaisesException] DOMString markerTextForListItem(Element element);
247
248    [RaisesException] DOMString baseURL(Document document);
249
250    SerializedScriptValue deserializeBuffer(ArrayBuffer buffer);
251    ArrayBuffer serializeObject(SerializedScriptValue obj);
252
253    void forceReload(boolean endToEnd);
254
255    [RaisesException] DOMString getImageSourceURL(Element element);
256
257    boolean isSelectPopupVisible(Node node);
258
259    [RaisesException] ClientRect selectionBounds();
260
261    boolean loseSharedGraphicsContext3D();
262
263    [RaisesException] void forceCompositingUpdate(Document document);
264
265    void setZoomFactor(float factor);
266
267    [RaisesException] void setShouldRevealPassword(Element element, boolean reveal);
268
269    [CallWith=ScriptState] Promise createPromise();
270    [CallWith=ScriptState] Promise createResolvedPromise(any value);
271    [CallWith=ScriptState] Promise createRejectedPromise(any reason);
272    [CallWith=ExecutionContext] Promise addOneToPromise(Promise promise);
273
274    void setValueForUser(Element element, DOMString value);
275
276    DOMString textSurroundingNode(Node node, long x, long y, unsigned long maxLength);
277
278    void setFocused(boolean focused);
279
280    [RaisesException] boolean ignoreLayoutWithPendingStylesheets(Document document);
281
282    // These functions are for testing NetInfo. You must call setNetworkStateNotifierTestOnly(true)
283    // before calling setNetworkConnectionInfo.
284    void setNetworkStateNotifierTestOnly(boolean testOnly);
285    [RaisesException] void setNetworkConnectionInfo(DOMString type);
286};
287