Changeset 145719 in webkit
- Timestamp:
- Mar 13, 2013 8:24:17 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/qt/ChangeLog
r145717 r145719 1 2013-03-13 Simon Hausmann <simon.hausmann@digia.com> 2 3 [Qt] Port TestRunner::findString to shared interface 4 https://bugs.webkit.org/show_bug.cgi?id=112147 5 6 Reviewed by Jocelyn Turcotte. 7 8 Add new find options used by the DRT. 9 10 * WebCoreSupport/DumpRenderTreeSupportQt.cpp: 11 * WebCoreSupport/DumpRenderTreeSupportQt.h: 12 * WebCoreSupport/QWebPageAdapter.cpp: 13 (QWebPageAdapter::findText): 14 * WebCoreSupport/QWebPageAdapter.h: 15 * WidgetApi/qwebpage.cpp: 16 * WidgetApi/qwebpage.h: 17 1 18 2013-03-13 Pavel Feldman <pfeldman@chromium.org> 2 19 -
trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
r145012 r145719 349 349 } 350 350 351 bool DumpRenderTreeSupportQt::findString(QWebPageAdapter *adapter, const QString& string, const QStringList& optionArray)352 {353 // 1. Parse the options from the array354 WebCore::FindOptions options = 0;355 const int optionCount = optionArray.size();356 for (int i = 0; i < optionCount; ++i) {357 const QString& option = optionArray.at(i);358 if (option == QLatin1String("CaseInsensitive"))359 options |= WebCore::CaseInsensitive;360 else if (option == QLatin1String("AtWordStarts"))361 options |= WebCore::AtWordStarts;362 else if (option == QLatin1String("TreatMedialCapitalAsWordStart"))363 options |= WebCore::TreatMedialCapitalAsWordStart;364 else if (option == QLatin1String("Backwards"))365 options |= WebCore::Backwards;366 else if (option == QLatin1String("WrapAround"))367 options |= WebCore::WrapAround;368 else if (option == QLatin1String("StartInSelection"))369 options |= WebCore::StartInSelection;370 }371 372 // 2. find the string373 WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame();374 return frame && frame->editor()->findString(string, options);375 }376 377 351 QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPageAdapter *adapter) 378 352 { -
trunk/Source/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.h
r145012 r145719 94 94 static void executeCoreCommandByName(QWebPageAdapter*, const QString& name, const QString& value); 95 95 static bool isCommandEnabled(QWebPageAdapter*, const QString& name); 96 static bool findString(QWebPageAdapter*, const QString&, const QStringList& optionArray);97 96 static void setSmartInsertDeleteEnabled(QWebPageAdapter*, bool enabled); 98 97 static void setSelectTrailingWhitespaceEnabled(QWebPageAdapter*, bool enabled); -
trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
r144568 r145719 315 315 bool QWebPageAdapter::findText(const QString& subString, FindFlag options) 316 316 { 317 ::TextCaseSensitivity caseSensitivity = ::TextCaseInsensitive; 318 if (options & FindCaseSensitively) 319 caseSensitivity = ::TextCaseSensitive; 317 ::WebCore::FindOptions webCoreFindOptions = 0; 318 319 if (!(options & FindCaseSensitively)) 320 webCoreFindOptions |= WebCore::CaseInsensitive; 321 322 if (options & FindBackward) 323 webCoreFindOptions |= WebCore::Backwards; 324 325 if (options & FindWrapsAroundDocument) 326 webCoreFindOptions |= WebCore::WrapAround; 327 328 if (options & FindAtWordBeginningsOnly) 329 webCoreFindOptions |= WebCore::AtWordStarts; 330 331 if (options & TreatMedialCapitalAsWordBeginning) 332 webCoreFindOptions |= WebCore::TreatMedialCapitalAsWordStart; 333 334 if (options & FindBeginsInSelection) 335 webCoreFindOptions |= WebCore::StartInSelection; 320 336 321 337 if (options & HighlightAllOccurrences) { … … 324 340 return true; 325 341 } 326 return page->markAllMatchesForText(subString, caseSensitivity, true,0);342 return page->markAllMatchesForText(subString, webCoreFindOptions, /*shouldHighlight*/ true, /*limit*/ 0); 327 343 } 328 344 … … 335 351 } 336 352 } 337 ::FindDirection direction = ::FindDirectionForward; 338 if (options & FindBackward) 339 direction = ::FindDirectionBackward; 340 341 const bool shouldWrap = options & FindWrapsAroundDocument; 342 343 return page->findString(subString, caseSensitivity, direction, shouldWrap); 353 354 return page->findString(subString, webCoreFindOptions); 344 355 } 345 356 -
trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h
r143588 r145719 112 112 FindCaseSensitively = 2, 113 113 FindWrapsAroundDocument = 4, 114 HighlightAllOccurrences = 8 114 HighlightAllOccurrences = 8, 115 FindAtWordBeginningsOnly = 16, 116 TreatMedialCapitalAsWordBeginning = 32, 117 FindBeginsInSelection = 64 115 118 }; 116 119 -
trunk/Source/WebKit/qt/WidgetApi/qwebpage.cpp
r141233 r145719 1052 1052 \value HighlightAllOccurrences Highlights all existing occurrences of a specific string. 1053 1053 (This value was introduced in 4.6.) 1054 \value FindAtWordBeginningsOnly Searches for the sub-string only at the beginnings of words. 1055 (This value was introduced in 5.2.) 1056 \value TreatMedialCapitalAsWordBeginning Treats a capital letter occurring anywhere in the middle of a word 1057 as the beginning of a new word. 1058 (This value was introduced in 5.2.) 1059 \value FindBeginsInSelection Begin searching inside the text selection first. 1060 (This value was introduced in 5.2.) 1054 1061 */ 1055 1062 -
trunk/Source/WebKit/qt/WidgetApi/qwebpage.h
r136394 r145719 188 188 FindCaseSensitively = 2, 189 189 FindWrapsAroundDocument = 4, 190 HighlightAllOccurrences = 8 190 HighlightAllOccurrences = 8, 191 FindAtWordBeginningsOnly = 16, 192 TreatMedialCapitalAsWordBeginning = 32, 193 FindBeginsInSelection = 64 191 194 }; 192 195 Q_DECLARE_FLAGS(FindFlags, FindFlag) -
trunk/Tools/ChangeLog
r145714 r145719 1 2013-03-13 Simon Hausmann <simon.hausmann@digia.com> 2 3 [Qt] Port TestRunner::findString to shared interface 4 https://bugs.webkit.org/show_bug.cgi?id=112147 5 6 Reviewed by Jocelyn Turcotte. 7 8 This patch also removes DumpRenderTree and some other helper classes from 9 the WebCore namespace, to which they do not really belong. 10 11 * DumpRenderTree/qt/DumpRenderTreeMain.cpp: 12 (main): 13 * DumpRenderTree/qt/DumpRenderTreeQt.cpp: 14 (DumpRenderTree::DumpRenderTree): 15 (DumpRenderTree::~DumpRenderTree): 16 (DumpRenderTree::instance): 17 (DumpRenderTree::setShouldTimeout): 18 * DumpRenderTree/qt/DumpRenderTreeQt.h: 19 (DumpRenderTree): 20 * DumpRenderTree/qt/EventSenderQt.cpp: 21 (EventSender::contextClick): 22 (EventSender::sendEvent): 23 (EventSender::postEvent): 24 * DumpRenderTree/qt/EventSenderQt.h: 25 (EventSender::isGraphicsBased): 26 * DumpRenderTree/qt/TestRunnerQt.cpp: 27 (TestRunnerQt::TestRunnerQt): 28 (TestRunner::findString): 29 (TestRunnerQt::setMockDeviceOrientation): 30 (TestRunnerQt::setGeolocationPermission): 31 (TestRunnerQt::numberOfPendingGeolocationPermissionRequests): 32 (TestRunnerQt::setMockGeolocationPositionUnavailableError): 33 (TestRunnerQt::setMockGeolocationPosition): 34 * DumpRenderTree/qt/TestRunnerQt.h: 35 (TestRunnerQt): 36 1 37 2013-03-13 Mikhail Naganov <mnaganov@chromium.org> 2 38 -
trunk/Tools/DumpRenderTree/qt/DumpRenderTreeMain.cpp
r145708 r145719 136 136 args.removeAt(0); 137 137 138 WebCore::DumpRenderTree dumper;138 DumpRenderTree dumper; 139 139 140 140 int index = args.indexOf(QLatin1String("--stdout")); -
trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
r145708 r145719 75 75 #endif 76 76 77 namespace WebCore { 77 using namespace WebCore; 78 78 79 79 const int databaseDefaultQuota = 5 * 1024 * 1024; … … 386 386 } 387 387 388 static DumpRenderTree *s_instance = 0; 389 388 390 DumpRenderTree::DumpRenderTree() 389 391 : m_dumpPixelsForAllTests(false) … … 394 396 , m_persistentStoragePath(QString(getenv("DUMPRENDERTREE_TEMP"))) 395 397 { 398 ASSERT(!s_instance); 399 s_instance = this; 400 396 401 QByteArray viewMode = getenv("QT_DRT_WEBVIEW_MODE"); 397 402 if (viewMode == "graphics") … … 486 491 delete m_mainView; 487 492 delete m_stdin; 493 s_instance = 0; 494 } 495 496 DumpRenderTree* DumpRenderTree::instance() 497 { 498 return s_instance; 488 499 } 489 500 … … 1218 1229 m_controller->setShouldTimeout(flag); 1219 1230 } 1220 1221 } -
trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h
r145708 r145719 65 65 class GCController; 66 66 67 namespace WebCore {68 69 67 class WebPage; 70 68 class NetworkAccessManager; … … 76 74 DumpRenderTree(); 77 75 virtual ~DumpRenderTree(); 76 77 static DumpRenderTree* instance(); 78 78 79 79 // Initialize in single-file mode. … … 239 239 }; 240 240 241 }242 243 241 #endif -
trunk/Tools/DumpRenderTree/qt/EventSenderQt.cpp
r135515 r145719 425 425 ctxEvent.setReason(QGraphicsSceneContextMenuEvent::Mouse); 426 426 ctxEvent.setPos(m_mousePos); 427 Web Core::WebViewGraphicsBased* view = qobject_cast<WebCore::WebViewGraphicsBased*>(m_page->view());427 WebViewGraphicsBased* view = qobject_cast<WebViewGraphicsBased*>(m_page->view()); 428 428 if (view) 429 429 sendEvent(view->graphicsView(), &ctxEvent); … … 746 746 void EventSender::sendEvent(QObject* receiver, QEvent* event) 747 747 { 748 if (Web Core::WebViewGraphicsBased* view = qobject_cast<WebCore::WebViewGraphicsBased*>(receiver))748 if (WebViewGraphicsBased* view = qobject_cast<WebViewGraphicsBased*>(receiver)) 749 749 view->scene()->sendEvent(view->graphicsView(), event); 750 750 else … … 756 756 // QGraphicsScene does not have a postEvent method, so send the event in this case 757 757 // and delete it after that. 758 if (Web Core::WebViewGraphicsBased* view = qobject_cast<WebCore::WebViewGraphicsBased*>(receiver)) {758 if (WebViewGraphicsBased* view = qobject_cast<WebViewGraphicsBased*>(receiver)) { 759 759 view->scene()->sendEvent(view->graphicsView(), event); 760 760 delete event; -
trunk/Tools/DumpRenderTree/qt/EventSenderQt.h
r132052 r145719 97 97 98 98 private: 99 bool isGraphicsBased() const { return qobject_cast<Web Core::WebViewGraphicsBased*>(m_page->view()); }99 bool isGraphicsBased() const { return qobject_cast<WebViewGraphicsBased*>(m_page->view()); } 100 100 QGraphicsSceneMouseEvent* createGraphicsSceneMouseEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, Qt::MouseButton, Qt::MouseButtons, Qt::KeyboardModifiers); 101 101 QGraphicsSceneWheelEvent* createGraphicsSceneWheelEvent(QEvent::Type, const QPoint& pos, const QPoint& screenPos, int delta, Qt::KeyboardModifiers, Qt::Orientation); -
trunk/Tools/DumpRenderTree/qt/TestRunnerQt.cpp
r145708 r145719 35 35 #include "WorkQueue.h" 36 36 #include "WorkQueueItemQt.h" 37 #include <JSStringRefQt.h> 37 38 #include <QCoreApplication> 38 39 #include <QDir> … … 40 41 #include <qwebsettings.h> 41 42 42 TestRunnerQt::TestRunnerQt( WebCore::DumpRenderTree* drt)43 TestRunnerQt::TestRunnerQt(DumpRenderTree* drt) 43 44 : QObject() 44 45 , m_drt(drt) … … 745 746 } 746 747 747 bool TestRunnerQt::findString(const QString& string, const QStringList& optionArray) 748 { 749 return DumpRenderTreeSupportQt::findString(m_drt->pageAdapter(), string, optionArray); 748 bool TestRunner::findString(JSContextRef context, JSStringRef string, JSObjectRef optionsArray) 749 { 750 JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length")); 751 JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0); 752 if (!JSValueIsNumber(context, lengthValue)) 753 return false; 754 755 QWebPage::FindFlags findFlags = QWebPage::FindCaseSensitively; 756 757 int length = static_cast<int>(JSValueToNumber(context, lengthValue, 0)); 758 for (int i = 0; i < length; ++i) { 759 JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0); 760 if (!JSValueIsString(context, value)) 761 continue; 762 763 JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0)); 764 if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive")) 765 findFlags &= ~QWebPage::FindCaseSensitively; 766 else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts")) 767 findFlags |= QWebPage::FindAtWordBeginningsOnly; 768 else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart")) 769 findFlags |= QWebPage::TreatMedialCapitalAsWordBeginning; 770 else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards")) 771 findFlags |= QWebPage::FindBackward; 772 else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround")) 773 findFlags |= QWebPage::FindWrapsAroundDocument; 774 else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection")) 775 findFlags |= QWebPage::FindBeginsInSelection; 776 } 777 778 DumpRenderTree* drt = DumpRenderTree::instance(); 779 return drt->webPage()->findText(JSStringCopyQString(string), findFlags); 750 780 } 751 781 … … 765 795 void TestRunnerQt::setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) 766 796 { 767 QList<Web Core::WebPage*> pages = m_drt->getAllPages();768 foreach (Web Core::WebPage* page, pages)797 QList<WebPage*> pages = m_drt->getAllPages(); 798 foreach (WebPage* page, pages) 769 799 DumpRenderTreeSupportQt::setMockDeviceOrientation(page->handle(), canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma); 770 800 } … … 773 803 { 774 804 setGeolocationPermissionCommon(allow); 775 QList<Web Core::WebPage*> pages = m_drt->getAllPages();776 foreach (Web Core::WebPage* page, pages)805 QList<WebPage*> pages = m_drt->getAllPages(); 806 foreach (WebPage* page, pages) 777 807 DumpRenderTreeSupportQt::setMockGeolocationPermission(page->handle(), allow); 778 808 } … … 781 811 { 782 812 int pendingPermissionCount = 0; 783 QList<Web Core::WebPage*> pages = m_drt->getAllPages();784 foreach (Web Core::WebPage* page, pages)813 QList<WebPage*> pages = m_drt->getAllPages(); 814 foreach (WebPage* page, pages) 785 815 pendingPermissionCount += DumpRenderTreeSupportQt::numberOfPendingGeolocationPermissionRequests(page->handle()); 786 816 … … 796 826 void TestRunnerQt::setMockGeolocationPositionUnavailableError(const QString& message) 797 827 { 798 QList<Web Core::WebPage*> pages = m_drt->getAllPages();799 foreach (Web Core::WebPage* page, pages)828 QList<WebPage*> pages = m_drt->getAllPages(); 829 foreach (WebPage* page, pages) 800 830 DumpRenderTreeSupportQt::setMockGeolocationPositionUnavailableError(page->handle(), message); 801 831 } … … 803 833 void TestRunnerQt::setMockGeolocationPosition(double latitude, double longitude, double accuracy) 804 834 { 805 QList<Web Core::WebPage*> pages = m_drt->getAllPages();806 foreach (Web Core::WebPage* page, pages)835 QList<WebPage*> pages = m_drt->getAllPages(); 836 foreach (WebPage* page, pages) 807 837 DumpRenderTreeSupportQt::setMockGeolocationPosition(page->handle(), latitude, longitude, accuracy); 808 838 } … … 1341 1371 } 1342 1372 1343 bool TestRunner::findString(JSContextRef, JSStringRef, JSObjectRef optionsArray)1344 {1345 return false;1346 }1347 1348 1373 void TestRunner::execCommand(JSStringRef name, JSStringRef value) 1349 1374 { -
trunk/Tools/DumpRenderTree/qt/TestRunnerQt.h
r145012 r145719 50 50 class QWebFrame; 51 51 class DumpRenderTreeSupportQt; 52 namespace WebCore {53 52 class DumpRenderTree; 54 }55 53 56 54 class TestRunnerQt : public QObject { … … 59 57 Q_PROPERTY(bool globalFlag READ globalFlag WRITE setGlobalFlag) 60 58 public: 61 TestRunnerQt( WebCore::DumpRenderTree*);59 TestRunnerQt(DumpRenderTree*); 62 60 63 61 bool shouldDisallowIncreaseForApplicationCacheQuota() const { return m_disallowIncreaseForApplicationCacheQuota; } … … 183 181 void execCommand(const QString& name, const QString& value = QString()); 184 182 bool isCommandEnabled(const QString& name) const; 185 bool findString(const QString&, const QStringList& optionArray);186 183 187 184 void addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains); … … 300 297 QBasicTimer m_timeoutTimer; 301 298 QWebFrame* m_topLoadingFrame; 302 WebCore::DumpRenderTree* m_drt;299 DumpRenderTree* m_drt; 303 300 QWebHistory* m_webHistory; 304 301 bool m_ignoreDesktopNotification;
Note: See TracChangeset
for help on using the changeset viewer.