Example #1
0
int SceneGraph::getNNodes() const
{
    int nNode = 0;
    for (Node *node = getNodes(); node; node = node->next())
        nNode++;
    return nNode;
}
Example #2
0
bool AStar::Step(sf::RectangleShape board[])
{
	Node* pCurrentNode;
	if (!qOpenList.empty())
	{
		pCurrentNode = VisitNode();
	}
	else
	{ 
		std::cout << "Can't find a path" << std::endl;
		return true;
	}

	UpdateBoardGraphic(board);

	if (pCurrentNode == tRoot[iEndNode])
	{
		PrintPath(pCurrentNode, board);
		return true;
	}

	board[pCurrentNode->X()*yMax + pCurrentNode->Y()].setFillColor(sf::Color::Red);

	return false;
}
// (Reação): Resolve as EDOs associadas para cada volume de controle da rede
void solveEDO (Graph *g, double t, int k, Func *func, int num_eq)
{
	int i;
	double f[num_eq];
	Volume *v;
	Node *ptr = g->getListNodes();
	while (ptr != NULL)
	{
		v = ptr->getVolume();
		// Verifica se a celula se polarizou novamente
		if (v->y_old[0] < -80)
			ptr->setRetro(false);
		for (i = 0; i < num_eq; i++)
		{
			// Calcular o potencial transmembranico intermediário -> V_{i/2} = V*
			if (i == 0)
			{
				f[0] = func[0](k,t,v->y_old)*dt;
				v->V_star = v->y_old[0] + f[0];
			}
			// gate -> n -> n+1
			else
			{
				f[i] = func[i](k,t,v->y_old)*dt;
				v->y_new[i] = v->y_old[i] + f[i];
			}
		}
		ptr = ptr->getNext();
	}
}
Example #4
0
bool Edge::setNodes(Node * parent)
{ // set relations only
  const char * p1;
  char * p2;
  Node * n;
  char b[MNL];
    // start name - remove connector part
  strncpy(b, name1, MNL);
  p2 = b;
  p1 = p2;
  n = parent;
  while (p2 != NULL)
  {
    p1 = strsep(&p2, ".");
    n = n->getChild(p1);
  }
  node1 = n;
    // end name - remove connector part
  strncpy(b, name2, MNL);
  p2 = b;
  p1 = p2;
  n = parent;
  while (p2 != NULL)
  {
    p1 = strsep(&p2, ".");
    n = n->getChild(p1);
  }
  node2 = n;
  return node1 != NULL and node2 != NULL;
}
Example #5
0
static Node* enclosingListChild(Node* node, Node* listNode)
{
    Node* listChild = enclosingListChild(node);
    while (listChild && enclosingList(listChild) != listNode)
        listChild = enclosingListChild(listChild->parentNode());
    return listChild;
}
Example #6
0
    inline uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile)
    {
        /* handle special case - when current tile is the destination tile */
        if (dst_tile == v->tile) {
            /* distance is zero in this case */
            return 0;
        }

        if (!SetOriginFromVehiclePos(v)) return UINT_MAX;

        /* get available trackdirs on the destination tile */
        Yapf().SetDestination(v);

        /* if path not found - return distance = UINT_MAX */
        uint dist = UINT_MAX;

        /* find the best path */
        if (!Yapf().FindPath(v)) return dist;

        Node *pNode = Yapf().GetBestNode();
        if (pNode != NULL) {
            /* path was found
             * get the path cost estimate */
            dist = pNode->GetCostEstimate();
        }

        return dist;
    }
