Foo::s_info should be Foo::info(), so that you can change how the s_info is actually...
[WebKit-https.git] / Source / WebKit / qt / WebCoreSupport / DumpRenderTreeSupportQt.cpp
index 0b7856a..3df5597 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "APICast.h"
 #include "ApplicationCacheStorage.h"
-#include "CSSComputedStyleDeclaration.h"
 #include "ChromeClientQt.h"
 #include "ContainerNode.h"
 #include "ContextMenu.h"
@@ -39,6 +38,7 @@
 #include "EditorClientQt.h"
 #include "Element.h"
 #include "FocusController.h"
+#include "Font.h"
 #include "Frame.h"
 #include "FrameLoadRequest.h"
 #include "FrameLoaderClientQt.h"
@@ -163,7 +163,7 @@ WebCore::Node* QtDRTNodeRuntime::get(const QDRTNode& node)
 
 static QVariant convertJSValueToNodeVariant(JSC::JSObject* object, int *distance, HashSet<JSObjectRef>*)
 {
-    if (!object || !object->inherits(&JSNode::s_info))
+    if (!object || !object->inherits(JSNode::info()))
         return QVariant();
     return QVariant::fromValue<QDRTNode>(QtDRTNodeRuntime::create((static_cast<JSNode*>(object))->impl()));
 }
@@ -219,7 +219,7 @@ void DumpRenderTreeSupportQt::setDumpRenderTreeModeEnabled(bool b)
 
 void DumpRenderTreeSupportQt::setFrameFlatteningEnabled(QWebPageAdapter* adapter, bool enabled)
 {
-    adapter->page->settings()->setFrameFlatteningEnabled(enabled);
+    adapter->page->settings().setFrameFlatteningEnabled(enabled);
 }
 
 void DumpRenderTreeSupportQt::webPageSetGroupName(QWebPageAdapter *adapter, const QString& groupName)
@@ -264,18 +264,6 @@ bool DumpRenderTreeSupportQt::hasDocumentElement(QWebFrameAdapter *adapter)
     return adapter->frame->document()->documentElement();
 }
 
