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

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

Also shortens some repetitive code.

Bug: 82078
Change-Id: Ib0e4946233c3bf595319ce8368e106eb1be8a041
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1868629
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: default avatarFredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#707282}
parent 436b5c07
...@@ -46,8 +46,6 @@ ...@@ -46,8 +46,6 @@
namespace blink { namespace blink {
using namespace html_names;
HitTestResult::HitTestResult() HitTestResult::HitTestResult()
: hit_test_request_(HitTestRequest::kReadOnly | HitTestRequest::kActive), : hit_test_request_(HitTestRequest::kReadOnly | HitTestRequest::kActive),
cacheable_(true), cacheable_(true),
...@@ -190,7 +188,7 @@ HTMLAreaElement* HitTestResult::ImageAreaForImage() const { ...@@ -190,7 +188,7 @@ HTMLAreaElement* HitTestResult::ImageAreaForImage() const {
return nullptr; return nullptr;
HTMLMapElement* map = image_element->GetTreeScope().GetImageMap( HTMLMapElement* map = image_element->GetTreeScope().GetImageMap(
image_element->FastGetAttribute(kUsemapAttr)); image_element->FastGetAttribute(html_names::kUsemapAttr));
if (!map) if (!map)
return nullptr; return nullptr;
...@@ -293,7 +291,7 @@ const AtomicString& HitTestResult::AltDisplayString() const { ...@@ -293,7 +291,7 @@ const AtomicString& HitTestResult::AltDisplayString() const {
return g_null_atom; return g_null_atom;
if (auto* image = ToHTMLImageElementOrNull(*inner_node_or_image_map_image)) if (auto* image = ToHTMLImageElementOrNull(*inner_node_or_image_map_image))
return image->getAttribute(kAltAttr); return image->getAttribute(html_names::kAltAttr);
if (auto* input = ToHTMLInputElementOrNull(*inner_node_or_image_map_image)) if (auto* input = ToHTMLInputElementOrNull(*inner_node_or_image_map_image))
return input->Alt(); return input->Alt();
......
...@@ -27,31 +27,22 @@ ...@@ -27,31 +27,22 @@
namespace blink { namespace blink {
using namespace html_names;
LayoutDetailsMarker::LayoutDetailsMarker(Element* element) LayoutDetailsMarker::LayoutDetailsMarker(Element* element)
: LayoutBlockFlow(element) {} : LayoutBlockFlow(element) {}
LayoutDetailsMarker::Orientation LayoutDetailsMarker::GetOrientation() const { LayoutDetailsMarker::Orientation LayoutDetailsMarker::GetOrientation() const {
switch (StyleRef().GetWritingMode()) { // TODO(layout-dev): Sideways-lr and sideways-rl are not yet supported.
case WritingMode::kHorizontalTb: const auto mode = StyleRef().GetWritingMode();
if (StyleRef().IsLeftToRightDirection()) DCHECK(mode != WritingMode::kSidewaysRl && mode != WritingMode::kSidewaysLr);
return IsOpen() ? kDown : kRight;
return IsOpen() ? kDown : kLeft; if (IsOpen()) {
case WritingMode::kVerticalRl: if (mode == WritingMode::kHorizontalTb)
if (StyleRef().IsLeftToRightDirection()) return kDown;
return IsOpen() ? kLeft : kDown; return (mode == WritingMode::kVerticalRl) ? kLeft : kRight;
return IsOpen() ? kLeft : kUp;
case WritingMode::kVerticalLr:
if (StyleRef().IsLeftToRightDirection())
return IsOpen() ? kRight : kDown;
return IsOpen() ? kRight : kUp;
// TODO(layout-dev): Sideways-lr and sideways-rl are not yet supported.
default:
break;
} }
NOTREACHED(); if (mode == WritingMode::kHorizontalTb)
return kRight; return StyleRef().IsLeftToRightDirection() ? kRight : kLeft;
return StyleRef().IsLeftToRightDirection() ? kDown : kUp;
} }
void LayoutDetailsMarker::Paint(const PaintInfo& paint_info) const { void LayoutDetailsMarker::Paint(const PaintInfo& paint_info) const {
...@@ -61,13 +52,12 @@ void LayoutDetailsMarker::Paint(const PaintInfo& paint_info) const { ...@@ -61,13 +52,12 @@ void LayoutDetailsMarker::Paint(const PaintInfo& paint_info) const {
bool LayoutDetailsMarker::IsOpen() const { bool LayoutDetailsMarker::IsOpen() const {
for (LayoutObject* layout_object = Parent(); layout_object; for (LayoutObject* layout_object = Parent(); layout_object;
layout_object = layout_object->Parent()) { layout_object = layout_object->Parent()) {
if (!layout_object->GetNode()) const auto* node = layout_object->GetNode();
if (!node)
continue; continue;
if (IsHTMLDetailsElement(*layout_object->GetNode())) if (IsHTMLDetailsElement(*node))
return !To<Element>(layout_object->GetNode()) return !To<Element>(node)->getAttribute(html_names::kOpenAttr).IsNull();
->getAttribute(kOpenAttr) if (IsHTMLInputElement(*node))
.IsNull();
if (IsHTMLInputElement(*layout_object->GetNode()))
return true; return true;
} }
......
...@@ -50,8 +50,6 @@ ...@@ -50,8 +50,6 @@
namespace blink { namespace blink {
using namespace html_names;
LayoutImage::LayoutImage(Element* element) LayoutImage::LayoutImage(Element* element)
: LayoutReplaced(element, LayoutSize()), : LayoutReplaced(element, LayoutSize()),
did_increment_visually_non_empty_pixel_count_(false), did_increment_visually_non_empty_pixel_count_(false),
...@@ -287,7 +285,8 @@ LayoutUnit LayoutImage::MinimumReplacedHeight() const { ...@@ -287,7 +285,8 @@ LayoutUnit LayoutImage::MinimumReplacedHeight() const {
HTMLMapElement* LayoutImage::ImageMap() const { HTMLMapElement* LayoutImage::ImageMap() const {
HTMLImageElement* i = ToHTMLImageElementOrNull(GetNode()); HTMLImageElement* i = ToHTMLImageElementOrNull(GetNode());
return i ? i->GetTreeScope().GetImageMap(i->FastGetAttribute(kUsemapAttr)) return i ? i->GetTreeScope().GetImageMap(
i->FastGetAttribute(html_names::kUsemapAttr))
: nullptr; : nullptr;
} }
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
namespace blink { namespace blink {
using namespace html_names;
struct SameSizeAsLayoutTableCell : public LayoutBlockFlow, struct SameSizeAsLayoutTableCell : public LayoutBlockFlow,
public LayoutNGTableCellInterface { public LayoutNGTableCellInterface {
unsigned bitfields; unsigned bitfields;
...@@ -203,7 +201,7 @@ void LayoutTableCell::ComputePreferredLogicalWidths() { ...@@ -203,7 +201,7 @@ void LayoutTableCell::ComputePreferredLogicalWidths() {
// See if nowrap was set. // See if nowrap was set.
Length w = StyleOrColLogicalWidth(); Length w = StyleOrColLogicalWidth();
const AtomicString& nowrap = const AtomicString& nowrap =
To<Element>(GetNode())->getAttribute(kNowrapAttr); To<Element>(GetNode())->getAttribute(html_names::kNowrapAttr);
if (!nowrap.IsNull() && w.IsFixed()) { if (!nowrap.IsNull() && w.IsFixed()) {
// Nowrap is set, but we didn't actually use it because of the fixed width // Nowrap is set, but we didn't actually use it because of the fixed width
// set on the cell. Even so, it is a WinIE/Moz trait to make the minwidth // set on the cell. Even so, it is a WinIE/Moz trait to make the minwidth
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
namespace blink { namespace blink {
using namespace svg_names;
SVGResources::SVGResources() : linked_resource_(nullptr) {} SVGResources::SVGResources() : linked_resource_(nullptr) {}
SVGResourceClient* SVGResources::GetClient(const LayoutObject& object) { SVGResourceClient* SVGResources::GetClient(const LayoutObject& object) {
...@@ -59,26 +57,28 @@ static HashSet<AtomicString>& ClipperFilterMaskerTags() { ...@@ -59,26 +57,28 @@ static HashSet<AtomicString>& ClipperFilterMaskerTags() {
// http://www.w3.org/TR/SVG11/intro.html#TermContainerElement // http://www.w3.org/TR/SVG11/intro.html#TermContainerElement
// "graphics elements" : // "graphics elements" :
// http://www.w3.org/TR/SVG11/intro.html#TermGraphicsElement // http://www.w3.org/TR/SVG11/intro.html#TermGraphicsElement
kATag.LocalName(), kCircleTag.LocalName(), kEllipseTag.LocalName(), svg_names::kATag.LocalName(), svg_names::kCircleTag.LocalName(),
kGTag.LocalName(), kImageTag.LocalName(), kLineTag.LocalName(), svg_names::kEllipseTag.LocalName(), svg_names::kGTag.LocalName(),
kMarkerTag.LocalName(), kMaskTag.LocalName(), kPathTag.LocalName(), svg_names::kImageTag.LocalName(), svg_names::kLineTag.LocalName(),
kPolygonTag.LocalName(), kPolylineTag.LocalName(), svg_names::kMarkerTag.LocalName(), svg_names::kMaskTag.LocalName(),
kRectTag.LocalName(), kSVGTag.LocalName(), kTextTag.LocalName(), svg_names::kPathTag.LocalName(), svg_names::kPolygonTag.LocalName(),
kUseTag.LocalName(), svg_names::kPolylineTag.LocalName(), svg_names::kRectTag.LocalName(),
svg_names::kSVGTag.LocalName(), svg_names::kTextTag.LocalName(),
svg_names::kUseTag.LocalName(),
// Not listed in the definitions is the clipPath element, the SVG spec // Not listed in the definitions is the clipPath element, the SVG spec
// says though: // says though:
// The "clipPath" element or any of its children can specify property // The "clipPath" element or any of its children can specify property
// "clip-path". // "clip-path".
// So we have to add kClipPathTag here, otherwhise clip-path on // So we have to add kClipPathTag here, otherwhise clip-path on
// clipPath will fail. (Already mailed SVG WG, waiting for a solution) // clipPath will fail. (Already mailed SVG WG, waiting for a solution)
kClipPathTag.LocalName(), svg_names::kClipPathTag.LocalName(),
// Not listed in the definitions are the text content elements, though // Not listed in the definitions are the text content elements, though
// filter/clipper/masker on tspan/text/.. is allowed. // filter/clipper/masker on tspan/text/.. is allowed.
// (Already mailed SVG WG, waiting for a solution) // (Already mailed SVG WG, waiting for a solution)
kTextPathTag.LocalName(), kTSpanTag.LocalName(), svg_names::kTextPathTag.LocalName(), svg_names::kTSpanTag.LocalName(),
// Not listed in the definitions is the foreignObject element, but // Not listed in the definitions is the foreignObject element, but
// clip-path is a supported attribute. // clip-path is a supported attribute.
kForeignObjectTag.LocalName(), svg_names::kForeignObjectTag.LocalName(),
// Elements that we ignore, as it doesn't make any sense. // Elements that we ignore, as it doesn't make any sense.
// defs, pattern, switch (FIXME: Mail SVG WG about these) // defs, pattern, switch (FIXME: Mail SVG WG about these)
// symbol (is converted to a svg element, when referenced by use, we // symbol (is converted to a svg element, when referenced by use, we
...@@ -90,21 +90,28 @@ static HashSet<AtomicString>& ClipperFilterMaskerTags() { ...@@ -90,21 +90,28 @@ static HashSet<AtomicString>& ClipperFilterMaskerTags() {
bool SVGResources::SupportsMarkers(const SVGElement& element) { bool SVGResources::SupportsMarkers(const SVGElement& element) {
DEFINE_STATIC_LOCAL(HashSet<AtomicString>, tag_list, DEFINE_STATIC_LOCAL(HashSet<AtomicString>, tag_list,
({ ({
kLineTag.LocalName(), kPathTag.LocalName(), svg_names::kLineTag.LocalName(),
kPolygonTag.LocalName(), kPolylineTag.LocalName(), svg_names::kPathTag.LocalName(),
svg_names::kPolygonTag.LocalName(),
svg_names::kPolylineTag.LocalName(),
})); }));
return tag_list.Contains(element.localName()); return tag_list.Contains(element.localName());
} }
static HashSet<AtomicString>& FillAndStrokeTags() { static HashSet<AtomicString>& FillAndStrokeTags() {
DEFINE_STATIC_LOCAL( DEFINE_STATIC_LOCAL(HashSet<AtomicString>, tag_list,
HashSet<AtomicString>, tag_list, ({
({ svg_names::kCircleTag.LocalName(),
kCircleTag.LocalName(), kEllipseTag.LocalName(), kLineTag.LocalName(), svg_names::kEllipseTag.LocalName(),
kPathTag.LocalName(), kPolygonTag.LocalName(), svg_names::kLineTag.LocalName(),
kPolylineTag.LocalName(), kRectTag.LocalName(), kTextTag.LocalName(), svg_names::kPathTag.LocalName(),
kTextPathTag.LocalName(), kTSpanTag.LocalName(), svg_names::kPolygonTag.LocalName(),
})); svg_names::kPolylineTag.LocalName(),
svg_names::kRectTag.LocalName(),
svg_names::kTextTag.LocalName(),
svg_names::kTextPathTag.LocalName(),
svg_names::kTSpanTag.LocalName(),
}));
return tag_list; return tag_list;
} }
......
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