Пример #1
0
void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior recalcStyleBehavior)
{
    String oldData = m_data;
    m_data = newData;

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalcStyleBehavior);

    didModifyData(oldData);
}
Пример #2
0
// _____________________________________________________________________________
void QueryPlanner::TripleGraph::splitAtText(
    const vector<SparqlFilter>& origFilters,
    vector<pair<QueryPlanner::TripleGraph, vector<SparqlFilter>>>& subgraphs,
    unordered_map<string, vector<size_t>>& contextVarToTextNodesIds,
    vector<SparqlFilter>& filtersWithContextVars) const {
  std::set<string> varsInNonContextTriples;
  std::set<string> varsInContextTriples;
  std::set<string> contextVars;
  // Find all context vars.
  for (size_t i = 0; i < _adjLists.size(); ++i) {
    if (isTextNode(i)) {
      varsInContextTriples.insert(
          _nodeMap.find(i)->second->_variables.begin(),
          _nodeMap.find(i)->second->_variables.end());
    } else {
      varsInNonContextTriples.insert(
          _nodeMap.find(i)->second->_variables.begin(),
          _nodeMap.find(i)->second->_variables.end());
    }
  }
  std::set_difference(varsInContextTriples.begin(),
                      varsInContextTriples.end(),
                      varsInNonContextTriples.begin(),
                      varsInNonContextTriples.end(),
                      std::inserter(contextVars, contextVars.begin()));
  // Iterate again and fill contextVar -> triples map
  for (size_t i = 0; i < _adjLists.size(); ++i) {
    if (isTextNode(i)) {
      if (contextVars.count(_nodeMap.find(i)->second->_triple._s) > 0) {
        contextVarToTextNodesIds[_nodeMap.find(
            i)->second->_triple._s].push_back(i);
        AD_CHECK_EQ(0, contextVars.count(_nodeMap.find(i)->second->_triple._o));
      }
      if (contextVars.count(_nodeMap.find(i)->second->_triple._o) > 0) {
        contextVarToTextNodesIds[_nodeMap.find(
            i)->second->_triple._o].push_back(i);
        AD_CHECK_EQ(0, contextVars.count(_nodeMap.find(i)->second->_triple._s));
      }
    }
  }
  vector<SparqlFilter> filtersWithoutContextVars;
  for (auto& f : origFilters) {
    if (contextVars.count(f._lhs) > 0 || contextVars.count(f._lhs) > 0) {
      filtersWithContextVars.push_back(f);
    } else {
      filtersWithoutContextVars.push_back(f);
    }
  }
  subgraphs = splitAtContextVars(filtersWithoutContextVars,
                                 contextVarToTextNodesIds);
}
Пример #3
0
void CharacterData::parserAppendData(const String& string)
{
    unsigned oldLength = m_data.length();
    m_data = m_data + string;

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(oldLength, 0);

    if (parentNode()) {
        ContainerNode::ChildrenChange change = {ContainerNode::TextChanged, ContainerNode::ChildrenChangeSourceParser};
        parentNode()->childrenChanged(change);
    }
}
Пример #4
0
void CharacterData::parserAppendData(const String& string)
{
    unsigned oldLength = m_data.length();
    m_data = m_data + string;

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(oldLength, 0);

    document().incDOMTreeVersion();

    if (parentNode())
        parentNode()->childrenChanged();
}
Пример #5
0
void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength)
{
    String oldData = m_data;
    m_data = newData;

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength);

    if (document()->frame())
        document()->frame()->selection()->textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);

    document()->incDOMTreeVersion();
    dispatchModifiedEvent(oldData);
}
Пример #6
0
void Node::output(ostream& printStream, int indentLevet) 
{
	char *indentString = getIndentLevelString(indentLevet);

	if (isInstanceNode() == false) {
		outputHead(printStream, indentString);
		outputContext(printStream, indentString);
	
		if (!isElevationGridNode() && !isShapeNode() && !isSoundNode() && !isPointSetNode() && !isIndexedFaceSetNode() && 
			!isIndexedLineSetNode() && !isTextNode() && !isAppearanceNode()) {
			if (getChildNodes() != NULL) {
				if (isLodNode()) 
					printStream << indentString << "\tlevel [" << endl;
				else if (isSwitchNode()) 
					printStream << indentString << "\tchoice [" << endl;
				else
					printStream << indentString <<"\tchildren [" << endl;
			
				for (Node *node = getChildNodes(); node; node = node->next()) {
					if (node->isInstanceNode() == false) 
						node->output(printStream, indentLevet+2);
					else
						node->output(printStream, indentLevet+2);
				}
			
				printStream << indentString << "\t]" << endl;
			}
		}
		outputTail(printStream, indentString);
	}
	else 
		printStream << indentString << "USE " << getName() << endl;

	delete indentString;
}
Пример #7
0
	void Node::setTextNode( bool theTextNode )
	{
		if ( theTextNode != isTextNode() )
		{
			flag = theTextNode ? TextNode : None;
			text.clear();
		}
	}
