Commit acc1e48e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove using directives ("using namespace x") from blink/renderer/core/xml/.

Bug: 82078
Change-Id: Idb949d0a3d0d70077aa9a0e88558d504507a1e3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1866431
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708332}
parent 0b9037d9
...@@ -82,8 +82,6 @@ ...@@ -82,8 +82,6 @@
namespace blink { namespace blink {
using namespace html_names;
// FIXME: HTMLConstructionSite has a limit of 512, should these match? // FIXME: HTMLConstructionSite has a limit of 512, should these match?
static const unsigned kMaxXMLTreeDepth = 5000; static const unsigned kMaxXMLTreeDepth = 5000;
...@@ -455,8 +453,8 @@ bool XMLDocumentParser::ParseDocumentFragment( ...@@ -455,8 +453,8 @@ bool XMLDocumentParser::ParseDocumentFragment(
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-parsing-algorithm // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-xhtml-syntax.html#xml-fragment-parsing-algorithm
// For now we have a hack for script/style innerHTML support: // For now we have a hack for script/style innerHTML support:
if (context_element && if (context_element &&
(context_element->HasLocalName(kScriptTag.LocalName()) || (context_element->HasLocalName(html_names::kScriptTag.LocalName()) ||
context_element->HasLocalName(kStyleTag.LocalName()))) { context_element->HasLocalName(html_names::kStyleTag.LocalName()))) {
fragment->ParserAppendChild(fragment->GetDocument().createTextNode(chunk)); fragment->ParserAppendChild(fragment->GetDocument().createTextNode(chunk));
return true; return true;
} }
...@@ -981,7 +979,7 @@ void XMLDocumentParser::StartElementNs(const AtomicString& local_name, ...@@ -981,7 +979,7 @@ void XMLDocumentParser::StartElementNs(const AtomicString& local_name,
prefix_to_namespace_map_, exception_state); prefix_to_namespace_map_, exception_state);
AtomicString is; AtomicString is;
for (const auto& attr : prefixed_attributes) { for (const auto& attr : prefixed_attributes) {
if (attr.GetName() == kIsAttr) { if (attr.GetName() == html_names::kIsAttr) {
is = attr.Value(); is = attr.Value();
break; break;
} }
......
...@@ -38,8 +38,6 @@ ...@@ -38,8 +38,6 @@
namespace blink { namespace blink {
using namespace html_names;
const int kMaxErrors = 25; const int kMaxErrors = 25;
XMLErrors::XMLErrors(Document* document) XMLErrors::XMLErrors(Document* document)
...@@ -99,30 +97,31 @@ static inline Element* CreateXHTMLParserErrorHeader( ...@@ -99,30 +97,31 @@ static inline Element* CreateXHTMLParserErrorHeader(
const String& error_messages) { const String& error_messages) {
const CreateElementFlags flags = CreateElementFlags::ByParser(); const CreateElementFlags flags = CreateElementFlags::ByParser();
Element* report_element = doc->CreateRawElement( Element* report_element = doc->CreateRawElement(
QualifiedName(g_null_atom, "parsererror", xhtmlNamespaceURI), flags); QualifiedName(g_null_atom, "parsererror", html_names::xhtmlNamespaceURI),
flags);
Vector<Attribute> report_attributes; Vector<Attribute> report_attributes;
report_attributes.push_back(Attribute( report_attributes.push_back(Attribute(
kStyleAttr, html_names::kStyleAttr,
"display: block; white-space: pre; border: 2px solid #c77; padding: 0 " "display: block; white-space: pre; border: 2px solid #c77; padding: 0 "
"1em 0 1em; margin: 1em; background-color: #fdd; color: black")); "1em 0 1em; margin: 1em; background-color: #fdd; color: black"));
report_element->ParserSetAttributes(report_attributes); report_element->ParserSetAttributes(report_attributes);
Element* h3 = doc->CreateRawElement(kH3Tag, flags); Element* h3 = doc->CreateRawElement(html_names::kH3Tag, flags);
report_element->ParserAppendChild(h3); report_element->ParserAppendChild(h3);
h3->ParserAppendChild( h3->ParserAppendChild(
doc->createTextNode("This page contains the following errors:")); doc->createTextNode("This page contains the following errors:"));
Element* fixed = doc->CreateRawElement(kDivTag, flags); Element* fixed = doc->CreateRawElement(html_names::kDivTag, flags);
Vector<Attribute> fixed_attributes; Vector<Attribute> fixed_attributes;
fixed_attributes.push_back( fixed_attributes.push_back(Attribute(html_names::kStyleAttr,
Attribute(kStyleAttr, "font-family:monospace;font-size:12px")); "font-family:monospace;font-size:12px"));
fixed->ParserSetAttributes(fixed_attributes); fixed->ParserSetAttributes(fixed_attributes);
report_element->ParserAppendChild(fixed); report_element->ParserAppendChild(fixed);
fixed->ParserAppendChild(doc->createTextNode(error_messages)); fixed->ParserAppendChild(doc->createTextNode(error_messages));
h3 = doc->CreateRawElement(kH3Tag, flags); h3 = doc->CreateRawElement(html_names::kH3Tag, flags);
report_element->ParserAppendChild(h3); report_element->ParserAppendChild(h3);
h3->ParserAppendChild(doc->createTextNode( h3->ParserAppendChild(doc->createTextNode(
"Below is a rendering of the page up to the first error.")); "Below is a rendering of the page up to the first error."));
...@@ -139,22 +138,24 @@ void XMLErrors::InsertErrorMessageBlock() { ...@@ -139,22 +138,24 @@ void XMLErrors::InsertErrorMessageBlock() {
const CreateElementFlags flags = CreateElementFlags::ByParser(); const CreateElementFlags flags = CreateElementFlags::ByParser();
Element* document_element = document_->documentElement(); Element* document_element = document_->documentElement();
if (!document_element) { if (!document_element) {
Element* root_element = document_->CreateRawElement(kHTMLTag, flags); Element* root_element =
Element* body = document_->CreateRawElement(kBodyTag, flags); document_->CreateRawElement(html_names::kHTMLTag, flags);
Element* body = document_->CreateRawElement(html_names::kBodyTag, flags);
root_element->ParserAppendChild(body); root_element->ParserAppendChild(body);
document_->ParserAppendChild(root_element); document_->ParserAppendChild(root_element);
document_element = body; document_element = body;
} else if (document_element->namespaceURI() == svg_names::kNamespaceURI) { } else if (document_element->namespaceURI() == svg_names::kNamespaceURI) {
Element* root_element = document_->CreateRawElement(kHTMLTag, flags); Element* root_element =
Element* head = document_->CreateRawElement(kHeadTag, flags); document_->CreateRawElement(html_names::kHTMLTag, flags);
Element* style = document_->CreateRawElement(kStyleTag, flags); Element* head = document_->CreateRawElement(html_names::kHeadTag, flags);
Element* style = document_->CreateRawElement(html_names::kStyleTag, flags);
head->ParserAppendChild(style); head->ParserAppendChild(style);
style->ParserAppendChild( style->ParserAppendChild(
document_->createTextNode("html, body { height: 100% } parsererror + " document_->createTextNode("html, body { height: 100% } parsererror + "
"svg { width: 100%; height: 100% }")); "svg { width: 100%; height: 100% }"));
style->FinishParsingChildren(); style->FinishParsingChildren();
root_element->ParserAppendChild(head); root_element->ParserAppendChild(head);
Element* body = document_->CreateRawElement(kBodyTag, flags); Element* body = document_->CreateRawElement(html_names::kBodyTag, flags);
root_element->ParserAppendChild(body); root_element->ParserAppendChild(body);
document_->ParserRemoveChild(*document_element); document_->ParserRemoveChild(*document_element);
...@@ -171,8 +172,9 @@ void XMLErrors::InsertErrorMessageBlock() { ...@@ -171,8 +172,9 @@ void XMLErrors::InsertErrorMessageBlock() {
if (DocumentXSLT::HasTransformSourceDocument(*document_)) { if (DocumentXSLT::HasTransformSourceDocument(*document_)) {
Vector<Attribute> attributes; Vector<Attribute> attributes;
attributes.push_back(Attribute(kStyleAttr, "white-space: normal")); attributes.push_back(
Element* paragraph = document_->CreateRawElement(kPTag, flags); Attribute(html_names::kStyleAttr, "white-space: normal"));
Element* paragraph = document_->CreateRawElement(html_names::kPTag, flags);
paragraph->ParserSetAttributes(attributes); paragraph->ParserSetAttributes(attributes);
paragraph->ParserAppendChild(document_->createTextNode( paragraph->ParserAppendChild(document_->createTextNode(
"This document was created as the result of an XSL transformation. The " "This document was created as the result of an XSL transformation. The "
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
namespace blink { namespace blink {
using namespace xpath;
XPathExpression* XPathEvaluator::createExpression( XPathExpression* XPathEvaluator::createExpression(
const String& expression, const String& expression,
XPathNSResolver* resolver, XPathNSResolver* resolver,
...@@ -56,7 +54,7 @@ XPathResult* XPathEvaluator::evaluate(const String& expression, ...@@ -56,7 +54,7 @@ XPathResult* XPathEvaluator::evaluate(const String& expression,
uint16_t type, uint16_t type,
const ScriptValue&, const ScriptValue&,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (!IsValidContextNode(context_node)) { if (!xpath::IsValidContextNode(context_node)) {
exception_state.ThrowDOMException( exception_state.ThrowDOMException(
DOMExceptionCode::kNotSupportedError, DOMExceptionCode::kNotSupportedError,
"The node provided is '" + context_node->nodeName() + "The node provided is '" + context_node->nodeName() +
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
namespace blink { namespace blink {
using namespace xpath;
XPathExpression::XPathExpression() = default; XPathExpression::XPathExpression() = default;
XPathExpression* XPathExpression::CreateExpression( XPathExpression* XPathExpression::CreateExpression(
...@@ -45,7 +43,7 @@ XPathExpression* XPathExpression::CreateExpression( ...@@ -45,7 +43,7 @@ XPathExpression* XPathExpression::CreateExpression(
XPathNSResolver* resolver, XPathNSResolver* resolver,
ExceptionState& exception_state) { ExceptionState& exception_state) {
auto* expr = MakeGarbageCollected<XPathExpression>(); auto* expr = MakeGarbageCollected<XPathExpression>();
Parser parser; xpath::Parser parser;
expr->top_expression_ = expr->top_expression_ =
parser.ParseStatement(expression, resolver, exception_state); parser.ParseStatement(expression, resolver, exception_state);
...@@ -64,7 +62,7 @@ XPathResult* XPathExpression::evaluate(Node* context_node, ...@@ -64,7 +62,7 @@ XPathResult* XPathExpression::evaluate(Node* context_node,
uint16_t type, uint16_t type,
const ScriptValue&, const ScriptValue&,
ExceptionState& exception_state) { ExceptionState& exception_state) {
if (!IsValidContextNode(context_node)) { if (!xpath::IsValidContextNode(context_node)) {
exception_state.ThrowDOMException( exception_state.ThrowDOMException(
DOMExceptionCode::kNotSupportedError, DOMExceptionCode::kNotSupportedError,
"The node provided is '" + context_node->nodeName() + "The node provided is '" + context_node->nodeName() +
...@@ -72,7 +70,7 @@ XPathResult* XPathExpression::evaluate(Node* context_node, ...@@ -72,7 +70,7 @@ XPathResult* XPathExpression::evaluate(Node* context_node,
return nullptr; return nullptr;
} }
EvaluationContext evaluation_context(*context_node); xpath::EvaluationContext evaluation_context(*context_node);
auto* result = MakeGarbageCollected<XPathResult>( auto* result = MakeGarbageCollected<XPathResult>(
evaluation_context, top_expression_->Evaluate(evaluation_context)); evaluation_context, top_expression_->Evaluate(evaluation_context));
......
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h" #include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
namespace blink { namespace blink {
namespace xpath {
using namespace xpath;
Parser* Parser::current_parser_ = nullptr; Parser* Parser::current_parser_ = nullptr;
...@@ -520,4 +519,5 @@ void Parser::DeleteString(String* s) { ...@@ -520,4 +519,5 @@ void Parser::DeleteString(String* s) {
strings_.erase(s); strings_.erase(s);
} }
} // namespace xpath
} // namespace blink } // namespace blink
...@@ -33,24 +33,23 @@ ...@@ -33,24 +33,23 @@
namespace blink { namespace blink {
using namespace xpath; XPathResult::XPathResult(xpath::EvaluationContext& context,
const xpath::Value& value)
XPathResult::XPathResult(EvaluationContext& context, const Value& value)
: value_(value), node_set_position_(0), dom_tree_version_(0) { : value_(value), node_set_position_(0), dom_tree_version_(0) {
switch (value_.GetType()) { switch (value_.GetType()) {
case Value::kBooleanValue: case xpath::Value::kBooleanValue:
result_type_ = kBooleanType; result_type_ = kBooleanType;
return; return;
case Value::kNumberValue: case xpath::Value::kNumberValue:
result_type_ = kNumberType; result_type_ = kNumberType;
return; return;
case Value::kStringValue: case xpath::Value::kStringValue:
result_type_ = kStringType; result_type_ = kStringType;
return; return;
case Value::kNodeSetValue: case xpath::Value::kNodeSetValue:
result_type_ = kUnorderedNodeIteratorType; result_type_ = kUnorderedNodeIteratorType;
node_set_position_ = 0; node_set_position_ = 0;
node_set_ = NodeSet::Create(value_.ToNodeSet(&context)); node_set_ = xpath::NodeSet::Create(value_.ToNodeSet(&context));
document_ = &context.node->GetDocument(); document_ = &context.node->GetDocument();
dom_tree_version_ = document_->DomTreeVersion(); dom_tree_version_ = document_->DomTreeVersion();
return; return;
...@@ -152,7 +151,7 @@ Node* XPathResult::singleNodeValue(ExceptionState& exception_state) const { ...@@ -152,7 +151,7 @@ Node* XPathResult::singleNodeValue(ExceptionState& exception_state) const {
return nullptr; return nullptr;
} }
const NodeSet& nodes = value_.ToNodeSet(nullptr); const xpath::NodeSet& nodes = value_.ToNodeSet(nullptr);
if (resultType() == kFirstOrderedNodeType) if (resultType() == kFirstOrderedNodeType)
return nodes.FirstNode(); return nodes.FirstNode();
return nodes.AnyNode(); return nodes.AnyNode();
...@@ -209,7 +208,7 @@ Node* XPathResult::snapshotItem(unsigned index, ...@@ -209,7 +208,7 @@ Node* XPathResult::snapshotItem(unsigned index,
return nullptr; return nullptr;
} }
const NodeSet& nodes = value_.ToNodeSet(nullptr); const xpath::NodeSet& nodes = value_.ToNodeSet(nullptr);
if (index >= nodes.size()) if (index >= nodes.size())
return nullptr; return nullptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment