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

Side by Side Diff: cc/top_controls_manager.cc

Issue 11967021: Remove top controls layer from cc/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove invalid TODO Created 7 years, 11 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
« no previous file with comments | « cc/top_controls_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "cc/top_controls_manager.h" 5 #include "cc/top_controls_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // static 26 // static
27 scoped_ptr<TopControlsManager> TopControlsManager::Create( 27 scoped_ptr<TopControlsManager> TopControlsManager::Create(
28 TopControlsManagerClient* client, float top_controls_height) { 28 TopControlsManagerClient* client, float top_controls_height) {
29 return make_scoped_ptr(new TopControlsManager(client, top_controls_height)); 29 return make_scoped_ptr(new TopControlsManager(client, top_controls_height));
30 } 30 }
31 31
32 TopControlsManager::TopControlsManager(TopControlsManagerClient* client, 32 TopControlsManager::TopControlsManager(TopControlsManagerClient* client,
33 float top_controls_height) 33 float top_controls_height)
34 : client_(client), 34 : client_(client),
35 content_layer_id_(0),
36 is_overlay_mode_(false), 35 is_overlay_mode_(false),
37 top_controls_height_(top_controls_height), 36 top_controls_height_(top_controls_height),
38 controls_top_offset_(0), 37 controls_top_offset_(0),
39 content_top_offset_(top_controls_height), 38 content_top_offset_(top_controls_height),
40 previous_root_scroll_offset_(0.f), 39 previous_root_scroll_offset_(0.f),
41 scroll_readjustment_enabled_(false), 40 scroll_readjustment_enabled_(false),
42 is_showing_animation_(false) { 41 is_showing_animation_(false) {
43 CHECK(client_); 42 CHECK(client_);
44 } 43 }
45 44
46 TopControlsManager::~TopControlsManager() { 45 TopControlsManager::~TopControlsManager() {
47 } 46 }
48 47
49 void TopControlsManager::UpdateDrawPositions() { 48 void TopControlsManager::UpdateDrawPositions() {
50 if (!RootScrollLayer()) 49 if (!RootScrollLayer())
51 return; 50 return;
52 51
53 // If the scroll position has changed underneath us (i.e. a javascript 52 // If the scroll position has changed underneath us (i.e. a javascript
54 // scroll), then simulate a scroll that covers the delta. 53 // scroll), then simulate a scroll that covers the delta.
55 float scroll_total_y = RootScrollLayerTotalScrollY(); 54 float scroll_total_y = RootScrollLayerTotalScrollY();
56 if (scroll_readjustment_enabled_ 55 if (scroll_readjustment_enabled_
57 && scroll_total_y != previous_root_scroll_offset_) { 56 && scroll_total_y != previous_root_scroll_offset_) {
58 ScrollBy(gfx::Vector2dF(0, scroll_total_y - previous_root_scroll_offset_)); 57 ScrollBy(gfx::Vector2dF(0, scroll_total_y - previous_root_scroll_offset_));
59 StartAnimationIfNecessary(); 58 StartAnimationIfNecessary();
60 previous_root_scroll_offset_ = RootScrollLayerTotalScrollY(); 59 previous_root_scroll_offset_ = RootScrollLayerTotalScrollY();
61 } 60 }
62
63 float offset_top = is_overlay_mode_ ? 0 : content_top_offset_;
64
65 LayerImpl* content_layer =
66 client_->activeTree()->FindActiveTreeLayerById(content_layer_id_);
67 DCHECK(content_layer);
68 if (content_layer) {
69 gfx::Transform transform;
70 transform.Translate(0, offset_top);
71 content_layer->setTransform(transform);
72 }
73
74 // TODO(tedchoc): Adjust fixed position layers as well.
75 } 61 }
76 62
77 void TopControlsManager::ScrollBegin() { 63 void TopControlsManager::ScrollBegin() {
78 ResetAnimations(); 64 ResetAnimations();
79 scroll_readjustment_enabled_ = false; 65 scroll_readjustment_enabled_ = false;
80 } 66 }
81 67
82 gfx::Vector2dF TopControlsManager::ScrollBy( 68 gfx::Vector2dF TopControlsManager::ScrollBy(
83 const gfx::Vector2dF pending_delta) { 69 const gfx::Vector2dF pending_delta) {
84 ResetAnimations(); 70 ResetAnimations();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 171
186 if (controls_top_offset_ != 0 172 if (controls_top_offset_ != 0
187 && controls_top_offset_ != -top_controls_height_) { 173 && controls_top_offset_ != -top_controls_height_) {
188 SetupAnimation( 174 SetupAnimation(
189 controls_top_offset_ >= -(top_controls_height_ * kShowHideThreshold)); 175 controls_top_offset_ >= -(top_controls_height_ * kShowHideThreshold));
190 client_->setNeedsRedraw(); 176 client_->setNeedsRedraw();
191 } 177 }
192 } 178 }
193 179
194 } // namespace cc 180 } // namespace cc
OLDNEW
« no previous file with comments | « cc/top_controls_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698