rAc: reduce number of redundant layouts of DetailsContainerView
This cuts down total AutofillDialogViews layout time by about half (!). BUG=285996, 272402 Review URL: https://chromiumcodereview.appspot.com/23526021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221584 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/browser/ui/views/autofill
@@ -240,24 +240,6 @@ class ErrorBubbleContents : public views::View {
|
|||||||
DISALLOW_COPY_AND_ASSIGN(ErrorBubbleContents);
|
DISALLOW_COPY_AND_ASSIGN(ErrorBubbleContents);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A view that runs a callback whenever its bounds change.
|
|
||||||
class DetailsContainerView : public views::View {
|
|
||||||
public:
|
|
||||||
explicit DetailsContainerView(const base::Closure& callback)
|
|
||||||
: bounds_changed_callback_(callback) {}
|
|
||||||
virtual ~DetailsContainerView() {}
|
|
||||||
|
|
||||||
// views::View implementation.
|
|
||||||
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE {
|
|
||||||
bounds_changed_callback_.Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
base::Closure bounds_changed_callback_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(DetailsContainerView);
|
|
||||||
};
|
|
||||||
|
|
||||||
// A view that propagates visibility and preferred size changes.
|
// A view that propagates visibility and preferred size changes.
|
||||||
class LayoutPropagationView : public views::View {
|
class LayoutPropagationView : public views::View {
|
||||||
public:
|
public:
|
||||||
@@ -1067,6 +1049,25 @@ int AutofillDialogViews::SuggestedButton::ResourceIDForState() const {
|
|||||||
return IDR_AUTOFILL_DIALOG_MENU_BUTTON;
|
return IDR_AUTOFILL_DIALOG_MENU_BUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AutofillDialogViews::DetailsContainerView -----------------------------------
|
||||||
|
|
||||||
|
AutofillDialogViews::DetailsContainerView::DetailsContainerView(
|
||||||
|
const base::Closure& callback)
|
||||||
|
: bounds_changed_callback_(callback),
|
||||||
|
ignore_layouts_(false) {}
|
||||||
|
|
||||||
|
AutofillDialogViews::DetailsContainerView::~DetailsContainerView() {}
|
||||||
|
|
||||||
|
void AutofillDialogViews::DetailsContainerView::OnBoundsChanged(
|
||||||
|
const gfx::Rect& previous_bounds) {
|
||||||
|
bounds_changed_callback_.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutofillDialogViews::DetailsContainerView::Layout() {
|
||||||
|
if (!ignore_layouts_)
|
||||||
|
views::View::Layout();
|
||||||
|
}
|
||||||
|
|
||||||
// AutofillDialogViews::SuggestionView -----------------------------------------
|
// AutofillDialogViews::SuggestionView -----------------------------------------
|
||||||
|
|
||||||
AutofillDialogViews::SuggestionView::SuggestionView(
|
AutofillDialogViews::SuggestionView::SuggestionView(
|
||||||
@@ -1558,8 +1559,12 @@ void AutofillDialogViews::Layout() {
|
|||||||
scroll_y += notification_height + views::kRelatedControlVerticalSpacing;
|
scroll_y += notification_height + views::kRelatedControlVerticalSpacing;
|
||||||
|
|
||||||
int scroll_bottom = content_bounds.bottom();
|
int scroll_bottom = content_bounds.bottom();
|
||||||
scrollable_area_->contents()->SizeToPreferredSize();
|
DCHECK_EQ(scrollable_area_->contents(), details_container_);
|
||||||
|
details_container_->SizeToPreferredSize();
|
||||||
|
// TODO(estade): remove this hack. See crbug.com/285996
|
||||||
|
details_container_->set_ignore_layouts(true);
|
||||||
scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y);
|
scrollable_area_->SetBounds(x, scroll_y, width, scroll_bottom - scroll_y);
|
||||||
|
details_container_->set_ignore_layouts(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loading_shield_->visible())
|
if (loading_shield_->visible())
|
||||||
|
@@ -398,6 +398,30 @@ class AutofillDialogViews : public AutofillDialogView,
|
|||||||
DISALLOW_COPY_AND_ASSIGN(SuggestedButton);
|
DISALLOW_COPY_AND_ASSIGN(SuggestedButton);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A view that runs a callback whenever its bounds change, and which can
|
||||||
|
// optionally suppress layout.
|
||||||
|
class DetailsContainerView : public views::View {
|
||||||
|
public:
|
||||||
|
explicit DetailsContainerView(const base::Closure& callback);
|
||||||
|
virtual ~DetailsContainerView();
|
||||||
|
|
||||||
|
void set_ignore_layouts(bool ignore_layouts) {
|
||||||
|
ignore_layouts_ = ignore_layouts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// views::View implementation.
|
||||||
|
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
|
||||||
|
virtual void Layout() OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
base::Closure bounds_changed_callback_;
|
||||||
|
|
||||||
|
// The view ignores Layout() calls when this is true.
|
||||||
|
bool ignore_layouts_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(DetailsContainerView);
|
||||||
|
};
|
||||||
|
|
||||||
// A view that contains a suggestion (such as a known address) and a link to
|
// A view that contains a suggestion (such as a known address) and a link to
|
||||||
// edit the suggestion.
|
// edit the suggestion.
|
||||||
class SuggestionView : public views::View {
|
class SuggestionView : public views::View {
|
||||||
@@ -612,7 +636,7 @@ class AutofillDialogViews : public AutofillDialogView,
|
|||||||
views::ScrollView* scrollable_area_;
|
views::ScrollView* scrollable_area_;
|
||||||
|
|
||||||
// View to host details sections.
|
// View to host details sections.
|
||||||
views::View* details_container_;
|
DetailsContainerView* details_container_;
|
||||||
|
|
||||||
// A view that overlays |this| (for "loading..." messages).
|
// A view that overlays |this| (for "loading..." messages).
|
||||||
views::View* loading_shield_;
|
views::View* loading_shield_;
|
||||||
|
Reference in New Issue
Block a user