AccessibilityController::AccessibilityController()
    : m_logAccessibilityEvents(false)
{

    bindMethod("logAccessibilityEvents", &AccessibilityController::logAccessibilityEventsCallback);
    bindMethod("addNotificationListener", &AccessibilityController::addNotificationListenerCallback);
    bindMethod("removeNotificationListener", &AccessibilityController::removeNotificationListenerCallback);

    bindProperty("focusedElement", &AccessibilityController::focusedElementGetterCallback);
    bindProperty("rootElement", &AccessibilityController::rootElementGetterCallback);

    bindMethod("accessibleElementById", &AccessibilityController::accessibleElementByIdGetterCallback);

    bindFallbackMethod(&AccessibilityController::fallbackCallback);
}
Example #2
0
void ReflectedGroupItem::getChildValues(Variants &childValues) const
{
	if( groupObj_ == nullptr )
		return;

	auto object = getObject();
	if (object == nullptr)
		return;

	auto definitionManager = getDefinitionManager();
	if( definitionManager == nullptr )
		return;

	auto definition = object.getDefinition( *getDefinitionManager() );
	if( definition == nullptr )
		return;

	EnumerateVisibleProperties([&](IBasePropertyPtr property, const std::string & inplacePath){
		// Check if this property is a part of this group
		const auto groupObj = findFirstMetaData< MetaGroupObj >(*property, *definitionManager);
		if ( isSameGroup( groupObj ) )
		{
			auto path = inplacePath + property->getName();
			auto propertyAccessor = definition->bindProperty( path.c_str(), object );
			Variant value = getController()->getValue(propertyAccessor);
			childValues.emplace_back(value);
		}
		return true;
	});
}
Example #3
0
bool ReflectedGroupItem::setData( int column, size_t roleId, const Variant & data )
{
	auto controller = getController();
	if (controller == nullptr)
	{
		return false;
	}

	auto object = getObject();
	if (object == nullptr)
	{
		return false;
	}

	auto definitionManager = getDefinitionManager();
	if (definitionManager == nullptr)
	{
		return false;
	}

	auto definition = getDefinition();
	if (definition == nullptr)
	{
		return false;
	}

	Collection collection;
	bool isOk = data.tryCast( collection );
	if(!isOk)
	{
		return false;
	}
	size_t value_size = collection.size();
	
	auto iter = collection.begin();

	EnumerateVisibleProperties([&](IBasePropertyPtr property, const std::string & inplacePath)
	{
		if(iter == collection.end())
			return false;

		auto groupObj = findFirstMetaData< MetaGroupObj >( *property, *getDefinitionManager() );
		if ( isSameGroup( groupObj ) )
		{
			const Variant & value = *iter++;
			auto path = inplacePath + property->getName();
			auto propertyAccessor = definition->bindProperty( path.c_str(), object );
			controller->setValue( propertyAccessor, value );
		}
		return true;
	});

	return true;
}
	Data(Data& data)
	    : checked_(data.checked_), text_(data.text_), slider_(data.slider_), vector_(nullptr), color_(data.color_),
	      context_(data.context_)
	{
		auto& definitionManager = *context_.queryInterface<IDefinitionManager>();
		vector_ = GenericObject::create(definitionManager);
		auto definition = data.vector_.getDefinition(definitionManager);
		for (auto property : definition->allProperties())
		{
			const char* name = property->getName();
			vector_->set(name, definition->bindProperty(name, data.vector_).getValue());
		}
	}
