コード例 #1
0
    const GumboNode* ParserUtils::getElementById(const GumboNode* node,
            GumboTag elementTag,
            const string& idValue)
    {
        if (node == nullptr || node->type != GUMBO_NODE_ELEMENT)
        {
            return nullptr;
        }

        if (node->v.element.tag == elementTag)
        {
            if (getAttribute(node, "id") == idValue)
            {
                return node;
            }
        }

        const GumboVector* childrenList = &node->v.element.children;
        for (unsigned int childIndex = 0; childIndex < childrenList->length; ++childIndex)
        {
            const GumboNode* child = static_cast<GumboNode*>(childrenList->data[childIndex]);
            const GumboNode* currentResult = getElementById(child, elementTag, idValue);
            if (currentResult != nullptr)
                return currentResult;
        }

        return nullptr;
    }
コード例 #2
0
ファイル: conn.c プロジェクト: gmarciani/librusp
Connection *getConnectionById(const ConnectionId connid) {
	Connection *conn = NULL;

	conn = (Connection *) getElementById(&CONPOOL, connid);

	return conn;		
}
コード例 #3
0
JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStringRef elementId)
{
    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
    JSObjectRef element = getElementById(mainFrame, elementId);
    if (!element)
        return 0;
    WKRetainPtr<WKStringRef> value(AdoptWK, WKBundleFrameCopyCounterValue(mainFrame, const_cast<JSObjectRef>(element)));
    return toJS(value);
}
コード例 #4
0
  QList <QWebElement> ChromeDOM::getInitialElements()
  {
    m_renderer->clearRenderList();
    QWebElement test = getElementById("TestTableCell9");
    //qDebug() << "TEST ELEMENT:" << test.toPlainText();
    m_height = 0;
    QWebElement doc = m_page->mainFrame()->documentElement();
#if QT_VERSION < 0x040600 //TBD: Do we care, given that the dom api is not officially supported before 4.6?
    return doc.findAll(".GinebraSnippet");
#else
    return doc.findAll(".GinebraSnippet").toList();
#endif
  }
コード例 #5
0
void ofxLayout::applyAnimations(){
    for(pair<string, ofxAnimationInstance*> it : *am.getAnimationInstances()){
        bool hasState = false;
        bool isID = false;
        bool isClass = false;
        string selector = "";
        string state = "default";
        
        char c = it.first[0];
        
        if(c == '#'){
            isID = true;
        }
        else if(c == '.'){
            isClass = true;
        }
        
        for(char c : it.first){
            if(c == '#' || c == '.'){
                continue;
            }
            else if(c == ':'){
                state = "";
                hasState = true;
                continue;
            }
            
            if(hasState){
                state += c;
            }
            else{
                selector += c;
            }
        }
        
        if(isID){
            ofxLayoutElement* element = getElementById(selector);
            if(element && !element->hasState(state)){
                element->addState(state, it.second);
            }
        }
        else if(isClass){
            set<ofxLayoutElement*> classElements = getElementsByClass(selector);
            for(ofxLayoutElement* element : classElements){
                if(element && !element->hasState(state)){
                    element->addState(state, am.cloneAnimationInstance(it.second->getID()));
                }
            }
        }
    }
}
コード例 #6
0
 QList<CachedHandler> ChromeDOM::getCachedHandlers(const QString &elementId, const QRectF & ownerArea)
 {
   QWebElement snippet = getElementById(elementId);
   QList <QWebElement> controls =  snippet.findAll(".GinebraCached").toList();
   QList <CachedHandler> handlers;
   for (int i = 0; i < controls.size(); i++){
     QWebElement elem = controls.at(i);
     //Element rectangle relative to snippet, so we can handle mouse events relative to snippet
     //qDebug() << "====> Owner X: " << ownerArea.x() << " Owner Width: " << ownerArea.width() << " Elem X: " << elem.geometry().x() << " Elem Width: " << elem.geometry().width();
     QRectF elemRect(elem.geometry().x() - ownerArea.x(), elem.geometry().y() - ownerArea.y(), elem.geometry().width(), elem.geometry().height());
     //NB: For now we handle only onclick from cache. Should add at least long-press too.
     CachedHandler handler(elem.attribute("id"), elem.attribute("data-GinebraOnClick"), elemRect, m_chrome, elem.attribute("data-GinebraTargetView"));
     //qDebug() << "Cached handler" << handler.elementId() << ": "  << handler.script() << ": "  << handler.rect();
     handlers.append(handler);
   }
   return handlers;
 }
コード例 #7
0
ファイル: Document.cpp プロジェクト: aiyer/tinyxmlpp
  /**
   * Recursive function called by the actual getElementById, that is exposed to the user.
   *
   * @param node A pointer to the current node in the recursion
   * @param id The string being searched for in the attribute values.
   * @return A pointer to the Node which has an attribute value that matches id
   */
  Node* Document::getElementById (Node* node, const std::string& id) {
    if (node != nullptr) {

      vector<Attribute*> attributes = static_cast<ElementNode*>(node)->getAttributes();
      for (int i = 0; i < attributes.size(); ++i) {
	Attribute* attrib = attributes[i];
	if (attrib->getValue() == id) {
	  return node;
	}
      }

      vector<Node*> children = node->getChildren();
      for (int i = 0; i < children.size(); ++i) {
	if (dynamic_cast<ElementNode*>(children[i]) == NULL)
	  continue;
	Node* temp = getElementById(children[i], id);
	if(!temp)
	  return temp;
      }

    }
    return nullptr;	
  }
コード例 #8
0
 QString ChromeDOM::getElementAttribute(const QString &id, const QString &attribute)
 {
   return getElementById(id).attribute(attribute);
 }
コード例 #9
0
 QRect ChromeDOM::getElementRect(const QString &id)
 {
   return getElementById(id).geometry();
 }
コード例 #10
0
ファイル: Document.cpp プロジェクト: aiyer/tinyxmlpp
 /**
  * Function to find the first node in the XML DOM object that has an attribute with the value provided as 'id'. This function
  * in turn calls the private getElementById function that takes in a Node* and std::string as arguments.
  *
  * @param id The string being searched for inside attribute values.
  * @return A pointer to an ElementNode which contains an attribute that has the value = id
  */
 ElementNode* Document::getElementById (const std::string& id) {
   return static_cast<ElementNode*>(getElementById(this->rootElement, id));
 }