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

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: Integrated xiyuan's CL and responded to comments 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 "ui/aura/window.h"
10 #include "ui/aura/window_observer.h" 11 #include "ui/aura/window_observer.h"
11 #include "ui/views/controls/native/native_view_host_wrapper.h" 12 #include "ui/views/controls/native/native_view_host_wrapper.h"
12 #include "ui/views/views_export.h" 13 #include "ui/views/views_export.h"
13 14
14 namespace views { 15 namespace views {
15 16
16 class NativeViewHost; 17 class NativeViewHost;
17 18
18 // Aura implementation of NativeViewHostWrapper. 19 // Aura implementation of NativeViewHostWrapper.
19 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper, 20 class VIEWS_EXPORT NativeViewHostAura : public NativeViewHostWrapper,
20 public aura::WindowObserver { 21 public aura::WindowObserver {
21 public: 22 public:
22 explicit NativeViewHostAura(NativeViewHost* host); 23 explicit NativeViewHostAura(NativeViewHost* host);
23 virtual ~NativeViewHostAura(); 24 virtual ~NativeViewHostAura();
24 25
25 // Overridden from NativeViewHostWrapper: 26 // Overridden from NativeViewHostWrapper:
26 virtual void NativeViewWillAttach() OVERRIDE; 27 virtual void AttachNativeView() OVERRIDE;
27 virtual void NativeViewDetaching(bool destroyed) OVERRIDE; 28 virtual void NativeViewDetaching(bool destroyed) OVERRIDE;
28 virtual void AddedToWidget() OVERRIDE; 29 virtual void AddedToWidget() OVERRIDE;
29 virtual void RemovedFromWidget() OVERRIDE; 30 virtual void RemovedFromWidget() OVERRIDE;
30 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE; 31 virtual void InstallClip(int x, int y, int w, int h) OVERRIDE;
31 virtual bool HasInstalledClip() OVERRIDE; 32 virtual bool HasInstalledClip() OVERRIDE;
32 virtual void UninstallClip() OVERRIDE; 33 virtual void UninstallClip() OVERRIDE;
33 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE; 34 virtual void ShowWidget(int x, int y, int w, int h) OVERRIDE;
34 virtual void HideWidget() OVERRIDE; 35 virtual void HideWidget() OVERRIDE;
35 virtual void SetFocus() OVERRIDE; 36 virtual void SetFocus() OVERRIDE;
36 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; 37 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
37 38
38 private: 39 private:
40 friend class NativeViewHostAuraTest;
41
39 // Overridden from aura::WindowObserver: 42 // Overridden from aura::WindowObserver:
40 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; 43 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE;
41 44
45 // Calculates the origin of the native view for the fast resize path, so it
46 // can be clipped correctly. This value is affected by the current gravity
47 // being applied. The formula for this calulation is:
48 //
49 // x' = width_scaling_factor * (content_width - clip_width)
50 // y' = height_scaling_factor * (content_heigth - clip_height)
51 //
52 // , where the scaling factors are either 0, 0.5, or 1.0 depending on the
53 // current gravity.
54 gfx::Point CalculateNativeViewOrigin(const gfx::Rect& input_rect,
55 const gfx::Rect& native_rect) const;
56
57 // Reparents the native view with the clipping window existing between it and
58 // its old parent, so that the fast resize path works.
59 void AddClippingWindow();
60
61 // If the native view has been reparented via AddClippingWindow, this call
62 // undoes it.
63 void RemoveClippingWindow();
64
65 // TBD
66 void UpdateClippingWindow();
67
42 // Our associated NativeViewHost. 68 // Our associated NativeViewHost.
43 NativeViewHost* host_; 69 NativeViewHost* host_;
44 70
45 // Have we installed a clip region? 71 // Have we installed a clip region?
46 bool installed_clip_; 72 bool installed_clip_;
47 73
74 // Window that exists between the native view and the parent that allows for
75 // clipping to occur.
76 aura::Window clipping_window_;
77
78 // The bounds of the content layer before clipping occurs on the fast resize
79 // path. This is restored when the clip is uninstalled. This is done since the
80 // contents needs to be places relatively to the clip that is about to occur.
81 gfx::Rect orig_bounds_;
82
83 // TBD
84 gfx::Rect clip_rect_;
xiyuan 2013/10/09 18:31:47 It would be good to document this and |orig_bounds
rharrison 2013/10/10 15:08:55 Done.
85
48 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura); 86 DISALLOW_COPY_AND_ASSIGN(NativeViewHostAura);
49 }; 87 };
50 88
51 } // namespace views 89 } // namespace views
52 90
53 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_ 91 #endif // UI_VIEWS_CONTROLS_NATIVE_NATIVE_VIEW_HOST_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698