Example #7
0
Node* Semester::CreateSplit(Node *parent){
  Node *retnode = new Node(NODE_SPLIT);
  parent->SetChild(retnode);
  retnode->SetParent(parent);
  total_width += 250;
  return retnode;
}//createSplit
Example #8
0
void TreeView::insertNode(NewNodeDialog *dlg, bool insert)
{
	if (insert)
	{
		QModelIndex index = dlg->getIndex();
		int row = dlg->getRow();
		if (model->insertRow(row, index))
		{
			int column = 0;
			QModelIndex child = model->index(row, column, index);

			model->setData(child, QVariant(dlg->getCaption()), Qt::EditRole);

			Node *item = model->getItem(child);
			item->setContent(dlg->getContent());
			item->addLabels(dlg->getLabels());
			connect(item, SIGNAL(changed(Node*)), Controller::create()->getDataStore(), SLOT(saveNode(Node*)));
			Controller::create()->getDataStore()->addNode(item);

			tree->selectionModel()->setCurrentIndex(model->index(row, column, index), QItemSelectionModel::ClearAndSelect);

			updateActions();
		}
	}

	Controller::create()->getMainWindow()->removeDialog(dlg);
	dlg->deleteLater();
}
Example #9
0
String HitTestResult::innerTextIfTruncated(TextDirection& dir) const
{
    for (Node* truncatedNode = m_innerNode.get(); truncatedNode; truncatedNode = truncatedNode->parentNode()) {
        if (!truncatedNode->isElementNode())
            continue;

        if (RenderObject* renderer = truncatedNode->renderer()) {
            if (renderer->isRenderBlock()) {
                RenderBlock* block = toRenderBlock(renderer);
                if (block->style()->textOverflow()) {
                    for (RootInlineBox* line = block->firstRootBox(); line; line = line->nextRootBox()) {
                        if (line->hasEllipsisBox()) {
                            dir = block->style()->direction();
                            return toElement(truncatedNode)->innerText();
                        }
                    }
                }
                break;
            }
        }
    }

    dir = LTR;
    return String();
}
Example #10
0
 void del(int key){//删除一个值
     if (root == NIL)
         return;
     Node *x = search(key), *y;
     if (x == NIL)
         return;
     if (x->cnt > 1){
         x->cnt--;
         x->rs();
         return;
     }
     else if (x->ch[0] == NIL && x->ch[1] == NIL){
         init();
         return;
     }
     else if (x->ch[0] == NIL){
         root = x->ch[1];
         x->ch[1]->pnt = NIL;
         return;
     }
     else if (x->ch[1] == NIL){
         root = x->ch[0];
         x->ch[0]->pnt = NIL;
         return;
     }
     y = searchmin(x->ch[1]);
     y->pnt = NIL;
     y->ch[0] = x->ch[0];
     x->ch[0]->pnt = y;
     y->rs();
     root = y;
 }
