Check that the return value of CefClient::GetRenderHandler is non-NULL (issue #1504).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1995 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2015-01-26 00:57:01 +00:00
parent f38c620e28
commit d640978350
6 changed files with 73 additions and 45 deletions

View File

@ -1838,8 +1838,9 @@ void CefBrowserHostImpl::DragTargetDragEnter(CefRefPtr<CefDragData> drag_data,
int screenX, screenY;
if (!client_->GetRenderHandler()->GetScreenPoint(
this, event.x, event.y, screenX, screenY)) {
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (!handler.get() || !handler->GetScreenPoint(this, event.x, event.y,
screenX, screenY)) {
screenX = event.x;
screenY = event.y;
}
@ -1877,8 +1878,9 @@ void CefBrowserHostImpl::DragTargetDragOver(const CefMouseEvent& event,
int screenX, screenY;
if (!client_->GetRenderHandler()->GetScreenPoint(
this, event.x, event.y, screenX, screenY)) {
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (!handler.get() || !handler->GetScreenPoint(this, event.x, event.y,
screenX, screenY)) {
screenX = event.x;
screenY = event.y;
}
@ -1931,8 +1933,9 @@ void CefBrowserHostImpl::DragTargetDrop(const CefMouseEvent& event) {
int screenX, screenY;
if (!client_->GetRenderHandler()->GetScreenPoint(
this, event.x, event.y, screenX, screenY)) {
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (!handler.get() || !handler->GetScreenPoint(this, event.x, event.y,
screenX, screenY)) {
screenX = event.x;
screenY = event.y;
}
@ -1984,8 +1987,9 @@ void CefBrowserHostImpl::DragSourceEndedAt(
int screenX, screenY;
if (!client_->GetRenderHandler()->GetScreenPoint(
this, x, y, screenX, screenY)) {
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (!handler.get() || !handler->GetScreenPoint(this, x, y, screenX,
screenY)) {
screenX = x;
screenY = y;
}

View File

@ -419,10 +419,11 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent(
result.globalY = result.y;
if (IsWindowless()) {
GetClient()->GetRenderHandler()->GetScreenPoint(
GetBrowser(),
result.x, result.y,
result.globalX, result.globalY);
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (handler.get()) {
handler->GetScreenPoint(this, result.x, result.y, result.globalX,
result.globalY);
}
} else if (window_x11_) {
const gfx::Point& origin = window_x11_->bounds().origin();
result.globalX += origin.x();

View File

@ -911,10 +911,11 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent(
result.globalY = result.y;
if (IsWindowless()) {
GetClient()->GetRenderHandler()->GetScreenPoint(
GetBrowser(),
result.x, result.y,
result.globalX, result.globalY);
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (handler.get()) {
handler->GetScreenPoint(this, result.x, result.y, result.globalX,
result.globalY);
}
} else {
NSView* view = window_info_.parent_view;
if (view) {

View File

@ -1105,10 +1105,11 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent(
result.globalY = result.y;
if (IsWindowless()) {
GetClient()->GetRenderHandler()->GetScreenPoint(
GetBrowser(),
result.x, result.y,
result.globalX, result.globalY);
CefRefPtr<CefRenderHandler> handler = client_->GetRenderHandler();
if (handler.get()) {
handler->GetScreenPoint(this, result.x, result.y, result.globalX,
result.globalY);
}
} else {
POINT globalPoint = { result.x, result.y };
ClientToScreen(GetWindowHandle(), &globalPoint);

View File

@ -551,8 +551,10 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() const {
return gfx::Rect();
CefRect rc;
browser_impl_->GetClient()->GetRenderHandler()->GetViewRect(
browser_impl_.get(), rc);
CefRefPtr<CefRenderHandler> handler =
browser_impl_->GetClient()->GetRenderHandler();
if (handler.get())
handler->GetViewRect(browser_impl_.get(), rc);
return gfx::Rect(rc.x, rc.y, rc.width, rc.height);
}
@ -652,14 +654,17 @@ void CefRenderWidgetHostViewOSR::InitAsPopup(
}
parent_host_view_->set_popup_host_view(this);
browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow(
browser_impl_.get(), true);
CefRefPtr<CefRenderHandler> handler =
browser_impl_->GetClient()->GetRenderHandler();
if (handler.get())
handler->OnPopupShow(browser_impl_.get(), true);
popup_position_ = pos;
CefRect widget_pos(pos.x(), pos.y(), pos.width(), pos.height());
browser_impl_->GetClient()->GetRenderHandler()->OnPopupSize(
browser_impl_.get(), widget_pos);
if (handler.get())
handler->OnPopupSize(browser_impl_.get(), widget_pos);
ResizeRootLayer();
WasShown();
@ -708,6 +713,11 @@ void CefRenderWidgetHostViewOSR::UpdateCursor(
if (!browser_impl_.get())
return;
CefRefPtr<CefRenderHandler> handler =
browser_impl_->GetClient()->GetRenderHandler();
if (!handler.get())
return;
content::WebCursor::CursorInfo cursor_info;
cursor.GetCursorInfo(&cursor_info);
@ -734,14 +744,14 @@ void CefRenderWidgetHostViewOSR::UpdateCursor(
platform_cursor = browser_impl_->GetPlatformCursor(cursor_info.type);
}
browser_impl_->GetClient()->GetRenderHandler()->OnCursorChange(
browser_impl_.get(), platform_cursor, cursor_type, custom_cursor_info);
handler->OnCursorChange(browser_impl_.get(), platform_cursor, cursor_type,
custom_cursor_info);
#elif defined(OS_MACOSX)
// |web_cursor| owns the resulting |native_cursor|.
content::WebCursor web_cursor = cursor;
CefCursorHandle native_cursor = web_cursor.GetNativeCursor();
browser_impl_->GetClient()->GetRenderHandler()->OnCursorChange(
browser_impl_.get(), native_cursor, cursor_type, custom_cursor_info);
handler->OnCursorChange(browser_impl_.get(), native_cursor, cursor_type,
custom_cursor_info);
#else
// TODO(port): Implement this method to work on other platforms as part of
// off-screen rendering support.
@ -876,11 +886,12 @@ void CefRenderWidgetHostViewOSR::GetScreenInfo(blink::WebScreenInfo* results) {
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (!handler->GetScreenInfo(browser_impl_.get(), screen_info) ||
if (handler.get() &&
(!handler->GetScreenInfo(browser_impl_.get(), screen_info) ||
screen_info.rect.width == 0 ||
screen_info.rect.height == 0 ||
screen_info.available_rect.width == 0 ||
screen_info.available_rect.height == 0) {
screen_info.available_rect.height == 0)) {
// If a screen rectangle was not provided, try using the view rectangle
// instead. Otherwise, popup views may be drawn incorrectly, or not at all.
CefRect screenRect;
@ -905,10 +916,10 @@ gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
return gfx::Rect();
CefRect rc;
if (browser_impl_->GetClient()->GetRenderHandler()->GetRootScreenRect(
browser_impl_.get(), rc)) {
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (handler.get() && handler->GetRootScreenRect(browser_impl_.get(), rc))
return gfx::Rect(rc.x, rc.y, rc.width, rc.height);
}
return gfx::Rect();
}
@ -1186,6 +1197,11 @@ void CefRenderWidgetHostViewOSR::OnPaint(
void* bitmap_pixels) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnPaint");
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (!handler.get())
return;
// Don't execute WasResized while the OnPaint callback is pending.
HoldResize();
@ -1196,7 +1212,7 @@ void CefRenderWidgetHostViewOSR::OnPaint(
rcList.push_back(CefRect(rect_in_bitmap.x(), rect_in_bitmap.y(),
rect_in_bitmap.width(), rect_in_bitmap.height()));
browser_impl_->GetClient()->GetRenderHandler()->OnPaint(
handler->OnPaint(
browser_impl_.get(),
IsPopupWidget() ? PET_POPUP : PET_VIEW,
rcList,
@ -1241,8 +1257,10 @@ void CefRenderWidgetHostViewOSR::SetDeviceScaleFactor() {
if (browser_impl_.get()) {
CefScreenInfo screen_info(
kDefaultScaleFactor, 0, 0, false, CefRect(), CefRect());
if (browser_impl_->GetClient()->GetRenderHandler()->GetScreenInfo(
browser_impl_.get(), screen_info)) {
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (handler.get() && handler->GetScreenInfo(browser_impl_.get(),
screen_info)) {
scale_factor_ = screen_info.device_scale_factor;
return;
}
@ -1319,8 +1337,10 @@ void CefRenderWidgetHostViewOSR::CancelPopupWidget() {
WasHidden();
if (browser_impl_.get()) {
browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow(
browser_impl_.get(), false);
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
if (handler.get())
handler->OnPopupShow(browser_impl_.get(), false);
browser_impl_ = NULL;
}
@ -1340,7 +1360,8 @@ void CefRenderWidgetHostViewOSR::OnScrollOffsetChanged() {
if (browser_impl_.get()) {
CefRefPtr<CefRenderHandler> handler =
browser_impl_->client()->GetRenderHandler();
handler->OnScrollOffsetChanged(browser_impl_.get());
if (handler.get())
handler->OnScrollOffsetChanged(browser_impl_.get());
}
is_scroll_offset_changed_pending_ = false;
}

View File

@ -131,13 +131,13 @@ void CefWebContentsViewOSR::StartDragging(
browser = view->browser_impl();
if (browser.get())
handler = browser->GetClient()->GetRenderHandler();
DCHECK(handler.get());
if (handler.get()) {
CefRefPtr<CefDragDataImpl> drag_data(new CefDragDataImpl(drop_data));
drag_data->SetReadOnly(true);
base::MessageLoop::ScopedNestableTaskAllower allow(
base::MessageLoop::current());
handled = handler->StartDragging(browser->GetBrowser(),
handled = handler->StartDragging(
browser.get(),
drag_data.get(),
static_cast<CefRenderHandler::DragOperationsMask>(allowed_ops),
event_info.event_location.x(),
@ -157,9 +157,9 @@ void CefWebContentsViewOSR::UpdateDragCursor(
browser = view->browser_impl();
if (browser.get())
handler = browser->GetClient()->GetRenderHandler();
DCHECK(handler.get());
if (handler.get()) {
handler->UpdateDragCursor(browser->GetBrowser(),
handler->UpdateDragCursor(
browser.get(),
static_cast<CefRenderHandler::DragOperation>(operation));
}
}