From 0ca4d99da72d2cc071f52d1f203ab4314ab135aa Mon Sep 17 00:00:00 2001 From: openkraken-bot Date: Tue, 11 Jan 2022 13:36:29 +0000 Subject: [PATCH] Committing clang-format changes --- bridge/bindings/qjs/bom/location.h | 8 +- bridge/bindings/qjs/bom/window.h | 3 +- bridge/bindings/qjs/dom/document.cc | 119 +++++++++--------- bridge/bindings/qjs/dom/document.h | 32 ++--- bridge/bindings/qjs/dom/document_fragment.cc | 2 +- bridge/bindings/qjs/dom/document_fragment.h | 6 +- bridge/bindings/qjs/dom/element.cc | 5 +- bridge/bindings/qjs/dom/element.h | 15 +-- bridge/bindings/qjs/dom/event_target.h | 3 +- bridge/bindings/qjs/dom/node.h | 16 +-- bridge/bindings/qjs/dom/text_node.h | 6 +- bridge/bindings/qjs/executing_context.cc | 1 - bridge/bindings/qjs/executing_context.h | 7 +- bridge/bindings/qjs/executing_context_data.cc | 3 +- bridge/bindings/qjs/executing_context_data.h | 5 +- bridge/bindings/qjs/garbage_collected.h | 12 +- bridge/bindings/qjs/js_context_macros.h | 18 ++- bridge/bindings/qjs/wrapper_type_info.h | 7 +- bridge/page.cc | 2 +- 19 files changed, 121 insertions(+), 149 deletions(-) diff --git a/bridge/bindings/qjs/bom/location.h b/bridge/bindings/qjs/bom/location.h index 50e1a99890..277d7186e5 100644 --- a/bridge/bindings/qjs/bom/location.h +++ b/bridge/bindings/qjs/bom/location.h @@ -20,7 +20,7 @@ class Location : public GarbageCollected { static Location* create(JSContext* ctx); static JSValue reload(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); - void trace(JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func) const override; + void trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) const override; void dispose() const override; }; @@ -35,11 +35,7 @@ auto locationCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst th return location->toQuickJS(); }; -const WrapperTypeInfo locationTypeInfo = { - "Location", - nullptr, - locationCreator -}; +const WrapperTypeInfo locationTypeInfo = {"Location", nullptr, locationCreator}; } // namespace kraken::binding::qjs diff --git a/bridge/bindings/qjs/bom/window.h b/bridge/bindings/qjs/bom/window.h index 2d5fe54e7e..2e01be49b1 100644 --- a/bridge/bindings/qjs/bom/window.h +++ b/bridge/bindings/qjs/bom/window.h @@ -17,7 +17,6 @@ void bindWindow(std::unique_ptr& context); class Window : public EventTarget { public: - Window(); static JSClassID classId; @@ -42,7 +41,7 @@ class Window : public EventTarget { DEFINE_PROTOTYPE_PROPERTY(onerror); - void trace(JSRuntime *rt, JSValue val, JS_MarkFunc *mark_func) const override; + void trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) const override; private: Document* document(); diff --git a/bridge/bindings/qjs/dom/document.cc b/bridge/bindings/qjs/dom/document.cc index ad55cc3e68..3925305726 100644 --- a/bridge/bindings/qjs/dom/document.cc +++ b/bridge/bindings/qjs/dom/document.cc @@ -56,11 +56,10 @@ void traverseNode(Node* node, TraverseHandler handler) { std::once_flag kDocumentInitOnceFlag; void bindDocument(std::unique_ptr& context) { - -// auto* documentConstructor = Document::instance(context.get()); -// context->defineGlobalProperty("Document", documentConstructor->jsObject); -// JSValue documentInstance = JS_CallConstructor(context->ctx(), documentConstructor->jsObject, 0, nullptr); -// context->defineGlobalProperty("document", documentInstance); + // auto* documentConstructor = Document::instance(context.get()); + // context->defineGlobalProperty("Document", documentConstructor->jsObject); + // JSValue documentInstance = JS_CallConstructor(context->ctx(), documentConstructor->jsObject, 0, nullptr); + // context->defineGlobalProperty("document", documentInstance); } JSClassID Document::classId{0}; @@ -77,63 +76,66 @@ Document* Document::create(JSContext* ctx) { Document::Document() : Node() { if (!document_registered) { -// defineElement("img", ImageElement::instance(m_context)); -// defineElement("a", AnchorElement::instance(m_context)); -// defineElement("canvas", CanvasElement::instance(m_context)); -// defineElement("input", InputElement::instance(m_context)); -// defineElement("object", ObjectElement::instance(m_context)); -// defineElement("script", ScriptElement::instance(m_context)); -// defineElement("template", TemplateElement::instance(m_context)); + // defineElement("img", ImageElement::instance(m_context)); + // defineElement("a", AnchorElement::instance(m_context)); + // defineElement("canvas", CanvasElement::instance(m_context)); + // defineElement("input", InputElement::instance(m_context)); + // defineElement("object", ObjectElement::instance(m_context)); + // defineElement("script", ScriptElement::instance(m_context)); + // defineElement("template", TemplateElement::instance(m_context)); document_registered = true; } if (!event_registered) { event_registered = true; -// Event::defineEvent( -// EVENT_INPUT, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new InputEventInstance(InputEvent::instance(context), reinterpret_cast(nativeEvent)); }); -// Event::defineEvent(EVENT_MEDIA_ERROR, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new MediaErrorEventInstance(MediaErrorEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_MESSAGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new MessageEventInstance(MessageEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent( -// EVENT_CLOSE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new CloseEventInstance(CloseEvent::instance(context), reinterpret_cast(nativeEvent)); }); -// Event::defineEvent(EVENT_INTERSECTION_CHANGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new IntersectionChangeEventInstance(IntersectionChangeEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_TOUCH_START, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_TOUCH_END, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_TOUCH_MOVE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_TOUCH_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_SWIPE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_PAN, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_LONG_PRESS, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_SCALE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent( -// EVENT_CLICK, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new MouseEventInstance(MouseEvent::instance(context), reinterpret_cast(nativeEvent)); }); -// Event::defineEvent(EVENT_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new MouseEventInstance(MouseEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); -// Event::defineEvent(EVENT_POPSTATE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { -// return new PopStateEventInstance(PopStateEvent::instance(context), reinterpret_cast(nativeEvent)); -// }); + // Event::defineEvent( + // EVENT_INPUT, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new InputEventInstance(InputEvent::instance(context), + // reinterpret_cast(nativeEvent)); }); + // Event::defineEvent(EVENT_MEDIA_ERROR, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new MediaErrorEventInstance(MediaErrorEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_MESSAGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new MessageEventInstance(MessageEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent( + // EVENT_CLOSE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new CloseEventInstance(CloseEvent::instance(context), + // reinterpret_cast(nativeEvent)); }); + // Event::defineEvent(EVENT_INTERSECTION_CHANGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new IntersectionChangeEventInstance(IntersectionChangeEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_TOUCH_START, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_TOUCH_END, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_TOUCH_MOVE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_TOUCH_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_SWIPE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_PAN, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_LONG_PRESS, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_SCALE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent( + // EVENT_CLICK, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new MouseEventInstance(MouseEvent::instance(context), + // reinterpret_cast(nativeEvent)); }); + // Event::defineEvent(EVENT_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new MouseEventInstance(MouseEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); + // Event::defineEvent(EVENT_POPSTATE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { + // return new PopStateEventInstance(PopStateEvent::instance(context), reinterpret_cast(nativeEvent)); + // }); } } @@ -529,8 +531,7 @@ Document::Document(Document* document) : Node(document, NodeType::DOCUMENT_NODE, #endif } -Document::~Document() { -} +Document::~Document() {} void Document::removeElementById(JSAtom id, Element* element) { if (m_elementMapById.count(id) > 0) { auto& list = m_elementMapById[id]; diff --git a/bridge/bindings/qjs/dom/document.h b/bridge/bindings/qjs/dom/document.h index b83cc42b17..2c61138e4a 100644 --- a/bridge/bindings/qjs/dom/document.h +++ b/bridge/bindings/qjs/dom/document.h @@ -20,17 +20,16 @@ using TraverseHandler = std::function; void traverseNode(Node* node, TraverseHandler handler); class DocumentCookie { -public: + public: DocumentCookie() = default; std::string getCookie(); void setCookie(std::string& str); -private: + private: std::unordered_map cookiePairs; }; - class Document : public Node { public: static JSClassID classId; @@ -64,7 +63,6 @@ class Document : public Node { void dispose() const override; private: - void removeElementById(JSAtom id, Element* element); void addElementById(JSAtom id, Element* element); Element* getDocumentElement(); @@ -73,14 +71,14 @@ class Document : public Node { std::unique_ptr m_cookie; ScriptAnimationController* m_scriptAnimationController; -// DEFINE_PROTOTYPE_FUNCTION(createEvent, 1); -// DEFINE_PROTOTYPE_FUNCTION(createElement, 1); -// DEFINE_PROTOTYPE_FUNCTION(createDocumentFragment, 0); -// DEFINE_PROTOTYPE_FUNCTION(createTextNode, 1); -// DEFINE_PROTOTYPE_FUNCTION(createComment, 1); -// DEFINE_PROTOTYPE_FUNCTION(getElementById, 1); -// DEFINE_PROTOTYPE_FUNCTION(getElementsByTagName, 1); -// DEFINE_PROTOTYPE_FUNCTION(getElementsByClassName, 1); + // DEFINE_PROTOTYPE_FUNCTION(createEvent, 1); + // DEFINE_PROTOTYPE_FUNCTION(createElement, 1); + // DEFINE_PROTOTYPE_FUNCTION(createDocumentFragment, 0); + // DEFINE_PROTOTYPE_FUNCTION(createTextNode, 1); + // DEFINE_PROTOTYPE_FUNCTION(createComment, 1); + // DEFINE_PROTOTYPE_FUNCTION(getElementById, 1); + // DEFINE_PROTOTYPE_FUNCTION(getElementsByTagName, 1); + // DEFINE_PROTOTYPE_FUNCTION(getElementsByClassName, 1); void defineElement(const std::string& tagName, Element* constructor); @@ -89,15 +87,9 @@ class Document : public Node { std::unordered_map elementConstructorMap; }; -auto documentCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags) -> JSValue { - return JS_ThrowTypeError(ctx, "Illegal constructor"); -}; +auto documentCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags) -> JSValue { return JS_ThrowTypeError(ctx, "Illegal constructor"); }; -const WrapperTypeInfo documentTypeInfo = { - "Document", - &nodeTypeInfo, - documentCreator -}; +const WrapperTypeInfo documentTypeInfo = {"Document", &nodeTypeInfo, documentCreator}; } // namespace kraken::binding::qjs diff --git a/bridge/bindings/qjs/dom/document_fragment.cc b/bridge/bindings/qjs/dom/document_fragment.cc index 6b14777bba..2b2c096ad1 100644 --- a/bridge/bindings/qjs/dom/document_fragment.cc +++ b/bridge/bindings/qjs/dom/document_fragment.cc @@ -18,7 +18,7 @@ JSValue DocumentFragment::constructor(ExecutionContext* context) { return context->contextData()->constructorForType(&documentFragmentInfo); } -DocumentFragment * DocumentFragment::create(JSContext* ctx) { +DocumentFragment* DocumentFragment::create(JSContext* ctx) { auto* context = static_cast(JS_GetContextOpaque(ctx)); JSValue prototype = context->contextData()->prototypeForType(&documentFragmentInfo); auto* documentFragment = makeGarbageCollected()->initialize(ctx, &classId); diff --git a/bridge/bindings/qjs/dom/document_fragment.h b/bridge/bindings/qjs/dom/document_fragment.h index a2bdcf8791..b24c57314e 100644 --- a/bridge/bindings/qjs/dom/document_fragment.h +++ b/bridge/bindings/qjs/dom/document_fragment.h @@ -29,11 +29,7 @@ auto documentFragmentCreator = [](JSContext* ctx, JSValueConst func_obj, JSValue return eventTarget->toQuickJS(); }; -const WrapperTypeInfo documentFragmentInfo = { - "DocumentFragment", - &nodeTypeInfo, - documentFragmentCreator -}; +const WrapperTypeInfo documentFragmentInfo = {"DocumentFragment", &nodeTypeInfo, documentFragmentCreator}; } // namespace kraken::binding::qjs diff --git a/bridge/bindings/qjs/dom/element.cc b/bridge/bindings/qjs/dom/element.cc index 3957b66b91..7174f05a36 100644 --- a/bridge/bindings/qjs/dom/element.cc +++ b/bridge/bindings/qjs/dom/element.cc @@ -178,7 +178,7 @@ Element* Element::create(JSContext* ctx) { return element; } -//JSValue Element::instanceConstructor(JSContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) { +// JSValue Element::instanceConstructor(JSContext* ctx, JSValue func_obj, JSValue this_val, int argc, JSValue* argv) { // if (argc == 0) // return JS_ThrowTypeError(ctx, "Illegal constructor"); // JSValue tagName = argv[0]; @@ -880,8 +880,7 @@ void Element::trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) { NodeInstance::trace(rt, val, mark_func); } -Element::Element(Element* element, std::string tagName, bool shouldAddUICommand) - : m_tagName(tagName), NodeInstance(element, NodeType::ELEMENT_NODE, Element::classId(), exoticMethods, "Element") { +Element::Element(Element* element, std::string tagName, bool shouldAddUICommand) : m_tagName(tagName), NodeInstance(element, NodeType::ELEMENT_NODE, Element::classId(), exoticMethods, "Element") { m_attributes = makeGarbageCollected()->initialize(m_ctx, &ElementAttributes::classId); JSValue arguments[] = {jsObject}; JSValue style = JS_CallConstructor(m_ctx, CSSStyleDeclaration::instance(m_context)->jsObject, 1, arguments); diff --git a/bridge/bindings/qjs/dom/element.h b/bridge/bindings/qjs/dom/element.h index 28577ee00b..074afd0f3e 100644 --- a/bridge/bindings/qjs/dom/element.h +++ b/bridge/bindings/qjs/dom/element.h @@ -124,6 +124,7 @@ class Element : public Node { protected: StyleDeclarationInstance* m_style{nullptr}; ElementAttributes* m_attributes{nullptr}; + private: std::string m_tagName; void _notifyNodeRemoved(Node* node) override; @@ -158,13 +159,13 @@ auto elementCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst thi Element* element = Element::create(ctx); auto* document = context->document(); -// auto* Document = Document::instance(context); -// if (Document->isCustomElement(name)) { -// return JS_CallConstructor(ctx, Document->getElementConstructor(context, name), argc, argv); -// } -// -// auto* element = new Element(this, name, true); -// return element->jsObject; + // auto* Document = Document::instance(context); + // if (Document->isCustomElement(name)) { + // return JS_CallConstructor(ctx, Document->getElementConstructor(context, name), argc, argv); + // } + // + // auto* element = new Element(this, name, true); + // return element->jsObject; }; const WrapperTypeInfo elementTypeInfo = {"Element", &nodeTypeInfo, elementCreator}; diff --git a/bridge/bindings/qjs/dom/event_target.h b/bridge/bindings/qjs/dom/event_target.h index f293bfb42a..2bcbe6a567 100644 --- a/bridge/bindings/qjs/dom/event_target.h +++ b/bridge/bindings/qjs/dom/event_target.h @@ -80,7 +80,8 @@ class EventTarget : public GarbageCollected { static void copyNodeProperties(EventTarget* newNode, EventTarget* referenceNode); NativeEventTarget* nativeEventTarget{new NativeEventTarget(this)}; -private: + + private: static int hasProperty(JSContext* ctx, JSValueConst obj, JSAtom atom); static JSValue getProperty(JSContext* ctx, JSValueConst obj, JSAtom atom, JSValueConst receiver); static int setProperty(JSContext* ctx, JSValueConst obj, JSAtom atom, JSValueConst value, JSValueConst receiver, int flags); diff --git a/bridge/bindings/qjs/dom/node.h b/bridge/bindings/qjs/dom/node.h index ddc1b43a71..b47fd31090 100644 --- a/bridge/bindings/qjs/dom/node.h +++ b/bridge/bindings/qjs/dom/node.h @@ -77,7 +77,7 @@ class Node : public EventTarget { void trace(JSRuntime* rt, JSValue val, JS_MarkFunc* mark_func) const override; void dispose() const override; -protected: + protected: NodeJob nodeLink{this}; void refer(); @@ -91,10 +91,10 @@ class Node : public EventTarget { virtual void internalSetTextContent(JSValue content); JSValue internalReplaceChild(Node* newChild, Node* oldChild); - virtual void _notifyNodeRemoved(Node* node); virtual void _notifyNodeInsert(Node* node); -private: + + private: ObjectProperty m_childNodes{context(), jsObject, "childNodes", childNodes}; void ensureDetached(Node* node); @@ -102,15 +102,9 @@ class Node : public EventTarget { static JSValue copyNodeValue(JSContext* ctx, Node* node); }; -auto nodeCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags) -> JSValue { - return JS_ThrowTypeError(ctx, "Illegal constructor"); -}; +auto nodeCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags) -> JSValue { return JS_ThrowTypeError(ctx, "Illegal constructor"); }; -const WrapperTypeInfo nodeTypeInfo = { - "Node", - &eventTargetTypeInfo, - nodeCreator -}; +const WrapperTypeInfo nodeTypeInfo = {"Node", &eventTargetTypeInfo, nodeCreator}; } // namespace kraken::binding::qjs diff --git a/bridge/bindings/qjs/dom/text_node.h b/bridge/bindings/qjs/dom/text_node.h index 2dea9ab6d4..955166d9f5 100644 --- a/bridge/bindings/qjs/dom/text_node.h +++ b/bridge/bindings/qjs/dom/text_node.h @@ -47,11 +47,7 @@ auto textNodeCreator = [](JSContext* ctx, JSValueConst func_obj, JSValueConst th return textNode->toQuickJS(); }; -const WrapperTypeInfo textNodeType = { - "TextNode", - &nodeTypeInfo, - textNodeCreator -}; +const WrapperTypeInfo textNodeType = {"TextNode", &nodeTypeInfo, textNodeCreator}; } // namespace kraken::binding::qjs diff --git a/bridge/bindings/qjs/executing_context.cc b/bridge/bindings/qjs/executing_context.cc index d5f1dcdaf7..0129f81de4 100644 --- a/bridge/bindings/qjs/executing_context.cc +++ b/bridge/bindings/qjs/executing_context.cc @@ -368,7 +368,6 @@ void installPropertyGetter(ExecutionContext* context, JSValue thisObject, const JS_FreeValue(context->ctx(), getter); } - DOMTimerCoordinator* ExecutionContext::timers() { return &m_timers; } diff --git a/bridge/bindings/qjs/executing_context.h b/bridge/bindings/qjs/executing_context.h index 936f9025d6..0c9b3da367 100644 --- a/bridge/bindings/qjs/executing_context.h +++ b/bridge/bindings/qjs/executing_context.h @@ -17,11 +17,11 @@ #include #include #include "bindings/qjs/bom/dom_timer_coordinator.h" +#include "executing_context_data.h" #include "foundation/ui_command_buffer.h" #include "garbage_collected.h" #include "js_context_macros.h" #include "kraken_foundation.h" -#include "executing_context_data.h" #include "qjs_patch.h" #include "wrapper_type_info.h" @@ -156,7 +156,8 @@ static JSValue handleCallThisOnProxy(JSContext* ctx, JSValueConst this_val, int class ObjectProperty { KRAKEN_DISALLOW_COPY_ASSIGN_AND_MOVE(ObjectProperty); -public: + + public: ObjectProperty() = delete; // Define an property on object with a JSValue. @@ -166,7 +167,7 @@ class ObjectProperty { JSValue value() const { return m_value; } -private: + private: JSValue m_value{JS_NULL}; }; diff --git a/bridge/bindings/qjs/executing_context_data.cc b/bridge/bindings/qjs/executing_context_data.cc index 0007e650e3..1a396859e4 100644 --- a/bridge/bindings/qjs/executing_context_data.cc +++ b/bridge/bindings/qjs/executing_context_data.cc @@ -3,7 +3,6 @@ * Author: Kraken Team. */ - #include "executing_context_data.h" namespace kraken::binding::qjs { @@ -71,4 +70,4 @@ JSValue ExecutionContextData::constructorForIdSlowCase(const WrapperTypeInfo* ty return classObject; } -} +} // namespace kraken::binding::qjs diff --git a/bridge/bindings/qjs/executing_context_data.h b/bridge/bindings/qjs/executing_context_data.h index 16e2c8171f..dcc1d2fb55 100644 --- a/bridge/bindings/qjs/executing_context_data.h +++ b/bridge/bindings/qjs/executing_context_data.h @@ -16,7 +16,7 @@ namespace kraken::binding::qjs { // has a 1:1 relationship with ExecutionContext. class ExecutionContextData final { public: - explicit ExecutionContextData(ExecutionContext& context): m_context(context) {}; + explicit ExecutionContextData(ExecutionContext& context) : m_context(context){}; ExecutionContextData(const ExecutionContextData&) = delete; ExecutionContextData& operator=(const ExecutionContextData&) = delete; @@ -33,7 +33,6 @@ class ExecutionContextData final { ExecutionContext& m_context; }; - -} +} // namespace kraken::binding::qjs #endif // KRAKENBRIDGE_CONTEXT_DATA_H diff --git a/bridge/bindings/qjs/garbage_collected.h b/bridge/bindings/qjs/garbage_collected.h index 6fce87e47d..8e8226985b 100644 --- a/bridge/bindings/qjs/garbage_collected.h +++ b/bridge/bindings/qjs/garbage_collected.h @@ -34,8 +34,10 @@ class GarbageCollected { public: using ParentMostGarbageCollectedType = T; - template P* initialize(JSContext* ctx, JSClassID* classId); - template P* initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods); + template + P* initialize(JSContext* ctx, JSClassID* classId); + template + P* initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods); // Must use MakeGarbageCollected. void* operator new(size_t) = delete; @@ -91,7 +93,8 @@ class MakeGarbageCollectedTrait { }; template -template P* GarbageCollected::initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods) { +template +P* GarbageCollected::initialize(JSContext* ctx, JSClassID* classId, JSClassExoticMethods* exoticMethods) { JSRuntime* runtime = JS_GetRuntime(ctx); /// When classId is 0, it means this class are not initialized. We should create a JSClassDef to describe the behavior of this class and associate with classID. @@ -141,7 +144,8 @@ template P* GarbageCollected::initialize(JSContext* ctx, JSClass } template -template P* GarbageCollected::initialize(JSContext* ctx, JSClassID* classId) { +template +P* GarbageCollected::initialize(JSContext* ctx, JSClassID* classId) { return initialize