-void DumpRenderTreeSupportQt::setAutofilled(const QWebElement& element, bool isAutofilled)
-{
-    WebCore::Element* webElement = element.m_element;
-    if (!webElement)
-        return;
-    HTMLInputElement* inputElement = webElement->toInputElement();
-    if (!inputElement)
-        return;
-
-    inputElement->setAutofilled(isAutofilled);
-}
-
 void DumpRenderTreeSupportQt::setValueForUser(const QWebElement& element, const QString& value)
 {
     WebCore::Element* webElement = element.m_element;
@@ -296,7 +284,7 @@ void DumpRenderTreeSupportQt::clearFrameName(QWebFrameAdapter *adapter)
 
 int DumpRenderTreeSupportQt::javaScriptObjectsCount()
 {
-    return JSDOMWindowBase::commonJSGlobalData()->heap.globalObjectCount();
+    return JSDOMWindowBase::commonVM()->heap.globalObjectCount();
 }
 
 void DumpRenderTreeSupportQt::garbageCollectorCollect()
@@ -331,97 +319,22 @@ void DumpRenderTreeSupportQt::setDomainRelaxationForbiddenForURLScheme(bool forb
 
 void DumpRenderTreeSupportQt::setCaretBrowsingEnabled(QWebPageAdapter* adapter, bool value)
 {
-    adapter->page->settings()->setCaretBrowsingEnabled(value);
+    adapter->page->settings().setCaretBrowsingEnabled(value);
 }
 
 void DumpRenderTreeSupportQt::setAuthorAndUserStylesEnabled(QWebPageAdapter* adapter, bool value)
 {
-    adapter->page->settings()->setAuthorAndUserStylesEnabled(value);
+    adapter->page->settings().setAuthorAndUserStylesEnabled(value);
 }
 
-void DumpRenderTreeSupportQt::setSmartInsertDeleteEnabled(QWebPageAdapter *adapter, bool enabled)
-{
-    static_cast<EditorClientQt*>(adapter->page->editorClient())->setSmartInsertDeleteEnabled(enabled);
-}
-
-
-void DumpRenderTreeSupportQt::setSelectTrailingWhitespaceEnabled(QWebPageAdapter *adapter, bool enabled)
-{
-    static_cast<EditorClientQt*>(adapter->page->editorClient())->setSelectTrailingWhitespaceEnabled(enabled);
-}
-
-
 void DumpRenderTreeSupportQt::executeCoreCommandByName(QWebPageAdapter* adapter, const QString& name, const QString& value)
 {
-    adapter->page->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value);
+    adapter->page->focusController()->focusedOrMainFrame()->editor().command(name).execute(value);
 }
 
 bool DumpRenderTreeSupportQt::isCommandEnabled(QWebPageAdapter *adapter, const QString& name)
 {
-    return adapter->page->focusController()->focusedOrMainFrame()->editor()->command(name).isEnabled();
-}
-
-bool DumpRenderTreeSupportQt::findString(QWebPageAdapter *adapter, const QString& string, const QStringList& optionArray)
-{
-    // 1. Parse the options from the array
-    WebCore::FindOptions options = 0;
-    const int optionCount = optionArray.size();
-    for (int i = 0; i < optionCount; ++i) {
-        const QString& option = optionArray.at(i);
-        if (option == QLatin1String("CaseInsensitive"))
-            options |= WebCore::CaseInsensitive;
-        else if (option == QLatin1String("AtWordStarts"))
-            options |= WebCore::AtWordStarts;
-        else if (option == QLatin1String("TreatMedialCapitalAsWordStart"))
-            options |= WebCore::TreatMedialCapitalAsWordStart;
-        else if (option == QLatin1String("Backwards"))
-            options |= WebCore::Backwards;
-        else if (option == QLatin1String("WrapAround"))
-            options |= WebCore::WrapAround;
-        else if (option == QLatin1String("StartInSelection"))
-            options |= WebCore::StartInSelection;
-    }
-
-    // 2. find the string
-    WebCore::Frame* frame = adapter->page->focusController()->focusedOrMainFrame();
-    return frame && frame->editor()->findString(string, options);
-}
-
-QString DumpRenderTreeSupportQt::markerTextForListItem(const QWebElement& listItem)
-{
-    return WebCore::markerTextForListItem(listItem.m_element);
-}
-
-static QString convertToPropertyName(const QString& name)
-{
-    QStringList parts = name.split(QLatin1Char('-'));
-    QString camelCaseName;
-    for (int j = 0; j < parts.count(); ++j) {
-        QString part = parts.at(j);
-        if (j)
-            camelCaseName.append(part.replace(0, 1, part.left(1).toUpper()));
-        else
-            camelCaseName.append(part);
-    }
-    return camelCaseName;
-}
-
-QVariantMap DumpRenderTreeSupportQt::computedStyleIncludingVisitedInfo(const QWebElement& element)
-{
-    QVariantMap res;
-
-    WebCore::Element* webElement = element.m_element;
-    if (!webElement)
-        return res;
-
-    RefPtr<WebCore::CSSComputedStyleDeclaration> computedStyleDeclaration = CSSComputedStyleDeclaration::create(webElement, true);
-    CSSStyleDeclaration* style = static_cast<WebCore::CSSStyleDeclaration*>(computedStyleDeclaration.get());
-    for (unsigned i = 0; i < style->length(); i++) {
-        QString name = style->item(i);
-        QString value = style->getPropertyValue(name);
-        res[convertToPropertyName(name)] = QVariant(value);
-    }
-    return res;
+    return adapter->page->focusController()->focusedOrMainFrame()->editor().command(name).isEnabled();
 }
 
 QVariantList DumpRenderTreeSupportQt::selectedRange(QWebPageAdapter *adapter)
@@ -461,35 +374,17 @@ QVariantList DumpRenderTreeSupportQt::firstRectForCharacterRange(QWebPageAdapter
     if (!range)
         return QVariantList();
 
-    QRect resultRect = frame->editor()->firstRectForRange(range.get());
+    QRect resultRect = frame->editor().firstRectForRange(range.get());
     rect << resultRect.x() << resultRect.y() << resultRect.width() << resultRect.height();
     return rect;
 }
 
-bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrameAdapter *adapter, const QString& elementId)
-{
-    Frame* coreFrame = adapter->frame;
-    if (!coreFrame)
-        return false;
-
-    Document* doc = coreFrame->document();
-    Q_ASSERT(doc);
-
-    Node* coreNode = doc->getElementById(elementId);
-    if (!coreNode || !coreNode->renderer())
-        return false;
-
-    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(coreNode);
-
-    return inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->shouldAutocomplete();
-}
-
 void DumpRenderTreeSupportQt::setWindowsBehaviorAsEditingBehavior(QWebPageAdapter* adapter)
 {
     Page* corePage = adapter->page;
     if (!corePage)
         return;
-    corePage->settings()->setEditingBehaviorType(EditingWindowsBehavior);
+    corePage->settings().setEditingBehaviorType(EditingWindowsBehavior);
 }
 
 void DumpRenderTreeSupportQt::clearAllApplicationCaches()
