
Note our Attribute class is what the spec refers to as just "Attr". The main differences between the existing implementation and the spec are just that the spec defines more fields. Attributes can contain namespace URIs and prefixes. However, note that these are not parsed in HTML documents unless the document content-type is XML. So for now, these are initialized to null. Web pages are able to set the namespace via JavaScript (setAttributeNS), so these fields may be filled in when the corresponding APIs are implemented. The main change to be aware of is that an attribute is a node. This has implications on how attributes are stored in the Element class. Nodes are non-copyable and non-movable because these constructors are deleted by the EventTarget base class. This means attributes cannot be stored in a Vector or HashMap as these containers assume copyability / movability. So for now, the Vector holding attributes is changed to hold RefPtrs to attributes instead. This might change when attribute storage is implemented according to the spec (by way of NamedNodeMap).
23 lines
794 B
C++
23 lines
794 B
C++
/*
|
|
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Optional.h>
|
|
#include <AK/String.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
bool prescan_should_abort(const ByteBuffer& input, const size_t& position);
|
|
bool prescan_is_whitespace_or_slash(const u8& byte);
|
|
bool prescan_skip_whitespace_and_slashes(const ByteBuffer& input, size_t& position);
|
|
Optional<String> extract_character_encoding_from_meta_element(String const&);
|
|
RefPtr<DOM::Attribute> prescan_get_attribute(DOM::Document&, const ByteBuffer& input, size_t& position);
|
|
Optional<String> run_prescan_byte_stream_algorithm(DOM::Document&, const ByteBuffer& input);
|
|
String run_encoding_sniffing_algorithm(DOM::Document&, const ByteBuffer& input);
|
|
|
|
}
|