Commit ceeea934 authored by Ionel Popescu's avatar Ionel Popescu Committed by Commit Bot

Fixed issue when the focus ring is clipped for textarea.

Prior to http://crrev.com/c/2138156, the outline-offset was ignored
when drawing the focus ring.

Unlike normal outlines (whole width is outside of the offset), focus
rings are drawn with the center of the path aligned with the offset, so
only a part of the ouline is outside of the offset.

This CL updates the behavior of NeedsDecorationOutlineLayer to consider
the part of the outline drawn inside.

Added textarea-with-scrollbar.html to validate the change.

Bug: 1084997
Change-Id: I50949194c0a2f413d7a3c508509339dac63cfbb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216705Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#772103}
parent 64fdbd75
......@@ -167,7 +167,7 @@ static FloatPoint StickyPositionOffsetForLayer(PaintLayer& layer) {
static bool NeedsDecorationOutlineLayer(const PaintLayer& paint_layer,
const LayoutObject& layout_object) {
int min_border_width = std::min(
const int min_border_width = std::min(
layout_object.StyleRef().BorderTopWidth(),
std::min(layout_object.StyleRef().BorderLeftWidth(),
std::min(layout_object.StyleRef().BorderRightWidth(),
......@@ -178,8 +178,20 @@ static bool NeedsDecorationOutlineLayer(const PaintLayer& paint_layer,
paint_layer.GetScrollableArea()->UsesCompositedScrolling()) ||
layout_object.IsCanvas() || IsA<LayoutVideo>(layout_object);
// Unlike normal outlines (whole width is outside of the offset), focus
// rings can be drawn with the center of the path aligned with the offset, so
// only 2/3 of the width is outside of the offset.
const int outline_drawn_inside =
layout_object.StyleRef().OutlineStyleIsAuto()
? std::ceil(
layout_object.StyleRef().GetOutlineStrokeWidthForFocusRing() /
3.f) +
1
: 0;
return could_obscure_decorations && layout_object.StyleRef().HasOutline() &&
layout_object.StyleRef().OutlineOffsetInt() < -min_border_width;
(layout_object.StyleRef().OutlineOffsetInt() - outline_drawn_inside) <
-min_border_width;
}
CompositedLayerMapping::CompositedLayerMapping(PaintLayer& layer)
......
<!doctype html>
<script src="../../../resources/run-after-layout-and-paint.js"></script>
<body style="background-color: blue">
<textarea rows=3 style="transform: translateZ(0);">
1
2
3
4
5
</textarea>
<br><br>
<textarea rows=3 style="border-width: 3px; transform: translateZ(0);">
1
2
3
4
5
</textarea>
<br><br>
<textarea rows=3 style="border-width: 5px; transform: translateZ(0);">
1
2
3
4
5
</textarea>
<script>
runAfterLayoutAndPaint(function() {
const textareas = document.querySelectorAll("textarea");
textareas.forEach((textarea) => {
internals.setPseudoClassState(textarea, ":focus", true);
});
}, true);
</script>
</body>
\ No newline at end of file
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