Пример #1
0
nsresult
nsTextControlFrame::OffsetToDOMPoint(PRInt32 aOffset,
                                     nsIDOMNode** aResult,
                                     PRInt32* aPosition)
{
  NS_ENSURE_ARG_POINTER(aResult && aPosition);

  *aResult = nsnull;
  *aPosition = 0;

  nsCOMPtr<nsIDOMElement> rootElement;
  nsresult rv = GetRootNodeAndInitializeEditor(getter_AddRefs(rootElement));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootElement));

  NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);

  nsCOMPtr<nsIDOMNodeList> nodeList;

  rv = rootNode->GetChildNodes(getter_AddRefs(nodeList));
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);

  PRUint32 length = 0;

  rv = nodeList->GetLength(&length);
  NS_ENSURE_SUCCESS(rv, rv);

  NS_ASSERTION(length <= 2, "We should have one text node and one mozBR at most");

  nsCOMPtr<nsIDOMNode> firstNode;
  rv = nodeList->Item(0, getter_AddRefs(firstNode));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(firstNode);

  if (length == 0 || aOffset < 0) {
    NS_IF_ADDREF(*aResult = rootNode);
    *aPosition = 0;
  } else if (textNode) {
    PRUint32 textLength = 0;
    textNode->GetLength(&textLength);
    if (length == 2 && PRUint32(aOffset) == textLength) {
      // If we're at the end of the text node and we have a trailing BR node,
      // set the selection on the BR node.
      NS_IF_ADDREF(*aResult = rootNode);
      *aPosition = 1;
    } else {
      // Otherwise, set the selection on the textnode itself.
      NS_IF_ADDREF(*aResult = firstNode);
      *aPosition = NS_MIN(aOffset, PRInt32(textLength));
    }
  } else {
    NS_IF_ADDREF(*aResult = rootNode);
    *aPosition = 0;
  }

  return NS_OK;
}
Пример #2
0
void QFormulatorEditWidget::MovePG( int fUp, int fSel )
{
	RectFde rcf = clientRect();
	SizeFde ofs( 0, 0 );
	CFmlDrawEngineQt::DPtoLPEx( rcf, scale(), scale() );
	CFmlDrawEngineQt::DPtoLPEx( ofs, scale(), scale() );
	if( rootNode()->MovePgUpDown( rcf, ofs, fUp, fSel ) == 0 )
		updateFormulatorWidget();
}
Пример #3
0
osgDB::ReaderWriter::ReadResult
ReaderWriterDAE::readNode(const std::string& fname,
        const osgDB::ReaderWriter::Options* options) const
{
    SERIALIZER();

    bool bOwnDAE = false;
    DAE* pDAE = NULL;
   
    if ( options )
        pDAE = (DAE*) options->getPluginData("DAE");        
    
    std::string ext( osgDB::getLowerCaseFileExtension(fname) );
    if( ! acceptsExtension(ext) ) return ReadResult::FILE_NOT_HANDLED;

    std::string fileName( osgDB::findDataFile( fname, options ) );
    if( fileName.empty() ) return ReadResult::FILE_NOT_FOUND;

    osg::notify(osg::INFO) << "ReaderWriterDAE( \"" << fileName << "\" )" << std::endl;

    if (NULL == pDAE)
    {
        bOwnDAE = true;
        pDAE = new DAE;
    }

    osgdae::daeReader daeReader(pDAE) ;

    // Convert file name to URI
    std::string fileURI = ConvertFilePathToColladaCompatibleURI(fileName);

    if ( ! daeReader.convert( fileURI ) )
    {
        osg::notify( osg::WARN ) << "Load failed in COLLADA DOM conversion" << std::endl;
        return ReadResult::ERROR_IN_READING_FILE;
    }

    if ( options )
    {
        // Return the document URI
        if (options->getPluginData("DAE-DocumentURI"))
            *(std::string*)options->getPluginData("DAE-DocumentURI") = fileURI;
        // Return some additional information about the document
        if (options->getPluginData("DAE-AssetUnitName"))
             *(std::string*)options->getPluginData("DAE-AssetUnitName") = daeReader.m_AssetUnitName;
        if (options->getPluginData("DAE-AssetUnitMeter"))
            *(float*)options->getPluginData("DAE-AssetUnitMeter") = daeReader.m_AssetUnitMeter;
        if (options->getPluginData("DAE-AssetUp_axis"))
            *(domUpAxisType*)options->getPluginData("DAE-AssetUp_axis") = daeReader.m_AssetUp_axis;
   }

    if (bOwnDAE)
        delete pDAE;

    osg::Node* rootNode( daeReader.getRootNode() );
    return rootNode;
}
Пример #4
0
void SatellitesItem::recreateList() {
    QList<SatelliteGroup*> list = m_satComp->groups();
    for(int i = 0; i < list.size(); ++i) {
        SatelliteGroup *group = list.at(i);
        for(int c = 0; c < group->size(); ++c) {
            appendChildNode(new SatelliteNode(group->at(c), rootNode()));
        }
    }
}
Пример #5
0
void QSGAbstractSoftwareRenderer::buildRenderList()
{
    // Clear the previous renderlist
    m_renderableNodes.clear();
    // Add the background renderable (always first)
    m_renderableNodes.append(renderableNode(m_background));
    // Build the renderlist
    QSGSoftwareRenderListBuilder(this).visitChildren(rootNode());
}
Пример #6
0
Element* FocusNavigationScope::owner() const
{
    Node* root = rootNode();
    if (root->isShadowRoot()) {
        ShadowRoot* shadowRoot = toShadowRoot(root);
        return shadowRoot->host();
    }
    return 0;
}
Пример #7
0
void QFormulatorEditWidget::dropEvent( QDropEvent *event )
{
	if( event->mimeData() && (event->dropAction() == Qt::CopyAction || event->dropAction() == Qt::MoveAction) )
	{
		PointFde ptf( event->pos().x(), event->pos().y() );
		RectFde rcf = clientRect();
		CFmlDrawEngineQt::DPtoLPEx( ptf, scale(), scale() );
		CFmlDrawEngineQt::DPtoLPEx( rcf, scale(), scale() );
		if( rootNode()->DrInSelection() == 0 || rootNode()->PtInSelection( rcf, ptf ) == 0 )
		{
			setBlinkingCursorEnabled( true );
			rootNode()->GetDrag().SetEmpty();
			rootNode()->GetSelectInfo().SetEmpty();
			rootNode()->MoveCaret( rcf, ptf, 0 );
			updateFormulatorWidget();
		}
		else
		{
			if( event->dropAction() == Qt::MoveAction && isRemovedSelection() == 0 )
			{
				CFrameNode *pFrameNode = rootNode()->RemoveOrCopySelection( 1 );
				if( pFrameNode )
				{
					delete pFrameNode;
					setRemovedSelection();
				}
			}
			else if( event->dropAction() == Qt::CopyAction )
			{
				rootNode()->GetSelectInfo().SetEmpty();
			}

			int iRet = document()->paste( event->mimeData(), false );

			setBlinkingCursorEnabled( true );
			rootNode()->GetDrag().SetEmpty();
			updateViewDocument();

			if( !hasFocus() ) setFocus();
			if( iRet ) event->acceptProposedAction();
		}
	}
	else
	{
		setBlinkingCursorEnabled( true );
		rootNode()->GetDrag().SetEmpty();
		updateFormulatorWidget();
	}
}
Пример #8
0
QString CFormulatorDoc::exportPureContentMathML( bool ignoreCache )
{
	if( !ignoreCache )
	{
		if( isMmlChanged() )
		{
			QString sRet = rootNode()->to_mathml_pureContent();
			::hstr_0a_to_0d0a( sRet );
			::hstr_del_redundant_0d0a( sRet );
			m_cmmlCache = sRet;
			setMmlChanged( false );
		}
		return m_cmmlCache;
	}
	QString sRet = rootNode()->to_mathml_pureContent();
	::hstr_0a_to_0d0a( sRet );
	::hstr_del_redundant_0d0a( sRet );
	return sRet;
}
Пример #9
0
void NetworkView::updateAccountDependents() {
	ZLBlockTreeNode::List rootChildren = rootNode().children();

	ZLBlockTreeNode::List::iterator nodeIt = rootChildren.begin();
	while (nodeIt != rootChildren.end() && (*nodeIt)->isInstanceOf(NetworkCatalogNode::TYPE_ID)) {
		NetworkCatalogNode &node = (NetworkCatalogNode &) **nodeIt;
		updateAccountDependents(node);
		++nodeIt;
	}
}
Пример #10
0
void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
{
    if (!m_scrollingCoordinator)
        return;

    if (nodeID == rootNode()->scrollingNodeID())
        setMainFrameScrollPosition(scrollPosition);

    callOnMainThread(bind(&AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll, m_scrollingCoordinator.get(), nodeID, scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
}
Пример #11
0
TextureMapperNodeClientQt::TextureMapperNodeClientQt(QWebFrame* frame, GraphicsLayer* layer)
    : m_frame(frame)
    , m_rootGraphicsLayer(GraphicsLayer::create(0))
{
    m_frame->d->rootTextureMapperNode = rootNode();
    m_rootGraphicsLayer->addChild(layer);
    m_rootGraphicsLayer->setDrawsContent(false);
    m_rootGraphicsLayer->setMasksToBounds(false);
    m_rootGraphicsLayer->setSize(IntSize(1, 1));
}
Пример #12
0
void TreeScope::setNeedsStyleRecalcForViewportUnits()
{
    for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::next(*element)) {
        if (ShadowRoot* root = element->shadowRoot())
            root->setNeedsStyleRecalcForViewportUnits();
        RenderStyle* style = element->renderStyle();
        if (style && style->hasViewportUnits())
            element->setNeedsStyleRecalc(LocalStyleChange);
    }
}
Пример #13
0
Element* TreeScope::adjustedFocusedElement() const
{
    Document& document = rootNode().document();
    Element* element = document.focusedElement();
    if (!element)
        return 0;

    EventPath eventPath(element);
    for (size_t i = 0; i < eventPath.size(); ++i) {
        if (eventPath[i].node() == rootNode()) {
            // eventPath.at(i).target() is one of the followings:
            // - InsertionPoint
            // - shadow host
            // - Document::focusedElement()
            // So, it's safe to do toElement().
            return toElement(eventPath[i].target()->toNode());
        }
    }
    return 0;
}
Пример #14
0
void QFormulatorEditWidget::MoveUD( int fUp, int fSelect )
{
	RectFde rcf = clientRect();
	CFmlDrawEngineQt::DPtoLPEx( rcf, scale(), scale() );

	PointFde ptf = caretPos();
	SizeFde szf = caretSize();

	if( rootNode()->MoveUpDown( rcf, ptf, szf, fUp, fSelect ) == 0 )
		updateFormulatorWidget();
}
Пример #15
0
void TreeScope::setParentTreeScope(TreeScope& newParentScope)
{
    // A document node cannot be re-parented.
    ASSERT(!rootNode().isDocumentNode());

    newParentScope.guardRef();
    if (m_parentTreeScope)
        m_parentTreeScope->guardDeref();
    m_parentTreeScope = &newParentScope;
    setDocument(newParentScope.document());
}
Пример #16
0
int CFormulatorDoc::copy( QImage *pImage, bool isCut, bool needSelection )
{
	if( !QApplication::clipboard() ) return 0;
	if( needSelection && !rootNode()->IsSelection() ) return 0;

	int iRet = 0;
	CFrameNode *pFrameNode = rootNode()->RemoveOrCopySelection( isCut ? 1 : 0 );
	if( pFrameNode )
	{
		CRootNode *pRootNode = new CRootNode( m_owner );
		if( pRootNode->Insert( pFrameNode ) == 0 )
		{
			CFormulatorDoc::copy( pRootNode, pImage );
			iRet = 1;
		}
		delete pRootNode;
		delete pFrameNode;
	}
	return iRet;
}
Пример #17
0
int DeviceExplorerModel::addDevice(const Device::Node& deviceNode)
{
    int row = m_rootNode.childCount();
    QModelIndex parent; //invalid

    beginInsertRows(parent, row, row);
    rootNode().push_back(deviceNode);
    endInsertRows();

    return row;
}
Пример #18
0
//
// embed original graph according to embedding of skeletons
//
// The procedure also handles the case when some (real or virtual)
// edges are reversed (used in upward-planarity algorithms)
void PlanarSPQRTree::embed(Graph &G)
{
	OGDF_ASSERT(&G == &originalGraph());

	const Skeleton &S = skeleton(rootNode());
	const Graph &M = S.getGraph();

	for (node v : M.nodes)
	{
		node vOrig = S.original(v);
		SListPure<adjEntry> adjEdges;

		for (adjEntry adj : v->adjEdges) {
			edge e = adj->theEdge();
			edge eOrig = S.realEdge(e);

			if (eOrig != nullptr) {
				adjEntry adjOrig = (vOrig == eOrig->source()) ?
					eOrig->adjSource() : eOrig->adjTarget();
				OGDF_ASSERT(adjOrig->theNode() == S.original(v));
				adjEdges.pushBack(adjOrig);

			} else {
				node wT    = S.twinTreeNode(e);
				edge eTwin = S.twinEdge(e);
				expandVirtualEmbed(wT,
					(vOrig == skeleton(wT).original(eTwin->source())) ?
					eTwin->adjSource() : eTwin->adjTarget(),
					adjEdges);
			}
		}

		G.sort(vOrig,adjEdges);
	}

	edge e;
	forall_adj_edges(e,rootNode()) {
		node wT = e->target();
		if (wT != rootNode())
			createInnerVerticesEmbed(G, wT);
	}
Пример #19
0
QString CFormulatorDoc::exportMathML()
{
	if( isMmlChanged() )
	{
		QString sRet = ::isPureContentMathMLOutput() ? rootNode()->to_mathml_pureContent() : rootNode()->to_mathml();
		::hstr_0a_to_0d0a( sRet );
		::hstr_del_redundant_0d0a( sRet );
		m_mmlCache = sRet;
		setMmlChanged( false );
	}
	return m_mmlCache;
}
Пример #20
0
void QFormulatorEditWidget::mouseDoubleClickEvent( QMouseEvent *e )
{
	if( !rootNode() ) return;

	if( e->button() == Qt::LeftButton )
	{
		PointFde ptf( e->x(), e->y() );
		RectFde rcf = clientRect();
		CFmlDrawEngineQt::DPtoLPEx( ptf, scale(), scale() );
		CFmlDrawEngineQt::DPtoLPEx( rcf, scale(), scale() );

		if( rootNode()->DblClk( rcf, ptf ) == 0 )
			updateFormulatorWidget();

		//cbFireEvent( FORMULIB_CALLBACK_LMOUSEDBLCLICK, nFlags, MAKEWPARAM( point.x(), point.y() ) );
	}
	else if( e->button() == Qt::RightButton )
	{
		//cbFireEvent( FORMULIB_CALLBACK_RMOUSEDBLCLICK, nFlags, MAKEWPARAM( point.x(), point.y() ) );
	}
}
Пример #21
0
void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const std::optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction)
{
    if (!m_scrollingCoordinator)
        return;

    if (nodeID == rootNode()->scrollingNodeID())
        setMainFrameScrollPosition(scrollPosition);

    RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll = isHandlingProgrammaticScroll(), scrollingLayerPositionAction] {
        scrollingCoordinator->scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll, scrollingLayerPositionAction);
    });
}
Пример #22
0
Node *buildExpressionTree(char *expression) {

	NodeStack *operands = createNodeStack();
	NodeStack *result = createNodeStack();
	
	char *start = expression;
	char *end; // = expression;	
	char *beginning = expression;

	Stack *target;
	Node *node;
	Node *operand1;
	Node *operand2;
	
	while((start - beginning) < strlen(expression)) {
		if(start[0] - 0 == 39) {
			end = strstr(start + 1, "'") + 1;
		} else {
			end = strstr(start, " ");	
			if(!end) {
				end = start;
				while(end[0] != '\0')
					++end;
			}
		}
		
		char *token = malloc((end - start) + 1);
		strlcpy(token, start, (end - start) + 1);
		start = end + 1;	

		node = createNode(token);

		if(isBinaryOperator(token)) {
			target = result;
		} else if(isLogicalOperator(token)) { 
			target = operands;
		} else { 
			pushNode(operands, node);		
			continue;
		}		
	
		operand1 = popNode(target);
		operand2 = popNode(target);		
		node->right = operand1;
		node->left = operand2;

		// add this to stack
		pushNode(result, node);
	}

	// return the first node in the list (not the top)
    	return rootNode(result);
}
Пример #23
0
void XmlParser::parseInputFile(const string& file) {
	/* Open document */
	ticpp::Document doc(file.c_str());
	try {
		/* Load document */
		doc.LoadFile();
		rootNode(doc.GetTiXmlPointer(),file);
	} catch(ticpp::Exception& ex) {
		throw(ParserError(ex.details.description + " at line " +
				toString(ex.details.line) + " in column " + toString(ex.details.column)));
	}
}
Пример #24
0
void QFormulatorEditWidget::dragMoveEvent( QDragMoveEvent *event )
{
	if( event->mimeData() )
	{
		if( document()->isAcceptedMimeFormat( event->mimeData() )
			/*&& event->answerRect().intersects( geometry() )*/ )
		{
			event->acceptProposedAction();

			PointFde ptf( event->pos().x(), event->pos().y() );
			RectFde rcf = clientRect();
			CFmlDrawEngineQt::DPtoLPEx( ptf, scale(), scale() );
			CFmlDrawEngineQt::DPtoLPEx( rcf, scale(), scale() );
			if( rootNode()->DragCaret( rcf, ptf ) == 0 )
			{
				RectFde dragRect = rootNode()->GetDragRect();
				updateScrollPosition( dragRect.topLeft(), dragRect.size(), 50, 50 );
				update();
			}
		}
	}
}
Пример #25
0
int CFormulatorDoc::paste( const QMimeData *mimeData, bool deleteOldSelection )
{
	int iRet = 0;
	if( mimeData->hasFormat( FORMULATOR_MIME_FORMAT ) )
	{
		//QByteArray mmlBinaryData = mimeData->data( FORMULATOR_MIME_FORMAT );
		QDataStream ar( mimeData->data( FORMULATOR_MIME_FORMAT ) );
		CRootNode *pNode = new CRootNode( m_owner );
		pNode->Load( ar );
		if( deleteOldSelection && rootNode()->IsSelection() )
			rootNode()->MoveDel( 0 );
		iRet = (rootNode()->Insert( pNode ) == 0 ? 1 : 0);
		delete pNode;
	}
	else if( mimeData->hasText() )
	{
		iRet = (rootNode()->InsertMathML( __FMLCORE_Product_Title, mimeData->text(), 1 ) == 0 ? 1 : 0);
	}
	//else if( mimeData->hasImage() )
	//	setPixmap(qvariant_cast<QPixmap>(mimeData->imageData()));
	return iRet;
}
Пример #26
0
	const LLHTTPNode* followRemainder(const LLSD& remainder) const
	{
		const LLHTTPNode* node = rootNode();
		
		LLSD::array_const_iterator i = remainder.beginArray();
		LLSD::array_const_iterator end = remainder.endArray();
		for (; node  &&  i != end; ++i)
		{
			node = node->findNode(*i);
		}
		
		return node;
	}
