Commit 2eee57dd authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

[Multipaste] Refactoring on ClipboardHistoryBitmapItemView

ClipboardHistoryBitmapItemView contains a pointer to a
RoundedImageView instance which is the item view's grandchild.
This CL removes the pointer to RoundedImageView from
ClipboardHistoryBitmapItemView. Instead, the pointer is kept by
BitmapContentsView, the RoundedImageView's parent. This change should
not bring any visual difference.

Bug: 1139498
Change-Id: Ie3e2dacd32dcd6500394278c01e1903c35b5f8d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508797
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarDavid Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#822694}
parent 2f0be479
......@@ -11,7 +11,6 @@
namespace ash {
class ClipboardHistoryResourceManager;
class RoundedImageView;
// The menu item showing a bitmap.
class ClipboardHistoryBitmapItemView : public ClipboardHistoryItemView {
......@@ -26,23 +25,12 @@ class ClipboardHistoryBitmapItemView : public ClipboardHistoryItemView {
const ClipboardHistoryBitmapItemView& rhs) = delete;
~ClipboardHistoryBitmapItemView() override;
// Updates |image_view_|'s size.
void UpdateChildImageViewSize();
private:
class BitmapContentsView;
// ClipboardHistoryItemView:
const char* GetClassName() const override;
std::unique_ptr<ContentsView> CreateContentsView() override;
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void OnThemeChanged() override;
// Builds `image_view_`.
std::unique_ptr<RoundedImageView> BuildImageView();
// Owned by view hierarchy.
RoundedImageView* image_view_ = nullptr;
// Owned by ClipboardHistoryController.
const ClipboardHistoryResourceManager* const resource_manager_;
......
......@@ -55,6 +55,10 @@ void ClipboardHistoryItemView::ContentsView::InstallDeleteButton() {
delete_button_ = CreateDeleteButton();
}
const char* ClipboardHistoryItemView::ContentsView::GetClassName() const {
return "ContenstView";
}
// Accepts the event only when |delete_button_| should be the handler.
bool ClipboardHistoryItemView::ContentsView::DoesIntersectRect(
const views::View* target,
......
......@@ -78,16 +78,21 @@ class ClipboardHistoryItemView : public views::View {
protected:
virtual DeleteButton* CreateDeleteButton() = 0;
// The parent of ContentsView.
ClipboardHistoryItemView* const container_;
ClipboardHistoryItemView* container() { return container_; }
private:
// views::View:
const char* GetClassName() const override;
// views::ViewTargeterDelegate:
bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override;
// Owned by the view hierarchy.
DeleteButton* delete_button_ = nullptr;
// The parent of ContentsView.
ClipboardHistoryItemView* const container_;
};
ClipboardHistoryItemView(const ClipboardHistoryItem* clipboard_history_item,
......
......@@ -43,7 +43,7 @@ class ClipboardHistoryTextItemView::TextContentsView
private:
// ContentsView:
DeleteButton* CreateDeleteButton() override {
auto delete_button = std::make_unique<DeleteButton>(container_);
auto delete_button = std::make_unique<DeleteButton>(container());
delete_button->SetVisible(false);
delete_button->SetProperty(views::kMarginsKey, kDeleteButtonMargins);
return AddChildView(std::move(delete_button));
......
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