当前位置: 首页>>代码示例>>C++>>正文


C++ Node::isHTMLElement方法代码示例

本文整理汇总了C++中webcore::Node::isHTMLElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::isHTMLElement方法的具体用法?C++ Node::isHTMLElement怎么用?C++ Node::isHTMLElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webcore::Node的用法示例。


在下文中一共展示了Node::isHTMLElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setInputMethodState

void EditorClientEA::setInputMethodState(bool active)
{
	WebCore::Node* pNode = NULL;
	Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame();
	if (frame && frame->document() && frame->document()->focusedNode())
	{
		pNode = frame->document()->focusedNode();
	}	

	// Note by Arpit Baldeva: If on console(true by default on consoles/can be enabled on PC through emulation), 
	// we detect if the node was focused due to the user input or through javascript.
	// If the node was focused by user input(such as click), we present the editor(emulated keyboard on consoles, debug log on PC).
	// If the node was focused by javascript, we make the cursor jump to the node. In addition, we blur <input>/<textarea> element 
	// so that the user click can bring up the emulated keyboard.
	EA::WebKit::View* pView = m_page->view();
#if defined(EA_PLATFORM_CONSOLE)
	bool onConsole = true;
#elif defined(EA_PLATFORM_WINDOWS)
	bool onConsole = pView->IsEmulatingConsoleOnPC();
#elif defined(EA_PLATFORM_OSX)
	bool onConsole = false;
#endif
	
	if(onConsole && !pView->AllowJSTextInputStateNotificationOnConsole())
	{
		if(!m_page->handle()->mouseCausedEventActive)
		{
			pView->MoveMouseCursorToNode(pNode);
			if (pNode && pNode->isHTMLElement())
			{
				if(pNode->hasTagName(WebCore::HTMLNames::inputTag) || pNode->hasTagName(WebCore::HTMLNames::textareaTag)) 
				{
					HTMLElement* pElement = static_cast<HTMLElement*> (pNode);
					pElement->blur();
				}
			}
			return;
		}
	}
	
	// CSidhall 1/22/09 Added notify user app of text input state for possible virtual keyboard...
	// We can't fully trust the enabled flag because the input field might be a password in which case we still
	// want to activate the keyboard input. So we do our own checking and also get extra info...   

	//Note by Arpit Baldeva: We are interested in the <input> and <textarea> elements. The problem is that we can't rely on the shouldUseInputMethod() of node to reliably detect an
	//editable node since it does not include password(as noted above). Webkit trunk has some cryptic comment explaining why that is the right thing to do. So we do as follows. 
	// We could add a new method to the class hierarchy to achieve following but want to minimize the changes inside core layer.

	bool inputActive	= active;
	bool searchActive	= false;
	bool passwordActive = false;
	EA::WebKit::KeyboardType kbType = EA::WebKit::kDefaultKeyBoard;
	EA::WebKit::InputType inputType = EA::WebKit::kInputTypeNone;

	
    if( pNode && pNode->isHTMLElement())
	{
		if(pNode->hasTagName(WebCore::HTMLNames::inputTag) ) 
		{	
			HTMLInputElement* pInputElement = static_cast<HTMLInputElement*> (pNode);
			inputActive		= pInputElement->isTextField(); // This check makes sure that we are not firing this event with inputActive set to true in case of HTML like <input type="button" value="Click me" onclick="msg()">
			//+ Deprecated
			searchActive	= pInputElement->isSearchField();
			passwordActive	= pInputElement->isPasswordField();
			//-
			
			//New HTML5 input types (text field related)
			if(pInputElement->isEmailField())
				inputType = EA::WebKit::kInputTypeEmail;
			else if (pInputElement->isNumberField())
				inputType = EA::WebKit::kInputTypeNumber;
			else if(pInputElement->isSearchField())
				inputType = EA::WebKit::kInputTypeSearch;
			else if(pInputElement->isTelephoneField())
				inputType = EA::WebKit::kInputTypeTelephone;
			else if(pInputElement->isURLField())
				inputType = EA::WebKit::kInputTypeUrl;
			else if(pInputElement->isPasswordField())
				inputType = EA::WebKit::kInputTypePassword;

		}
/*			//Note by Arpit Baldeva: This will always come back as true but provided the commented out code here for the sack of clarity
		else if(pNode->hasTagName(WebCore::HTMLNames::textareaTag))
		{
			inputActive = enabled;
		}
*/

		HTMLElement* pElement = static_cast<HTMLElement*> (pNode);
		if(pElement->hasClass())
		{
			const WebCore::SpaceSplitString& classNames = pElement->classNames();
			for(int i = 0; i < EA::WebKit::kCountKeyBoardTypes; ++i)
			{
				if(classNames.contains(sKeyBoardClassMap[i].mKeyboardClass))
				{
					kbType = sKeyBoardClassMap[i].mKeyboardType;
					break;
				}
			}
//.........这里部分代码省略.........
开发者ID:Xertz,项目名称:EAWebKit,代码行数:101,代码来源:EditorClientEA.cpp


注:本文中的webcore::Node::isHTMLElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。