void WebPageSerializerImpl::collectTargetFrames()
{
    ASSERT(!m_framesCollected);
    m_framesCollected = true;

    // First, process main frame.
    m_frames.append(m_specifiedWebFrameImpl);
    // Return now if user only needs to serialize specified frame, not including
    // all sub-frames.
    if (!m_recursiveSerialization)
        return;
    // Collect all frames inside the specified frame.
    for (int i = 0; i < static_cast<int>(m_frames.size()); ++i) {
        WebFrameImpl* currentFrame = m_frames[i];
        // Get current using document.
        Document* currentDoc = currentFrame->frame()->document();
        // Go through sub-frames.
        RefPtr<HTMLAllCollection> all = currentDoc->all();
        for (Node* node = all->firstItem(); node; node = all->nextItem()) {
            if (!node->isHTMLElement())
                continue;
            Element* element = static_cast<Element*>(node);
            WebFrameImpl* webFrame =
                WebFrameImpl::fromFrameOwnerElement(element);
            if (webFrame)
                m_frames.append(webFrame);
        }
    }
}
Example #12
0
void SceneGraph::recomputeBoundingBox()
{
    Node	*node;
    float	center[3];
    float	size[3];
    float	m4[4][4];
    SFMatrix mx;

    BoundingBox bbox;

    for (node=getNodes(); node; node=node->nextTraversal()) {
        if (node->isBoundedGroupingNode()) {
            BoundedGroupingNode *gnode = (BoundedGroupingNode *)node;
            gnode->getBoundingBoxCenter(center);
            gnode->getBoundingBoxSize(size);
            // Thanks for Peter DeSantis (07/22/04)
            gnode->getTransformMatrix(m4);
            mx.setValue(m4);
            bbox.addBoundingBox(&mx, center, size);
        }
        else if (node->isGeometry3DNode()) {
            Geometry3DNode *gnode = (Geometry3DNode *)node;
            gnode->getBoundingBoxCenter(center);
            gnode->getBoundingBoxSize(size);
            // Thanks for Peter DeSantis (07/22/04)
            gnode->getTransformMatrix(m4);
            mx.setValue(m4);
            bbox.addBoundingBox(&mx, center, size);
        }
    }

    setBoundingBox(&bbox);
}
Example #13
0
bool SceneGraph::saveXML(const wchar_t *filename, void (*callbackFn)(int nNode, void *info), void *callbackFnInfo)
{
    char nonsense[100];
    wcstombs(nonsense,filename,100);
    std::ofstream outputFile(nonsense);

    if (!outputFile)
        return false;

    uninitialize();

    outputFile << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
    outputFile << "<X3D>" << std::endl;
    outputFile << "<Scene>" << std::endl;

    int nNode = 0;
    for (Node *node = getNodes(); node; node = node->next()) {
        node->outputXML(outputFile, 0);
        nNode++;
        if (callbackFn)
            callbackFn(nNode, callbackFnInfo);
    }
    for (Route *route = getRoutes(); route; route = route->next()) {
        route->outputXML(outputFile);
    }

    initialize();

    outputFile << "</Scene>" << std::endl;
    outputFile << "</X3D>" << std::endl;

    return true;
}
Example #14
0
bool SceneGraph::save(const wchar_t *filename, void (*callbackFn)(int nNode, void *info), void *callbackFnInfo)
{
    char nonsense[100];
    wcstombs(nonsense, filename, 100);
    std::ofstream outputFile(nonsense);

    if (!outputFile)
        return false;

    uninitialize();

    outputFile << "#VRML V2.0 utf8" << std::endl;

    int nNode = 0;
    for (Node *node = getNodes(); node; node = node->next()) {
        node->output(outputFile, 0);
        nNode++;
        if (callbackFn)
            callbackFn(nNode, callbackFnInfo);
    }
    for (Route *route = getRoutes(); route; route = route->next()) {
        route->output(outputFile);
    }

    initialize();

    return true;
}
Example #15
0
bool Game::init()
{
	if (!Layer::init()){
		return false;
	}

	step = 0;
	starEndFrame[0] = 18;
	starEndFrame[1] = 33;
	starEndFrame[2] = 60;

	swallowNode = Node::create();
	swallowNode->setContentSize(Director::getInstance()->getVisibleSize());
	this->addChild(swallowNode, 0);

	gameNode = CSLoader::createNode("bg6_Secene.csb");
	this->addChild(gameNode);
	//UI 
	gameUIMgr = new GameUIMgr(gameNode->getChildByTag(354), this);

	//GAME 
	gameArea = GameArea::create(gameUIMgr, guanQiaName[step]);
	gameNode->addChild(gameArea, Game::ZORDER_AREA, Game::TAG_AREA);

	//STAR
	Node* starNode = gameNode->getChildByTag(962);
	starNode->setZOrder(2);
	starAtl = dynamic_cast<ActionTimeline*>(starNode->getActionByTag(starNode->getTag()));
	starAtl->gotoFrameAndPause(0);

	initTouch();

	return true;
}
// used by table cells to share style decls created by the enclosing table.
CSSMutableStyleDeclaration* HTMLTableCellElement::additionalAttributeStyleDecl()
{
    Node* p = parentNode();
    while (p && !p->hasTagName(tableTag))
        p = p->parentNode();
    return p ? static_cast<HTMLTableElement*>(p)->getSharedCellDecl() : 0;
}
// @brief  : PMDファイルの取り出し
// @param  : 親クラス
//         : 描画するのか?
//         : ファイル名
//--------------------------------------------------------------------
_3d::PMDNoBone *PMDNoBoneManagerDx9::Load( IDraw *_parent, bool _is_draw, const std::string &_file_name )
{
    assert(!_file_name.empty());

    // ファイルの検索
    PMDDataDx9 *data = nullptr;
    Node *i = Begin();
    while(i)
    {
        data = dynamic_cast<PMDDataDx9 *>(i);
        std::string name = data->m_FilePass;
        if( name.compare(_file_name) == 0 ) break;
        i = i->Next();
        data = nullptr;
    }

    // ファイルの作成
    if(!data)
    {
        data = new PMDDataDx9(_file_name);
    }

    // モデルの作成
    PMDNoBoneDx9 *re = new PMDNoBoneDx9(data,_parent,_is_draw);
    PMDMeshDx9 *mesh = new PMDMeshDx9(data,re,true);
    for(unsigned i = 0 ; i < data->m_MaxMaterial ; ++i)
    {
        new PMDMaterialDx9(&data->m_Material[i],data,mesh,true);
    }

    // 作成
    return re;
}
Example #18
0
/* Copy Constructor
   Makes a complete copy of the function set and the terminal set too */
