31 constexpr
const char* kXmlNamespace =
"http://www.w3.org/XML/1998/namespace";
32 constexpr
const char* kXmlNsNamespace =
"http://www.w3.org/2000/xmlns/";
36 std::atomic<Document*> Document::instance_{
nullptr};
40 created_at_(util::Clock::Instance.GetMonotonicTime()) {}
43 Document::~Document() {
46 instance_.compare_exchange_strong(temp,
nullptr, std::memory_order_relaxed);
52 Document* ret = instance_.load(std::memory_order_relaxed);
57 if (instance_.compare_exchange_strong(ret, doc.
get(),
58 std::memory_order_relaxed)) {
79 if (child->is_element())
80 return static_cast<Element*>(child.get());
86 const std::string&
name)
const {
96 if (name ==
"video") {
104 return new Comment(
this, data);
108 return new Text(
this, data);
121 const std::string& namespace_uri,
const std::string& qualified_name) {
128 if (qualified_name.empty())
135 std::string local_name = qualified_name;
139 auto pos = local_name.find(
':');
140 if (pos != std::string::npos) {
141 prefix = local_name.substr(0, pos);
142 local_name = local_name.substr(pos + 1);
152 if (prefix ==
"xml" && namespace_uri != kXmlNamespace)
157 if (prefix ==
"xmlns" && namespace_uri != kXmlNsNamespace)
162 if (namespace_uri == kXmlNsNamespace && qualified_name !=
"xmlns" &&
168 return new Attr(
this,
nullptr, local_name, ns, prefix,
"");
183 NotImplemented(
"createEvent");
185 NotImplemented(
"createElementNS");
186 NotImplemented(
"createDocumentFragment");
187 NotImplemented(
"createCDATASection");
188 NotImplemented(
"createProcessingInstruction");
190 NotImplemented(
"createRange");
191 NotImplemented(
"createNodeIterator");
192 NotImplemented(
"createTreeWalker");
194 NotImplemented(
"importNode");
195 NotImplemented(
"adoptNode");
std::string ToAsciiLower(const std::string &source)
std::vector< RefPtr< Element > > GetElementsByTagName(const std::string &name) const override
RefPtr< Element > CreateElement(const std::string &name)
RefPtr< Comment > CreateComment(const std::string &data)
optional< std::string > TextContent() const override
RefPtr< Text > CreateTextNode(const std::string &data)
static RefPtr< Document > EnsureGlobalDocument()
virtual std::vector< RefPtr< Element > > GetElementsByTagName(const std::string &name) const
optional< std::string > NodeValue() const override
RefPtr< Element > DocumentElement() const
std::string node_name() const override
static JsError DOMException(ExceptionCode code)
std::vector< RefPtr< Node > > child_nodes() const
ExceptionOr< RefPtr< Attr > > CreateAttribute(const std::string &name)
static RefPtr< HTMLVideoElement > AnyVideoElement()
ExceptionOr< RefPtr< Attr > > CreateAttributeNS(const std::string &namespace_uri, const std::string &qualified_name)