// -----------------------------------------------------------------------------
TEST_F(TestCollectionFixture, int_vector)
{
	TestCollectionObject subject;

	IntVector test1;
	test1.push_back(1);
	test1.push_back(2);
	test1.push_back(4);
	test1.push_back(8);
	test1.push_back(16);
	test1.push_back(32);

	IntVector test2;
	test2.push_back(-1);
	test2.push_back(-2);
	test2.push_back(-4);
	test2.push_back(-8);
	test2.push_back(-16);
	test2.push_back(-32);
	test2.push_back(-64);
	test2.push_back(-128);

	// Verify initial size & types
	CHECK_EQUAL(0, subject.int_vector_.size());

	ObjectHandle provider( &subject );

	Variant vIntVector =
		intVectorProperty_.get( provider, getDefinitionManager() );
	Collection collection;
	vIntVector.tryCast( collection );
	CHECK_EQUAL(0, collection.size());

	// Verify initial iterator properties
	{
		CHECK_EQUAL(collection.begin(), collection.end());
		const size_t index = 0;
		CHECK_EQUAL(collection.end(), collection.find(index));
	}

	{
		subject.int_vector_ = test1;

		CHECK_EQUAL( Collection( subject.int_vector_), collection );
		CHECK_EQUAL(test1.size(), collection.size());
	}

	// Verify iteration
	{
		IntVector result;
		for (auto iter = collection.begin(), 
			end = collection.end(); iter != end; ++iter)
		{
			int value;
			iter.value().tryCast( value );
			result.push_back(value);
		}

		CHECK(test1 == result);
	}

	// Verify iterator access
	{
		size_t index = 3, test_index = 0;
		auto iter = collection.find(index);
		iter.key().tryCast( test_index );
		CHECK_EQUAL(index, test_index);

		int value = 0;
		iter.value().tryCast( value );
		CHECK_EQUAL(test1[3], value);

		index = 0;
		iter = collection.find( index );
		iter.key().tryCast( test_index );
		CHECK_EQUAL(index, test_index);

		iter.value().tryCast( value );
		CHECK_EQUAL(test1[0], value);

		index = 1000;
		iter = collection.find( index );
		CHECK_EQUAL(collection.end(), iter);
	}

	{
		IntVector value = test2;
		intVectorProperty_.set( provider, value, getDefinitionManager() );

		CHECK(test2 == value);
		CHECK(test2 == subject.int_vector_);

		CHECK_EQUAL(test2.size(), collection.size());
	}

	auto definition = getDefinitionManager().getDefinition< TestCollectionObject >();
	CHECK( definition );

	{
		auto pa = definition->bindProperty( "int vector[0]", provider );
		CHECK( pa.isValid() );

		int i = 0;
		CHECK( pa.getValue().tryCast( i ) );

		CHECK_EQUAL( -1, i );

		// not Variant
		// not Variant::traits< int >::storage_type
		CHECK( pa.getType() == TypeId::getType< int >() );
	}
}
void CppBoundClass::bindProperty(const string& name, CppVariant* prop)
{
    PropertyCallback* propertyCallback = prop ? new CppVariantPropertyCallback(prop) : 0;
    bindProperty(name, propertyCallback);
}
void CppBoundClass::bindGetterCallback(const string& name, auto_ptr<GetterCallback> callback)
{
    PropertyCallback* propertyCallback = callback.get() ? new GetterPropertyCallback(callback) : 0;
    bindProperty(name, propertyCallback);
}
Example #8
0
AccessibilityUIElement::AccessibilityUIElement(const WebAccessibilityObject& object, Factory* factory)
    : m_accessibilityObject(object)
    , m_factory(factory)
{

    ASSERT(factory);

    //
    // Properties
    //

    bindProperty("role", &AccessibilityUIElement::roleGetterCallback);
    bindProperty("title", &AccessibilityUIElement::titleGetterCallback);
    bindProperty("description", &AccessibilityUIElement::descriptionGetterCallback);
    bindProperty("helpText", &AccessibilityUIElement::helpTextGetterCallback);
    bindProperty("stringValue", &AccessibilityUIElement::stringValueGetterCallback);
    bindProperty("x", &AccessibilityUIElement::xGetterCallback);
    bindProperty("y", &AccessibilityUIElement::yGetterCallback);
    bindProperty("width", &AccessibilityUIElement::widthGetterCallback);
    bindProperty("height", &AccessibilityUIElement::heightGetterCallback);
    bindProperty("intValue", &AccessibilityUIElement::intValueGetterCallback);
    bindProperty("minValue", &AccessibilityUIElement::minValueGetterCallback);
    bindProperty("maxValue", &AccessibilityUIElement::maxValueGetterCallback);
    bindProperty("valueDescription", &AccessibilityUIElement::valueDescriptionGetterCallback);
    bindProperty("childrenCount", &AccessibilityUIElement::childrenCountGetterCallback);
    bindProperty("insertionPointLineNumber", &AccessibilityUIElement::insertionPointLineNumberGetterCallback);
    bindProperty("selectedTextRange", &AccessibilityUIElement::selectedTextRangeGetterCallback);
    bindProperty("isEnabled", &AccessibilityUIElement::isEnabledGetterCallback);
    bindProperty("isRequired", &AccessibilityUIElement::isRequiredGetterCallback);
    bindProperty("isFocused", &AccessibilityUIElement::isFocusedGetterCallback);
    bindProperty("isFocusable", &AccessibilityUIElement::isFocusableGetterCallback);
    bindProperty("isSelected", &AccessibilityUIElement::isSelectedGetterCallback);
    bindProperty("isSelectable", &AccessibilityUIElement::isSelectableGetterCallback);
    bindProperty("isMultiSelectable", &AccessibilityUIElement::isMultiSelectableGetterCallback);
    bindProperty("isSelectedOptionActive", &AccessibilityUIElement::isSelectedOptionActiveGetterCallback);
    bindProperty("isExpanded", &AccessibilityUIElement::isExpandedGetterCallback);
    bindProperty("isChecked", &AccessibilityUIElement::isCheckedGetterCallback);
    bindProperty("isVisible", &AccessibilityUIElement::isVisibleGetterCallback);
    bindProperty("isOffScreen", &AccessibilityUIElement::isOffScreenGetterCallback);
    bindProperty("isCollapsed", &AccessibilityUIElement::isCollapsedGetterCallback);
    bindProperty("hasPopup", &AccessibilityUIElement::hasPopupGetterCallback);
    bindProperty("isValid", &AccessibilityUIElement::isValidGetterCallback);
    bindProperty("isReadOnly", &AccessibilityUIElement::isReadOnlyGetterCallback);
    bindProperty("orientation", &AccessibilityUIElement::orientationGetterCallback);
    bindProperty("clickPointX", &AccessibilityUIElement::clickPointXGetterCallback);
    bindProperty("clickPointY", &AccessibilityUIElement::clickPointYGetterCallback);

    //
    // Methods
    //

    bindMethod("allAttributes", &AccessibilityUIElement::allAttributesCallback);
    bindMethod("attributesOfLinkedUIElements", &AccessibilityUIElement::attributesOfLinkedUIElementsCallback);
    bindMethod("attributesOfDocumentLinks", &AccessibilityUIElement::attributesOfDocumentLinksCallback);
    bindMethod("attributesOfChildren", &AccessibilityUIElement::attributesOfChildrenCallback);
    bindMethod("lineForIndex", &AccessibilityUIElement::lineForIndexCallback);
    bindMethod("boundsForRange", &AccessibilityUIElement::boundsForRangeCallback);
    bindMethod("stringForRange", &AccessibilityUIElement::stringForRangeCallback);
    bindMethod("childAtIndex", &AccessibilityUIElement::childAtIndexCallback);
    bindMethod("elementAtPoint", &AccessibilityUIElement::elementAtPointCallback);
    bindMethod("attributesOfColumnHeaders", &AccessibilityUIElement::attributesOfColumnHeadersCallback);
    bindMethod("attributesOfRowHeaders", &AccessibilityUIElement::attributesOfRowHeadersCallback);
    bindMethod("attributesOfColumns", &AccessibilityUIElement::attributesOfColumnsCallback);
    bindMethod("attributesOfRows", &AccessibilityUIElement::attributesOfRowsCallback);
    bindMethod("attributesOfVisibleCells", &AccessibilityUIElement::attributesOfVisibleCellsCallback);
    bindMethod("attributesOfHeader", &AccessibilityUIElement::attributesOfHeaderCallback);
    bindMethod("indexInTable", &AccessibilityUIElement::indexInTableCallback);
    bindMethod("rowIndexRange", &AccessibilityUIElement::rowIndexRangeCallback);
    bindMethod("columnIndexRange", &AccessibilityUIElement::columnIndexRangeCallback);
    bindMethod("cellForColumnAndRow", &AccessibilityUIElement::cellForColumnAndRowCallback);
    bindMethod("titleUIElement", &AccessibilityUIElement::titleUIElementCallback);
    bindMethod("setSelectedTextRange", &AccessibilityUIElement::setSelectedTextRangeCallback);
    bindMethod("attributeValue", &AccessibilityUIElement::attributeValueCallback);
    bindMethod("isAttributeSettable", &AccessibilityUIElement::isAttributeSettableCallback);
    bindMethod("isPressActionSupported", &AccessibilityUIElement::isPressActionSupportedCallback);
    bindMethod("isIncrementActionSupported", &AccessibilityUIElement::isIncrementActionSupportedCallback);
    bindMethod("isDecrementActionSupported", &AccessibilityUIElement::isDecrementActionSupportedCallback);
    bindMethod("parentElement", &AccessibilityUIElement::parentElementCallback);
    bindMethod("increment", &AccessibilityUIElement::incrementCallback);
    bindMethod("decrement", &AccessibilityUIElement::decrementCallback);
    bindMethod("showMenu", &AccessibilityUIElement::showMenuCallback);
    bindMethod("press", &AccessibilityUIElement::pressCallback);
    bindMethod("isEqual", &AccessibilityUIElement::isEqualCallback);
    bindMethod("addNotificationListener", &AccessibilityUIElement::addNotificationListenerCallback);
    bindMethod("removeNotificationListener", &AccessibilityUIElement::removeNotificationListenerCallback);
    bindMethod("takeFocus", &AccessibilityUIElement::takeFocusCallback);
    bindMethod("scrollToMakeVisible", &AccessibilityUIElement::scrollToMakeVisibleCallback);
    bindMethod("scrollToMakeVisibleWithSubFocus", &AccessibilityUIElement::scrollToMakeVisibleWithSubFocusCallback);
    bindMethod("scrollToGlobalPoint", &AccessibilityUIElement::scrollToGlobalPointCallback);

    bindFallbackMethod(&AccessibilityUIElement::fallbackCallback);
}
Example #9
0
TestRunner::TestRunner()
    : m_delegate(0)
    , m_webView(0)
    , m_intentClient(adoptPtr(new EmptyWebDeliveredIntentClient))
{
    // Methods implemented in terms of chromium's public WebKit API.
    bindMethod("setTabKeyCyclesThroughElements", &TestRunner::setTabKeyCyclesThroughElements);
    bindMethod("execCommand", &TestRunner::execCommand);
    bindMethod("isCommandEnabled", &TestRunner::isCommandEnabled);
    bindMethod("pauseAnimationAtTimeOnElementWithId", &TestRunner::pauseAnimationAtTimeOnElementWithId);
    bindMethod("pauseTransitionAtTimeOnElementWithId", &TestRunner::pauseTransitionAtTimeOnElementWithId);
    bindMethod("elementDoesAutoCompleteForElementWithId", &TestRunner::elementDoesAutoCompleteForElementWithId);
    bindMethod("numberOfActiveAnimations", &TestRunner::numberOfActiveAnimations);
    bindMethod("callShouldCloseOnWebView", &TestRunner::callShouldCloseOnWebView);
    bindMethod("setDomainRelaxationForbiddenForURLScheme", &TestRunner::setDomainRelaxationForbiddenForURLScheme);
    bindMethod("evaluateScriptInIsolatedWorldAndReturnValue", &TestRunner::evaluateScriptInIsolatedWorldAndReturnValue);
    bindMethod("evaluateScriptInIsolatedWorld", &TestRunner::evaluateScriptInIsolatedWorld);
    bindMethod("setIsolatedWorldSecurityOrigin", &TestRunner::setIsolatedWorldSecurityOrigin);
    bindMethod("setIsolatedWorldContentSecurityPolicy", &TestRunner::setIsolatedWorldContentSecurityPolicy);
    bindMethod("addOriginAccessWhitelistEntry", &TestRunner::addOriginAccessWhitelistEntry);
    bindMethod("removeOriginAccessWhitelistEntry", &TestRunner::removeOriginAccessWhitelistEntry);
    bindMethod("hasCustomPageSizeStyle", &TestRunner::hasCustomPageSizeStyle);
    bindMethod("forceRedSelectionColors", &TestRunner::forceRedSelectionColors);
    bindMethod("addUserScript", &TestRunner::addUserScript);
    bindMethod("addUserStyleSheet", &TestRunner::addUserStyleSheet);
    bindMethod("startSpeechInput", &TestRunner::startSpeechInput);
    bindMethod("loseCompositorContext", &TestRunner::loseCompositorContext);
    bindMethod("markerTextForListItem", &TestRunner::markerTextForListItem);
    bindMethod("findString", &TestRunner::findString);
    bindMethod("setAutofilled", &TestRunner::setAutofilled);
    bindMethod("setValueForUser", &TestRunner::setValueForUser);
    bindMethod("enableFixedLayoutMode", &TestRunner::enableFixedLayoutMode);
    bindMethod("setFixedLayoutSize", &TestRunner::setFixedLayoutSize);
    bindMethod("selectionAsMarkup", &TestRunner::selectionAsMarkup);
    bindMethod("setTextSubpixelPositioning", &TestRunner::setTextSubpixelPositioning);
    bindMethod("resetPageVisibility", &TestRunner::resetPageVisibility);
    bindMethod("setPageVisibility", &TestRunner::setPageVisibility);
    bindMethod("setTextDirection", &TestRunner::setTextDirection);
    bindMethod("textSurroundingNode", &TestRunner::textSurroundingNode);

    // The following modify WebPreferences.
    bindMethod("setUserStyleSheetEnabled", &TestRunner::setUserStyleSheetEnabled);
    bindMethod("setUserStyleSheetLocation", &TestRunner::setUserStyleSheetLocation);
    bindMethod("setAuthorAndUserStylesEnabled", &TestRunner::setAuthorAndUserStylesEnabled);
    bindMethod("setPopupBlockingEnabled", &TestRunner::setPopupBlockingEnabled);
    bindMethod("setJavaScriptCanAccessClipboard", &TestRunner::setJavaScriptCanAccessClipboard);
    bindMethod("setXSSAuditorEnabled", &TestRunner::setXSSAuditorEnabled);
    bindMethod("setAllowUniversalAccessFromFileURLs", &TestRunner::setAllowUniversalAccessFromFileURLs);
    bindMethod("setAllowFileAccessFromFileURLs", &TestRunner::setAllowFileAccessFromFileURLs);
    bindMethod("overridePreference", &TestRunner::overridePreference);
    bindMethod("setPluginsEnabled", &TestRunner::setPluginsEnabled);
    bindMethod("setAsynchronousSpellCheckingEnabled", &TestRunner::setAsynchronousSpellCheckingEnabled);
    bindMethod("setMinimumTimerInterval", &TestRunner::setMinimumTimerInterval);
    bindMethod("setTouchDragDropEnabled", &TestRunner::setTouchDragDropEnabled);

    // The following modify the state of the TestRunner.
    bindMethod("dumpEditingCallbacks", &TestRunner::dumpEditingCallbacks);

    // The following methods interact with the WebTestProxy.
    bindMethod("sendWebIntentResponse", &TestRunner::sendWebIntentResponse);
    bindMethod("deliverWebIntent", &TestRunner::deliverWebIntent);

    // Properties.
    bindProperty("workerThreadCount", &TestRunner::workerThreadCount);
    bindProperty("globalFlag", &m_globalFlag);
    bindProperty("platformName", &m_platformName);

    // The following are stubs.
    bindMethod("dumpDatabaseCallbacks", &TestRunner::notImplemented);
#if ENABLE(NOTIFICATIONS)
    bindMethod("denyWebNotificationPermission", &TestRunner::notImplemented);
    bindMethod("removeAllWebNotificationPermissions", &TestRunner::notImplemented);
    bindMethod("simulateWebNotificationClick", &TestRunner::notImplemented);
#endif
    bindMethod("setIconDatabaseEnabled", &TestRunner::notImplemented);
    bindMethod("setScrollbarPolicy", &TestRunner::notImplemented);
    bindMethod("clearAllApplicationCaches", &TestRunner::notImplemented);
    bindMethod("clearApplicationCacheForOrigin", &TestRunner::notImplemented);
    bindMethod("clearBackForwardList", &TestRunner::notImplemented);
    bindMethod("keepWebHistory", &TestRunner::notImplemented);
    bindMethod("setApplicationCacheOriginQuota", &TestRunner::notImplemented);
    bindMethod("setCallCloseOnWebViews", &TestRunner::notImplemented);
    bindMethod("setMainFrameIsFirstResponder", &TestRunner::notImplemented);
    bindMethod("setPrivateBrowsingEnabled", &TestRunner::notImplemented);
    bindMethod("setUseDashboardCompatibilityMode", &TestRunner::notImplemented);
    bindMethod("deleteAllLocalStorage", &TestRunner::notImplemented);
    bindMethod("localStorageDiskUsageForOrigin", &TestRunner::notImplemented);
    bindMethod("originsWithLocalStorage", &TestRunner::notImplemented);
    bindMethod("deleteLocalStorageForOrigin", &TestRunner::notImplemented);
    bindMethod("observeStorageTrackerNotifications", &TestRunner::notImplemented);
    bindMethod("syncLocalStorage", &TestRunner::notImplemented);
    bindMethod("addDisallowedURL", &TestRunner::notImplemented);
    bindMethod("applicationCacheDiskUsageForOrigin", &TestRunner::notImplemented);
    bindMethod("abortModal", &TestRunner::notImplemented);

    // The fallback method is called when an unknown method is invoked.
    bindFallbackMethod(&TestRunner::fallbackMethod);
}
Example #10
0
void CppBoundClass::bindGetterCallback(const string& name, PassOwnPtr<GetterCallback> callback)
{
    PropertyCallback* propertyCallback = callback ? new GetterPropertyCallback(callback) : 0;
    bindProperty(name, propertyCallback);
}