diff --git a/bridge/bindings/qjs/dart_methods.cc b/bridge/bindings/qjs/dart_methods.cc index 2f955890ae..564fb50273 100644 --- a/bridge/bindings/qjs/dart_methods.cc +++ b/bridge/bindings/qjs/dart_methods.cc @@ -4,13 +4,12 @@ */ #include "dart_methods.h" -#include "foundation/macros.h" #include +#include "foundation/macros.h" namespace kraken { -//std::shared_ptr methodPointer = std::make_shared() - +// std::shared_ptr methodPointer = std::make_shared() std::shared_ptr getDartMethod() { std::thread::id currentThread = std::this_thread::get_id(); @@ -24,16 +23,12 @@ std::shared_ptr getDartMethod() { return std::make_shared(); } #endif -// return methodPointer; + // return methodPointer; } -void registerDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) { +void registerDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) {} -} - -void registerTestEnvDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) { - -} +void registerTestEnvDartMethods(std::shared_ptr methodPointer, uint64_t* methodBytes, int32_t length) {} #if ENABLE_PROFILE void registerGetPerformanceEntries(GetPerformanceEntries getPerformanceEntries) { diff --git a/bridge/bindings/qjs/native_string.cc b/bridge/bindings/qjs/native_string.cc index 278f97b805..61d4b12e47 100644 --- a/bridge/bindings/qjs/native_string.cc +++ b/bridge/bindings/qjs/native_string.cc @@ -8,7 +8,6 @@ namespace kraken { - NativeString* NativeString::clone() { auto* newNativeString = new NativeString(); auto* newString = new uint16_t[length]; @@ -45,7 +44,6 @@ std::unique_ptr jsValueToNativeString(JSContext* ctx, JSValue valu return ptr; } - std::unique_ptr stringToNativeString(const std::string& string) { std::u16string utf16; fromUTF8(string, utf16); @@ -76,6 +74,4 @@ std::string jsAtomToStdString(JSContext* ctx, JSAtom atom) { return str; } - - -} +} // namespace kraken diff --git a/bridge/bindings/qjs/native_string.h b/bridge/bindings/qjs/native_string.h index 92783e2aae..f966063bd1 100644 --- a/bridge/bindings/qjs/native_string.h +++ b/bridge/bindings/qjs/native_string.h @@ -8,10 +8,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include namespace kraken { @@ -54,7 +54,7 @@ void fromUTF8(const std::string& source, std::basic_string running_context_list) diff --git a/bridge/core/executing_context.h b/bridge/core/executing_context.h index 9976074d1f..e853a5fabc 100644 --- a/bridge/core/executing_context.h +++ b/bridge/core/executing_context.h @@ -16,10 +16,10 @@ #include #include #include -#include "foundation/macros.h" +#include "bindings/qjs/garbage_collected.h" #include "executing_context_data.h" +#include "foundation/macros.h" #include "foundation/ui_command_buffer.h" -#include "bindings/qjs/garbage_collected.h" //#include "garbage_collected.h" //#include "qjs_patch.h" //#include "dart_methods.h" diff --git a/bridge/core/executing_context_data.h b/bridge/core/executing_context_data.h index a24cd43e8f..90e612df4f 100644 --- a/bridge/core/executing_context_data.h +++ b/bridge/core/executing_context_data.h @@ -6,8 +6,8 @@ #ifndef KRAKENBRIDGE_CONTEXT_DATA_H #define KRAKENBRIDGE_CONTEXT_DATA_H -#include #include +#include #include "bindings/qjs/wrapper_type_info.h" namespace kraken { diff --git a/bridge/core/html/html_all_collection.cc b/bridge/core/html/html_all_collection.cc index 98318d2d82..0f6894bc77 100644 --- a/bridge/core/html/html_all_collection.cc +++ b/bridge/core/html/html_all_collection.cc @@ -5,9 +5,9 @@ // //#include "html_all_collection.h" // -//namespace kraken { +// namespace kraken { // -//JSValue AllCollection::item(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// JSValue AllCollection::item(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // if (argc < 1) { // return JS_NULL; // } @@ -23,7 +23,7 @@ // auto node = collection->m_nodes[index]; // return node->jsObject; //} -//JSValue AllCollection::add(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// JSValue AllCollection::add(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // if (argc < 1) { // return JS_ThrowTypeError(ctx, "Failed to execute add() on HTMLAllCollection: 1 arguments required."); // } @@ -50,7 +50,7 @@ // // return JS_NULL; //} -//JSValue AllCollection::remove(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// JSValue AllCollection::remove(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // if (argc < 1) { // return JS_ThrowTypeError(ctx, "Failed to execute remove() on HTMLAllCollection: 1 arguments required."); // } @@ -61,7 +61,7 @@ // collection->m_nodes.erase(collection->m_nodes.begin() + index); // return JS_NULL; //} -//void AllCollection::internalAdd(NodeInstance* node, NodeInstance* before) { +// void AllCollection::internalAdd(NodeInstance* node, NodeInstance* before) { // if (before != nullptr) { // auto it = std::find(m_nodes.begin(), m_nodes.end(), before); // m_nodes.erase(it); @@ -71,7 +71,7 @@ // } //} // -//IMPL_PROPERTY_GETTER(AllCollection, length)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(AllCollection, length)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* collection = static_cast(JS_GetOpaque(this_val, ExecutionContext::kHostObjectClassId)); // return JS_NewUint32(ctx, collection->m_nodes.size()); //} diff --git a/bridge/core/html/html_all_collection.h b/bridge/core/html/html_all_collection.h index 9946cd154a..9483d30fd0 100644 --- a/bridge/core/html/html_all_collection.h +++ b/bridge/core/html/html_all_collection.h @@ -8,9 +8,9 @@ // //#include "bindings/qjs/garbage_collected.h" // -//namespace kraken { +// namespace kraken { // -//class HTMLAllCollection : public HostObject { +// class HTMLAllCollection : public HostObject { // public: // AllCollection(ExecutionContext* context) : HostObject(context, "AllCollection"){}; // diff --git a/bridge/core/html/html_image_element.cc b/bridge/core/html/html_image_element.cc index 874d50634a..a7017caf2b 100644 --- a/bridge/core/html/html_image_element.cc +++ b/bridge/core/html/html_image_element.cc @@ -7,28 +7,28 @@ //#include "bindings/qjs/qjs_patch.h" //#include "page.h" // -//namespace kraken { +// namespace kraken { // -//ImageElement::ImageElement(ExecutionContext* context) : Element(context) { +// ImageElement::ImageElement(ExecutionContext* context) : Element(context) { // JS_SetPrototype(m_ctx, m_prototypeObject, Element::instance(m_context)->prototype()); //} // -//void bindImageElement(ExecutionContext* context) { +// void bindImageElement(ExecutionContext* context) { // auto* constructor = ImageElement::instance(context); // context->defineGlobalProperty("HTMLImageElement", constructor->jsObject); // context->defineGlobalProperty("Image", JS_DupValue(context->ctx(), constructor->jsObject)); //} // -//JSValue ImageElement::instanceConstructor(JSContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) { +// JSValue ImageElement::instanceConstructor(JSContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) { // auto instance = new ImageElementInstance(this); // return instance->jsObject; //} -//IMPL_PROPERTY_GETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("width"); //} -//IMPL_PROPERTY_SETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, width)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "width"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -36,12 +36,12 @@ // element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr); // return JS_NULL; //} -//IMPL_PROPERTY_GETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("height"); //} -//IMPL_PROPERTY_SETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, height)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "height"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -49,22 +49,22 @@ // element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr); // return JS_NULL; //} -//IMPL_PROPERTY_GETTER(ImageElement, naturalWidth)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, naturalWidth)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("naturalWidth"); //} -//IMPL_PROPERTY_GETTER(ImageElement, naturalHeight)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, naturalHeight)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("naturalHeight"); //} -//IMPL_PROPERTY_GETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("src"); //} -//IMPL_PROPERTY_SETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, src)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "src"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -72,12 +72,12 @@ // element->m_context->uiCommandBuffer()->addCommand(element->m_eventTargetId, UICommand::setProperty, *args_01, *args_02, nullptr); // return JS_NULL; //} -//IMPL_PROPERTY_GETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_GETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // getDartMethod()->flushUICommand(); // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // return element->getNativeProperty("loading"); //} -//IMPL_PROPERTY_SETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { +// IMPL_PROPERTY_SETTER(ImageElement, loading)(JSContext* ctx, JSValue this_val, int argc, JSValue* argv) { // auto* element = static_cast(JS_GetOpaque(this_val, Element::classId())); // std::string key = "loading"; // std::unique_ptr args_01 = stringToNativeString(key); @@ -86,12 +86,12 @@ // return JS_NULL; //} // -//ImageElementInstance::ImageElementInstance(ImageElement* element) : ElementInstance(element, "img", true) { +// ImageElementInstance::ImageElementInstance(ImageElement* element) : ElementInstance(element, "img", true) { // // Protect image instance util load or error event triggered. // refer(); //} // -//bool ImageElementInstance::dispatchEvent(EventInstance* event) { +// bool ImageElementInstance::dispatchEvent(EventInstance* event) { // std::u16string u16EventType = std::u16string(reinterpret_cast(event->nativeEvent->type->string), event->nativeEvent->type->length); // std::string eventType = toUTF8(u16EventType); // bool result = EventTargetInstance::dispatchEvent(event); diff --git a/bridge/core/html/html_image_element.h b/bridge/core/html/html_image_element.h index e1e2d051d4..4df787ea41 100644 --- a/bridge/core/html/html_image_element.h +++ b/bridge/core/html/html_image_element.h @@ -8,12 +8,12 @@ // //#include "bindings/qjs/dom/element.h" // -//namespace kraken { +// namespace kraken { // -//void bindImageElement(ExecutionContext* context); +// void bindImageElement(ExecutionContext* context); // -//class ImageElementInstance; -//class ImageElement : public Element { +// class ImageElementInstance; +// class ImageElement : public Element { // public: // ImageElement() = delete; // explicit ImageElement(ExecutionContext* context); @@ -32,7 +32,7 @@ // friend ImageElementInstance; //}; // -//class ImageElementInstance : public ElementInstance { +// class ImageElementInstance : public ElementInstance { // public: // ImageElementInstance() = delete; // explicit ImageElementInstance(ImageElement* element); diff --git a/bridge/foundation/logging.h b/bridge/foundation/logging.h index 5e2f47805a..2efe33d7af 100644 --- a/bridge/foundation/logging.h +++ b/bridge/foundation/logging.h @@ -33,18 +33,18 @@ constexpr LogSeverity LOG_NUM_SEVERITIES = 5; constexpr LogSeverity LOG_FATAL = 6; class LogMessageVoidify { -public: + public: void operator&(std::ostream&) {} }; class LogMessage { - public: + public: LogMessage(LogSeverity severity, const char* file, int line, const char* condition); ~LogMessage(); std::ostream& stream() { return stream_; } - private: + private: std::ostringstream stream_; const LogSeverity severity_; const char* file_; diff --git a/bridge/foundation/macros.h b/bridge/foundation/macros.h index a65cf1ec79..85ae551827 100644 --- a/bridge/foundation/macros.h +++ b/bridge/foundation/macros.h @@ -40,5 +40,4 @@ TypeName() = delete; \ KRAKEN_DISALLOW_COPY_ASSIGN_AND_MOVE(TypeName) - #endif // KRAKENBRIDGE_MACROS_H diff --git a/bridge/foundation/native_value.cc b/bridge/foundation/native_value.cc index 8bc6bdaf3d..6a98c6fa17 100644 --- a/bridge/foundation/native_value.cc +++ b/bridge/foundation/native_value.cc @@ -4,9 +4,9 @@ */ #include "native_value.h" +#include "bindings/qjs/dom/event_target.h" #include "bindings/qjs/executing_context.h" #include "bindings/qjs/qjs_patch.h" -#include "bindings/qjs/dom/event_target.h" namespace kraken { @@ -272,4 +272,4 @@ JSValue nativeValueToJSValue(ExecutionContext* context, NativeValue& value) { return JS_NULL; } -} // namespace kraken::binding::qjs +} // namespace kraken diff --git a/bridge/foundation/native_value.h b/bridge/foundation/native_value.h index 3453105b92..a945bdea29 100644 --- a/bridge/foundation/native_value.h +++ b/bridge/foundation/native_value.h @@ -67,6 +67,6 @@ NativeValue Native_NewJSON(ExecutionContext* context, JSValue& value); NativeValue jsValueToNativeValue(JSContext* ctx, JSValue& value); JSValue nativeValueToJSValue(ExecutionContext* context, NativeValue& value); -} // namespace kraken::binding::qjs +} // namespace kraken #endif // KRAKENBRIDGE_NATIVE_VALUE_H diff --git a/bridge/foundation/ref_ptr.h b/bridge/foundation/ref_ptr.h index ddadd0e382..3b47ebd881 100644 --- a/bridge/foundation/ref_ptr.h +++ b/bridge/foundation/ref_ptr.h @@ -13,8 +13,8 @@ #include #include "logging.h" -#include "ref_ptr_internal.h" #include "macros.h" +#include "ref_ptr_internal.h" namespace fml { diff --git a/bridge/foundation/ui_command_buffer.cc b/bridge/foundation/ui_command_buffer.cc index 39ff4e7ffe..f0e7318ff9 100644 --- a/bridge/foundation/ui_command_buffer.cc +++ b/bridge/foundation/ui_command_buffer.cc @@ -9,7 +9,7 @@ namespace kraken { -UICommandBuffer::UICommandBuffer(ExecutionContext *context) : m_context(context) {} +UICommandBuffer::UICommandBuffer(ExecutionContext* context) : m_context(context) {} void UICommandBuffer::addCommand(int32_t id, int32_t type, void* nativePtr, bool batchedUpdate) { if (batchedUpdate) { diff --git a/bridge/foundation/ui_command_buffer.h b/bridge/foundation/ui_command_buffer.h index 25d9eee78c..bb50c92c34 100644 --- a/bridge/foundation/ui_command_buffer.h +++ b/bridge/foundation/ui_command_buffer.h @@ -6,10 +6,10 @@ #ifndef KRAKENBRIDGE_FOUNDATION_UI_COMMAND_BUFFER_H_ #define KRAKENBRIDGE_FOUNDATION_UI_COMMAND_BUFFER_H_ -#include #include -#include "native_value.h" +#include #include "bindings/qjs/native_string.h" +#include "native_value.h" namespace kraken { @@ -33,15 +33,15 @@ enum UICommand { struct UICommandItem { UICommandItem(int32_t id, int32_t type, NativeString args_01, NativeString args_02, void* nativePtr) - : type(type), - string_01(reinterpret_cast(args_01.string)), - args_01_length(args_01.length), - string_02(reinterpret_cast(args_02.string)), - args_02_length(args_02.length), - id(id), - nativePtr(reinterpret_cast(nativePtr)){}; + : type(type), + string_01(reinterpret_cast(args_01.string)), + args_01_length(args_01.length), + string_02(reinterpret_cast(args_02.string)), + args_02_length(args_02.length), + id(id), + nativePtr(reinterpret_cast(nativePtr)){}; UICommandItem(int32_t id, int32_t type, NativeString args_01, void* nativePtr) - : type(type), string_01(reinterpret_cast(args_01.string)), args_01_length(args_01.length), id(id), nativePtr(reinterpret_cast(nativePtr)){}; + : type(type), string_01(reinterpret_cast(args_01.string)), args_01_length(args_01.length), id(id), nativePtr(reinterpret_cast(nativePtr)){}; UICommandItem(int32_t id, int32_t type, void* nativePtr) : type(type), id(id), nativePtr(reinterpret_cast(nativePtr)){}; int32_t type; int32_t id; @@ -65,7 +65,7 @@ class UICommandBuffer { void clear(); private: - ExecutionContext *m_context{nullptr}; + ExecutionContext* m_context{nullptr}; std::atomic update_batched{false}; std::vector queue; }; diff --git a/bridge/kraken_bridge.cc b/bridge/kraken_bridge.cc index 26237b63b1..c7a8873477 100644 --- a/bridge/kraken_bridge.cc +++ b/bridge/kraken_bridge.cc @@ -4,15 +4,15 @@ */ #include -#include #include +#include -#include "include/kraken_bridge.h" +#include "bindings/qjs/native_string.h" #include "foundation/inspector_task_queue.h" #include "foundation/logging.h" -#include "foundation/ui_task_queue.h" #include "foundation/ui_command_buffer.h" -#include "bindings/qjs/native_string.h" +#include "foundation/ui_task_queue.h" +#include "include/kraken_bridge.h" #include "page.h" #if defined(_WIN32) @@ -162,9 +162,9 @@ void registerDartMethods(int32_t contextId, uint64_t* methodBytes, int32_t lengt } NativeScreen* createScreen(double width, double height) { -// screen.width = width; -// screen.height = height; -// return &screen; + // screen.width = width; + // screen.height = height; + // return &screen; } static KrakenInfo* krakenInfo{nullptr}; diff --git a/bridge/page.cc b/bridge/page.cc index 6a26d3d412..63e3216022 100644 --- a/bridge/page.cc +++ b/bridge/page.cc @@ -5,10 +5,10 @@ #include -#include "foundation/logging.h" -#include "polyfill.h" #include "bindings/qjs/qjs_patch.h" +#include "foundation/logging.h" #include "page.h" +#include "polyfill.h" //#include "bindings/qjs/bom/blob.h" //#include "bindings/qjs/bom/console.h" @@ -57,12 +57,15 @@ KrakenPage::KrakenPage(int32_t contextId, const JSExceptionHandler& handler) : c #if ENABLE_PROFILE auto jsContextStartTime = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); #endif - m_context = new ExecutionContext(contextId, [this](int32_t contextId, const char* message) { - if (m_context->dartMethodPtr()->onJsError != nullptr) { - m_context->dartMethodPtr()->onJsError(contextId, message); - } - KRAKEN_LOG(ERROR) << message << std::endl; - }, this); + m_context = new ExecutionContext( + contextId, + [this](int32_t contextId, const char* message) { + if (m_context->dartMethodPtr()->onJsError != nullptr) { + m_context->dartMethodPtr()->onJsError(contextId, message); + } + KRAKEN_LOG(ERROR) << message << std::endl; + }, + this); #if ENABLE_PROFILE auto nativePerformance = Performance::instance(m_context)->m_nativePerformance; @@ -71,21 +74,21 @@ KrakenPage::KrakenPage(int32_t contextId, const JSExceptionHandler& handler) : c nativePerformance.mark(PERF_JS_NATIVE_METHOD_INIT_START); #endif -// bindConsole(m_context); -// bindTimer(m_context); -// bindScreen(m_context); -// bindModuleManager(m_context); -// bindEventTarget(m_context); -// bindBlob(m_context); -// bindLocation(m_context); -// bindWindow(m_context); -// bindEvent(m_context); -// bindCustomEvent(m_context); -// bindNode(m_context); -// bindDocumentFragment(m_context); -// bindTextNode(m_context); -// bindCommentNode(m_context); -// bindElement(m_context); + // bindConsole(m_context); + // bindTimer(m_context); + // bindScreen(m_context); + // bindModuleManager(m_context); + // bindEventTarget(m_context); + // bindBlob(m_context); + // bindLocation(m_context); + // bindWindow(m_context); + // bindEvent(m_context); + // bindCustomEvent(m_context); + // bindNode(m_context); + // bindDocumentFragment(m_context); + // bindTextNode(m_context); + // bindCommentNode(m_context); + // bindElement(m_context); // bindAnchorElement(m_context); // bindCanvasElement(m_context); // bindImageElement(m_context); @@ -93,7 +96,7 @@ KrakenPage::KrakenPage(int32_t contextId, const JSExceptionHandler& handler) : c // bindObjectElement(m_context); // bindScriptElement(m_context); // bindTemplateElement(m_context); -// bindCSSStyleDeclaration(m_context); + // bindCSSStyleDeclaration(m_context); // bindCloseEvent(m_context); // bindGestureEvent(m_context); // bindInputEvent(m_context); @@ -103,7 +106,7 @@ KrakenPage::KrakenPage(int32_t contextId, const JSExceptionHandler& handler) : c // bindMessageEvent(m_context); // bindPopStateEvent(m_context); // bindTouchEvent(m_context); -// bindDocument(m_context); + // bindDocument(m_context); // bindPerformance(m_context); #if ENABLE_PROFILE @@ -123,56 +126,56 @@ KrakenPage::KrakenPage(int32_t contextId, const JSExceptionHandler& handler) : c } bool KrakenPage::parseHTML(const char* code, size_t length) { -// if (!m_context->isValid()) -// return false; -// JSValue bodyValue = JS_GetPropertyStr(m_context->ctx(), m_context->document()->jsObject, "body"); -// auto* body = static_cast(JS_GetOpaque(bodyValue, Element::classId)); -// HTMLParser::parseHTML(code, length, body); -// JS_FreeValue(m_context->ctx(), bodyValue); -// return true; + // if (!m_context->isValid()) + // return false; + // JSValue bodyValue = JS_GetPropertyStr(m_context->ctx(), m_context->document()->jsObject, "body"); + // auto* body = static_cast(JS_GetOpaque(bodyValue, Element::classId)); + // HTMLParser::parseHTML(code, length, body); + // JS_FreeValue(m_context->ctx(), bodyValue); + // return true; } void KrakenPage::invokeModuleEvent(const NativeString* moduleName, const char* eventType, void* ptr, NativeString* extra) { -// if (!m_context->isValid()) -// return; -// -// JSValue eventObject = JS_NULL; -// if (ptr != nullptr) { -// std::string type = std::string(eventType); -// auto* rawEvent = static_cast(ptr)->bytes; -// Event* event = Event::create(m_context->ctx(), reinterpret_cast(rawEvent)); -// eventObject = event->toQuickJS(); -// } -// -// JSValue moduleNameValue = JS_NewUnicodeString(m_context->runtime(), m_context->ctx(), moduleName->string, moduleName->length); -// JSValue extraObject = JS_NULL; -// if (extra != nullptr) { -// std::u16string u16Extra = std::u16string(reinterpret_cast(extra->string), extra->length); -// std::string extraString = toUTF8(u16Extra); -// extraObject = JS_ParseJSON(m_context->ctx(), extraString.c_str(), extraString.size(), ""); -// } -// -// { -// struct list_head *el, *el1; -// list_for_each_safe(el, el1, &m_context->module_job_list) { -// auto* module = list_entry(el, ModuleContext, link); -// JSValue callback = module->callback; -// -// JSValue arguments[] = {moduleNameValue, eventObject, extraObject}; -// JSValue returnValue = JS_Call(m_context->ctx(), callback, m_context->global(), 3, arguments); -// m_context->handleException(&returnValue); -// JS_FreeValue(m_context->ctx(), returnValue); -// } -// } -// -// JS_FreeValue(m_context->ctx(), moduleNameValue); -// -// if (rawEvent != nullptr) { -// JS_FreeValue(m_context->ctx(), eventObject); -// } -// if (extra != nullptr) { -// JS_FreeValue(m_context->ctx(), extraObject); -// } + // if (!m_context->isValid()) + // return; + // + // JSValue eventObject = JS_NULL; + // if (ptr != nullptr) { + // std::string type = std::string(eventType); + // auto* rawEvent = static_cast(ptr)->bytes; + // Event* event = Event::create(m_context->ctx(), reinterpret_cast(rawEvent)); + // eventObject = event->toQuickJS(); + // } + // + // JSValue moduleNameValue = JS_NewUnicodeString(m_context->runtime(), m_context->ctx(), moduleName->string, moduleName->length); + // JSValue extraObject = JS_NULL; + // if (extra != nullptr) { + // std::u16string u16Extra = std::u16string(reinterpret_cast(extra->string), extra->length); + // std::string extraString = toUTF8(u16Extra); + // extraObject = JS_ParseJSON(m_context->ctx(), extraString.c_str(), extraString.size(), ""); + // } + // + // { + // struct list_head *el, *el1; + // list_for_each_safe(el, el1, &m_context->module_job_list) { + // auto* module = list_entry(el, ModuleContext, link); + // JSValue callback = module->callback; + // + // JSValue arguments[] = {moduleNameValue, eventObject, extraObject}; + // JSValue returnValue = JS_Call(m_context->ctx(), callback, m_context->global(), 3, arguments); + // m_context->handleException(&returnValue); + // JS_FreeValue(m_context->ctx(), returnValue); + // } + // } + // + // JS_FreeValue(m_context->ctx(), moduleNameValue); + // + // if (rawEvent != nullptr) { + // JS_FreeValue(m_context->ctx(), eventObject); + // } + // if (extra != nullptr) { + // JS_FreeValue(m_context->ctx(), extraObject); + // } } void KrakenPage::evaluateScript(const NativeString* script, const char* url, int startLine) { diff --git a/bridge/page.h b/bridge/page.h index d979b5b322..68a75231a5 100644 --- a/bridge/page.h +++ b/bridge/page.h @@ -9,8 +9,8 @@ #include #include #include -#include #include +#include #include "bindings/qjs/executing_context.h" #include "bindings/qjs/html_parser.h"