GPConfig::GPConfig(GPConfig &c) : 
                       minDepth(c.minDepth), maxDepth(c.maxDepth),
                       funcSet(this), termSet(this),
                       randomNumGenerator(c.randomNumGenerator),
                       crossoverOperator(c.crossoverOperator), mutationOperator(c.mutationOperator),
                       selectionOperator(c.selectionOperator), fitnessObject(c.fitnessObject),
                       programGenerator(c.programGenerator)
{
   int i;
   Node *tmp;
   if (c.funcSet.size() > 0)
   {
      for (i=0;i<c.funcSet.size();i++)
      {
         tmp = c.funcSet.getNodeByNumber(i);
         funcSet.addNodeToSet(tmp->getReturnType(),c.funcSet.getGenFunction(i));
      }
   }

   if (c.termSet.size() > 0)
   {
      for (i=0;i<c.termSet.size();i++)
      {
         tmp = c.termSet.getNodeByNumber(i);
         termSet.addNodeToSet(tmp->getReturnType(),c.termSet.getGenFunction(i));
      }
   }
}
// FIXME: Once https://bugs.webkit.org/show_bug.cgi?id=52963 lands, this should
// be greatly improved. See https://bugs.webkit.org/show_bug.cgi?id=54025.
PassRefPtr<EventTarget> EventDispatcher::adjustRelatedTarget(Event* event, PassRefPtr<EventTarget> prpRelatedTarget)
{
    if (!prpRelatedTarget)
        return 0;

    RefPtr<Node> relatedTarget = prpRelatedTarget->toNode();
    if (!relatedTarget)
        return 0;

    Node* target = m_node.get();
    if (!target)
        return prpRelatedTarget;

    ensureEventAncestors(event);

    // Calculate early if the common boundary is even possible by looking at
    // ancestors size and if the retargeting has occured (indicating the presence of shadow DOM boundaries).
    // If there are no boundaries detected, the target and related target can't have a common boundary.
    bool noCommonBoundary = ancestorsCrossShadowBoundaries(m_ancestors);

    Vector<Node*> relatedTargetAncestors;
    Node* outermostShadowBoundary = relatedTarget.get();
    for (Node* n = outermostShadowBoundary; n; n = n->parentOrHostNode()) {
        if (isShadowRootOrSVGShadowRoot(n))
            outermostShadowBoundary = n->parentOrHostNode();
        if (!noCommonBoundary)
            relatedTargetAncestors.append(n);
    }

    // Short-circuit the fast case when we know there is no need to calculate a common boundary.
    if (noCommonBoundary)
        return outermostShadowBoundary;

    return adjustToShadowBoundaries(relatedTarget.release(), relatedTargetAncestors);
}
v8::Handle<v8::Value> V8Clipboard::setDragImageCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Clipboard.setDragImage()");
    Clipboard* clipboard = V8Clipboard::toNative(args.Holder());

    if (!clipboard->isForDragging())
        return v8::Undefined();

    if (args.Length() != 3)
        return throwError("setDragImage: Invalid number of arguments", V8Proxy::SyntaxError);

    int x = toInt32(args[1]);
    int y = toInt32(args[2]);

    Node* node = 0;
    if (V8Node::HasInstance(args[0]))
        node = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0]));

    if (!node || !node->isElementNode())
        return throwError("setDragImageFromElement: Invalid first argument");

    if (static_cast<Element*>(node)->hasLocalName(HTMLNames::imgTag) && !node->inDocument())
        clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
    else
        clipboard->setDragImageElement(node, IntPoint(x, y));

    return v8::Undefined();
}
static void clearSelectionIfNeeded(Frame* oldFocusedFrame, Frame* newFocusedFrame, Node* newFocusedNode)
{
    if (!oldFocusedFrame || !newFocusedFrame)
        return;
        
    if (oldFocusedFrame->document() != newFocusedFrame->document())
        return;
    
    SelectionController* s = oldFocusedFrame->selection();
    if (s->isNone())
        return;

    bool caretBrowsing = oldFocusedFrame->settings()->caretBrowsingEnabled();
    if (caretBrowsing)
        return;

    Node* selectionStartNode = s->selection().start().node();
    if (selectionStartNode == newFocusedNode || selectionStartNode->isDescendantOf(newFocusedNode) || selectionStartNode->shadowAncestorNode() == newFocusedNode)
        return;
        
    if (Node* mousePressNode = newFocusedFrame->eventHandler()->mousePressNode())
        if (mousePressNode->renderer() && !mousePressNode->canStartSelection())
            if (Node* root = s->rootEditableElement())
                if (Node* shadowAncestorNode = root->shadowAncestorNode())
                    // Don't do this for textareas and text fields, when they lose focus their selections should be cleared
                    // and then restored when they regain focus, to match other browsers.
                    if (!shadowAncestorNode->hasTagName(inputTag) && !shadowAncestorNode->hasTagName(textareaTag))
                        return;
    
    s->clear();
}
bool UITextFieldTest_Editor::init()
{
    if (UIScene_Editor::init())
    {
        Node* node = CSLoader::createNode("cocosui/UIEditorTest/UITextField/res.csb");
        Node* child = node->getChildByTag(5);
        child->removeFromParent();
        _layout = static_cast<Layout*>(child);
        _touchGroup->addChild(_layout);
        
        this->configureGUIScene();
        
        _displayValueLabel = Text::create();
        _displayValueLabel->setFontName("fonts/Marker Felt.ttf");
        _displayValueLabel->setFontSize(30);
        _displayValueLabel->setString("No event");
        _displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
                                              _layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
        _touchGroup->addChild(_displayValueLabel, 20);
        
        return true;
    }
    
    return false;
}
static inline Node* lastDescendant(const ContainerNode& node)
{
    Node* descendant = node.lastChild();
    for (Node* current = descendant; current; current = current->lastChild())
        descendant = current;
    return descendant;
}
void InputMethodController::setCompositionFromExistingText(const Vector<CompositionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd)
{
    Element* editable = m_frame.selection().rootEditableElement();
    Position base = m_frame.selection().base().downstream();
    Node* baseNode = base.anchorNode();
    if (editable->firstChild() == baseNode && editable->lastChild() == baseNode && baseNode->isTextNode()) {
        m_compositionNode = nullptr;
        m_customCompositionUnderlines.clear();

        if (base.anchorType() != Position::PositionIsOffsetInAnchor)
            return;
        if (!baseNode || baseNode != m_frame.selection().extent().anchorNode())
            return;

        m_compositionNode = toText(baseNode);
        RefPtrWillBeRawPtr<Range> range = PlainTextRange(compositionStart, compositionEnd).createRange(*editable);
        m_compositionStart = range->startOffset();
        m_compositionEnd = range->endOffset();
        m_customCompositionUnderlines = underlines;
        size_t numUnderlines = m_customCompositionUnderlines.size();
        for (size_t i = 0; i < numUnderlines; ++i) {
            m_customCompositionUnderlines[i].startOffset += m_compositionStart;
            m_customCompositionUnderlines[i].endOffset += m_compositionStart;
        }
        if (baseNode->renderer())
            baseNode->renderer()->paintInvalidationForWholeRenderer();
        return;
    }

    Editor::RevealSelectionScope revealSelectionScope(&editor());
    SelectionOffsetsScope selectionOffsetsScope(this);
    setSelectionOffsets(PlainTextRange(compositionStart, compositionEnd));
    setComposition(m_frame.selectedText(), underlines, 0, 0);
}
Example #25
0
List<Map<String, String> > XPathI::evaluateToAttributesMapList(const String& text, 
															   Document document) throw (Exception)
{
	List<Node> nodelist = evaluateToNodeList(text, document);
	List<Map<String, String> > result = new ArrayListI<Map<String, String> >(nodelist->size());
	Iterator<Node> n = nodelist->iterator();
	while (n->hasNext())
	{
		Node node = n->next();
		Map<String, String> attr = new LinkedHashMapI<String, String>();
		try
		{
			if (node->hasAttributes())
			{
				xercesc::DOMNamedNodeMap* namednodemap = node->getAttributes();
				for (XMLSize_t i = 0; i < namednodemap->getLength(); ++i)
				{
					xercesc::DOMAttr* item = (xercesc::DOMAttr*) namednodemap->item(i);
					attr->put(String(item->getName(), 0), String(item->getValue(), 0));
				}
			}
			result->add(attr);
		}
		catch (const xercesc::DOMException& e)
		{
			throw XPathExpressionException(WITHDETAILS(String(e.getMessage(), 0)));
		}
	}
	return result;
}
/* 
 * Main method to call the prefix generation
 * @Params A - Vector of strings
 */
