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

Unified Diff: sky/engine/bindings-dart/core/dart/custom/DartMessagePortCustom.cpp

Issue 875013003: Import Dart bindings as of Blink r188698. This merely copies the files over and does not attach any… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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/bindings-dart/core/dart/custom/DartMessagePortCustom.cpp
diff --git a/sky/engine/platform/text/TextRunIterator.h b/sky/engine/bindings-dart/core/dart/custom/DartMessagePortCustom.cpp
similarity index 50%
copy from sky/engine/platform/text/TextRunIterator.h
copy to sky/engine/bindings-dart/core/dart/custom/DartMessagePortCustom.cpp
index 280ff3f155a50d1407e7ed4225cb587714c49ef0..e7b6370eef11779ba434114c032abb6ab6fff7a2 100644
--- a/sky/engine/platform/text/TextRunIterator.h
+++ b/sky/engine/bindings-dart/core/dart/custom/DartMessagePortCustom.cpp
@@ -1,4 +1,5 @@
-// Copyright (C) 2013 Google Inc. All rights reserved.
+// Copyright 2011, Google Inc.
+// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -26,53 +27,62 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef SKY_ENGINE_PLATFORM_TEXT_TEXTRUNITERATOR_H_
-#define SKY_ENGINE_PLATFORM_TEXT_TEXTRUNITERATOR_H_
+#include "config.h"
+#include "bindings/core/dart/DartMessagePort.h"
-#include "sky/engine/platform/text/TextRun.h"
+#include "bindings/core/dart/DartDOMWrapper.h"
+#include "bindings/core/dart/DartUtilities.h"
+#include "core/dom/MessagePort.h"
namespace blink {
-class TextRunIterator {
-public:
- TextRunIterator()
- : m_textRun(0)
- , m_offset(0)
- {
- }
+namespace DartMessagePortInternal {
- TextRunIterator(const TextRun* textRun, unsigned offset)
- : m_textRun(textRun)
- , m_offset(offset)
+void handlePostMessageCallback(Dart_NativeArguments args, bool extendedTransfer)
+{
+ Dart_Handle exception = 0;
{
- }
+ MessagePort* receiver = DartDOMWrapper::receiver<MessagePort>(args);
- TextRunIterator(const TextRunIterator& other)
- : m_textRun(other.m_textRun)
- , m_offset(other.m_offset)
- {
- }
+ MessagePortArray portArray;
+ ArrayBufferArray bufferArray;
+ DartUtilities::toMessagePortArray(Dart_GetNativeArgument(args, 2), portArray, bufferArray, exception);
+ if (exception)
+ goto fail;
- unsigned offset() const { return m_offset; }
- void increment() { m_offset++; }
- bool atEnd() const { return !m_textRun || m_offset >= m_textRun->length(); }
- UChar current() const { return (*m_textRun)[m_offset]; }
- WTF::Unicode::Direction direction() const { return atEnd() ? WTF::Unicode::OtherNeutral : WTF::Unicode::direction(current()); }
- bool atParagraphSeparator() const { return current() == '\n'; }
+ RefPtr<SerializedScriptValue> message = DartUtilities::toSerializedScriptValue(
+ Dart_GetNativeArgument(args, 1),
+ &portArray,
+ extendedTransfer ? &bufferArray : 0,
+ exception);
+ if (exception)
+ goto fail;
- bool operator==(const TextRunIterator& other)
- {
- return m_offset == other.m_offset && m_textRun == other.m_textRun;
+ DartExceptionState es;
+ receiver->postMessage(DartUtilities::scriptExecutionContext(), message.release(), &portArray, es);
+ if (es.hadException()) {
+ exception = es.toDart(args);
+ goto fail;
+ }
+
+ return;
}
- bool operator!=(const TextRunIterator& other) { return !operator==(other); }
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
-private:
- const TextRun* m_textRun;
- int m_offset;
-};
+void postMessageCallback(Dart_NativeArguments args)
+{
+ handlePostMessageCallback(args, false);
+}
+void webkitPostMessageCallback(Dart_NativeArguments args)
+{
+ handlePostMessageCallback(args, true);
+}
-} // namespace blink
+}
-#endif // SKY_ENGINE_PLATFORM_TEXT_TEXTRUNITERATOR_H_
+}

Powered by Google App Engine
This is Rietveld 408576698