Ejemplo n.º 1
0
void ArgumentsEditor::accept()
{
    QStringList argNames = m_call->argNames();
    QVector<QVariant> originalValues = m_call->arguments();
    QVector<QVariant> newValues;
    bool changed = false;
    for (int i = 0; i < argNames.count(); ++i) {
        bool valChanged = false;
        QString argName = argNames[i];
        QVariant argValue = originalValues[i];
        QVariant editorValue = valueForName(argName, argValue, &valChanged);

        newValues.append(editorValue);
#if 0
        qDebug()<<"Arg = "<<argName;
        qDebug()<<"\toriginal = "<<argValue;
        qDebug()<<"\teditor   = "<<editorValue;
        qDebug()<<"\tchanged  = "<<valChanged;
#endif
        if (valChanged)
            changed = true;
    }
    if (changed)
        m_call->setEditedValues(newValues);
    QDialog::accept();
}
bool ScriptCustomElementDefinitionBuilder::checkPrototype() {
  v8::Local<v8::Value> prototypeValue;
  if (!valueForName(m_constructor, "prototype", prototypeValue))
    return false;
  if (!prototypeValue->IsObject()) {
    m_exceptionState.throwTypeError("constructor prototype is not an object");
    return false;
  }
  m_prototype = prototypeValue.As<v8::Object>();
  // If retrieving the prototype destroyed the context, indicate that
  // defining the element should not proceed.
  return true;
}
bool ScriptCustomElementDefinitionBuilder::callableForName(const String& name,
    v8::Local<v8::Function>& callback) const
{
    v8::Local<v8::Value> value;
    if (!valueForName(m_prototype, name, value))
        return false;
    // "undefined" means "omitted", so return true.
    if (value->IsUndefined())
        return true;
    if (!value->IsFunction()) {
        m_exceptionState.throwTypeError(
            String::format("\"%s\" is not a callable object", name.ascii().data()));
        return false;
    }
    callback = value.As<v8::Function>();
    return true;
}
bool ScriptCustomElementDefinitionBuilder::retrieveObservedAttributes() {
  v8::Local<v8::Value> observedAttributesValue;
  if (!valueForName(m_constructor, "observedAttributes",
                    observedAttributesValue))
    return false;
  if (observedAttributesValue->IsUndefined())
    return true;
  Vector<AtomicString> list = toImplSequence<Vector<AtomicString>>(
      m_scriptState->isolate(), observedAttributesValue, m_exceptionState);
  if (m_exceptionState.hadException())
    return false;
  if (list.isEmpty())
    return true;
  m_observedAttributes.reserveCapacityForSize(list.size());
  for (const auto& attribute : list)
    m_observedAttributes.add(attribute);
  return true;
}