Open
Bug 2043161
Opened 4 months ago
Updated 4 months ago
Optimize representation of common enum attributes in the parser
Categories
(Core :: DOM: HTML Parser, enhancement)
Core
DOM: HTML Parser
Tracking
()
NEW
People
(Reporter: hsivonen, Unassigned)
References
(Blocks 1 open bug)
Details
Enum attributes, notably the type attribute on input and button cause the parser to allocate a StringBuffer, but the StringBuffer gets thrown away in the DOM.
The most obvious fix is to use the atom representation in the parser and then add an atom overload of ParseAttribute as approriate.
We could even start with only the attribute name type as a special case.
| Reporter | ||
Comment 1•4 months ago
•
|
||
The general idea is this:
- Read through the overloads of
Element::ParseAttributein HTML element classes to come up with a list of names of attributes that are of enum type. - List those (under a new macro) in
AtomAttributes.h. - Regenerate the HTML parser.
- Introduce an overload of
nsAttrValue::ParseEnumValuethat takes value asnsAtom*and takes a table where each item contains annsAttrValue::EnumTableEntry(as in the current table) and thensGkAtomsatom for the string. Make the implementation take the lowercase atom for the incoming atom and pointer-compare that against the table instead of comparing the strings. If the incoming atom was mixed-case, use that atom in attribute storage. - Introduce no-op virtual function
Element::ParseEnumAttributethat takes value as atom and assumes no namespace. - Override this method next to each enum-aware pre-existing override of
Element::ParseAttributeon HTML elements, only check for enum attributes, and use the newnsAttrValue::ParseEnumValueoverload from above. - Call the
Element::ParseEnumAttributemethod inElement::SetNoNameSpaceAttrOnNewlyCreatedElement(in anelsebranch forif (valueAtom->GetLength() == 1)).
You need to log in
before you can comment on or make changes to this bug.
Description
•