Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Unified Diff: sky/engine/core/dom/custom2/new_custom_element.cc

Issue 946083003: Rename Sky's custom2 to custom (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/core/dom/custom2/new_custom_element.cc
diff --git a/sky/engine/core/dom/custom2/new_custom_element.cc b/sky/engine/core/dom/custom2/new_custom_element.cc
deleted file mode 100644
index be4b08576d97cd888f870d755894babae664514a..0000000000000000000000000000000000000000
--- a/sky/engine/core/dom/custom2/new_custom_element.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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/custom2/new_custom_element.h"
-
-#include "base/bind.h"
-#include "dart/runtime/include/dart_api.h"
-#include "sky/engine/core/dom/Document.h"
-#include "sky/engine/core/dom/Element.h"
-#include "sky/engine/core/dom/Microtask.h"
-#include "sky/engine/core/dom/custom2/new_custom_element_callback_scope.h"
-#include "sky/engine/core/dom/custom2/new_custom_element_registry.h"
-#include "sky/engine/tonic/dart_converter.h"
-#include "sky/engine/tonic/dart_state.h"
-#include "sky/engine/wtf/text/AtomicString.h"
-
-namespace blink {
-namespace {
-
-void ScheduleCallback(const base::Closure& callback) {
- if (auto* scope = NewCustomElementCallbackScope::Current()) {
- scope->Enqueue(callback);
- } else {
- Microtask::enqueueMicrotask(callback);
- }
-}
-
-void CallAttributeDidChangedCallback(RefPtr<Element> element,
- AtomicString name,
- AtomicString oldValue,
- AtomicString newValue) {
- auto* dart_state = element->document().elementRegistry().dart_state().get();
- if (!dart_state)
- return;
- DartState::Scope scope(dart_state);
- Dart_Handle wrapper = ToDart(element);
- Dart_Handle callback = Dart_NewStringFromCString("attributeChangedCallback");
- Dart_Handle args[] = {
- StringToDart(dart_state, name),
- StringToDart(dart_state, oldValue),
- StringToDart(dart_state, newValue),
- };
- LogIfError(Dart_Invoke(wrapper, callback, arraysize(args), args));
-}
-
-void CallDidAttachedCallback(RefPtr<Element> element, RefPtr<Document> document) {
- auto* dart_state = document->elementRegistry().dart_state().get();
- if (!dart_state)
- return;
- DartState::Scope scope(dart_state);
- Dart_Handle wrapper = ToDart(element);
- Dart_Handle callback = Dart_NewStringFromCString("attachedCallback");
- LogIfError(Dart_Invoke(wrapper, callback, 0, nullptr));
-}
-
-void CallDidDetachedCallback(RefPtr<Element> element, RefPtr<Document> document) {
- auto* dart_state = document->elementRegistry().dart_state().get();
- if (!dart_state)
- return;
- DartState::Scope scope(dart_state);
- Dart_Handle wrapper = ToDart(element);
- Dart_Handle callback = Dart_NewStringFromCString("detachedCallback");
- LogIfError(Dart_Invoke(wrapper, callback, 0, nullptr));
-}
-
-} // namespace
-
-void NewCustomElement::AttributeDidChange(Element* element,
- const AtomicString& name,
- const AtomicString& oldValue,
- const AtomicString& newValue) {
- ScheduleCallback(base::Bind(CallAttributeDidChangedCallback,
- element, name, oldValue, newValue));
-}
-
-void NewCustomElement::DidAttach(Element* element, Document& document) {
- ScheduleCallback(base::Bind(CallDidAttachedCallback, element, &document));
-}
-
-void NewCustomElement::DidDetach(Element* element, Document& document) {
- ScheduleCallback(base::Bind(CallDidDetachedCallback, element, &document));
-}
-
-} // namespace blink
« no previous file with comments | « sky/engine/core/dom/custom2/new_custom_element.h ('k') | sky/engine/core/dom/custom2/new_custom_element_callback_scope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698