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 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
233 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
234 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
237 void PageClientImpl::fitViewportToContent()
239 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
242 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
244 m_focusedNodeRect = focusedNodeRect;
247 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
248 bool PageClientImpl::scrollBy(IntSize scrollOffset)
250 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
251 // scrollOffset means device screen coordiate, not an actual offset of contents.
252 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
253 // in the actual scale.
254 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
255 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
256 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
262 IntPoint oldScrollPosition = scrollPosition();
263 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
268 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
270 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
272 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
274 #endif // #if OS(TIZEN)
276 EwkViewImpl* PageClientImpl::viewImpl() const
282 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
284 return DrawingAreaProxyImpl::create(m_viewImpl->page());
287 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
290 ewk_view_mark_for_sync(m_viewImpl->view());
292 m_viewImpl->redrawRegion(rect);
295 #if ENABLE(TIZEN_SCREEN_READER)
296 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
297 m_viewImpl->page()->recalcScreenReaderFocusRect();
301 void PageClientImpl::displayView()
306 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
308 setViewNeedsDisplay(scrollRect);
311 WebCore::IntSize PageClientImpl::viewSize()
313 return m_viewImpl->size();
316 bool PageClientImpl::isViewVisible()
321 return m_viewImpl->isVisible();
325 bool PageClientImpl::isViewInWindow()
331 void PageClientImpl::processDidCrash()
333 // Check if loading was ongoing, when web process crashed.
334 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
335 if (loadProgress >= 0 && loadProgress < 1)
336 m_viewImpl->informLoadProgress(1);
338 m_viewImpl->informWebProcessCrashed();
341 void PageClientImpl::didRelaunchProcess()
343 const char* themePath = m_viewImpl->themePath();
345 m_viewImpl->page()->setThemePath(themePath);
348 void PageClientImpl::pageClosed()
353 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
355 m_viewImpl->informTooltipTextChange(newToolTip);
358 void PageClientImpl::setCursor(const Cursor& cursor)
360 m_viewImpl->setCursor(cursor);
363 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
368 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
370 m_viewportConstraints = computeViewportConstraints(attributes);
372 // if content is reloaded, contents size will not be changed
373 // so, we need to calculate minimum scale here.
374 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
375 if (m_viewportConstraints.userScalable)
376 m_viewportConstraints.minimumScale = availableMinimumScale();
378 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
379 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
382 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
383 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
386 float newScale = scaleFactor();
387 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
388 int angle = ecore_evas_rotation_get(ee);
389 bool isRotated = (angle != m_viewportAngle);
391 // if it's rotated, we need to fit content to viewport by minimize the scale
393 m_viewportAngle = angle;
394 if (m_viewportFitsToContent)
395 newScale = m_viewportConstraints.minimumScale;
397 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
398 setVisibleContentRect(m_visibleContentRect, newScale);
400 m_viewImpl->page()->scalePage(newScale, m_visibleContentRect.location());
403 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
404 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
405 if (smartData->api->formdata_candidate_is_showing(smartData))
406 smartData->api->formdata_candidate_hide(smartData);
411 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
413 if (undoOrRedo == WebPageProxy::Undo) {
414 m_undoCommands.append(command);
416 int undoSize = m_undoCommands.size();
417 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
420 m_redoCommands.append(command);
422 int redoSize = m_redoCommands.size();
423 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
427 void PageClientImpl::clearAllEditCommands()
429 m_undoCommands.clear();
430 m_redoCommands.clear();
432 int undoSize = m_undoCommands.size();
433 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
435 int redoSize = m_redoCommands.size();
436 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
439 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
441 if (undoOrRedo == WebPageProxy::Undo)
442 return !m_undoCommands.isEmpty();
444 return !m_redoCommands.isEmpty();
447 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
449 if (undoOrRedo == WebPageProxy::Undo) {
450 m_undoCommands.last()->unapply();
451 m_undoCommands.removeLast();
453 int undoSize = m_undoCommands.size();
454 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
456 m_redoCommands.last()->reapply();
457 m_redoCommands.removeLast();
459 int redoSize = m_redoCommands.size();
460 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
464 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
469 void PageClientImpl::clearAllEditCommands()
474 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
480 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
486 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
492 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
498 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
504 IntRect PageClientImpl::windowToScreen(const IntRect&)
510 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
515 #if ENABLE(GESTURE_EVENTS)
516 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
522 #if ENABLE(TOUCH_EVENTS)
523 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
526 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
529 #endif // #if OS(TIZEN)
533 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
535 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
538 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
540 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
541 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
548 #if ENABLE(INPUT_TYPE_COLOR)
549 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
556 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
562 #if USE(ACCELERATED_COMPOSITING)
563 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
565 m_viewImpl->enterAcceleratedCompositingMode();
568 void PageClientImpl::exitAcceleratedCompositingMode()
570 m_viewImpl->exitAcceleratedCompositingMode();
573 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
577 #endif // USE(ACCELERATED_COMPOSITING)
580 void PageClientImpl::initializeAcceleratedCompositingMode()
584 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
585 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
589 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
591 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
593 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
594 m_bgColor.setRGB(rgba);
597 void PageClientImpl::didChangeScrollbarsForMainFrame() const
603 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
605 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
606 m_initialViewRect.setSize(viewSize());
610 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
612 #if USE(TILED_BACKING_STORE)
616 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
617 if (drawingArea()->layerTreeCoordinatorProxy())
618 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
621 // if minimum scale factor is changed, update minimumScale.
622 if (m_viewportConstraints.userScalable) {
623 double minimumScale = availableMinimumScale();
625 // Sometimes initializeVisibleContentRect can be called after content size change.
626 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
627 if (!m_viewportConstraints.contentsDefinedInitialScale
628 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
629 m_viewportConstraints.initialScale = minimumScale;
630 m_viewportConstraints.minimumScale = minimumScale;
633 m_viewImpl->informContentsSizeChange(size);
635 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
638 // FIXME: Do we really need to adjust visible content rect at here?
639 // if contents size is changed smaller and visible content rect is outside of content area,
640 // adjust visible content rect
641 IntRect adjustedVisibleContentRect = adjustVisibleContentRect(m_visibleContentRect, scaleFactor());
642 if (adjustedVisibleContentRect != m_visibleContentRect)
643 setVisibleContentRect(m_visibleContentRect, scaleFactor());
646 void PageClientImpl::pageScaleFactorDidChange()
648 ewk_view_focused_node_adjust(m_viewImpl->view());
650 #endif // #if OS(TIZEN)
652 void PageClientImpl::didCommitLoadForMainFrame(bool)
655 m_pageDidRendered = false;
656 m_viewportFitsToContent = false;
657 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
658 m_restoredScaleFactor = 0;
665 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
670 double PageClientImpl::customRepresentationZoomFactor()
676 void PageClientImpl::setCustomRepresentationZoomFactor(double)
681 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
686 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
691 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
696 void PageClientImpl::updateTextInputState()
698 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
699 if (inputMethodContext)
700 inputMethodContext->updateTextInputState();
702 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
703 m_textSelection->update();
707 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
709 Ewk_Context* context = m_viewImpl->ewkContext();
710 context->downloadManager()->registerDownload(download, m_viewImpl);
713 #if USE(TILED_BACKING_STORE)
714 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
716 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
717 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
718 if (smartData->api->formdata_candidate_is_showing(smartData))
721 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
722 IntPoint newPoint = point;
723 newPoint.scale(scaleFactor(), scaleFactor());
724 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
730 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
731 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
733 m_restoredScrollPosition = point;
734 m_restoredScrollPosition.scale(scale, scale);
735 m_restoredScaleFactor = scale;
737 // Before contents size is fixed, just update visible content rect's position
738 m_visibleContentRect.setLocation(m_restoredScrollPosition);
742 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
743 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
745 if (value == m_formDataCandidate->getCandidateValue()) {
746 m_formDataCandidate->updateCandidateValue(emptyString());
750 m_formDataCandidate->updateCandidateValue(value);
751 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
755 void PageClientImpl::updateFormNavigation(int length, int offset)
760 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
761 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
762 DrawingAreaProxy* PageClientImpl::drawingArea() const
764 return m_viewImpl->page()->drawingArea();
768 // Before rendering, scale factor and scroll position is different from m_viewImpl.
769 float PageClientImpl::scaleFactor()
771 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
774 const IntPoint PageClientImpl::scrollPosition()
776 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
779 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
781 IntSize contentsSize = m_viewImpl->page()->contentsSize();
782 contentsSize.scale(targetScale);
783 if (contentsSize.width() < visibleContentRect.width())
784 visibleContentRect.setX(0);
786 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
788 if (contentsSize.height() < visibleContentRect.height())
789 visibleContentRect.setY(0);
791 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
792 return visibleContentRect;
795 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
797 #if ENABLE(TIZEN_SCREEN_READER)
798 IntPoint previousScrollPosition(scrollPosition());
799 float previousScale = m_scaleFactor;
802 m_scaleFactor = adjustScaleWithViewport(newScale);
803 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
804 m_visibleContentRect.setLocation(newRect.location());
805 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
807 // update both drawing scale factor and scroll position after page is rendered
808 if (m_pageDidRendered) {
809 if (!m_hasSuspendedContent) {
810 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
811 // PageViewport's values are updated when resuming content in the webkit opensource,
812 // but we have to update viewImpl's values here to sync with PageClient's values.
813 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
814 // The values will be updated when resuming content.
815 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
816 m_viewImpl->setScaleFactor(m_scaleFactor);
817 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
821 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
822 // So we removed enclosingIntRect and replaced with floorf and ceilf.
823 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
824 floorf(m_visibleContentRect.y() / m_scaleFactor),
825 ceilf(m_visibleContentRect.width() / m_scaleFactor),
826 ceilf(m_visibleContentRect.height() / m_scaleFactor));
829 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
830 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
831 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
832 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
836 #if ENABLE(TIZEN_SCREEN_READER)
837 if (ScreenReaderProxy::screenReader().isEnabled()
838 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
839 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
842 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
843 if (!isClipboardWindowOpened())
844 updateTextSelectionHandlesAndContextMenu(true);
848 void PageClientImpl::displayViewport()
850 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
852 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
856 #if ENABLE(TIZEN_SCREEN_READER)
857 m_viewImpl->page()->recalcScreenReaderFocusRect();
861 void PageClientImpl::drawContents()
865 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
868 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
869 cairo_transform(context, &matrix);
872 if (drawingArea()->layerTreeCoordinatorProxy()) {
873 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
874 renderer->paintToGraphicsContext(context, m_bgColor);
878 cairo_restore(context);
881 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
883 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
884 // We don't want to process scaling in the FullScreen mode.
885 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
889 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
890 m_textSelection->hideHandlers();
893 // Adjust scaleFactor.
894 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
895 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
896 scaleFactor = adjustScaleWithViewport(scaleFactor);
898 scaleFactor = adjustScaleWithViewport(scaleFactor);
901 scaleContents(scaleFactor, scrollPosition);
904 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
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())
911 scaleFactor = adjustScaleWithViewport(scaleFactor);
913 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
916 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
917 // so below code should be replaced when PageViewportController codes are merged.
918 // Please do not use below codes. They are only for scaling contents.
919 void PageClientImpl::suspendContent()
921 if (m_hasSuspendedContent)
924 m_hasSuspendedContent = true;
927 void PageClientImpl::resumeContent()
929 if (!m_hasSuspendedContent)
932 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
933 // The concept is that the values of EwkViewImpl and PageClient can be different
934 // during suspending content and they become same when content is resumed.
935 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
936 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
937 m_hasSuspendedContent = false;
940 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
942 // We need to floor the viewport here as to allow aligning the content in device units. If not,
943 // it might not be possible to scroll the last pixel and that affects fixed position elements.
945 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
946 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
947 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
950 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
951 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
952 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
957 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
958 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
961 if (horizontalBar && !m_horizontalScrollbar) {
962 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
963 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
964 m_horizontalScrollbar->setFrameRect(hBarRect);
965 } else if (!horizontalBar && m_horizontalScrollbar)
966 m_horizontalScrollbar = 0;
968 if (verticalBar && !m_verticalScrollbar) {
969 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
970 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
971 m_verticalScrollbar->setFrameRect(vBarRect);
972 } else if (!verticalBar && m_verticalScrollbar)
973 m_verticalScrollbar = 0;
976 void PageClientImpl::updateScrollbar()
978 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
979 scaledContentsSize.scale(scaleFactor());
981 bool newHasHorizontalScrollbar = false;
982 bool newVerticalScrollbar = false;
983 if (viewSize().width() < scaledContentsSize.width())
984 newHasHorizontalScrollbar = true;
985 if (viewSize().height() < scaledContentsSize.height())
986 newVerticalScrollbar = true;
987 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
989 if (m_horizontalScrollbar) {
990 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
991 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
993 if (m_verticalScrollbar) {
994 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
995 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
999 void PageClientImpl::frameRectChanged()
1001 if (m_horizontalScrollbar) {
1002 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1003 m_horizontalScrollbar->setFrameRect(hBarRect);
1005 if (m_verticalScrollbar) {
1006 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1007 m_verticalScrollbar->setFrameRect(vBarRect);
1011 void PageClientImpl::updateVisibility()
1013 if (m_horizontalScrollbar)
1014 m_horizontalScrollbar->updateVisibility();
1015 if (m_verticalScrollbar)
1016 m_verticalScrollbar->updateVisibility();
1019 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1021 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1022 bool PageClientImpl::isTextSelectionDowned()
1024 return m_textSelection->isTextSelectionDowned();
1027 bool PageClientImpl::isTextSelectionMode()
1029 return m_textSelection->isTextSelectionMode();
1032 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1034 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1037 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1039 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1040 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1043 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1045 if (!evas_object_focus_get(m_viewImpl->view())) {
1046 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1047 if (inputMethodContext && !inputMethodContext->isShow())
1048 inputMethodContext->hideIMFContext();
1050 evas_object_focus_set(m_viewImpl->view(), true);
1053 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1056 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1058 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1061 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1063 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1066 bool PageClientImpl::isTextSelectionHandleDowned()
1068 return m_textSelection->isTextSelectionHandleDowned();
1071 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1072 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1074 m_textSelection->textSelectionHandleDown(point);
1077 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1079 m_textSelection->textSelectionHandleMove(point);
1082 void PageClientImpl::textSelectonHandleUp()
1084 m_textSelection->textSelectionHandleUp();
1088 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1089 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1091 m_textSelection->requestToShow();
1096 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1097 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1099 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1102 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1104 m_offlinePageSave->saveSubresourcesData(subresourceData);
1107 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1109 m_offlinePageSave->startOfflinePageSave(path, url, title);
1113 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1114 void PageClientImpl::pasteContextMenuSelected()
1116 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1120 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1121 void PageClientImpl::setClipboardData(const String& data, const String& type)
1123 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1124 m_clipboardHelper->setData(data, type);
1128 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1129 void PageClientImpl::clipboardContextMenuSelected()
1131 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1134 bool PageClientImpl::isClipboardWindowOpened()
1136 return m_clipboardHelper->isClipboardWindowOpened();
1139 void PageClientImpl::closeClipboardWindow()
1141 m_clipboardHelper->closeClipboardWindow();
1145 void PageClientImpl::clearClipboardData()
1147 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1148 m_clipboardHelper->clear();
1153 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1154 void PageClientImpl::setIsVisible(bool isVisible)
1156 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1157 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1158 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1159 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1160 int angle = ecore_evas_rotation_get(ee);
1161 if (angle == 0 || angle == 180) {
1162 m_shouldMakeBackupTexture = true;
1163 m_shouldShowBackupTexture = true;
1170 m_isVisible = isVisible;
1172 WebPageProxy* pageProxy = m_viewImpl->page();
1174 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1176 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1178 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1183 #if ENABLE(TIZEN_DRAG_SUPPORT)
1184 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1186 m_drag->setDragPoint(point);
1188 bool PageClientImpl::isDragMode()
1190 return m_drag->isDragMode();
1192 void PageClientImpl::setDragMode(bool isDragMode)
1194 m_drag->setDragMode(isDragMode);
1196 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1198 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1199 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1201 String dragStorageName("Drag");
1202 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1204 m_drag->setDragData(dragInfo);
1209 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1210 bool PageClientImpl::isShowingFormDataCandidate()
1212 return m_formDataCandidate->isShowing();
1215 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1217 m_formDataCandidate->updateFormData(data);
1220 void PageClientImpl::hideFormDataCandidate()
1222 m_formDataCandidate->hide();
1225 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1227 m_formDataCandidate->show(rect);
1231 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1232 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1234 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1238 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1239 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1241 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1244 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1246 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1250 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1251 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1253 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1256 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1258 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1261 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1263 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1267 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1268 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1270 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1273 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1275 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1279 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1280 bool PageClientImpl::getStandaloneStatus()
1282 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1286 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1287 bool PageClientImpl::lockOrientation(int willLockOrientation)
1289 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1292 void PageClientImpl::unlockOrientation()
1294 ewk_view_orientation_unlock(m_viewImpl->view());
1298 void PageClientImpl::didRenderFrame()
1300 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1301 if (m_shouldShowBackupTexture && m_isVisible)
1302 m_shouldShowBackupTexture = false;
1304 if (!m_pageDidRendered) {
1305 m_pageDidRendered = true;
1306 initializeVisibleContentRect();
1310 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1311 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1313 setIsScrollableLayerFocused(false);
1314 setIsScrollableNodeFocused(false);
1318 setIsScrollableLayerFocused(true);
1319 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1321 setIsScrollableNodeFocused(true);
1326 void PageClientImpl::findScrollableNode(const IntPoint& point)
1328 WebPageProxy* pageProxy = m_viewImpl->page();
1329 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1330 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1331 WebLayerID webLayerID = 0;
1332 bool checkOverflowLayer = false;
1333 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1334 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1335 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1337 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1342 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1343 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1345 WebCore::IntPoint startPoint, endPoint;
1346 WebCore::IntRect leftRect, rightRect;
1348 WebCore::IntRect caretRect;
1349 m_viewImpl->page()->getCaretPosition(caretRect);
1350 if (!caretRect.isEmpty()) {
1351 startPoint.setX(caretRect.x());
1352 startPoint.setY(caretRect.y() + caretRect.height());
1354 endPoint.setX(caretRect.x() + caretRect.width());
1355 endPoint.setY(caretRect.y() + caretRect.height());
1357 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1358 else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
1359 startPoint.setX(leftRect.x());
1360 startPoint.setY(leftRect.y() + leftRect.height());
1362 endPoint.setX(rightRect.x() + rightRect.width());
1363 endPoint.setY(rightRect.y() + rightRect.height());
1367 startPoint.scale(scaleFactor(), scaleFactor());
1368 endPoint.scale(scaleFactor(), scaleFactor());
1370 int viewPositionX, viewPositionY;
1371 evas_object_geometry_get(m_viewImpl->view(), &viewPositionX, &viewPositionY, NULL, NULL);
1373 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1374 startPoint.move(viewPositionX, viewPositionY);
1376 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1377 endPoint.move(viewPositionX, viewPositionY);
1379 ewkViewDidGetTextStyleStateForSelection(m_viewImpl->view(), underlineState, italicState, boldState, startPoint, endPoint);
1383 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1385 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1388 #if ENABLE(TIZEN_ICON_DATABASE)
1389 void PageClientImpl::didReceiveIcon()
1391 ewkViewIconReceived(m_viewImpl->view());
1395 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1396 void PageClientImpl::hideFocusRing()
1398 ewkViewFocusRingHide(m_viewImpl->view());
1401 #endif // #if OS(TIZEN)
1404 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1405 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1406 : PageClientImpl(viewImpl)
1412 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1415 , m_isAcceleratedCompositingModeInitialized(false)
1417 initializeAcceleratedCompositingMode();
1420 PageClientEvasGL::~PageClientEvasGL()
1422 m_viewImpl->page()->close();
1425 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1428 evas_gl_surface_destroy(m_evasGL, m_surface);
1433 PageClientImpl::updateViewportSize(viewportSize);
1436 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1438 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1441 m_viewImpl->redrawRegion(rect);
1443 #if ENABLE(TIZEN_SCREEN_READER)
1444 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1445 m_viewImpl->page()->recalcScreenReaderFocusRect();
1449 void PageClientEvasGL::displayViewport()
1451 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1452 // We should not draw here when Direct Rendering is enabled.
1453 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1454 ewk_view_mark_for_sync(m_viewImpl->view());
1456 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1459 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1463 #if ENABLE(TIZEN_SCREEN_READER)
1464 m_viewImpl->page()->recalcScreenReaderFocusRect();
1468 void PageClientEvasGL::drawContents()
1470 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1473 WebCore::TransformationMatrix matrix;
1475 IntSize ewkViewSize = viewSize();
1477 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1478 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1479 m_angle = ecore_evas_rotation_get(ee);
1481 drawingArea()->setAngle(m_angle);
1482 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1484 if (m_angle == 90 || m_angle == 270) {
1485 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1487 matrix.translate(-ewkViewSize.width(), 0);
1488 else if (m_angle == 270)
1489 matrix.translate(0, -ewkViewSize.height());
1490 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1492 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1494 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1495 clipRect = IntRect(IntPoint(), ewkViewSize);
1498 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1499 clipRect = IntRect(IntPoint(), ewkViewSize);
1501 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1503 if (drawingArea()) {
1504 if (drawingArea()->layerTreeCoordinatorProxy()) {
1505 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1506 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1507 if (m_shouldMakeBackupTexture) {
1508 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1509 glClearColor(1, 1, 1, 1);
1510 glClear(GL_COLOR_BUFFER_BIT);
1511 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1512 m_shouldMakeBackupTexture = false;
1513 } else if (m_shouldShowBackupTexture) {
1514 matrix.makeIdentity();
1515 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1516 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1519 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1524 void PageClientEvasGL::didRenderFrame()
1526 ewkViewFrameRendered(m_viewImpl->view());
1527 PageClientImpl::didRenderFrame();
1530 bool PageClientEvasGL::makeContextCurrent()
1532 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1535 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1537 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1539 m_config = evas_gl_config_new();
1540 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1541 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1542 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1544 m_config->color_format = EVAS_GL_RGBA_8888;
1545 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1546 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1548 m_evasGL = evas_gl_new(evas);
1550 evas_gl_config_free(m_config);
1552 TIZEN_LOGE("failed to create evas_gl");
1556 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1558 evas_gl_free(m_evasGL);
1560 evas_gl_config_free(m_config);
1562 TIZEN_LOGE("failed to get evas_gl_api");
1565 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1567 m_context = evas_gl_context_create(m_evasGL, 0);
1569 evas_gl_free(m_evasGL);
1571 evas_gl_config_free(m_config);
1573 TIZEN_LOGE("failed to create evas_gl_context");
1578 m_isAcceleratedCompositingModeInitialized = true;
1581 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1585 evas_gl_surface_destroy(m_evasGL, m_surface);
1589 evas_gl_context_destroy(m_evasGL, m_context);
1593 evas_gl_config_free(m_config);
1596 evas_gl_free(m_evasGL);
1600 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1601 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1603 m_isAcceleratedCompositingModeInitialized = false;
1606 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1608 if (!m_isAcceleratedCompositingModeInitialized)
1609 initializeAcceleratedCompositingMode();
1612 void PageClientEvasGL::exitAcceleratedCompositingMode()
1614 if (m_isAcceleratedCompositingModeInitialized)
1615 finalizeAcceleratedCompositingMode();
1618 void PageClientEvasGL::setTargetSurface()
1624 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1625 if (width == 0 || height == 0)
1628 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1630 TIZEN_LOGE("failed to create Evas_GL_Surface");
1634 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1635 makeContextCurrent();
1637 if (makeContextCurrent()) {
1638 glViewport(0, 0, width, height);
1639 glClearColor(1.0, 1.0, 1.0, 1.0);
1640 glClear(GL_COLOR_BUFFER_BIT);
1645 Evas_Native_Surface nativeSurface;
1646 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1647 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1651 } // namespace WebKit