Add CefRenderHandler::OnScrollOffsetChanged callback (issue #889).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1309 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2013-07-18 19:26:11 +00:00
parent 575cdbbd31
commit 0b46579e99
7 changed files with 76 additions and 10 deletions

View File

@ -120,6 +120,12 @@ typedef struct _cef_render_handler_t {
///
void (CEF_CALLBACK *on_cursor_change)(struct _cef_render_handler_t* self,
struct _cef_browser_t* browser, cef_cursor_handle_t cursor);
///
// Called when the scroll offset has changed.
///
void (CEF_CALLBACK *on_scroll_offset_changed)(
struct _cef_render_handler_t* self, struct _cef_browser_t* browser);
} cef_render_handler_t;

View File

@ -127,6 +127,12 @@ class CefRenderHandler : public virtual CefBase {
/*--cef()--*/
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor) {}
///
// Called when the scroll offset has changed.
///
/*--cef()--*/
virtual void OnScrollOffsetChanged(CefRefPtr<CefBrowser> browser) {}
};
#endif // CEF_INCLUDE_CEF_RENDER_HANDLER_H_

View File

@ -323,6 +323,10 @@ void CefRenderWidgetHostViewOSR::SelectionBoundsChanged(
}
void CefRenderWidgetHostViewOSR::ScrollOffsetChanged() {
if (!browser_impl_.get())
return;
browser_impl_->GetClient()->GetRenderHandler()->
OnScrollOffsetChanged(browser_impl_.get());
}
content::BackingStore* CefRenderWidgetHostViewOSR::AllocBackingStore(

View File

@ -265,6 +265,23 @@ void CEF_CALLBACK render_handler_on_cursor_change(
cursor);
}
void CEF_CALLBACK render_handler_on_scroll_offset_changed(
struct _cef_render_handler_t* self, cef_browser_t* browser) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return;
// Execute
CefRenderHandlerCppToC::Get(self)->OnScrollOffsetChanged(
CefBrowserCToCpp::Wrap(browser));
}
// CONSTRUCTOR - Do not edit by hand.
@ -279,6 +296,8 @@ CefRenderHandlerCppToC::CefRenderHandlerCppToC(CefRenderHandler* cls)
struct_.struct_.on_popup_size = render_handler_on_popup_size;
struct_.struct_.on_paint = render_handler_on_paint;
struct_.struct_.on_cursor_change = render_handler_on_cursor_change;
struct_.struct_.on_scroll_offset_changed =
render_handler_on_scroll_offset_changed;
}
#ifndef NDEBUG

View File

@ -202,6 +202,23 @@ void CefRenderHandlerCToCpp::OnCursorChange(CefRefPtr<CefBrowser> browser,
cursor);
}
void CefRenderHandlerCToCpp::OnScrollOffsetChanged(
CefRefPtr<CefBrowser> browser) {
if (CEF_MEMBER_MISSING(struct_, on_scroll_offset_changed))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return;
// Execute
struct_->on_scroll_offset_changed(struct_,
CefBrowserCppToC::Wrap(browser));
}
#ifndef NDEBUG
template<> long CefCToCpp<CefRenderHandlerCToCpp, CefRenderHandler,

View File

@ -50,6 +50,7 @@ class CefRenderHandlerCToCpp
int height) OVERRIDE;
virtual void OnCursorChange(CefRefPtr<CefBrowser> browser,
CefCursorHandle cursor) OVERRIDE;
virtual void OnScrollOffsetChanged(CefRefPtr<CefBrowser> browser) OVERRIDE;
};
#endif // BUILDING_CEF_SHARED

View File

@ -196,8 +196,13 @@ class OSRTestHandler : public TestHandler,
public:
explicit OSRTestHandler(OSRTestType test)
: test_type_(test),
started_(false),
succeeded_(false) {
event_count_(0),
event_total_(1),
started_(false) {
if (test == OSR_TEST_SCROLLING) {
// Wait for both the paint event and the scroll offset event.
event_total_ = 2;
}
}
virtual ~OSRTestHandler() {}
@ -638,7 +643,6 @@ class OSRTestHandler : public TestHandler,
CefRect(0, kOsrHeight - kHorizontalScrollbarWidth,
kOsrWidth - kVerticalScrollbarWidth,
kHorizontalScrollbarWidth));
DestroySucceededTestSoon();
#elif defined(OS_MACOSX)
// On Mac, when scrollbars are Always on, there is a single update of
// the whole view
@ -650,15 +654,14 @@ class OSRTestHandler : public TestHandler,
EXPECT_EQ(dirtyRects.size(), 1U);
EXPECT_EQ(dirtyRects[0], CefRect(0, 0,
kOsrWidth, kOsrHeight));
DestroySucceededTestSoon();
#elif defined(OS_LINUX)
EXPECT_EQ(dirtyRects.size(), 1U);
EXPECT_EQ(dirtyRects[0], CefRect(0, 0,
kOsrWidth, kOsrHeight));
DestroySucceededTestSoon();
#else
#error "Unsupported platform"
#endif // defined(OS_WIN)
DestroySucceededTestSoon();
}
break;
}
@ -791,6 +794,12 @@ class OSRTestHandler : public TestHandler,
}
}
virtual void OnScrollOffsetChanged(CefRefPtr<CefBrowser> browser) OVERRIDE {
if (test_type_ == OSR_TEST_SCROLLING && started()) {
DestroySucceededTestSoon();
}
}
virtual bool OnTooltip(CefRefPtr<CefBrowser> browser,
CefString& text) OVERRIDE {
if (test_type_ == OSR_TEST_TOOLTIP && started()) {
@ -863,9 +872,12 @@ class OSRTestHandler : public TestHandler,
}
void DestroySucceededTestSoon() {
succeeded_ = true;
CefPostTask(TID_UI, NewCefRunnableMethod(this,
&OSRTestHandler::DestroyTest));
if (succeeded())
return;
if (++event_count_ == event_total_) {
CefPostTask(TID_UI, NewCefRunnableMethod(this,
&OSRTestHandler::DestroyTest));
}
}
void ExpandDropDown() {
@ -883,7 +895,7 @@ class OSRTestHandler : public TestHandler,
// true if the exit point was reached, even the result is not
// the expected one
bool succeeded() { return succeeded_; }
bool succeeded() { return (event_count_ == event_total_); }
// will mark test as started and will return true only the first time
// it is called
@ -896,8 +908,9 @@ class OSRTestHandler : public TestHandler,
private:
OSRTestType test_type_;
int event_count_;
int event_total_;
bool started_;
bool succeeded_;
IMPLEMENT_REFCOUNTING(OSRTestHandler);
};