Commit 17cd2c0a authored by Aleks Totic's avatar Aleks Totic Committed by Commit Bot

[LayoutNG] Use OutlineUtils::HasPaintedOutline instead of style::HasOutline

ComputedStyle::HasOutline does not work when outline is set by focus.
Focus outline status is determined by
LayoutTheme::ShouldDrawDefaultFocusRing

Created a utility function for this.

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Bug: 835484
Change-Id: If717533f72374ea493368ac6db07037961e312ef
Reviewed-on: https://chromium-review.googlesource.com/1210944Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Aleks Totic <atotic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589261}
parent fd8e8380
......@@ -6,6 +6,7 @@
#include "third_party/blink/renderer/core/layout/layout_inline.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/ng/ng_outline_utils.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result_buffer.h"
......@@ -121,8 +122,10 @@ void NGInlineItem::ComputeBoxProperties() {
is_empty_item_ = true;
should_create_box_fragment_ =
ToLayoutBoxModelObject(layout_object_)->HasSelfPaintingLayer() ||
style_->HasOutline() || style_->CanContainAbsolutePositionObjects() ||
style_->CanContainAbsolutePositionObjects() ||
style_->CanContainFixedPositionObjects(false) ||
NGOutlineUtils::HasPaintedOutline(*style_,
layout_object_->GetNode()) ||
ToLayoutBoxModelObject(layout_object_)
->ShouldApplyPaintContainment() ||
ToLayoutBoxModelObject(layout_object_)
......
......@@ -13,6 +13,16 @@ namespace blink {
class LayoutObject;
bool NGOutlineUtils::HasPaintedOutline(const ComputedStyle& style,
const Node* node) {
if (!style.HasOutline() || style.Visibility() != EVisibility::kVisible)
return false;
if (style.OutlineStyleIsAuto() &&
!LayoutTheme::GetTheme().ShouldDrawDefaultFocusRing(node, style))
return false;
return true;
}
void NGOutlineUtils::CollectDescendantOutlines(
const NGPhysicalBoxFragment& container,
const NGPhysicalOffset& paint_offset,
......@@ -26,13 +36,8 @@ void NGOutlineUtils::CollectDescendantOutlines(
if (!descendant.fragment->IsBox() || descendant.fragment->IsAtomicInline())
continue;
const ComputedStyle& descendant_style = descendant.fragment->Style();
if (!descendant_style.HasOutline() ||
descendant_style.Visibility() != EVisibility::kVisible)
continue;
if (descendant_style.OutlineStyleIsAuto() &&
!LayoutTheme::GetTheme().ShouldDrawDefaultFocusRing(
descendant.fragment->GetNode(), descendant_style))
if (!HasPaintedOutline(descendant.fragment->Style(),
descendant.fragment->GetNode()))
continue;
const LayoutObject* layout_object = descendant.fragment->GetLayoutObject();
......
......@@ -14,6 +14,7 @@ namespace blink {
class ComputedStyle;
class LayoutObject;
class LayoutRect;
class Node;
class NGPhysicalFragment;
class NGPhysicalBoxFragment;
struct NGPhysicalOffset;
......@@ -31,6 +32,8 @@ class CORE_EXPORT NGOutlineUtils {
FragmentMap* anchor_fragment_map,
OutlineRectMap* outline_rect_map);
static bool HasPaintedOutline(const ComputedStyle& style, const Node* node);
// Union of all outline rectangles, including outline thickness.
static NGPhysicalOffsetRect ComputeEnclosingOutline(
const ComputedStyle& style,
......
......@@ -145,7 +145,8 @@ NGPhysicalOffsetRect NGPhysicalBoxFragment::SelfInkOverflow() const {
if (style.HasVisualOverflowingEffect()) {
if (GetLayoutObject()->IsBox()) {
ink_overflow.Expand(style.BoxDecorationOutsets());
if (style.HasOutline()) {
if (NGOutlineUtils::HasPaintedOutline(style,
GetLayoutObject()->GetNode())) {
Vector<LayoutRect> outline_rects;
// The result rects are in coordinates of this object's border box.
AddSelfOutlineRects(&outline_rects, LayoutPoint());
......
......@@ -1763,6 +1763,8 @@ class ComputedStyle : public ComputedStyleBase,
bool HasPerspective() const { return Perspective() > 0; }
// Outline utility functions.
// HasOutline is insufficient to determine whether Node has an outline.
// Use NGOutlineUtils::HasPaintedOutline instead.
bool HasOutline() const {
return OutlineWidth() > 0 && OutlineStyle() > EBorderStyle::kHidden;
}
......
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