Update to Chromium revision 3a87aecc (#433059)

This commit is contained in:
Marshall Greenblatt
2016-11-23 15:54:29 -05:00
parent c6881fe145
commit 12aeeb13f7
126 changed files with 1643 additions and 1436 deletions

View File

@@ -11,6 +11,8 @@
#include "libcef/browser/osr/web_contents_view_osr.h"
#include "libcef/common/drag_data_impl.h"
#include "content/browser/renderer_host/render_widget_host_input_event_router.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/render_view_host.h"
CefBrowserPlatformDelegateOsr::CefBrowserPlatformDelegateOsr(
@@ -247,52 +249,119 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
CefRefPtr<CefDragData> drag_data,
const CefMouseEvent& event,
cef_drag_operations_mask_t allowed_ops) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
if (current_rvh_for_drag_)
DragTargetDragLeave();
const gfx::Point client_pt(event.x, event.y);
gfx::Point transformed_pt;
current_rwh_for_drag_ =
web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint(
web_contents->GetRenderViewHost()->GetWidget()->GetView(),
client_pt, &transformed_pt)->GetWeakPtr();
current_rvh_for_drag_ = web_contents->GetRenderViewHost();
drag_data_ = drag_data;
drag_allowed_ops_ = allowed_ops;
CefDragDataImpl* data_impl = static_cast<CefDragDataImpl*>(drag_data.get());
base::AutoLock lock_scope(data_impl->lock());
content::DropData* drop_data = data_impl->drop_data();
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
blink::WebDragOperationsMask ops =
static_cast<blink::WebDragOperationsMask>(allowed_ops);
int modifiers = TranslateModifiers(event.modifiers);
rvh->FilterDropData(drop_data);
rvh->DragTargetDragEnter(*drop_data, client_pt, screen_pt, ops, modifiers);
current_rwh_for_drag_->FilterDropData(drop_data);
// Give the delegate an opportunity to cancel the drag.
if (web_contents->GetDelegate() &&
!web_contents->GetDelegate()->CanDragEnter(
web_contents, *drop_data, ops)) {
drag_data_ = nullptr;
return;
}
current_rwh_for_drag_->DragTargetDragEnter(
*drop_data, transformed_pt, screen_pt, ops, modifiers);
}
void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
const CefMouseEvent& event,
cef_drag_operations_mask_t allowed_ops) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_data_)
return;
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
const gfx::Point client_pt(event.x, event.y);
gfx::Point transformed_pt;
content::RenderWidgetHostImpl* target_rwh =
web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint(
web_contents->GetRenderViewHost()->GetWidget()->GetView(),
client_pt, &transformed_pt);
if (target_rwh != current_rwh_for_drag_.get()) {
if (current_rwh_for_drag_)
current_rwh_for_drag_->DragTargetDragLeave();
DragTargetDragEnter(drag_data_, event, drag_allowed_ops_);
}
if (!drag_data_)
return;
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
blink::WebDragOperationsMask ops =
static_cast<blink::WebDragOperationsMask>(allowed_ops);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDragOver(client_pt, screen_pt, ops, modifiers);
target_rwh->DragTargetDragOver(transformed_pt, screen_pt, ops, modifiers);
}
void CefBrowserPlatformDelegateOsr::DragTargetDragLeave() {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (current_rvh_for_drag_ != browser_->web_contents()->GetRenderViewHost() ||
!drag_data_) {
return;
}
rvh->DragTargetDragLeave();
if (current_rwh_for_drag_) {
current_rwh_for_drag_->DragTargetDragLeave();
current_rwh_for_drag_.reset();
}
drag_data_ = nullptr;
}
void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_data_)
return;
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
gfx::Point client_pt(event.x, event.y);
gfx::Point transformed_pt;
content::RenderWidgetHostImpl* target_rwh =
web_contents->GetInputEventRouter()->GetRenderWidgetHostAtPoint(
web_contents->GetRenderViewHost()->GetWidget()->GetView(),
client_pt, &transformed_pt);
if (target_rwh != current_rwh_for_drag_.get()) {
if (current_rwh_for_drag_)
current_rwh_for_drag_->DragTargetDragLeave();
DragTargetDragEnter(drag_data_, event, drag_allowed_ops_);
}
if (!drag_data_)
return;
{
@@ -300,35 +369,85 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
static_cast<CefDragDataImpl*>(drag_data_.get());
base::AutoLock lock_scope(data_impl->lock());
content::DropData* drop_data = data_impl->drop_data();
const gfx::Point client_pt(event.x, event.y);
const gfx::Point& screen_pt = GetScreenPoint(client_pt);
int modifiers = TranslateModifiers(event.modifiers);
rvh->DragTargetDrop(*drop_data, client_pt, screen_pt, modifiers);
target_rwh->DragTargetDrop(*drop_data, transformed_pt, screen_pt,
modifiers);
}
drag_data_ = nullptr;
}
void CefBrowserPlatformDelegateOsr::StartDragging(
const content::DropData& drop_data,
blink::WebDragOperationsMask allowed_ops,
const gfx::ImageSkia& image,
const gfx::Vector2d& image_offset,
const content::DragEventSourceInfo& event_info,
content::RenderWidgetHostImpl* source_rwh) {
drag_start_rwh_ = source_rwh->GetWeakPtr();
bool handled = false;
CefRefPtr<CefRenderHandler> handler =
browser_->GetClient()->GetRenderHandler();
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_,
drag_data.get(),
static_cast<CefRenderHandler::DragOperationsMask>(allowed_ops),
event_info.event_location.x(),
event_info.event_location.y());
}
if (!handled)
DragSourceSystemDragEnded();
}
void CefBrowserPlatformDelegateOsr::UpdateDragCursor(
blink::WebDragOperation operation) {
CefRefPtr<CefRenderHandler> handler =
browser_->GetClient()->GetRenderHandler();
if (handler.get()) {
handler->UpdateDragCursor(
browser_, static_cast<CefRenderHandler::DragOperation>(operation));
}
}
void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(
int x, int y,
cef_drag_operations_mask_t op) {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_start_rwh_)
return;
content::WebContentsImpl* web_contents =
static_cast<content::WebContentsImpl*>(browser_->web_contents());
if (!web_contents)
return;
const gfx::Point& screen_pt = GetScreenPoint(gfx::Point(x, y));
blink::WebDragOperation drag_op = static_cast<blink::WebDragOperation>(op);
rvh->DragSourceEndedAt(x, y, screen_pt.x(), screen_pt.y(), drag_op);
web_contents->DragSourceEndedAt(x, y, screen_pt.x(), screen_pt.y(), drag_op,
drag_start_rwh_.get());
}
void CefBrowserPlatformDelegateOsr::DragSourceSystemDragEnded() {
content::RenderViewHost* rvh = browser_->web_contents()->GetRenderViewHost();
if (!rvh)
if (!drag_start_rwh_)
return;
rvh->DragSourceSystemDragEnded();
content::WebContents* web_contents = browser_->web_contents();
if (!web_contents)
return;
web_contents->SystemDragEnded(drag_start_rwh_.get());
drag_start_rwh_ = nullptr;
}
CefWindowHandle CefBrowserPlatformDelegateOsr::GetParentWindowHandle() const {