Пример #8
0
void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength, RecalcStyleBehavior recalcStyleBehavior)
{
    String oldData = m_data;
    m_data = newData;

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(offsetOfReplacedData, oldLength, recalcStyleBehavior);

    if (nodeType() == PROCESSING_INSTRUCTION_NODE)
        toProcessingInstruction(this)->checkStyleSheet();

    if (document().frame())
        document().frame()->selection().didUpdateCharacterData(this, offsetOfReplacedData, oldLength, newLength);

    document().incDOMTreeVersion();
    didModifyData(oldData);
}
Пример #9
0
void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength, UpdateSource source, RecalcStyleBehavior recalcStyleBehavior)
{
    String oldData = m_data;
    m_data = newData;

    ASSERT(!layoutObject() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextLayoutObject(offsetOfReplacedData, oldLength, recalcStyleBehavior);

    if (source != UpdateFromParser) {
        if (getNodeType() == PROCESSING_INSTRUCTION_NODE)
            toProcessingInstruction(this)->didAttributeChanged();

        if (document().frame())
            document().frame()->selection().didUpdateCharacterData(this, offsetOfReplacedData, oldLength, newLength);
    }

    document().incDOMTreeVersion();
    didModifyData(oldData, source);
}
Пример #10
0
unsigned CharacterData::parserAppendData(const String& string, unsigned offset, unsigned lengthLimit)
{
    unsigned oldLength = m_data.length();

    ASSERT(lengthLimit >= oldLength);

    unsigned characterLength = string.length() - offset;
    unsigned characterLengthLimit = min(characterLength, lengthLimit - oldLength);

    // Check that we are not on an unbreakable boundary.
    // Some text break iterator implementations work best if the passed buffer is as small as possible,
    // see <https://bugs.webkit.org/show_bug.cgi?id=29092>.
    // We need at least two characters look-ahead to account for UTF-16 surrogates.
    ASSERT(!string.is8Bit() || string.containsOnlyLatin1()); // Latin-1 doesn't have unbreakable boundaries.
    if (characterLengthLimit < characterLength && !string.is8Bit()) {
        NonSharedCharacterBreakIterator it(string.characters16() + offset, (characterLengthLimit + 2 > characterLength) ? characterLength : characterLengthLimit + 2);
        if (!isTextBreak(it, characterLengthLimit))
            characterLengthLimit = textBreakPreceding(it, characterLengthLimit);
    }

    if (!characterLengthLimit)
        return 0;

    if (string.is8Bit())
        m_data.append(string.characters8() + offset, characterLengthLimit);
    else
        m_data.append(string.characters16() + offset, characterLengthLimit);

    ASSERT(!renderer() || isTextNode());
    if (isTextNode())
        toText(this)->updateTextRenderer(oldLength, 0);

    document()->incDOMTreeVersion();
    // We don't call dispatchModifiedEvent here because we don't want the
    // parser to dispatch DOM mutation events.
    if (parentNode())
        parentNode()->childrenChanged();

    return characterLengthLimit;
}
Пример #11
0
	std::string Node::getString() const
	{
		std::string toReturn;
		if ( isTextNode() )
		{
			toReturn = text;
		}
		else if ( isCharacterData() )
		{
			toReturn =  "<![CDATA[";
			toReturn += text;
			toReturn += "]]>";
		}
		else
		{
			toReturn =  "<";
			toReturn += name;
			for ( auto it = attributes.begin(); it != attributes.end(); ++it )
			{
				toReturn += " ";
				toReturn += it->getString();
			}
			
			if ( isSelfClosing() )
			{
				toReturn += " />";
			}
			else
			{
				toReturn += ">";
				
				for ( auto it = children.begin(); it != children.end(); ++it )
				{
					toReturn += "\r\n";
					toReturn += ( * it )->getString();
				}
				
				if ( getChildren().size() != 0 )
				{
					toReturn += "\r\n";
				}
				
				toReturn += "</";
				toReturn += name;
				toReturn += ">";
			}
		}
		
		return toReturn;
	}
Пример #12
0
string XMLNode::Affiche() const
{
	if ( isTextNode() )
	{
		return textContent;
	}
	else
	{
		string result = "<";
		if (elementNamespace != "")
		{
			result += elementNamespace + ":";
		}
		result += elementName;
		for (map<string, string>::const_iterator it = attributes.begin() ; it != attributes.end() ; it++)
		{
			result = result + " " + it->first + "=\"" + it->second + "\"";
		
		}
		
		if (lonely)
		{
			result += "/>\n";
		}
		else
		{
			result += ">\n";
			for (vector<XMLNode*>::const_iterator it = children.begin() ; it != children.end() ; it++)
			{
				result += (*it)->Affiche();
			}
			result=indent(result);
			result += "</";
			if (elementNamespace != "")
			{
				result += elementNamespace + ":";
			}
			result += elementName + ">\n";
		}
		return result;
	}
}
Пример #13
0
Node *Node::createInstanceNode() 
{
	Node *instanceNode = NULL;
		
	if (isAnchorNode())
		instanceNode = new AnchorNode();
	else if (isAppearanceNode()) 
		instanceNode = new AppearanceNode();
	else if (isAudioClipNode())
		instanceNode = new AudioClipNode();
	else if (isBackgroundNode())
		instanceNode = new BackgroundNode();
	else if (isBillboardNode())
		instanceNode = new BillboardNode();
	else if (isBoxNode())
		instanceNode = new BoxNode();
	else if (isCollisionNode())
		instanceNode = new CollisionNode();
	else if (isColorNode())
		instanceNode = new ColorNode();
	else if (isColorInterpolatorNode())
		instanceNode = new ColorInterpolatorNode();
	else if (isConeNode())
		instanceNode = new ConeNode();
	else if (isCoordinateNode())
		instanceNode = new CoordinateNode();
	else if (isCoordinateInterpolatorNode())
		instanceNode = new CoordinateInterpolatorNode();
	else if (isCylinderNode())
		instanceNode = new CylinderNode();
	else if (isCylinderSensorNode())
		instanceNode = new CylinderSensorNode();
	else if (isDirectionalLightNode())
		instanceNode = new DirectionalLightNode();
	else if (isElevationGridNode())
		instanceNode = new ElevationGridNode();
	else if (isExtrusionNode())
		instanceNode = new ExtrusionNode();
	else if (isFogNode())
		instanceNode = new FogNode();
	else if (isFontStyleNode())
		instanceNode = new FontStyleNode();
	else if (isGroupNode())
		instanceNode = new GroupNode();
	else if (isImageTextureNode())
		instanceNode = new ImageTextureNode();
	else if (isIndexedFaceSetNode())
		instanceNode = new IndexedFaceSetNode();
	else if (isIndexedLineSetNode()) 
		instanceNode = new IndexedLineSetNode();
	else if (isInlineNode()) 
		instanceNode = new InlineNode();
	else if (isLodNode())
		instanceNode = new LodNode();
	else if (isMaterialNode())
		instanceNode = new MaterialNode();
	else if (isMovieTextureNode())
		instanceNode = new MovieTextureNode();
	else if (isNavigationInfoNode())
		instanceNode = new NavigationInfoNode();
	else if (isNormalNode())
		instanceNode = new NormalNode();
	else if (isNormalInterpolatorNode())
		instanceNode = new NormalInterpolatorNode();
	else if (isOrientationInterpolatorNode())
		instanceNode = new OrientationInterpolatorNode();
	else if (isPixelTextureNode())
		instanceNode = new PixelTextureNode();
	else if (isPlaneSensorNode())
		instanceNode = new PlaneSensorNode();
	else if (isPointLightNode())
		instanceNode = new PointLightNode();
	else if (isPointSetNode())
		instanceNode = new PointSetNode();
	else if (isPositionInterpolatorNode())
		instanceNode = new PositionInterpolatorNode();
	else if (isProximitySensorNode())
		instanceNode = new ProximitySensorNode();
	else if (isScalarInterpolatorNode())
		instanceNode = new ScalarInterpolatorNode();
	else if (isScriptNode())
		instanceNode = new ScriptNode();
	else if (isShapeNode())
		instanceNode = new ShapeNode();
	else if (isSoundNode())
		instanceNode = new SoundNode();
	else if (isSphereNode())
		instanceNode = new SphereNode();
	else if (isSphereSensorNode())
		instanceNode = new SphereSensorNode();
	else if (isSpotLightNode())
		instanceNode = new SpotLightNode();
	else if (isSwitchNode())
		instanceNode = new SwitchNode();
	else if (isTextNode())
		instanceNode = new TextNode();
	else if (isTextureCoordinateNode())
		instanceNode = new TextureCoordinateNode();
	else if (isTextureTransformNode())
		instanceNode = new TextureTransformNode();
	else if (isTimeSensorNode())
		instanceNode = new TimeSensorNode();
	else if (isTouchSensorNode())
		instanceNode = new TouchSensorNode();
	else if (isTransformNode())
		instanceNode = new TransformNode();
	else if (isViewpointNode())
		instanceNode = new ViewpointNode();
	else if (isVisibilitySensorNode())
		instanceNode = new VisibilitySensorNode();
	else if (isWorldInfoNode())
		instanceNode = new WorldInfoNode();

	assert(instanceNode);

	if (instanceNode) {
		Node *refNode = this;
		while (refNode->isInstanceNode() == true) 
			refNode = refNode->getReferenceNode();
		instanceNode->setAsInstanceNode(refNode);
		for (Node *cnode=getChildNodes(); cnode; cnode = cnode->next()) {
			Node *childInstanceNode = cnode->createInstanceNode();
			instanceNode->addChildNode(childInstanceNode);
		}
	}		
		
	return instanceNode;
}