2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "PageClientImpl.h"
29 #include "EwkViewImpl.h"
30 #include "InputMethodContextEfl.h"
31 #include "NativeWebKeyboardEvent.h"
32 #include "NotImplemented.h"
33 #include "TransformationMatrix.h"
34 #include "WebContext.h"
35 #include "WebContextMenuProxy.h"
36 #include "WebPageProxy.h"
37 #include "WebPopupMenuProxyEfl.h"
38 #include "ewk_context.h"
39 #include "ewk_context_private.h"
40 #include "ewk_download_job.h"
41 #include "ewk_download_job_private.h"
45 #include "DrawingAreaProxyImpl.h"
47 #include "EflScreenUtilities.h"
48 #include "LayerTreeCoordinatorProxy.h"
49 #include "OpenGLShims.h"
50 #include "WebContextMenuProxyTizen.h"
51 #include "WebLayerTreeRenderer.h"
52 #include "WebPageGroup.h"
53 #include "WebPageMessages.h"
54 #include "WebPopupMenuProxyEfl.h"
55 #include "WebPreferences.h"
57 #include <Ecore_Evas.h>
60 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
61 #include "MainFrameScrollbarTizen.h"
64 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
65 #include "ClipboardHelper.h"
68 #if ENABLE(TIZEN_DRAG_SUPPORT)
73 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
74 #include "ewk_context_private.h"
77 #if ENABLE(TIZEN_SCREEN_READER)
78 #include "ScreenReaderProxy.h"
81 using namespace WebCore;
86 PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
87 : m_viewImpl(viewImpl)
89 , m_viewportConstraints()
90 , m_viewFocused(false)
91 , m_viewWindowActive(true)
92 , m_pageDidRendered(true)
94 , m_viewportFitsToContent(false)
95 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
96 , m_visibleContentRect(IntRect())
98 , m_hasSuspendedContent(false)
100 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
101 , m_restoredScaleFactor(0)
103 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
104 , m_scrollPositionBeforePageRendered(IntPoint())
107 , m_isScrollableLayerFocused(false)
108 , m_isScrollableNodeFocused(false)
109 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
110 , m_shouldMakeBackupTexture(false)
111 , m_shouldShowBackupTexture(false)
113 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
114 , m_isContextMenuVisible(false)
116 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
117 , m_waitFrameOfNewViewortSize(false)
119 , m_nonemptyLayoutRendered(false)
120 #endif // #if OS(TIZEN)
122 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
123 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
124 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
128 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
129 m_textSelection = TextSelection::create(m_viewImpl);
131 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
132 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
134 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
135 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
137 #if ENABLE(TIZEN_DRAG_SUPPORT)
138 m_drag = Drag::create(m_viewImpl);
140 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
141 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
143 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
144 m_viewportAngle = ecore_evas_rotation_get(ee);
147 setBackgroundColor(1, 1, 1, 1);
150 PageClientImpl::~PageClientImpl()
152 if (m_viewImpl && m_viewImpl->page())
153 m_viewImpl->page()->close();
157 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
159 PageClientImpl::ViewportConstraints constraints;
160 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
161 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
162 constraints.userScalable = attributes.userScalable;
163 constraints.layoutSize = attributes.layoutSize;
164 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
166 bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
167 if (autoFittingEnabled)
168 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
170 // if content doesn't set initial scale value, set readable scale factor
171 // if not, set initial scale factor of viewport attribute
172 if (attributes.initialScale == ViewportArguments::ValueAuto)
173 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
175 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
178 // adjust scale with both minimum and maximum scale factor
179 constraints.initialScale = adjustScaleWithViewport(constraints.initialScale);
184 double PageClientImpl::adjustScaleWithViewport(double scale)
186 double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
187 return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale);
190 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
191 void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle)
193 #if ENABLE(TIZEN_DLOG_SUPPORT)
194 TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle);
197 // update viewport size of webkit
198 m_viewImpl->page()->setViewportSize(viewportSize);
201 void PageClientImpl::updateVisibleContentRectSize(const IntSize& size)
203 // update visible content rect's size
204 m_visibleContentRect.setSize(size);
208 void PageClientImpl::prepareRestoredVisibleContectRect()
210 m_restoredScaleFactor = scaleFactor();
211 m_restoredScrollPosition = scrollPosition();
212 #if ENABLE(TIZEN_DLOG_SUPPORT)
213 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
217 void PageClientImpl::initializeVisibleContentRect()
219 _ewk_view_resume_painting(m_viewImpl->view());
221 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
222 IntPoint initialScrollPosition;
223 float initialScaleFactor = m_viewportConstraints.initialScale;
224 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
225 initialScrollPosition = m_scrollPositionBeforePageRendered;
226 m_scrollPositionBeforePageRendered = IntPoint();
228 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
229 // if scroll position and scale factor are restored by history controller,
230 // move scroll position and scale factor with them
231 if (m_restoredScaleFactor) {
232 initialScrollPosition = m_restoredScrollPosition;
233 initialScaleFactor = m_restoredScaleFactor;
235 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
236 m_restoredScaleFactor = 0;
238 #if ENABLE(TIZEN_DLOG_SUPPORT)
239 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", initialScrollPosition.x(), initialScrollPosition.y(), initialScaleFactor);
242 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
244 // Set initial scale.
245 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
249 double PageClientImpl::availableMinimumScale()
251 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
252 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
253 IntSize contentsSize = m_viewImpl->page()->contentsSize();
254 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
255 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
256 // If there's only a bit ignorable difference between horizontalMinScale and verticalMinScale,
257 // ignore verticalMinScale to fit content's width to view
258 const double ignorableThreshold = 0.01;
259 if (fabs(horizontalMinScale - verticalMinScale) < ignorableThreshold)
260 verticalMinScale = horizontalMinScale;
261 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
264 void PageClientImpl::fitViewportToContent()
266 #if ENABLE(TIZEN_DLOG_SUPPORT)
267 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), m_viewportConstraints.minimumScale);
269 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
272 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
274 m_focusedNodeRect = focusedNodeRect;
277 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
278 bool PageClientImpl::scrollBy(IntSize scrollOffset)
280 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
281 // scrollOffset means device screen coordiate, not an actual offset of contents.
282 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
283 // in the actual scale.
284 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
285 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
286 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
292 IntPoint oldScrollPosition = scrollPosition();
293 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
298 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
300 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
302 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
304 #endif // #if OS(TIZEN)
306 EwkViewImpl* PageClientImpl::viewImpl() const
312 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
314 return DrawingAreaProxyImpl::create(m_viewImpl->page());
317 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
320 ewk_view_mark_for_sync(m_viewImpl->view());
322 m_viewImpl->redrawRegion(rect);
325 #if ENABLE(TIZEN_SCREEN_READER)
326 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
327 m_viewImpl->page()->recalcScreenReaderFocusRect();
331 void PageClientImpl::displayView()
336 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
338 setViewNeedsDisplay(scrollRect);
341 WebCore::IntSize PageClientImpl::viewSize()
343 return m_viewImpl->size();
346 bool PageClientImpl::isViewVisible()
351 return m_viewImpl->isVisible();
355 bool PageClientImpl::isViewInWindow()
361 void PageClientImpl::processDidCrash()
363 // Check if loading was ongoing, when web process crashed.
364 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
365 if (loadProgress >= 0 && loadProgress < 1)
366 m_viewImpl->informLoadProgress(1);
368 m_viewImpl->informWebProcessCrashed();
371 void PageClientImpl::didRelaunchProcess()
373 const char* themePath = m_viewImpl->themePath();
375 m_viewImpl->page()->setThemePath(themePath);
378 void PageClientImpl::pageClosed()
383 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
385 m_viewImpl->informTooltipTextChange(newToolTip);
388 void PageClientImpl::setCursor(const Cursor& cursor)
390 m_viewImpl->setCursor(cursor);
393 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
398 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
400 double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
401 m_viewportConstraints = computeViewportConstraints(attributes);
403 // Initially, m_scaleFactor is not decided yet.
404 // So, we should update visible content rect at here.
405 if (!m_scaleFactor) {
406 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale);
410 // if content is reloaded, contents size will not be changed
411 // so, we need to calculate minimum scale here.
412 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
413 if (m_viewportConstraints.userScalable) {
414 if (fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
415 m_viewportConstraints.initialScale = availableMinimumScale();
416 m_viewportConstraints.minimumScale = availableMinimumScale();
419 #if ENABLE(TIZEN_DLOG_SUPPORT)
420 TIZEN_LOGI("layout size: [%d, %d], scale: [%.2f, %.2f, %.2f], user scalable: [%s]",
421 m_viewportConstraints.layoutSize.width(), m_viewportConstraints.layoutSize.height(),
422 m_viewportConstraints.initialScale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale,
423 m_viewportConstraints.userScalable ? "TRUE" : "FALSE");
426 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
427 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
430 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
431 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
434 float newScale = scaleFactor();
435 IntPoint newScrollPosition = m_visibleContentRect.location();
436 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
437 int angle = ecore_evas_rotation_get(ee);
438 bool isRotated = (angle != m_viewportAngle);
440 // if it's rotated, we need to fit content to viewport by minimize the scale
442 m_viewportAngle = angle;
443 newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
444 newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
447 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
448 if (m_waitFrameOfNewViewortSize)
449 ewk_view_resume(m_viewImpl->view());
451 #if ENABLE(TIZEN_DLOG_SUPPORT)
452 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated");
455 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
456 setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
458 m_viewImpl->page()->scalePage(newScale, newScrollPosition);
461 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
462 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
463 if (smartData->api->formdata_candidate_is_showing(smartData))
464 smartData->api->formdata_candidate_hide(smartData);
467 #if ENABLE(TIZEN_FULLSCREEN_API)
468 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
469 m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle();
474 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
476 if (undoOrRedo == WebPageProxy::Undo) {
477 m_undoCommands.append(command);
479 int undoSize = m_undoCommands.size();
480 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
483 m_redoCommands.append(command);
485 int redoSize = m_redoCommands.size();
486 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
490 void PageClientImpl::clearAllEditCommands()
492 m_undoCommands.clear();
493 m_redoCommands.clear();
495 int undoSize = m_undoCommands.size();
496 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
498 int redoSize = m_redoCommands.size();
499 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
502 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
504 if (undoOrRedo == WebPageProxy::Undo)
505 return !m_undoCommands.isEmpty();
507 return !m_redoCommands.isEmpty();
510 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
512 if (undoOrRedo == WebPageProxy::Undo) {
513 m_undoCommands.last()->unapply();
514 m_undoCommands.removeLast();
516 int undoSize = m_undoCommands.size();
517 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
519 m_redoCommands.last()->reapply();
520 m_redoCommands.removeLast();
522 int redoSize = m_redoCommands.size();
523 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
527 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
532 void PageClientImpl::clearAllEditCommands()
537 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
543 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
549 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
555 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
561 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
567 IntRect PageClientImpl::windowToScreen(const IntRect&)
573 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
578 #if ENABLE(GESTURE_EVENTS)
579 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
585 #if ENABLE(TOUCH_EVENTS)
586 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
589 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
592 #endif // #if OS(TIZEN)
596 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
598 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
601 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
603 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
604 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
611 #if ENABLE(INPUT_TYPE_COLOR)
612 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
619 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
625 #if USE(ACCELERATED_COMPOSITING)
626 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
628 m_viewImpl->enterAcceleratedCompositingMode();
631 void PageClientImpl::exitAcceleratedCompositingMode()
633 m_viewImpl->exitAcceleratedCompositingMode();
636 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
640 #endif // USE(ACCELERATED_COMPOSITING)
643 void PageClientImpl::initializeAcceleratedCompositingMode()
647 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
648 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
652 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
654 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
656 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
657 m_bgColor.setRGB(rgba);
660 void PageClientImpl::didChangeScrollbarsForMainFrame() const
666 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
668 m_nonemptyLayoutRendered = true;
669 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
670 m_initialViewRect.setSize(viewSize());
674 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
676 #if ENABLE(TIZEN_DLOG_SUPPORT)
677 TIZEN_LOGI(" [%d, %d]", size.width(), size.height());
679 #if USE(TILED_BACKING_STORE)
683 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
684 if (drawingArea()->layerTreeCoordinatorProxy())
685 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
688 // if minimum scale factor is changed, update minimumScale.
689 if (m_viewportConstraints.userScalable) {
690 double minimumScale = availableMinimumScale();
692 // Sometimes initializeVisibleContentRect can be called after content size change.
693 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
694 if (!m_viewportConstraints.contentsDefinedInitialScale
695 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
696 m_viewportConstraints.initialScale = minimumScale;
697 m_viewportConstraints.minimumScale = minimumScale;
700 m_viewImpl->informContentsSizeChange(size);
702 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
705 // FIXME: Do we really need to adjust visible content rect at here?
706 // if contents size is changed smaller and visible content rect is outside of content area,
707 // adjust visible content rect
708 bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect);
709 bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits<float>::epsilon());
710 if (needScrollAdjustment || needScaleAdjustment) {
711 #if ENABLE(TIZEN_DLOG_SUPPORT)
712 TIZEN_LOGI(" setVisibleContentRect: [%d, %d], [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), scaleFactor());
714 setVisibleContentRect(m_visibleContentRect, scaleFactor());
718 void PageClientImpl::pageScaleFactorDidChange()
720 ewk_view_focused_node_adjust(m_viewImpl->view());
722 #endif // #if OS(TIZEN)
724 void PageClientImpl::didCommitLoadForMainFrame(bool)
727 m_pageDidRendered = false;
728 m_viewportFitsToContent = false;
729 m_nonemptyLayoutRendered = false;
735 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
740 double PageClientImpl::customRepresentationZoomFactor()
746 void PageClientImpl::setCustomRepresentationZoomFactor(double)
751 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
756 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
761 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
766 void PageClientImpl::updateTextInputState()
768 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
769 m_textSelection->update();
770 if (isTextSelectionMode() && isTextSelectionHandleDowned())
774 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
775 if (inputMethodContext)
776 inputMethodContext->updateTextInputState();
779 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
781 Ewk_Context* context = m_viewImpl->ewkContext();
782 context->downloadManager()->registerDownload(download, m_viewImpl);
785 #if USE(TILED_BACKING_STORE)
786 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
788 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
789 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
790 if (smartData->api->formdata_candidate_is_showing(smartData))
793 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
794 IntPoint newPoint = point;
795 newPoint.scale(scaleFactor(), scaleFactor());
796 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
797 if (!m_pageDidRendered)
798 m_scrollPositionBeforePageRendered = newPoint;
800 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
802 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
809 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
810 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
812 m_restoredScrollPosition = point;
813 m_restoredScrollPosition.scale(scale, scale);
814 m_restoredScaleFactor = scale;
815 #if ENABLE(TIZEN_DLOG_SUPPORT)
816 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
819 // Before contents size is fixed, just update visible content rect's position
820 m_visibleContentRect.setLocation(m_restoredScrollPosition);
824 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
825 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
827 if (value == m_formDataCandidate->getCandidateValue()) {
828 m_formDataCandidate->updateCandidateValue(emptyString());
832 m_formDataCandidate->updateCandidateValue(value);
833 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
837 void PageClientImpl::updateFormNavigation(int length, int offset)
842 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
843 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
844 DrawingAreaProxy* PageClientImpl::drawingArea() const
846 return m_viewImpl->page()->drawingArea();
850 // Before rendering, scale factor and scroll position is different from m_viewImpl.
851 float PageClientImpl::scaleFactor()
853 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
856 const IntPoint PageClientImpl::scrollPosition()
858 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
861 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
863 IntSize contentsSize = m_viewImpl->page()->contentsSize();
864 contentsSize.scale(targetScale);
865 if (contentsSize.width() < visibleContentRect.width())
866 visibleContentRect.setX(0);
868 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
870 if (contentsSize.height() < visibleContentRect.height())
871 visibleContentRect.setY(0);
873 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
874 return visibleContentRect;
877 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
879 #if ENABLE(TIZEN_SCREEN_READER)
880 IntPoint previousScrollPosition(scrollPosition());
881 float previousScale = m_scaleFactor;
884 m_scaleFactor = adjustScaleWithViewport(newScale);
885 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
886 m_visibleContentRect.setLocation(newRect.location());
887 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
889 // update both drawing scale factor and scroll position after page is rendered
890 if (m_pageDidRendered) {
891 if (!m_hasSuspendedContent) {
892 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
893 // PageViewport's values are updated when resuming content in the webkit opensource,
894 // but we have to update viewImpl's values here to sync with PageClient's values.
895 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
896 // The values will be updated when resuming content.
897 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
898 m_viewImpl->setScaleFactor(m_scaleFactor);
899 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
903 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
904 // So we removed enclosingIntRect and replaced with floorf and ceilf.
905 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
906 floorf(m_visibleContentRect.y() / m_scaleFactor),
907 ceilf(m_visibleContentRect.width() / m_scaleFactor),
908 ceilf(m_visibleContentRect.height() / m_scaleFactor));
911 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
912 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
913 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
914 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
918 #if ENABLE(TIZEN_SCREEN_READER)
919 if (ScreenReaderProxy::screenReader().isEnabled()
920 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
921 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
924 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
925 if (!isClipboardWindowOpened())
926 updateTextSelectionHandlesAndContextMenu(true);
930 void PageClientImpl::displayViewport()
932 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
934 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
938 #if ENABLE(TIZEN_SCREEN_READER)
939 m_viewImpl->page()->recalcScreenReaderFocusRect();
943 void PageClientImpl::drawContents()
947 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
950 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
951 cairo_transform(context, &matrix);
954 if (drawingArea()->layerTreeCoordinatorProxy()) {
955 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
956 renderer->paintToGraphicsContext(context, m_bgColor);
960 cairo_restore(context);
963 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
965 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
966 // We don't want to process scaling in the FullScreen mode.
967 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
971 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
972 m_textSelection->hideHandlers();
975 // Adjust scaleFactor.
976 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
977 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
978 scaleFactor = adjustScaleWithViewport(scaleFactor);
980 scaleFactor = adjustScaleWithViewport(scaleFactor);
983 scaleContents(scaleFactor, scrollPosition);
986 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
988 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
989 // We don't want to process scaling in the FullScreen mode.
990 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
993 scaleFactor = adjustScaleWithViewport(scaleFactor);
995 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
998 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
999 // so below code should be replaced when PageViewportController codes are merged.
1000 // Please do not use below codes. They are only for scaling contents.
1001 void PageClientImpl::suspendContent()
1003 if (m_hasSuspendedContent)
1006 m_hasSuspendedContent = true;
1009 void PageClientImpl::resumeContent()
1011 if (!m_hasSuspendedContent)
1014 #if ENABLE(TIZEN_DLOG_SUPPORT)
1015 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_viewImpl->scrollPosition().x(), m_viewImpl->scrollPosition().y(), m_viewImpl->scaleFactor());
1018 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
1019 // The concept is that the values of EwkViewImpl and PageClient can be different
1020 // during suspending content and they become same when content is resumed.
1021 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1022 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
1023 m_hasSuspendedContent = false;
1026 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1028 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1029 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1031 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
1032 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1033 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1035 FloatPoint position;
1036 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1037 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1038 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1043 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1044 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1046 // create if needed.
1047 if (horizontalBar && !m_horizontalScrollbar) {
1048 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
1049 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1050 m_horizontalScrollbar->setFrameRect(hBarRect);
1051 } else if (!horizontalBar && m_horizontalScrollbar)
1052 m_horizontalScrollbar = 0;
1054 if (verticalBar && !m_verticalScrollbar) {
1055 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
1056 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1057 m_verticalScrollbar->setFrameRect(vBarRect);
1058 } else if (!verticalBar && m_verticalScrollbar)
1059 m_verticalScrollbar = 0;
1062 void PageClientImpl::updateScrollbar()
1064 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
1065 scaledContentsSize.scale(scaleFactor());
1067 bool newHasHorizontalScrollbar = false;
1068 bool newVerticalScrollbar = false;
1069 if (viewSize().width() < scaledContentsSize.width())
1070 newHasHorizontalScrollbar = true;
1071 if (viewSize().height() < scaledContentsSize.height())
1072 newVerticalScrollbar = true;
1073 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1075 if (m_horizontalScrollbar) {
1076 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1077 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
1079 if (m_verticalScrollbar) {
1080 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1081 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1085 void PageClientImpl::frameRectChanged()
1087 if (m_horizontalScrollbar) {
1088 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1089 m_horizontalScrollbar->setFrameRect(hBarRect);
1091 if (m_verticalScrollbar) {
1092 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1093 m_verticalScrollbar->setFrameRect(vBarRect);
1097 void PageClientImpl::updateVisibility()
1099 if (m_horizontalScrollbar)
1100 m_horizontalScrollbar->updateVisibility();
1101 if (m_verticalScrollbar)
1102 m_verticalScrollbar->updateVisibility();
1105 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1107 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1108 bool PageClientImpl::isTextSelectionDowned()
1110 return m_textSelection->isTextSelectionDowned();
1113 bool PageClientImpl::isTextSelectionMode()
1115 return m_textSelection->isTextSelectionMode();
1118 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1120 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1123 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1125 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1126 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1129 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1131 if (!evas_object_focus_get(m_viewImpl->view())) {
1132 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1133 if (inputMethodContext)
1134 inputMethodContext->hideIMFContext();
1136 evas_object_focus_set(m_viewImpl->view(), true);
1139 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1142 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1144 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1147 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1149 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1152 bool PageClientImpl::isTextSelectionHandleDowned()
1154 return m_textSelection->isTextSelectionHandleDowned();
1157 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1158 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1160 m_textSelection->textSelectionHandleDown(point);
1163 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1165 m_textSelection->textSelectionHandleMove(point);
1168 void PageClientImpl::textSelectonHandleUp()
1170 m_textSelection->textSelectionHandleUp();
1174 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1176 m_textSelection->requestToShow();
1179 void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
1181 m_textSelection->initHandlesMouseDownedStatus();
1184 void PageClientImpl::changeContextMenuPosition(IntPoint& point)
1186 m_textSelection->changeContextMenuPosition(point);
1190 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1191 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1193 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1196 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1198 m_offlinePageSave->saveSubresourcesData(subresourceData);
1201 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1203 m_offlinePageSave->startOfflinePageSave(path, url, title);
1207 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1208 void PageClientImpl::pasteContextMenuSelected()
1210 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1214 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1215 void PageClientImpl::setClipboardData(const String& data, const String& type)
1217 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1218 m_clipboardHelper->setData(data, type);
1222 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1223 void PageClientImpl::clipboardContextMenuSelected()
1225 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1228 bool PageClientImpl::isClipboardWindowOpened()
1230 return m_clipboardHelper->isClipboardWindowOpened();
1233 void PageClientImpl::closeClipboardWindow()
1235 m_clipboardHelper->closeClipboardWindow();
1239 void PageClientImpl::clearClipboardData()
1241 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1242 m_clipboardHelper->clear();
1247 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1248 void PageClientImpl::setIsVisible(bool isVisible)
1250 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1251 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1252 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1253 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1254 int angle = ecore_evas_rotation_get(ee);
1255 if (angle == 0 || angle == 180) {
1256 m_shouldMakeBackupTexture = true;
1257 m_shouldShowBackupTexture = true;
1264 m_isVisible = isVisible;
1266 WebPageProxy* pageProxy = m_viewImpl->page();
1268 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1270 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1272 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1277 #if ENABLE(TIZEN_DRAG_SUPPORT)
1278 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1280 m_drag->setDragPoint(point);
1282 bool PageClientImpl::isDragMode()
1284 return m_drag->isDragMode();
1286 void PageClientImpl::setDragMode(bool isDragMode)
1288 m_drag->setDragMode(isDragMode);
1290 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1292 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1293 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1295 String dragStorageName("Drag");
1296 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1298 m_drag->setDragData(dragInfo);
1303 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1304 bool PageClientImpl::isShowingFormDataCandidate()
1306 return m_formDataCandidate->isShowing();
1309 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1311 m_formDataCandidate->updateFormData(data);
1314 void PageClientImpl::hideFormDataCandidate()
1316 m_formDataCandidate->hide();
1319 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1321 m_formDataCandidate->show(rect);
1325 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1326 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1328 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1332 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1333 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1335 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1338 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1340 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1344 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1345 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1347 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1350 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1352 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1355 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1357 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1361 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1362 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1364 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1367 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1369 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1373 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1374 bool PageClientImpl::getStandaloneStatus()
1376 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1380 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1381 bool PageClientImpl::lockOrientation(int willLockOrientation)
1383 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1386 void PageClientImpl::unlockOrientation()
1388 ewk_view_orientation_unlock(m_viewImpl->view());
1392 void PageClientImpl::didRenderFrame()
1394 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1395 if (m_shouldShowBackupTexture && m_isVisible)
1396 m_shouldShowBackupTexture = false;
1398 if (!m_pageDidRendered) {
1399 m_pageDidRendered = true;
1400 initializeVisibleContentRect();
1403 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
1404 if (m_waitFrameOfNewViewortSize) {
1405 m_waitFrameOfNewViewortSize = false;
1406 ewkViewRotatePrepared(m_viewImpl->view());
1411 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1412 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1414 setIsScrollableLayerFocused(false);
1415 setIsScrollableNodeFocused(false);
1419 setIsScrollableLayerFocused(true);
1420 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1422 setIsScrollableNodeFocused(true);
1427 void PageClientImpl::findScrollableNode(const IntPoint& point)
1429 WebPageProxy* pageProxy = m_viewImpl->page();
1430 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1431 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1432 WebLayerID webLayerID = 0;
1433 bool checkOverflowLayer = false;
1434 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1435 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1436 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1438 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1443 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1445 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1448 #if ENABLE(TIZEN_ICON_DATABASE)
1449 void PageClientImpl::didReceiveIcon()
1451 ewkViewIconReceived(m_viewImpl->view());
1455 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1456 void PageClientImpl::hideFocusRing()
1458 ewkViewFocusRingHide(m_viewImpl->view());
1461 #endif // #if OS(TIZEN)
1464 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1465 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1466 : PageClientImpl(viewImpl)
1472 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1475 , m_isAcceleratedCompositingModeInitialized(false)
1477 initializeAcceleratedCompositingMode();
1480 PageClientEvasGL::~PageClientEvasGL()
1482 if (m_viewImpl && m_viewImpl->page())
1483 m_viewImpl->page()->close();
1486 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
1488 PageClientImpl::updateViewportSize(viewportSize, angle);
1491 void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size)
1494 evas_gl_surface_destroy(m_evasGL, m_surface);
1499 PageClientImpl::updateVisibleContentRectSize(size);
1502 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1504 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1505 if (!isDirectRendering())
1508 m_viewImpl->redrawRegion(rect);
1510 #if ENABLE(TIZEN_SCREEN_READER)
1511 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1512 m_viewImpl->page()->recalcScreenReaderFocusRect();
1516 void PageClientEvasGL::displayViewport()
1518 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1519 // We should not draw here when Direct Rendering is enabled.
1520 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1521 if (isDirectRendering())
1522 ewk_view_mark_for_sync(m_viewImpl->view());
1525 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1527 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1531 #if ENABLE(TIZEN_SCREEN_READER)
1532 m_viewImpl->page()->recalcScreenReaderFocusRect();
1536 void PageClientEvasGL::drawContents()
1538 if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()))
1541 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1545 if (!makeContextCurrent())
1548 WebCore::TransformationMatrix matrix;
1550 IntSize ewkViewSize = viewSize();
1552 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1553 if (isDirectRendering()) {
1554 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1555 m_angle = ecore_evas_rotation_get(ee);
1556 renderer->setAngle(m_angle);
1557 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1559 if (m_angle == 90 || m_angle == 270) {
1560 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1562 matrix.translate(-ewkViewSize.width(), 0);
1563 else if (m_angle == 270)
1564 matrix.translate(0, -ewkViewSize.height());
1565 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1567 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1569 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1570 clipRect = IntRect(IntPoint(), ewkViewSize);
1575 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1576 clipRect = IntRect(IntPoint(), ewkViewSize);
1579 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1581 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1582 if (m_shouldMakeBackupTexture) {
1583 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1584 glClearColor(1, 1, 1, 1);
1585 glClear(GL_COLOR_BUFFER_BIT);
1586 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1587 m_shouldMakeBackupTexture = false;
1588 } else if (m_shouldShowBackupTexture) {
1589 matrix.makeIdentity();
1590 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1591 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1594 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1597 void PageClientEvasGL::didRenderFrame()
1599 ewkViewFrameRendered(m_viewImpl->view());
1600 PageClientImpl::didRenderFrame();
1603 bool PageClientEvasGL::makeContextCurrent()
1605 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1608 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1610 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1612 m_config = evas_gl_config_new();
1613 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1614 char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
1615 if (!directRenderingEnv || atoi(directRenderingEnv)) {
1616 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1617 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1620 m_config->color_format = EVAS_GL_RGBA_8888;
1621 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1622 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1624 m_evasGL = evas_gl_new(evas);
1626 evas_gl_config_free(m_config);
1628 TIZEN_LOGE("failed to create evas_gl");
1632 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1634 evas_gl_free(m_evasGL);
1636 evas_gl_config_free(m_config);
1638 TIZEN_LOGE("failed to get evas_gl_api");
1641 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1643 m_context = evas_gl_context_create(m_evasGL, 0);
1645 evas_gl_free(m_evasGL);
1647 evas_gl_config_free(m_config);
1649 TIZEN_LOGE("failed to create evas_gl_context");
1654 m_isAcceleratedCompositingModeInitialized = true;
1657 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1661 evas_gl_surface_destroy(m_evasGL, m_surface);
1665 evas_gl_context_destroy(m_evasGL, m_context);
1669 evas_gl_config_free(m_config);
1672 evas_gl_free(m_evasGL);
1676 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1677 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1679 m_isAcceleratedCompositingModeInitialized = false;
1682 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1684 if (!m_isAcceleratedCompositingModeInitialized)
1685 initializeAcceleratedCompositingMode();
1688 void PageClientEvasGL::exitAcceleratedCompositingMode()
1690 if (m_isAcceleratedCompositingModeInitialized)
1691 finalizeAcceleratedCompositingMode();
1694 void PageClientEvasGL::setTargetSurface()
1700 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1701 if (width == 0 || height == 0)
1704 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1706 TIZEN_LOGE("failed to create Evas_GL_Surface");
1710 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1711 if (isDirectRendering())
1712 makeContextCurrent();
1716 if (makeContextCurrent()) {
1717 glViewport(0, 0, width, height);
1718 glClearColor(1.0, 1.0, 1.0, 1.0);
1719 glClear(GL_COLOR_BUFFER_BIT);
1724 Evas_Native_Surface nativeSurface;
1725 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1726 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1730 } // namespace WebKit