Commit 1dc552dd authored by David Black's avatar David Black Committed by Commit Bot

Fix AssistantWebView contents clipping mask.

Previously the painter for our mask layer was a round rect with all
corners of the same corner radius. This caused us to clip content that
appeared in the upper right and left corners.

Now, the painter for our mask layer only rounds the lower right and left
corners to avoid painting outside container bounds. This prevents content
in the upper corners of our contents from being clipped.

See bug for before/after.

Bug: b:116626523
Change-Id: I5295a4ec22217aa35c973a5f8fc29fee47a1d1af
Reviewed-on: https://chromium-review.googlesource.com/1244337Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#594531}
parent d1a3a027
......@@ -5,8 +5,6 @@
#include "ash/assistant/ui/assistant_web_view.h"
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include "ash/assistant/assistant_controller.h"
......@@ -21,12 +19,48 @@
#include "ui/compositor/layer.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/canvas.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/painter.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
// ContentViewMaskPainter -------------------------------------------------
class ContentViewMaskPainter : public views::Painter {
public:
ContentViewMaskPainter() = default;
~ContentViewMaskPainter() override = default;
// views::Painter:
gfx::Size GetMinimumSize() const override { return gfx::Size(); }
void Paint(gfx::Canvas* canvas, const gfx::Size& size) override {
cc::PaintFlags flags;
flags.setAntiAlias(true);
flags.setColor(SK_ColorBLACK);
SkRRect rect;
rect.setRectRadii(
SkRect::MakeWH(size.width(), size.height()),
(const SkVector[]){
/*upper_left=*/SkVector::Make(0, 0),
/*upper_right=*/SkVector::Make(0, 0),
/*lower_right=*/SkVector::Make(kCornerRadiusDip, kCornerRadiusDip),
/*lower_left=*/SkVector::Make(kCornerRadiusDip, kCornerRadiusDip)});
canvas->sk_canvas()->drawRRect(rect, flags);
}
private:
DISALLOW_COPY_AND_ASSIGN(ContentViewMaskPainter);
};
} // namespace
// AssistantWebView ------------------------------------------------------------
AssistantWebView::AssistantWebView(AssistantController* assistant_controller)
......@@ -93,8 +127,7 @@ void AssistantWebView::InitLayout() {
// Content mask.
// This is used to enforce corner radius on the contents' layer.
content_view_mask_ = views::Painter::CreatePaintedLayer(
views::Painter::CreateSolidRoundRectPainter(SK_ColorBLACK,
kCornerRadiusDip));
std::make_unique<ContentViewMaskPainter>());
content_view_mask_->layer()->SetFillsBoundsOpaquely(false);
}
......
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