Commit 9e2d2d1f authored by kuan@chromium.org's avatar kuan@chromium.org

alternate ntp: fix content origin when overlay shrinks to shorter than top bars

BUG=229897
TEST=verify per bug rpt

Review URL: https://chromiumcodereview.appspot.com/13974003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194761 0039d316-1c4b-4281-b951-d872f2087c98
parent 896619e7
......@@ -2039,7 +2039,7 @@ void BrowserView::Init() {
contents_container_ = new views::WebView(browser_->profile());
contents_container_->set_id(VIEW_ID_TAB_CONTAINER);
contents_ = new ContentsContainer(contents_container_);
contents_ = new ContentsContainer(contents_container_, this);
overlay_controller_.reset(
new InstantOverlayControllerViews(browser(), contents_));
......
......@@ -352,6 +352,10 @@ void BrowserViewLayout::Layout(views::View* host) {
// Now set the contents to display at their previous origin if we just hid the
// bookmark and/or infobars.
if (active_top_margin == 0 && !old_contents_origin.IsOrigin()) {
// Retrieve the overlay height again since it may have changed in layouts
// triggered in LayoutTabContents().
overlay_height = contents_container_->overlay_height();
// Get the new origin of contents.
gfx::Point new_contents_origin(contents->bounds().origin());
views::View::ConvertPointToTarget(contents->parent(), browser_view_,
&new_contents_origin);
......
......@@ -78,8 +78,10 @@ class ShadowView : public views::View {
} // namespace
ContentsContainer::ContentsContainer(views::WebView* active)
ContentsContainer::ContentsContainer(views::WebView* active,
views::View* browser_view)
: active_(active),
browser_view_(browser_view),
overlay_(NULL),
overlay_web_contents_(NULL),
draw_drop_shadow_(false),
......@@ -170,6 +172,17 @@ void ContentsContainer::SetOverlay(views::WebView* overlay,
#endif // !defined(OS_WIN)
}
// If |overlay_|'s height has shrunk and |active_top_margin_| was used to
// preserve |active_|'s origin in BrowserViewLayout::Layout(), we need to re-
// determine if its origin still needs to be preserved. The origin is
// preserved if overlay is taller than total height of hidden bookmark and
// info bars. In this case, force a re-layout of BrowserView.
bool layout_browser_view = false;
if (overlay_ && active_top_margin_ > 0 && units == INSTANT_SIZE_PIXELS &&
height > 0 && height < overlay_height_) {
layout_browser_view = true;
}
overlay_height_ = height;
overlay_height_units_ = units;
draw_drop_shadow_ = draw_drop_shadow;
......@@ -198,7 +211,10 @@ void ContentsContainer::SetOverlay(views::WebView* overlay,
shadow_view_.reset();
}
Layout();
if (layout_browser_view)
browser_view_->Layout(); // This will trigger |this| Layout.
else
Layout();
}
void ContentsContainer::MaybeStackOverlayAtTop() {
......
......@@ -32,7 +32,7 @@ class ContentsContainer : public views::View,
// Internal class name
static const char kViewClassName[];
explicit ContentsContainer(views::WebView* active);
ContentsContainer(views::WebView* active, views::View* browser_view);
virtual ~ContentsContainer();
// Makes the overlay view the active view and nulls out the old active view.
......@@ -96,6 +96,7 @@ class ContentsContainer : public views::View,
const content::NotificationDetails& details) OVERRIDE;
views::WebView* active_;
views::View* browser_view_;
views::WebView* overlay_;
scoped_ptr<views::View> shadow_view_;
content::WebContents* overlay_web_contents_;
......
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