Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Issue 2228093003: Fix wrong popup offset when changing popup bounds.

Created:
4 years, 4 months ago by bokan
Modified:
4 years, 4 months ago
Reviewers:
ananta, sky
CC:
chromium-reviews, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix wrong popup offset when changing popup bounds. The popup's aura::Window's bounds are relative to the native widget. However, when we change the bounds from Blink, they get applied to the aura::Window and, through various observers, end up resizing and moving the host widget in DesktopNativeWidgetTopLevelHandler. But the aura::Window's bounds origin isn't ever reset. This is problematic in the bug as the following happens: 1. RenderWidgetHostViewAura gets the bounds change message from Blink. 2. It resizes the popup menu's aura::Window and moves it up -20 pixels along the y-axis. 3. DesktopNativeWidgetTopLevelHandler observes the aura::Window for changes and sets the native widget's screen bounds to match the aura::Window 4. The native widget is now pushed up 20 pixels, but the aura::Window still has a -20 y-offset so the content is shifted up 40 pixels. This used to appear to work because Blink would send the bounds change message without regard for whether the bounds actually changed. These multiple messages moving the popup to the same location would end up clearing the aura::Window's offset. In r389984 I made WebWidgetPopupImpl::resize only call into setWindowRect if the bounds actually change which exposed this bug. The fix here is to make DesktopNativeWidgetTopLevelHandler clear the aura::Window's origin when it sets the bounds on the native widget. I also fixed a bug I noticed in WebWidgetPopupImpl::resize in the condition used to check whether the bounds changed. BUG=633140

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -1 line) Patch
M ui/views/widget/desktop_aura/desktop_native_widget_aura.cc View 1 chunk +7 lines, -1 line 6 comments Download

Messages

Total messages: 17 (6 generated)
bokan
Hi ananta@, It looks like you've touched this code quite a bit; please punt to ...
4 years, 4 months ago (2016-08-09 20:38:51 UTC) #2
ananta
+sky https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right): https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc#newcode154 ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:154: top_level_widget_->SetBounds(window->GetBoundsInScreen()); The Widget::SetBounds should make it all the ...
4 years, 4 months ago (2016-08-09 21:24:07 UTC) #6
bokan
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right): https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc#newcode154 ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:154: top_level_widget_->SetBounds(window->GetBoundsInScreen()); On 2016/08/09 21:24:07, ananta wrote: > The Widget::SetBounds ...
4 years, 4 months ago (2016-08-11 17:04:08 UTC) #9
bokan
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right): https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc#newcode154 ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:154: top_level_widget_->SetBounds(window->GetBoundsInScreen()); On 2016/08/11 17:04:08, bokan wrote: > On 2016/08/09 ...
4 years, 4 months ago (2016-08-11 18:14:24 UTC) #10
bokan
ping
4 years, 4 months ago (2016-08-15 05:18:58 UTC) #11
sky
I'm assuming you're pinging Ananta, who had the most recent question. Can you please add ...
4 years, 4 months ago (2016-08-15 15:01:30 UTC) #12
sky
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right): https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc#newcode159 ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:159: window->SetBounds(gfx::Rect(gfx::Point(), window->bounds().size())); I'm nervous about changing the bounds of ...
4 years, 4 months ago (2016-08-15 15:05:48 UTC) #13
bokan
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right): https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc#newcode159 ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:159: window->SetBounds(gfx::Rect(gfx::Point(), window->bounds().size())); On 2016/08/15 15:05:48, sky wrote: > I'm ...
4 years, 4 months ago (2016-08-18 22:51:06 UTC) #14
sky
That depends. If you can write the test entirely in terms of widget, then in ...
4 years, 4 months ago (2016-08-19 03:19:39 UTC) #15
bokan
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right): https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc#newcode159 ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:159: window->SetBounds(gfx::Rect(gfx::Point(), window->bounds().size())); On 2016/08/15 15:05:48, sky wrote: > I'm ...
4 years, 4 months ago (2016-08-19 17:57:47 UTC) #16
sky
4 years, 4 months ago (2016-08-19 20:06:52 UTC) #17
On 2016/08/19 17:57:47, bokan wrote:
>
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aur...
> File ui/views/widget/desktop_aura/desktop_native_widget_aura.cc (right):
> 
>
https://codereview.chromium.org/2228093003/diff/1/ui/views/widget/desktop_aur...
> ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:159:
> window->SetBounds(gfx::Rect(gfx::Point(), window->bounds().size()));
> On 2016/08/15 15:05:48, sky wrote:
> > I'm nervous about changing the bounds of the same window that has it's bound
> > changing. That can easily lead to observers seeing the wrong thing.
> > 
> > This should be done using an aura::LayoutManager. Requests to change a
windows
> > bounds flow through the layoutmanager, so it's the ideal place to change
> things
> > like this.
> 
> I don't think this'll work since the flow through LayoutManager happens before
> the NativeWidget gets the bounds from the Window.

If you make DesktopNativeWidgetTopLevelHandler a LayoutManager (or have a
LayoutManager), DesktopNativeWidgetTopLevelHandler should no longer need to be a
WindowObserver. What is in OnWindowBoundsChanged() should move to the
layoutmanager. You'll likely need to track when the bounds change should be
processed, and when it should be mapped to a change in size/bounds of the
widget.

 It seems like there's a
> strange circular dependency here where the aura::Window location is relative
to
> the Widget but the Widget's location is dependent on the Window location.
> 
> Put another way, we want to move the popup up 20px so we do this:
> 
> 1. RWHVA::SetBounds called with new screen coordinates
> 2. Call Window::SetBounds with parent-relative coordinates y: -20px
> 3. Call Layer::SetBounds
> 4. Calls Layer::SetBoundsFromAnimation
> 5. Calls Window::OnWindowBoundsChanged (this is where the Window::bounds_ is
> actually set)
> 6. Calls Window observer DesktopNativeWidgetAura::OnWindowBoundsChanged
> 7. Calls Widget::SetBounds passing Window::GetBoundsInScreen which because of
> the -20px will move Widget up by 20px on the screen but the Window is still
> -20px relative to the Widget.
> 
> The LayoutManager path is inserted between steps 2 and 3 so clearing the
> location coordinates there means the Widget wouldn't be moved. If the Widget
> gets its location from the Window, then changing the Widget's location should
> counter move the Window to keep it in the same screen location.
> 
> Perhaps the right thing is to not move the Window at all? Can we move the
Widget
> from the RWHVA::SetBounds and Window::SetBounds using only the size?

Powered by Google App Engine
This is Rietveld 408576698