Commit d2d3689d authored by danakj's avatar danakj Committed by Commit bot

views: Make SubmenuView::PaintChildren use the canvas via PaintRecorder

This uses a PaintRecorder to get at the canvas() for painting, instead
of grabbing it directly off PaintContext. This will allow PaintContext
to be backed by a DisplayItemList instead of a Canvas.

R=sadrul, sky
BUG=466426

Review URL: https://codereview.chromium.org/1064763002

Cr-Commit-Position: refs/heads/master@{#324080}
parent 90099734
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "ui/accessibility/ax_view_state.h" #include "ui/accessibility/ax_view_state.h"
#include "ui/compositor/paint_context.h" #include "ui/compositor/paint_context.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/safe_integer_conversions.h" #include "ui/gfx/geometry/safe_integer_conversions.h"
...@@ -191,8 +192,25 @@ ui::TextInputClient* SubmenuView::GetTextInputClient() { ...@@ -191,8 +192,25 @@ ui::TextInputClient* SubmenuView::GetTextInputClient() {
void SubmenuView::PaintChildren(const ui::PaintContext& context) { void SubmenuView::PaintChildren(const ui::PaintContext& context) {
View::PaintChildren(context); View::PaintChildren(context);
if (drop_item_ && drop_position_ != MenuDelegate::DROP_ON) bool paint_drop_indicator = false;
PaintDropIndicator(context.canvas(), drop_item_, drop_position_); if (drop_item_) {
switch (drop_position_) {
case MenuDelegate::DROP_NONE:
case MenuDelegate::DROP_ON:
break;
case MenuDelegate::DROP_UNKNOWN:
case MenuDelegate::DROP_BEFORE:
case MenuDelegate::DROP_AFTER:
paint_drop_indicator = true;
break;
}
}
if (paint_drop_indicator) {
gfx::Rect bounds = CalculateDropIndicatorBounds(drop_item_, drop_position_);
ui::PaintRecorder recorder(context);
recorder.canvas()->FillRect(bounds, kDropIndicatorColor);
}
} }
bool SubmenuView::GetDropFormats( bool SubmenuView::GetDropFormats(
...@@ -445,16 +463,6 @@ void SubmenuView::OnBoundsChanged(const gfx::Rect& previous_bounds) { ...@@ -445,16 +463,6 @@ void SubmenuView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
SchedulePaint(); SchedulePaint();
} }
void SubmenuView::PaintDropIndicator(gfx::Canvas* canvas,
MenuItemView* item,
MenuDelegate::DropPosition position) {
if (position == MenuDelegate::DROP_NONE)
return;
gfx::Rect bounds = CalculateDropIndicatorBounds(item, position);
canvas->FillRect(bounds, kDropIndicatorColor);
}
void SubmenuView::SchedulePaintForDropIndicator( void SubmenuView::SchedulePaintForDropIndicator(
MenuItemView* item, MenuItemView* item,
MenuDelegate::DropPosition position) { MenuDelegate::DropPosition position) {
......
...@@ -166,12 +166,6 @@ class VIEWS_EXPORT SubmenuView : public PrefixDelegate, ...@@ -166,12 +166,6 @@ class VIEWS_EXPORT SubmenuView : public PrefixDelegate,
void ChildPreferredSizeChanged(View* child) override; void ChildPreferredSizeChanged(View* child) override;
private: private:
// Paints the drop indicator. This is only invoked if item is non-NULL and
// position is not DROP_NONE.
void PaintDropIndicator(gfx::Canvas* canvas,
MenuItemView* item,
MenuDelegate::DropPosition position);
void SchedulePaintForDropIndicator(MenuItemView* item, void SchedulePaintForDropIndicator(MenuItemView* item,
MenuDelegate::DropPosition position); MenuDelegate::DropPosition position);
......
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