Skip to content

Commit

Permalink
Rename legacy 'Layout' methods across Blink and cc.
Browse files Browse the repository at this point in the history
- rename WebWidget::layout to updateAllLifecyclePhases
  as the core Blink-exposed method for running all that's
  needed to generate a frame.

- rename {LayerTreeHostClient, CompositorClient}::layout
  to UpdateLayerTreeHost to match above from cc perspective.

- rename LayerTreeHost::layout to RequestMainFrameUpdate
  for consistency with the host side of things.

And a TODO to further revise the Android JNI plumbing
following this naming, for example, onCompositorLayout
should become onCompositorUpdateLayerTreeHost.

BUG=490921,476158
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1411303005

Cr-Commit-Position: refs/heads/master@{#357530}
  • Loading branch information
shaper authored and Commit bot committed Nov 3, 2015
1 parent e4a61c5 commit 7265db0
Show file tree
Hide file tree
Showing 56 changed files with 289 additions and 265 deletions.
2 changes: 1 addition & 1 deletion blimp/client/compositor/blimp_compositor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void BlimpCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) {}

void BlimpCompositor::BeginMainFrameNotExpectedSoon() {}

void BlimpCompositor::Layout() {}
void BlimpCompositor::UpdateLayerTreeHost() {}

void BlimpCompositor::ApplyViewportDeltas(
const gfx::Vector2dF& inner_delta,
Expand Down
2 changes: 1 addition & 1 deletion blimp/client/compositor/blimp_compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BlimpCompositor : public cc::LayerTreeHostClient {
void DidBeginMainFrame() override;
void BeginMainFrame(const cc::BeginFrameArgs& args) override;
void BeginMainFrameNotExpectedSoon() override;
void Layout() override;
void UpdateLayerTreeHost() override;
void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
const gfx::Vector2dF& elastic_overscroll_delta,
Expand Down
2 changes: 1 addition & 1 deletion cc/test/fake_layer_tree_host_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FakeLayerTreeHostClient : public LayerTreeHostClient,
void DidBeginMainFrame() override {}
void BeginMainFrame(const BeginFrameArgs& args) override {}
void BeginMainFrameNotExpectedSoon() override {}
void Layout() override {}
void UpdateLayerTreeHost() override {}
void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
const gfx::Vector2dF& elastic_overscroll_delta,
Expand Down
4 changes: 3 additions & 1 deletion cc/test/layer_tree_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient,
test_hooks_->BeginMainFrame(args);
}

void Layout() override { test_hooks_->Layout(); }
void UpdateLayerTreeHost() override {
test_hooks_->UpdateLayerTreeHost();
}

void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
Expand Down
2 changes: 1 addition & 1 deletion cc/test/layer_tree_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TestHooks : public AnimationDelegate {
virtual void BeginMainFrame(const BeginFrameArgs& args) {}
virtual void WillBeginMainFrame() {}
virtual void DidBeginMainFrame() {}
virtual void Layout() {}
virtual void UpdateLayerTreeHost() {}
virtual void DidInitializeOutputSurface() {}
virtual void DidFailToInitializeOutputSurface() {}
virtual void DidAddAnimation() {}
Expand Down
6 changes: 3 additions & 3 deletions cc/trees/layer_tree_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ void LayerTreeHost::DidStopFlinging() {
proxy_->MainThreadHasStoppedFlinging();
}

void LayerTreeHost::Layout() {
client_->Layout();
void LayerTreeHost::RequestMainFrameUpdate() {
client_->UpdateLayerTreeHost();
}

// This function commits the LayerTreeHost to an impl tree. When modifying
Expand Down Expand Up @@ -681,7 +681,7 @@ void LayerTreeHost::LayoutAndUpdateLayers() {
return;
}

Layout();
RequestMainFrameUpdate();
UpdateLayers();
}

Expand Down
2 changes: 1 addition & 1 deletion cc/trees/layer_tree_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
void BeginMainFrameNotExpectedSoon();
void AnimateLayers(base::TimeTicks monotonic_frame_begin_time);
void DidStopFlinging();
void Layout();
void RequestMainFrameUpdate();
void FinishCommitOnImplThread(LayerTreeHostImpl* host_impl);
void WillCommit();
void CommitComplete();
Expand Down
13 changes: 12 additions & 1 deletion cc/trees/layer_tree_host_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,18 @@ class LayerTreeHostClient {
virtual void BeginMainFrame(const BeginFrameArgs& args) = 0;
virtual void BeginMainFrameNotExpectedSoon() = 0;
virtual void DidBeginMainFrame() = 0;
virtual void Layout() = 0;
// A LayerTreeHost is bound to a LayerTreeHostClient. Visual frame-based
// updates to the state of the LayerTreeHost are expected to happen only in
// calls to LayerTreeHostClient::UpdateLayerTreeHost, which should
// mutate/invalidate the layer tree or other page parameters as appropriate.
//
// An example of a LayerTreeHostClient is (via additional indirections) Blink,
// which inside of LayerTreeHostClient::UpdateLayerTreeHost will update
// (Blink's notions of) style, layout, paint invalidation and compositing
// state. (The "compositing state" will result in a mutated layer tree on the
// LayerTreeHost via additional interface indirections which lead back to
// mutations on the LayerTreeHost.)
virtual void UpdateLayerTreeHost() = 0;
virtual void ApplyViewportDeltas(
const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/layer_tree_host_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class ScrollingLayerTreePerfTest : public LayerTreeHostPerfTestJsonReader {
ASSERT_TRUE(scrollable_.get());
}

void Layout() override {
void UpdateLayerTreeHost() override {
if (TestEnded())
return;
static const gfx::Vector2d delta = gfx::Vector2d(0, 10);
Expand Down
8 changes: 5 additions & 3 deletions cc/trees/layer_tree_host_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class LayerTreeHostTestSetNeedsCommitInsideLayout : public LayerTreeHostTest {
protected:
void BeginTest() override { PostSetNeedsCommitToMainThread(); }

void Layout() override {
void UpdateLayerTreeHost() override {
// This shouldn't cause a second commit to happen.
layer_tree_host()->SetNeedsCommit();
}
Expand Down Expand Up @@ -141,7 +141,9 @@ class LayerTreeHostTestFrameOrdering : public LayerTreeHostTest {

void BeginTest() override { PostSetNeedsCommitToMainThread(); }

void Layout() override { EXPECT_TRUE(CheckStep(MAIN_LAYOUT, &main_)); }
void UpdateLayerTreeHost() override {
EXPECT_TRUE(CheckStep(MAIN_LAYOUT, &main_));
}

void DidCommit() override {
EXPECT_TRUE(CheckStep(MAIN_COMMIT_COMPLETE, &main_));
Expand Down Expand Up @@ -188,7 +190,7 @@ class LayerTreeHostTestSetNeedsUpdateInsideLayout : public LayerTreeHostTest {
protected:
void BeginTest() override { PostSetNeedsCommitToMainThread(); }

void Layout() override {
void UpdateLayerTreeHost() override {
// This shouldn't cause a second commit to happen.
layer_tree_host()->SetNeedsUpdateLayers();
}
Expand Down
4 changes: 3 additions & 1 deletion cc/trees/layer_tree_host_unittest_animation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ class LayerTreeHostAnimationTestForceRedraw
layer_tree_host()->SetNeedsAnimate();
}

void Layout() override { layer_tree_host()->SetNextCommitForcesRedraw(); }
void UpdateLayerTreeHost() override {
layer_tree_host()->SetNextCommitForcesRedraw();
}

void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
if (++num_draw_layers_ == 2)
Expand Down
4 changes: 2 additions & 2 deletions cc/trees/layer_tree_host_unittest_animation_timelines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ class DISABLED_LayerTreeHostTimelinesTestSetPotentiallyAnimatingOnLacDestruction

void DidCommit() override { PostSetNeedsCommitToMainThread(); }

void Layout() override {
void UpdateLayerTreeHost() override {
if (layer_tree_host()->source_frame_number() == 2) {
// Destroy player.
timeline_->DetachPlayer(player_.get());
Expand Down Expand Up @@ -1075,7 +1075,7 @@ class LayerTreeHostTimelinesTestRebuildPropertyTreesOnAnimationSetNeedsCommit
PostSetNeedsCommitToMainThread();
}

void Layout() override {
void UpdateLayerTreeHost() override {
if (layer_tree_host()->source_frame_number() == 1) {
EXPECT_FALSE(layer_tree_host()->property_trees()->needs_rebuild);
AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 5, 5);
Expand Down
6 changes: 3 additions & 3 deletions cc/trees/layer_tree_host_unittest_scroll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest {
PostSetNeedsCommitToMainThread();
}

void Layout() override {
void UpdateLayerTreeHost() override {
Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
if (!layer_tree_host()->source_frame_number()) {
EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
Expand Down Expand Up @@ -534,7 +534,7 @@ class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
num_scrolls_++;
}

void Layout() override {
void UpdateLayerTreeHost() override {
EXPECT_VECTOR_EQ(gfx::Vector2d(),
expected_no_scroll_layer_->scroll_offset());

Expand Down Expand Up @@ -764,7 +764,7 @@ class LayerTreeHostScrollTestSimple : public LayerTreeHostScrollTest {
PostSetNeedsCommitToMainThread();
}

void Layout() override {
void UpdateLayerTreeHost() override {
Layer* scroll_layer = layer_tree_host()->outer_viewport_scroll_layer();
if (!layer_tree_host()->source_frame_number()) {
EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/single_thread_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ void SingleThreadProxy::DoBeginMainFrame(
layer_tree_host_->WillBeginMainFrame();
layer_tree_host_->BeginMainFrame(begin_frame_args);
layer_tree_host_->AnimateLayers(begin_frame_args.frame_time);
layer_tree_host_->Layout();
layer_tree_host_->RequestMainFrameUpdate();

// New commits requested inside UpdateLayers should be respected.
commit_requested_ = false;
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/thread_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ void ThreadProxy::BeginMainFrame(
if (begin_main_frame_state->evicted_ui_resources)
layer_tree_host()->RecreateUIResources();

layer_tree_host()->Layout();
layer_tree_host()->RequestMainFrameUpdate();
TRACE_EVENT_SYNTHETIC_DELAY_END("cc.BeginMainFrame");

bool can_cancel_this_commit =
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/android/compositor/compositor_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ base::android::ScopedJavaLocalRef<jobject> CompositorView::GetResourceManager(
return compositor_->GetResourceManager().GetJavaObject();
}

void CompositorView::Layout() {
void CompositorView::UpdateLayerTreeHost() {
JNIEnv* env = base::android::AttachCurrentThread();
// TODO(wkorman): Rename JNI interface to onCompositorUpdateLayerTreeHost.
Java_CompositorView_onCompositorLayout(env, obj_.obj());
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/android/compositor/compositor_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CompositorView : public content::CompositorClient,
void SetSceneLayer(JNIEnv* env, jobject object, jobject jscene_layer);

// CompositorClient implementation:
void Layout() override;
void UpdateLayerTreeHost() override;
void OnSwapBuffersCompleted(int pending_swap_buffers) override;
ui::UIResourceProvider* GetUIResourceProvider();

Expand Down
4 changes: 2 additions & 2 deletions components/html_viewer/web_layer_tree_view_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ void WebLayerTreeViewImpl::BeginMainFrame(const cc::BeginFrameArgs& args) {
layer_tree_host_->SetNeedsAnimate();
}

void WebLayerTreeViewImpl::Layout() {
widget_->layout();
void WebLayerTreeViewImpl::UpdateLayerTreeHost() {
widget_->updateAllLifecyclePhases();
}

void WebLayerTreeViewImpl::ApplyViewportDeltas(
Expand Down
2 changes: 1 addition & 1 deletion components/html_viewer/web_layer_tree_view_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class WebLayerTreeViewImpl : public blink::WebLayerTreeView,
void DidBeginMainFrame() override;
void BeginMainFrame(const cc::BeginFrameArgs& args) override;
void BeginMainFrameNotExpectedSoon() override;
void Layout() override;
void UpdateLayerTreeHost() override;
void ApplyViewportDeltas(const gfx::Vector2dF& inner_delta,
const gfx::Vector2dF& outer_delta,
const gfx::Vector2dF& elastic_overscroll_delta,
Expand Down
4 changes: 3 additions & 1 deletion components/plugins/renderer/webview_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ v8::Local<v8::Object> WebViewPlugin::v8ScriptableObject(v8::Isolate* isolate) {
return delegate_->GetV8ScriptableObject(isolate);
}

// TODO(wkorman): Look into renaming this to something more in line with
// either the Blink lifecycle or Compositor layer tree host nomenclature.
void WebViewPlugin::layoutIfNeeded() {
web_view_->layout();
web_view_->updateAllLifecyclePhases();
}

void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
Expand Down
22 changes: 11 additions & 11 deletions components/test_runner/event_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ void EventSender::DoDragDrop(const WebDragData& drag_data,

void EventSender::MouseDown(int button_number, int modifiers) {
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

DCHECK_NE(-1, button_number);

Expand All @@ -1255,7 +1255,7 @@ void EventSender::MouseDown(int button_number, int modifiers) {

void EventSender::MouseUp(int button_number, int modifiers) {
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

DCHECK_NE(-1, button_number);

Expand Down Expand Up @@ -1464,7 +1464,7 @@ void EventSender::KeyDown(const std::string& code_str,
// EventSender.m forces a layout here, with at least one
// test (fast/forms/focus-control-to-page.html) relying on this.
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

// In the browser, if a keyboard event corresponds to an editor command,
// the command will be dispatched to the renderer just before dispatching
Expand Down Expand Up @@ -1513,7 +1513,7 @@ void EventSender::ClearKillRing() {}

std::vector<std::string> EventSender::ContextClick() {
if (force_layout_on_events_) {
view_->layout();
view_->updateAllLifecyclePhases();
}

UpdateClickCountForButton(WebMouseEvent::ButtonRight);
Expand Down Expand Up @@ -1692,7 +1692,7 @@ void EventSender::GestureFlingCancel() {
event.timeStampSeconds = GetCurrentEventTimeSec();

if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

HandleInputEventOnViewOrPopup(event);
}
Expand Down Expand Up @@ -1728,7 +1728,7 @@ void EventSender::GestureFlingStart(float x,
event.timeStampSeconds = GetCurrentEventTimeSec();

if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

HandleInputEventOnViewOrPopup(event);
}
Expand Down Expand Up @@ -1904,7 +1904,7 @@ void EventSender::ContinuousMouseScrollBy(gin::Arguments* args) {

void EventSender::MouseMoveTo(gin::Arguments* args) {
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

double x;
double y;
Expand Down Expand Up @@ -1940,7 +1940,7 @@ void EventSender::MouseMoveTo(gin::Arguments* args) {

void EventSender::MouseLeave() {
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

WebMouseEvent event;
InitMouseEvent(WebInputEvent::MouseLeave,
Expand Down Expand Up @@ -2021,7 +2021,7 @@ void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type,
DCHECK_GT(static_cast<unsigned>(WebTouchEvent::touchesLengthCap),
touch_points_.size());
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

WebTouchEvent touch_event;
touch_event.type = type;
Expand Down Expand Up @@ -2291,7 +2291,7 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
event.timeStampSeconds = GetCurrentEventTimeSec();

if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

bool result = HandleInputEventOnViewOrPopup(event);

Expand Down Expand Up @@ -2331,7 +2331,7 @@ void EventSender::InitMouseWheelEvent(gin::Arguments* args,
// determined before we send events (as well as all the other methods
// that send an event do).
if (force_layout_on_events_)
view_->layout();
view_->updateAllLifecyclePhases();

double horizontal;
if (!args->GetNext(&horizontal)) {
Expand Down
6 changes: 3 additions & 3 deletions components/test_runner/web_test_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ void WebTestProxyBase::CopyImageAtAndCapturePixels(

void WebTestProxyBase::CapturePixelsForPrinting(
const base::Callback<void(const SkBitmap&)>& callback) {
web_widget_->layout();
web_widget_->updateAllLifecyclePhases();

blink::WebSize page_size_in_pixels = web_widget_->size();
blink::WebFrame* web_frame = GetWebView()->mainFrame();
Expand Down Expand Up @@ -762,10 +762,10 @@ void WebTestProxyBase::AnimateNow() {
base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks();
animate_scheduled_ = false;
web_widget_->beginFrame(animate_time.InSecondsF());
web_widget_->layout();
web_widget_->updateAllLifecyclePhases();
if (blink::WebPagePopup* popup = web_widget_->pagePopup()) {
popup->beginFrame(animate_time.InSecondsF());
popup->layout();
popup->updateAllLifecyclePhases();
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion content/browser/android/content_view_render_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ void ContentViewRenderView::SetNeedsComposite(JNIEnv* env, jobject obj) {
compositor_->SetNeedsComposite();
}

void ContentViewRenderView::Layout() {
void ContentViewRenderView::UpdateLayerTreeHost() {
JNIEnv* env = base::android::AttachCurrentThread();
// TODO(wkorman): Rename Layout to UpdateLayerTreeHost in all Android
// Compositor related classes.
Java_ContentViewRenderView_onCompositorLayout(env, java_obj_.obj());
}

Expand Down
Loading

0 comments on commit 7265db0

Please sign in to comment.