web_view_->OnSnapshot(pixData, size.width(), size.height(), snapshotId);
}
+ void OnDidChangeMaxScrollOffset(int maxScrollX, int maxScrollY) {
+ if (web_view_)
+ web_view_->GetScrollDetector()->SetMaxScroll(maxScrollX, maxScrollY);
+ }
+
+ void OnDidChangeScrollOffset(int scrollX, int scrollY) {
+ if (web_view_)
+ web_view_->GetScrollDetector()->OnChangeScrollOffset(gfx::Vector2d(scrollX, scrollY));
+ }
+
void OnGetTextAtPositionReply(const std::string& text) {
#ifdef TIZEN_CONTENTS_DETECTION
if (web_view_) {
WebViewBrowserMessageFilterPrivate::OnDidChangePageScaleFactor)
IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangePageScaleRange, private_,
WebViewBrowserMessageFilterPrivate::OnDidChangePageScaleRange)
+ IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangeMaxScrollOffset, private_,
+ WebViewBrowserMessageFilterPrivate::OnDidChangeMaxScrollOffset)
+ IPC_MESSAGE_FORWARD(EwkHostMsg_DidChangeScrollOffset, private_,
+ WebViewBrowserMessageFilterPrivate::OnDidChangeScrollOffset)
#if defined(OS_TIZEN)
IPC_MESSAGE_FORWARD(ViewHostMsg_SnapshotDataReceived, private_,
WebViewBrowserMessageFilterPrivate::OnSnapshot)
'network_delegate_efl.h',
'popup_controller_efl.cc',
'popup_controller_efl.h',
+ 'scroll_detector.cc',
+ 'scroll_detector.h',
'selection_box_efl.cc',
'selection_box_efl.h',
'selection_controller_efl.cc',
selection_controller_.reset(new content::SelectionControllerEfl(this));
+ scroll_detector_.reset(new ScrollDetector(this));
+
web_contents_delegate_.reset(new WebContentsDelegateEfl(this));
web_contents_->SetDelegate(web_contents_delegate_.get());
back_forward_list_.reset(new _Ewk_Back_Forward_List(
}
bool EWebView::GetScrollPosition(int* x, int* y) const {
-#if defined(EWK_REFACTOR)
DCHECK(x);
DCHECK(y);
- if (!rwhv()) {
- *y = *x = 0;
- return false;
- }
- if (rwhv()->IsScrollOffsetChanged()) {
+ if (scroll_detector_->IsScrollOffsetChanged()) {
*x = previous_scroll_position_.x();
*y = previous_scroll_position_.y();
} else {
- const gfx::Vector2d scroll_position = rwhv()->scroll_offset();
+ const gfx::Vector2d scroll_position = scroll_detector_->GetLastScrollPosition();
*x = scroll_position.x();
*y = scroll_position.y();
}
return true;
-#else
- NOTIMPLEMENTED();
- return false;
-#endif
}
void EWebView::SetScroll(int x, int y) {
-#if defined(EWK_REFACTOR)
RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
if (!render_view_host)
return;
- if (rwhv()) {
- rwhv()->SetScrollOffsetChanged();
- int maxX, maxY;
- GetScrollSize(&maxX, &maxY);
- previous_scroll_position_.set_x(std::min(std::max(x, 0), maxX));
- previous_scroll_position_.set_y(std::min(std::max(y, 0), maxY));
- }
+ int maxX, maxY;
+ GetScrollSize(&maxX, &maxY);
+ previous_scroll_position_.set_x(std::min(std::max(x, 0), maxX));
+ previous_scroll_position_.set_y(std::min(std::max(y, 0), maxY));
+
+ scroll_detector_->SetScrollOffsetChanged();
render_view_host->Send(new EwkViewMsg_SetScroll(render_view_host->GetRoutingID(), x, y));
-#else
- NOTIMPLEMENTED();
-#endif
}
void EWebView::UseSettingsFont() {
#include "private/ewk_web_application_icon_data_private.h"
#include "public/ewk_view.h"
#include "eweb_view_callbacks.h"
+#include "scroll_detector.h"
#include "selection_controller_efl.h"
#include "web_contents_delegate_efl.h"
#include "context_menu_controller_efl.h"
#ifdef TIZEN_CONTENTS_DETECTION
content::PopupControllerEfl* GetPopupController() const { return popup_controller_.get(); }
#endif
+ ScrollDetector* GetScrollDetector() const { return scroll_detector_.get(); }
void SelectRange(const gfx::Point& start, const gfx::Point& end);
void MoveCaret(const gfx::Point& point);
void QuerySelectionStyle();
IDMap< WebAppScreenshotCapturedCallback, IDMapOwnPointer> screen_capture_cb_map_;
scoped_ptr<NotificationPermissionCallback> notification_permission_callback_;
content::DevToolsDelegateEfl* inspector_server_;
-
+ scoped_ptr<ScrollDetector> scroll_detector_;
#if defined(OS_TIZEN_MOBILE)
content::FileChooserParams::Mode filechooser_mode_;
#endif
// found in the LICENSE file.
#include "eweb_view.h"
-#include "browser/renderer_host/scroll_detector.h"
+#include "scroll_detector.h"
-namespace EflWebview {
-
-ScrollDetector::ScrollDetector()
- : cached_is_main_frame_pinned_to_left_(false),
+ScrollDetector::ScrollDetector(EWebView* web_view)
+ : web_view_(web_view),
+ cached_is_main_frame_pinned_to_left_(false),
cached_is_main_frame_pinned_to_right_(false),
cached_is_main_frame_pinned_to_top_(false),
cached_is_main_frame_pinned_to_bottom_(false),
- edge_Flag_(false) {
+ edge_Flag_(false),
+ scroll_offset_changed_(false) {
}
-void ScrollDetector::OnChangeScrollOffset(EWebView* web_view,
- const gfx::Vector2d& scroll_position) {
+void ScrollDetector::OnChangeScrollOffset(const gfx::Vector2d& scroll_position) {
edge_Flag_ = true;
gfx::Vector2d scroll_delta = scroll_position;
scroll_delta -= last_scroll_position_;
last_scroll_position_ = scroll_position;
- DetectEdge(web_view, scroll_delta);
+ DetectEdge(scroll_delta);
if (edge_Flag_ && scroll_delta.x() > 0)
- web_view->SmartCallback<EWebViewCallbacks::ScrollLeft>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::ScrollLeft>().call();
if (edge_Flag_ && scroll_delta.x() < 0)
- web_view->SmartCallback<EWebViewCallbacks::ScrollRight>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::ScrollRight>().call();
if (edge_Flag_ && scroll_delta.y() < 0)
- web_view->SmartCallback<EWebViewCallbacks::ScrollDown>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::ScrollDown>().call();
if (edge_Flag_ && scroll_delta.y() > 0)
- web_view->SmartCallback<EWebViewCallbacks::ScrollUp>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::ScrollUp>().call();
+
+ scroll_offset_changed_ = false;
}
-void ScrollDetector::DetectEdge(EWebView* web_view, const gfx::Vector2d& scroll_delta) {
+void ScrollDetector::DetectEdge(const gfx::Vector2d& scroll_delta) {
if (scroll_delta.x()) {
- CheckForLeftRightEdges(web_view, last_scroll_position_.x());
+ CheckForLeftRightEdges(last_scroll_position_.x());
}
if (scroll_delta.y()) {
- CheckForTopBottomEdges(web_view, last_scroll_position_.y());
+ CheckForTopBottomEdges(last_scroll_position_.y());
}
}
max_Scroll_.set_y(y);
}
-void ScrollDetector::CheckForLeftRightEdges(EWebView* web_view, int scroll_x) {
+void ScrollDetector::CheckForLeftRightEdges(int scroll_x) {
bool is_pinned_to_left = scroll_x <= min_Scroll_.x();
bool is_pinned_to_right = scroll_x >= max_Scroll_.x();
if (is_pinned_to_left && (is_pinned_to_left != cached_is_main_frame_pinned_to_left_)) {
edge_Flag_ = false;
- web_view->SmartCallback<EWebViewCallbacks::EdgeLeft>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::EdgeLeft>().call();
}
if (is_pinned_to_right && (is_pinned_to_right != cached_is_main_frame_pinned_to_right_)) {
edge_Flag_ = false;
- web_view->SmartCallback<EWebViewCallbacks::EdgeRight>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::EdgeRight>().call();
}
cached_is_main_frame_pinned_to_left_ = is_pinned_to_left;
cached_is_main_frame_pinned_to_right_ = is_pinned_to_right;
}
-void ScrollDetector::CheckForTopBottomEdges(EWebView* web_view, int scroll_y) {
+void ScrollDetector::CheckForTopBottomEdges(int scroll_y) {
bool is_pinned_to_top = scroll_y <= min_Scroll_.y();
bool is_pinned_to_bottom = scroll_y >= max_Scroll_.y();
if (is_pinned_to_top && (is_pinned_to_top != cached_is_main_frame_pinned_to_top_)) {
edge_Flag_ = false;
- web_view->SmartCallback<EWebViewCallbacks::EdgeTop>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::EdgeTop>().call();
}
if (is_pinned_to_bottom && (is_pinned_to_bottom != cached_is_main_frame_pinned_to_bottom_)) {
edge_Flag_ = false;
- web_view->SmartCallback<EWebViewCallbacks::EdgeBottom>().call();
+ web_view_->SmartCallback<EWebViewCallbacks::EdgeBottom>().call();
}
cached_is_main_frame_pinned_to_top_ = is_pinned_to_top;
cached_is_main_frame_pinned_to_bottom_ = is_pinned_to_bottom;
}
-
-} // namespace EflWebview
class EWebView;
-namespace EflWebview {
-
class ScrollDetector {
public:
- ScrollDetector();
- void OnChangeScrollOffset(EWebView* web_view,
- const gfx::Vector2d& scroll_position);
+ ScrollDetector(EWebView* web_view);
+ void OnChangeScrollOffset(const gfx::Vector2d& scroll_position);
void SetMaxScroll(int x, int y);
gfx::Vector2d GetLastScrollPosition() const { return last_scroll_position_; }
+ bool IsScrollOffsetChanged() const { return scroll_offset_changed_; }
+ void SetScrollOffsetChanged() { scroll_offset_changed_ = true; }
private:
- void DetectEdge(EWebView* web_view, const gfx::Vector2d& scroll_delta);
- void CheckForLeftRightEdges(EWebView* web_view, int scroll_x);
- void CheckForTopBottomEdges(EWebView* web_view, int sroll_y);
+ void DetectEdge(const gfx::Vector2d& scroll_delta);
+ void CheckForLeftRightEdges(int scroll_x);
+ void CheckForTopBottomEdges(int sroll_y);
+ EWebView* web_view_;
gfx::Vector2d last_scroll_position_;
gfx::Vector2d max_Scroll_;
gfx::Vector2d min_Scroll_;
bool cached_is_main_frame_pinned_to_top_;
bool cached_is_main_frame_pinned_to_bottom_;
bool edge_Flag_;
+ bool scroll_offset_changed_;
};
-} // namespace EflWebview
-
#endif //_SCROLL_DETECTOR_H