示例#1
0
TEST(AnimationEffectInputTest, LooslySorted) {
  V8TestingScope scope;
  Vector<Dictionary> jsKeyframes;
  v8::Local<v8::Object> keyframe1 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe2 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe3 = v8::Object::New(scope.isolate());

  setV8ObjectPropertyAsString(scope.isolate(), keyframe1, "width", "100px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe1, "offset", "0");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe2, "width", "200px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe3, "width", "0px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe3, "offset", "1");

  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe1, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe2, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe3, scope.getExceptionState()));

  Element* element = appendElement(scope.document());
  EffectModel* animationEffect = EffectInput::convert(
      element,
      DictionarySequenceOrDictionary::fromDictionarySequence(jsKeyframes),
      nullptr, scope.getExceptionState());
  EXPECT_FALSE(scope.getExceptionState().hadException());
  const KeyframeEffectModelBase& keyframeEffect =
      *toKeyframeEffectModelBase(animationEffect);
  EXPECT_EQ(1, keyframeEffect.getFrames()[2]->offset());
}
示例#2
0
void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Namespaces* namespaces)
{
    switch (node.nodeType()) {
    case Node::TEXT_NODE:
        appendText(result, toText(node));
        break;
    case Node::COMMENT_NODE:
        appendComment(result, toComment(node).data());
        break;
    case Node::DOCUMENT_NODE:
        appendXMLDeclaration(result, toDocument(node));
        break;
    case Node::DOCUMENT_FRAGMENT_NODE:
        break;
    case Node::DOCUMENT_TYPE_NODE:
        appendDocumentType(result, toDocumentType(node));
        break;
    case Node::PROCESSING_INSTRUCTION_NODE:
        appendProcessingInstruction(result, toProcessingInstruction(node).target(), toProcessingInstruction(node).data());
        break;
    case Node::ELEMENT_NODE:
        appendElement(result, toElement(node), namespaces);
        break;
    case Node::CDATA_SECTION_NODE:
        appendCDATASection(result, toCDATASection(node).data());
        break;
    case Node::ATTRIBUTE_NODE:
        ASSERT_NOT_REACHED();
        break;
    }
}
示例#3
0
TEST(AnimationEffectInputTest, OutOfOrderWithNullOffsets) {
  V8TestingScope scope;
  Vector<Dictionary> jsKeyframes;
  v8::Local<v8::Object> keyframe1 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe2 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe3 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe4 = v8::Object::New(scope.isolate());

  setV8ObjectPropertyAsString(scope.isolate(), keyframe1, "height", "100px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe1, "offset", "0.5");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe2, "height", "150px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe3, "height", "200px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe3, "offset", "0");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe4, "height", "300px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe4, "offset", "1");

  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe1, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe2, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe3, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe4, scope.getExceptionState()));

  Element* element = appendElement(scope.document());
  EffectInput::convert(
      element,
      DictionarySequenceOrDictionary::fromDictionarySequence(jsKeyframes),
      nullptr, scope.getExceptionState());
  EXPECT_TRUE(scope.getExceptionState().hadException());
}
示例#4
0
TEST(AnimationEffectInputTest, Invalid) {
  V8TestingScope scope;
  // Not loosely sorted by offset, and there exists a keyframe with null offset.
  Vector<Dictionary> jsKeyframes;
  v8::Local<v8::Object> keyframe1 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe2 = v8::Object::New(scope.isolate());
  v8::Local<v8::Object> keyframe3 = v8::Object::New(scope.isolate());

  setV8ObjectPropertyAsString(scope.isolate(), keyframe1, "width", "0px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe1, "offset", "1");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe2, "width", "200px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe3, "width", "100px");
  setV8ObjectPropertyAsString(scope.isolate(), keyframe3, "offset", "0");

  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe1, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe2, scope.getExceptionState()));
  jsKeyframes.push_back(
      Dictionary(scope.isolate(), keyframe3, scope.getExceptionState()));

  Element* element = appendElement(scope.document());
  EffectInput::convert(
      element,
      DictionarySequenceOrDictionary::fromDictionarySequence(jsKeyframes),
      nullptr, scope.getExceptionState());
  EXPECT_TRUE(scope.getExceptionState().hadException());
  EXPECT_EQ(V8TypeError, scope.getExceptionState().code());
}
示例#5
0
List::List(const List &other):
					first(nullptr), last(nullptr), currentSize(0), def(0)
{
	for (ListItem *item = other.first; item != nullptr; item = item->getNext()) {
		appendElement(item->getContent());
	}
}
List::List(const List& other):
	first(nullptr), last(nullptr), currentSize(0)
{
	// Copy list item-wise to avoid having two lists pointing at the same list items
	for (ListItem *item = other.first; item != nullptr; item = item->getNext()) {
		appendElement(item->getContent());
	}
}
示例#7
0
文件: Race.cpp 项目: ameily/WarRoom
QDomElement& Race::toXml(QDomDocument& doc, QDomElement& parent) const
    throw(ValidationException)
{
    if(m_game == NULL)
        throw ValidationException("Race", "game", "is null reference");
    
    if(m_id.isEmpty())
        throw ValidationException("Race", "id", "is null");
    
    if(m_name.isEmpty())
        throw ValidationException("Race", "name", "is null");
    
    QDomProcessingInstruction header = doc.createProcessingInstruction("xml", "version=\"1.0\"");   
    doc.appendChild(header);
    
    QDomElement root = doc.createElement("race");
    
    QDomElement ruleSetNode = doc.createElement("rule_set");
    RuleSet::toXml(doc, ruleSetNode);
    
    QDomElement wargearsNode = doc.createElement("wargears");
    WargearList::toXml(doc, wargearsNode);
    
    QDomElement unitsNode = doc.createElement("units");
    UnitList::toXml(doc, unitsNode);
    
    appendElement(doc, root, "id", m_id);
    appendElement(doc, root, "name", m_name);
    
    QDomElement gameNode = doc.createElement("game");
    UnresolvedReference game(m_game->id());
    game.toXml(doc, gameNode);
    root.appendChild(gameNode);
    
    root.appendChild(ruleSetNode);
    root.appendChild(wargearsNode);
    root.appendChild(unitsNode);
    
    doc.appendChild(root);
    
    return parent;
}
示例#8
0
void List::insertElementAt(int i, int pos) {
	if (pos <= 0)
		prependElement(i);
	else if (pos >= getSize())
		appendElement(i);
	else {
		ListItem *tmp = first;
		while (pos-- > 0) {
			tmp = tmp->getNext();
		}
		new ListItem(tmp->getPrevious(), tmp, i);
		currentSize++;
	}
}
示例#9
0
QDomElement& RuleSet::toXml(QDomDocument& doc, QDomElement& parent) const
    throw(ValidationException)
{
    if(m_book.isEmpty())
        throw ValidationException("RuleSet", "book", "is null");
    
    if(m_edition.isEmpty())
        throw ValidationException("RuleSet", "edition", "is null");
    
    if(m_version.isEmpty())
        throw ValidationException("RuleSet", "version", "is null");
    
    QDomElement ruleList = doc.createElement("rules");
    RuleList::toXml(doc, ruleList);
    
    appendElement(doc, parent, "book", m_book);
    appendElement(doc, parent, "edition", m_edition);
    appendElement(doc, parent, "version", m_version);
    
    parent.appendChild(ruleList);
    
    return parent;
}
示例#10
0
void List::insertElementAt(int i, int pos) {
	if (pos <= 0) {
		prependElement(i);
	}
	else if (pos >= getSize()) {
		appendElement(i);
	}
	else {
		ListItem* p = first;
		// iterate over elements
		while (pos-- > 0) {
			p = p->getNext();
		}
		new ListItem(p->getPrevious(), p, i);
		++currentSize;
	}
}
示例#11
0
void MarkupAccumulator::appendStartMarkup(StringBuilder& result, const Node* node, Namespaces* namespaces)
{
    if (namespaces)
        namespaces->checkConsistency();

    switch (node->nodeType()) {
    case Node::TEXT_NODE:
        appendText(result, toText(const_cast<Node*>(node)));
        break;
    case Node::COMMENT_NODE:
        appendComment(result, static_cast<const Comment*>(node)->data());
        break;
    case Node::DOCUMENT_NODE:
        appendXMLDeclaration(result, static_cast<const Document*>(node));
        break;
    case Node::DOCUMENT_FRAGMENT_NODE:
        break;
    case Node::DOCUMENT_TYPE_NODE:
        appendDocumentType(result, static_cast<const DocumentType*>(node));
        break;
    case Node::PROCESSING_INSTRUCTION_NODE:
        appendProcessingInstruction(result, static_cast<const ProcessingInstruction*>(node)->target(), static_cast<const ProcessingInstruction*>(node)->data());
        break;
    case Node::ELEMENT_NODE:
        appendElement(result, static_cast<Element*>(const_cast<Node*>(node)), namespaces);
        break;
    case Node::CDATA_SECTION_NODE:
        appendCDATASection(result, static_cast<const CDATASection*>(node)->data());
        break;
    case Node::ATTRIBUTE_NODE:
    case Node::ENTITY_NODE:
    case Node::ENTITY_REFERENCE_NODE:
    case Node::NOTATION_NODE:
    case Node::XPATH_NAMESPACE_NODE:
        ASSERT_NOT_REACHED();
        break;
    }
}
示例#12
0
void PeriodicGrid::create()
{
    int r, g, b, color, period, group, intElement = 1;

    QColor bgColor(m_applet->palette().foreground().color());
    bgColor.darker();
    bgColor.getRgb(&r,&g,&b);

    foreach (ElementLabel * i, m_elementItemList) {
        delete i;
    }

    m_elementItemList.clear();

    int maxWidth = pseTables::instance()->getTabletype(m_psTableType)->tableSize().x();
    // a parameter for the linear function. y(x) = ax + b
    double a = 50 / (maxWidth / 2);

    foreach (intElement, pseTables::instance()->getTabletype(m_psTableType)->elements()) {
        if (intElement <= 112) {
            group = pseTables::instance()->getTabletype(m_psTableType)->elementCoords(intElement).x();
            period = pseTables::instance()->getTabletype(m_psTableType)->elementCoords(intElement).y();

            // makes a v-like color scheme
            color = period + (abs(group - maxWidth/2) * a);

            ElementLabel *element = new ElementLabel(intElement, m_applet);
            m_elementItemList.append(element);

            element->setTextBackgroundColor(QColor (r - color, g - color, b - color));

            connect (element, SIGNAL(ElementAction(QString)), m_applet, SLOT(appendElement(QString)));

            m_actualPeriodSystem->addItem (element, period, group);
        }
    }
}
示例#13
0
/*
 * Create an argument list for function and procedure invocation.
 *
 * Return a pointer to a ProxySymbol containing the list.
 */
struct ElementArray *createArgList(struct treeNode *arg) {
	struct ElementArray * ea = NULL;
	
	if (!arg) {
		/* ERROR */
		return NULL;
	}

	if (!(arg->symbol)) return NULL;

	if (	(arg->symbol->kind == PROC_KIND) || 
		((arg->symbol->kind == FUNC_KIND) && 
		 !(arg->symbol->kindPtr.FuncKind->invocationInstance)) ||
		(arg->symbol->kind == PARAM_KIND)
	){
		errMsg = customErrorString("Invalid argument type.");
		recordError(errMsg, yylineno, colno, SEMANTIC);
	}

	ea = newElementArray();
	growElementArray(ea);
	appendElement(ea, arg);	
	return ea;
}