!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableDelegatedRenderer)),
locks_on_frame_count_(0),
- root_window_destroyed_(false) {
+ observing_root_window_(false) {
if (!using_delegated_renderer_) {
texture_layer_ = cc::TextureLayer::Create(NULL);
layer_ = texture_layer_;
host_->WasShown();
- if (content_view_core_ && !using_synchronous_compositor_)
+ if (content_view_core_ && !using_synchronous_compositor_) {
content_view_core_->GetWindowAndroid()->AddObserver(this);
+ observing_root_window_ = true;
+ }
}
void RenderWidgetHostViewAndroid::WasHidden() {
// utilization.
host_->WasHidden();
- if (content_view_core_ && !using_synchronous_compositor_)
+ if (content_view_core_ && !using_synchronous_compositor_) {
content_view_core_->GetWindowAndroid()->RemoveObserver(this);
+ observing_root_window_ = false;
+ }
}
void RenderWidgetHostViewAndroid::WasResized() {
// Ignore the given size as only the Java code has the power to
// resize the view on Android.
default_size_ = size;
- WasResized();
}
void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
if (!content_view_core_)
return gfx::Rect(default_size_);
- gfx::Size size = content_view_core_->GetViewportSizeDip();
- gfx::Size offset = content_view_core_->GetViewportSizeOffsetDip();
- size.Enlarge(-offset.width(), -offset.height());
-
- return gfx::Rect(size);
+ return gfx::Rect(content_view_core_->GetViewSize());
}
gfx::Size RenderWidgetHostViewAndroid::GetPhysicalBackingSize() const {
void RenderWidgetHostViewAndroid::SelectionRootBoundsChanged(
const gfx::Rect& bounds) {
- if (content_view_core_) {
- content_view_core_->OnSelectionRootBoundsChanged(bounds);
- }
}
void RenderWidgetHostViewAndroid::ScrollOffsetChanged() {
void RenderWidgetHostViewAndroid::SetContentViewCore(
ContentViewCoreImpl* content_view_core) {
RemoveLayers();
- // TODO: crbug.com/324341
- // WindowAndroid and Compositor should outlive all WebContents.
- // Allowing this here at runtime is a bandaid.
- DCHECK(!root_window_destroyed_);
- if (content_view_core_ && !root_window_destroyed_ &&
- !using_synchronous_compositor_) {
+ if (observing_root_window_ && content_view_core_) {
content_view_core_->GetWindowAndroid()->RemoveObserver(this);
+ observing_root_window_ = false;
}
- if (content_view_core != content_view_core_)
+ bool resize = false;
+ if (content_view_core != content_view_core_) {
ReleaseLocksOnSurface();
+ resize = true;
+ }
content_view_core_ = content_view_core;
}
AttachLayers();
- if (content_view_core_ && !root_window_destroyed_ &&
- !using_synchronous_compositor_) {
+ if (content_view_core_ && !using_synchronous_compositor_) {
content_view_core_->GetWindowAndroid()->AddObserver(this);
+ observing_root_window_ = true;
}
+
+ if (resize && content_view_core_)
+ WasResized();
}
void RenderWidgetHostViewAndroid::RunAckCallbacks() {
void RenderWidgetHostViewAndroid::OnDetachCompositor() {
DCHECK(content_view_core_);
DCHECK(!using_synchronous_compositor_);
- root_window_destroyed_ = true;
RunAckCallbacks();
}
+void RenderWidgetHostViewAndroid::OnWillDestroyWindow() {
+ // crbug.com/324341
+ // WindowAndroid and Compositor should outlive all WebContents.
+ NOTREACHED();
+ observing_root_window_ = false;
+}
+
void RenderWidgetHostViewAndroid::OnLostResources() {
ReleaseLocksOnSurface();
if (texture_layer_.get())