1/*
2 *  Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 *
4 *  This library is free software; you can redistribute it and/or
5 *  modify it under the terms of the GNU Lesser General Public
6 *  License as published by the Free Software Foundation; either
7 *  version 2 of the License, or (at your option) any later version.
8 *
9 *  This library is distributed in the hope that it will be useful,
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 *  Lesser General Public License for more details.
13 *
14 *  You should have received a copy of the GNU Lesser General Public
15 *  License along with this library; if not, write to the Free Software
16 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19#ifndef DumpRenderTreeSupportGtk_h
20#define DumpRenderTreeSupportGtk_h
21
22#include "JSStringRef.h"
23#include <atk/atk.h>
24#include <glib.h>
25#include <webkit/webkitdefines.h>
26#include <webkit/webkitdomdefines.h>
27#include <wtf/text/CString.h>
28
29namespace WebKit {
30
31enum {
32    WebFindOptionsCaseInsensitive = 1 << 0,
33    WebFindOptionsAtWordStarts = 1 << 1,
34    WebFindOptionsTreatMedialCapitalAsWordStart = 1 << 2,
35    WebFindOptionsBackwards = 1 << 3,
36    WebFindOptionsWrapAround = 1 << 4,
37    WebFindOptionsStartInSelection = 1 << 5
38};
39
40}
41typedef unsigned WebKitFindOptions;
42
43class DumpRenderTreeSupportGtk {
44
45public:
46    DumpRenderTreeSupportGtk();
47    ~DumpRenderTreeSupportGtk();
48
49    static void setDumpRenderTreeModeEnabled(bool);
50    static bool dumpRenderTreeModeEnabled();
51
52    static void setLinksIncludedInFocusChain(bool);
53    static bool linksIncludedInFocusChain();
54    static void setSelectTrailingWhitespaceEnabled(bool);
55    static bool selectTrailingWhitespaceEnabled();
56
57    static JSValueRef nodesFromRect(JSContextRef context, JSValueRef value, int x, int y, unsigned top, unsigned right, unsigned bottom, unsigned left, bool ignoreClipping);
58    static void dumpConfigurationForViewport(WebKitWebView* webView, gint deviceDPI, gint deviceWidth, gint deviceHeight, gint availableWidth, gint availableHeight);
59
60    static void clearOpener(WebKitWebFrame*);
61
62    static JSValueRef shadowRoot(JSContextRef, JSValueRef);
63    static WebKitDOMRange* jsValueToDOMRange(JSContextRef, JSValueRef);
64
65    // FIXME: Move these to webkitwebframe.h once their API has been discussed.
66    static GSList* getFrameChildren(WebKitWebFrame*);
67    static WTF::CString getInnerText(WebKitWebFrame*);
68    static WTF::CString dumpRenderTree(WebKitWebFrame*);
69    static WTF::CString counterValueForElementById(WebKitWebFrame*, const char* id);
70    static int pageNumberForElementById(WebKitWebFrame*, const char* id, float pageWidth, float pageHeight);
71    static int numberOfPagesForFrame(WebKitWebFrame*, float pageWidth, float pageHeight);
72    static WTF::CString pageProperty(WebKitWebFrame*, const char* propertyName, int pageNumber);
73    static bool isPageBoxVisible(WebKitWebFrame*, int pageNumber);
74    static WTF::CString pageSizeAndMarginsInPixels(WebKitWebFrame*, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
75    static void addUserStyleSheet(WebKitWebFrame*, const char* sourceCode, bool allFrames);
76    static guint getPendingUnloadEventCount(WebKitWebFrame*);
77    static bool pauseAnimation(WebKitWebFrame*, const char* name, double time, const char* element);
78    static bool pauseTransition(WebKitWebFrame*, const char* name, double time, const char* element);
79    static bool pauseSVGAnimation(WebKitWebFrame*, const char* animationId, double time, const char* elementId);
80    static WTF::CString markerTextForListItem(WebKitWebFrame*, JSContextRef, JSValueRef nodeObject);
81    static unsigned int numberOfActiveAnimations(WebKitWebFrame*);
82    static void suspendAnimations(WebKitWebFrame*);
83    static void resumeAnimations(WebKitWebFrame*);
84    static void clearMainFrameName(WebKitWebFrame*);
85    static AtkObject* getFocusedAccessibleElement(WebKitWebFrame*);
86    static AtkObject* getRootAccessibleElement(WebKitWebFrame*);
87    static void layoutFrame(WebKitWebFrame*);
88    static void setAutofilled(JSContextRef, JSValueRef, bool);
89    static void setValueForUser(JSContextRef, JSValueRef, JSStringRef);
90
91    // WebKitWebView
92    static void executeCoreCommandByName(WebKitWebView*, const gchar* name, const gchar* value);
93    static bool isCommandEnabled(WebKitWebView*, const gchar* name);
94    static bool findString(WebKitWebView*, const gchar*, WebKitFindOptions);
95    static void setComposition(WebKitWebView*, const char* text, int start, int end);
96    static void confirmComposition(WebKitWebView*, const char* text);
97    static bool firstRectForCharacterRange(WebKitWebView*, int location, int length, GdkRectangle*);
98    static bool selectedRange(WebKitWebView*, int* start, int* end);
99    static double defaultMinimumTimerInterval(); // Not really tied to WebView
100    static void setMinimumTimerInterval(WebKitWebView*, double);
101    static void rectangleForSelection(WebKitWebFrame*, GdkRectangle*);
102
103    // Accessibility
104    static void incrementAccessibilityValue(AtkObject*);
105    static void decrementAccessibilityValue(AtkObject*);
106
107    // GC
108    static void gcCollectJavascriptObjects();
109    static void gcCollectJavascriptObjectsOnAlternateThread(bool waitUntilDone);
110    static unsigned long gcCountJavascriptObjects();
111
112    static void whiteListAccessFromOrigin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains);
113    static void resetOriginAccessWhiteLists();
114    static unsigned int workerThreadCount();
115    static bool webkitWebFrameSelectionHasSpellingMarker(WebKitWebFrame*, gint from, gint length);
116
117private:
118    static bool s_drtRun;
119    static bool s_linksIncludedInTabChain;
120    static bool s_selectTrailingWhitespaceEnabled;
121};
122
123#endif
124