void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor) { if (!qmlObjectNode.isValid()) return; if (qmlObjectNode.isValid()) { foreach (const PropertyName &propertyName, qmlObjectNode.modelNode().metaInfo().propertyNames()) createPropertyEditorValue(qmlObjectNode, propertyName, qmlObjectNode.instanceValue(propertyName), propertyEditor); // className PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("className"))); if (!valueObject) valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap); valueObject->setName("className"); valueObject->setModelNode(qmlObjectNode.modelNode()); valueObject->setValue(qmlObjectNode.modelNode().simplifiedTypeName()); QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant))); m_backendValuesPropertyMap.insert("className", QVariant::fromValue(valueObject)); // id valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("id"))); if (!valueObject) valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap); valueObject->setName("id"); valueObject->setValue(qmlObjectNode.id()); QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant))); m_backendValuesPropertyMap.insert("id", QVariant::fromValue(valueObject)); // anchors m_backendAnchorBinding.setup(QmlItemNode(qmlObjectNode.modelNode())); context()->setContextProperty("anchorBackend", &m_backendAnchorBinding); context()->setContextProperty("transaction", m_propertyEditorTransaction.data()); contextObject()->setSpecificsUrl(qmlSpecificsFile); contextObject()->setStateName(stateName); if (!qmlObjectNode.isValid()) return; context()->setContextProperty("propertyCount", QVariant(qmlObjectNode.modelNode().properties().count())); contextObject()->setIsBaseState(qmlObjectNode.isInBaseState()); contextObject()->setSelectionChanged(false); contextObject()->setSelectionChanged(false); NodeMetaInfo metaInfo = qmlObjectNode.modelNode().metaInfo(); if (metaInfo.isValid()) { contextObject()->setMajorVersion(metaInfo.majorVersion()); contextObject()->setMinorVersion(metaInfo.minorVersion()); } else { contextObject()->setMajorVersion(-1); contextObject()->setMinorVersion(-1); } } else {
JSValue JSHTMLCanvasElement::getContext(ExecState* exec) { HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl()); const String& contextId = exec->argument(0).toString(exec)->value(exec); RefPtr<CanvasContextAttributes> attrs; #if ENABLE(WEBGL) if (HTMLCanvasElement::is3dType(contextId)) { get3DContextAttributes(exec, attrs); if (exec->hadException()) return jsUndefined(); } #endif CanvasRenderingContext* context = canvas->getContext(contextId, attrs.get()); if (!context) return jsNull(); JSValue jsValue = toJS(exec, globalObject(), WTF::getPtr(context)); if (InspectorInstrumentation::canvasAgentEnabled(canvas->document())) { ScriptObject contextObject(exec, jsValue.getObject()); ScriptObject wrapped; if (context->is2d()) wrapped = InspectorInstrumentation::wrapCanvas2DRenderingContextForInstrumentation(canvas->document(), contextObject); #if ENABLE(WEBGL) else if (context->is3d()) wrapped = InspectorInstrumentation::wrapWebGLRenderingContextForInstrumentation(canvas->document(), contextObject); #endif if (!wrapped.hasNoValue()) return wrapped.jsValue(); } return jsValue; }