Greetings all,
the default constructor of QualifiedName is behind a flag QNAME_DEFAULT_CONSTRUCTOR,
and I can't find a qualified name that stands for invalid / null value.
Is there any designated qualified name object that stands for invalid / null value?
Invalid / null qualified name will be useful in the context like:
void MarkupAccumulator::appendText(Vector<UChar>& out, Text* text)
{
const QualifiedName* parentName = 0;
if (text->parentElement())
parentName = &static_cast<Element*>(text->parentElement())->tagQName();
if (parentName && (*parentName == scriptTag || *parentName == styleTag || *parentName == xmpTag)) {
appendUCharRange(out, ucharRange(text, m_range));
return;
}
if (!shouldAnnotate() || (parentName && *parentName == textareaTag)) {
appendEscapedContent(out, ucharRange(text, m_range), text->document()->isHTMLDocument());
return;
}
...
where I obtain the qualified name of the parent element which may or may not exist.
If we had a null qualified name, above code can be re-written as:
void MarkupAccumulator::appendText(Vector<UChar>& out, Text* text)
{
QualifiedName parentName = nullName;
if (text->parentElement())
parentName = &static_cast<Element*>(text->parentElement())->tagQName();
if (parentName == scriptTag || parentName == styleTag || parentName == xmpTag) {
appendUCharRange(out, ucharRange(text, m_range));
return;
}
if (!shouldAnnotate() || parentName == textareaTag) {
appendEscapedContent(out, ucharRange(text, m_range), text->document()->isHTMLDocument());
return;
}
...
IMHO, new code is easier to read and has very little drawbacks (possible slowdown use to construction of QualifiedName).
I could have used htmlTag or any other qualified name different from the four names used above,
but that wouldn't be semantically correct.
Ryosuke Niwa
Software EngineerGoogle Inc.