(ctx, classId, nullptr); } diff --git a/bridge/bindings/qjs/js_context_macros.h b/bridge/bindings/qjs/js_context_macros.h index e514f28cbe..971280e9a7 100644 --- a/bridge/bindings/qjs/js_context_macros.h +++ b/bridge/bindings/qjs/js_context_macros.h @@ -15,45 +15,41 @@ #define IMPL_PROPERTY_GETTER(Constructor, Property) JSValue Constructor::Property##PropertyDescriptor::getter #define IMPL_PROPERTY_SETTER(Constructor, Property) JSValue Constructor::Property##PropertyDescriptor::setter -#define INSTALL_READONLY_PROPERTY(Host, thisObject, property) \ - installPropertyGetter(context.get(), thisObject, #property, Host::property##PropertyDescriptor::getter) +#define INSTALL_READONLY_PROPERTY(Host, thisObject, property) installPropertyGetter(context.get(), thisObject, #property, Host::property##PropertyDescriptor::getter) #define INSTALL_PROPERTY(Host, thisObject, property) \ installPropertyGetterSetter(context.get(), thisObject, #property, Host::property##PropertyDescriptor::getter, Host::property##PropertyDescriptor::setter) -#define INSTALL_FUNCTION(Host, thisObject, property, argc) \ - installFunctionProperty(context.get(), thisObject, #property, Host::m_##property##_, 1); +#define INSTALL_FUNCTION(Host, thisObject, property, argc) installFunctionProperty(context.get(), thisObject, #property, Host::m_##property##_, 1); -#define DEFINE_FUNCTION(NAME) \ - static JSValue m_##NAME##_(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); +#define DEFINE_FUNCTION(NAME) static JSValue m_##NAME##_(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); #define IMPL_FUNCTION(Host, NAME) JSValue Host::m_##NAME##_ - #define DEFINE_PROTOTYPE_READONLY_PROPERTY(PROPERTY) \ class PROPERTY##PropertyDescriptor { \ public: \ static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \ - }; \ + }; #define DEFINE_PROTOTYPE_PROPERTY(PROPERTY) \ class PROPERTY##PropertyDescriptor { \ public: \ static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \ static JSValue setter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \ - }; \ + }; #define DEFINE_READONLY_PROPERTY(PROPERTY) \ class PROPERTY##PropertyDescriptor { \ public: \ static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \ - }; \ + }; #define DEFINE_PROPERTY(PROPERTY) \ class PROPERTY##PropertyDescriptor { \ public: \ static JSValue getter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \ static JSValue setter(JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv); \ - }; \ + }; #endif // KRAKENBRIDGE_JS_CONTEXT_MACROS_H diff --git a/bridge/bindings/qjs/wrapper_type_info.h b/bridge/bindings/qjs/wrapper_type_info.h index a7bc005cd0..02496a855c 100644 --- a/bridge/bindings/qjs/wrapper_type_info.h +++ b/bridge/bindings/qjs/wrapper_type_info.h @@ -6,8 +6,8 @@ #ifndef KRAKENBRIDGE_WRAPPER_TYPE_INFO_H #define KRAKENBRIDGE_WRAPPER_TYPE_INFO_H -#include #include +#include #include "bindings/qjs/qjs_patch.h" #include "include/kraken_foundation.h" @@ -22,8 +22,7 @@ class WrapperTypeInfo final { bool equals(const WrapperTypeInfo* that) const { return this == that; } bool isSubclass(const WrapperTypeInfo* that) const { - for (const WrapperTypeInfo* current = this; current; - current = current->parent_class) { + for (const WrapperTypeInfo* current = this; current; current = current->parent_class) { if (current == that) return true; } @@ -37,6 +36,6 @@ class WrapperTypeInfo final { JSClassID classId{0}; }; -} +} // namespace kraken::binding::qjs #endif // KRAKENBRIDGE_WRAPPER_TYPE_INFO_H diff --git a/bridge/page.cc b/bridge/page.cc index c24d439888..02602cd6ce 100644 --- a/bridge/page.cc +++ b/bridge/page.cc @@ -12,10 +12,10 @@ #include "bindings/qjs/bom/blob.h" #include "bindings/qjs/bom/console.h" +#include "bindings/qjs/bom/location.h" #include "bindings/qjs/bom/performance.h" #include "bindings/qjs/bom/screen.h" #include "bindings/qjs/bom/timer.h" -#include "bindings/qjs/bom/location.h" #include "bindings/qjs/bom/window.h" #include "bindings/qjs/dom/comment_node.h" #include "bindings/qjs/dom/custom_event.h"