コード例 #1
0
void ProgramOptions::processOption(const QString & slashOption)
{
    int x = slashOption.indexOf('=');
    if (x > 1)
    {
        arguments_qsl << optionName(slashOption.left(x-1));
        arguments_qsl << slashOption.mid(x+1);
    }
    else
    {
        arguments_qsl << optionName(slashOption);
    }
}
コード例 #2
0
bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
{
    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
    JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
    if (!JSValueIsNumber(context, lengthValue))
        return false;

    WebCore::FindOptions options = 0;

    const size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
    for (size_t i = 0; i < length; ++i) {
        JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
        if (!JSValueIsString(context, value))
            continue;

        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));

        if (equals(optionName, "CaseInsensitive"))
            options |= WebCore::CaseInsensitive;
        else if (equals(optionName, "AtWordStarts"))
            options |= WebCore::AtWordStarts;
        else if (equals(optionName, "TreatMedialCapitalAsWordStart"))
            options |= WebCore::TreatMedialCapitalAsWordStart;
        else if (equals(optionName, "Backwards"))
            options |= WebCore::Backwards;
        else if (equals(optionName, "WrapAround"))
            options |= WebCore::WrapAround;
        else if (equals(optionName, "StartInSelection"))
            options |= WebCore::StartInSelection;
    }

    return DumpRenderTreeSupportEfl::findString(browser->mainView(), target->ustring().utf8().data(), options);
}
コード例 #3
0
ファイル: TestRunnerQt.cpp プロジェクト: 3163504123/phantomjs
bool TestRunner::findString(JSContextRef context, JSStringRef string, JSObjectRef optionsArray)
{
    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
    JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
    if (!JSValueIsNumber(context, lengthValue))
        return false;

    QWebPage::FindFlags findFlags = QWebPage::FindCaseSensitively;

    int length = static_cast<int>(JSValueToNumber(context, lengthValue, 0));
    for (int i = 0; i < length; ++i) {
        JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
        if (!JSValueIsString(context, value))
            continue;

        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));
        if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
            findFlags &= ~QWebPage::FindCaseSensitively;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
            findFlags |= QWebPage::FindAtWordBeginningsOnly;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
            findFlags |=  QWebPage::TreatMedialCapitalAsWordBeginning;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
            findFlags |=  QWebPage::FindBackward;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
            findFlags |=  QWebPage::FindWrapsAroundDocument;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection"))
            findFlags |=  QWebPage::FindBeginsInSelection;
    }

    DumpRenderTree* drt = DumpRenderTree::instance();
    return drt->webPage()->findText(JSStringCopyQString(string), findFlags);
}
コード例 #4
0
ファイル: TestRunner.cpp プロジェクト: rotime/webkit
bool TestRunner::findString(JSStringRef target, JSValueRef optionsArrayAsValue)
{
    WKFindOptions options = 0;

    auto& injectedBundle = InjectedBundle::singleton();
    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(injectedBundle.page()->page());
    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
    JSObjectRef optionsArray = JSValueToObject(context, optionsArrayAsValue, 0);
    JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0);
    if (!JSValueIsNumber(context, lengthValue))
        return false;

    size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
    for (size_t i = 0; i < length; ++i) {
        JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0);
        if (!JSValueIsString(context, value))
            continue;

        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));

        if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
            options |= kWKFindOptionsCaseInsensitive;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
            options |= kWKFindOptionsAtWordStarts;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
            options |= kWKFindOptionsTreatMedialCapitalAsWordStart;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
            options |= kWKFindOptionsBackwards;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
            options |= kWKFindOptionsWrapAround;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection")) {
            // FIXME: No kWKFindOptionsStartInSelection.
        }
    }

    return WKBundlePageFindString(injectedBundle.page()->page(), toWK(target).get(), options);
}
コード例 #5
0
bool LayoutTestController::findString(JSContextRef context, JSStringRef target, JSObjectRef optionsArray)
{
    WebKitFindOptions findOptions = 0;
    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
    ASSERT(webView);

    JSRetainPtr<JSStringRef> lengthPropertyName(Adopt, JSStringCreateWithUTF8CString("length"));
    JSValueRef lengthValue = JSObjectGetProperty(context, optionsArray, lengthPropertyName.get(), 0); 
    if (!JSValueIsNumber(context, lengthValue))
        return false;

    GOwnPtr<gchar> targetString(JSStringCopyUTF8CString(target));

    size_t length = static_cast<size_t>(JSValueToNumber(context, lengthValue, 0));
    for (size_t i = 0; i < length; ++i) {
        JSValueRef value = JSObjectGetPropertyAtIndex(context, optionsArray, i, 0); 
        if (!JSValueIsString(context, value))
            continue;
    
        JSRetainPtr<JSStringRef> optionName(Adopt, JSValueToStringCopy(context, value, 0));

        if (JSStringIsEqualToUTF8CString(optionName.get(), "CaseInsensitive"))
            findOptions |= WebKit::WebFindOptionsCaseInsensitive;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "AtWordStarts"))
            findOptions |= WebKit::WebFindOptionsAtWordStarts;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "TreatMedialCapitalAsWordStart"))
            findOptions |= WebKit::WebFindOptionsTreatMedialCapitalAsWordStart;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "Backwards"))
            findOptions |= WebKit::WebFindOptionsBackwards;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "WrapAround"))
            findOptions |= WebKit::WebFindOptionsWrapAround;
        else if (JSStringIsEqualToUTF8CString(optionName.get(), "StartInSelection"))
            findOptions |= WebKit::WebFindOptionsStartInSelection;
    }   

    return DumpRenderTreeSupportGtk::findString(webView, targetString.get(), findOptions); 
}
コード例 #6
0
    // /////////////////////////////////////////////////////////////////
    //
    // /////////////////////////////////////////////////////////////////
    void LuaStateManager::Shutdown()
    {
        // Write out the various player options so they are available to the lua UI setup scripts.
        LuaPlus::LuaObject luaPlayerOptions = m_GlobalState->GetGlobal("INIT_PLAYER_OPTIONS");

        boost::shared_ptr<GameOptions> goPtr = g_appPtr->GetGameOptions();
        if(!goPtr) {
            // We must have a valid options pointer to proceed!
            return;
        }

        // Sound options.
        std::string optionName("MasterVolume");
        if(luaPlayerOptions[optionName.c_str()].IsNumber()) {
            if(!SetAndConvertOption<F32>(goPtr, optionName, GameOptions::PLAYER, luaPlayerOptions[optionName.c_str()].GetFloat())) {
                GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
            }
        }
        optionName.assign(std::string("Music"));
        if(luaPlayerOptions[optionName.c_str()].IsBoolean()) {
            if(!SetAndConvertOption<bool>(goPtr, optionName, GameOptions::PLAYER, luaPlayerOptions[optionName.c_str()].GetBoolean())) {
                GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
            }
        }
        optionName.assign(std::string("SoundFx"));
        if(luaPlayerOptions[optionName.c_str()].IsBoolean()) {
            if(!SetAndConvertOption<bool>(goPtr, optionName, GameOptions::PLAYER, luaPlayerOptions[optionName.c_str()].GetBoolean())) {
                GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
            }
        }

        // Graphics options.
        optionName.assign(std::string("RenderShadows"));
        if(luaPlayerOptions[optionName.c_str()].IsBoolean()) {
            if(!SetAndConvertOption<bool>(goPtr, optionName, GameOptions::PLAYER, luaPlayerOptions[optionName.c_str()].GetBoolean())) {
                GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
            }
        }
        optionName.assign(std::string("Multisampling"));
        if(luaPlayerOptions[optionName.c_str()].IsString()) {
            std::string value(luaPlayerOptions[optionName.c_str()].GetString());
            if(boost::algorithm::istarts_with(value, std::string("x"))) {
                value.assign(value.substr(1));
            }
            if(!SetAndConvertOption<std::string>(goPtr, optionName, GameOptions::PLAYER, value)) {
                GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
            }
        }
        optionName.assign(std::string("TextureFilteringType"));
        if(luaPlayerOptions[optionName.c_str()].IsString()) {
            if(!SetAndConvertOption<std::string>(goPtr, optionName, GameOptions::PLAYER, luaPlayerOptions[optionName.c_str()].GetString())) {
                GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
            }
        }
        if(luaPlayerOptions["ScreenResolution"].IsString()) {
            std::string resolutionStr(luaPlayerOptions["ScreenResolution"].GetString());
            std::vector<std::string> tokens;
            boost::algorithm::split(tokens, resolutionStr, boost::algorithm::is_any_of(std::string("*")));
            if(tokens.size() == 2 && boost::algorithm::all(tokens[0], boost::algorithm::is_digit()) && boost::algorithm::all(tokens[1], boost::algorithm::is_digit())) {
                optionName.assign(std::string("ScreenWidth"));
                if(!SetAndConvertOption<std::string>(goPtr, optionName, GameOptions::PLAYER, tokens[0])) {
                    GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
                } else {
                    optionName.assign(std::string("ScreenHeight"));
                    if(!SetAndConvertOption<std::string>(goPtr, optionName, GameOptions::PLAYER, tokens[1])) {
                        GF_LOG_TRACE_ERR("LuaStateManager::Shutdown()", std::string("Failed to save (to the GameOptions file) the lua option: ") + optionName);
                    }
                }
            }
        }

        goPtr->Commit();
    }