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 using namespace WebCore;
82 PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
83 : m_viewImpl(viewImpl)
85 , m_viewportConstraints()
86 , m_viewFocused(false)
87 , m_viewWindowActive(true)
88 , m_pageDidRendered(true)
90 , m_viewportFitsToContent(false)
91 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
92 , m_visibleContentRect(IntRect())
94 , m_hasSuspendedContent(false)
96 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
97 , m_restoredScaleFactor(0)
99 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
100 , m_scrollPositionBeforePageRendered(IntPoint())
103 , m_deferUpdateViewportSize(false)
104 , m_isScrollableLayerFocused(false)
105 , m_isScrollableNodeFocused(false)
106 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
107 , m_shouldMakeBackupTexture(false)
108 , m_shouldShowBackupTexture(false)
110 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
111 , m_isContextMenuVisible(false)
113 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
114 , m_waitFrameOfNewViewortSize(false)
116 , m_nonemptyLayoutRendered(false)
117 #endif // #if OS(TIZEN)
119 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
120 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
121 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
125 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
126 m_textSelection = TextSelection::create(m_viewImpl);
128 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
129 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
131 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
132 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
134 #if ENABLE(TIZEN_DRAG_SUPPORT)
135 m_drag = Drag::create(m_viewImpl);
137 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
138 m_autoFillManager = AutoFillManager::create(m_viewImpl);
140 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
141 m_viewportAngle = ecore_evas_rotation_get(ee);
144 setBackgroundColor(1, 1, 1, 1);
147 PageClientImpl::~PageClientImpl()
149 if (m_viewImpl && m_viewImpl->page())
150 m_viewImpl->page()->close();
154 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
156 PageClientImpl::ViewportConstraints constraints;
157 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
158 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
159 constraints.userScalable = attributes.userScalable;
160 constraints.layoutSize = attributes.layoutSize;
161 constraints.fixedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
163 bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
164 if (autoFittingEnabled)
165 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
167 // if content doesn't set initial scale value, set readable scale factor
168 // if not, set initial scale factor of viewport attribute
169 if (attributes.initialScale == ViewportArguments::ValueAuto) {
170 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
171 // Enable fixedInitialScale like content is defining initial scale factor.
172 // Because it should be fixed by disabled auto fit setting
173 constraints.fixedInitialScale = true;
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);
196 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
197 if (m_deferUpdateViewportSize) {
198 m_visibleContentRect.setSize(viewportSize);
199 m_viewImpl->page()->setViewportSize(viewportSize);
200 m_deferUpdateViewportSize = false;
205 // update viewport size of webkit
206 m_visibleContentRect.setSize(viewportSize);
207 m_viewImpl->page()->setViewportSize(viewportSize);
210 void PageClientImpl::updateVisibleContentRectSize(const IntSize& size)
212 // update visible content rect's size and scroll position
213 m_visibleContentRect.setSize(size);
214 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
215 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
217 #if ENABLE(TIZEN_DLOG_SUPPORT)
218 TIZEN_LOGI("size: [%d, %d], visibleContentRect: [%d, %d, %d, %d]", size.width(), size.height(),
219 m_visibleContentRect.x(), m_visibleContentRect.y(), m_visibleContentRect.width(), m_visibleContentRect.height());
224 void PageClientImpl::prepareRestoredVisibleContectRect()
226 m_restoredScaleFactor = scaleFactor();
227 m_restoredScrollPosition = scrollPosition();
228 #if ENABLE(TIZEN_DLOG_SUPPORT)
229 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
233 void PageClientImpl::initializeVisibleContentRect()
235 _ewk_view_resume_painting(m_viewImpl->view());
237 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
238 IntPoint initialScrollPosition;
239 float initialScaleFactor = m_viewportConstraints.initialScale;
240 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
241 initialScrollPosition = m_scrollPositionBeforePageRendered;
242 m_scrollPositionBeforePageRendered = IntPoint();
244 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
245 // if scroll position and scale factor are restored by history controller,
246 // move scroll position and scale factor with them
247 if (m_restoredScaleFactor) {
248 initialScrollPosition = m_restoredScrollPosition;
249 initialScaleFactor = m_restoredScaleFactor;
251 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
252 m_restoredScaleFactor = 0;
254 #if ENABLE(TIZEN_DLOG_SUPPORT)
255 TIZEN_LOGI("visibleContentRect: [%d, %d, %d, %d], scale factor: [%.2f]",
256 initialScrollPosition.x(), initialScrollPosition.y(),
257 m_visibleContentRect.width(), m_visibleContentRect.height(), initialScaleFactor);
260 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
262 // Set initial scale.
263 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
267 double PageClientImpl::availableMinimumScale()
269 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
270 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
271 IntSize contentsSize = m_viewImpl->page()->contentsSize();
272 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
273 return horizontalMinScale;
276 void PageClientImpl::fitViewportToContent()
278 #if ENABLE(TIZEN_DLOG_SUPPORT)
279 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), m_viewportConstraints.minimumScale);
281 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
284 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
286 m_focusedNodeRect = focusedNodeRect;
289 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
290 bool PageClientImpl::scrollBy(IntSize scrollOffset)
292 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
293 // scrollOffset means device screen coordiate, not an actual offset of contents.
294 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
295 // in the actual scale.
296 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
297 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
298 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
304 IntPoint oldScrollPosition = scrollPosition();
305 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
310 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
312 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
314 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
316 #endif // #if OS(TIZEN)
318 EwkViewImpl* PageClientImpl::viewImpl() const
324 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
326 return DrawingAreaProxyImpl::create(m_viewImpl->page());
329 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
332 ewk_view_mark_for_sync(m_viewImpl->view());
334 m_viewImpl->redrawRegion(rect);
338 void PageClientImpl::displayView()
343 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
345 setViewNeedsDisplay(scrollRect);
348 WebCore::IntSize PageClientImpl::viewSize()
350 return m_viewImpl->size();
353 bool PageClientImpl::isViewVisible()
358 return m_viewImpl->isVisible();
362 bool PageClientImpl::isViewInWindow()
368 void PageClientImpl::processDidCrash()
370 // Check if loading was ongoing, when web process crashed.
371 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
372 if (loadProgress >= 0 && loadProgress < 1)
373 m_viewImpl->informLoadProgress(1);
375 m_viewImpl->informWebProcessCrashed();
378 void PageClientImpl::didRelaunchProcess()
380 const char* themePath = m_viewImpl->themePath();
382 m_viewImpl->page()->setThemePath(themePath);
385 void PageClientImpl::pageClosed()
390 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
392 m_viewImpl->informTooltipTextChange(newToolTip);
395 void PageClientImpl::setCursor(const Cursor& cursor)
397 m_viewImpl->setCursor(cursor);
400 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
405 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
407 double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
408 m_viewportConstraints = computeViewportConstraints(attributes);
410 // Initially, m_scaleFactor is not decided yet.
411 // So, we should update visible content rect at here.
412 if (!m_scaleFactor) {
413 m_scaleFactor = m_viewportConstraints.initialScale;
417 // if content is reloaded, contents size will not be changed
418 // so, we need to calculate minimum scale here.
419 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
420 if (m_viewportConstraints.userScalable) {
421 if (!m_viewportConstraints.fixedInitialScale
422 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
423 m_viewportConstraints.initialScale = availableMinimumScale();
424 m_viewportConstraints.minimumScale = availableMinimumScale();
427 #if ENABLE(TIZEN_GESTURE)
428 m_viewImpl->setDoubleTapEnabled(userScalable());
431 #if ENABLE(TIZEN_DLOG_SUPPORT)
432 TIZEN_LOGI("layout size: [%d, %d], scale: [%.2f, %.2f, %.2f], user scalable: [%s]",
433 m_viewportConstraints.layoutSize.width(), m_viewportConstraints.layoutSize.height(),
434 m_viewportConstraints.initialScale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale,
435 m_viewportConstraints.userScalable ? "TRUE" : "FALSE");
438 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
439 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
442 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
443 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
446 float newScale = scaleFactor();
447 IntPoint newScrollPosition = m_visibleContentRect.location();
448 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
449 int angle = ecore_evas_rotation_get(ee);
450 bool isRotated = (angle != m_viewportAngle);
452 // if it's rotated, we need to fit content to viewport by minimize the scale
454 m_viewportAngle = angle;
455 newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
456 if (m_viewportFitsToContent)
457 newScale = m_viewportConstraints.minimumScale;
458 newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
461 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
462 if (m_waitFrameOfNewViewortSize)
463 ewk_view_resume(m_viewImpl->view());
465 #if ENABLE(TIZEN_DLOG_SUPPORT)
466 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated");
469 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
470 setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
472 m_viewImpl->page()->scalePage(newScale, newScrollPosition);
475 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
476 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
477 if (smartData->api->formdata_candidate_is_showing(smartData))
478 smartData->api->formdata_candidate_hide(smartData);
481 #if ENABLE(TIZEN_FULLSCREEN_API)
482 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
483 m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle();
488 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
490 if (undoOrRedo == WebPageProxy::Undo) {
491 m_undoCommands.append(command);
493 int undoSize = m_undoCommands.size();
494 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
497 m_redoCommands.append(command);
499 int redoSize = m_redoCommands.size();
500 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
504 void PageClientImpl::clearAllEditCommands()
506 m_undoCommands.clear();
507 m_redoCommands.clear();
509 int undoSize = m_undoCommands.size();
510 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
512 int redoSize = m_redoCommands.size();
513 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
516 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
518 if (undoOrRedo == WebPageProxy::Undo)
519 return !m_undoCommands.isEmpty();
521 return !m_redoCommands.isEmpty();
524 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
526 if (undoOrRedo == WebPageProxy::Undo) {
527 m_undoCommands.last()->unapply();
528 m_undoCommands.removeLast();
530 int undoSize = m_undoCommands.size();
531 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
533 m_redoCommands.last()->reapply();
534 m_redoCommands.removeLast();
536 int redoSize = m_redoCommands.size();
537 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
541 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
546 void PageClientImpl::clearAllEditCommands()
551 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
557 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
563 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
569 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
575 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
581 IntRect PageClientImpl::windowToScreen(const IntRect&)
587 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
592 #if ENABLE(GESTURE_EVENTS)
593 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
599 #if ENABLE(TOUCH_EVENTS)
600 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
603 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
606 #endif // #if OS(TIZEN)
610 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
612 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
615 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
617 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
618 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
625 #if ENABLE(INPUT_TYPE_COLOR)
626 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
633 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
639 #if USE(ACCELERATED_COMPOSITING)
640 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
642 m_viewImpl->enterAcceleratedCompositingMode();
645 void PageClientImpl::exitAcceleratedCompositingMode()
647 m_viewImpl->exitAcceleratedCompositingMode();
650 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
654 #endif // USE(ACCELERATED_COMPOSITING)
657 void PageClientImpl::initializeAcceleratedCompositingMode()
661 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
662 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
666 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
668 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
670 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
671 m_bgColor.setRGB(rgba);
674 void PageClientImpl::didChangeScrollbarsForMainFrame() const
680 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
682 m_nonemptyLayoutRendered = true;
683 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
684 m_initialViewRect.setSize(viewSize());
688 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
690 #if ENABLE(TIZEN_DLOG_SUPPORT)
691 TIZEN_LOGI(" [%d, %d]", size.width(), size.height());
693 #if USE(TILED_BACKING_STORE)
697 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
698 if (drawingArea()->layerTreeCoordinatorProxy())
699 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
702 // if minimum scale factor is changed, update minimumScale.
703 if (m_viewportConstraints.userScalable) {
704 double minimumScale = availableMinimumScale();
706 // Sometimes initializeVisibleContentRect can be called after content size change.
707 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
708 if (!m_viewportConstraints.fixedInitialScale
709 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
710 m_viewportConstraints.initialScale = minimumScale;
711 m_viewportConstraints.minimumScale = minimumScale;
712 #if ENABLE(TIZEN_GESTURE)
713 m_viewImpl->setDoubleTapEnabled(userScalable());
717 m_viewImpl->informContentsSizeChange(size);
719 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
722 // FIXME: Do we really need to adjust visible content rect at here?
723 // if contents size is changed smaller and visible content rect is outside of content area,
724 // adjust visible content rect
725 bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect);
726 bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits<float>::epsilon());
727 if (needScrollAdjustment || needScaleAdjustment) {
728 #if ENABLE(TIZEN_DLOG_SUPPORT)
729 TIZEN_LOGI(" setVisibleContentRect: [%d, %d], [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), scaleFactor());
731 setVisibleContentRect(m_visibleContentRect, scaleFactor());
735 void PageClientImpl::pageScaleFactorDidChange()
737 ewk_view_focused_node_adjust(m_viewImpl->view());
739 #endif // #if OS(TIZEN)
741 void PageClientImpl::didCommitLoadForMainFrame(bool)
744 m_pageDidRendered = false;
745 m_viewportFitsToContent = false;
746 m_nonemptyLayoutRendered = false;
752 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
757 double PageClientImpl::customRepresentationZoomFactor()
763 void PageClientImpl::setCustomRepresentationZoomFactor(double)
768 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
773 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
778 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
783 void PageClientImpl::updateTextInputState()
785 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
786 m_textSelection->update();
787 if (isTextSelectionMode() && isTextSelectionHandleDowned())
791 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
792 if (inputMethodContext)
793 inputMethodContext->updateTextInputState();
796 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
798 Ewk_Context* context = m_viewImpl->ewkContext();
799 context->downloadManager()->registerDownload(download, m_viewImpl);
802 #if USE(TILED_BACKING_STORE)
803 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
805 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
806 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
807 if (smartData->api->formdata_candidate_is_showing(smartData))
810 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
811 IntPoint newPoint = point;
812 newPoint.scale(scaleFactor(), scaleFactor());
813 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
814 if (!m_pageDidRendered)
815 m_scrollPositionBeforePageRendered = newPoint;
817 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
819 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
826 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
827 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
829 m_restoredScrollPosition = point;
830 m_restoredScrollPosition.scale(scale, scale);
831 m_restoredScaleFactor = scale;
832 #if ENABLE(TIZEN_DLOG_SUPPORT)
833 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
836 // Before contents size is fixed, just update visible content rect's position
837 m_visibleContentRect.setLocation(m_restoredScrollPosition);
841 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
842 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
844 if (value == m_autoFillManager->getCandidateValue()) {
845 m_autoFillManager->updateCandidateValue(emptyString());
849 #if ENABLE(TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM)
850 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value, isInputInForm);
852 m_autoFillManager->updateCandidateValue(value);
853 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
854 #endif // TIZEN_WEBKIT2_AUTOFILL_PROFILE_FORM
858 void PageClientImpl::updateFormNavigation(int length, int offset)
863 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
864 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
865 DrawingAreaProxy* PageClientImpl::drawingArea() const
867 return m_viewImpl->page()->drawingArea();
871 // Before rendering, scale factor and scroll position is different from m_viewImpl.
872 float PageClientImpl::scaleFactor()
874 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
877 const IntPoint PageClientImpl::scrollPosition()
879 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
882 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
884 IntSize contentsSize = m_viewImpl->page()->contentsSize();
885 contentsSize.scale(targetScale);
886 if (contentsSize.width() < visibleContentRect.width())
887 visibleContentRect.setX(0);
889 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
891 if (contentsSize.height() < visibleContentRect.height())
892 visibleContentRect.setY(0);
894 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
895 return visibleContentRect;
898 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
900 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
901 if(isShowingAutoFillPopup())
906 IntPoint previousScrollPosition(m_viewImpl->scrollPosition());
907 float previousScale = m_viewImpl->scaleFactor();
910 m_scaleFactor = adjustScaleWithViewport(newScale);
911 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
912 m_visibleContentRect.setLocation(newRect.location());
913 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
915 // update both drawing scale factor and scroll position after page is rendered
916 if (m_pageDidRendered) {
917 if (!m_hasSuspendedContent) {
918 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
919 // PageViewport's values are updated when resuming content in the webkit opensource,
920 // but we have to update viewImpl's values here to sync with PageClient's values.
921 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
922 // The values will be updated when resuming content.
923 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
924 m_viewImpl->setScaleFactor(m_scaleFactor);
925 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
929 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
930 // So we removed enclosingIntRect and replaced with floorf and ceilf.
931 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
932 floorf(m_visibleContentRect.y() / m_scaleFactor),
933 ceilf(m_visibleContentRect.width() / m_scaleFactor),
934 ceilf(m_visibleContentRect.height() / m_scaleFactor));
937 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
938 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
939 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
940 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
944 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
945 if (m_viewImpl->focusRing())
946 m_viewImpl->focusRing()->didChangeVisibleContentRect(previousScrollPosition, previousScale);
949 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
950 if (!isClipboardWindowOpened())
951 updateTextSelectionHandlesAndContextMenu(true);
955 void PageClientImpl::displayViewport()
957 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
959 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
964 void PageClientImpl::drawContents()
968 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
971 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
972 cairo_transform(context, &matrix);
975 if (drawingArea()->layerTreeCoordinatorProxy()) {
976 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
977 renderer->paintToGraphicsContext(context, m_bgColor);
981 cairo_restore(context);
984 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
986 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
987 // We don't want to process scaling in the FullScreen mode.
988 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
992 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
993 m_textSelection->hideHandlers();
996 // Adjust scaleFactor.
997 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
998 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
999 scaleFactor = adjustScaleWithViewport(scaleFactor);
1001 scaleFactor = adjustScaleWithViewport(scaleFactor);
1004 scaleContents(scaleFactor, scrollPosition);
1007 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
1009 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1010 // We don't want to process scaling in the FullScreen mode.
1011 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
1014 scaleFactor = adjustScaleWithViewport(scaleFactor);
1016 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
1019 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1020 // so below code should be replaced when PageViewportController codes are merged.
1021 // Please do not use below codes. They are only for scaling contents.
1022 void PageClientImpl::suspendContent()
1024 if (m_hasSuspendedContent)
1027 m_hasSuspendedContent = true;
1030 void PageClientImpl::resumeContent()
1032 if (!m_hasSuspendedContent)
1035 #if ENABLE(TIZEN_DLOG_SUPPORT)
1036 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_viewImpl->scrollPosition().x(), m_viewImpl->scrollPosition().y(), m_viewImpl->scaleFactor());
1039 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
1040 // The concept is that the values of EwkViewImpl and PageClient can be different
1041 // during suspending content and they become same when content is resumed.
1042 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1043 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
1044 m_hasSuspendedContent = false;
1047 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1049 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1050 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1052 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
1053 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1054 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1056 FloatPoint position;
1057 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1058 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1059 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1064 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1065 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1067 // create if needed.
1068 if (horizontalBar && !m_horizontalScrollbar) {
1069 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
1070 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1071 m_horizontalScrollbar->setFrameRect(hBarRect);
1072 } else if (!horizontalBar && m_horizontalScrollbar)
1073 m_horizontalScrollbar = 0;
1075 if (verticalBar && !m_verticalScrollbar) {
1076 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
1077 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1078 m_verticalScrollbar->setFrameRect(vBarRect);
1079 } else if (!verticalBar && m_verticalScrollbar)
1080 m_verticalScrollbar = 0;
1083 void PageClientImpl::updateScrollbar()
1085 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
1086 scaledContentsSize.scale(scaleFactor());
1088 bool newHasHorizontalScrollbar = false;
1089 bool newVerticalScrollbar = false;
1090 if (viewSize().width() < scaledContentsSize.width())
1091 newHasHorizontalScrollbar = true;
1092 if (viewSize().height() < scaledContentsSize.height())
1093 newVerticalScrollbar = true;
1094 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1096 if (m_horizontalScrollbar) {
1097 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1098 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
1100 if (m_verticalScrollbar) {
1101 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1102 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1106 void PageClientImpl::frameRectChanged()
1108 if (m_horizontalScrollbar) {
1109 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1110 m_horizontalScrollbar->setFrameRect(hBarRect);
1112 if (m_verticalScrollbar) {
1113 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1114 m_verticalScrollbar->setFrameRect(vBarRect);
1118 void PageClientImpl::updateVisibility()
1120 if (m_horizontalScrollbar)
1121 m_horizontalScrollbar->updateVisibility();
1122 if (m_verticalScrollbar)
1123 m_verticalScrollbar->updateVisibility();
1126 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1128 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1129 bool PageClientImpl::isTextSelectionDowned()
1131 return m_textSelection->isTextSelectionDowned();
1134 bool PageClientImpl::isTextSelectionMode()
1136 return m_textSelection->isTextSelectionMode();
1139 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1141 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1144 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1146 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1147 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1150 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point)
1152 if (!evas_object_focus_get(m_viewImpl->view())) {
1153 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1154 if (inputMethodContext)
1155 inputMethodContext->hideIMFContext();
1157 evas_object_focus_set(m_viewImpl->view(), true);
1160 return m_textSelection->textSelectionDown(point);
1163 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point)
1165 m_textSelection->textSelectionMove(point);
1168 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1170 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1173 bool PageClientImpl::isTextSelectionHandleDowned()
1175 return m_textSelection->isTextSelectionHandleDowned();
1178 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1179 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1181 m_textSelection->textSelectionHandleDown(point);
1184 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1186 m_textSelection->textSelectionHandleMove(point);
1189 void PageClientImpl::textSelectonHandleUp()
1191 m_textSelection->textSelectionHandleUp();
1195 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1197 m_textSelection->requestToShow();
1200 void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
1202 m_textSelection->initHandlesMouseDownedStatus();
1205 void PageClientImpl::changeContextMenuPosition(IntPoint& point)
1207 m_textSelection->changeContextMenuPosition(point);
1211 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1212 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1214 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1217 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1219 m_offlinePageSave->saveSubresourcesData(subresourceData);
1222 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1224 m_offlinePageSave->startOfflinePageSave(path, url, title);
1228 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1229 void PageClientImpl::pasteContextMenuSelected()
1231 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1235 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1236 void PageClientImpl::setClipboardData(const String& data, const String& type)
1238 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1239 m_clipboardHelper->setData(data, type);
1243 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1244 void PageClientImpl::clipboardContextMenuSelected()
1246 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1249 bool PageClientImpl::isClipboardWindowOpened()
1251 return m_clipboardHelper->isClipboardWindowOpened();
1254 void PageClientImpl::closeClipboardWindow()
1256 m_clipboardHelper->closeClipboardWindow();
1260 void PageClientImpl::clearClipboardData()
1262 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1263 m_clipboardHelper->clear();
1268 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1269 void PageClientImpl::setIsVisible(bool isVisible)
1271 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1272 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1273 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1274 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1275 int angle = ecore_evas_rotation_get(ee);
1276 if (angle == 0 || angle == 180) {
1277 m_shouldMakeBackupTexture = true;
1278 m_shouldShowBackupTexture = true;
1285 m_isVisible = isVisible;
1287 WebPageProxy* pageProxy = m_viewImpl->page();
1289 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1291 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1293 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1298 #if ENABLE(TIZEN_DRAG_SUPPORT)
1299 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1301 m_drag->setDragPoint(point);
1303 bool PageClientImpl::isDragMode()
1305 return m_drag->isDragMode();
1307 void PageClientImpl::setDragMode(bool isDragMode)
1309 m_drag->setDragMode(isDragMode);
1311 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1313 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1314 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1316 String dragStorageName("Drag");
1317 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1319 m_drag->setDragData(dragInfo, dragImage);
1324 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1325 bool PageClientImpl::isShowingAutoFillPopup()
1327 return m_autoFillManager->isShowing();
1330 void PageClientImpl::updateAutoFillPopup(const Vector<AutoFillPopupItem>& data)
1332 m_autoFillManager->updateFormData(data);
1335 void PageClientImpl::hideAutoFillPopup()
1337 m_autoFillManager->hide();
1340 void PageClientImpl::showAutoFillPopup(const WebCore::IntRect& rect)
1342 m_autoFillManager->show(rect);
1346 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1347 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1349 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1353 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1354 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1356 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1359 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1361 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1365 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1366 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1368 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1371 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1373 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1376 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1378 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1382 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1383 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1385 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1388 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1390 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1394 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1395 bool PageClientImpl::getStandaloneStatus()
1397 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1401 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1402 bool PageClientImpl::lockOrientation(int willLockOrientation)
1404 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1407 void PageClientImpl::unlockOrientation()
1409 ewk_view_orientation_unlock(m_viewImpl->view());
1414 bool PageClientImpl::canUpdateVisibleContentRect()
1416 // Visible content rect can be updated when below conditions are satisfied
1417 // 1. page render is done(m_pageDidRendered && (m_viewImpl->page()->estimatedProgress())
1418 // 2. function call count of both updateViewportSize() and didChangeViewportProperties() should be matched
1419 return m_pageDidRendered && (m_viewImpl->page()->estimatedProgress() > 0.1);
1423 void PageClientImpl::didRenderFrame()
1425 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1426 if (m_shouldShowBackupTexture && m_isVisible)
1427 m_shouldShowBackupTexture = false;
1429 if (!m_pageDidRendered) {
1430 m_pageDidRendered = true;
1431 initializeVisibleContentRect();
1434 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
1435 if (m_waitFrameOfNewViewortSize) {
1436 m_waitFrameOfNewViewortSize = false;
1437 ewkViewRotatePrepared(m_viewImpl->view());
1442 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1443 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1445 setIsScrollableLayerFocused(false);
1446 setIsScrollableNodeFocused(false);
1450 setIsScrollableLayerFocused(true);
1451 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1453 setIsScrollableNodeFocused(true);
1458 void PageClientImpl::findScrollableNode(const IntPoint& point)
1460 WebPageProxy* pageProxy = m_viewImpl->page();
1461 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1462 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1463 WebLayerID webLayerID = 0;
1464 bool checkOverflowLayer = false;
1465 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1466 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1467 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1469 bool result = pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID);
1470 setOverflowResult(result, webLayerID);
1475 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1477 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1480 #if ENABLE(TIZEN_ICON_DATABASE)
1481 void PageClientImpl::didReceiveIcon()
1483 ewkViewIconReceived(m_viewImpl->view());
1486 #endif // #if OS(TIZEN)
1489 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1490 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1491 : PageClientImpl(viewImpl)
1497 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1500 , m_isAcceleratedCompositingModeInitialized(false)
1502 initializeAcceleratedCompositingMode();
1505 PageClientEvasGL::~PageClientEvasGL()
1507 if (m_viewImpl && m_viewImpl->page())
1508 m_viewImpl->page()->close();
1511 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
1513 PageClientImpl::updateViewportSize(viewportSize, angle);
1516 void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size)
1519 evas_gl_surface_destroy(m_evasGL, m_surface);
1524 PageClientImpl::updateVisibleContentRectSize(size);
1527 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1529 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1530 if (!isDirectRendering())
1533 m_viewImpl->redrawRegion(rect);
1536 void PageClientEvasGL::displayViewport()
1538 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1539 // We should not draw here when Direct Rendering is enabled.
1540 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1541 if (isDirectRendering())
1542 ewk_view_mark_for_sync(m_viewImpl->view());
1545 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1547 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1552 void PageClientEvasGL::drawContents()
1554 if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()) || !m_isVisible)
1557 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1561 if (!makeContextCurrent())
1564 WebCore::TransformationMatrix matrix;
1566 IntSize ewkViewSize = viewSize();
1568 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1569 if (isDirectRendering()) {
1570 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1571 m_angle = ecore_evas_rotation_get(ee);
1572 renderer->setAngle(m_angle);
1573 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1575 if (m_angle == 90 || m_angle == 270) {
1576 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1578 matrix.translate(-ewkViewSize.width(), 0);
1579 else if (m_angle == 270)
1580 matrix.translate(0, -ewkViewSize.height());
1581 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1583 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1585 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1586 clipRect = IntRect(IntPoint(), ewkViewSize);
1591 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1592 clipRect = IntRect(IntPoint(), ewkViewSize);
1595 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1597 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1598 if (m_shouldMakeBackupTexture) {
1599 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1600 glClearColor(1, 1, 1, 1);
1601 glClear(GL_COLOR_BUFFER_BIT);
1602 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1603 m_shouldMakeBackupTexture = false;
1604 } else if (m_shouldShowBackupTexture) {
1605 matrix.makeIdentity();
1606 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1607 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1610 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1613 void PageClientEvasGL::didRenderFrame()
1615 ewkViewFrameRendered(m_viewImpl->view());
1616 PageClientImpl::didRenderFrame();
1619 bool PageClientEvasGL::makeContextCurrent()
1621 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1624 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1626 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1628 m_config = evas_gl_config_new();
1629 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1630 char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
1631 if (!directRenderingEnv || atoi(directRenderingEnv)) {
1632 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1633 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1636 m_config->color_format = EVAS_GL_RGBA_8888;
1637 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1638 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1640 m_evasGL = evas_gl_new(evas);
1642 evas_gl_config_free(m_config);
1644 TIZEN_LOGE("failed to create evas_gl");
1648 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1650 evas_gl_free(m_evasGL);
1652 evas_gl_config_free(m_config);
1654 TIZEN_LOGE("failed to get evas_gl_api");
1657 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1659 m_context = evas_gl_context_create(m_evasGL, 0);
1661 evas_gl_free(m_evasGL);
1663 evas_gl_config_free(m_config);
1665 TIZEN_LOGE("failed to create evas_gl_context");
1670 m_isAcceleratedCompositingModeInitialized = true;
1673 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1677 evas_gl_surface_destroy(m_evasGL, m_surface);
1681 evas_gl_context_destroy(m_evasGL, m_context);
1685 evas_gl_config_free(m_config);
1688 evas_gl_free(m_evasGL);
1692 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1693 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1695 m_isAcceleratedCompositingModeInitialized = false;
1698 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1700 if (!m_isAcceleratedCompositingModeInitialized)
1701 initializeAcceleratedCompositingMode();
1704 void PageClientEvasGL::exitAcceleratedCompositingMode()
1706 if (m_isAcceleratedCompositingModeInitialized)
1707 finalizeAcceleratedCompositingMode();
1710 void PageClientEvasGL::setTargetSurface()
1716 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1717 if (width == 0 || height == 0)
1720 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1722 TIZEN_LOGE("failed to create Evas_GL_Surface");
1726 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1727 if (isDirectRendering())
1728 makeContextCurrent();
1732 if (makeContextCurrent()) {
1733 glViewport(0, 0, width, height);
1734 glClearColor(1.0, 1.0, 1.0, 1.0);
1735 glClear(GL_COLOR_BUFFER_BIT);
1740 Evas_Native_Surface nativeSurface;
1741 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1742 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1746 } // namespace WebKit