Skip to content

Commit

Permalink
Brevity for LayerTreeHostImpl references.
Browse files Browse the repository at this point in the history
There is minimal ambiguity for tree related classes to reference the
LayerTreeHostImpl as host_impl rather than layer_tree_host_impl, and
reasonably high value from shorter code.

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ifb4e1c098ba8aa840aaa5c2ccf91e5b525a4be8b
Reviewed-on: https://chromium-review.googlesource.com/627389
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Commit-Queue: Walter Korman <wkorman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496489}
  • Loading branch information
shaper authored and Commit Bot committed Aug 22, 2017
1 parent 6d158ab commit aa326e4
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 235 deletions.
40 changes: 18 additions & 22 deletions cc/input/scroll_elasticity_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace cc {

class ScrollElasticityHelperImpl : public ScrollElasticityHelper {
public:
explicit ScrollElasticityHelperImpl(LayerTreeHostImpl* layer_tree_host_impl);
explicit ScrollElasticityHelperImpl(LayerTreeHostImpl* host_impl);
~ScrollElasticityHelperImpl() override;

bool IsUserScrollable() const override;
Expand All @@ -25,68 +25,64 @@ class ScrollElasticityHelperImpl : public ScrollElasticityHelper {
void RequestOneBeginFrame() override;

private:
LayerTreeHostImpl* layer_tree_host_impl_;
LayerTreeHostImpl* host_impl_;
};

ScrollElasticityHelperImpl::ScrollElasticityHelperImpl(
LayerTreeHostImpl* layer_tree)
: layer_tree_host_impl_(layer_tree) {
}
: host_impl_(layer_tree) {}

ScrollElasticityHelperImpl::~ScrollElasticityHelperImpl() {
}

bool ScrollElasticityHelperImpl::IsUserScrollable() const {
const auto* scroll_node = layer_tree_host_impl_->OuterViewportScrollNode();
const auto* scroll_node = host_impl_->OuterViewportScrollNode();
if (!scroll_node)
return false;
return scroll_node->user_scrollable_horizontal ||
scroll_node->user_scrollable_vertical;
}

gfx::Vector2dF ScrollElasticityHelperImpl::StretchAmount() const {
return layer_tree_host_impl_->active_tree()->elastic_overscroll()->Current(
true);
return host_impl_->active_tree()->elastic_overscroll()->Current(true);
}

void ScrollElasticityHelperImpl::SetStretchAmount(
const gfx::Vector2dF& stretch_amount) {
if (stretch_amount == StretchAmount())
return;

layer_tree_host_impl_->active_tree()->elastic_overscroll()->SetCurrent(
stretch_amount);
layer_tree_host_impl_->active_tree()->set_needs_update_draw_properties();
layer_tree_host_impl_->SetNeedsCommit();
layer_tree_host_impl_->SetNeedsRedraw();
layer_tree_host_impl_->SetFullViewportDamage();
host_impl_->active_tree()->elastic_overscroll()->SetCurrent(stretch_amount);
host_impl_->active_tree()->set_needs_update_draw_properties();
host_impl_->SetNeedsCommit();
host_impl_->SetNeedsRedraw();
host_impl_->SetFullViewportDamage();
}

gfx::ScrollOffset ScrollElasticityHelperImpl::ScrollOffset() const {
return layer_tree_host_impl_->active_tree()->TotalScrollOffset();
return host_impl_->active_tree()->TotalScrollOffset();
}

gfx::ScrollOffset ScrollElasticityHelperImpl::MaxScrollOffset() const {
return layer_tree_host_impl_->active_tree()->TotalMaxScrollOffset();
return host_impl_->active_tree()->TotalMaxScrollOffset();
}

void ScrollElasticityHelperImpl::ScrollBy(const gfx::Vector2dF& delta) {
LayerImpl* root_scroll_layer =
layer_tree_host_impl_->OuterViewportScrollLayer()
? layer_tree_host_impl_->OuterViewportScrollLayer()
: layer_tree_host_impl_->InnerViewportScrollLayer();
LayerImpl* root_scroll_layer = host_impl_->OuterViewportScrollLayer()
? host_impl_->OuterViewportScrollLayer()
: host_impl_->InnerViewportScrollLayer();
if (root_scroll_layer)
root_scroll_layer->ScrollBy(delta);
}

void ScrollElasticityHelperImpl::RequestOneBeginFrame() {
layer_tree_host_impl_->SetNeedsOneBeginImplFrame();
host_impl_->SetNeedsOneBeginImplFrame();
}

// static
ScrollElasticityHelper* ScrollElasticityHelper::CreateForLayerTreeHostImpl(
LayerTreeHostImpl* layer_tree_host_impl) {
return new ScrollElasticityHelperImpl(layer_tree_host_impl);
LayerTreeHostImpl* host_impl) {
return new ScrollElasticityHelperImpl(host_impl);
}

} // namespace cc
2 changes: 1 addition & 1 deletion cc/input/scroll_elasticity_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LayerTreeHostImpl;
class CC_EXPORT ScrollElasticityHelper {
public:
static ScrollElasticityHelper* CreateForLayerTreeHostImpl(
LayerTreeHostImpl* layer_tree_host_impl);
LayerTreeHostImpl* host_impl);

virtual ~ScrollElasticityHelper() {}

Expand Down
10 changes: 4 additions & 6 deletions cc/trees/latency_info_swap_promise_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ namespace cc {
LatencyInfoSwapPromiseMonitor::LatencyInfoSwapPromiseMonitor(
ui::LatencyInfo* latency,
SwapPromiseManager* swap_promise_manager,
LayerTreeHostImpl* layer_tree_host_impl)
: SwapPromiseMonitor(swap_promise_manager, layer_tree_host_impl),
latency_(latency) {}
LayerTreeHostImpl* host_impl)
: SwapPromiseMonitor(swap_promise_manager, host_impl), latency_(latency) {}

LatencyInfoSwapPromiseMonitor::~LatencyInfoSwapPromiseMonitor() {
}
Expand All @@ -66,8 +65,7 @@ void LatencyInfoSwapPromiseMonitor::OnSetNeedsRedrawOnImpl() {
// measurement of the time to the next SwapBuffers(). The swap
// promise is pinned so that it is not interrupted by new incoming
// activations (which would otherwise break the swap promise).
layer_tree_host_impl_->active_tree()->QueuePinnedSwapPromise(
std::move(swap_promise));
host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise));
}
}

Expand Down Expand Up @@ -98,7 +96,7 @@ void LatencyInfoSwapPromiseMonitor::OnForwardScrollUpdateToMainThreadOnImpl() {
new_sequence_number, "ScrollUpdate");
std::unique_ptr<SwapPromise> swap_promise(
new LatencyInfoSwapPromise(new_latency));
layer_tree_host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(
host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(
std::move(swap_promise));
}
}
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/latency_info_swap_promise_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CC_EXPORT LatencyInfoSwapPromiseMonitor : public SwapPromiseMonitor {
public:
LatencyInfoSwapPromiseMonitor(ui::LatencyInfo* latency,
SwapPromiseManager* swap_promise_manager,
LayerTreeHostImpl* layer_tree_host_impl);
LayerTreeHostImpl* host_impl);
~LatencyInfoSwapPromiseMonitor() override;

void OnSetNeedsCommitOnMain() override;
Expand Down
Loading

0 comments on commit aa326e4

Please sign in to comment.