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

Side by Side Diff: ui/views/controls/native/native_view_host_aura.h

Issue 24299004: Implement features in NativeViewHostAura for scroll end effect (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to sky's comments and added some testing Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 5 #ifndef UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 6 #define UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/aura/window.h"
10 #include "ui/aura/window_observer.h" 12 #include "ui/aura/window_observer.h"
13 #include "ui/compositor/layer.h"
11 #include "ui/views/controls/native/native_view_host_wrapper.h" 14 #include "ui/views/controls/native/native_view_host_wrapper.h"
12 #include "ui/views/views_export.h" 15 #include "ui/views/views_export.h"
13 16
14 namespace views { 17 namespace views {
15 18
16 class NativeViewHost; 19 class NativeViewHost;
17 20
18 // Aura implementation of NativeViewHostWrapper. 21 // Aura implementation of NativeViewHostWrapper.
19 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, 22 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper,
20 public aura::WindowObserver { 23 public aura::WindowObserver {
21 public: 24 public:
22 explicit NativeViewHostAura(NativeViewHost* host); 25 explicit NativeViewHostAura(NativeViewHost* host);
23 virtual ~NativeViewHostAura(); 26 virtual ~NativeViewHostAura();
24 27
25 // Overridden from NativeViewHostWrapper: 28 // Overridden from NativeViewHostWrapper:
26 virtual void NativeViewWillAttach() OVERRIDE; 29 virtual void NativeViewWillAttach() OVERRIDE;
30 virtual void NativeViewAttached() OVERRIDE;
27 virtual void NativeViewDetaching(bool destroyed) OVERRIDE; 31 virtual void NativeViewDetaching(bool destroyed) OVERRIDE;
28 virtual void AddedToWidget() OVERRIDE; 32 virtual void AddedToWidget() OVERRIDE;
29 virtual void RemovedFromWidget() OVERRIDE; 33 virtual void RemovedFromWidget() OVERRIDE;
30 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE; 34 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE;
31 virtual bool HasInstalledClip() OVERRIDE; 35 virtual bool HasInstalledClip() OVERRIDE;
32 virtual void UninstallClip() OVERRIDE; 36 virtual void UninstallClip() OVERRIDE;
33 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE; 37 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE;
34 virtual void HideWidget() OVERRIDE; 38 virtual void HideWidget() OVERRIDE;
35 virtual void SetFocus() OVERRIDE; 39 virtual void SetFocus() OVERRIDE;
36 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; 40 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
37 41
38 private: 42 private:
43 friend class NativeViewHostAuraTest;
44
39 // Overridden from aura::WindowObserver: 45 // Overridden from aura::WindowObserver:
40 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; 46 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
41 47
48 // Calculates the origin of the native view for the fast resize path, so it
49 // can be clipped correctly. This value is affected by the current gravity
50 // being applied. The formula for this calulation is:
51 //
52 // x' = x * width_scaling_factor * (content_width - clip_width)
53 // y' = y * height_scaling_factor * (content_heigth - clip_height)
54 //
55 // , where the scaling factors are either 0, 0.5, or 1.0 depending on the
56 // current gravity.
57 gfx::Point CalculateNewNativeViewOrigin(const gfx::Rect& input_rect,
58 const gfx::Rect& native_rect) const;
59
60 // Since the native view is positioned before the clip is installed, the
61 // origin for the clip being used needs to be tranformed into the new
62 // coordinate system due to the input values to ShowWidget being relative to
63 // the native view. This function does the calculation of the origin. This
64 // value is affected by the current gravity being applied. The formula for
65 // this calulation is:
66 //
67 // x' = width_scaling_factor * (content_width - clip_width)
68 // y' = height_scaling_factor * (content_heigth - clip_height)
69 //
70 // , where the scaling factors are either 0, 0.5, or 1.0 depending on the
71 // current gravity.
72 gfx::Point CalculateClipOrigin(const gfx::Rect& input_rect,
73 const gfx::Rect& native_rect) const;
74
75 // Reparents the native view with the clipping window existing between it and
76 // its old parent, so that the fast resize path works.
77 void AddClippingWindow();
78
79 // If the native view has been reparented via AddClippingWindow, this call
80 // undoes it.
81 void RemoveClippingWindow();
82
42 // Our associated NativeViewHost. 83 // Our associated NativeViewHost.
43 NativeViewHost* host_; 84 NativeViewHost* host_;
44 85
45 // Have we installed a clip region? 86 // Have we installed a clip region?
46 bool installed_clip_; 87 bool installed_clip_;
47 88
89 // Window that exists between the native view and the parent that allows for
90 // clipping to occur.
91 aura::Window clipping_window_;
92
93 // The bounds of the content layer before clipping occurs on the fast resize
94 // path. This is restored when the clip is uninstalled. This is done since the
95 // contents needs to be places relatively to the clip that is about to occur.
96 gfx::Rect orig_bounds_;
97
48 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura); 98 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura);
49 }; 99 };
50 100
51 } // namespace views 101 } // namespace views
52 102
53 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 103 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698