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(false)
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 #endif // #if OS(TIZEN)
115 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
116 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
117 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
121 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
122 m_textSelection = TextSelection::create(m_viewImpl);
124 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
125 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
127 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
128 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
130 #if ENABLE(TIZEN_DRAG_SUPPORT)
131 m_drag = Drag::create(m_viewImpl);
133 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
134 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
138 setBackgroundColor(1, 1, 1, 1);
141 PageClientImpl::~PageClientImpl()
143 m_viewImpl->page()->close();
147 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
149 PageClientImpl::ViewportConstraints constraints;
150 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
151 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
152 constraints.userScalable = attributes.userScalable;
153 constraints.layoutSize = attributes.layoutSize;
154 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
156 double defaultViewLevel = m_viewImpl->page()->pageGroup()->preferences()->defaultViewLevel();
157 // If defaultViewLevel is 1, "Default View" is set as "Readable"
158 // if not, "Default View" is set as "Fit to width"
159 if (defaultViewLevel) {
160 // if content doesn't set initial scale value, set readable scale factor
161 // if not, set initial scale factor of viewport attribute
162 if (attributes.initialScale == ViewportArguments::ValueAuto)
163 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
165 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
167 // Minimize initial scale factor
168 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
171 // adjust scale with both minimum and maximum scale factor
172 constraints.initialScale = clampTo(constraints.initialScale, constraints.minimumScale, constraints.maximumScale);
177 double PageClientImpl::adjustScaleWithViewport(double scale)
179 double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
180 return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale);
183 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
184 void PageClientImpl::updateViewportSize(const IntSize& viewportSize)
186 // update device width & height
187 int deviceWidth = WebCore::getDefaultScreenResolution().width();
188 int deviceHeight = WebCore::getDefaultScreenResolution().height();
189 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
190 int angle = ecore_evas_rotation_get(ee);
191 if (angle == 90 || angle == 270) {
192 int tempWidth = deviceWidth;
193 deviceWidth = deviceHeight;
194 deviceHeight = tempWidth;
196 m_viewImpl->page()->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
197 m_viewImpl->page()->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
199 // update viewport size of webkit
200 m_visibleContentRect.setSize(viewportSize);
201 m_viewImpl->page()->setViewportSize(viewportSize);
205 void PageClientImpl::initializeVisibleContentRect()
207 _ewk_view_resume_painting(m_viewImpl->view());
209 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
210 IntPoint initialScrollPosition;
211 float initialScaleFactor = m_viewportConstraints.initialScale;
212 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
213 // if scroll position and scale factor are restored by history controller,
214 // move scroll position and scale factor with them
215 if (m_restoredScaleFactor) {
216 initialScrollPosition = m_restoredScrollPosition;
217 initialScaleFactor = m_restoredScaleFactor;
220 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
222 // Set initial scale.
223 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
227 double PageClientImpl::availableMinimumScale()
229 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
230 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
231 IntSize contentsSize = m_viewImpl->page()->contentsSize();
232 #if ENABLE(TIZEN_FULLSCREEN_API)
233 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
234 contentsSize = viewSize();
237 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
238 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
239 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
242 void PageClientImpl::fitViewportToContent()
244 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
247 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
249 m_focusedNodeRect = focusedNodeRect;
252 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
253 bool PageClientImpl::scrollBy(IntSize scrollOffset)
255 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
256 // scrollOffset means device screen coordiate, not an actual offset of contents.
257 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
258 // in the actual scale.
259 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
260 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
261 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
267 IntPoint oldScrollPosition = scrollPosition();
268 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
273 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
275 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
277 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
279 #endif // #if OS(TIZEN)
281 EwkViewImpl* PageClientImpl::viewImpl() const
287 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
289 return DrawingAreaProxyImpl::create(m_viewImpl->page());
292 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
295 ewk_view_mark_for_sync(m_viewImpl->view());
297 m_viewImpl->redrawRegion(rect);
300 #if ENABLE(TIZEN_SCREEN_READER)
301 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
302 m_viewImpl->page()->recalcScreenReaderFocusRect();
306 void PageClientImpl::displayView()
311 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
313 setViewNeedsDisplay(scrollRect);
316 WebCore::IntSize PageClientImpl::viewSize()
318 return m_viewImpl->size();
321 bool PageClientImpl::isViewVisible()
326 return m_viewImpl->isVisible();
330 bool PageClientImpl::isViewInWindow()
336 void PageClientImpl::processDidCrash()
338 // Check if loading was ongoing, when web process crashed.
339 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
340 if (loadProgress >= 0 && loadProgress < 1)
341 m_viewImpl->informLoadProgress(1);
343 m_viewImpl->informWebProcessCrashed();
346 void PageClientImpl::didRelaunchProcess()
348 const char* themePath = m_viewImpl->themePath();
350 m_viewImpl->page()->setThemePath(themePath);
353 void PageClientImpl::pageClosed()
358 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
360 m_viewImpl->informTooltipTextChange(newToolTip);
363 void PageClientImpl::setCursor(const Cursor& cursor)
365 m_viewImpl->setCursor(cursor);
368 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
373 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
375 m_viewportConstraints = computeViewportConstraints(attributes);
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 m_viewportConstraints.minimumScale = availableMinimumScale();
383 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
384 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
387 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
388 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
391 float newScale = scaleFactor();
392 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
393 int angle = ecore_evas_rotation_get(ee);
394 bool isRotated = (angle != m_viewportAngle);
396 // if it's rotated, we need to fit content to viewport by minimize the scale
398 m_viewportAngle = angle;
399 if (m_viewportFitsToContent)
400 newScale = m_viewportConstraints.minimumScale;
402 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
403 setVisibleContentRect(m_visibleContentRect, newScale);
405 m_viewImpl->page()->scalePage(newScale, m_visibleContentRect.location());
408 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
409 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
410 if (smartData->api->formdata_candidate_is_showing(smartData))
411 smartData->api->formdata_candidate_hide(smartData);
416 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
418 if (undoOrRedo == WebPageProxy::Undo) {
419 m_undoCommands.append(command);
421 int undoSize = m_undoCommands.size();
422 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
425 m_redoCommands.append(command);
427 int redoSize = m_redoCommands.size();
428 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
432 void PageClientImpl::clearAllEditCommands()
434 m_undoCommands.clear();
435 m_redoCommands.clear();
437 int undoSize = m_undoCommands.size();
438 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
440 int redoSize = m_redoCommands.size();
441 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
444 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
446 if (undoOrRedo == WebPageProxy::Undo)
447 return !m_undoCommands.isEmpty();
449 return !m_redoCommands.isEmpty();
452 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
454 if (undoOrRedo == WebPageProxy::Undo) {
455 m_undoCommands.last()->unapply();
456 m_undoCommands.removeLast();
458 int undoSize = m_undoCommands.size();
459 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
461 m_redoCommands.last()->reapply();
462 m_redoCommands.removeLast();
464 int redoSize = m_redoCommands.size();
465 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
469 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
474 void PageClientImpl::clearAllEditCommands()
479 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
485 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
491 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
497 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
503 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
509 IntRect PageClientImpl::windowToScreen(const IntRect&)
515 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
520 #if ENABLE(GESTURE_EVENTS)
521 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
527 #if ENABLE(TOUCH_EVENTS)
528 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
531 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
534 #endif // #if OS(TIZEN)
538 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
540 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
543 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
545 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
546 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
553 #if ENABLE(INPUT_TYPE_COLOR)
554 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
561 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
567 #if USE(ACCELERATED_COMPOSITING)
568 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
570 m_viewImpl->enterAcceleratedCompositingMode();
573 void PageClientImpl::exitAcceleratedCompositingMode()
575 m_viewImpl->exitAcceleratedCompositingMode();
578 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
582 #endif // USE(ACCELERATED_COMPOSITING)
585 void PageClientImpl::initializeAcceleratedCompositingMode()
589 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
590 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
594 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
596 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
598 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
599 m_bgColor.setRGB(rgba);
602 void PageClientImpl::didChangeScrollbarsForMainFrame() const
608 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
610 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
611 m_initialViewRect.setSize(viewSize());
615 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
617 #if USE(TILED_BACKING_STORE)
621 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
622 if (drawingArea()->layerTreeCoordinatorProxy())
623 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
626 // if minimum scale factor is changed, update minimumScale.
627 if (m_viewportConstraints.userScalable) {
628 double minimumScale = availableMinimumScale();
630 // Sometimes initializeVisibleContentRect can be called after content size change.
631 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
632 if (!m_viewportConstraints.contentsDefinedInitialScale
633 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
634 m_viewportConstraints.initialScale = minimumScale;
635 m_viewportConstraints.minimumScale = minimumScale;
638 m_viewImpl->informContentsSizeChange(size);
640 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
643 // FIXME: Do we really need to adjust visible content rect at here?
644 // if contents size is changed smaller and visible content rect is outside of content area,
645 // adjust visible content rect
646 IntRect adjustedVisibleContentRect = adjustVisibleContentRect(m_visibleContentRect, scaleFactor());
647 if (adjustedVisibleContentRect != m_visibleContentRect)
648 setVisibleContentRect(m_visibleContentRect, scaleFactor());
651 void PageClientImpl::pageScaleFactorDidChange()
653 ewk_view_focused_node_adjust(m_viewImpl->view());
655 #endif // #if OS(TIZEN)
657 void PageClientImpl::didCommitLoadForMainFrame(bool)
660 m_pageDidRendered = false;
661 m_viewportFitsToContent = false;
662 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
663 m_restoredScaleFactor = 0;
670 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
675 double PageClientImpl::customRepresentationZoomFactor()
681 void PageClientImpl::setCustomRepresentationZoomFactor(double)
686 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
691 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
696 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
701 void PageClientImpl::updateTextInputState()
703 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
704 if (inputMethodContext)
705 inputMethodContext->updateTextInputState();
707 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
708 m_textSelection->update();
712 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
714 Ewk_Context* context = m_viewImpl->ewkContext();
715 context->downloadManager()->registerDownload(download, m_viewImpl);
718 #if USE(TILED_BACKING_STORE)
719 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
721 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
722 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
723 if (smartData->api->formdata_candidate_is_showing(smartData))
726 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
727 IntPoint newPoint = point;
728 newPoint.scale(scaleFactor(), scaleFactor());
729 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
735 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
736 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
738 m_restoredScrollPosition = point;
739 m_restoredScrollPosition.scale(scale, scale);
740 m_restoredScaleFactor = scale;
742 // Before contents size is fixed, just update visible content rect's position
743 m_visibleContentRect.setLocation(m_restoredScrollPosition);
747 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
748 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
750 if (value == m_formDataCandidate->getCandidateValue()) {
751 m_formDataCandidate->updateCandidateValue(emptyString());
755 m_formDataCandidate->updateCandidateValue(value);
756 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
760 void PageClientImpl::updateFormNavigation(int length, int offset)
765 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
766 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
767 DrawingAreaProxy* PageClientImpl::drawingArea() const
769 return m_viewImpl->page()->drawingArea();
773 // Before rendering, scale factor and scroll position is different from m_viewImpl.
774 float PageClientImpl::scaleFactor()
776 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
779 const IntPoint PageClientImpl::scrollPosition()
781 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
784 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
786 IntSize contentsSize = m_viewImpl->page()->contentsSize();
787 contentsSize.scale(targetScale);
788 if (contentsSize.width() < visibleContentRect.width())
789 visibleContentRect.setX(0);
791 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
793 if (contentsSize.height() < visibleContentRect.height())
794 visibleContentRect.setY(0);
796 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
797 return visibleContentRect;
800 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
802 #if ENABLE(TIZEN_SCREEN_READER)
803 IntPoint previousScrollPosition(scrollPosition());
804 float previousScale = m_scaleFactor;
807 m_scaleFactor = adjustScaleWithViewport(newScale);
808 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
809 m_visibleContentRect.setLocation(newRect.location());
810 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
812 // update both drawing scale factor and scroll position after page is rendered
813 if (m_pageDidRendered) {
814 if (!m_hasSuspendedContent) {
815 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
816 // PageViewport's values are updated when resuming content in the webkit opensource,
817 // but we have to update viewImpl's values here to sync with PageClient's values.
818 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
819 // The values will be updated when resuming content.
820 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
821 m_viewImpl->setScaleFactor(m_scaleFactor);
822 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
826 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
827 // So we removed enclosingIntRect and replaced with floorf and ceilf.
828 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
829 floorf(m_visibleContentRect.y() / m_scaleFactor),
830 ceilf(m_visibleContentRect.width() / m_scaleFactor),
831 ceilf(m_visibleContentRect.height() / m_scaleFactor));
834 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
835 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
836 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
837 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
841 #if ENABLE(TIZEN_SCREEN_READER)
842 if (ScreenReaderProxy::screenReader().isEnabled()
843 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
844 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
847 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
848 if (!isClipboardWindowOpened())
849 updateTextSelectionHandlesAndContextMenu(true);
853 void PageClientImpl::displayViewport()
855 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
857 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
861 #if ENABLE(TIZEN_SCREEN_READER)
862 m_viewImpl->page()->recalcScreenReaderFocusRect();
866 void PageClientImpl::drawContents()
870 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
873 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
874 cairo_transform(context, &matrix);
877 if (drawingArea()->layerTreeCoordinatorProxy()) {
878 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
879 renderer->paintToGraphicsContext(context, m_bgColor);
883 cairo_restore(context);
886 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
888 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
889 // We don't want to process scaling in the FullScreen mode.
890 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
894 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
895 m_textSelection->hideHandlers();
898 // Adjust scaleFactor.
899 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
900 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
901 scaleFactor = adjustScaleWithViewport(scaleFactor);
903 scaleFactor = adjustScaleWithViewport(scaleFactor);
906 scaleContents(scaleFactor, scrollPosition);
909 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
911 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
912 // We don't want to process scaling in the FullScreen mode.
913 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
916 scaleFactor = adjustScaleWithViewport(scaleFactor);
918 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
921 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
922 // so below code should be replaced when PageViewportController codes are merged.
923 // Please do not use below codes. They are only for scaling contents.
924 void PageClientImpl::suspendContent()
926 if (m_hasSuspendedContent)
929 m_hasSuspendedContent = true;
932 void PageClientImpl::resumeContent()
934 if (!m_hasSuspendedContent)
937 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
938 // The concept is that the values of EwkViewImpl and PageClient can be different
939 // during suspending content and they become same when content is resumed.
940 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
941 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
942 m_hasSuspendedContent = false;
945 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
947 // We need to floor the viewport here as to allow aligning the content in device units. If not,
948 // it might not be possible to scroll the last pixel and that affects fixed position elements.
950 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
951 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
952 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
955 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
956 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
957 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
962 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
963 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
966 if (horizontalBar && !m_horizontalScrollbar) {
967 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
968 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
969 m_horizontalScrollbar->setFrameRect(hBarRect);
970 } else if (!horizontalBar && m_horizontalScrollbar)
971 m_horizontalScrollbar = 0;
973 if (verticalBar && !m_verticalScrollbar) {
974 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
975 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
976 m_verticalScrollbar->setFrameRect(vBarRect);
977 } else if (!verticalBar && m_verticalScrollbar)
978 m_verticalScrollbar = 0;
981 void PageClientImpl::updateScrollbar()
983 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
984 scaledContentsSize.scale(scaleFactor());
986 bool newHasHorizontalScrollbar = false;
987 bool newVerticalScrollbar = false;
988 if (viewSize().width() < scaledContentsSize.width())
989 newHasHorizontalScrollbar = true;
990 if (viewSize().height() < scaledContentsSize.height())
991 newVerticalScrollbar = true;
992 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
994 if (m_horizontalScrollbar) {
995 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
996 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
998 if (m_verticalScrollbar) {
999 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1000 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1004 void PageClientImpl::frameRectChanged()
1006 if (m_horizontalScrollbar) {
1007 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1008 m_horizontalScrollbar->setFrameRect(hBarRect);
1010 if (m_verticalScrollbar) {
1011 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1012 m_verticalScrollbar->setFrameRect(vBarRect);
1016 void PageClientImpl::updateVisibility()
1018 if (m_horizontalScrollbar)
1019 m_horizontalScrollbar->updateVisibility();
1020 if (m_verticalScrollbar)
1021 m_verticalScrollbar->updateVisibility();
1024 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1026 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1027 bool PageClientImpl::isTextSelectionDowned()
1029 return m_textSelection->isTextSelectionDowned();
1032 bool PageClientImpl::isTextSelectionMode()
1034 return m_textSelection->isTextSelectionMode();
1037 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1039 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1042 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1044 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1045 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1048 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1050 if (!evas_object_focus_get(m_viewImpl->view())) {
1051 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1052 if (inputMethodContext)
1053 inputMethodContext->hideIMFContext();
1055 evas_object_focus_set(m_viewImpl->view(), true);
1058 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1061 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1063 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1066 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1068 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1071 bool PageClientImpl::isTextSelectionHandleDowned()
1073 return m_textSelection->isTextSelectionHandleDowned();
1076 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1077 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1079 m_textSelection->textSelectionHandleDown(point);
1082 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1084 m_textSelection->textSelectionHandleMove(point);
1087 void PageClientImpl::textSelectonHandleUp()
1089 m_textSelection->textSelectionHandleUp();
1093 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1094 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1096 m_textSelection->requestToShow();
1101 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1102 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1104 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1107 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1109 m_offlinePageSave->saveSubresourcesData(subresourceData);
1112 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1114 m_offlinePageSave->startOfflinePageSave(path, url, title);
1118 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1119 void PageClientImpl::pasteContextMenuSelected()
1121 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1125 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1126 void PageClientImpl::setClipboardData(const String& data, const String& type)
1128 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1129 m_clipboardHelper->setData(data, type);
1133 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1134 void PageClientImpl::clipboardContextMenuSelected()
1136 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1139 bool PageClientImpl::isClipboardWindowOpened()
1141 return m_clipboardHelper->isClipboardWindowOpened();
1144 void PageClientImpl::closeClipboardWindow()
1146 m_clipboardHelper->closeClipboardWindow();
1150 void PageClientImpl::clearClipboardData()
1152 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1153 m_clipboardHelper->clear();
1158 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1159 void PageClientImpl::setIsVisible(bool isVisible)
1161 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1162 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1163 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1164 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1165 int angle = ecore_evas_rotation_get(ee);
1166 if (angle == 0 || angle == 180) {
1167 m_shouldMakeBackupTexture = true;
1168 m_shouldShowBackupTexture = true;
1175 m_isVisible = isVisible;
1177 WebPageProxy* pageProxy = m_viewImpl->page();
1179 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1181 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1183 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1188 #if ENABLE(TIZEN_DRAG_SUPPORT)
1189 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1191 m_drag->setDragPoint(point);
1193 bool PageClientImpl::isDragMode()
1195 return m_drag->isDragMode();
1197 void PageClientImpl::setDragMode(bool isDragMode)
1199 m_drag->setDragMode(isDragMode);
1201 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1203 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1204 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1206 String dragStorageName("Drag");
1207 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1209 m_drag->setDragData(dragInfo);
1214 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1215 bool PageClientImpl::isShowingFormDataCandidate()
1217 return m_formDataCandidate->isShowing();
1220 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1222 m_formDataCandidate->updateFormData(data);
1225 void PageClientImpl::hideFormDataCandidate()
1227 m_formDataCandidate->hide();
1230 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1232 m_formDataCandidate->show(rect);
1236 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1237 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1239 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1243 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1244 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1246 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1249 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1251 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1255 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1256 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1258 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1261 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1263 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1266 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1268 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1272 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1273 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1275 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1278 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1280 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1284 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1285 bool PageClientImpl::getStandaloneStatus()
1287 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1291 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1292 bool PageClientImpl::lockOrientation(int willLockOrientation)
1294 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1297 void PageClientImpl::unlockOrientation()
1299 ewk_view_orientation_unlock(m_viewImpl->view());
1303 void PageClientImpl::didRenderFrame()
1305 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1306 if (m_shouldShowBackupTexture && m_isVisible)
1307 m_shouldShowBackupTexture = false;
1309 if (!m_pageDidRendered) {
1310 m_pageDidRendered = true;
1311 initializeVisibleContentRect();
1315 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1316 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1318 setIsScrollableLayerFocused(false);
1319 setIsScrollableNodeFocused(false);
1323 setIsScrollableLayerFocused(true);
1324 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1326 setIsScrollableNodeFocused(true);
1331 void PageClientImpl::findScrollableNode(const IntPoint& point)
1333 WebPageProxy* pageProxy = m_viewImpl->page();
1334 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1335 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1336 WebLayerID webLayerID = 0;
1337 bool checkOverflowLayer = false;
1338 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1339 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1340 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1342 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1347 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1348 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1350 WebCore::IntPoint startPoint, endPoint;
1351 WebCore::IntRect leftRect, rightRect;
1353 WebCore::IntRect caretRect;
1354 m_viewImpl->page()->getCaretPosition(caretRect);
1355 if (!caretRect.isEmpty()) {
1356 startPoint.setX(caretRect.x());
1357 startPoint.setY(caretRect.y() + caretRect.height());
1359 endPoint.setX(caretRect.x() + caretRect.width());
1360 endPoint.setY(caretRect.y() + caretRect.height());
1362 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1363 else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
1364 startPoint.setX(leftRect.x());
1365 startPoint.setY(leftRect.y() + leftRect.height());
1367 endPoint.setX(rightRect.x() + rightRect.width());
1368 endPoint.setY(rightRect.y() + rightRect.height());
1372 startPoint.scale(scaleFactor(), scaleFactor());
1373 endPoint.scale(scaleFactor(), scaleFactor());
1375 int viewPositionX, viewPositionY;
1376 evas_object_geometry_get(m_viewImpl->view(), &viewPositionX, &viewPositionY, NULL, NULL);
1378 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1379 startPoint.move(viewPositionX, viewPositionY);
1381 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1382 endPoint.move(viewPositionX, viewPositionY);
1384 ewkViewDidGetTextStyleStateForSelection(m_viewImpl->view(), underlineState, italicState, boldState, startPoint, endPoint);
1388 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1390 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1393 #if ENABLE(TIZEN_ICON_DATABASE)
1394 void PageClientImpl::didReceiveIcon()
1396 ewkViewIconReceived(m_viewImpl->view());
1400 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1401 void PageClientImpl::hideFocusRing()
1403 ewkViewFocusRingHide(m_viewImpl->view());
1406 #endif // #if OS(TIZEN)
1409 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1410 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1411 : PageClientImpl(viewImpl)
1417 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1420 , m_isAcceleratedCompositingModeInitialized(false)
1422 initializeAcceleratedCompositingMode();
1425 PageClientEvasGL::~PageClientEvasGL()
1427 m_viewImpl->page()->close();
1430 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1433 evas_gl_surface_destroy(m_evasGL, m_surface);
1438 PageClientImpl::updateViewportSize(viewportSize);
1441 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1443 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1446 m_viewImpl->redrawRegion(rect);
1448 #if ENABLE(TIZEN_SCREEN_READER)
1449 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1450 m_viewImpl->page()->recalcScreenReaderFocusRect();
1454 void PageClientEvasGL::displayViewport()
1456 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1457 // We should not draw here when Direct Rendering is enabled.
1458 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1459 ewk_view_mark_for_sync(m_viewImpl->view());
1461 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1464 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1468 #if ENABLE(TIZEN_SCREEN_READER)
1469 m_viewImpl->page()->recalcScreenReaderFocusRect();
1473 void PageClientEvasGL::drawContents()
1475 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1478 WebCore::TransformationMatrix matrix;
1480 IntSize ewkViewSize = viewSize();
1482 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1483 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1484 m_angle = ecore_evas_rotation_get(ee);
1486 drawingArea()->setAngle(m_angle);
1487 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1489 if (m_angle == 90 || m_angle == 270) {
1490 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1492 matrix.translate(-ewkViewSize.width(), 0);
1493 else if (m_angle == 270)
1494 matrix.translate(0, -ewkViewSize.height());
1495 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1497 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1499 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1500 clipRect = IntRect(IntPoint(), ewkViewSize);
1503 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1504 clipRect = IntRect(IntPoint(), ewkViewSize);
1506 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1508 if (drawingArea()) {
1509 if (drawingArea()->layerTreeCoordinatorProxy()) {
1510 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1511 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1512 if (m_shouldMakeBackupTexture) {
1513 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1514 glClearColor(1, 1, 1, 1);
1515 glClear(GL_COLOR_BUFFER_BIT);
1516 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1517 m_shouldMakeBackupTexture = false;
1518 } else if (m_shouldShowBackupTexture) {
1519 matrix.makeIdentity();
1520 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1521 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1524 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1529 void PageClientEvasGL::didRenderFrame()
1531 ewkViewFrameRendered(m_viewImpl->view());
1532 PageClientImpl::didRenderFrame();
1535 bool PageClientEvasGL::makeContextCurrent()
1537 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1540 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1542 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1544 m_config = evas_gl_config_new();
1545 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1546 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1547 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1549 m_config->color_format = EVAS_GL_RGBA_8888;
1550 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1551 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1553 m_evasGL = evas_gl_new(evas);
1555 evas_gl_config_free(m_config);
1557 TIZEN_LOGE("failed to create evas_gl");
1561 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1563 evas_gl_free(m_evasGL);
1565 evas_gl_config_free(m_config);
1567 TIZEN_LOGE("failed to get evas_gl_api");
1570 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1572 m_context = evas_gl_context_create(m_evasGL, 0);
1574 evas_gl_free(m_evasGL);
1576 evas_gl_config_free(m_config);
1578 TIZEN_LOGE("failed to create evas_gl_context");
1583 m_isAcceleratedCompositingModeInitialized = true;
1586 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1590 evas_gl_surface_destroy(m_evasGL, m_surface);
1594 evas_gl_context_destroy(m_evasGL, m_context);
1598 evas_gl_config_free(m_config);
1601 evas_gl_free(m_evasGL);
1605 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1606 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1608 m_isAcceleratedCompositingModeInitialized = false;
1611 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1613 if (!m_isAcceleratedCompositingModeInitialized)
1614 initializeAcceleratedCompositingMode();
1617 void PageClientEvasGL::exitAcceleratedCompositingMode()
1619 if (m_isAcceleratedCompositingModeInitialized)
1620 finalizeAcceleratedCompositingMode();
1623 void PageClientEvasGL::setTargetSurface()
1629 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1630 if (width == 0 || height == 0)
1633 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1635 TIZEN_LOGE("failed to create Evas_GL_Surface");
1639 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1640 makeContextCurrent();
1642 if (makeContextCurrent()) {
1643 glViewport(0, 0, width, height);
1644 glClearColor(1.0, 1.0, 1.0, 1.0);
1645 glClear(GL_COLOR_BUFFER_BIT);
1650 Evas_Native_Surface nativeSurface;
1651 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1652 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1656 } // namespace WebKit