-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #641 from openkraken/feat/DocumentFragment
Feat/document fragment
- Loading branch information
Showing
19 changed files
with
311 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2021 Alibaba Inc. All rights reserved. | ||
* Author: Kraken Team. | ||
*/ | ||
|
||
#include "document_fragment.h" | ||
|
||
namespace kraken::binding::jsc { | ||
|
||
void bindDocumentFragment(std::unique_ptr<JSContext> &context) { | ||
auto DocumentFragment = JSDocumentFragment::instance(context.get()); | ||
JSC_GLOBAL_SET_PROPERTY(context, "DocumentFragment", DocumentFragment->classObject); | ||
} | ||
|
||
std::unordered_map<JSContext *, JSDocumentFragment *> JSDocumentFragment::instanceMap{}; | ||
|
||
JSDocumentFragment::~JSDocumentFragment() { | ||
instanceMap.erase(context); | ||
} | ||
|
||
JSDocumentFragment::JSDocumentFragment(JSContext *context) : JSNode(context) {} | ||
JSObjectRef JSDocumentFragment::instanceConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, | ||
const JSValueRef *arguments, JSValueRef *exception) { | ||
auto instance = new DocumentFragmentInstance(this); | ||
return instance->object; | ||
} | ||
|
||
JSDocumentFragment::DocumentFragmentInstance::DocumentFragmentInstance(JSDocumentFragment *jsDocumentFragment) | ||
: NodeInstance(jsDocumentFragment, NodeType::DOCUMENT_FRAGMENT_NODE) { | ||
setNodeFlag(DocumentFragmentInstance::NodeFlag::IsDocumentFragment); | ||
std::string tagName = "documentfragment"; | ||
NativeString args_01{}; | ||
buildUICommandArgs(tagName, args_01); | ||
|
||
foundation::UICommandBuffer::instance(context->getContextId()) | ||
->addCommand(eventTargetId, UICommand::createDocumentFragment, args_01, nativeNode); | ||
} | ||
|
||
JSDocumentFragment::DocumentFragmentInstance::~DocumentFragmentInstance() {} | ||
|
||
} // namespace kraken::binding::jsc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2021 Alibaba Inc. All rights reserved. | ||
* Author: Kraken Team. | ||
*/ | ||
|
||
#ifndef KRAKENBRIDGE_DOCUMENT_FRAGMENT_ELEMENT_H | ||
#define KRAKENBRIDGE_DOCUMENT_FRAGMENT_ELEMENT_H | ||
|
||
#include "bindings/jsc/DOM/element.h" | ||
#include "bindings/jsc/js_context_internal.h" | ||
|
||
namespace kraken::binding::jsc { | ||
|
||
void bindDocumentFragment(std::unique_ptr<JSContext> &context); | ||
|
||
class JSDocumentFragment : public JSNode { | ||
public: | ||
static std::unordered_map<JSContext *, JSDocumentFragment *> instanceMap; | ||
OBJECT_INSTANCE(JSDocumentFragment) | ||
JSObjectRef instanceConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, | ||
const JSValueRef *arguments, JSValueRef *exception) override; | ||
|
||
class DocumentFragmentInstance : public NodeInstance { | ||
public: | ||
|
||
DocumentFragmentInstance() = delete; | ||
~DocumentFragmentInstance(); | ||
explicit DocumentFragmentInstance(JSDocumentFragment *JSDocumentFragment); | ||
|
||
JSDocumentFragment *nativeDocumentFragment; | ||
}; | ||
protected: | ||
~JSDocumentFragment(); | ||
JSDocumentFragment() = delete; | ||
explicit JSDocumentFragment(JSContext *context); | ||
}; | ||
|
||
|
||
} // namespace kraken::binding::jsc | ||
|
||
#endif // KRAKENBRIDGE_DOCUMENT_FRAGMENT_ELEMENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.