1 /* 2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 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 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15 * its contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 #ifndef JSOBJECTS_H 30 #define JSOBJECTS_H 31 32 #include <qobject.h> 33 #include <qdebug.h> 34 #include <qpoint.h> 35 #include <qstringlist.h> 36 #include <qsize.h> 37 #include <qbasictimer.h> 38 39 class QWebFrame; 40 namespace WebCore { 41 class DumpRenderTree; 42 } 43 class LayoutTestController : public QObject 44 { 45 Q_OBJECT 46 public: 47 LayoutTestController(WebCore::DumpRenderTree *drt); 48 isLoading()49 bool isLoading() const { return m_isLoading; } setLoading(bool loading)50 void setLoading(bool loading) { m_isLoading = loading; } 51 shouldDumpAsText()52 bool shouldDumpAsText() const { return m_textDump; } shouldDumpBackForwardList()53 bool shouldDumpBackForwardList() const { return m_dumpBackForwardList; } shouldDumpChildrenAsText()54 bool shouldDumpChildrenAsText() const { return m_dumpChildrenAsText; } shouldDumpDatabaseCallbacks()55 bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; } shouldWaitUntilDone()56 bool shouldWaitUntilDone() const { return m_waitForDone; } canOpenWindows()57 bool canOpenWindows() const { return m_canOpenWindows; } shouldDumpTitleChanges()58 bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; } 59 60 void reset(); 61 62 protected: 63 void timerEvent(QTimerEvent *); 64 65 signals: 66 void done(); 67 68 public slots: 69 void maybeDump(bool ok); dumpAsText()70 void dumpAsText() { m_textDump = true; } dumpChildFramesAsText()71 void dumpChildFramesAsText() { m_dumpChildrenAsText = true; } dumpDatabaseCallbacks()72 void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; } setCanOpenWindows()73 void setCanOpenWindows() { m_canOpenWindows = true; } 74 void waitUntilDone(); 75 void notifyDone(); dumpBackForwardList()76 void dumpBackForwardList() { m_dumpBackForwardList = true; } 77 void dumpEditingCallbacks(); 78 void dumpResourceLoadCallbacks(); 79 void queueBackNavigation(int howFarBackward); 80 void queueForwardNavigation(int howFarForward); 81 void queueLoad(const QString &url, const QString &target = QString()); 82 void queueReload(); 83 void queueScript(const QString &url); 84 void provisionalLoad(); 85 void setCloseRemainingWindowsWhenComplete(bool=false) {} 86 int windowCount(); display()87 void display() {} 88 void clearBackForwardList(); dumpTitleChanges()89 void dumpTitleChanges() { m_dumpTitleChanges = true; } 90 QString encodeHostName(const QString &host); 91 QString decodeHostName(const QString &host); dumpSelectionRect()92 void dumpSelectionRect() const {} 93 void setJavaScriptProfilingEnabled(bool enable); 94 void setFixedContentsSize(int width, int height); 95 void setPrivateBrowsingEnabled(bool enable); 96 97 bool pauseAnimationAtTimeOnElementWithId(const QString &animationName, double time, const QString &elementId); 98 bool pauseTransitionAtTimeOnElementWithId(const QString &propertyName, double time, const QString &elementId); 99 unsigned numberOfActiveAnimations() const; 100 void dispatchPendingLoadRequests(); 101 void disableImageLoading(); 102 103 void setDatabaseQuota(int size); 104 void clearAllDatabases(); 105 106 private slots: 107 void processWork(); 108 109 private: 110 bool m_isLoading; 111 bool m_textDump; 112 bool m_dumpBackForwardList; 113 bool m_dumpChildrenAsText; 114 bool m_canOpenWindows; 115 bool m_waitForDone; 116 bool m_dumpTitleChanges; 117 bool m_dumpDatabaseCallbacks; 118 QBasicTimer m_timeoutTimer; 119 QWebFrame *m_topLoadingFrame; 120 WebCore::DumpRenderTree *m_drt; 121 }; 122 123 class QWebPage; 124 class QWebFrame; 125 126 class EventSender : public QObject 127 { 128 Q_OBJECT 129 public: 130 EventSender(QWebPage *parent); 131 132 public slots: 133 void mouseDown(); 134 void mouseUp(); 135 void mouseMoveTo(int x, int y); 136 void leapForward(int ms); 137 void keyDown(const QString &string, const QStringList &modifiers=QStringList()); clearKillRing()138 void clearKillRing() {} 139 140 private: 141 QPoint m_mousePos; 142 QWebPage *m_page; 143 int m_timeLeap; 144 QWebFrame *frameUnderMouse() const; 145 }; 146 147 class TextInputController : public QObject 148 { 149 Q_OBJECT 150 public: 151 TextInputController(QWebPage *parent); 152 153 public slots: 154 void doCommand(const QString &command); 155 // void setMarkedText(const QString &str, int from, int length); 156 // bool hasMarkedText(); 157 // void unmarkText(); 158 // QList<int> markedRange(); 159 // QList<int> selectedRange(); 160 // void validAttributesForMarkedText(); 161 // void inserText(const QString &); 162 // void firstRectForCharacterRange(); 163 // void characterIndexForPoint(int, int); 164 // void substringFromRange(int, int); 165 // void conversationIdentifier(); 166 }; 167 168 class GCController : public QObject 169 { 170 Q_OBJECT 171 public: 172 GCController(QWebPage* parent); 173 174 public slots: 175 void collect() const; 176 void collectOnAlternateThread(bool waitUntilDone) const; 177 size_t getJSObjectCount() const; 178 }; 179 180 #endif 181