Add enable_osr build flag

This commit is contained in:
Aleksei Kuzmin 2017-06-26 11:13:05 +02:00
parent ab174f5e74
commit da36bdfcc4
8 changed files with 79 additions and 10 deletions

View file

@ -6,8 +6,10 @@
#include <utility>
#include <vector>
#if defined(ENABLE_OSR)
#include "atom/browser/osr/osr_render_widget_host_view.h"
#include "atom/browser/osr/osr_view_proxy.h"
#endif
#include "atom/browser/ui/autofill_popup.h"
#include "atom/common/api/api_messages.h"
#include "ui/display/display.h"
@ -132,12 +134,14 @@ void AutofillPopup::CreateView(
view_ = new AutofillPopupView(this, parent_widget);
view_->Show();
#if defined(ENABLE_OSR)
if (offscreen) {
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
frame_host_->GetView());
view_->view_proxy_.reset(new OffscreenViewProxy(view_));
osr_rwhv->AddViewProxy(view_->view_proxy_.get());
}
#endif
}
void AutofillPopup::Hide() {

View file

@ -22,7 +22,9 @@ AutofillPopupView::AutofillPopupView(
views::Widget* parent_widget)
: popup_(popup),
parent_widget_(parent_widget),
#if defined(ENABLE_OSR)
view_proxy_(nullptr),
#endif
weak_ptr_factory_(this) {
CreateChildViews();
SetFocusBehavior(FocusBehavior::ALWAYS);
@ -39,9 +41,11 @@ AutofillPopupView::~AutofillPopupView() {
RemoveObserver();
#if defined(ENABLE_OSR)
if (view_proxy_.get()) {
view_proxy_->ResetView();
}
#endif
if (GetWidget()) {
GetWidget()->Close();
@ -220,12 +224,14 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
gfx::Canvas* draw_canvas = canvas;
SkBitmap bitmap;
#if defined(ENABLE_OSR)
if (view_proxy_.get()) {
bitmap.allocN32Pixels(popup_->popup_bounds_in_view_.width(),
popup_->popup_bounds_in_view_.height(),
true);
draw_canvas = new gfx::Canvas(new SkCanvas(bitmap), 1.0);
}
#endif
draw_canvas->DrawColor(GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ResultsTableNormalBackground));
@ -237,10 +243,12 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
DrawAutofillEntry(draw_canvas, i, line_rect);
}
#if defined(ENABLE_OSR)
if (view_proxy_.get()) {
view_proxy_->SetBounds(popup_->popup_bounds_in_view_);
view_proxy_->SetBitmap(bitmap);
}
#endif
}
void AutofillPopupView::GetAccessibleNodeData(ui::AXNodeData* node_data) {

View file

@ -7,7 +7,9 @@
#include "atom/browser/ui/autofill_popup.h"
#if defined(ENABLE_OSR)
#include "atom/browser/osr/osr_view_proxy.h"
#endif
#include "base/optional.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/render_widget_host.h"
@ -138,7 +140,9 @@ class AutofillPopupView : public views::WidgetDelegateView,
// The index of the currently selected line
base::Optional<int> selected_line_;
#if defined(ENABLE_OSR)
std::unique_ptr<OffscreenViewProxy> view_proxy_;
#endif
// The registered keypress callback, responsible for switching lines on
// key presses