mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Remove the legacy off-screen rendering implementation. A new implementation is required (issue #1257).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1678 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -1,171 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/backing_store_osr.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "content/browser/renderer_host/dip_util.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/rect_conversions.h"
|
||||
#include "ui/gfx/size_conversions.h"
|
||||
#include "ui/gfx/vector2d_conversions.h"
|
||||
#include "ui/surface/transport_dib.h"
|
||||
|
||||
// Assume that somewhere along the line, someone will do width * height * 4
|
||||
// with signed numbers. If the maximum value is 2**31, then 2**31 / 4 =
|
||||
// 2**29 and floor(sqrt(2**29)) = 23170.
|
||||
|
||||
// Max height and width for layers
|
||||
static const int kMaxVideoLayerSize = 23170;
|
||||
|
||||
BackingStoreOSR::BackingStoreOSR(content::RenderWidgetHost* widget,
|
||||
const gfx::Size& size,
|
||||
float scale_factor)
|
||||
: content::BackingStore(widget, size),
|
||||
device_scale_factor_(scale_factor) {
|
||||
gfx::Size pixel_size = gfx::ToFlooredSize(
|
||||
gfx::ScaleSize(size, device_scale_factor_));
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(pixel_size.width(),
|
||||
pixel_size.height());
|
||||
device_.reset(SkBitmapDevice::Create(info));
|
||||
canvas_.reset(new SkCanvas(device_.get()));
|
||||
|
||||
canvas_->drawColor(SK_ColorWHITE);
|
||||
}
|
||||
|
||||
void BackingStoreOSR::ScaleFactorChanged(float scale_factor) {
|
||||
if (scale_factor == device_scale_factor_)
|
||||
return;
|
||||
|
||||
gfx::Size old_pixel_size = gfx::ToFlooredSize(
|
||||
gfx::ScaleSize(size(), device_scale_factor_));
|
||||
device_scale_factor_ = scale_factor;
|
||||
|
||||
gfx::Size pixel_size = gfx::ToFlooredSize(
|
||||
gfx::ScaleSize(size(), device_scale_factor_));
|
||||
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(pixel_size.width(),
|
||||
pixel_size.height());
|
||||
scoped_ptr<SkBaseDevice> new_device(SkBitmapDevice::Create(info));
|
||||
|
||||
scoped_ptr<SkCanvas> new_canvas(new SkCanvas(new_device.get()));
|
||||
|
||||
// Copy old contents; a low-res flash is better than a black flash.
|
||||
SkPaint copy_paint;
|
||||
copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
SkIRect src_rect = SkIRect::MakeWH(old_pixel_size.width(),
|
||||
old_pixel_size.height());
|
||||
SkRect dst_rect = SkRect::MakeWH(pixel_size.width(), pixel_size.height());
|
||||
new_canvas.get()->drawBitmapRect(device_->accessBitmap(false), &src_rect,
|
||||
dst_rect, ©_paint);
|
||||
|
||||
canvas_.swap(new_canvas);
|
||||
device_.swap(new_device);
|
||||
}
|
||||
|
||||
size_t BackingStoreOSR::MemorySize() {
|
||||
// NOTE: The computation may be different when the canvas is a subrectangle of
|
||||
// a larger bitmap.
|
||||
return gfx::ToFlooredSize(
|
||||
gfx::ScaleSize(size(), device_scale_factor_)).GetArea() * 4;
|
||||
}
|
||||
|
||||
void BackingStoreOSR::PaintToBackingStore(
|
||||
content::RenderProcessHost* process,
|
||||
TransportDIB::Id bitmap,
|
||||
const gfx::Rect& bitmap_rect,
|
||||
const std::vector<gfx::Rect>& copy_rects,
|
||||
float scale_factor,
|
||||
const base::Closure& completion_callback,
|
||||
bool* scheduled_completion_callback) {
|
||||
*scheduled_completion_callback = false;
|
||||
if (bitmap_rect.IsEmpty())
|
||||
return;
|
||||
|
||||
gfx::Rect pixel_bitmap_rect = gfx::ToEnclosedRect(
|
||||
gfx::ScaleRect(bitmap_rect, scale_factor));
|
||||
|
||||
const int width = pixel_bitmap_rect.width();
|
||||
const int height = pixel_bitmap_rect.height();
|
||||
|
||||
if (width <= 0 || width > kMaxVideoLayerSize ||
|
||||
height <= 0 || height > kMaxVideoLayerSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
TransportDIB* dib = process->GetTransportDIB(bitmap);
|
||||
if (!dib)
|
||||
return;
|
||||
|
||||
SkBitmap src_bitmap;
|
||||
src_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
|
||||
src_bitmap.setPixels(dib->memory());
|
||||
|
||||
SkPaint copy_paint;
|
||||
copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
|
||||
for (size_t i = 0; i < copy_rects.size(); i++) {
|
||||
const gfx::Rect pixel_copy_rect = gfx::ToEnclosingRect(
|
||||
gfx::ScaleRect(copy_rects[i], scale_factor));
|
||||
SkIRect src_rect =
|
||||
SkIRect::MakeXYWH(pixel_copy_rect.x() - pixel_bitmap_rect.x(),
|
||||
pixel_copy_rect.y() - pixel_bitmap_rect.y(),
|
||||
pixel_copy_rect.width(),
|
||||
pixel_copy_rect.height());
|
||||
|
||||
const gfx::Rect pixel_copy_dst_rect = gfx::ToEnclosingRect(
|
||||
gfx::ScaleRect(copy_rects[i], device_scale_factor_));
|
||||
SkRect paint_rect = SkRect::MakeXYWH(pixel_copy_dst_rect.x(),
|
||||
pixel_copy_dst_rect.y(),
|
||||
pixel_copy_dst_rect.width(),
|
||||
pixel_copy_dst_rect.height());
|
||||
canvas_->drawBitmapRect(src_bitmap, &src_rect, paint_rect, ©_paint);
|
||||
}
|
||||
src_bitmap.setPixels(0);
|
||||
}
|
||||
|
||||
bool BackingStoreOSR::CopyFromBackingStore(const gfx::Rect& rect,
|
||||
skia::PlatformBitmap* output) {
|
||||
const int width =
|
||||
std::min(size().width(), rect.width()) * device_scale_factor_;
|
||||
const int height =
|
||||
std::min(size().height(), rect.height()) * device_scale_factor_;
|
||||
if (!output->Allocate(width, height, true))
|
||||
return false;
|
||||
|
||||
SkPaint copy_paint;
|
||||
copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
|
||||
SkCanvas canvas(output->GetBitmap());
|
||||
canvas.drawColor(SK_ColorWHITE);
|
||||
canvas.drawBitmap(device_->accessBitmap(false), 0, 0, ©_paint);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BackingStoreOSR::ScrollBackingStore(const gfx::Vector2d& delta,
|
||||
const gfx::Rect& clip_rect,
|
||||
const gfx::Size& view_size) {
|
||||
gfx::Rect pixel_rect = gfx::ToEnclosingRect(
|
||||
gfx::ScaleRect(clip_rect, device_scale_factor_));
|
||||
gfx::Vector2d pixel_delta = gfx::ToFlooredVector2d(
|
||||
gfx::ScaleVector2d(delta, device_scale_factor_));
|
||||
|
||||
int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_delta.x());
|
||||
int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_delta.y());
|
||||
int w = pixel_rect.width() + abs(pixel_delta.x());
|
||||
int h = pixel_rect.height() + abs(pixel_delta.y());
|
||||
SkIRect rect = SkIRect::MakeXYWH(x, y, w, h);
|
||||
|
||||
device_->accessBitmap(true).scrollRect(&rect,
|
||||
pixel_delta.x(),
|
||||
pixel_delta.y());
|
||||
}
|
||||
|
||||
const void* BackingStoreOSR::getPixels() const {
|
||||
return const_cast<BackingStoreOSR*>(this)->device_->
|
||||
accessBitmap(false).getPixels();
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_
|
||||
#define CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "content/browser/renderer_host/backing_store.h"
|
||||
#include "ui/gfx/canvas.h"
|
||||
|
||||
class CefRenderWidgetHostViewOSR;
|
||||
|
||||
class BackingStoreOSR : public content::BackingStore {
|
||||
public:
|
||||
static BackingStoreOSR* From(content::BackingStore* backing_store) {
|
||||
return static_cast<BackingStoreOSR*>(backing_store);
|
||||
}
|
||||
|
||||
// BackingStore implementation.
|
||||
virtual size_t MemorySize() OVERRIDE;
|
||||
virtual void PaintToBackingStore(
|
||||
content::RenderProcessHost* process,
|
||||
TransportDIB::Id bitmap,
|
||||
const gfx::Rect& bitmap_rect,
|
||||
const std::vector<gfx::Rect>& copy_rects,
|
||||
float scale_factor,
|
||||
const base::Closure& completion_callback,
|
||||
bool* scheduled_completion_callback) OVERRIDE;
|
||||
virtual bool CopyFromBackingStore(const gfx::Rect& rect,
|
||||
skia::PlatformBitmap* output) OVERRIDE;
|
||||
virtual void ScrollBackingStore(const gfx::Vector2d& delta,
|
||||
const gfx::Rect& clip_rect,
|
||||
const gfx::Size& view_size) OVERRIDE;
|
||||
|
||||
void ScaleFactorChanged(float scale_factor);
|
||||
|
||||
const void* getPixels() const;
|
||||
|
||||
private:
|
||||
// Can be instantiated only within CefRenderWidgetHostViewOSR.
|
||||
friend class CefRenderWidgetHostViewOSR;
|
||||
|
||||
explicit BackingStoreOSR(content::RenderWidgetHost* widget,
|
||||
const gfx::Size& size, float scale_factor);
|
||||
virtual ~BackingStoreOSR() {}
|
||||
|
||||
scoped_ptr<SkBaseDevice> device_;
|
||||
scoped_ptr<SkCanvas> canvas_;
|
||||
|
||||
float device_scale_factor_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BackingStoreOSR);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_BACKING_STORE_OSR_H_
|
||||
|
@@ -19,11 +19,9 @@
|
||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||
#include "libcef/browser/navigate_params.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
#include "libcef/browser/scheme_handler.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/web_contents_view_osr.h"
|
||||
#include "libcef/common/cef_messages.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/drag_data_impl.h"
|
||||
@@ -286,28 +284,9 @@ bool CefBrowserHost::CreateBrowser(
|
||||
return false;
|
||||
}
|
||||
|
||||
CefBrowserSettings new_settings = settings;
|
||||
|
||||
// Verify that render handler is in place for a windowless browser.
|
||||
if (CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)) {
|
||||
if (!CefContext::Get()->settings().windowless_rendering_enabled) {
|
||||
NOTREACHED() << "Windowless rendering must be enabled";
|
||||
return false;
|
||||
}
|
||||
if (!client->GetRenderHandler().get()) {
|
||||
NOTREACHED() << "CefRenderHandler implementation is required";
|
||||
return false;
|
||||
}
|
||||
if (new_settings.accelerated_compositing != STATE_DISABLED) {
|
||||
// Accelerated compositing is not supported when window rendering is
|
||||
// disabled.
|
||||
new_settings.accelerated_compositing = STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the browser on the UI thread.
|
||||
CreateBrowserHelper* helper =
|
||||
new CreateBrowserHelper(windowInfo, client, url, new_settings,
|
||||
new CreateBrowserHelper(windowInfo, client, url, settings,
|
||||
request_context);
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(CreateBrowserWithHelper, helper));
|
||||
|
||||
@@ -358,35 +337,10 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
||||
CefWindowHandle opener,
|
||||
bool is_popup,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
CefBrowserSettings new_settings = settings;
|
||||
|
||||
// Verify that render handler is in place for a windowless browser.
|
||||
if (CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo)) {
|
||||
if (!CefContext::Get()->settings().windowless_rendering_enabled) {
|
||||
NOTREACHED() << "Windowless rendering must be enabled";
|
||||
return NULL;
|
||||
}
|
||||
if (!client->GetRenderHandler().get()) {
|
||||
NOTREACHED() << "CefRenderHandler implementation is required";
|
||||
return NULL;
|
||||
}
|
||||
if (new_settings.accelerated_compositing != STATE_DISABLED) {
|
||||
// Accelerated compositing is not supported when window rendering is
|
||||
// disabled.
|
||||
new_settings.accelerated_compositing = STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
CefContentBrowserClient::Get()->set_use_osr_next_contents_view(
|
||||
CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo));
|
||||
|
||||
scoped_refptr<CefBrowserInfo> info =
|
||||
CefContentBrowserClient::Get()->CreateBrowserInfo(is_popup);
|
||||
|
||||
info->set_window_rendering_disabled(
|
||||
CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo));
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::CreateInternal(windowInfo, new_settings, client, NULL,
|
||||
CefBrowserHostImpl::CreateInternal(windowInfo, settings, client, NULL,
|
||||
info, opener, request_context);
|
||||
if (browser && !url.empty()) {
|
||||
browser->LoadURL(CefFrameHostImpl::kMainFrameId, url, content::Referrer(),
|
||||
@@ -429,8 +383,7 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
new CefBrowserHostImpl(window_info, settings, client, web_contents,
|
||||
browser_info, opener);
|
||||
if (!browser->IsWindowRenderingDisabled() &&
|
||||
!browser->PlatformCreateWindow()) {
|
||||
if (!browser->PlatformCreateWindow()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -654,8 +607,7 @@ void CefBrowserHostImpl::CloseBrowser(bool force_close) {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
// Exit early if a close attempt is already pending and this method is
|
||||
// called again from somewhere other than WindowDestroyed().
|
||||
if (destruction_state_ >= DESTRUCTION_STATE_PENDING &&
|
||||
(IsWindowRenderingDisabled() || !window_destroyed_)) {
|
||||
if (destruction_state_ >= DESTRUCTION_STATE_PENDING && !window_destroyed_) {
|
||||
if (force_close && destruction_state_ == DESTRUCTION_STATE_PENDING) {
|
||||
// Upgrade the destruction state.
|
||||
destruction_state_ = DESTRUCTION_STATE_ACCEPTED;
|
||||
@@ -887,109 +839,6 @@ bool CefBrowserHostImpl::IsMouseCursorChangeDisabled() {
|
||||
return mouse_cursor_change_disabled_;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsWindowRenderingDisabled() {
|
||||
return IsWindowRenderingDisabled(window_info_);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::WasResized() {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(&CefBrowserHostImpl::WasResized, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
return;
|
||||
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->WasResized();
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::WasHidden(bool hidden) {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHost::WasHidden, this, hidden));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
return;
|
||||
|
||||
content::RenderWidgetHostImpl* widget =
|
||||
content::RenderWidgetHostImpl::From(web_contents()->GetRenderViewHost());
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
if (hidden)
|
||||
widget->WasHidden();
|
||||
else
|
||||
widget->WasShown();
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::NotifyScreenInfoChanged() {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::NotifyScreenInfoChanged, this));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
return;
|
||||
|
||||
content::RenderWidgetHostView* view =
|
||||
web_contents()->GetRenderViewHost()->GetView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
CefRenderWidgetHostViewOSR* orview =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(view);
|
||||
|
||||
orview->OnScreenInfoChanged();
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::Invalidate(const CefRect& dirtyRect,
|
||||
PaintElementType type) {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::Invalidate, this, dirtyRect, type));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!web_contents())
|
||||
return;
|
||||
|
||||
content::RenderWidgetHostView* view =
|
||||
web_contents()->GetRenderViewHost()->GetView();
|
||||
CefRenderWidgetHostViewOSR* orview =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(view);
|
||||
|
||||
if (orview) {
|
||||
gfx::Rect rect(dirtyRect.x, dirtyRect.y,
|
||||
dirtyRect.width, dirtyRect.height);
|
||||
orview->Invalidate(rect, type);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -1000,20 +849,9 @@ void CefBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
|
||||
content::NativeWebKeyboardEvent web_event;
|
||||
PlatformTranslateKeyEvent(web_event, event);
|
||||
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->ForwardKeyboardEvent(web_event);
|
||||
} else {
|
||||
if (!web_contents())
|
||||
return;
|
||||
content::RenderWidgetHostView* view =
|
||||
web_contents()->GetRenderViewHost()->GetView();
|
||||
CefRenderWidgetHostViewOSR* orview =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(view);
|
||||
if (orview)
|
||||
orview->SendKeyEvent(web_event);
|
||||
}
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->ForwardKeyboardEvent(web_event);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
|
||||
@@ -1058,21 +896,9 @@ void CefBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
|
||||
blink::WebMouseWheelEvent web_event;
|
||||
PlatformTranslateWheelEvent(web_event, event, deltaX, deltaY);
|
||||
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->ForwardWheelEvent(web_event);
|
||||
} else {
|
||||
if (!web_contents())
|
||||
return;
|
||||
content::RenderWidgetHostView* view =
|
||||
web_contents()->GetRenderViewHost()->GetView();
|
||||
CefRenderWidgetHostViewOSR* orview =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(view);
|
||||
|
||||
if (orview)
|
||||
orview->SendMouseWheelEvent(web_event);
|
||||
}
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->ForwardWheelEvent(web_event);
|
||||
}
|
||||
|
||||
int CefBrowserHostImpl::TranslateModifiers(uint32 cef_modifiers) {
|
||||
@@ -1106,21 +932,9 @@ int CefBrowserHostImpl::TranslateModifiers(uint32 cef_modifiers) {
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SendMouseEvent(const blink::WebMouseEvent& event) {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->ForwardMouseEvent(event);
|
||||
} else {
|
||||
if (!web_contents())
|
||||
return;
|
||||
content::RenderWidgetHostView* view =
|
||||
web_contents()->GetRenderViewHost()->GetView();
|
||||
CefRenderWidgetHostViewOSR* orview =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(view);
|
||||
|
||||
if (orview)
|
||||
orview->SendMouseEvent(event);
|
||||
}
|
||||
content::RenderWidgetHost* widget = web_contents()->GetRenderViewHost();
|
||||
if (widget)
|
||||
widget->ForwardMouseEvent(event);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SendFocusEvent(bool setFocus) {
|
||||
@@ -1691,12 +1505,10 @@ void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||
web_contents_->GetView()->Focus();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
// When windowed rendering is used in combination with Aura on Windows we
|
||||
// need to explicitly set focus to the native window handle. Otherwise,
|
||||
// the window doesn't get keyboard focus.
|
||||
PlatformSetViewFocus();
|
||||
}
|
||||
// When windowed rendering is used in combination with Aura on Windows we
|
||||
// need to explicitly set focus to the native window handle. Otherwise,
|
||||
// the window doesn't get keyboard focus.
|
||||
PlatformSetViewFocus();
|
||||
#endif // defined(OS_WIN)
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
@@ -1712,23 +1524,6 @@ void CefBrowserHostImpl::RunFileChooser(
|
||||
callback));
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
NOTREACHED();
|
||||
}
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
// content::WebContentsDelegate methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -1775,7 +1570,7 @@ void CefBrowserHostImpl::CloseContents(content::WebContents* source) {
|
||||
|
||||
// If this method is called in response to something other than
|
||||
// WindowDestroyed() ask the user if the browser should close.
|
||||
if (client_.get() && (IsWindowRenderingDisabled() || !window_destroyed_)) {
|
||||
if (client_.get() && !window_destroyed_) {
|
||||
CefRefPtr<CefLifeSpanHandler> handler =
|
||||
client_->GetLifeSpanHandler();
|
||||
if (handler.get()) {
|
||||
@@ -1787,7 +1582,7 @@ void CefBrowserHostImpl::CloseContents(content::WebContents* source) {
|
||||
if (destruction_state_ != DESTRUCTION_STATE_ACCEPTED)
|
||||
destruction_state_ = DESTRUCTION_STATE_ACCEPTED;
|
||||
|
||||
if (!IsWindowRenderingDisabled() && !window_destroyed_) {
|
||||
if (!window_destroyed_) {
|
||||
// A window exists so try to close it using the platform method. Will
|
||||
// result in a call to WindowDestroyed() if/when the window is destroyed
|
||||
// via the platform window destruction mechanism.
|
||||
@@ -1799,10 +1594,8 @@ void CefBrowserHostImpl::CloseContents(content::WebContents* source) {
|
||||
|
||||
// No window exists. Destroy the browser immediately.
|
||||
DestroyBrowser();
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
// Release the reference added in PlatformCreateWindow().
|
||||
Release();
|
||||
}
|
||||
// Release the reference added in PlatformCreateWindow().
|
||||
Release();
|
||||
}
|
||||
} else if (destruction_state_ != DESTRUCTION_STATE_NONE) {
|
||||
destruction_state_ = DESTRUCTION_STATE_NONE;
|
||||
@@ -1930,26 +1723,6 @@ bool CefBrowserHostImpl::CanDragEnter(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::ShouldCreateWebContents(
|
||||
content::WebContents* web_contents,
|
||||
int route_id,
|
||||
WindowContainerType window_container_type,
|
||||
const base::string16& frame_name,
|
||||
const GURL& target_url,
|
||||
const std::string& partition_id,
|
||||
content::SessionStorageNamespace* session_storage_namespace) {
|
||||
// In cases where the navigation will occur in a new render process the
|
||||
// |route_id| value will be MSG_ROUTING_NONE here (because the existing
|
||||
// renderer will not be able to communicate with the new renderer) and
|
||||
// OpenURLFromTab will be called after WebContentsCreated.
|
||||
base::AutoLock lock_scope(pending_popup_info_lock_);
|
||||
DCHECK(pending_popup_info_.get());
|
||||
CefContentBrowserClient::Get()->set_use_osr_next_contents_view(
|
||||
IsWindowRenderingDisabled(pending_popup_info_->window_info));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::WebContentsCreated(
|
||||
content::WebContents* source_contents,
|
||||
int opener_render_frame_id,
|
||||
@@ -2424,14 +2197,6 @@ CefBrowserHostImpl::CefBrowserHostImpl(
|
||||
|
||||
// Make sure RenderViewCreated is called at least one time.
|
||||
RenderViewCreated(web_contents->GetRenderViewHost());
|
||||
|
||||
if (IsWindowRenderingDisabled()) {
|
||||
CefRenderWidgetHostViewOSR* view =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(
|
||||
web_contents->GetRenderViewHost()->GetView());
|
||||
if (view)
|
||||
view->set_browser_impl(this);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefFrame> CefBrowserHostImpl::GetOrCreateFrame(
|
||||
|
@@ -120,9 +120,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
static CefRefPtr<CefBrowserHostImpl> GetBrowserForFrame(
|
||||
int render_process_id, int render_routing_id);
|
||||
|
||||
// Returns true if window rendering is disabled in CefWindowInfo.
|
||||
static bool IsWindowRenderingDisabled(const CefWindowInfo& info);
|
||||
|
||||
// CefBrowserHost methods.
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() OVERRIDE;
|
||||
virtual void CloseBrowser(bool force_close) OVERRIDE;
|
||||
@@ -150,12 +147,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
virtual void CloseDevTools() OVERRIDE;
|
||||
virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE;
|
||||
virtual bool IsMouseCursorChangeDisabled() OVERRIDE;
|
||||
virtual bool IsWindowRenderingDisabled() OVERRIDE;
|
||||
virtual void WasResized() OVERRIDE;
|
||||
virtual void WasHidden(bool hidden) OVERRIDE;
|
||||
virtual void NotifyScreenInfoChanged() OVERRIDE;
|
||||
virtual void Invalidate(const CefRect& dirtyRect,
|
||||
PaintElementType type) OVERRIDE;
|
||||
virtual void SendKeyEvent(const CefKeyEvent& event) OVERRIDE;
|
||||
virtual void SendMouseClickEvent(const CefMouseEvent& event,
|
||||
MouseButtonType type,
|
||||
@@ -166,11 +157,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
int deltaX, int deltaY) OVERRIDE;
|
||||
virtual void SendFocusEvent(bool setFocus) OVERRIDE;
|
||||
virtual void SendCaptureLostEvent() OVERRIDE;
|
||||
virtual CefTextInputContext GetNSTextInputContext() OVERRIDE;
|
||||
virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent)
|
||||
OVERRIDE;
|
||||
virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent)
|
||||
OVERRIDE;
|
||||
|
||||
// CefBrowser methods.
|
||||
virtual CefRefPtr<CefBrowserHost> GetHost() OVERRIDE;
|
||||
@@ -258,8 +244,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Returns the URL that is currently loading (or loaded) in the main frame.
|
||||
GURL GetLoadingURL();
|
||||
|
||||
bool IsTransparent();
|
||||
|
||||
#if defined(OS_WIN)
|
||||
static void RegisterWindowClass();
|
||||
#endif
|
||||
@@ -344,14 +328,6 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
content::WebContents* source,
|
||||
const content::DropData& data,
|
||||
blink::WebDragOperationsMask operations_allowed) OVERRIDE;
|
||||
virtual bool ShouldCreateWebContents(
|
||||
content::WebContents* web_contents,
|
||||
int route_id,
|
||||
WindowContainerType window_container_type,
|
||||
const base::string16& frame_name,
|
||||
const GURL& target_url,
|
||||
const std::string& partition_id,
|
||||
content::SessionStorageNamespace* session_storage_namespace) OVERRIDE;
|
||||
virtual void WebContentsCreated(content::WebContents* source_contents,
|
||||
int opener_render_frame_id,
|
||||
const base::string16& frame_name,
|
||||
@@ -494,7 +470,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY);
|
||||
void PlatformTranslateMouseEvent(blink::WebMouseEvent& web_event,
|
||||
const CefMouseEvent& mouse_event);
|
||||
const CefMouseEvent& mouse_event);
|
||||
|
||||
int TranslateModifiers(uint32 cefKeyStates);
|
||||
void SendMouseEvent(const blink::WebMouseEvent& web_event);
|
||||
|
@@ -320,9 +320,7 @@ void CefBrowserHostImpl::PlatformSizeTo(int width, int height) {
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() {
|
||||
return IsWindowRenderingDisabled() ?
|
||||
window_info_.parent_widget :
|
||||
window_info_.widget;
|
||||
return window_info_.widget;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::PlatformViewText(const std::string& text) {
|
||||
@@ -383,15 +381,6 @@ void CefBrowserHostImpl::PlatformRunFileChooser(
|
||||
void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) {
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) {
|
||||
return info.windowless_rendering_enabled ? true : false;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsTransparent() {
|
||||
return window_info_.transparent_painting_enabled ? true : false;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::PlatformTranslateKeyEvent(
|
||||
content::NativeWebKeyboardEvent& result,
|
||||
const CefKeyEvent& key_event) {
|
||||
@@ -553,18 +542,12 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent(
|
||||
result.globalY = result.y;
|
||||
|
||||
// global position
|
||||
if (IsWindowRenderingDisabled()) {
|
||||
GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(),
|
||||
result.x, result.y,
|
||||
result.globalX, result.globalY);
|
||||
} else {
|
||||
GtkWidget* window = gtk_widget_get_toplevel(GetWindowHandle());
|
||||
GdkWindow* gdk_window = gtk_widget_get_window(window);
|
||||
gint xorigin, yorigin;
|
||||
gdk_window_get_root_origin(gdk_window, &xorigin, &yorigin);
|
||||
result.globalX = xorigin + result.x;
|
||||
result.globalY = yorigin + result.y;
|
||||
}
|
||||
GtkWidget* window = gtk_widget_get_toplevel(GetWindowHandle());
|
||||
GdkWindow* gdk_window = gtk_widget_get_window(window);
|
||||
gint xorigin, yorigin;
|
||||
gdk_window_get_root_origin(gdk_window, &xorigin, &yorigin);
|
||||
result.globalX = xorigin + result.x;
|
||||
result.globalY = yorigin + result.y;
|
||||
|
||||
// modifiers
|
||||
result.modifiers |= TranslateModifiers(mouse_event.modifiers);
|
||||
|
@@ -8,8 +8,6 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <CoreServices/CoreServices.h>
|
||||
|
||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||
#include "libcef/browser/text_input_client_osr_mac.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "base/file_util.h"
|
||||
@@ -258,59 +256,6 @@ bool RunSaveFileDialog(const content::FileChooserParams& params,
|
||||
|
||||
} // namespace
|
||||
|
||||
CefTextInputContext CefBrowserHostImpl::GetNSTextInputContext() {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "Called on invalid thread";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRenderWidgetHostViewOSR* rwhv = static_cast<CefRenderWidgetHostViewOSR*>(
|
||||
GetWebContents()->GetRenderWidgetHostView());
|
||||
|
||||
return rwhv->GetNSTextInputContext();
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::HandleKeyEventBeforeTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "Called on invalid thread";
|
||||
return;
|
||||
}
|
||||
|
||||
CefRenderWidgetHostViewOSR* rwhv = static_cast<CefRenderWidgetHostViewOSR*>(
|
||||
GetWebContents()->GetRenderWidgetHostView());
|
||||
|
||||
rwhv->HandleKeyEventBeforeTextInputClient(keyEvent);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::HandleKeyEventAfterTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
if (!IsWindowRenderingDisabled()) {
|
||||
NOTREACHED() << "Window rendering is not disabled";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||
NOTREACHED() << "Called on invalid thread";
|
||||
return;
|
||||
}
|
||||
|
||||
CefRenderWidgetHostViewOSR* rwhv = static_cast<CefRenderWidgetHostViewOSR*>(
|
||||
GetWebContents()->GetRenderWidgetHostView());
|
||||
|
||||
rwhv->HandleKeyEventAfterTextInputClient(keyEvent);
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::PlatformViewText(const std::string& text) {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
@@ -402,9 +347,7 @@ void CefBrowserHostImpl::PlatformSizeTo(int width, int height) {
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() {
|
||||
return IsWindowRenderingDisabled() ?
|
||||
window_info_.parent_view :
|
||||
window_info_.view;
|
||||
return window_info_.view;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::PlatformHandleKeyboardEvent(
|
||||
@@ -436,15 +379,6 @@ void CefBrowserHostImpl::PlatformRunFileChooser(
|
||||
void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) {
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) {
|
||||
return info.windowless_rendering_enabled ? true : false;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsTransparent() {
|
||||
return window_info_.transparent_painting_enabled ? true : false;
|
||||
}
|
||||
|
||||
static NSTimeInterval currentEventTimestamp() {
|
||||
NSEvent* currentEvent = [NSApp currentEvent];
|
||||
if (currentEvent)
|
||||
@@ -627,20 +561,14 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent(
|
||||
result.globalX = result.x;
|
||||
result.globalY = result.y;
|
||||
|
||||
if (IsWindowRenderingDisabled()) {
|
||||
GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(),
|
||||
result.x, result.y,
|
||||
result.globalX, result.globalY);
|
||||
} else {
|
||||
NSView* view = window_info_.parent_view;
|
||||
if (view) {
|
||||
NSRect bounds = [view bounds];
|
||||
NSPoint view_pt = {result.x, bounds.size.height - result.y};
|
||||
NSPoint window_pt = [view convertPoint:view_pt toView:nil];
|
||||
NSPoint screen_pt = [[view window] convertBaseToScreen:window_pt];
|
||||
result.globalX = screen_pt.x;
|
||||
result.globalY = screen_pt.y;
|
||||
}
|
||||
NSView* view = window_info_.parent_view;
|
||||
if (view) {
|
||||
NSRect bounds = [view bounds];
|
||||
NSPoint view_pt = {result.x, bounds.size.height - result.y};
|
||||
NSPoint window_pt = [view convertPoint:view_pt toView:nil];
|
||||
NSPoint screen_pt = [[view window] convertBaseToScreen:window_pt];
|
||||
result.globalX = screen_pt.x;
|
||||
result.globalY = screen_pt.y;
|
||||
}
|
||||
|
||||
// modifiers
|
||||
|
@@ -47,23 +47,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsAeroGlassEnabled() {
|
||||
if (base::win::GetVersion() < base::win::VERSION_VISTA)
|
||||
return false;
|
||||
|
||||
BOOL enabled = FALSE;
|
||||
return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled;
|
||||
}
|
||||
|
||||
void SetAeroGlass(HWND hWnd) {
|
||||
if (!IsAeroGlassEnabled())
|
||||
return;
|
||||
|
||||
// Make the whole window transparent.
|
||||
MARGINS mgMarInset = { -1, -1, -1, -1 };
|
||||
DwmExtendFrameIntoClientArea(hWnd, &mgMarInset);
|
||||
}
|
||||
|
||||
HWND GetHWND(views::Widget* widget) {
|
||||
gfx::NativeWindow window = widget->GetNativeWindow();
|
||||
DCHECK(window);
|
||||
@@ -714,13 +697,6 @@ LRESULT CALLBACK CefBrowserHostImpl::WndProc(HWND hwnd, UINT message,
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 0;
|
||||
|
||||
case WM_DWMCOMPOSITIONCHANGED:
|
||||
// Message sent to top-level windows when composition has been enabled or
|
||||
// disabled.
|
||||
if (browser && browser->IsTransparent())
|
||||
SetAeroGlass(hwnd);
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
@@ -761,12 +737,6 @@ bool CefBrowserHostImpl::PlatformCreateWindow() {
|
||||
if (!window_info_.window)
|
||||
return false;
|
||||
|
||||
if (window_info_.transparent_painting_enabled &&
|
||||
!(window_info_.style & WS_CHILD)) {
|
||||
// Transparent top-level windows will be given "sheet of glass" effect.
|
||||
SetAeroGlass(window_info_.window);
|
||||
}
|
||||
|
||||
// Set window user data to this object for future reference from the window
|
||||
// procedure.
|
||||
gfx::SetWindowUserData(window_info_.window, this);
|
||||
@@ -823,9 +793,7 @@ void CefBrowserHostImpl::PlatformSizeTo(int width, int height) {
|
||||
}
|
||||
|
||||
CefWindowHandle CefBrowserHostImpl::PlatformGetWindowHandle() {
|
||||
return IsWindowRenderingDisabled() ?
|
||||
window_info_.parent_window :
|
||||
window_info_.window;
|
||||
return window_info_.window;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::PlatformViewText(const std::string& text) {
|
||||
@@ -905,15 +873,6 @@ void CefBrowserHostImpl::PlatformHandleExternalProtocol(const GURL& url) {
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
bool CefBrowserHostImpl::IsWindowRenderingDisabled(const CefWindowInfo& info) {
|
||||
return info.windowless_rendering_enabled ? true : false;
|
||||
}
|
||||
|
||||
bool CefBrowserHostImpl::IsTransparent() {
|
||||
return window_info_.transparent_painting_enabled ? true : false;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::PlatformTranslateKeyEvent(
|
||||
content::NativeWebKeyboardEvent& result, const CefKeyEvent& key_event) {
|
||||
result.timeStampSeconds = GetMessageTime() / 1000.0;
|
||||
@@ -1058,16 +1017,10 @@ void CefBrowserHostImpl::PlatformTranslateMouseEvent(
|
||||
result.globalY = result.y;
|
||||
|
||||
// global position
|
||||
if (IsWindowRenderingDisabled()) {
|
||||
GetClient()->GetRenderHandler()->GetScreenPoint(GetBrowser(),
|
||||
result.x, result.y,
|
||||
result.globalX, result.globalY);
|
||||
} else {
|
||||
POINT globalPoint = { result.x, result.y };
|
||||
ClientToScreen(GetWindowHandle(), &globalPoint);
|
||||
result.globalX = globalPoint.x;
|
||||
result.globalY = globalPoint.y;
|
||||
}
|
||||
POINT globalPoint = { result.x, result.y };
|
||||
ClientToScreen(GetWindowHandle(), &globalPoint);
|
||||
result.globalX = globalPoint.x;
|
||||
result.globalY = globalPoint.y;
|
||||
|
||||
// modifiers
|
||||
result.modifiers |= TranslateModifiers(mouse_event.modifiers);
|
||||
|
@@ -7,18 +7,13 @@
|
||||
|
||||
CefBrowserInfo::CefBrowserInfo(int browser_id, bool is_popup)
|
||||
: browser_id_(browser_id),
|
||||
is_popup_(is_popup),
|
||||
is_window_rendering_disabled_(false) {
|
||||
is_popup_(is_popup) {
|
||||
DCHECK_GT(browser_id, 0);
|
||||
}
|
||||
|
||||
CefBrowserInfo::~CefBrowserInfo() {
|
||||
}
|
||||
|
||||
void CefBrowserInfo::set_window_rendering_disabled(bool disabled) {
|
||||
is_window_rendering_disabled_ = disabled;
|
||||
}
|
||||
|
||||
void CefBrowserInfo::add_render_view_id(
|
||||
int render_process_id, int render_routing_id) {
|
||||
add_render_id(&render_view_id_set_, render_process_id, render_routing_id);
|
||||
|
@@ -24,12 +24,7 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
|
||||
int browser_id() const { return browser_id_; };
|
||||
bool is_popup() const { return is_popup_; }
|
||||
bool is_window_rendering_disabled() const {
|
||||
return is_window_rendering_disabled_;
|
||||
}
|
||||
|
||||
void set_window_rendering_disabled(bool disabled);
|
||||
|
||||
// Adds an ID pair if it doesn't already exist.
|
||||
void add_render_view_id(int render_process_id, int render_routing_id);
|
||||
void add_render_frame_id(int render_process_id, int render_routing_id);
|
||||
@@ -60,7 +55,6 @@ class CefBrowserInfo : public base::RefCountedThreadSafe<CefBrowserInfo> {
|
||||
|
||||
int browser_id_;
|
||||
bool is_popup_;
|
||||
bool is_window_rendering_disabled_;
|
||||
|
||||
base::Lock lock_;
|
||||
|
||||
|
@@ -91,7 +91,6 @@ void CefBrowserMessageFilter::OnGetNewBrowserInfo(
|
||||
render_frame_routing_id);
|
||||
params->browser_id = info->browser_id();
|
||||
params->is_popup = info->is_popup();
|
||||
params->is_window_rendering_disabled = info->is_window_rendering_disabled();
|
||||
}
|
||||
|
||||
void CefBrowserMessageFilter::OnCreateWindow(
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include "libcef/browser/resource_dispatcher_host_delegate.h"
|
||||
#include "libcef/browser/speech_recognition_manager_delegate.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/browser/web_contents_view_osr.h"
|
||||
#include "libcef/browser/web_plugin_impl.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/command_line_impl.h"
|
||||
@@ -349,8 +348,7 @@ int GetCrashSignalFD(const CommandLine& command_line) {
|
||||
|
||||
CefContentBrowserClient::CefContentBrowserClient()
|
||||
: browser_main_parts_(NULL),
|
||||
next_browser_id_(0),
|
||||
use_osr_next_contents_view_(false) {
|
||||
next_browser_id_(0) {
|
||||
plugin_service_filter_.reset(new CefPluginServiceFilter);
|
||||
content::PluginServiceImpl::GetInstance()->SetFilter(
|
||||
plugin_service_filter_.get());
|
||||
@@ -541,23 +539,6 @@ content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts(
|
||||
return browser_main_parts_;
|
||||
}
|
||||
|
||||
content::WebContentsViewPort*
|
||||
CefContentBrowserClient::OverrideCreateWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
content::RenderViewHostDelegateView** render_view_host_delegate_view) {
|
||||
content::WebContentsViewPort* view = NULL;
|
||||
*render_view_host_delegate_view = NULL;
|
||||
|
||||
if (use_osr_next_contents_view()) {
|
||||
CefWebContentsViewOSR* view_or = new CefWebContentsViewOSR(web_contents,
|
||||
GetWebContentsViewDelegate(web_contents));
|
||||
*render_view_host_delegate_view = view_or;
|
||||
view = view_or;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host) {
|
||||
host->GetChannel()->AddFilter(new CefBrowserMessageFilter(host));
|
||||
@@ -817,20 +798,6 @@ bool CefContentBrowserClient::CanCreateWindow(
|
||||
pending_info->client,
|
||||
pending_info->settings,
|
||||
no_javascript_access);
|
||||
if (allow) {
|
||||
if (CefBrowserHostImpl::IsWindowRenderingDisabled(
|
||||
pending_info->window_info)) {
|
||||
if (!pending_info->client->GetRenderHandler().get()) {
|
||||
NOTREACHED() << "CefRenderHandler implementation is required";
|
||||
allow = false;
|
||||
}
|
||||
if (pending_info->settings.accelerated_compositing != STATE_DISABLED) {
|
||||
// Accelerated compositing is not supported when window rendering is
|
||||
// disabled.
|
||||
pending_info->settings.accelerated_compositing = STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -81,9 +81,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
// ContentBrowserClient implementation.
|
||||
virtual content::BrowserMainParts* CreateBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters) OVERRIDE;
|
||||
virtual content::WebContentsViewPort* OverrideCreateWebContentsView(
|
||||
content::WebContents* web_contents,
|
||||
content::RenderViewHostDelegateView** rvhdv) OVERRIDE;
|
||||
virtual void RenderProcessWillLaunch(
|
||||
content::RenderProcessHost* host) OVERRIDE;
|
||||
virtual net::URLRequestContextGetter* CreateRequestContext(
|
||||
@@ -165,16 +162,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
};
|
||||
void set_last_create_window_params(const LastCreateWindowParams& params);
|
||||
|
||||
// To disable window rendering call this function with |override|=true
|
||||
// just before calling WebContents::Create. This will cause
|
||||
// OverrideCreateWebContentsView to create a windowless WebContentsView.
|
||||
void set_use_osr_next_contents_view(bool value) {
|
||||
use_osr_next_contents_view_ = value;
|
||||
}
|
||||
bool use_osr_next_contents_view() const {
|
||||
return use_osr_next_contents_view_;
|
||||
}
|
||||
|
||||
CefBrowserContext* browser_context() const;
|
||||
scoped_refptr<net::URLRequestContextGetter> request_context() const;
|
||||
CefDevToolsDelegate* devtools_delegate() const;
|
||||
@@ -199,8 +186,6 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
|
||||
// Only accessed on the IO thread.
|
||||
LastCreateWindowParams last_create_window_params_;
|
||||
|
||||
bool use_osr_next_contents_view_;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|
||||
|
@@ -31,33 +31,14 @@ bool CefMenuCreatorRunnerGtk::RunContextMenu(CefMenuCreator* manager) {
|
||||
gfx::Point screen_point;
|
||||
GdkEventButton* event = NULL;
|
||||
|
||||
if (manager->browser()->IsWindowRenderingDisabled()) {
|
||||
CefRefPtr<CefClient> client = manager->browser()->GetClient();
|
||||
if (!client.get())
|
||||
return false;
|
||||
gfx::Rect bounds;
|
||||
manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds);
|
||||
screen_point = bounds.origin();
|
||||
screen_point.Offset(manager->params().x, manager->params().y);
|
||||
|
||||
CefRefPtr<CefRenderHandler> handler = client->GetRenderHandler();
|
||||
if (!handler.get())
|
||||
return false;
|
||||
|
||||
int screenX = 0, screenY = 0;
|
||||
if (!handler->GetScreenPoint(manager->browser(),
|
||||
manager->params().x, manager->params().y,
|
||||
screenX, screenY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
screen_point = gfx::Point(screenX, screenY);
|
||||
} else {
|
||||
gfx::Rect bounds;
|
||||
manager->browser()->GetWebContents()->GetView()->GetContainerBounds(&bounds);
|
||||
screen_point = bounds.origin();
|
||||
screen_point.Offset(manager->params().x, manager->params().y);
|
||||
|
||||
content::RenderWidgetHostView* view =
|
||||
manager->browser()->GetWebContents()->GetRenderWidgetHostView();
|
||||
event = view->GetLastMouseDown();
|
||||
}
|
||||
content::RenderWidgetHostView* view =
|
||||
manager->browser()->GetWebContents()->GetRenderWidgetHostView();
|
||||
event = view->GetLastMouseDown();
|
||||
|
||||
if (!menu_delegate_.get())
|
||||
menu_delegate_.reset(new CefMenuDelegate);
|
||||
|
@@ -62,33 +62,9 @@ bool CefMenuCreatorRunnerMac::RunContextMenu(CefMenuCreator* manager) {
|
||||
base::mac::ScopedSendingEvent sendingEventScoper;
|
||||
|
||||
// Show the menu. Blocks until the menu is dismissed.
|
||||
if (manager->browser()->IsWindowRenderingDisabled()) {
|
||||
// Showing the menu in OSR is pretty much self contained, only using
|
||||
// the initialized menu_controller_ in this function, and the scoped
|
||||
// variables in this block.
|
||||
int screenX = 0, screenY = 0;
|
||||
CefRefPtr<CefRenderHandler> handler =
|
||||
manager->browser()->GetClient()->GetRenderHandler();
|
||||
if (!handler->GetScreenPoint(manager->browser(),
|
||||
manager->params().x, manager->params().y,
|
||||
screenX, screenY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't show the menu unless there is a parent native window to tie it to
|
||||
if (!manager->browser()->GetWindowHandle())
|
||||
return false;
|
||||
|
||||
NSPoint screen_position =
|
||||
NSPointFromCGPoint(gfx::Point(screenX, screenY).ToCGPoint());
|
||||
[[menu_controller_ menu] popUpMenuPositioningItem:nil
|
||||
atLocation:screen_position
|
||||
inView:nil];
|
||||
} else {
|
||||
[NSMenu popUpContextMenu:[menu_controller_ menu]
|
||||
withEvent:clickEvent
|
||||
forView:parent_view];
|
||||
}
|
||||
[NSMenu popUpContextMenu:[menu_controller_ menu]
|
||||
withEvent:clickEvent
|
||||
forView:parent_view];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -25,29 +25,10 @@ bool CefMenuCreatorRunnerWin::RunContextMenu(CefMenuCreator* manager) {
|
||||
|
||||
gfx::Point screen_point;
|
||||
|
||||
if (manager->browser()->IsWindowRenderingDisabled()) {
|
||||
CefRefPtr<CefClient> client = manager->browser()->GetClient();
|
||||
if (!client.get())
|
||||
return false;
|
||||
|
||||
CefRefPtr<CefRenderHandler> handler = client->GetRenderHandler();
|
||||
if (!handler.get())
|
||||
return false;
|
||||
|
||||
int screenX = 0, screenY = 0;
|
||||
if (!handler->GetScreenPoint(manager->browser(),
|
||||
manager->params().x, manager->params().y,
|
||||
screenX, screenY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
screen_point = gfx::Point(screenX, screenY);
|
||||
} else {
|
||||
aura::Window* window = manager->browser()->GetContentView();
|
||||
const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen();
|
||||
screen_point = gfx::Point(bounds_in_screen.x() + manager->params().x,
|
||||
bounds_in_screen.y() + manager->params().y);
|
||||
}
|
||||
aura::Window* window = manager->browser()->GetContentView();
|
||||
const gfx::Rect& bounds_in_screen = window->GetBoundsInScreen();
|
||||
screen_point = gfx::Point(bounds_in_screen.x() + manager->params().x,
|
||||
bounds_in_screen.y() + manager->params().y);
|
||||
|
||||
// Show the menu. Blocks until the menu is dismissed.
|
||||
menu_->RunMenuAt(screen_point, views::Menu2::ALIGN_TOPLEFT);
|
||||
|
@@ -1,736 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/backing_store_osr.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/common/cursors/webcursor.h"
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
|
||||
#include "ui/gfx/size_conversions.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const float kDefaultScaleFactor = 1.0;
|
||||
|
||||
static blink::WebScreenInfo webScreenInfoFrom(const CefScreenInfo& src) {
|
||||
blink::WebScreenInfo webScreenInfo;
|
||||
webScreenInfo.deviceScaleFactor = src.device_scale_factor;
|
||||
webScreenInfo.depth = src.depth;
|
||||
webScreenInfo.depthPerComponent = src.depth_per_component;
|
||||
webScreenInfo.isMonochrome = src.is_monochrome ? true : false;
|
||||
webScreenInfo.rect = blink::WebRect(src.rect.x, src.rect.y,
|
||||
src.rect.width, src.rect.height);
|
||||
webScreenInfo.availableRect = blink::WebRect(src.available_rect.x,
|
||||
src.available_rect.y,
|
||||
src.available_rect.width,
|
||||
src.available_rect.height);
|
||||
|
||||
return webScreenInfo;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CefRenderWidgetHostViewOSR, public:
|
||||
|
||||
CefRenderWidgetHostViewOSR::CefRenderWidgetHostViewOSR(
|
||||
content::RenderWidgetHost* widget)
|
||||
: weak_factory_(this),
|
||||
render_widget_host_(content::RenderWidgetHostImpl::From(widget)),
|
||||
parent_host_view_(NULL),
|
||||
popup_host_view_(NULL),
|
||||
about_to_validate_and_paint_(false)
|
||||
#if defined(OS_MACOSX)
|
||||
, text_input_context_osr_mac_(NULL)
|
||||
#endif
|
||||
{
|
||||
DCHECK(render_widget_host_);
|
||||
render_widget_host_->SetView(this);
|
||||
|
||||
// CefBrowserHostImpl might not be created at this time for popups.
|
||||
if (render_widget_host_->IsRenderView()) {
|
||||
browser_impl_ = CefBrowserHostImpl::GetBrowserForHost(
|
||||
content::RenderViewHost::From(render_widget_host_));
|
||||
}
|
||||
}
|
||||
|
||||
CefRenderWidgetHostViewOSR::~CefRenderWidgetHostViewOSR() {
|
||||
}
|
||||
|
||||
|
||||
// RenderWidgetHostView implementation.
|
||||
|
||||
gfx::Size CefRenderWidgetHostViewOSR::GetPhysicalBackingSize() const {
|
||||
return gfx::ToCeiledSize(gfx::ScaleSize(GetViewBounds().size(),
|
||||
GetDeviceScaleFactor()));
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::InitAsChild(gfx::NativeView parent_view) {
|
||||
}
|
||||
|
||||
content::RenderWidgetHost*
|
||||
CefRenderWidgetHostViewOSR::GetRenderWidgetHost() const {
|
||||
return render_widget_host_;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetSize(const gfx::Size& size) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetBounds(const gfx::Rect& rect) {
|
||||
}
|
||||
|
||||
gfx::NativeView CefRenderWidgetHostViewOSR::GetNativeView() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gfx::NativeViewId CefRenderWidgetHostViewOSR::GetNativeViewId() const {
|
||||
if (!browser_impl_.get())
|
||||
return gfx::NativeViewId();
|
||||
// This Id is used on Windows as HWND to retrieve monitor info
|
||||
// If this Id is not a valid window, the main screen monitor info is used
|
||||
return reinterpret_cast<gfx::NativeViewId>(browser_impl_->GetWindowHandle());
|
||||
}
|
||||
|
||||
gfx::NativeViewAccessible
|
||||
CefRenderWidgetHostViewOSR::GetNativeViewAccessible() {
|
||||
return gfx::NativeViewAccessible();
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::HasFocus() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::IsSurfaceAvailableForCopy() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Show() {
|
||||
WasShown();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Hide() {
|
||||
WasHidden();
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::IsShowing() {
|
||||
return true;
|
||||
}
|
||||
|
||||
gfx::Rect CefRenderWidgetHostViewOSR::GetViewBounds() const {
|
||||
if (IsPopupWidget())
|
||||
return popup_position_;
|
||||
|
||||
if (!browser_impl_.get())
|
||||
return gfx::Rect();
|
||||
CefRect rc;
|
||||
browser_impl_->GetClient()->GetRenderHandler()->GetViewRect(
|
||||
browser_impl_->GetBrowser(), rc);
|
||||
return gfx::Rect(rc.x, rc.y, rc.width, rc.height);
|
||||
}
|
||||
|
||||
// Implementation of RenderWidgetHostViewPort.
|
||||
void CefRenderWidgetHostViewOSR::InitAsPopup(
|
||||
RenderWidgetHostView* parent_host_view,
|
||||
const gfx::Rect& pos) {
|
||||
parent_host_view_ = static_cast<CefRenderWidgetHostViewOSR*>(
|
||||
parent_host_view);
|
||||
browser_impl_ = parent_host_view_->get_browser_impl();
|
||||
if (!browser_impl_.get())
|
||||
return;
|
||||
|
||||
parent_host_view_->CancelWidget();
|
||||
|
||||
parent_host_view_->set_popup_host_view(this);
|
||||
NotifyShowWidget();
|
||||
|
||||
popup_position_ = pos;
|
||||
NotifySizeWidget();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::InitAsFullscreen(
|
||||
RenderWidgetHostView* reference_host_view) {
|
||||
NOTREACHED() << "Fullscreen widgets are not supported in OSR";
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::WasShown() {
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->WasShown();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::WasHidden() {
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->WasHidden();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::MovePluginWindows(
|
||||
const gfx::Vector2d& scroll_offset,
|
||||
const std::vector<content::WebPluginGeometry>& moves) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Focus() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Blur() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::UpdateCursor(
|
||||
const content::WebCursor& cursor) {
|
||||
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::UpdateCursor");
|
||||
if (!browser_impl_.get())
|
||||
return;
|
||||
#if defined(USE_AURA)
|
||||
content::WebCursor web_cursor = cursor;
|
||||
|
||||
ui::PlatformCursor platform_cursor;
|
||||
if (web_cursor.IsCustom()) {
|
||||
// |web_cursor| owns the resulting |platform_cursor|.
|
||||
platform_cursor = web_cursor.GetPlatformCursor();
|
||||
} else {
|
||||
content::WebCursor::CursorInfo cursor_info;
|
||||
cursor.GetCursorInfo(&cursor_info);
|
||||
platform_cursor = browser_impl_->GetPlatformCursor(cursor_info.type);
|
||||
}
|
||||
|
||||
browser_impl_->GetClient()->GetRenderHandler()->OnCursorChange(
|
||||
browser_impl_->GetBrowser(), platform_cursor);
|
||||
#elif defined(OS_MACOSX) || defined(TOOLKIT_GTK)
|
||||
// |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_->GetBrowser(), native_cursor);
|
||||
#else
|
||||
// TODO(port): Implement this method to work on other platforms as part of
|
||||
// off-screen rendering support.
|
||||
NOTREACHED();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) {
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
void CefRenderWidgetHostViewOSR::TextInputTypeChanged(
|
||||
ui::TextInputType type,
|
||||
ui::TextInputMode mode,
|
||||
bool can_compose_inline) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
|
||||
}
|
||||
|
||||
#if defined(OS_WIN) || defined(USE_AURA)
|
||||
void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged(
|
||||
const gfx::Range& range,
|
||||
const std::vector<gfx::Rect>& character_bounds) {
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
void CefRenderWidgetHostViewOSR::DidUpdateBackingStore(
|
||||
const gfx::Rect& scroll_rect,
|
||||
const gfx::Vector2d& scroll_delta,
|
||||
const std::vector<gfx::Rect>& copy_rects,
|
||||
const std::vector<ui::LatencyInfo>& latency_info) {
|
||||
if (!scroll_rect.IsEmpty()) {
|
||||
std::vector<gfx::Rect> dirty_rects(copy_rects);
|
||||
dirty_rects.push_back(scroll_rect);
|
||||
Paint(dirty_rects);
|
||||
} else {
|
||||
Paint(copy_rects);
|
||||
}
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::RenderProcessGone(
|
||||
base::TerminationStatus status,
|
||||
int error_code) {
|
||||
render_widget_host_ = NULL;
|
||||
parent_host_view_ = NULL;
|
||||
popup_host_view_ = NULL;
|
||||
}
|
||||
|
||||
#if defined(OS_WIN) && !defined(USE_AURA)
|
||||
void CefRenderWidgetHostViewOSR::WillWmDestroy() {
|
||||
// Will not be called if GetNativeView returns NULL.
|
||||
NOTREACHED();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN) && defined(USE_AURA)
|
||||
void CefRenderWidgetHostViewOSR::SetParentNativeViewAccessible(
|
||||
gfx::NativeViewAccessible accessible_parent) {
|
||||
}
|
||||
|
||||
gfx::NativeViewId
|
||||
CefRenderWidgetHostViewOSR::GetParentForWindowlessPlugin() const {
|
||||
if (browser_impl_.get()) {
|
||||
return reinterpret_cast<gfx::NativeViewId>(
|
||||
browser_impl_->GetWindowHandle());
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif // defined(OS_WIN) && defined(USE_AURA)
|
||||
|
||||
void CefRenderWidgetHostViewOSR::GetScreenInfo(blink::WebScreenInfo* results) {
|
||||
if (!browser_impl_.get())
|
||||
return;
|
||||
|
||||
CefScreenInfo screen_info(
|
||||
kDefaultScaleFactor, 0, 0, false, CefRect(), CefRect());
|
||||
|
||||
CefRefPtr<CefRenderHandler> handler =
|
||||
browser_impl_->client()->GetRenderHandler();
|
||||
if (!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) {
|
||||
// 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;
|
||||
if (!handler->GetViewRect(browser_impl_.get(), screenRect)) {
|
||||
NOTREACHED();
|
||||
screenRect = CefRect();
|
||||
}
|
||||
|
||||
if (screen_info.rect.width == 0 && screen_info.rect.height == 0)
|
||||
screen_info.rect = screenRect;
|
||||
|
||||
if (screen_info.available_rect.width == 0 &&
|
||||
screen_info.available_rect.height == 0)
|
||||
screen_info.available_rect = screenRect;
|
||||
}
|
||||
|
||||
*results = webScreenInfoFrom(screen_info);
|
||||
}
|
||||
|
||||
gfx::Rect CefRenderWidgetHostViewOSR::GetBoundsInRootWindow() {
|
||||
if (!browser_impl_.get())
|
||||
return gfx::Rect();
|
||||
CefRect rc;
|
||||
if (browser_impl_->GetClient()->GetRenderHandler()->GetRootScreenRect(
|
||||
browser_impl_->GetBrowser(), rc)) {
|
||||
return gfx::Rect(rc.x, rc.y, rc.width, rc.height);
|
||||
}
|
||||
return gfx::Rect();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::CreateBrowserAccessibilityManagerIfNeeded() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Destroy() {
|
||||
if (IsPopupWidget()) {
|
||||
if (parent_host_view_)
|
||||
parent_host_view_->CancelWidget();
|
||||
} else {
|
||||
CancelWidget();
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetTooltipText(
|
||||
const base::string16& tooltip_text) {
|
||||
if (!browser_impl_.get())
|
||||
return;
|
||||
|
||||
CefString tooltip(tooltip_text);
|
||||
CefRefPtr<CefDisplayHandler> handler =
|
||||
browser_impl_->GetClient()->GetDisplayHandler();
|
||||
if (handler.get()) {
|
||||
handler->OnTooltip(browser_impl_->GetBrowser(), tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SelectionBoundsChanged(
|
||||
const ViewHostMsg_SelectionBounds_Params& params) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ScrollOffsetChanged() {
|
||||
if (!browser_impl_.get())
|
||||
return;
|
||||
browser_impl_->GetClient()->GetRenderHandler()->
|
||||
OnScrollOffsetChanged(browser_impl_.get());
|
||||
}
|
||||
|
||||
content::BackingStore* CefRenderWidgetHostViewOSR::AllocBackingStore(
|
||||
const gfx::Size& size) {
|
||||
return render_widget_host_ ?
|
||||
new BackingStoreOSR(render_widget_host_, size, GetDeviceScaleFactor()) :
|
||||
NULL;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::CopyFromCompositingSurface(
|
||||
const gfx::Rect& src_subrect,
|
||||
const gfx::Size& dst_size,
|
||||
const base::Callback<void(bool, const SkBitmap&)>& callback,
|
||||
const SkBitmap::Config config) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::CopyFromCompositingSurfaceToVideoFrame(
|
||||
const gfx::Rect& src_subrect,
|
||||
const scoped_refptr<media::VideoFrame>& target,
|
||||
const base::Callback<void(bool)>& callback) {
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::CanCopyToVideoFrame() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::OnAcceleratedCompositingStateChange() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::AcceleratedSurfaceInitialized(
|
||||
int host_id, int route_id) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetScrollOffsetPinning(
|
||||
bool is_pinned_to_left, bool is_pinned_to_right) {
|
||||
}
|
||||
|
||||
gfx::GLSurfaceHandle CefRenderWidgetHostViewOSR::GetCompositingSurface() {
|
||||
return gfx::GLSurfaceHandle();
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::AcceleratedSurfaceBuffersSwapped(
|
||||
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
|
||||
int gpu_host_id) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::AcceleratedSurfacePostSubBuffer(
|
||||
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
|
||||
int gpu_host_id) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::AcceleratedSurfaceSuspend() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::AcceleratedSurfaceRelease() {
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::HasAcceleratedSurface(
|
||||
const gfx::Size& desired_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::LockMouse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::UnlockMouse() {
|
||||
}
|
||||
|
||||
#if defined(OS_WIN) && !defined(USE_AURA)
|
||||
void CefRenderWidgetHostViewOSR::SetClickthroughRegion(SkRegion* region) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetBackground(const SkBitmap& background) {
|
||||
if (!render_widget_host_)
|
||||
return;
|
||||
RenderWidgetHostViewBase::SetBackground(background);
|
||||
render_widget_host_->SetBackground(background);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Invalidate(const gfx::Rect& rect,
|
||||
CefBrowserHost::PaintElementType type) {
|
||||
TRACE_EVENT1("libcef", "CefRenderWidgetHostViewOSR::Invalidate", "type", type);
|
||||
if (!IsPopupWidget() && type == PET_POPUP) {
|
||||
if (popup_host_view_)
|
||||
popup_host_view_->Invalidate(rect, type);
|
||||
return;
|
||||
}
|
||||
std::vector<gfx::Rect> dirtyRects;
|
||||
dirtyRects.push_back(rect);
|
||||
Paint(dirtyRects);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::Paint(
|
||||
const std::vector<gfx::Rect>& copy_rects) {
|
||||
TRACE_EVENT1("libcef", "CefRenderWidgetHostViewOSR::Paint", "rects", copy_rects.size());
|
||||
if (about_to_validate_and_paint_ ||
|
||||
!browser_impl_.get() ||
|
||||
!render_widget_host_) {
|
||||
pending_update_rects_.insert(pending_update_rects_.end(),
|
||||
copy_rects.begin(), copy_rects.end());
|
||||
return;
|
||||
}
|
||||
|
||||
about_to_validate_and_paint_ = true;
|
||||
BackingStoreOSR* backing_store =
|
||||
BackingStoreOSR::From(render_widget_host_->GetBackingStore(true));
|
||||
about_to_validate_and_paint_ = false;
|
||||
|
||||
if (backing_store) {
|
||||
const gfx::Rect client_rect(backing_store->size());
|
||||
SkRegion damaged_rgn;
|
||||
|
||||
for (size_t i = 0; i < copy_rects.size(); ++i) {
|
||||
SkIRect skRect = SkIRect::MakeLTRB(
|
||||
copy_rects[i].x(), copy_rects[i].y(),
|
||||
copy_rects[i].right(), copy_rects[i].bottom());
|
||||
damaged_rgn.op(skRect, SkRegion::kUnion_Op);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < pending_update_rects_.size(); ++i) {
|
||||
SkIRect skRect = SkIRect::MakeLTRB(
|
||||
pending_update_rects_[i].x(), pending_update_rects_[i].y(),
|
||||
pending_update_rects_[i].right(), pending_update_rects_[i].bottom());
|
||||
damaged_rgn.op(skRect, SkRegion::kUnion_Op);
|
||||
}
|
||||
pending_update_rects_.clear();
|
||||
|
||||
CefRenderHandler::RectList rcList;
|
||||
SkRegion::Cliperator iterator(damaged_rgn,
|
||||
SkIRect::MakeWH(client_rect.width(), client_rect.height()));
|
||||
for (; !iterator.done(); iterator.next()) {
|
||||
const SkIRect& r = iterator.rect();
|
||||
rcList.push_back(
|
||||
CefRect(r.left(), r.top(), r.width(), r.height()));
|
||||
}
|
||||
|
||||
if (rcList.size() == 0)
|
||||
return;
|
||||
|
||||
browser_impl_->GetClient()->GetRenderHandler()->OnPaint(
|
||||
browser_impl_->GetBrowser(),
|
||||
IsPopupWidget() ? PET_POPUP : PET_VIEW,
|
||||
rcList,
|
||||
backing_store->getPixels(),
|
||||
client_rect.width(),
|
||||
client_rect.height());
|
||||
}
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::InstallTransparency() {
|
||||
if (browser_impl_.get() && browser_impl_->IsTransparent()) {
|
||||
SkBitmap bg;
|
||||
bg.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); // 1x1 alpha bitmap.
|
||||
bg.allocPixels();
|
||||
bg.eraseARGB(0x00, 0x00, 0x00, 0x00);
|
||||
SetBackground(bg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::CancelWidget() {
|
||||
if (IsPopupWidget()) {
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->LostCapture();
|
||||
|
||||
if (browser_impl_.get()) {
|
||||
NotifyHideWidget();
|
||||
browser_impl_ = NULL;
|
||||
}
|
||||
|
||||
if (parent_host_view_) {
|
||||
parent_host_view_->set_popup_host_view(NULL);
|
||||
parent_host_view_ = NULL;
|
||||
}
|
||||
|
||||
if (!weak_factory_.HasWeakPtrs()) {
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE,
|
||||
base::Bind(&CefRenderWidgetHostViewOSR::ShutdownHost,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
} else if (popup_host_view_) {
|
||||
popup_host_view_->CancelWidget();
|
||||
}
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::NotifyShowWidget() {
|
||||
if (browser_impl_.get()) {
|
||||
browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow(
|
||||
browser_impl_->GetBrowser(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::NotifyHideWidget() {
|
||||
if (browser_impl_.get()) {
|
||||
browser_impl_->GetClient()->GetRenderHandler()->OnPopupShow(
|
||||
browser_impl_->GetBrowser(), false);
|
||||
}
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::NotifySizeWidget() {
|
||||
if (browser_impl_.get()) {
|
||||
CefRect widget_pos(popup_position_.x(), popup_position_.y(),
|
||||
popup_position_.width(), popup_position_.height());
|
||||
browser_impl_->GetClient()->GetRenderHandler()->OnPopupSize(
|
||||
browser_impl_->GetBrowser(), widget_pos);
|
||||
}
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl>
|
||||
CefRenderWidgetHostViewOSR::get_browser_impl() const {
|
||||
return browser_impl_;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::set_browser_impl(
|
||||
CefRefPtr<CefBrowserHostImpl> browser) {
|
||||
browser_impl_ = browser;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::set_popup_host_view(
|
||||
CefRenderWidgetHostViewOSR* popup_view) {
|
||||
popup_host_view_ = popup_view;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ShutdownHost() {
|
||||
weak_factory_.InvalidateWeakPtrs();
|
||||
if (render_widget_host_)
|
||||
render_widget_host_->Shutdown();
|
||||
// Do not touch any members at this point, |this| has been deleted.
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::set_parent_host_view(
|
||||
CefRenderWidgetHostViewOSR* parent_view) {
|
||||
parent_host_view_ = parent_view;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SendKeyEvent(
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendKeyEvent");
|
||||
if (!render_widget_host_)
|
||||
return;
|
||||
render_widget_host_->ForwardKeyboardEvent(event);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SendMouseEvent(
|
||||
const blink::WebMouseEvent& event) {
|
||||
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseEvent");
|
||||
if (!IsPopupWidget() && popup_host_view_) {
|
||||
if (popup_host_view_->popup_position_.Contains(event.x, event.y)) {
|
||||
blink::WebMouseEvent popup_event(event);
|
||||
popup_event.x -= popup_host_view_->popup_position_.x();
|
||||
popup_event.y -= popup_host_view_->popup_position_.y();
|
||||
popup_event.windowX = popup_event.x;
|
||||
popup_event.windowY = popup_event.y;
|
||||
|
||||
popup_host_view_->SendMouseEvent(popup_event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!render_widget_host_)
|
||||
return;
|
||||
render_widget_host_->ForwardMouseEvent(event);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SendMouseWheelEvent(
|
||||
const blink::WebMouseWheelEvent& event) {
|
||||
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendMouseWheelEvent");
|
||||
if (!IsPopupWidget() && popup_host_view_) {
|
||||
if (popup_host_view_->popup_position_.Contains(event.x, event.y)) {
|
||||
blink::WebMouseWheelEvent popup_event(event);
|
||||
popup_event.x -= popup_host_view_->popup_position_.x();
|
||||
popup_event.y -= popup_host_view_->popup_position_.y();
|
||||
popup_event.windowX = popup_event.x;
|
||||
popup_event.windowY = popup_event.y;
|
||||
popup_host_view_->SendMouseWheelEvent(popup_event);
|
||||
return;
|
||||
} else {
|
||||
// scrolling outside the popup widget, will destroy widget
|
||||
CancelWidget();
|
||||
}
|
||||
}
|
||||
if (!render_widget_host_)
|
||||
return;
|
||||
render_widget_host_->ForwardWheelEvent(event);
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::OnScreenInfoChanged() {
|
||||
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::OnScreenInfoChanged");
|
||||
if (!render_widget_host_)
|
||||
return;
|
||||
|
||||
BackingStoreOSR* backing_store =
|
||||
BackingStoreOSR::From(render_widget_host_->GetBackingStore(true));
|
||||
if (backing_store)
|
||||
backing_store->ScaleFactorChanged(GetDeviceScaleFactor());
|
||||
|
||||
// What could be taken from UpdateScreenInfo(window_) - updates the renderer
|
||||
// cached rectangles
|
||||
//render_widget_host_->SendScreenRects();
|
||||
|
||||
render_widget_host_->NotifyScreenInfoChanged();
|
||||
// We might want to change the cursor scale factor here as well - see the
|
||||
// cache for the current_cursor_, as passed by UpdateCursor from the renderer
|
||||
// in the rwhv_aura (current_cursor_.SetScaleFactor)
|
||||
}
|
||||
|
||||
float CefRenderWidgetHostViewOSR::GetDeviceScaleFactor() const {
|
||||
if (!browser_impl_.get())
|
||||
return kDefaultScaleFactor;
|
||||
|
||||
CefScreenInfo screen_info(
|
||||
kDefaultScaleFactor, 0, 0, false, CefRect(), CefRect());
|
||||
if (!browser_impl_->GetClient()->GetRenderHandler()->GetScreenInfo(
|
||||
browser_impl_->GetBrowser(), screen_info)) {
|
||||
// Use the default
|
||||
return kDefaultScaleFactor;
|
||||
}
|
||||
|
||||
return screen_info.device_scale_factor;
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool CefRenderWidgetHostViewOSR::PostProcessEventForPluginIme(
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void CefRenderWidgetHostViewOSR::SetActive(bool active) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetTakesFocusOnlyOnMouseDown(bool flag) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SetWindowVisibility(bool visible) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::WindowFrameChanged() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ShowDefinitionForSelection() {
|
||||
}
|
||||
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::SupportsSpeech() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::SpeakSelection() {
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::IsSpeaking() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::StopSpeaking() {
|
||||
}
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
#if defined(TOOLKIT_GTK)
|
||||
GdkEventButton* CefRenderWidgetHostViewOSR::GetLastMouseDown() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gfx::NativeView CefRenderWidgetHostViewOSR::BuildInputMethodsGtkMenu() {
|
||||
return NULL;
|
||||
}
|
||||
#endif // defined(TOOLKIT_GTK)
|
||||
|
@@ -1,259 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
|
||||
#define CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
|
||||
namespace content {
|
||||
class RenderWidgetHost;
|
||||
class BackingStore;
|
||||
}
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class CefWebContentsViewOSR;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CefRenderWidgetHostViewOSR
|
||||
//
|
||||
// An object representing the "View" of a rendered web page. This object is
|
||||
// responsible for sending paint events to the the CefRenderHandler
|
||||
// when window rendering is disabled. It is the implementation of the
|
||||
// RenderWidgetHostView that the cross-platform RenderWidgetHost object uses
|
||||
// to display the data.
|
||||
//
|
||||
// Comment excerpted from render_widget_host.h:
|
||||
//
|
||||
// "The lifetime of the RenderWidgetHostHWND is tied to the render process.
|
||||
// If the render process dies, the RenderWidgetHostHWND goes away and all
|
||||
// references to it must become NULL."
|
||||
//
|
||||
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase {
|
||||
#if defined(OS_MACOSX)
|
||||
public:
|
||||
NSTextInputContext* GetNSTextInputContext();
|
||||
void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent);
|
||||
void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent);
|
||||
|
||||
bool GetCachedFirstRectForCharacterRange(gfx::Range range, gfx::Rect* rect,
|
||||
gfx::Range* actual_range) const;
|
||||
|
||||
private:
|
||||
// Returns composition character boundary rectangle. The |range| is
|
||||
// composition based range. Also stores |actual_range| which is corresponding
|
||||
// to actually used range for returned rectangle.
|
||||
gfx::Rect GetFirstRectForCompositionRange(const gfx::Range& range,
|
||||
gfx::Range* actual_range) const;
|
||||
|
||||
// Converts from given whole character range to composition oriented range. If
|
||||
// the conversion failed, return gfx::Range::InvalidRange.
|
||||
gfx::Range ConvertCharacterRangeToCompositionRange(
|
||||
const gfx::Range& request_range) const;
|
||||
|
||||
// Returns true if there is line break in |range| and stores line breaking
|
||||
// point to |line_breaking_point|. The |line_break_point| is valid only if
|
||||
// this function returns true.
|
||||
static bool GetLineBreakIndex(const std::vector<gfx::Rect>& bounds,
|
||||
const gfx::Range& range,
|
||||
size_t* line_break_point);
|
||||
|
||||
void DestroyNSTextInputOSR();
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
public:
|
||||
// RenderWidgetHostView methods.
|
||||
virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE;
|
||||
virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
|
||||
virtual content::RenderWidgetHost* GetRenderWidgetHost() const OVERRIDE;
|
||||
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
||||
virtual void SetBounds(const gfx::Rect& rect) OVERRIDE;
|
||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||
virtual gfx::NativeViewId GetNativeViewId() const OVERRIDE;
|
||||
virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE;
|
||||
virtual bool HasFocus() const OVERRIDE;
|
||||
virtual bool IsSurfaceAvailableForCopy() const OVERRIDE;
|
||||
virtual void Show() OVERRIDE;
|
||||
virtual void Hide() OVERRIDE;
|
||||
virtual bool IsShowing() OVERRIDE;
|
||||
virtual gfx::Rect GetViewBounds() const OVERRIDE;
|
||||
#if defined(OS_MACOSX)
|
||||
virtual void SetActive(bool active) OVERRIDE;
|
||||
virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE;
|
||||
virtual void SetWindowVisibility(bool visible) OVERRIDE;
|
||||
virtual void WindowFrameChanged() OVERRIDE;
|
||||
virtual void ShowDefinitionForSelection() OVERRIDE;
|
||||
virtual bool SupportsSpeech() const OVERRIDE;
|
||||
virtual void SpeakSelection() OVERRIDE;
|
||||
virtual bool IsSpeaking() const OVERRIDE;
|
||||
virtual void StopSpeaking() OVERRIDE;
|
||||
#endif // defined(OS_MACOSX)
|
||||
#if defined(TOOLKIT_GTK)
|
||||
virtual GdkEventButton* GetLastMouseDown() OVERRIDE;
|
||||
virtual gfx::NativeView BuildInputMethodsGtkMenu() OVERRIDE;
|
||||
#endif // defined(TOOLKIT_GTK)
|
||||
|
||||
// RenderWidgetHostViewPort methods.
|
||||
virtual void InitAsPopup(RenderWidgetHostView* parent_host_view,
|
||||
const gfx::Rect& pos) OVERRIDE;
|
||||
virtual void InitAsFullscreen(
|
||||
RenderWidgetHostView* reference_host_view) OVERRIDE;
|
||||
virtual void WasShown() OVERRIDE;
|
||||
virtual void WasHidden() OVERRIDE;
|
||||
virtual void MovePluginWindows(
|
||||
const gfx::Vector2d& scroll_offset,
|
||||
const std::vector<content::WebPluginGeometry>& moves) OVERRIDE;
|
||||
virtual void Focus() OVERRIDE;
|
||||
virtual void Blur() OVERRIDE;
|
||||
virtual void UpdateCursor(const content::WebCursor& cursor) OVERRIDE;
|
||||
virtual void SetIsLoading(bool is_loading) OVERRIDE;
|
||||
virtual void TextInputTypeChanged(ui::TextInputType type,
|
||||
ui::TextInputMode mode,
|
||||
bool can_compose_inline) OVERRIDE;
|
||||
virtual void ImeCancelComposition() OVERRIDE;
|
||||
#if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
|
||||
virtual void ImeCompositionRangeChanged(
|
||||
const gfx::Range& range,
|
||||
const std::vector<gfx::Rect>& character_bounds) OVERRIDE;
|
||||
#endif
|
||||
virtual void DidUpdateBackingStore(
|
||||
const gfx::Rect& scroll_rect,
|
||||
const gfx::Vector2d& scroll_delta,
|
||||
const std::vector<gfx::Rect>& copy_rects,
|
||||
const std::vector<ui::LatencyInfo>& latency_info) OVERRIDE;
|
||||
virtual void RenderProcessGone(base::TerminationStatus status,
|
||||
int error_code) OVERRIDE;
|
||||
#if defined(OS_WIN) && !defined(USE_AURA)
|
||||
virtual void WillWmDestroy() OVERRIDE;
|
||||
#endif
|
||||
#if defined(OS_WIN) && defined(USE_AURA)
|
||||
virtual void SetParentNativeViewAccessible(
|
||||
gfx::NativeViewAccessible accessible_parent) OVERRIDE;
|
||||
virtual gfx::NativeViewId GetParentForWindowlessPlugin() const OVERRIDE;
|
||||
#endif
|
||||
virtual void GetScreenInfo(blink::WebScreenInfo* results) OVERRIDE;
|
||||
virtual gfx::Rect GetBoundsInRootWindow() OVERRIDE;
|
||||
virtual void CreateBrowserAccessibilityManagerIfNeeded() OVERRIDE;
|
||||
virtual void Destroy() OVERRIDE;
|
||||
virtual void SetTooltipText(const base::string16& tooltip_text) OVERRIDE;
|
||||
virtual void SelectionBoundsChanged(
|
||||
const ViewHostMsg_SelectionBounds_Params& params) OVERRIDE;
|
||||
virtual void ScrollOffsetChanged() OVERRIDE;
|
||||
virtual content::BackingStore*
|
||||
AllocBackingStore(const gfx::Size& size) OVERRIDE;
|
||||
virtual void CopyFromCompositingSurface(
|
||||
const gfx::Rect& src_subrect,
|
||||
const gfx::Size& dst_size,
|
||||
const base::Callback<void(bool, const SkBitmap&)>& callback,
|
||||
const SkBitmap::Config config) OVERRIDE;
|
||||
virtual void CopyFromCompositingSurfaceToVideoFrame(
|
||||
const gfx::Rect& src_subrect,
|
||||
const scoped_refptr<media::VideoFrame>& target,
|
||||
const base::Callback<void(bool)>& callback) OVERRIDE;
|
||||
virtual bool CanCopyToVideoFrame() const OVERRIDE;
|
||||
virtual void OnAcceleratedCompositingStateChange() OVERRIDE;
|
||||
virtual void AcceleratedSurfaceInitialized(
|
||||
int host_id, int route_id) OVERRIDE;
|
||||
virtual void SetHasHorizontalScrollbar(
|
||||
bool has_horizontal_scrollbar) OVERRIDE;
|
||||
virtual void SetScrollOffsetPinning(
|
||||
bool is_pinned_to_left, bool is_pinned_to_right) OVERRIDE;
|
||||
virtual gfx::GLSurfaceHandle GetCompositingSurface() OVERRIDE;
|
||||
virtual void AcceleratedSurfaceBuffersSwapped(
|
||||
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
|
||||
int gpu_host_id) OVERRIDE;
|
||||
virtual void AcceleratedSurfacePostSubBuffer(
|
||||
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
|
||||
int gpu_host_id) OVERRIDE;
|
||||
virtual void AcceleratedSurfaceSuspend() OVERRIDE;
|
||||
virtual void AcceleratedSurfaceRelease() OVERRIDE;
|
||||
virtual bool HasAcceleratedSurface(const gfx::Size& desired_size) OVERRIDE;
|
||||
virtual bool LockMouse() OVERRIDE;
|
||||
virtual void UnlockMouse() OVERRIDE;
|
||||
|
||||
#if defined(OS_WIN) && !defined(USE_AURA)
|
||||
virtual void SetClickthroughRegion(SkRegion* region) OVERRIDE;
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
virtual bool PostProcessEventForPluginIme(
|
||||
const content::NativeWebKeyboardEvent& event) OVERRIDE;
|
||||
#endif
|
||||
|
||||
// RenderWidgetHostViewBase methods.
|
||||
virtual void SetBackground(const SkBitmap& background) OVERRIDE;
|
||||
|
||||
void SendKeyEvent(const content::NativeWebKeyboardEvent& event);
|
||||
void SendMouseEvent(const blink::WebMouseEvent& event);
|
||||
void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event);
|
||||
|
||||
void Invalidate(const gfx::Rect& rect,
|
||||
CefBrowserHost::PaintElementType type);
|
||||
void Paint(const std::vector<gfx::Rect>& copy_rects);
|
||||
bool InstallTransparency();
|
||||
|
||||
void OnScreenInfoChanged();
|
||||
float GetDeviceScaleFactor() const;
|
||||
|
||||
void CancelWidget();
|
||||
void NotifyShowWidget();
|
||||
void NotifyHideWidget();
|
||||
void NotifySizeWidget();
|
||||
|
||||
content::RenderWidgetHostImpl* get_render_widget_host_impl() const
|
||||
{ return render_widget_host_; }
|
||||
CefRefPtr<CefBrowserHostImpl> get_browser_impl() const;
|
||||
void set_browser_impl(CefRefPtr<CefBrowserHostImpl> browser);
|
||||
void set_popup_host_view(CefRenderWidgetHostViewOSR* popup_view);
|
||||
void set_parent_host_view(CefRenderWidgetHostViewOSR* parent_view);
|
||||
|
||||
bool IsPopupWidget() const {
|
||||
return popup_type_ != blink::WebPopupTypeNone;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class CefWebContentsViewOSR;
|
||||
|
||||
explicit CefRenderWidgetHostViewOSR(content::RenderWidgetHost* widget);
|
||||
virtual ~CefRenderWidgetHostViewOSR();
|
||||
|
||||
// After calling this function, object gets deleted
|
||||
void ShutdownHost();
|
||||
|
||||
// Factory used to safely scope delayed calls to ShutdownHost().
|
||||
base::WeakPtrFactory<CefRenderWidgetHostViewOSR> weak_factory_;
|
||||
|
||||
// The associated Model. While |this| is being Destroyed,
|
||||
// |render_widget_host_| is NULL and the Windows message loop is run one last
|
||||
// time. Message handlers must check for a NULL |render_widget_host_|.
|
||||
content::RenderWidgetHostImpl* render_widget_host_;
|
||||
CefRenderWidgetHostViewOSR* parent_host_view_;
|
||||
CefRenderWidgetHostViewOSR* popup_host_view_;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser_impl_;
|
||||
|
||||
bool about_to_validate_and_paint_;
|
||||
std::vector<gfx::Rect> pending_update_rects_;
|
||||
|
||||
gfx::Rect popup_position_;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
NSTextInputContext* text_input_context_osr_mac_;
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefRenderWidgetHostViewOSR);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_RENDER_WIDGET_HOST_VIEW_OSR_H_
|
@@ -1,209 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||
#include "libcef/browser/text_input_client_osr_mac.h"
|
||||
|
||||
static CefTextInputClientOSRMac* GetInputClientFromContext(
|
||||
const NSTextInputContext* context) {
|
||||
if (!context)
|
||||
return NULL;
|
||||
return reinterpret_cast<CefTextInputClientOSRMac*>([context client]);
|
||||
}
|
||||
|
||||
CefTextInputContext CefRenderWidgetHostViewOSR::GetNSTextInputContext() {
|
||||
if (!text_input_context_osr_mac_) {
|
||||
CefTextInputClientOSRMac* text_input_client_osr_mac =
|
||||
[[CefTextInputClientOSRMac alloc] initWithRenderWidgetHostViewOSR:
|
||||
this];
|
||||
|
||||
text_input_context_osr_mac_ = [[NSTextInputContext alloc] initWithClient:
|
||||
text_input_client_osr_mac];
|
||||
}
|
||||
|
||||
return text_input_context_osr_mac_;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::HandleKeyEventBeforeTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
if (client)
|
||||
[client HandleKeyEventBeforeTextInputClient: keyEvent];
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::HandleKeyEventAfterTextInputClient(
|
||||
CefEventHandle keyEvent) {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
if (client)
|
||||
[client HandleKeyEventAfterTextInputClient: keyEvent];
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::DestroyNSTextInputOSR() {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
if (client) {
|
||||
[client release];
|
||||
client = NULL;
|
||||
}
|
||||
|
||||
[text_input_context_osr_mac_ release];
|
||||
text_input_context_osr_mac_ = NULL;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ImeCompositionRangeChanged(
|
||||
const gfx::Range& range,
|
||||
const std::vector<gfx::Rect>& character_bounds) {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
if (!client)
|
||||
return;
|
||||
|
||||
client->markedRange_ = range.ToNSRange();
|
||||
client->composition_range_ = range;
|
||||
client->composition_bounds_ = character_bounds;
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
if (client)
|
||||
[client cancelComposition];
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::TextInputTypeChanged(
|
||||
ui::TextInputType type,
|
||||
ui::TextInputMode mode,
|
||||
bool can_compose_inline) {
|
||||
[NSApp updateWindows];
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::GetLineBreakIndex(
|
||||
const std::vector<gfx::Rect>& bounds,
|
||||
const gfx::Range& range,
|
||||
size_t* line_break_point) {
|
||||
DCHECK(line_break_point);
|
||||
if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty())
|
||||
return false;
|
||||
|
||||
// We can't check line breaking completely from only rectangle array. Thus we
|
||||
// assume the line breaking as the next character's y offset is larger than
|
||||
// a threshold. Currently the threshold is determined as minimum y offset plus
|
||||
// 75% of maximum height.
|
||||
const size_t loop_end_idx = std::min(bounds.size(), range.end());
|
||||
int max_height = 0;
|
||||
int min_y_offset = kint32max;
|
||||
for (size_t idx = range.start(); idx < loop_end_idx; ++idx) {
|
||||
max_height = std::max(max_height, bounds[idx].height());
|
||||
min_y_offset = std::min(min_y_offset, bounds[idx].y());
|
||||
}
|
||||
int line_break_threshold = min_y_offset + (max_height * 3 / 4);
|
||||
for (size_t idx = range.start(); idx < loop_end_idx; ++idx) {
|
||||
if (bounds[idx].y() > line_break_threshold) {
|
||||
*line_break_point = idx;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
gfx::Rect CefRenderWidgetHostViewOSR::GetFirstRectForCompositionRange(
|
||||
const gfx::Range& range, gfx::Range* actual_range) const {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
|
||||
DCHECK(client);
|
||||
DCHECK(actual_range);
|
||||
DCHECK(!client->composition_bounds_.empty());
|
||||
DCHECK_LE(range.start(), client->composition_bounds_.size());
|
||||
DCHECK_LE(range.end(), client->composition_bounds_.size());
|
||||
|
||||
if (range.is_empty()) {
|
||||
*actual_range = range;
|
||||
if (range.start() == client->composition_bounds_.size()) {
|
||||
return gfx::Rect(client->composition_bounds_[range.start() - 1].right(),
|
||||
client->composition_bounds_[range.start() - 1].y(),
|
||||
0,
|
||||
client->composition_bounds_[range.start() - 1].height());
|
||||
} else {
|
||||
return gfx::Rect(client->composition_bounds_[range.start()].x(),
|
||||
client->composition_bounds_[range.start()].y(),
|
||||
0,
|
||||
client->composition_bounds_[range.start()].height());
|
||||
}
|
||||
}
|
||||
|
||||
size_t end_idx;
|
||||
if (!GetLineBreakIndex(client->composition_bounds_,
|
||||
range, &end_idx)) {
|
||||
end_idx = range.end();
|
||||
}
|
||||
*actual_range = gfx::Range(range.start(), end_idx);
|
||||
gfx::Rect rect = client->composition_bounds_[range.start()];
|
||||
for (size_t i = range.start() + 1; i < end_idx; ++i) {
|
||||
rect.Union(client->composition_bounds_[i]);
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
gfx::Range CefRenderWidgetHostViewOSR::ConvertCharacterRangeToCompositionRange(
|
||||
const gfx::Range& request_range) const {
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
DCHECK(client);
|
||||
|
||||
if (client->composition_range_.is_empty())
|
||||
return gfx::Range::InvalidRange();
|
||||
|
||||
if (request_range.is_reversed())
|
||||
return gfx::Range::InvalidRange();
|
||||
|
||||
if (request_range.start() < client->composition_range_.start()
|
||||
|| request_range.start() > client->composition_range_.end()
|
||||
|| request_range.end() > client->composition_range_.end())
|
||||
return gfx::Range::InvalidRange();
|
||||
|
||||
return gfx::Range(request_range.start() - client->composition_range_.start(),
|
||||
request_range.end() - client->composition_range_.start());
|
||||
}
|
||||
|
||||
bool CefRenderWidgetHostViewOSR::GetCachedFirstRectForCharacterRange(
|
||||
gfx::Range range, gfx::Rect* rect, gfx::Range* actual_range) const {
|
||||
DCHECK(rect);
|
||||
CefTextInputClientOSRMac* client = GetInputClientFromContext(
|
||||
text_input_context_osr_mac_);
|
||||
|
||||
// If requested range is same as caret location, we can just return it.
|
||||
if (selection_range_.is_empty() && gfx::Range(range) == selection_range_) {
|
||||
if (actual_range)
|
||||
*actual_range = range;
|
||||
*rect = client->caret_rect_;
|
||||
return true;
|
||||
}
|
||||
|
||||
const gfx::Range request_range_in_composition =
|
||||
ConvertCharacterRangeToCompositionRange(gfx::Range(range));
|
||||
if (request_range_in_composition == gfx::Range::InvalidRange())
|
||||
return false;
|
||||
|
||||
// If firstRectForCharacterRange in WebFrame is failed in renderer,
|
||||
// ImeCompositionRangeChanged will be sent with empty vector.
|
||||
if (client->composition_bounds_.empty())
|
||||
return false;
|
||||
|
||||
DCHECK_EQ(client->composition_bounds_.size(),
|
||||
client->composition_range_.length());
|
||||
|
||||
gfx::Range ui_actual_range;
|
||||
*rect = GetFirstRectForCompositionRange(request_range_in_composition,
|
||||
&ui_actual_range);
|
||||
if (actual_range) {
|
||||
*actual_range = gfx::Range(
|
||||
client->composition_range_.start() + ui_actual_range.start(),
|
||||
client->composition_range_.start() + ui_actual_range.end()).ToNSRange();
|
||||
}
|
||||
return true;
|
||||
}
|
@@ -1,89 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_TEXT_INPUT_CLIENT_OSR_MAC_H_
|
||||
#define CEF_LIBCEF_BROWSER_TEXT_INPUT_CLIENT_OSR_MAC_H_
|
||||
#pragma once
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <vector>
|
||||
|
||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/common/edit_command.h"
|
||||
#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
|
||||
|
||||
// Implementation for the NSTextInputClient protocol used for enabling IME on
|
||||
// mac when window rendering is disabled.
|
||||
|
||||
@interface CefTextInputClientOSRMac : NSObject<NSTextInputClient> {
|
||||
|
||||
@public
|
||||
// The range of current marked text inside the whole content of the DOM node
|
||||
// being edited.
|
||||
NSRange markedRange_;
|
||||
|
||||
// The current composition character range and its bounds.
|
||||
gfx::Range composition_range_;
|
||||
std::vector<gfx::Rect> composition_bounds_;
|
||||
|
||||
// The current caret bounds.
|
||||
gfx::Rect caret_rect_;
|
||||
|
||||
@private
|
||||
// Represents the input-method attributes supported by this object.
|
||||
base::scoped_nsobject<NSArray> validAttributesForMarkedText_;
|
||||
|
||||
// Indicates if we are currently handling a key down event.
|
||||
BOOL handlingKeyDown_;
|
||||
|
||||
// Indicates if there is any marked text.
|
||||
BOOL hasMarkedText_;
|
||||
|
||||
// Indicates whether there was any marked text prior to handling
|
||||
// the current key event.
|
||||
BOOL oldHasMarkedText_;
|
||||
|
||||
// Indicates if unmarkText is called or not when handling a keyboard
|
||||
// event.
|
||||
BOOL unmarkTextCalled_;
|
||||
|
||||
// The selected range, cached from a message sent by the renderer.
|
||||
NSRange selectedRange_;
|
||||
|
||||
// Text to be inserted which was generated by handling a key down event.
|
||||
base::string16 textToBeInserted_;
|
||||
|
||||
// Marked text which was generated by handling a key down event.
|
||||
base::string16 markedText_;
|
||||
|
||||
// Underline information of the |markedText_|.
|
||||
std::vector<blink::WebCompositionUnderline> underlines_;
|
||||
|
||||
// Indicates if doCommandBySelector method receives any edit command when
|
||||
// handling a key down event.
|
||||
BOOL hasEditCommands_;
|
||||
|
||||
// Contains edit commands received by the -doCommandBySelector: method when
|
||||
// handling a key down event, not including inserting commands, eg. insertTab,
|
||||
// etc.
|
||||
content::EditCommands editCommands_;
|
||||
|
||||
CefRenderWidgetHostViewOSR* renderWidgetHostView_;
|
||||
}
|
||||
|
||||
@property(nonatomic, readonly) NSRange selectedRange;
|
||||
@property(nonatomic) BOOL handlingKeyDown;
|
||||
|
||||
- (id)initWithRenderWidgetHostViewOSR:(CefRenderWidgetHostViewOSR*) rwhv;
|
||||
- (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent;
|
||||
- (void)HandleKeyEventAfterTextInputClient:(NSEvent*)keyEvent;
|
||||
- (void)cancelComposition;
|
||||
|
||||
@end
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_TEXT_INPUT_CLIENT_OSR_MAC_H_
|
@@ -1,362 +0,0 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/text_input_client_osr_mac.h"
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.h"
|
||||
#import "content/browser/renderer_host/text_input_client_mac.h"
|
||||
#include "content/common/input_messages.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO(suzhe): Upstream this function.
|
||||
blink::WebColor WebColorFromNSColor(NSColor *color) {
|
||||
CGFloat r, g, b, a;
|
||||
[color getRed:&r green:&g blue:&b alpha:&a];
|
||||
|
||||
return
|
||||
std::max(0, std::min(static_cast<int>(lroundf(255.0f * a)), 255)) << 24 |
|
||||
std::max(0, std::min(static_cast<int>(lroundf(255.0f * r)), 255)) << 16 |
|
||||
std::max(0, std::min(static_cast<int>(lroundf(255.0f * g)), 255)) << 8 |
|
||||
std::max(0, std::min(static_cast<int>(lroundf(255.0f * b)), 255));
|
||||
}
|
||||
|
||||
// Extract underline information from an attributed string. Mostly copied from
|
||||
// third_party/WebKit/Source/WebKit/mac/WebView/WebHTMLView.mm
|
||||
void ExtractUnderlines(NSAttributedString* string,
|
||||
std::vector<blink::WebCompositionUnderline>* underlines) {
|
||||
int length = [[string string] length];
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
NSRange range;
|
||||
NSDictionary* attrs = [string attributesAtIndex:i
|
||||
longestEffectiveRange:&range
|
||||
inRange:NSMakeRange(i, length - i)];
|
||||
NSNumber *style = [attrs objectForKey: NSUnderlineStyleAttributeName];
|
||||
if (style) {
|
||||
blink::WebColor color = SK_ColorBLACK;
|
||||
if (NSColor *colorAttr =
|
||||
[attrs objectForKey:NSUnderlineColorAttributeName]) {
|
||||
color = WebColorFromNSColor(
|
||||
[colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
|
||||
}
|
||||
underlines->push_back(blink::WebCompositionUnderline(
|
||||
range.location, NSMaxRange(range), color, [style intValue] > 1));
|
||||
}
|
||||
i = range.location + range.length;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" {
|
||||
extern NSString* NSTextInputReplacementRangeAttributeName;
|
||||
}
|
||||
|
||||
@implementation CefTextInputClientOSRMac
|
||||
|
||||
@synthesize selectedRange = selectedRange_;
|
||||
@synthesize handlingKeyDown = handlingKeyDown_;
|
||||
|
||||
- (id)initWithRenderWidgetHostViewOSR:(CefRenderWidgetHostViewOSR*)rwhv {
|
||||
self = [super init];
|
||||
renderWidgetHostView_ = rwhv;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray*)validAttributesForMarkedText {
|
||||
if (!validAttributesForMarkedText_) {
|
||||
validAttributesForMarkedText_.reset([[NSArray alloc] initWithObjects:
|
||||
NSUnderlineStyleAttributeName,
|
||||
NSUnderlineColorAttributeName,
|
||||
NSMarkedClauseSegmentAttributeName,
|
||||
NSTextInputReplacementRangeAttributeName,
|
||||
nil]);
|
||||
}
|
||||
return validAttributesForMarkedText_.get();
|
||||
}
|
||||
|
||||
- (NSRange)markedRange {
|
||||
return hasMarkedText_ ? markedRange_ : NSMakeRange(NSNotFound, 0);
|
||||
}
|
||||
|
||||
- (BOOL)hasMarkedText {
|
||||
return hasMarkedText_;
|
||||
}
|
||||
|
||||
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange {
|
||||
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
|
||||
NSString* im_text = isAttributedString ? [aString string] : aString;
|
||||
if (handlingKeyDown_) {
|
||||
textToBeInserted_.append(base::SysNSStringToUTF16(im_text));
|
||||
} else {
|
||||
gfx::Range replacement_range(replacementRange);
|
||||
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->ImeConfirmComposition(
|
||||
base::SysNSStringToUTF16(im_text), replacement_range, false);
|
||||
}
|
||||
|
||||
// Inserting text will delete all marked text automatically.
|
||||
hasMarkedText_ = NO;
|
||||
}
|
||||
|
||||
- (void)doCommandBySelector:(SEL)aSelector {
|
||||
// An input method calls this function to dispatch an editing command to be
|
||||
// handled by this view.
|
||||
if (aSelector == @selector(noop:))
|
||||
return;
|
||||
std::string command([content::RenderWidgetHostViewMacEditCommandHelper::
|
||||
CommandNameForSelector(aSelector) UTF8String]);
|
||||
|
||||
// If this method is called when handling a key down event, then we need to
|
||||
// handle the command in the key event handler. Otherwise we can just handle
|
||||
// it here.
|
||||
if (handlingKeyDown_) {
|
||||
hasEditCommands_ = YES;
|
||||
// We ignore commands that insert characters, because this was causing
|
||||
// strange behavior (e.g. tab always inserted a tab rather than moving to
|
||||
// the next field on the page).
|
||||
if (!StartsWithASCII(command, "insert", false))
|
||||
editCommands_.push_back(content::EditCommand(command, ""));
|
||||
} else {
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->Send(
|
||||
new InputMsg_ExecuteEditCommand(
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->
|
||||
GetRoutingID(), command, ""));
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setMarkedText:(id)aString selectedRange:(NSRange)newSelRange
|
||||
replacementRange:(NSRange)replacementRange {
|
||||
// An input method updates the composition string.
|
||||
// We send the given text and range to the renderer so it can update the
|
||||
// composition node of WebKit.
|
||||
|
||||
BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
|
||||
NSString* im_text = isAttributedString ? [aString string] : aString;
|
||||
int length = [im_text length];
|
||||
|
||||
// |markedRange_| will get set on a callback from ImeSetComposition().
|
||||
selectedRange_ = newSelRange;
|
||||
markedText_ = base::SysNSStringToUTF16(im_text);
|
||||
hasMarkedText_ = (length > 0);
|
||||
underlines_.clear();
|
||||
|
||||
if (isAttributedString) {
|
||||
ExtractUnderlines(aString, &underlines_);
|
||||
} else {
|
||||
// Use a thin black underline by default.
|
||||
underlines_.push_back(blink::WebCompositionUnderline(0, length,
|
||||
SK_ColorBLACK, false));
|
||||
}
|
||||
|
||||
// If we are handling a key down event, then SetComposition() will be
|
||||
// called in keyEvent: method.
|
||||
// Input methods of Mac use setMarkedText calls with an empty text to cancel
|
||||
// an ongoing composition. So, we should check whether or not the given text
|
||||
// is empty to update the input method state. (Our input method backend can
|
||||
// automatically cancels an ongoing composition when we send an empty text.
|
||||
// So, it is OK to send an empty text to the renderer.)
|
||||
if (!handlingKeyDown_) {
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->ImeSetComposition(
|
||||
markedText_, underlines_, newSelRange.location,
|
||||
NSMaxRange(newSelRange));
|
||||
}
|
||||
}
|
||||
|
||||
- (void)unmarkText {
|
||||
// Delete the composition node of the renderer and finish an ongoing
|
||||
// composition.
|
||||
// It seems an input method calls the setMarkedText method and set an empty
|
||||
// text when it cancels an ongoing composition, i.e. I have never seen an
|
||||
// input method calls this method.
|
||||
hasMarkedText_ = NO;
|
||||
markedText_.clear();
|
||||
underlines_.clear();
|
||||
|
||||
// If we are handling a key down event, then ConfirmComposition() will be
|
||||
// called in keyEvent: method.
|
||||
if (!handlingKeyDown_) {
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->
|
||||
ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(),
|
||||
false);
|
||||
} else {
|
||||
unmarkTextCalled_ = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)range
|
||||
actualRange:(NSRangePointer)actualRange {
|
||||
if (actualRange)
|
||||
*actualRange = range;
|
||||
NSAttributedString* str = content::TextInputClientMac::GetInstance()->
|
||||
GetAttributedSubstringFromRange(
|
||||
renderWidgetHostView_->GetRenderWidgetHost(), range);
|
||||
return str;
|
||||
}
|
||||
|
||||
- (NSRect)firstViewRectForCharacterRange:(NSRange)theRange
|
||||
actualRange:(NSRangePointer)actualRange {
|
||||
NSRect rect;
|
||||
gfx::Rect gfxRect;
|
||||
gfx::Range range(theRange);
|
||||
gfx::Range actual_range;
|
||||
if (!renderWidgetHostView_->GetCachedFirstRectForCharacterRange(range,
|
||||
&gfxRect, &actual_range)) {
|
||||
rect = content::TextInputClientMac::GetInstance()->
|
||||
GetFirstRectForRange(renderWidgetHostView_->GetRenderWidgetHost(),
|
||||
range.ToNSRange());
|
||||
|
||||
if (actualRange)
|
||||
*actualRange = range.ToNSRange();
|
||||
} else {
|
||||
rect = NSRectFromCGRect(gfxRect.ToCGRect());
|
||||
}
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSRect) screenRectFromViewRect:(NSRect)rect {
|
||||
NSRect screenRect;
|
||||
|
||||
int screenX, screenY;
|
||||
renderWidgetHostView_->get_browser_impl()->GetClient()->GetRenderHandler()->
|
||||
GetScreenPoint(renderWidgetHostView_->get_browser_impl()->GetBrowser(),
|
||||
rect.origin.x, rect.origin.y, screenX, screenY);
|
||||
screenRect.origin = NSMakePoint(screenX, screenY);
|
||||
screenRect.size = rect.size;
|
||||
|
||||
return screenRect;
|
||||
}
|
||||
|
||||
- (NSRect)firstRectForCharacterRange:(NSRange)theRange
|
||||
actualRange:(NSRangePointer)actualRange {
|
||||
NSRect rect = [self firstViewRectForCharacterRange:theRange
|
||||
actualRange:actualRange];
|
||||
|
||||
// Convert into screen coordinates for return.
|
||||
rect = [self screenRectFromViewRect:rect];
|
||||
|
||||
if (rect.origin.y >= rect.size.height)
|
||||
rect.origin.y -= rect.size.height;
|
||||
else
|
||||
rect.origin.y = 0;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint {
|
||||
// |thePoint| is in screen coordinates, but needs to be converted to WebKit
|
||||
// coordinates (upper left origin). Scroll offsets will be taken care of in
|
||||
// the renderer.
|
||||
|
||||
CefRect view_rect;
|
||||
renderWidgetHostView_->get_browser_impl()->GetClient()->GetRenderHandler()->
|
||||
GetViewRect(renderWidgetHostView_->get_browser_impl()->GetBrowser(),
|
||||
view_rect);
|
||||
|
||||
thePoint.x -= view_rect.x;
|
||||
thePoint.y -= view_rect.y;
|
||||
thePoint.y = view_rect.height - thePoint.y;
|
||||
|
||||
NSUInteger index = content::TextInputClientMac::GetInstance()->
|
||||
GetCharacterIndexAtPoint(renderWidgetHostView_->GetRenderWidgetHost(),
|
||||
gfx::Point(thePoint.x, thePoint.y));
|
||||
return index;
|
||||
}
|
||||
|
||||
- (void)HandleKeyEventBeforeTextInputClient:(NSEvent*)keyEvent {
|
||||
DCHECK([keyEvent type] == NSKeyDown);
|
||||
// Don't call this method recursively.
|
||||
DCHECK(!handlingKeyDown_);
|
||||
|
||||
oldHasMarkedText_ = hasMarkedText_;
|
||||
handlingKeyDown_ = YES;
|
||||
|
||||
// These variables might be set when handling the keyboard event.
|
||||
// Clear them here so that we can know whether they have changed afterwards.
|
||||
textToBeInserted_.clear();
|
||||
markedText_.clear();
|
||||
underlines_.clear();
|
||||
unmarkTextCalled_ = NO;
|
||||
hasEditCommands_ = NO;
|
||||
editCommands_.clear();
|
||||
}
|
||||
|
||||
- (void)HandleKeyEventAfterTextInputClient:(NSEvent*)keyEvent {
|
||||
handlingKeyDown_ = NO;
|
||||
|
||||
// Then send keypress and/or composition related events.
|
||||
// If there was a marked text or the text to be inserted is longer than 1
|
||||
// character, then we send the text by calling ConfirmComposition().
|
||||
// Otherwise, if the text to be inserted only contains 1 character, then we
|
||||
// can just send a keypress event which is fabricated by changing the type of
|
||||
// the keydown event, so that we can retain all necessary informations, such
|
||||
// as unmodifiedText, etc. And we need to set event.skip_in_browser to true to
|
||||
// prevent the browser from handling it again.
|
||||
// Note that, |textToBeInserted_| is a UTF-16 string, but it's fine to only
|
||||
// handle BMP characters here, as we can always insert non-BMP characters as
|
||||
// text.
|
||||
|
||||
if (!hasMarkedText_ && !oldHasMarkedText_ &&
|
||||
textToBeInserted_.length() <= 1) {
|
||||
content::NativeWebKeyboardEvent event(keyEvent);
|
||||
if (textToBeInserted_.length() == 1) {
|
||||
event.type = blink::WebInputEvent::Type::Char;
|
||||
event.text[0] = textToBeInserted_[0];
|
||||
event.text[1] = 0;
|
||||
}
|
||||
renderWidgetHostView_->SendKeyEvent(event);
|
||||
}
|
||||
|
||||
BOOL textInserted = NO;
|
||||
if (textToBeInserted_.length() >
|
||||
((hasMarkedText_ || oldHasMarkedText_) ? 0u : 1u)) {
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->ImeConfirmComposition(
|
||||
textToBeInserted_, gfx::Range::InvalidRange(), false);
|
||||
textToBeInserted_ = YES;
|
||||
}
|
||||
|
||||
// Updates or cancels the composition. If some text has been inserted, then
|
||||
// we don't need to cancel the composition explicitly.
|
||||
if (hasMarkedText_ && markedText_.length()) {
|
||||
// Sends the updated marked text to the renderer so it can update the
|
||||
// composition node in WebKit.
|
||||
// When marked text is available, |selectedRange_| will be the range being
|
||||
// selected inside the marked text.
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->ImeSetComposition(
|
||||
markedText_, underlines_, selectedRange_.location,
|
||||
NSMaxRange(selectedRange_));
|
||||
} else if (oldHasMarkedText_ && !hasMarkedText_ && !textInserted) {
|
||||
if (unmarkTextCalled_) {
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->
|
||||
ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(),
|
||||
false);
|
||||
} else {
|
||||
renderWidgetHostView_->get_render_widget_host_impl()->
|
||||
ImeCancelComposition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelComposition {
|
||||
if (!hasMarkedText_)
|
||||
return;
|
||||
|
||||
// Cancel the ongoing composition. [NSInputManager markedTextAbandoned:]
|
||||
// doesn't call any NSTextInput functions, such as setMarkedText or
|
||||
// insertText. So, we need to send an IPC message to a renderer so it can
|
||||
// delete the composition node.
|
||||
NSInputManager *currentInputManager = [NSInputManager currentInputManager];
|
||||
[currentInputManager markedTextAbandoned:self];
|
||||
|
||||
hasMarkedText_ = NO;
|
||||
// Should not call [self unmarkText] here, because it'll send unnecessary
|
||||
// cancel composition IPC message to the renderer.
|
||||
}
|
||||
|
||||
@end
|
@@ -1,149 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/render_widget_host_view_osr.h"
|
||||
#include "libcef/browser/web_contents_view_osr.h"
|
||||
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
CefWebContentsViewOSR::CefWebContentsViewOSR(
|
||||
content::WebContents* web_contents,
|
||||
content::WebContentsViewDelegate* delegate)
|
||||
: web_contents_(web_contents),
|
||||
view_(NULL) {
|
||||
}
|
||||
|
||||
CefWebContentsViewOSR::~CefWebContentsViewOSR() {
|
||||
}
|
||||
|
||||
// Overridden from WebContentsView:
|
||||
|
||||
void CefWebContentsViewOSR::CreateView(const gfx::Size& initial_size,
|
||||
gfx::NativeView context) {
|
||||
}
|
||||
|
||||
content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
if (render_widget_host->GetView())
|
||||
return render_widget_host->GetView();
|
||||
|
||||
view_ = new CefRenderWidgetHostViewOSR(render_widget_host);
|
||||
return view_;
|
||||
}
|
||||
|
||||
content::RenderWidgetHostView* CefWebContentsViewOSR::CreateViewForPopupWidget(
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
CefRenderWidgetHostViewOSR* popup_widget =
|
||||
new CefRenderWidgetHostViewOSR(render_widget_host);
|
||||
return popup_widget;
|
||||
}
|
||||
|
||||
gfx::NativeView CefWebContentsViewOSR::GetNativeView() const {
|
||||
return gfx::NativeView();
|
||||
}
|
||||
|
||||
gfx::NativeView CefWebContentsViewOSR::GetContentNativeView() const {
|
||||
return gfx::NativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow CefWebContentsViewOSR::GetTopLevelNativeWindow() const {
|
||||
return gfx::NativeWindow();
|
||||
}
|
||||
|
||||
|
||||
void CefWebContentsViewOSR::GetContainerBounds(gfx::Rect *out) const {
|
||||
*out = GetViewBounds();
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::SetPageTitle(const base::string16& title) {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::OnTabCrashed(base::TerminationStatus status,
|
||||
int error_code) {
|
||||
view_ = NULL;
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::SizeContents(const gfx::Size& size) {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::RenderViewCreated(content::RenderViewHost* host) {
|
||||
if (view_) {
|
||||
CefRenderWidgetHostViewOSR* osr_view =
|
||||
static_cast<CefRenderWidgetHostViewOSR*>(view_);
|
||||
osr_view->InstallTransparency();
|
||||
}
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::RenderViewSwappedIn(content::RenderViewHost* host) {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::SetOverscrollControllerEnabled(bool enabled) {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::Focus() {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::SetInitialFocus() {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::StoreFocus() {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::RestoreFocus() {
|
||||
}
|
||||
|
||||
content::DropData* CefWebContentsViewOSR::GetDropData() const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gfx::Rect CefWebContentsViewOSR::GetViewBounds() const {
|
||||
return view_ ? view_->GetViewBounds() : gfx::Rect();
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool CefWebContentsViewOSR::IsEventTracking() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::CloseTabAfterEventTracking() {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::SetAllowOverlappingViews(bool overlapping) {
|
||||
}
|
||||
|
||||
bool CefWebContentsViewOSR::GetAllowOverlappingViews() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::SetOverlayView(content::WebContentsView* overlay,
|
||||
const gfx::Point& offset) {
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::RemoveOverlayView() {
|
||||
}
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
// RenderViewHostDelegateView methods.
|
||||
|
||||
void CefWebContentsViewOSR::StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info) {
|
||||
// Dragging is not supported when window rendering is disabled.
|
||||
web_contents_->SystemDragEnded();
|
||||
}
|
||||
|
||||
void CefWebContentsViewOSR::ShowPopupMenu(
|
||||
const gfx::Rect& bounds,
|
||||
int item_height,
|
||||
double item_font_size,
|
||||
int selected_item,
|
||||
const std::vector<content::MenuItem>& items,
|
||||
bool right_aligned,
|
||||
bool allow_multiple_selection) {
|
||||
}
|
@@ -1,86 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_
|
||||
#define CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "content/port/browser/render_view_host_delegate_view.h"
|
||||
#include "content/port/browser/web_contents_view_port.h"
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
class WebContentsViewDelegate;
|
||||
}
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
|
||||
// An implementation of WebContentsView for off-screen rendering.
|
||||
class CefWebContentsViewOSR : public content::WebContentsViewPort,
|
||||
public content::RenderViewHostDelegateView {
|
||||
public:
|
||||
CefWebContentsViewOSR(content::WebContents* web_contents,
|
||||
content::WebContentsViewDelegate* delegate);
|
||||
virtual ~CefWebContentsViewOSR();
|
||||
|
||||
// WebContentsView methods.
|
||||
virtual void CreateView(const gfx::Size& initial_size,
|
||||
gfx::NativeView context) OVERRIDE;
|
||||
virtual content::RenderWidgetHostView* CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host) OVERRIDE;
|
||||
virtual content::RenderWidgetHostView* CreateViewForPopupWidget(
|
||||
content::RenderWidgetHost* render_widget_host);
|
||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||
virtual gfx::NativeView GetContentNativeView() const OVERRIDE;
|
||||
virtual gfx::NativeWindow GetTopLevelNativeWindow() const OVERRIDE;
|
||||
virtual void GetContainerBounds(gfx::Rect *out) const OVERRIDE;
|
||||
virtual void SetPageTitle(const base::string16& title) OVERRIDE;
|
||||
virtual void OnTabCrashed(base::TerminationStatus status,
|
||||
int error_code) OVERRIDE;
|
||||
virtual void SizeContents(const gfx::Size& size) OVERRIDE;
|
||||
virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE;
|
||||
virtual void RenderViewSwappedIn(content::RenderViewHost* host) OVERRIDE;
|
||||
virtual void SetOverscrollControllerEnabled(bool enabled) OVERRIDE;
|
||||
virtual void Focus() OVERRIDE;
|
||||
virtual void SetInitialFocus() OVERRIDE;
|
||||
virtual void StoreFocus() OVERRIDE;
|
||||
virtual void RestoreFocus() OVERRIDE;
|
||||
virtual content::DropData* GetDropData() const OVERRIDE;
|
||||
virtual gfx::Rect GetViewBounds() const OVERRIDE;
|
||||
#if defined(OS_MACOSX)
|
||||
virtual bool IsEventTracking() const OVERRIDE;
|
||||
virtual void CloseTabAfterEventTracking() OVERRIDE;
|
||||
virtual void SetAllowOverlappingViews(bool overlapping) OVERRIDE;
|
||||
virtual bool GetAllowOverlappingViews() const OVERRIDE;
|
||||
virtual void SetOverlayView(content::WebContentsView* overlay,
|
||||
const gfx::Point& offset) OVERRIDE;
|
||||
virtual void RemoveOverlayView() OVERRIDE;
|
||||
#endif // defined(OS_MACOSX)
|
||||
|
||||
// RenderViewHostDelegateView methods.
|
||||
virtual void StartDragging(
|
||||
const content::DropData& drop_data,
|
||||
blink::WebDragOperationsMask allowed_ops,
|
||||
const gfx::ImageSkia& image,
|
||||
const gfx::Vector2d& image_offset,
|
||||
const content::DragEventSourceInfo& event_info) OVERRIDE;
|
||||
virtual void ShowPopupMenu(
|
||||
const gfx::Rect& bounds,
|
||||
int item_height,
|
||||
double item_font_size,
|
||||
int selected_item,
|
||||
const std::vector<content::MenuItem>& items,
|
||||
bool right_aligned,
|
||||
bool allow_multiple_selection) OVERRIDE;
|
||||
|
||||
private:
|
||||
content::WebContents* web_contents_;
|
||||
content::RenderWidgetHostView* view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefWebContentsViewOSR);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_WEB_CONTENTS_VIEW_OSR_H_
|
@@ -151,7 +151,6 @@ IPC_SYNC_MESSAGE_CONTROL0_1(
|
||||
IPC_STRUCT_BEGIN(CefProcessHostMsg_GetNewBrowserInfo_Params)
|
||||
IPC_STRUCT_MEMBER(int, browser_id)
|
||||
IPC_STRUCT_MEMBER(bool, is_popup)
|
||||
IPC_STRUCT_MEMBER(bool, is_window_rendering_disabled)
|
||||
IPC_STRUCT_END()
|
||||
|
||||
// Retrieve information about a newly created browser.
|
||||
|
@@ -288,13 +288,6 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
command_line->AppendSwitchASCII(switches::kContextSafetyImplementation,
|
||||
base::IntToString(settings.context_safety_implementation));
|
||||
}
|
||||
|
||||
if (settings.windowless_rendering_enabled) {
|
||||
// Must disable delegated renderer and threaded compositing for select
|
||||
// popups to display correctly in a windowless browser.
|
||||
command_line->AppendSwitch(switches::kDisableDelegatedRenderer);
|
||||
command_line->AppendSwitch(switches::kDisableThreadedCompositing);
|
||||
}
|
||||
}
|
||||
|
||||
if (content_client_.application().get()) {
|
||||
|
@@ -267,12 +267,10 @@ bool CefBrowserImpl::SendProcessMessage(CefProcessId target_process,
|
||||
|
||||
CefBrowserImpl::CefBrowserImpl(content::RenderView* render_view,
|
||||
int browser_id,
|
||||
bool is_popup,
|
||||
bool is_window_rendering_disabled)
|
||||
bool is_popup)
|
||||
: content::RenderViewObserver(render_view),
|
||||
browser_id_(browser_id),
|
||||
is_popup_(is_popup),
|
||||
is_window_rendering_disabled_(is_window_rendering_disabled),
|
||||
last_focused_frame_id_(webkit_glue::kInvalidFrameId) {
|
||||
response_manager_.reset(new CefResponseManager);
|
||||
}
|
||||
|
@@ -79,8 +79,7 @@ class CefBrowserImpl : public CefBrowser,
|
||||
|
||||
CefBrowserImpl(content::RenderView* render_view,
|
||||
int browser_id,
|
||||
bool is_popup,
|
||||
bool is_window_rendering_disabled);
|
||||
bool is_popup);
|
||||
virtual ~CefBrowserImpl();
|
||||
|
||||
void LoadRequest(const CefMsg_LoadRequest_Params& params);
|
||||
@@ -100,9 +99,6 @@ class CefBrowserImpl : public CefBrowser,
|
||||
|
||||
int browser_id() const { return browser_id_; }
|
||||
bool is_popup() const { return is_popup_; }
|
||||
bool is_window_rendering_disabled() const {
|
||||
return is_window_rendering_disabled_;
|
||||
}
|
||||
content::RenderView* render_view() const {
|
||||
return content::RenderViewObserver::render_view();
|
||||
}
|
||||
@@ -144,7 +140,6 @@ class CefBrowserImpl : public CefBrowser,
|
||||
// same browser ID.
|
||||
int browser_id_;
|
||||
bool is_popup_;
|
||||
bool is_window_rendering_disabled_;
|
||||
|
||||
// Id of the last frame that had focus.
|
||||
int64 last_focused_frame_id_;
|
||||
|
@@ -436,90 +436,6 @@ void CefContentRendererClient::RenderViewCreated(
|
||||
BrowserCreated(render_view, render_view->GetMainRenderFrame());
|
||||
}
|
||||
|
||||
bool CefContentRendererClient::OverrideCreatePlugin(
|
||||
content::RenderFrame* render_frame,
|
||||
blink::WebFrame* frame,
|
||||
const blink::WebPluginParams& params,
|
||||
blink::WebPlugin** plugin) {
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
CefBrowserImpl::GetBrowserForMainFrame(frame->top());
|
||||
if (!browser || !browser->is_window_rendering_disabled())
|
||||
return false;
|
||||
|
||||
#if defined(ENABLE_PLUGINS)
|
||||
if (base::UTF16ToASCII(params.mimeType) == content::kBrowserPluginMimeType)
|
||||
return false;
|
||||
|
||||
content::RenderFrameImpl* render_frame_impl =
|
||||
static_cast<content::RenderFrameImpl*>(render_frame);
|
||||
|
||||
content::WebPluginInfo info;
|
||||
std::string mime_type;
|
||||
bool found = false;
|
||||
render_frame_impl->Send(
|
||||
new FrameHostMsg_GetPluginInfo(
|
||||
render_frame_impl->GetRoutingID(),
|
||||
params.url,
|
||||
frame->top()->document().url(),
|
||||
params.mimeType.utf8(),
|
||||
&found,
|
||||
&info,
|
||||
&mime_type));
|
||||
if (!found)
|
||||
return false;
|
||||
|
||||
bool flash = LowerCaseEqualsASCII(mime_type,
|
||||
"application/x-shockwave-flash");
|
||||
bool silverlight = StartsWithASCII(mime_type,
|
||||
"application/x-silverlight", false);
|
||||
|
||||
if (flash) {
|
||||
// "wmode" values of "opaque" or "transparent" are allowed.
|
||||
size_t size = params.attributeNames.size();
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
std::string name = params.attributeNames[i].utf8();
|
||||
if (name == "wmode") {
|
||||
std::string value = params.attributeValues[i].utf8();
|
||||
if (value == "opaque" || value == "transparent")
|
||||
flash = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flash || silverlight) {
|
||||
// Force Flash and Silverlight plugins to use windowless mode.
|
||||
blink::WebPluginParams params_to_use = params;
|
||||
params_to_use.mimeType = blink::WebString::fromUTF8(mime_type);
|
||||
|
||||
size_t size = params.attributeNames.size();
|
||||
blink::WebVector<blink::WebString> new_names(size+1),
|
||||
new_values(size+1);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
new_names[i] = params.attributeNames[i];
|
||||
new_values[i] = params.attributeValues[i];
|
||||
}
|
||||
|
||||
if (flash) {
|
||||
new_names[size] = "wmode";
|
||||
new_values[size] = "opaque";
|
||||
} else if (silverlight) {
|
||||
new_names[size] = "windowless";
|
||||
new_values[size] = "true";
|
||||
}
|
||||
|
||||
params_to_use.attributeNames.swap(new_names);
|
||||
params_to_use.attributeValues.swap(new_values);
|
||||
|
||||
*plugin = render_frame_impl->CreatePlugin(frame, info, params_to_use);
|
||||
return true;
|
||||
}
|
||||
#endif // defined(ENABLE_PLUGINS)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CefContentRendererClient::HandleNavigation(
|
||||
content::RenderFrame* render_frame,
|
||||
content::DocumentState* document_state,
|
||||
@@ -662,18 +578,8 @@ void CefContentRendererClient::BrowserCreated(
|
||||
if (GetBrowserForView(render_view))
|
||||
return;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// FIXME: It would be better if this API would be a callback from the
|
||||
// WebKit layer, or if it would be exposed as an WebView instance method; the
|
||||
// current implementation uses a static variable, and WebKit needs to be
|
||||
// patched in order to make it work for each WebView instance
|
||||
render_view->GetWebView()->setUseExternalPopupMenusThisInstance(
|
||||
!params.is_window_rendering_disabled);
|
||||
#endif
|
||||
|
||||
CefRefPtr<CefBrowserImpl> browser =
|
||||
new CefBrowserImpl(render_view, params.browser_id, params.is_popup,
|
||||
params.is_window_rendering_disabled);
|
||||
new CefBrowserImpl(render_view, params.browser_id, params.is_popup);
|
||||
browsers_.insert(std::make_pair(render_view, browser));
|
||||
|
||||
new CefPrerendererClient(render_view);
|
||||
|
@@ -76,11 +76,6 @@ class CefContentRendererClient : public content::ContentRendererClient,
|
||||
virtual void RenderThreadStarted() OVERRIDE;
|
||||
virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;
|
||||
virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE;
|
||||
virtual bool OverrideCreatePlugin(
|
||||
content::RenderFrame* render_frame,
|
||||
blink::WebFrame* frame,
|
||||
const blink::WebPluginParams& params,
|
||||
blink::WebPlugin** plugin) OVERRIDE;
|
||||
virtual bool HandleNavigation(content::RenderFrame* render_frame,
|
||||
content::DocumentState* document_state,
|
||||
int opener_id,
|
||||
|
Reference in New Issue
Block a user