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

Side by Side Diff: ui/views/view.h

Issue 275183002: patch from issue 218843002 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 7 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
« no previous file with comments | « ui/views/cull_set.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_VIEW_H_ 5 #ifndef UI_VIEWS_VIEW_H_
6 #define UI_VIEWS_VIEW_H_ 6 #define UI_VIEWS_VIEW_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "ui/accessibility/ax_enums.h" 19 #include "ui/accessibility/ax_enums.h"
20 #include "ui/base/accelerators/accelerator.h" 20 #include "ui/base/accelerators/accelerator.h"
21 #include "ui/base/dragdrop/drag_drop_types.h" 21 #include "ui/base/dragdrop/drag_drop_types.h"
22 #include "ui/base/dragdrop/drop_target_event.h" 22 #include "ui/base/dragdrop/drop_target_event.h"
23 #include "ui/base/dragdrop/os_exchange_data.h" 23 #include "ui/base/dragdrop/os_exchange_data.h"
24 #include "ui/base/ui_base_types.h" 24 #include "ui/base/ui_base_types.h"
25 #include "ui/compositor/layer_delegate.h" 25 #include "ui/compositor/layer_delegate.h"
26 #include "ui/compositor/layer_owner.h" 26 #include "ui/compositor/layer_owner.h"
27 #include "ui/events/event.h" 27 #include "ui/events/event.h"
28 #include "ui/events/event_target.h" 28 #include "ui/events/event_target.h"
29 #include "ui/events/event_targeter.h" 29 #include "ui/events/event_targeter.h"
30 #include "ui/gfx/geometry/r_tree.h"
30 #include "ui/gfx/insets.h" 31 #include "ui/gfx/insets.h"
31 #include "ui/gfx/native_widget_types.h" 32 #include "ui/gfx/native_widget_types.h"
32 #include "ui/gfx/rect.h" 33 #include "ui/gfx/rect.h"
33 #include "ui/gfx/vector2d.h" 34 #include "ui/gfx/vector2d.h"
35 #include "ui/views/cull_set.h"
34 #include "ui/views/views_export.h" 36 #include "ui/views/views_export.h"
35 37
36 #if defined(OS_WIN) 38 #if defined(OS_WIN)
37 #include "base/win/scoped_comptr.h" 39 #include "base/win/scoped_comptr.h"
38 #endif 40 #endif
39 41
40 using ui::OSExchangeData; 42 using ui::OSExchangeData;
41 43
42 namespace gfx { 44 namespace gfx {
43 class Canvas; 45 class Canvas;
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // transformations are applied to it to convert it into the parent coordinate 497 // transformations are applied to it to convert it into the parent coordinate
496 // system before propagating SchedulePaint up the view hierarchy. 498 // system before propagating SchedulePaint up the view hierarchy.
497 // TODO(beng): Make protected. 499 // TODO(beng): Make protected.
498 virtual void SchedulePaint(); 500 virtual void SchedulePaint();
499 virtual void SchedulePaintInRect(const gfx::Rect& r); 501 virtual void SchedulePaintInRect(const gfx::Rect& r);
500 502
501 // Called by the framework to paint a View. Performs translation and clipping 503 // Called by the framework to paint a View. Performs translation and clipping
502 // for View coordinates and language direction as required, allows the View 504 // for View coordinates and language direction as required, allows the View
503 // to paint itself via the various OnPaint*() event handlers and then paints 505 // to paint itself via the various OnPaint*() event handlers and then paints
504 // the hierarchy beneath it. 506 // the hierarchy beneath it.
505 virtual void Paint(gfx::Canvas* canvas); 507 virtual void Paint(gfx::Canvas* canvas, const CullSet& cull_set);
506 508
507 // The background object is owned by this object and may be NULL. 509 // The background object is owned by this object and may be NULL.
508 void set_background(Background* b); 510 void set_background(Background* b);
509 const Background* background() const { return background_.get(); } 511 const Background* background() const { return background_.get(); }
510 Background* background() { return background_.get(); } 512 Background* background() { return background_.get(); }
511 513
512 // The border object is owned by this object and may be NULL. 514 // The border object is owned by this object and may be NULL.
513 virtual void SetBorder(scoped_ptr<Border> b); 515 virtual void SetBorder(scoped_ptr<Border> b);
514 const Border* border() const { return border_.get(); } 516 const Border* border() const { return border_.get(); }
515 Border* border() { return border_.get(); } 517 Border* border() { return border_.get(); }
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 // ViewHierarchyChanged() is called when the parent NativeView of the widget 1071 // ViewHierarchyChanged() is called when the parent NativeView of the widget
1070 // that the view is attached to is changed as a result of changing the view 1072 // that the view is attached to is changed as a result of changing the view
1071 // hierarchy. Overriding this method is useful for tracking which 1073 // hierarchy. Overriding this method is useful for tracking which
1072 // FocusManager manages this view. 1074 // FocusManager manages this view.
1073 virtual void NativeViewHierarchyChanged(); 1075 virtual void NativeViewHierarchyChanged();
1074 1076
1075 // Painting ------------------------------------------------------------------ 1077 // Painting ------------------------------------------------------------------
1076 1078
1077 // Responsible for calling Paint() on child Views. Override to control the 1079 // Responsible for calling Paint() on child Views. Override to control the
1078 // order child Views are painted. 1080 // order child Views are painted.
1079 virtual void PaintChildren(gfx::Canvas* canvas); 1081 virtual void PaintChildren(gfx::Canvas* canvas, const CullSet& cull_set);
1080 1082
1081 // Override to provide rendering in any part of the View's bounds. Typically 1083 // Override to provide rendering in any part of the View's bounds. Typically
1082 // this is the "contents" of the view. If you override this method you will 1084 // this is the "contents" of the view. If you override this method you will
1083 // have to call the subsequent OnPaint*() methods manually. 1085 // have to call the subsequent OnPaint*() methods manually.
1084 virtual void OnPaint(gfx::Canvas* canvas); 1086 virtual void OnPaint(gfx::Canvas* canvas);
1085 1087
1086 // Override to paint a background before any content is drawn. Typically this 1088 // Override to paint a background before any content is drawn. Typically this
1087 // is done if you are satisfied with a default OnPaint handler but wish to 1089 // is done if you are satisfied with a default OnPaint handler but wish to
1088 // supply a different background. 1090 // supply a different background.
1089 virtual void OnPaintBackground(gfx::Canvas* canvas); 1091 virtual void OnPaintBackground(gfx::Canvas* canvas);
1090 1092
1091 // Override to paint a border not specified by SetBorder(). 1093 // Override to paint a border not specified by SetBorder().
1092 virtual void OnPaintBorder(gfx::Canvas* canvas); 1094 virtual void OnPaintBorder(gfx::Canvas* canvas);
1093 1095
1096 // Returns true if this View is the root for paint events, and should
1097 // therefore maintain a |bounds_tree_| member and use it for paint damage rect
1098 // calculations.
1099 virtual bool IsPaintRoot();
1100
1094 // Accelerated painting ------------------------------------------------------ 1101 // Accelerated painting ------------------------------------------------------
1095 1102
1096 // Returns the offset from this view to the nearest ancestor with a layer. If 1103 // Returns the offset from this view to the nearest ancestor with a layer. If
1097 // |layer_parent| is non-NULL it is set to the nearest ancestor with a layer. 1104 // |layer_parent| is non-NULL it is set to the nearest ancestor with a layer.
1098 virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer( 1105 virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer(
1099 ui::Layer** layer_parent); 1106 ui::Layer** layer_parent);
1100 1107
1101 // Updates the view's layer's parent. Called when a view is added to a view 1108 // Updates the view's layer's parent. Called when a view is added to a view
1102 // hierarchy, responsible for parenting the view's layer to the enclosing 1109 // hierarchy, responsible for parenting the view's layer to the enclosing
1103 // layer in the hierarchy. 1110 // layer in the hierarchy.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 // Indicates the size changed (and possibly the origin). 1251 // Indicates the size changed (and possibly the origin).
1245 SCHEDULE_PAINT_SIZE_CHANGED 1252 SCHEDULE_PAINT_SIZE_CHANGED
1246 }; 1253 };
1247 1254
1248 // Invoked before and after the bounds change to schedule painting the old and 1255 // Invoked before and after the bounds change to schedule painting the old and
1249 // new bounds. 1256 // new bounds.
1250 void SchedulePaintBoundsChanged(SchedulePaintType type); 1257 void SchedulePaintBoundsChanged(SchedulePaintType type);
1251 1258
1252 // Common Paint() code shared by accelerated and non-accelerated code paths to 1259 // Common Paint() code shared by accelerated and non-accelerated code paths to
1253 // invoke OnPaint() on the View. 1260 // invoke OnPaint() on the View.
1254 void PaintCommon(gfx::Canvas* canvas); 1261 void PaintCommon(gfx::Canvas* canvas, const CullSet& cull_set);
1255 1262
1256 // Tree operations ----------------------------------------------------------- 1263 // Tree operations -----------------------------------------------------------
1257 1264
1258 // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true, 1265 // Removes |view| from the hierarchy tree. If |update_focus_cycle| is true,
1259 // the next and previous focusable views of views pointing to this view are 1266 // the next and previous focusable views of views pointing to this view are
1260 // updated. If |update_tool_tip| is true, the tooltip is updated. If 1267 // updated. If |update_tool_tip| is true, the tooltip is updated. If
1261 // |delete_removed_view| is true, the view is also deleted (if it is parent 1268 // |delete_removed_view| is true, the view is also deleted (if it is parent
1262 // owned). If |new_parent| is not NULL, the remove is the result of 1269 // owned). If |new_parent| is not NULL, the remove is the result of
1263 // AddChildView() to a new parent. For this case, |new_parent| is the View 1270 // AddChildView() to a new parent. For this case, |new_parent| is the View
1264 // that |view| is going to be added to after the remove completes. 1271 // that |view| is going to be added to after the remove completes.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 void UnregisterForVisibleBoundsNotification(); 1320 void UnregisterForVisibleBoundsNotification();
1314 1321
1315 // Adds/removes view to the list of descendants that are notified any time 1322 // Adds/removes view to the list of descendants that are notified any time
1316 // this views location and possibly size are changed. 1323 // this views location and possibly size are changed.
1317 void AddDescendantToNotify(View* view); 1324 void AddDescendantToNotify(View* view);
1318 void RemoveDescendantToNotify(View* view); 1325 void RemoveDescendantToNotify(View* view);
1319 1326
1320 // Sets the layer's bounds given in DIP coordinates. 1327 // Sets the layer's bounds given in DIP coordinates.
1321 void SetLayerBounds(const gfx::Rect& bounds_in_dip); 1328 void SetLayerBounds(const gfx::Rect& bounds_in_dip);
1322 1329
1330 // Sets the bit indicating that the cached bounds for this object within the
1331 // root view bounds tree are no longer valid. If |origin_changed| is true sets
1332 // the same bit for all of our children as well.
1333 void SetRootBoundsDirty(bool origin_changed);
1334
1335 // If needed, updates the bounds rectangle in paint root coordinate space
1336 // in the supplied RTree. Recurses to children for recomputation as well.
1337 void UpdateRootBounds(gfx::RTree* bounds_tree, const gfx::Vector2d& offset);
1338
1339 // Remove self and all children from the supplied bounds tree. This is used,
1340 // for example, when a view gets a layer and therefore becomes paint root. It
1341 // needs to remove all references to itself and its children from any previous
1342 // paint root that may have been tracking it.
1343 void RemoveRootBounds(gfx::RTree* bounds_tree);
1344
1345 // Traverse up the View hierarchy to the first ancestor that is a paint root
1346 // and return a pointer to its |bounds_tree_| or NULL if no tree is found.
1347 gfx::RTree* GetBoundsTreeFromPaintRoot();
1348
1323 // Transformations ----------------------------------------------------------- 1349 // Transformations -----------------------------------------------------------
1324 1350
1325 // Returns in |transform| the transform to get from coordinates of |ancestor| 1351 // Returns in |transform| the transform to get from coordinates of |ancestor|
1326 // to this. Returns true if |ancestor| is found. If |ancestor| is not found, 1352 // to this. Returns true if |ancestor| is found. If |ancestor| is not found,
1327 // or NULL, |transform| is set to convert from root view coordinates to this. 1353 // or NULL, |transform| is set to convert from root view coordinates to this.
1328 bool GetTransformRelativeTo(const View* ancestor, 1354 bool GetTransformRelativeTo(const View* ancestor,
1329 gfx::Transform* transform) const; 1355 gfx::Transform* transform) const;
1330 1356
1331 // Coordinate conversion ----------------------------------------------------- 1357 // Coordinate conversion -----------------------------------------------------
1332 1358
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 // This flag is initialized to false. 1511 // This flag is initialized to false.
1486 bool notify_enter_exit_on_child_; 1512 bool notify_enter_exit_on_child_;
1487 1513
1488 // Whether or not RegisterViewForVisibleBoundsNotification on the RootView 1514 // Whether or not RegisterViewForVisibleBoundsNotification on the RootView
1489 // has been invoked. 1515 // has been invoked.
1490 bool registered_for_visible_bounds_notification_; 1516 bool registered_for_visible_bounds_notification_;
1491 1517
1492 // List of descendants wanting notification when their visible bounds change. 1518 // List of descendants wanting notification when their visible bounds change.
1493 scoped_ptr<Views> descendants_to_notify_; 1519 scoped_ptr<Views> descendants_to_notify_;
1494 1520
1521 // True if the bounds on this object have changed since the last time the
1522 // paint root view constructed the spatial database.
1523 bool root_bounds_dirty_;
1524
1525 // If this View IsPaintRoot() then this will be a pointer to a spatial data
1526 // structure where we will keep the bounding boxes of all our children, for
1527 // efficient paint damage rectangle intersection.
1528 scoped_ptr<gfx::RTree> bounds_tree_;
1529
1495 // Transformations ----------------------------------------------------------- 1530 // Transformations -----------------------------------------------------------
1496 1531
1497 // Clipping parameters. skia transformation matrix does not give us clipping. 1532 // Clipping parameters. skia transformation matrix does not give us clipping.
1498 // So we do it ourselves. 1533 // So we do it ourselves.
1499 gfx::Insets clip_insets_; 1534 gfx::Insets clip_insets_;
1500 1535
1501 // Layout -------------------------------------------------------------------- 1536 // Layout --------------------------------------------------------------------
1502 1537
1503 // Whether the view needs to be laid out. 1538 // Whether the view needs to be laid out.
1504 bool needs_layout_; 1539 bool needs_layout_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 // Belongs to this view, but it's reference-counted on some platforms 1606 // Belongs to this view, but it's reference-counted on some platforms
1572 // so we can't use a scoped_ptr. It's dereferenced in the destructor. 1607 // so we can't use a scoped_ptr. It's dereferenced in the destructor.
1573 NativeViewAccessibility* native_view_accessibility_; 1608 NativeViewAccessibility* native_view_accessibility_;
1574 1609
1575 DISALLOW_COPY_AND_ASSIGN(View); 1610 DISALLOW_COPY_AND_ASSIGN(View);
1576 }; 1611 };
1577 1612
1578 } // namespace views 1613 } // namespace views
1579 1614
1580 #endif // UI_VIEWS_VIEW_H_ 1615 #endif // UI_VIEWS_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/cull_set.cc ('k') | ui/views/view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698