2015-01-27 01:03:25 +01:00
|
|
|
// Copyright (c) 2015 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.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_HANDLER_OSR_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_HANDLER_OSR_H_
|
|
|
|
#pragma once
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2016-11-18 00:52:42 +01:00
|
|
|
#include "tests/cefclient/browser/client_handler.h"
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
// Client handler implementation for windowless browsers. There will only ever
|
|
|
|
// be one browser per handler instance.
|
2015-01-30 19:55:55 +01:00
|
|
|
class ClientHandlerOsr : public ClientHandler,
|
2017-05-12 20:28:25 +02:00
|
|
|
public CefAccessibilityHandler,
|
2015-01-27 01:03:25 +01:00
|
|
|
public CefRenderHandler {
|
|
|
|
public:
|
|
|
|
// Implement this interface to receive notification of ClientHandlerOsr
|
|
|
|
// events. The methods of this class will be called on the CEF UI thread.
|
|
|
|
class OsrDelegate {
|
|
|
|
public:
|
|
|
|
// These methods match the CefLifeSpanHandler interface.
|
|
|
|
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) = 0;
|
|
|
|
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) = 0;
|
|
|
|
|
|
|
|
// These methods match the CefRenderHandler interface.
|
|
|
|
virtual bool GetRootScreenRect(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRect& rect) = 0;
|
2018-09-25 15:40:02 +02:00
|
|
|
virtual void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
virtual bool GetScreenPoint(CefRefPtr<CefBrowser> browser,
|
|
|
|
int viewX,
|
|
|
|
int viewY,
|
|
|
|
int& screenX,
|
|
|
|
int& screenY) = 0;
|
|
|
|
virtual bool GetScreenInfo(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefScreenInfo& screen_info) = 0;
|
|
|
|
virtual void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) = 0;
|
|
|
|
virtual void OnPopupSize(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefRect& rect) = 0;
|
|
|
|
virtual void OnPaint(CefRefPtr<CefBrowser> browser,
|
2018-09-26 13:25:58 +02:00
|
|
|
CefRenderHandler::PaintElementType type,
|
|
|
|
const CefRenderHandler::RectList& dirtyRects,
|
2015-01-27 01:03:25 +01:00
|
|
|
const void* buffer,
|
|
|
|
int width,
|
|
|
|
int height) = 0;
|
2018-09-26 13:25:58 +02:00
|
|
|
virtual void OnAcceleratedPaint(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRenderHandler::PaintElementType type,
|
|
|
|
const CefRenderHandler::RectList& dirtyRects,
|
2024-03-08 13:44:56 +01:00
|
|
|
const CefAcceleratedPaintInfo& info) {}
|
2015-01-27 01:03:25 +01:00
|
|
|
virtual bool StartDragging(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefDragData> drag_data,
|
|
|
|
CefRenderHandler::DragOperationsMask allowed_ops,
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
|
|
|
int y) = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
virtual void UpdateDragCursor(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRenderHandler::DragOperation operation) = 0;
|
2016-10-28 18:11:24 +02:00
|
|
|
virtual void OnImeCompositionRangeChanged(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefRange& selection_range,
|
|
|
|
const CefRenderHandler::RectList& character_bounds) = 0;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2020-10-28 17:30:54 +01:00
|
|
|
// These methods match the CefDisplayHandler interface.
|
|
|
|
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefCursorHandle cursor,
|
|
|
|
cef_cursor_type_t type,
|
|
|
|
const CefCursorInfo& custom_cursor_info) = 0;
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2020-10-28 17:30:54 +01:00
|
|
|
virtual void UpdateAccessibilityTree(CefRefPtr<CefValue> value) = 0;
|
2019-03-21 17:56:06 +01:00
|
|
|
virtual void UpdateAccessibilityLocation(CefRefPtr<CefValue> value) = 0;
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
protected:
|
2024-01-20 03:22:56 +01:00
|
|
|
virtual ~OsrDelegate() = default;
|
2015-01-27 01:03:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
ClientHandlerOsr(Delegate* delegate,
|
|
|
|
OsrDelegate* osr_delegate,
|
2022-03-22 19:31:30 +01:00
|
|
|
bool with_controls,
|
2015-01-27 01:03:25 +01:00
|
|
|
const std::string& startup_url);
|
|
|
|
|
2024-08-06 00:30:39 +02:00
|
|
|
// Returns the ClientHandlerOsr for |client|, or nullptr if |client| is not a
|
|
|
|
// ClientHandlerOsr.
|
|
|
|
static CefRefPtr<ClientHandlerOsr> GetForClient(CefRefPtr<CefClient> client);
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
// This object may outlive the OsrDelegate object so it's necessary for the
|
|
|
|
// OsrDelegate to detach itself before destruction.
|
|
|
|
void DetachOsrDelegate();
|
|
|
|
|
|
|
|
// CefClient methods.
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefRenderHandler> GetRenderHandler() override { return this; }
|
|
|
|
CefRefPtr<CefAccessibilityHandler> GetAccessibilityHandler() override {
|
2017-05-12 20:28:25 +02:00
|
|
|
return this;
|
|
|
|
}
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// CefLifeSpanHandler methods.
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override;
|
|
|
|
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
// CefRenderHandler methods.
|
2021-06-17 21:43:06 +02:00
|
|
|
bool GetRootScreenRect(CefRefPtr<CefBrowser> browser, CefRect& rect) override;
|
|
|
|
void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
bool GetScreenPoint(CefRefPtr<CefBrowser> browser,
|
|
|
|
int viewX,
|
|
|
|
int viewY,
|
|
|
|
int& screenX,
|
2021-06-17 21:43:06 +02:00
|
|
|
int& screenY) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
bool GetScreenInfo(CefRefPtr<CefBrowser> browser,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefScreenInfo& screen_info) override;
|
|
|
|
void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) override;
|
|
|
|
void OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
void OnPaint(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRenderHandler::PaintElementType type,
|
|
|
|
const CefRenderHandler::RectList& dirtyRects,
|
|
|
|
const void* buffer,
|
|
|
|
int width,
|
2021-06-17 21:43:06 +02:00
|
|
|
int height) override;
|
2018-09-26 13:25:58 +02:00
|
|
|
void OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRenderHandler::PaintElementType type,
|
|
|
|
const CefRenderHandler::RectList& dirtyRects,
|
2024-03-08 13:44:56 +01:00
|
|
|
const CefAcceleratedPaintInfo& info) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
bool StartDragging(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefRefPtr<CefDragData> drag_data,
|
|
|
|
CefRenderHandler::DragOperationsMask allowed_ops,
|
2017-05-17 11:29:28 +02:00
|
|
|
int x,
|
2021-06-17 21:43:06 +02:00
|
|
|
int y) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
void UpdateDragCursor(CefRefPtr<CefBrowser> browser,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRenderHandler::DragOperation operation) override;
|
2016-10-28 18:11:24 +02:00
|
|
|
void OnImeCompositionRangeChanged(
|
|
|
|
CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefRange& selection_range,
|
2021-06-17 21:43:06 +02:00
|
|
|
const CefRenderHandler::RectList& character_bounds) override;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
2020-10-28 17:30:54 +01:00
|
|
|
// CefDisplayHandler methods.
|
|
|
|
bool OnCursorChange(CefRefPtr<CefBrowser> browser,
|
|
|
|
CefCursorHandle cursor,
|
|
|
|
cef_cursor_type_t type,
|
2021-06-17 21:43:06 +02:00
|
|
|
const CefCursorInfo& custom_cursor_info) override;
|
2020-10-28 17:30:54 +01:00
|
|
|
|
2017-05-12 20:28:25 +02:00
|
|
|
// CefAccessibilityHandler methods.
|
2021-06-17 21:43:06 +02:00
|
|
|
void OnAccessibilityTreeChange(CefRefPtr<CefValue> value) override;
|
|
|
|
void OnAccessibilityLocationChange(CefRefPtr<CefValue> value) override;
|
2017-05-12 20:28:25 +02:00
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
private:
|
2024-08-06 00:30:39 +02:00
|
|
|
// Used to determine the object type.
|
|
|
|
virtual const void* GetTypeKey() const override { return &kTypeKey; }
|
2024-08-07 17:30:07 +02:00
|
|
|
static constexpr int kTypeKey = 0;
|
2024-08-06 00:30:39 +02:00
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
// Only accessed on the UI thread.
|
|
|
|
OsrDelegate* osr_delegate_;
|
|
|
|
|
|
|
|
// Include the default reference counting implementation.
|
|
|
|
IMPLEMENT_REFCOUNTING(ClientHandlerOsr);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClientHandlerOsr);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_CLIENT_HANDLER_OSR_H_
|