Commit e36e145d authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Use a different color to highlight nodes rendered by LayoutNG.

With this patch, a node rendered by LayoutNG will be highlighted with
a different color when you hover over the node in the inspector.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I648d7cfa6bfd93a7829ffb480fe029b7e64a67c9
Reviewed-on: https://chromium-review.googlesource.com/1158391
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580508}
parent d010a85a
......@@ -19,6 +19,7 @@
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/platform/graphics/path.h"
#include "third_party/blink/renderer/platform/layout_test_support.h"
namespace blink {
......@@ -418,11 +419,17 @@ void InspectorHighlight::AppendNodeHighlight(
if (!layout_object)
return;
// Just for testing, invert the content color for nodes rendered by LayoutNG.
// TODO(layout-dev): Stop munging the color before NG ships. crbug.com/869866
Color content_color = layout_object->IsLayoutNGObject() &&
!LayoutTestSupport::IsRunningLayoutTest()
? Color(highlight_config.content.Rgb() ^ 0x00ffffff)
: highlight_config.content;
Vector<FloatQuad> svg_quads;
if (BuildSVGQuads(node, svg_quads)) {
for (size_t i = 0; i < svg_quads.size(); ++i) {
AppendQuad(svg_quads[i], highlight_config.content,
highlight_config.content_outline);
AppendQuad(svg_quads[i], content_color, highlight_config.content_outline);
}
return;
}
......@@ -430,8 +437,8 @@ void InspectorHighlight::AppendNodeHighlight(
FloatQuad content, padding, border, margin;
if (!BuildNodeQuads(node, &content, &padding, &border, &margin))
return;
AppendQuad(content, highlight_config.content,
highlight_config.content_outline, "content");
AppendQuad(content, content_color, highlight_config.content_outline,
"content");
AppendQuad(padding, highlight_config.padding, Color::kTransparent, "padding");
AppendQuad(border, highlight_config.border, Color::kTransparent, "border");
AppendQuad(margin, highlight_config.margin, Color::kTransparent, "margin");
......
......@@ -619,6 +619,7 @@ class CORE_EXPORT LayoutObject : public ImageResourceObserver,
virtual bool IsLayoutFlowThread() const { return false; }
virtual bool IsLayoutInline() const { return false; }
virtual bool IsLayoutEmbeddedContent() const { return false; }
virtual bool IsLayoutNGObject() const { return false; }
bool IsDocumentElement() const {
return GetDocument().documentElement() == node_;
......
......@@ -26,6 +26,7 @@ class CORE_EXPORT LayoutNGText : public LayoutText {
bool IsOfType(LayoutObjectType type) const override {
return type == kLayoutObjectNGText || LayoutText::IsOfType(type);
}
bool IsLayoutNGObject() const override { return true; }
bool HasValidLayout() const { return valid_ng_items_; }
const Vector<NGInlineItem*>& InlineItems() const {
......
......@@ -18,6 +18,7 @@ class CORE_EXPORT LayoutNGFlexibleBox : public LayoutBlock {
void UpdateBlockLayout(bool relayout_children) override;
bool IsFlexibleBox() const final { return true; }
bool IsLayoutNGObject() const override { return true; }
const char* GetName() const override { return "LayoutNGFlexibleBox"; }
protected:
......
......@@ -30,6 +30,8 @@ class LayoutNGMixin : public Base {
explicit LayoutNGMixin(Element* element);
~LayoutNGMixin() override;
bool IsLayoutNGObject() const override { return true; }
NGInlineNodeData* TakeNGInlineNodeData() override;
NGInlineNodeData* GetNGInlineNodeData() const override;
void ResetNGInlineNodeData() override;
......
......@@ -26,6 +26,7 @@ class CORE_EXPORT LayoutNGListItem final : public LayoutNGBlockFlow {
return StyleRef().ListStyleImage() &&
!StyleRef().ListStyleImage()->ErrorOccurred();
}
bool IsLayoutNGObject() const override { return true; }
void UpdateMarkerTextIfNeeded() {
if (marker_ && !is_marker_text_updated_ && !IsMarkerImage())
......
......@@ -33,6 +33,8 @@ class CORE_EXPORT LayoutNGListMarker final
bool IsContentImage() const;
bool IsLayoutNGObject() const override { return true; }
LayoutObject* SymbolMarkerLayoutText() const;
// Marker text with suffix, e.g. "1. ", for use in accessibility.
......
......@@ -17,6 +17,8 @@ class CORE_EXPORT LayoutNGListMarkerImage final : public LayoutImage {
explicit LayoutNGListMarkerImage(Element*);
static LayoutNGListMarkerImage* CreateAnonymous(Document*);
bool IsLayoutNGObject() const override { return true; }
private:
bool IsOfType(LayoutObjectType) const override;
......
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