Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
openkraken-bot committed Jan 11, 2022
1 parent 3449e36 commit 0ca4d99
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 149 deletions.
8 changes: 2 additions & 6 deletions bridge/bindings/qjs/bom/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Location : public GarbageCollected<Location> {
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;
};

Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions bridge/bindings/qjs/bom/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void bindWindow(std::unique_ptr<ExecutionContext>& context);

class Window : public EventTarget {
public:

Window();

static JSClassID classId;
Expand All @@ -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();
Expand Down
119 changes: 60 additions & 59 deletions bridge/bindings/qjs/dom/document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ void traverseNode(Node* node, TraverseHandler handler) {
std::once_flag kDocumentInitOnceFlag;

void bindDocument(std::unique_ptr<ExecutionContext>& 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};
Expand All @@ -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*>(nativeEvent)); });
// Event::defineEvent(EVENT_MEDIA_ERROR, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new MediaErrorEventInstance(MediaErrorEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_MESSAGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new MessageEventInstance(MessageEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(
// EVENT_CLOSE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new CloseEventInstance(CloseEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent)); });
// Event::defineEvent(EVENT_INTERSECTION_CHANGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new IntersectionChangeEventInstance(IntersectionChangeEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_START, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_END, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_MOVE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_SWIPE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_PAN, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_LONG_PRESS, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_SCALE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(
// EVENT_CLICK, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new MouseEventInstance(MouseEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent)); });
// Event::defineEvent(EVENT_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new MouseEventInstance(MouseEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_POPSTATE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new PopStateEventInstance(PopStateEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(
// EVENT_INPUT, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new InputEventInstance(InputEvent::instance(context),
// reinterpret_cast<NativeEvent*>(nativeEvent)); });
// Event::defineEvent(EVENT_MEDIA_ERROR, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new MediaErrorEventInstance(MediaErrorEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_MESSAGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new MessageEventInstance(MessageEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(
// EVENT_CLOSE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new CloseEventInstance(CloseEvent::instance(context),
// reinterpret_cast<NativeEvent*>(nativeEvent)); });
// Event::defineEvent(EVENT_INTERSECTION_CHANGE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new IntersectionChangeEventInstance(IntersectionChangeEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_START, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_END, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_MOVE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_TOUCH_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new TouchEventInstance(TouchEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_SWIPE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_PAN, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_LONG_PRESS, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_SCALE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new GestureEventInstance(GestureEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(
// EVENT_CLICK, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* { return new MouseEventInstance(MouseEvent::instance(context),
// reinterpret_cast<NativeEvent*>(nativeEvent)); });
// Event::defineEvent(EVENT_CANCEL, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new MouseEventInstance(MouseEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
// Event::defineEvent(EVENT_POPSTATE, [](ExecutionContext* context, void* nativeEvent) -> EventInstance* {
// return new PopStateEventInstance(PopStateEvent::instance(context), reinterpret_cast<NativeEvent*>(nativeEvent));
// });
}
}

Expand Down Expand Up @@ -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];
Expand Down
32 changes: 12 additions & 20 deletions bridge/bindings/qjs/dom/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ using TraverseHandler = std::function<bool(Node*)>;
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<std::string, std::string> cookiePairs;
};


class Document : public Node {
public:
static JSClassID classId;
Expand Down Expand Up @@ -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();
Expand All @@ -73,14 +71,14 @@ class Document : public Node {
std::unique_ptr<DocumentCookie> 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);

Expand All @@ -89,15 +87,9 @@ class Document : public Node {
std::unordered_map<std::string, Element*> 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

Expand Down
2 changes: 1 addition & 1 deletion bridge/bindings/qjs/dom/document_fragment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExecutionContext*>(JS_GetContextOpaque(ctx));
JSValue prototype = context->contextData()->prototypeForType(&documentFragmentInfo);
auto* documentFragment = makeGarbageCollected<DocumentFragment>()->initialize<DocumentFragment>(ctx, &classId);
Expand Down
6 changes: 1 addition & 5 deletions bridge/bindings/qjs/dom/document_fragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions bridge/bindings/qjs/dom/element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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<ElementAttributes>()->initialize(m_ctx, &ElementAttributes::classId);
JSValue arguments[] = {jsObject};
JSValue style = JS_CallConstructor(m_ctx, CSSStyleDeclaration::instance(m_context)->jsObject, 1, arguments);
Expand Down
15 changes: 8 additions & 7 deletions bridge/bindings/qjs/dom/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion bridge/bindings/qjs/dom/event_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class EventTarget : public GarbageCollected<EventTarget> {
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);
Expand Down
16 changes: 5 additions & 11 deletions bridge/bindings/qjs/dom/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -91,26 +91,20 @@ 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);

static void traverseCloneNode(JSContext* ctx, Node* baseNode, Node* targetNode);
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

Expand Down
6 changes: 1 addition & 5 deletions bridge/bindings/qjs/dom/text_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion bridge/bindings/qjs/executing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ void installPropertyGetter(ExecutionContext* context, JSValue thisObject, const
JS_FreeValue(context->ctx(), getter);
}


DOMTimerCoordinator* ExecutionContext::timers() {
return &m_timers;
}
Expand Down
Loading

0 comments on commit 0ca4d99

Please sign in to comment.