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)
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 #endif // #if OS(TIZEN)
118 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
119 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
120 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
124 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
125 m_textSelection = TextSelection::create(m_viewImpl);
127 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
128 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
130 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
131 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
133 #if ENABLE(TIZEN_DRAG_SUPPORT)
134 m_drag = Drag::create(m_viewImpl);
136 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
137 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
139 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
140 m_viewportAngle = ecore_evas_rotation_get(ee);
143 setBackgroundColor(1, 1, 1, 1);
146 PageClientImpl::~PageClientImpl()
148 if (m_viewImpl && m_viewImpl->page())
149 m_viewImpl->page()->close();
153 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
155 PageClientImpl::ViewportConstraints constraints;
156 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
157 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
158 constraints.userScalable = attributes.userScalable;
159 constraints.layoutSize = attributes.layoutSize;
160 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
162 bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
163 if (autoFittingEnabled)
164 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
166 // if content doesn't set initial scale value, set readable scale factor
167 // if not, set initial scale factor of viewport attribute
168 if (attributes.initialScale == ViewportArguments::ValueAuto)
169 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
171 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
174 // adjust scale with both minimum and maximum scale factor
175 constraints.initialScale = adjustScaleWithViewport(constraints.initialScale);
180 double PageClientImpl::adjustScaleWithViewport(double scale)
182 double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
183 return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale);
186 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
187 void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle)
189 // update viewport size of webkit
190 m_visibleContentRect.setSize(viewportSize);
191 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
192 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
193 m_viewImpl->page()->setViewportSize(viewportSize);
197 void PageClientImpl::initializeVisibleContentRect()
199 _ewk_view_resume_painting(m_viewImpl->view());
201 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
202 IntPoint initialScrollPosition;
203 float initialScaleFactor = m_viewportConstraints.initialScale;
204 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
205 // if scroll position and scale factor are restored by history controller,
206 // move scroll position and scale factor with them
207 if (m_restoredScaleFactor) {
208 initialScrollPosition = m_restoredScrollPosition;
209 initialScaleFactor = m_restoredScaleFactor;
212 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
214 // Set initial scale.
215 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
219 double PageClientImpl::availableMinimumScale()
221 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
222 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
223 IntSize contentsSize = m_viewImpl->page()->contentsSize();
224 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
225 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
226 // If there's only a bit ignorable difference between horizontalMinScale and verticalMinScale,
227 // ignore verticalMinScale to fit content's width to view
228 const double ignorableThreshold = 0.01;
229 if (fabs(horizontalMinScale - verticalMinScale) < ignorableThreshold)
230 verticalMinScale = horizontalMinScale;
231 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
234 void PageClientImpl::fitViewportToContent()
236 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
239 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
241 m_focusedNodeRect = focusedNodeRect;
244 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
245 bool PageClientImpl::scrollBy(IntSize scrollOffset)
247 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
248 // scrollOffset means device screen coordiate, not an actual offset of contents.
249 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
250 // in the actual scale.
251 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
252 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
253 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
259 IntPoint oldScrollPosition = scrollPosition();
260 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
265 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
267 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
269 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
271 #endif // #if OS(TIZEN)
273 EwkViewImpl* PageClientImpl::viewImpl() const
279 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
281 return DrawingAreaProxyImpl::create(m_viewImpl->page());
284 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
287 ewk_view_mark_for_sync(m_viewImpl->view());
289 m_viewImpl->redrawRegion(rect);
292 #if ENABLE(TIZEN_SCREEN_READER)
293 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
294 m_viewImpl->page()->recalcScreenReaderFocusRect();
298 void PageClientImpl::displayView()
303 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
305 setViewNeedsDisplay(scrollRect);
308 WebCore::IntSize PageClientImpl::viewSize()
310 return m_viewImpl->size();
313 bool PageClientImpl::isViewVisible()
318 return m_viewImpl->isVisible();
322 bool PageClientImpl::isViewInWindow()
328 void PageClientImpl::processDidCrash()
330 // Check if loading was ongoing, when web process crashed.
331 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
332 if (loadProgress >= 0 && loadProgress < 1)
333 m_viewImpl->informLoadProgress(1);
335 m_viewImpl->informWebProcessCrashed();
338 void PageClientImpl::didRelaunchProcess()
340 const char* themePath = m_viewImpl->themePath();
342 m_viewImpl->page()->setThemePath(themePath);
345 void PageClientImpl::pageClosed()
350 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
352 m_viewImpl->informTooltipTextChange(newToolTip);
355 void PageClientImpl::setCursor(const Cursor& cursor)
357 m_viewImpl->setCursor(cursor);
360 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
365 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
367 double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
368 m_viewportConstraints = computeViewportConstraints(attributes);
370 // Initially, m_scaleFactor is not decided yet.
371 // So, we should update visible content rect at here.
372 if (!m_scaleFactor) {
373 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale);
377 // if content is reloaded, contents size will not be changed
378 // so, we need to calculate minimum scale here.
379 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
380 if (m_viewportConstraints.userScalable) {
381 if (fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
382 m_viewportConstraints.initialScale = availableMinimumScale();
383 m_viewportConstraints.minimumScale = availableMinimumScale();
386 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
387 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
390 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
391 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
394 float newScale = scaleFactor();
395 IntPoint newScrollPosition = m_visibleContentRect.location();
396 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
397 int angle = ecore_evas_rotation_get(ee);
398 bool isRotated = (angle != m_viewportAngle);
400 // if it's rotated, we need to fit content to viewport by minimize the scale
402 m_viewportAngle = angle;
403 newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
404 newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
407 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
408 if (m_waitFrameOfNewViewortSize)
409 ewk_view_resume(m_viewImpl->view());
412 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
413 setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
415 m_viewImpl->page()->scalePage(newScale, newScrollPosition);
418 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
419 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
420 if (smartData->api->formdata_candidate_is_showing(smartData))
421 smartData->api->formdata_candidate_hide(smartData);
424 #if ENABLE(TIZEN_FULLSCREEN_API)
425 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
426 m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle();
431 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
433 if (undoOrRedo == WebPageProxy::Undo) {
434 m_undoCommands.append(command);
436 int undoSize = m_undoCommands.size();
437 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
440 m_redoCommands.append(command);
442 int redoSize = m_redoCommands.size();
443 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
447 void PageClientImpl::clearAllEditCommands()
449 m_undoCommands.clear();
450 m_redoCommands.clear();
452 int undoSize = m_undoCommands.size();
453 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
455 int redoSize = m_redoCommands.size();
456 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
459 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
461 if (undoOrRedo == WebPageProxy::Undo)
462 return !m_undoCommands.isEmpty();
464 return !m_redoCommands.isEmpty();
467 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
469 if (undoOrRedo == WebPageProxy::Undo) {
470 m_undoCommands.last()->unapply();
471 m_undoCommands.removeLast();
473 int undoSize = m_undoCommands.size();
474 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
476 m_redoCommands.last()->reapply();
477 m_redoCommands.removeLast();
479 int redoSize = m_redoCommands.size();
480 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
484 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
489 void PageClientImpl::clearAllEditCommands()
494 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
500 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
506 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
512 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
518 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
524 IntRect PageClientImpl::windowToScreen(const IntRect&)
530 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
535 #if ENABLE(GESTURE_EVENTS)
536 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
542 #if ENABLE(TOUCH_EVENTS)
543 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
546 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
549 #endif // #if OS(TIZEN)
553 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
555 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
558 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
560 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
561 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
568 #if ENABLE(INPUT_TYPE_COLOR)
569 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
576 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
582 #if USE(ACCELERATED_COMPOSITING)
583 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
585 m_viewImpl->enterAcceleratedCompositingMode();
588 void PageClientImpl::exitAcceleratedCompositingMode()
590 m_viewImpl->exitAcceleratedCompositingMode();
593 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
597 #endif // USE(ACCELERATED_COMPOSITING)
600 void PageClientImpl::initializeAcceleratedCompositingMode()
604 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
605 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
609 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
611 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
613 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
614 m_bgColor.setRGB(rgba);
617 void PageClientImpl::didChangeScrollbarsForMainFrame() const
623 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
625 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
626 m_initialViewRect.setSize(viewSize());
630 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
632 #if USE(TILED_BACKING_STORE)
636 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
637 if (drawingArea()->layerTreeCoordinatorProxy())
638 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
641 // if minimum scale factor is changed, update minimumScale.
642 if (m_viewportConstraints.userScalable) {
643 double minimumScale = availableMinimumScale();
645 // Sometimes initializeVisibleContentRect can be called after content size change.
646 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
647 if (!m_viewportConstraints.contentsDefinedInitialScale
648 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
649 m_viewportConstraints.initialScale = minimumScale;
650 m_viewportConstraints.minimumScale = minimumScale;
653 m_viewImpl->informContentsSizeChange(size);
655 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
658 // FIXME: Do we really need to adjust visible content rect at here?
659 // if contents size is changed smaller and visible content rect is outside of content area,
660 // adjust visible content rect
661 bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect);
662 bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits<float>::epsilon());
663 if (needScrollAdjustment || needScaleAdjustment)
664 setVisibleContentRect(m_visibleContentRect, scaleFactor());
667 void PageClientImpl::pageScaleFactorDidChange()
669 ewk_view_focused_node_adjust(m_viewImpl->view());
671 #endif // #if OS(TIZEN)
673 void PageClientImpl::didCommitLoadForMainFrame(bool)
676 m_pageDidRendered = false;
677 m_viewportFitsToContent = false;
678 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
679 m_restoredScaleFactor = 0;
686 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
691 double PageClientImpl::customRepresentationZoomFactor()
697 void PageClientImpl::setCustomRepresentationZoomFactor(double)
702 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
707 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
712 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
717 void PageClientImpl::updateTextInputState()
719 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
720 m_textSelection->update();
721 if (isTextSelectionMode() && isTextSelectionHandleDowned())
725 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
726 if (inputMethodContext)
727 inputMethodContext->updateTextInputState();
730 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
732 Ewk_Context* context = m_viewImpl->ewkContext();
733 context->downloadManager()->registerDownload(download, m_viewImpl);
736 #if USE(TILED_BACKING_STORE)
737 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
739 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
740 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
741 if (smartData->api->formdata_candidate_is_showing(smartData))
744 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
745 IntPoint newPoint = point;
746 newPoint.scale(scaleFactor(), scaleFactor());
747 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
753 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
754 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
756 m_restoredScrollPosition = point;
757 m_restoredScrollPosition.scale(scale, scale);
758 m_restoredScaleFactor = scale;
760 // Before contents size is fixed, just update visible content rect's position
761 m_visibleContentRect.setLocation(m_restoredScrollPosition);
765 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
766 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
768 if (value == m_formDataCandidate->getCandidateValue()) {
769 m_formDataCandidate->updateCandidateValue(emptyString());
773 m_formDataCandidate->updateCandidateValue(value);
774 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
778 void PageClientImpl::updateFormNavigation(int length, int offset)
783 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
784 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
785 DrawingAreaProxy* PageClientImpl::drawingArea() const
787 return m_viewImpl->page()->drawingArea();
791 // Before rendering, scale factor and scroll position is different from m_viewImpl.
792 float PageClientImpl::scaleFactor()
794 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
797 const IntPoint PageClientImpl::scrollPosition()
799 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
802 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
804 IntSize contentsSize = m_viewImpl->page()->contentsSize();
805 contentsSize.scale(targetScale);
806 if (contentsSize.width() < visibleContentRect.width())
807 visibleContentRect.setX(0);
809 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
811 if (contentsSize.height() < visibleContentRect.height())
812 visibleContentRect.setY(0);
814 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
815 return visibleContentRect;
818 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
820 #if ENABLE(TIZEN_SCREEN_READER)
821 IntPoint previousScrollPosition(scrollPosition());
822 float previousScale = m_scaleFactor;
825 m_scaleFactor = adjustScaleWithViewport(newScale);
826 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
827 m_visibleContentRect.setLocation(newRect.location());
828 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
830 // update both drawing scale factor and scroll position after page is rendered
831 if (m_pageDidRendered) {
832 if (!m_hasSuspendedContent) {
833 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
834 // PageViewport's values are updated when resuming content in the webkit opensource,
835 // but we have to update viewImpl's values here to sync with PageClient's values.
836 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
837 // The values will be updated when resuming content.
838 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
839 m_viewImpl->setScaleFactor(m_scaleFactor);
840 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
844 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
845 // So we removed enclosingIntRect and replaced with floorf and ceilf.
846 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
847 floorf(m_visibleContentRect.y() / m_scaleFactor),
848 ceilf(m_visibleContentRect.width() / m_scaleFactor),
849 ceilf(m_visibleContentRect.height() / m_scaleFactor));
852 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
853 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
854 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
855 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
859 #if ENABLE(TIZEN_SCREEN_READER)
860 if (ScreenReaderProxy::screenReader().isEnabled()
861 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
862 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
865 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
866 if (!isClipboardWindowOpened())
867 updateTextSelectionHandlesAndContextMenu(true);
871 void PageClientImpl::displayViewport()
873 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
875 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
879 #if ENABLE(TIZEN_SCREEN_READER)
880 m_viewImpl->page()->recalcScreenReaderFocusRect();
884 void PageClientImpl::drawContents()
888 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
891 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
892 cairo_transform(context, &matrix);
895 if (drawingArea()->layerTreeCoordinatorProxy()) {
896 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
897 renderer->paintToGraphicsContext(context, m_bgColor);
901 cairo_restore(context);
904 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
906 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
907 // We don't want to process scaling in the FullScreen mode.
908 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
912 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
913 m_textSelection->hideHandlers();
916 // Adjust scaleFactor.
917 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
918 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
919 scaleFactor = adjustScaleWithViewport(scaleFactor);
921 scaleFactor = adjustScaleWithViewport(scaleFactor);
924 scaleContents(scaleFactor, scrollPosition);
927 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
929 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
930 // We don't want to process scaling in the FullScreen mode.
931 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
934 scaleFactor = adjustScaleWithViewport(scaleFactor);
936 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
939 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
940 // so below code should be replaced when PageViewportController codes are merged.
941 // Please do not use below codes. They are only for scaling contents.
942 void PageClientImpl::suspendContent()
944 if (m_hasSuspendedContent)
947 m_hasSuspendedContent = true;
950 void PageClientImpl::resumeContent()
952 if (!m_hasSuspendedContent)
955 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
956 // The concept is that the values of EwkViewImpl and PageClient can be different
957 // during suspending content and they become same when content is resumed.
958 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
959 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
960 m_hasSuspendedContent = false;
963 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
965 // We need to floor the viewport here as to allow aligning the content in device units. If not,
966 // it might not be possible to scroll the last pixel and that affects fixed position elements.
968 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
969 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
970 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
973 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
974 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
975 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
980 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
981 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
984 if (horizontalBar && !m_horizontalScrollbar) {
985 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
986 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
987 m_horizontalScrollbar->setFrameRect(hBarRect);
988 } else if (!horizontalBar && m_horizontalScrollbar)
989 m_horizontalScrollbar = 0;
991 if (verticalBar && !m_verticalScrollbar) {
992 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
993 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
994 m_verticalScrollbar->setFrameRect(vBarRect);
995 } else if (!verticalBar && m_verticalScrollbar)
996 m_verticalScrollbar = 0;
999 void PageClientImpl::updateScrollbar()
1001 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
1002 scaledContentsSize.scale(scaleFactor());
1004 bool newHasHorizontalScrollbar = false;
1005 bool newVerticalScrollbar = false;
1006 if (viewSize().width() < scaledContentsSize.width())
1007 newHasHorizontalScrollbar = true;
1008 if (viewSize().height() < scaledContentsSize.height())
1009 newVerticalScrollbar = true;
1010 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1012 if (m_horizontalScrollbar) {
1013 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1014 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
1016 if (m_verticalScrollbar) {
1017 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1018 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1022 void PageClientImpl::frameRectChanged()
1024 if (m_horizontalScrollbar) {
1025 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1026 m_horizontalScrollbar->setFrameRect(hBarRect);
1028 if (m_verticalScrollbar) {
1029 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1030 m_verticalScrollbar->setFrameRect(vBarRect);
1034 void PageClientImpl::updateVisibility()
1036 if (m_horizontalScrollbar)
1037 m_horizontalScrollbar->updateVisibility();
1038 if (m_verticalScrollbar)
1039 m_verticalScrollbar->updateVisibility();
1042 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1044 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1045 bool PageClientImpl::isTextSelectionDowned()
1047 return m_textSelection->isTextSelectionDowned();
1050 bool PageClientImpl::isTextSelectionMode()
1052 return m_textSelection->isTextSelectionMode();
1055 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1057 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1060 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1062 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1063 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1066 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1068 if (!evas_object_focus_get(m_viewImpl->view())) {
1069 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1070 if (inputMethodContext)
1071 inputMethodContext->hideIMFContext();
1073 evas_object_focus_set(m_viewImpl->view(), true);
1076 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1079 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1081 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1084 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1086 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1089 bool PageClientImpl::isTextSelectionHandleDowned()
1091 return m_textSelection->isTextSelectionHandleDowned();
1094 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1095 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1097 m_textSelection->textSelectionHandleDown(point);
1100 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1102 m_textSelection->textSelectionHandleMove(point);
1105 void PageClientImpl::textSelectonHandleUp()
1107 m_textSelection->textSelectionHandleUp();
1111 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1113 m_textSelection->requestToShow();
1116 void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
1118 m_textSelection->initHandlesMouseDownedStatus();
1122 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1123 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1125 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1128 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1130 m_offlinePageSave->saveSubresourcesData(subresourceData);
1133 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1135 m_offlinePageSave->startOfflinePageSave(path, url, title);
1139 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1140 void PageClientImpl::pasteContextMenuSelected()
1142 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1146 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1147 void PageClientImpl::setClipboardData(const String& data, const String& type)
1149 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1150 m_clipboardHelper->setData(data, type);
1154 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1155 void PageClientImpl::clipboardContextMenuSelected()
1157 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1160 bool PageClientImpl::isClipboardWindowOpened()
1162 return m_clipboardHelper->isClipboardWindowOpened();
1165 void PageClientImpl::closeClipboardWindow()
1167 m_clipboardHelper->closeClipboardWindow();
1171 void PageClientImpl::clearClipboardData()
1173 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1174 m_clipboardHelper->clear();
1179 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1180 void PageClientImpl::setIsVisible(bool isVisible)
1182 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1183 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1184 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1185 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1186 int angle = ecore_evas_rotation_get(ee);
1187 if (angle == 0 || angle == 180) {
1188 m_shouldMakeBackupTexture = true;
1189 m_shouldShowBackupTexture = true;
1196 m_isVisible = isVisible;
1198 WebPageProxy* pageProxy = m_viewImpl->page();
1200 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1202 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1204 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1209 #if ENABLE(TIZEN_DRAG_SUPPORT)
1210 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1212 m_drag->setDragPoint(point);
1214 bool PageClientImpl::isDragMode()
1216 return m_drag->isDragMode();
1218 void PageClientImpl::setDragMode(bool isDragMode)
1220 m_drag->setDragMode(isDragMode);
1222 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1224 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1225 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1227 String dragStorageName("Drag");
1228 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1230 m_drag->setDragData(dragInfo);
1235 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1236 bool PageClientImpl::isShowingFormDataCandidate()
1238 return m_formDataCandidate->isShowing();
1241 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1243 m_formDataCandidate->updateFormData(data);
1246 void PageClientImpl::hideFormDataCandidate()
1248 m_formDataCandidate->hide();
1251 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1253 m_formDataCandidate->show(rect);
1257 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1258 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1260 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1264 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1265 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1267 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1270 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1272 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1276 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1277 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1279 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1282 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1284 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1287 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1289 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1293 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1294 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1296 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1299 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1301 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1305 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1306 bool PageClientImpl::getStandaloneStatus()
1308 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1312 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1313 bool PageClientImpl::lockOrientation(int willLockOrientation)
1315 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1318 void PageClientImpl::unlockOrientation()
1320 ewk_view_orientation_unlock(m_viewImpl->view());
1324 void PageClientImpl::didRenderFrame()
1326 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1327 if (m_shouldShowBackupTexture && m_isVisible)
1328 m_shouldShowBackupTexture = false;
1330 if (!m_pageDidRendered) {
1331 m_pageDidRendered = true;
1332 initializeVisibleContentRect();
1335 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
1336 if (m_waitFrameOfNewViewortSize) {
1337 m_waitFrameOfNewViewortSize = false;
1338 ewkViewRotatePrepared(m_viewImpl->view());
1343 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1344 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1346 setIsScrollableLayerFocused(false);
1347 setIsScrollableNodeFocused(false);
1351 setIsScrollableLayerFocused(true);
1352 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1354 setIsScrollableNodeFocused(true);
1359 void PageClientImpl::findScrollableNode(const IntPoint& point)
1361 WebPageProxy* pageProxy = m_viewImpl->page();
1362 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1363 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1364 WebLayerID webLayerID = 0;
1365 bool checkOverflowLayer = false;
1366 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1367 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1368 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1370 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1375 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1376 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1378 WebCore::IntPoint startPoint, endPoint;
1379 WebCore::IntRect leftRect, rightRect;
1381 WebCore::IntRect caretRect;
1382 m_viewImpl->page()->getCaretPosition(caretRect);
1383 if (!caretRect.isEmpty()) {
1384 startPoint.setX(caretRect.x());
1385 startPoint.setY(caretRect.y() + caretRect.height());
1387 endPoint.setX(caretRect.x() + caretRect.width());
1388 endPoint.setY(caretRect.y() + caretRect.height());
1390 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1391 else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
1392 startPoint.setX(leftRect.x());
1393 startPoint.setY(leftRect.y() + leftRect.height());
1395 endPoint.setX(rightRect.x() + rightRect.width());
1396 endPoint.setY(rightRect.y() + rightRect.height());
1400 startPoint.scale(scaleFactor(), scaleFactor());
1401 endPoint.scale(scaleFactor(), scaleFactor());
1403 int viewPositionX, viewPositionY;
1404 evas_object_geometry_get(m_viewImpl->view(), &viewPositionX, &viewPositionY, NULL, NULL);
1406 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1407 startPoint.move(viewPositionX, viewPositionY);
1409 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1410 endPoint.move(viewPositionX, viewPositionY);
1412 ewkViewDidGetTextStyleStateForSelection(m_viewImpl->view(), underlineState, italicState, boldState, startPoint, endPoint);
1416 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1418 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1421 #if ENABLE(TIZEN_ICON_DATABASE)
1422 void PageClientImpl::didReceiveIcon()
1424 ewkViewIconReceived(m_viewImpl->view());
1428 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1429 void PageClientImpl::hideFocusRing()
1431 ewkViewFocusRingHide(m_viewImpl->view());
1434 #endif // #if OS(TIZEN)
1437 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1438 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1439 : PageClientImpl(viewImpl)
1445 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1448 , m_isAcceleratedCompositingModeInitialized(false)
1450 initializeAcceleratedCompositingMode();
1453 PageClientEvasGL::~PageClientEvasGL()
1455 if (m_viewImpl && m_viewImpl->page())
1456 m_viewImpl->page()->close();
1459 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
1462 evas_gl_surface_destroy(m_evasGL, m_surface);
1467 PageClientImpl::updateViewportSize(viewportSize, angle);
1470 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1472 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1473 if (!isDirectRendering())
1476 m_viewImpl->redrawRegion(rect);
1478 #if ENABLE(TIZEN_SCREEN_READER)
1479 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1480 m_viewImpl->page()->recalcScreenReaderFocusRect();
1484 void PageClientEvasGL::displayViewport()
1486 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1487 // We should not draw here when Direct Rendering is enabled.
1488 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1489 if (isDirectRendering())
1490 ewk_view_mark_for_sync(m_viewImpl->view());
1493 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1495 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1499 #if ENABLE(TIZEN_SCREEN_READER)
1500 m_viewImpl->page()->recalcScreenReaderFocusRect();
1504 void PageClientEvasGL::drawContents()
1506 if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()))
1509 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1513 if (!makeContextCurrent())
1516 WebCore::TransformationMatrix matrix;
1518 IntSize ewkViewSize = viewSize();
1520 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1521 if (isDirectRendering()) {
1522 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1523 m_angle = ecore_evas_rotation_get(ee);
1524 renderer->setAngle(m_angle);
1525 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1527 if (m_angle == 90 || m_angle == 270) {
1528 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1530 matrix.translate(-ewkViewSize.width(), 0);
1531 else if (m_angle == 270)
1532 matrix.translate(0, -ewkViewSize.height());
1533 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1535 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1537 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1538 clipRect = IntRect(IntPoint(), ewkViewSize);
1543 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1544 clipRect = IntRect(IntPoint(), ewkViewSize);
1547 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1549 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1550 if (m_shouldMakeBackupTexture) {
1551 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1552 glClearColor(1, 1, 1, 1);
1553 glClear(GL_COLOR_BUFFER_BIT);
1554 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1555 m_shouldMakeBackupTexture = false;
1556 } else if (m_shouldShowBackupTexture) {
1557 matrix.makeIdentity();
1558 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1559 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1562 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1565 void PageClientEvasGL::didRenderFrame()
1567 ewkViewFrameRendered(m_viewImpl->view());
1568 PageClientImpl::didRenderFrame();
1571 bool PageClientEvasGL::makeContextCurrent()
1573 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1576 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1578 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1580 m_config = evas_gl_config_new();
1581 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1582 char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
1583 if (!directRenderingEnv || atoi(directRenderingEnv)) {
1584 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1585 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1588 m_config->color_format = EVAS_GL_RGBA_8888;
1589 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1590 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1592 m_evasGL = evas_gl_new(evas);
1594 evas_gl_config_free(m_config);
1596 TIZEN_LOGE("failed to create evas_gl");
1600 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1602 evas_gl_free(m_evasGL);
1604 evas_gl_config_free(m_config);
1606 TIZEN_LOGE("failed to get evas_gl_api");
1609 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1611 m_context = evas_gl_context_create(m_evasGL, 0);
1613 evas_gl_free(m_evasGL);
1615 evas_gl_config_free(m_config);
1617 TIZEN_LOGE("failed to create evas_gl_context");
1622 m_isAcceleratedCompositingModeInitialized = true;
1625 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1629 evas_gl_surface_destroy(m_evasGL, m_surface);
1633 evas_gl_context_destroy(m_evasGL, m_context);
1637 evas_gl_config_free(m_config);
1640 evas_gl_free(m_evasGL);
1644 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1645 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1647 m_isAcceleratedCompositingModeInitialized = false;
1650 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1652 if (!m_isAcceleratedCompositingModeInitialized)
1653 initializeAcceleratedCompositingMode();
1656 void PageClientEvasGL::exitAcceleratedCompositingMode()
1658 if (m_isAcceleratedCompositingModeInitialized)
1659 finalizeAcceleratedCompositingMode();
1662 void PageClientEvasGL::setTargetSurface()
1668 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1669 if (width == 0 || height == 0)
1672 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1674 TIZEN_LOGE("failed to create Evas_GL_Surface");
1678 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1679 if (isDirectRendering())
1680 makeContextCurrent();
1684 if (makeContextCurrent()) {
1685 glViewport(0, 0, width, height);
1686 glClearColor(1.0, 1.0, 1.0, 1.0);
1687 glClear(GL_COLOR_BUFFER_BIT);
1692 Evas_Native_Surface nativeSurface;
1693 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1694 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1698 } // namespace WebKit