mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
... instead of hard-coding "example". We do this by adding a custom constructor for Element that gets the |tagName| property off the instance. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/943153002
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sky/engine/config.h"
|
|
#include "sky/engine/core/dom/Element.h"
|
|
|
|
#include "dart/runtime/include/dart_api.h"
|
|
#include "sky/engine/core/script/dom_dart_state.h"
|
|
#include "sky/engine/tonic/dart_converter.h"
|
|
|
|
namespace blink {
|
|
namespace DartElementInternal {
|
|
|
|
void constructorCallback(Dart_NativeArguments args) {
|
|
Dart_Handle receiver = Dart_GetNativeArgument(args, 0);
|
|
DCHECK(!LogIfError(receiver));
|
|
|
|
Dart_Handle tag_name = Dart_GetField(receiver,
|
|
Dart_NewStringFromCString("tagName"));
|
|
if (!Dart_IsString(tag_name)) {
|
|
Dart_ThrowException(Dart_NewStringFromCString("tagName is not a string"));
|
|
return;
|
|
}
|
|
|
|
RefPtr<Element> element = Element::create(
|
|
QualifiedName(StringFromDart(tag_name)), DOMDartState::CurrentDocument());
|
|
|
|
// TODO(abarth): We should remove these states because elements are never
|
|
// waiting for upgrades.
|
|
element->setCustomElementState(Element::WaitingForUpgrade);
|
|
element->setCustomElementState(Element::Upgraded);
|
|
element->AssociateWithDartWrapper(args);
|
|
}
|
|
|
|
} // namespace DartElementInternal
|
|
} // namespace blink
|