@@ -789,7 +684,7 @@ void DumpRenderTreeSupportQt::setInteractiveFormValidationEnabled(QWebPageAdapte
 {
     Page* corePage = adapter->page;
     if (corePage)
-        corePage->settings()->setInteractiveFormValidationEnabled(enable);
+        corePage->settings().setInteractiveFormValidationEnabled(enable);
 }
 
 QStringList DumpRenderTreeSupportQt::contextMenu(QWebPageAdapter* page)
@@ -797,20 +692,6 @@ QStringList DumpRenderTreeSupportQt::contextMenu(QWebPageAdapter* page)
     return page->menuActionsAsText();
 }
 
-double DumpRenderTreeSupportQt::defaultMinimumTimerInterval()
-{
-    return Settings::defaultMinDOMTimerInterval();
-}
-
-void DumpRenderTreeSupportQt::setMinimumTimerInterval(QWebPageAdapter* adapter, double interval)
-{
-    Page* corePage = adapter->page;
-    if (!corePage)
-        return;
-
-    corePage->settings()->setMinDOMTimerInterval(interval);
-}
-
 bool DumpRenderTreeSupportQt::thirdPartyCookiePolicyAllows(QWebPageAdapter *adapter, const QUrl& url, const QUrl& firstPartyUrl)
 {
     Page* corePage = adapter->page;
@@ -839,7 +720,7 @@ QUrl DumpRenderTreeSupportQt::mediaContentUrlByElementId(QWebFrameAdapter* adapt
     if (!coreNode)
         return res;
 
-    HTMLVideoElement* videoElement = static_cast<HTMLVideoElement*>(coreNode);
+    HTMLVideoElement* videoElement = toHTMLVideoElement(coreNode);
     PlatformMedia platformMedia = videoElement->platformMedia();
     if (platformMedia.type != PlatformMedia::QtMediaPlayerType)
         return res;
@@ -870,17 +751,17 @@ void DumpRenderTreeSupportQt::confirmComposition(QWebPageAdapter *adapter, const
     if (!frame)
         return;
 
-    Editor* editor = frame->editor();
-    if (!editor || (!editor->hasComposition() && !text))
+    Editor& editor = frame->editor();
+    if (!editor.hasComposition() && !text)
         return;
 
-    if (editor->hasComposition()) {
+    if (editor.hasComposition()) {
         if (text)
-            editor->confirmComposition(String::fromUTF8(text));
+            editor.confirmComposition(String::fromUTF8(text));
         else
-            editor->confirmComposition();
+            editor.confirmComposition();
     } else
-        editor->insertText(String::fromUTF8(text), 0);
+        editor.insertText(String::fromUTF8(text), 0);
 }
 
 void DumpRenderTreeSupportQt::injectInternalsObject(QWebFrameAdapter* adapter)
@@ -992,6 +873,11 @@ void DumpRenderTreeSupportQt::setSeamlessIFramesEnabled(bool enabled)
 #endif
 }
 
+void DumpRenderTreeSupportQt::setShouldUseFontSmoothing(bool enabled)
+{
+    WebCore::Font::setShouldUseSmoothing(enabled);
+}
+
 QString DumpRenderTreeSupportQt::frameRenderTreeDump(QWebFrameAdapter* adapter)
 {
     if (adapter->frame->view() && adapter->frame->view()->layoutPending())
@@ -1006,3 +892,15 @@ void DumpRenderTreeSupportQt::clearNotificationPermissions()
     WebCore::NotificationPresenterClientQt::notificationPresenter()->clearCachedPermissions();
 #endif
 }
+
+void DumpRenderTreeSupportQt::disableDefaultTypesettingFeatures()
+{
+    WebCore::Font::setDefaultTypesettingFeatures(0);
+}
+
+void DumpRenderTreeSupportQt::getJSWindowObject(QWebFrameAdapter* adapter, JSContextRef* context, JSObjectRef* object)
+{
+    JSDOMWindow* window = toJSDOMWindow(adapter->frame, mainThreadNormalWorld());
+    *object = toRef(window);
+    *context = toRef(window->globalExec());
+}