NS_IMETHODIMP inDeepTreeWalker::PreviousNode(nsIDOMNode **_retval) { if (!mCurrentNode || mStack.Length() == 1) { // Nowhere to go from here *_retval = nullptr; return NS_OK; } nsCOMPtr<nsIDOMNode> node; PreviousSibling(getter_AddRefs(node)); if (!node) { return ParentNode(_retval); } // Now we're positioned at our previous sibling. But since the DOM tree // traversal is depth-first, the previous node is its most deeply nested last // child. Just loop until LastChild() returns null; since the LastChild() // call that returns null won't affect our position, we will then be // positioned at the correct node. while (node) { LastChild(getter_AddRefs(node)); } NS_ADDREF(*_retval = mCurrentNode); return NS_OK; }
Platform::Platform() :m_Platform("Platform"), m_Model(""), m_Position() { m_Platform.AddComponent(&m_Model); m_Platform.AddComponent(&m_Position); m_Parent = New ParentNode(&m_Platform); m_Platform.AddComponent(m_Parent); }
enum MemoryDump::Parse_Result MemoryDump::parse(const char *buf, Node &node) { const char comma = ','; while (*buf == ' ' || *buf == '\t') buf++; if (*buf == '#' || *buf == '\0') return PARSE_COMMENT; //ignore any line beginning with '#' const char *p = std::strchr(buf, comma); if (p == nullptr) return PARSE_FAIL; auto skip = buf[1] == 'x' ? 2 : 0; auto s = std::string(buf + skip, p - buf - skip); size_t pos = 0; node.label = std::stoll(s, &pos, 16); /* skip '0x' */ buf = p + 1; p = std::strchr(buf, comma); if (p == nullptr) return PARSE_FAIL; s = std::string(buf, p - buf); uintptr_t plabel; if (s != "(nil)") { plabel = std::stoll(s.substr(s[1] == 'x' ? 2 : 0), &pos, 16); /* skip '0x' */ } else { plabel = 0; } buf = p + 1; p = std::strchr(buf, comma); if (p == nullptr) return PARSE_FAIL; node.node_type = static_cast<enum Reb_Kind>(std::stoi(std::string(buf, p - buf))); buf = p + 1; p = std::strchr(buf, comma); if (p == nullptr) return PARSE_FAIL; node.subtree_size = node.size = std::stoi(std::string(buf, p - buf)); buf = p + 1; p = std::strchr(buf, comma); if (p == nullptr) return PARSE_FAIL; auto edge = std::string(buf, p - buf); if (edge == "(null)") { edge.erase(); } buf = p + 1; node.parents.insert(ParentNode(plabel, edge)); if (!std::strcmp("(null)", buf)) { node.name.erase(); } else { node.name.str(buf); } return PARSE_OK; }
static void nodePropagateBBRoot(Node * thisNode) { if(thisNode == NULL) return; Node * next; if(thisNode->parent){ /* Si thisNode no es el nodo raĆz */ next = ParentNode(thisNode); nodeUpdateBB(thisNode); nodePropagateBBRoot(next); } }
void CWsSpriteBase::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const { if(iNext) iNext->SendState(aWindowTreeObserver); if(IsActivated()) { //Sprite NodeCreated must only be sent if activated aWindowTreeObserver.NodeCreated(*this, ParentNode()); aWindowTreeObserver.NodeExtentChanged(*this, Rect()); aWindowTreeObserver.NodeActivated(*this); } }
bool SceneObject::isDecendentNode(Node* const TheNode) const { Node* ParentNode(TheNode); while(ParentNode != NULL) { if(ParentNode == getNode()) { return true; } ParentNode = ParentNode->getParent(); } return false; }
void CWsWindow::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const { aWindowTreeObserver.NodeCreated(*this, ParentNode()); if(iFlags & EFlagActive) { aWindowTreeObserver.NodeExtentChanged(*this, FullRect()); aWindowTreeObserver.NodeActivated(*this); } if(!IsVisible()) { aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::EVisible, EFalse); } if(IsTrackingVisibleRegion()) { MWsWindowVisibilityNotifier* windowVisibilityNotifier = Screen()->WindowVisibilityNotifier(); if(windowVisibilityNotifier) windowVisibilityNotifier->RegisterWindow(*this); } if(HasAlpha()) { aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::EAlphaChannelTransparencyEnabled, ETrue); } if(IsNonFading()) { aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::ENonFading, ETrue); } if(IsTopClientWindow() && (iFlags&EFlagScreenDeviceInvalid) ) { aWindowTreeObserver.FlagChanged(*this, MWsWindowTreeObserver::EScreenDeviceValid, EFalse); } if(iAnimList) iAnimList->SendState(aWindowTreeObserver); CWsWindowBase::SendState(aWindowTreeObserver); }
NS_IMETHODIMP inDeepTreeWalker::NextNode(nsIDOMNode **_retval) { // First try our kids FirstChild(_retval); if (*_retval) { return NS_OK; } // Now keep trying next siblings up the parent chain, but if we // discover there's nothing else restore our state. #ifdef DEBUG nsIDOMNode* origCurrentNode = mCurrentNode; #endif uint32_t lastChildCallsToMake = 0; while (1) { NextSibling(_retval); if (*_retval) { return NS_OK; } nsCOMPtr<nsIDOMNode> parent; ParentNode(getter_AddRefs(parent)); if (!parent) { // Nowhere else to go; we're done. Restore our state. while (lastChildCallsToMake--) { nsCOMPtr<nsIDOMNode> dummy; LastChild(getter_AddRefs(dummy)); } NS_ASSERTION(mCurrentNode == origCurrentNode, "Didn't go back to the right node?"); *_retval = nullptr; return NS_OK; } ++lastChildCallsToMake; } NS_NOTREACHED("how did we get here?"); return NS_OK; }
void CWsSpriteBase::Activate() { if (iFlags&ESpriteDisabled) { iFlags&=~ESpriteDisabled; } if (iMembers->Count()>1) { QueueDeltaTimer(); iDeltaTimer->Activate(); } iFlags|=ESpriteActive; if(iWin) iWin->AddSprite(this); SetDirty(ETrue); Screen()->SpriteManager()->Schedule(this); if(IsFloating()) { Screen()->SpriteManager()->AddFloatingSprite(this); if (!Screen()->ChangeTracking()) ForceRedraw(); } // As custom text cursors are sprites (CWsCustomTextCursor) and can be activated/deactivated // on various different windows during their lifetime, when activating // a text cursor, we pretend it's just been created to give us the option // of specifying a new parent window. Normal sprites (CWsSprite) are // treated the same way just for consistency as it does no harm. MWsWindowTreeObserver* const windowTreeObserver = Screen()->WindowTreeObserver(); if (windowTreeObserver) { windowTreeObserver->NodeCreated(*this, ParentNode()); windowTreeObserver->NodeExtentChanged(*this, Rect()); windowTreeObserver->NodeActivated(*this); } }
void SceneGraphTreeModel::valueForPathChanged(TreePath path, const boost::any& newValue) { try { NodeUnrecPtr NewNode = boost::any_cast<NodeUnrecPtr>(newValue); NodeUnrecPtr OldNode = boost::any_cast<NodeUnrecPtr>(path.getLastPathComponent()); if(NewNode != NULL && OldNode != NULL && NewNode != OldNode && OldNode->getParent() != NULL) { NodeUnrecPtr ParentNode(OldNode->getParent()); if(ParentNode->replaceChildBy(OldNode, NewNode)) { UInt32 ChildIndex(ParentNode->findChild(NewNode)); produceTreeStructureChanged(path.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, newValue)); } } } catch(boost::bad_any_cast &ex) { SWARNING << "Bad any cast: " << ex.what() << std::endl; } }
// ----------------------------------------------------------------------------- // FindTargetElementL: A utility function that finds target element // and adjust the begin time. // // Returns: TBool ETrue if target is set. // EFalse if target is not found. // ----------------------------------------------------------------------------- // TBool CSvgDiscardElementImpl::FindTargetElementL() { if (iTargetElement) return ETrue; // Target could be set from one of the following ways: // 1) Defined as SyncBased value. ==> get element // 2) xlink-href defined. ==> get element // 3) Invalid element id ==> Ignore // 4) No specified xlink-href nor other element id. ==> Use parent if ( iHrefValueDefined ) { // Case 2 & 3 TPtrC lPtr = iTargetId->Des(); iTargetElement = ( CSvgElementImpl * ) ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById(lPtr); if (iTargetElement == NULL) { // Case 3 // Ignore and remove myself later. iRemoveMyself = ETrue; return EFalse; } } else // Case 4 { // Set parent to target only when the parent is an animation element iTargetElement = ( CSvgElementImpl * ) ParentNode(); } // Target element should be determined by now. // Check to see if the target element is animatable. // If not, remove myself. // Calculate begin time. if ( iSyncValueDefined ) { // Get reference target element iRefTargetElement = ( CSvgElementImpl * ) ((CSvgDocumentImpl*)iOwnerDocument)->GetElementById(iBeginSyncElementId); // Only Syncbased begin time if (!iEventValueDefined) { // If specified element doesn't exist or the element is not animated, // remove myself. if ((iRefTargetElement == NULL) /*|| !IsAnimationElement(iRefTargetElement)*/) { // No referenced element or not animatable element (no begin/end attr) // ==> Ignore and remove myself later. iRemoveMyself = ETrue; return EFalse; } // re-calculate begin time. e.g. id1.start+5s if (iBeginReferenceEvent == ESvgEventBeginEvent) { iAbsoluteBeginTime += ((CSvgAnimationBase*)iRefTargetElement)->GetAbsoluteBeginTime(); } else if (iBeginReferenceEvent == ESvgEventEndEvent) { iAbsoluteBeginTime += ((CSvgAnimationBase*)iRefTargetElement)->GetEndTime(); } } else // iEventValueDefined is TRUE { // Listen external events ((CSvgDocumentImpl*) iOwnerDocument)->AddToEventReceiverListL(iRefTargetElement, KSvgEventMaskExternalUI); } } else if (iEventValueDefined) { // Listen external events ((CSvgDocumentImpl*) iOwnerDocument)->AddToEventReceiverListL(iTargetElement, KSvgEventMaskExternalUI); } return ETrue; // Set Target element }
// ----------------------------------------------------------------------------- // ReceiveEventL: The implemented function will be called whenever subscribed // events are received. // // From MSvgEventReceiver // // Return: TBool ETrue if redraw is needed // EFalse if redraw is not needed // ----------------------------------------------------------------------------- // TBool CSvgDiscardElementImpl::ReceiveEventL( MSvgEvent* aEvent ) { if (iRemoveMyself) { // Two reasons to remove myself. // 1) when discard element is not sepcified inside of the target // element so the object is not removed automatically along with // target element. // 2) Invalid begin time iTargetElement = ( CSvgElementImpl * ) ParentNode(); iTargetElement->RemoveChild(this); delete this; return EFalse; } // Looking for target as soon as first event received. Also adject time // according to timeing attribute. if (!FindTargetElementL()) { // Target not found, exit and remove myself next time return EFalse; } // Target element should be identified by now. CSvgEngineImpl* engine = ((CSvgDocumentImpl*)iOwnerDocument)->Engine(); if (engine == NULL) { return EFalse; } TInt32 lEngineCurrentTime = engine->CurrentTIme(); // User input event if (aEvent->EventType() == ESvgEngineEventKeyPress) { MSvgUiKeyEvent* evt = ( MSvgUiKeyEvent* ) aEvent; if (evt->KeyCode() == iKeyValue) { // Remove target immediately RemoveTargetElement(); engine->RedrawL(); return ETrue; } return EFalse; } // Timer event if (aEvent->EventMask() == KSvgEventMaskTimer) { if (lEngineCurrentTime >= iAbsoluteBeginTime) { // Time to remove target RemoveTargetElement(); } } // Internal event else if ((aEvent->EventMask() == KSvgEventMaskInternal ) && (!iRefBeginTimeSet)) { MSvgInternalEvent* evt = ( MSvgInternalEvent* ) aEvent; TSvgEvent s_evt = evt->SvgEvent(); if (s_evt == iBeginReferenceEvent) { // Event other than AccessKey // Check to see if there is a clock associated with the event. if (s_evt == iBeginReferenceEvent) { // This is some form of event+(-)clock so delay removing // Note that once the reference time is set, the absolutetime // can't be changed with other events. if (iRefTargetElement != NULL) { // This is a syncbased event if (evt->ObjectAddress() == iRefTargetElement) { iAbsoluteBeginTime = lEngineCurrentTime + iRefBeginTime; iRefBeginTimeSet = ETrue; return EFalse; } } else { // Not syncbased event if (evt->ObjectAddress() == iTargetElement) { iAbsoluteBeginTime = lEngineCurrentTime + iRefBeginTime; iRefBeginTimeSet = ETrue; return EFalse; } } } // if (s_evt == iBeginReferenceEvent)... else { // No clock assoicated with the event. if (iRefTargetElement != NULL) { // This is a syncbased event if (evt->ObjectAddress() == iRefTargetElement) { // Remove target immediately RemoveTargetElement(); } } // Not syncbased event else if (evt->ObjectAddress() == iTargetElement) { // Remove target immediately RemoveTargetElement(); } } } // if (s_evt == iBeginReferenceEvent)... } //if ((aEvent->EventMask() == KSvgEventMaskInte... else { // Not interested event return EFalse; } // return true to be redrawn return ETrue; }