vector<string> Solution::prefix(vector<string> &A) {
    // create a empty vector for results
    vector<string> result;
    
    // clear the global hashmap
    res.clear();
    
    // return empty vector in case A is empty
    if(A.size() == 0) return result;
    
    // Generate the prefix tree
    Node* Tree = new Node("*");
    for(int i = 0; i < A.size(); i++) {
        Tree->insertChild(A[i]);
    }
    
    // Traverse the tree to generate hashmap
    // Not needed if the order of prefix isn't important
    traverse(Tree, "");
    
    // generate ordered result from hashmap
    for(int i = 0; i < A.size(); i++) {
        result.push_back(res[A[i]]);
    }
    
    return result;
}
Example #27
0
Node* AStar::VisitNode()
{
    Node* pCurrentNode = qOpenList.front();
    qOpenList.pop_front();
    pCurrentNode->eState = NodeState::Closed;

    std::cout << "Visiting Node(" << pCurrentNode->X() << "," << pCurrentNode->Y() << ")...\n";
    
    std::cout << "  Adding Adj Node...\n";
    
    std::list<Node*>::iterator iAdjEnd(pCurrentNode->lAdj.end());
    for(std::list<Node*>::iterator iter = pCurrentNode->lAdj.begin(); iter != iAdjEnd; ++iter)
    {
        AddNodeToOpenList(pCurrentNode, *iter);
    }
    std::cout << "  Adding Adj Node...DONE\n";
    
    
    std::cout << "  OPENLIST - START Elements: " << qOpenList.size() << "\n";
    std::list<Node*>::iterator iEnd(qOpenList.end());
    for(std::list<Node*>::iterator iter = qOpenList.begin(); iter != iEnd;++iter)
    {
        std::cout << "      (" << (*iter)->X() << "," << (*iter)->Y() << ") F = " <<  (*iter)->iF << " = G(" << (*iter)->iG << ") + H(" << (*iter)->iH << ")\n";
    }   
    std::cout << "  OPENLIST - END \n";
    
    std::cout << "Visiting Node(" << pCurrentNode->X() << "," << pCurrentNode->Y() << ")... DONE\n";
    
    return pCurrentNode;
}
void RenderListItem::updateListMarkerNumbers()
{
    Node* listNode = enclosingList(this);
    ASSERT(listNode && listNode->renderer());
    if (!listNode || !listNode->renderer())
        return;

    RenderObject* list = listNode->renderer();
    RenderObject* child = nextInPreOrder(list);
    while (child) {
        if (child->node() && isList(child->node())) {
            // We've found a nested, independent list: nothing to do here.
            child = child->nextInPreOrderAfterChildren(list);
            continue;
        }

        if (child->isListItem()) {
            RenderListItem* item = toRenderListItem(child);

            if (!item->m_isValueUpToDate) {
                // If an item has been marked for update before, we can safely
                // assume that all the following ones have too.
                // This gives us the opportunity to stop here and avoid
                // marking the same nodes again.
                break;
            }

            item->updateValue();
        }

        child = child->nextInPreOrder(list);
    }
}
Example #29
0
void RenderListItem::updateListMarkerNumbers()
{
    // If distribution recalc is needed, updateListMarkerNumber will be re-invoked
    // after distribution is calculated.
    if (node()->document().childNeedsDistributionRecalc())
        return;

    Node* listNode = enclosingList(this);
    ASSERT(listNode);

    bool isListReversed = false;
    HTMLOListElement* oListElement = isHTMLOListElement(listNode) ? toHTMLOListElement(listNode) : 0;
    if (oListElement) {
        oListElement->itemCountChanged();
        isListReversed = oListElement->isReversed();
    }

    // FIXME: The n^2 protection below doesn't help if the elements were inserted after the
    // the list had already been displayed.

    // Avoid an O(n^2) walk over the children below when they're all known to be attaching.
    if (listNode->needsAttach())
        return;

    for (RenderListItem* item = previousOrNextItem(isListReversed, listNode, this); item; item = previousOrNextItem(isListReversed, listNode, item)) {
        if (!item->m_isValueUpToDate) {
            // If an item has been marked for update before, we can safely
            // assume that all the following ones have too.
            // This gives us the opportunity to stop here and avoid
            // marking the same nodes again.
            break;
        }
        item->updateValue();
    }
}
Example #30
0
int SceneGraph::getNAllNodes() const
{
    int nNode = 0;
    for (Node *node = getNodes(); node; node = node->nextTraversal())
        nNode++;
    return nNode;
}