diff --git a/include/cef.h b/include/cef.h index 30d1cc4eb..25b4c5a20 100644 --- a/include/cef.h +++ b/include/cef.h @@ -1264,6 +1264,15 @@ public: CefRefPtr frame, const CefString& url) {} + /// + // Called when the size of the content area has changed. + /// + /*--cef()--*/ + virtual void OnContentsSizeChange(CefRefPtr browser, + CefRefPtr frame, + int width, + int height) {} + /// // Called when the page title changes. /// diff --git a/include/cef_capi.h b/include/cef_capi.h index a44b4a712..6db627a55 100644 --- a/include/cef_capi.h +++ b/include/cef_capi.h @@ -1076,6 +1076,13 @@ typedef struct _cef_display_handler_t struct _cef_browser_t* browser, struct _cef_frame_t* frame, const cef_string_t* url); + /// + // Called when the size of the content area has changed. + /// + void (CEF_CALLBACK *on_contents_size_change)( + struct _cef_display_handler_t* self, struct _cef_browser_t* browser, + struct _cef_frame_t* frame, int width, int height); + /// // Called when the page title changes. /// diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index d3cf7c7ef..969e9d137 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -950,11 +950,23 @@ void BrowserWebViewDelegate::willSendRequest( request.setRequestorID(browser_->UIT_GetUniqueID()); } +void BrowserWebViewDelegate::didChangeContentsSize( + WebFrame* frame, const WebSize& size) { + CefRefPtr client = browser_->GetClient(); + if (client.get()) { + CefRefPtr handler = client->GetDisplayHandler(); + if (handler.get()) { + handler->OnContentsSizeChange(browser_, browser_->UIT_GetCefFrame(frame), + size.width, size.height); + } + } +} + void BrowserWebViewDelegate::reportFindInPageMatchCount( int request_id, int count, bool final_update) { browser_->UIT_NotifyFindStatus(request_id, count, gfx::Rect(), - -1, // // Don't update active match ordinal. + -1, // Don't update active match ordinal. final_update); } diff --git a/libcef/browser_webview_delegate.h b/libcef/browser_webview_delegate.h index 718fbc064..6cd90a0de 100644 --- a/libcef/browser_webview_delegate.h +++ b/libcef/browser_webview_delegate.h @@ -180,6 +180,8 @@ class BrowserWebViewDelegate : public WebKit::WebViewClient, virtual void willSendRequest( WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse& redirectResponse) OVERRIDE; + virtual void didChangeContentsSize( + WebKit::WebFrame*, const WebKit::WebSize&) OVERRIDE; virtual void reportFindInPageMatchCount( int request_id, int count, bool final_update) OVERRIDE; virtual void reportFindInPageSelection( diff --git a/libcef_dll/cpptoc/display_handler_cpptoc.cc b/libcef_dll/cpptoc/display_handler_cpptoc.cc index 978c0dd1d..6529b6205 100644 --- a/libcef_dll/cpptoc/display_handler_cpptoc.cc +++ b/libcef_dll/cpptoc/display_handler_cpptoc.cc @@ -47,6 +47,21 @@ void CEF_CALLBACK display_handler_on_address_change( CefString(url)); } +void CEF_CALLBACK display_handler_on_contents_size_change( + struct _cef_display_handler_t* self, cef_browser_t* browser, + cef_frame_t* frame, int width, int height) +{ + DCHECK(self); + DCHECK(browser); + DCHECK(frame); + if (!self || !browser || !frame) + return; + + CefDisplayHandlerCppToC::Get(self)->OnContentsSizeChange( + CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame), width, + height); +} + void CEF_CALLBACK display_handler_on_title_change( struct _cef_display_handler_t* self, cef_browser_t* browser, const cef_string_t* title) @@ -109,6 +124,8 @@ CefDisplayHandlerCppToC::CefDisplayHandlerCppToC(CefDisplayHandler* cls) { struct_.struct_.on_nav_state_change = display_handler_on_nav_state_change; struct_.struct_.on_address_change = display_handler_on_address_change; + struct_.struct_.on_contents_size_change = + display_handler_on_contents_size_change; struct_.struct_.on_title_change = display_handler_on_title_change; struct_.struct_.on_tooltip = display_handler_on_tooltip; struct_.struct_.on_status_message = display_handler_on_status_message; diff --git a/libcef_dll/ctocpp/display_handler_ctocpp.cc b/libcef_dll/ctocpp/display_handler_ctocpp.cc index f85075ab3..043647701 100644 --- a/libcef_dll/ctocpp/display_handler_ctocpp.cc +++ b/libcef_dll/ctocpp/display_handler_ctocpp.cc @@ -37,6 +37,17 @@ void CefDisplayHandlerCToCpp::OnAddressChange(CefRefPtr browser, CefFrameCppToC::Wrap(frame), url.GetStruct()); } +void CefDisplayHandlerCToCpp::OnContentsSizeChange( + CefRefPtr browser, CefRefPtr frame, int width, + int height) +{ + if (CEF_MEMBER_MISSING(struct_, on_contents_size_change)) + return; + + struct_->on_contents_size_change(struct_, CefBrowserCppToC::Wrap(browser), + CefFrameCppToC::Wrap(frame), width, height); +} + void CefDisplayHandlerCToCpp::OnTitleChange(CefRefPtr browser, const CefString& title) { diff --git a/libcef_dll/ctocpp/display_handler_ctocpp.h b/libcef_dll/ctocpp/display_handler_ctocpp.h index 12ab990e3..b8ef05dd9 100644 --- a/libcef_dll/ctocpp/display_handler_ctocpp.h +++ b/libcef_dll/ctocpp/display_handler_ctocpp.h @@ -37,6 +37,8 @@ public: bool canGoForward) OVERRIDE; virtual void OnAddressChange(CefRefPtr browser, CefRefPtr frame, const CefString& url) OVERRIDE; + virtual void OnContentsSizeChange(CefRefPtr browser, + CefRefPtr frame, int width, int height) OVERRIDE; virtual void OnTitleChange(CefRefPtr browser, const CefString& title) OVERRIDE; virtual bool OnTooltip(CefRefPtr browser,