Пример #27
0
bool DeviceExplorerModel::checkDeviceInstantiatable(
        Device::DeviceSettings& n)
{
    // Request from the protocol factory the protocol to see
    // if it is compatible.
    auto& context = m_devicePlugin.context().app.components;
    auto prot = context.factory<Device::DynamicProtocolList>().get(n.protocol);
    if(!prot)
        return false;

    // Look for other childs in the same protocol.
    return std::none_of(rootNode().begin(), rootNode().end(),
                       [&] (const Device::Node& child) {

        ISCORE_ASSERT(child.is<Device::DeviceSettings>());
        const auto& set = child.get<Device::DeviceSettings>();
        return (set.name == n.name)
                || (set.protocol == n.protocol
                    && !prot->checkCompatibility(n, child.get<Device::DeviceSettings>()));

    });
}
Пример #28
0
nsresult
nsTextControlFrame::DOMPointToOffset(nsIDOMNode* aNode,
                                     PRInt32 aNodeOffset,
                                     PRInt32* aResult)
{
  NS_ENSURE_ARG_POINTER(aNode && aResult);

  *aResult = 0;

  nsCOMPtr<nsIDOMElement> rootElement;
  nsresult rv = GetRootNodeAndInitializeEditor(getter_AddRefs(rootElement));
  nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootElement));

  NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);

  nsCOMPtr<nsIDOMNodeList> nodeList;

  rv = rootNode->GetChildNodes(getter_AddRefs(nodeList));
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);

  PRUint32 length = 0;
  rv = nodeList->GetLength(&length);
  NS_ENSURE_SUCCESS(rv, rv);

  if (!length || aNodeOffset < 0)
    return NS_OK;

  NS_ASSERTION(length <= 2, "We should have one text node and one mozBR at most");

  nsCOMPtr<nsIDOMNode> firstNode;
  rv = nodeList->Item(0, getter_AddRefs(firstNode));
  NS_ENSURE_SUCCESS(rv, rv);
  nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(firstNode);

  nsCOMPtr<nsIDOMText> nodeAsText = do_QueryInterface(aNode);
  if (nodeAsText || (aNode == rootNode && aNodeOffset == 0)) {
    // Selection is somewhere inside the text node; the offset is aNodeOffset
    *aResult = aNodeOffset;
  } else {
    // Selection is on the mozBR node, so offset should be set to the length
    // of the text node.
    if (textNode) {
      rv = textNode->GetLength(&length);
      NS_ENSURE_SUCCESS(rv, rv);
      *aResult = PRInt32(length);
    }
  }

  return NS_OK;
}
Пример #29
0
DOMSelection* TreeScope::getSelection() const
{
    if (!rootNode().document().frame())
        return 0;

    if (m_selection)
        return m_selection.get();

    // FIXME: The correct selection in Shadow DOM requires that Position can have a ShadowRoot
    // as a container.
    // See https://bugs.webkit.org/show_bug.cgi?id=82697
    m_selection = DOMSelection::create(this);
    return m_selection.get();
}
Пример #30
0
Element* TreeScope::elementFromPoint(int x, int y) const
{
    HitTestResult result = hitTestInDocument(&rootNode().document(), x, y);
    Node* node = result.innerNode();
    if (!node || node->isDocumentNode())
        return 0;
    if (node->isTextNode())
        node = node->parentOrShadowHostNode();
    ASSERT(!node || node->isElementNode() || node->isShadowRoot());
    node = ancestorInThisScope(node);
    if (!node || !node->isElementNode())
        return 0;
    return toElement(node);
}