2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "PageClientImpl.h"
29 #include "EwkViewImpl.h"
30 #include "InputMethodContextEfl.h"
31 #include "NativeWebKeyboardEvent.h"
32 #include "NotImplemented.h"
33 #include "TransformationMatrix.h"
34 #include "WebContext.h"
35 #include "WebContextMenuProxy.h"
36 #include "WebPageProxy.h"
37 #include "WebPopupMenuProxyEfl.h"
38 #include "ewk_context.h"
39 #include "ewk_context_private.h"
40 #include "ewk_download_job.h"
41 #include "ewk_download_job_private.h"
45 #include "DrawingAreaProxyImpl.h"
47 #include "EflScreenUtilities.h"
48 #include "LayerTreeCoordinatorProxy.h"
49 #include "OpenGLShims.h"
50 #include "WebContextMenuProxyTizen.h"
51 #include "WebLayerTreeRenderer.h"
52 #include "WebPageGroup.h"
53 #include "WebPageMessages.h"
54 #include "WebPopupMenuProxyEfl.h"
55 #include "WebPreferences.h"
57 #include <Ecore_Evas.h>
60 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
61 #include "MainFrameScrollbarTizen.h"
64 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
65 #include "ClipboardHelper.h"
68 #if ENABLE(TIZEN_DRAG_SUPPORT)
73 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
74 #include "ewk_context_private.h"
77 #if ENABLE(TIZEN_SCREEN_READER)
78 #include "ScreenReaderProxy.h"
81 using namespace WebCore;
86 PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
87 : m_viewImpl(viewImpl)
89 , m_viewportConstraints()
90 , m_viewFocused(false)
91 , m_viewWindowActive(true)
92 , m_pageDidRendered(true)
94 , m_viewportFitsToContent(false)
95 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
96 , m_visibleContentRect(IntRect())
98 , m_hasSuspendedContent(false)
100 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
101 , m_restoredScaleFactor(0)
103 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
104 , m_scrollPositionBeforePageRendered(IntPoint())
107 , m_deferUpdateViewportSize(false)
108 , m_isScrollableLayerFocused(false)
109 , m_isScrollableNodeFocused(false)
110 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
111 , m_shouldMakeBackupTexture(false)
112 , m_shouldShowBackupTexture(false)
114 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
115 , m_isContextMenuVisible(false)
117 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
118 , m_waitFrameOfNewViewortSize(false)
120 , m_nonemptyLayoutRendered(false)
121 #endif // #if OS(TIZEN)
123 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
124 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
125 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
129 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
130 m_textSelection = TextSelection::create(m_viewImpl);
132 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
133 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
135 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
136 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
138 #if ENABLE(TIZEN_DRAG_SUPPORT)
139 m_drag = Drag::create(m_viewImpl);
141 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
142 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
144 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
145 m_viewportAngle = ecore_evas_rotation_get(ee);
148 setBackgroundColor(1, 1, 1, 1);
151 PageClientImpl::~PageClientImpl()
153 if (m_viewImpl && m_viewImpl->page())
154 m_viewImpl->page()->close();
158 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
160 PageClientImpl::ViewportConstraints constraints;
161 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
162 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
163 constraints.userScalable = attributes.userScalable;
164 constraints.layoutSize = attributes.layoutSize;
165 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
167 bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
168 if (autoFittingEnabled)
169 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
171 // if content doesn't set initial scale value, set readable scale factor
172 // if not, set initial scale factor of viewport attribute
173 if (attributes.initialScale == ViewportArguments::ValueAuto)
174 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
176 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
179 // adjust scale with both minimum and maximum scale factor
180 constraints.initialScale = adjustScaleWithViewport(constraints.initialScale);
185 double PageClientImpl::adjustScaleWithViewport(double scale)
187 double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
188 return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale);
191 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
192 void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle)
194 #if ENABLE(TIZEN_DLOG_SUPPORT)
195 TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle);
197 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
198 if (m_deferUpdateViewportSize) {
199 m_visibleContentRect.setSize(viewportSize);
200 m_viewImpl->page()->setViewportSize(viewportSize);
201 m_deferUpdateViewportSize = false;
206 // update viewport size of webkit
207 m_viewImpl->page()->setViewportSize(viewportSize);
210 void PageClientImpl::updateVisibleContentRectSize(const IntSize& size)
212 // update visible content rect's size
213 m_visibleContentRect.setSize(size);
217 void PageClientImpl::prepareRestoredVisibleContectRect()
219 m_restoredScaleFactor = scaleFactor();
220 m_restoredScrollPosition = scrollPosition();
221 #if ENABLE(TIZEN_DLOG_SUPPORT)
222 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
226 void PageClientImpl::initializeVisibleContentRect()
228 _ewk_view_resume_painting(m_viewImpl->view());
230 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
231 IntPoint initialScrollPosition;
232 float initialScaleFactor = m_viewportConstraints.initialScale;
233 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
234 initialScrollPosition = m_scrollPositionBeforePageRendered;
235 m_scrollPositionBeforePageRendered = IntPoint();
237 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
238 // if scroll position and scale factor are restored by history controller,
239 // move scroll position and scale factor with them
240 if (m_restoredScaleFactor) {
241 initialScrollPosition = m_restoredScrollPosition;
242 initialScaleFactor = m_restoredScaleFactor;
244 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
245 m_restoredScaleFactor = 0;
247 #if ENABLE(TIZEN_DLOG_SUPPORT)
248 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", initialScrollPosition.x(), initialScrollPosition.y(), initialScaleFactor);
251 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
253 // Set initial scale.
254 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
258 double PageClientImpl::availableMinimumScale()
260 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
261 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
262 IntSize contentsSize = m_viewImpl->page()->contentsSize();
263 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
264 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
265 // If there's only a bit ignorable difference between horizontalMinScale and verticalMinScale,
266 // ignore verticalMinScale to fit content's width to view
267 const double ignorableThreshold = 0.01;
268 if (fabs(horizontalMinScale - verticalMinScale) < ignorableThreshold)
269 verticalMinScale = horizontalMinScale;
270 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
273 void PageClientImpl::fitViewportToContent()
275 #if ENABLE(TIZEN_DLOG_SUPPORT)
276 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), m_viewportConstraints.minimumScale);
278 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
281 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
283 m_focusedNodeRect = focusedNodeRect;
286 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
287 bool PageClientImpl::scrollBy(IntSize scrollOffset)
289 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
290 // scrollOffset means device screen coordiate, not an actual offset of contents.
291 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
292 // in the actual scale.
293 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
294 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
295 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
301 IntPoint oldScrollPosition = scrollPosition();
302 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
307 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
309 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
311 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
313 #endif // #if OS(TIZEN)
315 EwkViewImpl* PageClientImpl::viewImpl() const
321 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
323 return DrawingAreaProxyImpl::create(m_viewImpl->page());
326 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
329 ewk_view_mark_for_sync(m_viewImpl->view());
331 m_viewImpl->redrawRegion(rect);
334 #if ENABLE(TIZEN_SCREEN_READER)
335 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
336 m_viewImpl->page()->recalcScreenReaderFocusRect();
340 void PageClientImpl::displayView()
345 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
347 setViewNeedsDisplay(scrollRect);
350 WebCore::IntSize PageClientImpl::viewSize()
352 return m_viewImpl->size();
355 bool PageClientImpl::isViewVisible()
360 return m_viewImpl->isVisible();
364 bool PageClientImpl::isViewInWindow()
370 void PageClientImpl::processDidCrash()
372 // Check if loading was ongoing, when web process crashed.
373 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
374 if (loadProgress >= 0 && loadProgress < 1)
375 m_viewImpl->informLoadProgress(1);
377 m_viewImpl->informWebProcessCrashed();
380 void PageClientImpl::didRelaunchProcess()
382 const char* themePath = m_viewImpl->themePath();
384 m_viewImpl->page()->setThemePath(themePath);
387 void PageClientImpl::pageClosed()
392 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
394 m_viewImpl->informTooltipTextChange(newToolTip);
397 void PageClientImpl::setCursor(const Cursor& cursor)
399 m_viewImpl->setCursor(cursor);
402 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
407 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
409 double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
410 m_viewportConstraints = computeViewportConstraints(attributes);
412 #if ENABLE(TIZEN_GESTURE)
413 m_viewImpl->setDoubleTapEnabled(userScalable());
416 // Initially, m_scaleFactor is not decided yet.
417 // So, we should update visible content rect at here.
418 if (!m_scaleFactor) {
419 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale);
423 // if content is reloaded, contents size will not be changed
424 // so, we need to calculate minimum scale here.
425 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
426 if (m_viewportConstraints.userScalable) {
427 if (fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
428 m_viewportConstraints.initialScale = availableMinimumScale();
429 m_viewportConstraints.minimumScale = availableMinimumScale();
432 #if ENABLE(TIZEN_DLOG_SUPPORT)
433 TIZEN_LOGI("layout size: [%d, %d], scale: [%.2f, %.2f, %.2f], user scalable: [%s]",
434 m_viewportConstraints.layoutSize.width(), m_viewportConstraints.layoutSize.height(),
435 m_viewportConstraints.initialScale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale,
436 m_viewportConstraints.userScalable ? "TRUE" : "FALSE");
439 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
440 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
443 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
444 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
447 float newScale = scaleFactor();
448 IntPoint newScrollPosition = m_visibleContentRect.location();
449 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
450 int angle = ecore_evas_rotation_get(ee);
451 bool isRotated = (angle != m_viewportAngle);
453 // if it's rotated, we need to fit content to viewport by minimize the scale
455 m_viewportAngle = angle;
456 newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
457 if (m_viewportFitsToContent)
458 newScale = m_viewportConstraints.minimumScale;
459 newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
462 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
463 if (m_waitFrameOfNewViewortSize)
464 ewk_view_resume(m_viewImpl->view());
466 #if ENABLE(TIZEN_DLOG_SUPPORT)
467 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated");
470 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
471 setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
473 m_viewImpl->page()->scalePage(newScale, newScrollPosition);
476 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
477 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
478 if (smartData->api->formdata_candidate_is_showing(smartData))
479 smartData->api->formdata_candidate_hide(smartData);
482 #if ENABLE(TIZEN_FULLSCREEN_API)
483 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
484 m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle();
489 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
491 if (undoOrRedo == WebPageProxy::Undo) {
492 m_undoCommands.append(command);
494 int undoSize = m_undoCommands.size();
495 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
498 m_redoCommands.append(command);
500 int redoSize = m_redoCommands.size();
501 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
505 void PageClientImpl::clearAllEditCommands()
507 m_undoCommands.clear();
508 m_redoCommands.clear();
510 int undoSize = m_undoCommands.size();
511 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
513 int redoSize = m_redoCommands.size();
514 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
517 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
519 if (undoOrRedo == WebPageProxy::Undo)
520 return !m_undoCommands.isEmpty();
522 return !m_redoCommands.isEmpty();
525 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
527 if (undoOrRedo == WebPageProxy::Undo) {
528 m_undoCommands.last()->unapply();
529 m_undoCommands.removeLast();
531 int undoSize = m_undoCommands.size();
532 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
534 m_redoCommands.last()->reapply();
535 m_redoCommands.removeLast();
537 int redoSize = m_redoCommands.size();
538 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
542 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
547 void PageClientImpl::clearAllEditCommands()
552 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
558 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
564 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
570 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
576 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
582 IntRect PageClientImpl::windowToScreen(const IntRect&)
588 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
593 #if ENABLE(GESTURE_EVENTS)
594 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
600 #if ENABLE(TOUCH_EVENTS)
601 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
604 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
607 #endif // #if OS(TIZEN)
611 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
613 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
616 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
618 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
619 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
626 #if ENABLE(INPUT_TYPE_COLOR)
627 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
634 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
640 #if USE(ACCELERATED_COMPOSITING)
641 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
643 m_viewImpl->enterAcceleratedCompositingMode();
646 void PageClientImpl::exitAcceleratedCompositingMode()
648 m_viewImpl->exitAcceleratedCompositingMode();
651 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
655 #endif // USE(ACCELERATED_COMPOSITING)
658 void PageClientImpl::initializeAcceleratedCompositingMode()
662 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
663 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
667 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
669 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
671 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
672 m_bgColor.setRGB(rgba);
675 void PageClientImpl::didChangeScrollbarsForMainFrame() const
681 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
683 m_nonemptyLayoutRendered = true;
684 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
685 m_initialViewRect.setSize(viewSize());
689 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
691 #if ENABLE(TIZEN_DLOG_SUPPORT)
692 TIZEN_LOGI(" [%d, %d]", size.width(), size.height());
694 #if USE(TILED_BACKING_STORE)
698 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
699 if (drawingArea()->layerTreeCoordinatorProxy())
700 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
703 // if minimum scale factor is changed, update minimumScale.
704 if (m_viewportConstraints.userScalable) {
705 double minimumScale = availableMinimumScale();
707 // Sometimes initializeVisibleContentRect can be called after content size change.
708 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
709 if (!m_viewportConstraints.contentsDefinedInitialScale
710 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
711 m_viewportConstraints.initialScale = minimumScale;
712 m_viewportConstraints.minimumScale = minimumScale;
715 m_viewImpl->informContentsSizeChange(size);
717 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
720 // FIXME: Do we really need to adjust visible content rect at here?
721 // if contents size is changed smaller and visible content rect is outside of content area,
722 // adjust visible content rect
723 bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect);
724 bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits<float>::epsilon());
725 if (needScrollAdjustment || needScaleAdjustment) {
726 #if ENABLE(TIZEN_DLOG_SUPPORT)
727 TIZEN_LOGI(" setVisibleContentRect: [%d, %d], [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), scaleFactor());
729 setVisibleContentRect(m_visibleContentRect, scaleFactor());
733 void PageClientImpl::pageScaleFactorDidChange()
735 ewk_view_focused_node_adjust(m_viewImpl->view());
737 #endif // #if OS(TIZEN)
739 void PageClientImpl::didCommitLoadForMainFrame(bool)
742 m_pageDidRendered = false;
743 m_viewportFitsToContent = false;
744 m_nonemptyLayoutRendered = false;
750 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
755 double PageClientImpl::customRepresentationZoomFactor()
761 void PageClientImpl::setCustomRepresentationZoomFactor(double)
766 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
771 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
776 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
781 void PageClientImpl::updateTextInputState()
783 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
784 m_textSelection->update();
785 if (isTextSelectionMode() && isTextSelectionHandleDowned())
789 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
790 if (inputMethodContext)
791 inputMethodContext->updateTextInputState();
794 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
796 Ewk_Context* context = m_viewImpl->ewkContext();
797 context->downloadManager()->registerDownload(download, m_viewImpl);
800 #if USE(TILED_BACKING_STORE)
801 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
803 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
804 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
805 if (smartData->api->formdata_candidate_is_showing(smartData))
808 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
809 IntPoint newPoint = point;
810 newPoint.scale(scaleFactor(), scaleFactor());
811 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
812 if (!m_pageDidRendered)
813 m_scrollPositionBeforePageRendered = newPoint;
815 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
817 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
824 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
825 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
827 m_restoredScrollPosition = point;
828 m_restoredScrollPosition.scale(scale, scale);
829 m_restoredScaleFactor = scale;
830 #if ENABLE(TIZEN_DLOG_SUPPORT)
831 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
834 // Before contents size is fixed, just update visible content rect's position
835 m_visibleContentRect.setLocation(m_restoredScrollPosition);
839 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
840 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
842 if (value == m_formDataCandidate->getCandidateValue()) {
843 m_formDataCandidate->updateCandidateValue(emptyString());
847 m_formDataCandidate->updateCandidateValue(value);
848 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
852 void PageClientImpl::updateFormNavigation(int length, int offset)
857 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
858 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
859 DrawingAreaProxy* PageClientImpl::drawingArea() const
861 return m_viewImpl->page()->drawingArea();
865 // Before rendering, scale factor and scroll position is different from m_viewImpl.
866 float PageClientImpl::scaleFactor()
868 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
871 const IntPoint PageClientImpl::scrollPosition()
873 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
876 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
878 IntSize contentsSize = m_viewImpl->page()->contentsSize();
879 contentsSize.scale(targetScale);
880 if (contentsSize.width() < visibleContentRect.width())
881 visibleContentRect.setX(0);
883 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
885 if (contentsSize.height() < visibleContentRect.height())
886 visibleContentRect.setY(0);
888 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
889 return visibleContentRect;
892 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
894 #if ENABLE(TIZEN_SCREEN_READER)
895 IntPoint previousScrollPosition(scrollPosition());
896 float previousScale = m_scaleFactor;
899 m_scaleFactor = adjustScaleWithViewport(newScale);
900 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
901 m_visibleContentRect.setLocation(newRect.location());
902 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
904 // update both drawing scale factor and scroll position after page is rendered
905 if (m_pageDidRendered) {
906 if (!m_hasSuspendedContent) {
907 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
908 // PageViewport's values are updated when resuming content in the webkit opensource,
909 // but we have to update viewImpl's values here to sync with PageClient's values.
910 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
911 // The values will be updated when resuming content.
912 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
913 m_viewImpl->setScaleFactor(m_scaleFactor);
914 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
918 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
919 // So we removed enclosingIntRect and replaced with floorf and ceilf.
920 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
921 floorf(m_visibleContentRect.y() / m_scaleFactor),
922 ceilf(m_visibleContentRect.width() / m_scaleFactor),
923 ceilf(m_visibleContentRect.height() / m_scaleFactor));
926 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
927 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
928 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
929 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
933 #if ENABLE(TIZEN_SCREEN_READER)
934 if (ScreenReaderProxy::screenReader().isActive(m_viewImpl)
935 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
936 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
939 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
940 if (!isClipboardWindowOpened())
941 updateTextSelectionHandlesAndContextMenu(true);
945 void PageClientImpl::displayViewport()
947 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
949 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
953 #if ENABLE(TIZEN_SCREEN_READER)
954 m_viewImpl->page()->recalcScreenReaderFocusRect();
958 void PageClientImpl::drawContents()
962 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
965 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
966 cairo_transform(context, &matrix);
969 if (drawingArea()->layerTreeCoordinatorProxy()) {
970 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
971 renderer->paintToGraphicsContext(context, m_bgColor);
975 cairo_restore(context);
978 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
980 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
981 // We don't want to process scaling in the FullScreen mode.
982 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
986 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
987 m_textSelection->hideHandlers();
990 // Adjust scaleFactor.
991 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
992 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
993 scaleFactor = adjustScaleWithViewport(scaleFactor);
995 scaleFactor = adjustScaleWithViewport(scaleFactor);
998 scaleContents(scaleFactor, scrollPosition);
1001 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
1003 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1004 // We don't want to process scaling in the FullScreen mode.
1005 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
1008 scaleFactor = adjustScaleWithViewport(scaleFactor);
1010 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
1013 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1014 // so below code should be replaced when PageViewportController codes are merged.
1015 // Please do not use below codes. They are only for scaling contents.
1016 void PageClientImpl::suspendContent()
1018 if (m_hasSuspendedContent)
1021 m_hasSuspendedContent = true;
1024 void PageClientImpl::resumeContent()
1026 if (!m_hasSuspendedContent)
1029 #if ENABLE(TIZEN_DLOG_SUPPORT)
1030 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_viewImpl->scrollPosition().x(), m_viewImpl->scrollPosition().y(), m_viewImpl->scaleFactor());
1033 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
1034 // The concept is that the values of EwkViewImpl and PageClient can be different
1035 // during suspending content and they become same when content is resumed.
1036 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1037 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
1038 m_hasSuspendedContent = false;
1041 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1043 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1044 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1046 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
1047 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1048 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1050 FloatPoint position;
1051 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1052 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1053 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1058 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1059 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1061 // create if needed.
1062 if (horizontalBar && !m_horizontalScrollbar) {
1063 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
1064 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1065 m_horizontalScrollbar->setFrameRect(hBarRect);
1066 } else if (!horizontalBar && m_horizontalScrollbar)
1067 m_horizontalScrollbar = 0;
1069 if (verticalBar && !m_verticalScrollbar) {
1070 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
1071 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1072 m_verticalScrollbar->setFrameRect(vBarRect);
1073 } else if (!verticalBar && m_verticalScrollbar)
1074 m_verticalScrollbar = 0;
1077 void PageClientImpl::updateScrollbar()
1079 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
1080 scaledContentsSize.scale(scaleFactor());
1082 bool newHasHorizontalScrollbar = false;
1083 bool newVerticalScrollbar = false;
1084 if (viewSize().width() < scaledContentsSize.width())
1085 newHasHorizontalScrollbar = true;
1086 if (viewSize().height() < scaledContentsSize.height())
1087 newVerticalScrollbar = true;
1088 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1090 if (m_horizontalScrollbar) {
1091 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1092 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
1094 if (m_verticalScrollbar) {
1095 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1096 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1100 void PageClientImpl::frameRectChanged()
1102 if (m_horizontalScrollbar) {
1103 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1104 m_horizontalScrollbar->setFrameRect(hBarRect);
1106 if (m_verticalScrollbar) {
1107 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1108 m_verticalScrollbar->setFrameRect(vBarRect);
1112 void PageClientImpl::updateVisibility()
1114 if (m_horizontalScrollbar)
1115 m_horizontalScrollbar->updateVisibility();
1116 if (m_verticalScrollbar)
1117 m_verticalScrollbar->updateVisibility();
1120 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1122 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1123 bool PageClientImpl::isTextSelectionDowned()
1125 return m_textSelection->isTextSelectionDowned();
1128 bool PageClientImpl::isTextSelectionMode()
1130 return m_textSelection->isTextSelectionMode();
1133 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1135 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1138 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1140 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1141 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1144 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point)
1146 if (!evas_object_focus_get(m_viewImpl->view())) {
1147 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1148 if (inputMethodContext)
1149 inputMethodContext->hideIMFContext();
1151 evas_object_focus_set(m_viewImpl->view(), true);
1154 return m_textSelection->textSelectionDown(point);
1157 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point)
1159 m_textSelection->textSelectionMove(point);
1162 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1164 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1167 bool PageClientImpl::isTextSelectionHandleDowned()
1169 return m_textSelection->isTextSelectionHandleDowned();
1172 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1173 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1175 m_textSelection->textSelectionHandleDown(point);
1178 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1180 m_textSelection->textSelectionHandleMove(point);
1183 void PageClientImpl::textSelectonHandleUp()
1185 m_textSelection->textSelectionHandleUp();
1189 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1191 m_textSelection->requestToShow();
1194 void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
1196 m_textSelection->initHandlesMouseDownedStatus();
1199 void PageClientImpl::changeContextMenuPosition(IntPoint& point)
1201 m_textSelection->changeContextMenuPosition(point);
1205 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1206 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1208 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1211 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1213 m_offlinePageSave->saveSubresourcesData(subresourceData);
1216 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1218 m_offlinePageSave->startOfflinePageSave(path, url, title);
1222 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1223 void PageClientImpl::pasteContextMenuSelected()
1225 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1229 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1230 void PageClientImpl::setClipboardData(const String& data, const String& type)
1232 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1233 m_clipboardHelper->setData(data, type);
1237 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1238 void PageClientImpl::clipboardContextMenuSelected()
1240 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1243 bool PageClientImpl::isClipboardWindowOpened()
1245 return m_clipboardHelper->isClipboardWindowOpened();
1248 void PageClientImpl::closeClipboardWindow()
1250 m_clipboardHelper->closeClipboardWindow();
1254 void PageClientImpl::clearClipboardData()
1256 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1257 m_clipboardHelper->clear();
1262 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1263 void PageClientImpl::setIsVisible(bool isVisible)
1265 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1266 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1267 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1268 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1269 int angle = ecore_evas_rotation_get(ee);
1270 if (angle == 0 || angle == 180) {
1271 m_shouldMakeBackupTexture = true;
1272 m_shouldShowBackupTexture = true;
1279 m_isVisible = isVisible;
1281 WebPageProxy* pageProxy = m_viewImpl->page();
1283 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1285 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1287 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1292 #if ENABLE(TIZEN_DRAG_SUPPORT)
1293 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1295 m_drag->setDragPoint(point);
1297 bool PageClientImpl::isDragMode()
1299 return m_drag->isDragMode();
1301 void PageClientImpl::setDragMode(bool isDragMode)
1303 m_drag->setDragMode(isDragMode);
1305 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1307 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1308 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1310 String dragStorageName("Drag");
1311 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1313 m_drag->setDragData(dragInfo, dragImage);
1318 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1319 bool PageClientImpl::isShowingFormDataCandidate()
1321 return m_formDataCandidate->isShowing();
1324 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1326 m_formDataCandidate->updateFormData(data);
1329 void PageClientImpl::hideFormDataCandidate()
1331 m_formDataCandidate->hide();
1334 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1336 m_formDataCandidate->show(rect);
1340 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1341 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1343 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1347 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1348 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1350 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1353 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1355 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1359 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1360 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1362 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1365 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1367 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1370 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1372 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1376 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1377 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1379 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1382 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1384 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1388 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1389 bool PageClientImpl::getStandaloneStatus()
1391 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1395 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1396 bool PageClientImpl::lockOrientation(int willLockOrientation)
1398 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1401 void PageClientImpl::unlockOrientation()
1403 ewk_view_orientation_unlock(m_viewImpl->view());
1407 void PageClientImpl::didRenderFrame()
1409 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1410 if (m_shouldShowBackupTexture && m_isVisible)
1411 m_shouldShowBackupTexture = false;
1413 if (!m_pageDidRendered) {
1414 m_pageDidRendered = true;
1415 initializeVisibleContentRect();
1418 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
1419 if (m_waitFrameOfNewViewortSize) {
1420 m_waitFrameOfNewViewortSize = false;
1421 ewkViewRotatePrepared(m_viewImpl->view());
1426 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1427 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1429 setIsScrollableLayerFocused(false);
1430 setIsScrollableNodeFocused(false);
1434 setIsScrollableLayerFocused(true);
1435 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1437 setIsScrollableNodeFocused(true);
1442 void PageClientImpl::findScrollableNode(const IntPoint& point)
1444 WebPageProxy* pageProxy = m_viewImpl->page();
1445 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1446 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1447 WebLayerID webLayerID = 0;
1448 bool checkOverflowLayer = false;
1449 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1450 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1451 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1453 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1458 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1460 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1463 #if ENABLE(TIZEN_ICON_DATABASE)
1464 void PageClientImpl::didReceiveIcon()
1466 ewkViewIconReceived(m_viewImpl->view());
1470 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1471 void PageClientImpl::hideFocusRing()
1473 ewkViewFocusRingHide(m_viewImpl->view());
1476 #endif // #if OS(TIZEN)
1479 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1480 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1481 : PageClientImpl(viewImpl)
1487 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1490 , m_isAcceleratedCompositingModeInitialized(false)
1492 initializeAcceleratedCompositingMode();
1495 PageClientEvasGL::~PageClientEvasGL()
1497 if (m_viewImpl && m_viewImpl->page())
1498 m_viewImpl->page()->close();
1501 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
1503 PageClientImpl::updateViewportSize(viewportSize, angle);
1506 void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size)
1509 evas_gl_surface_destroy(m_evasGL, m_surface);
1514 PageClientImpl::updateVisibleContentRectSize(size);
1517 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1519 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1520 if (!isDirectRendering())
1523 m_viewImpl->redrawRegion(rect);
1525 #if ENABLE(TIZEN_SCREEN_READER)
1526 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1527 m_viewImpl->page()->recalcScreenReaderFocusRect();
1531 void PageClientEvasGL::displayViewport()
1533 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1534 // We should not draw here when Direct Rendering is enabled.
1535 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1536 if (isDirectRendering())
1537 ewk_view_mark_for_sync(m_viewImpl->view());
1540 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1542 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1546 #if ENABLE(TIZEN_SCREEN_READER)
1547 m_viewImpl->page()->recalcScreenReaderFocusRect();
1551 void PageClientEvasGL::drawContents()
1553 if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()))
1556 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1560 if (!makeContextCurrent())
1563 WebCore::TransformationMatrix matrix;
1565 IntSize ewkViewSize = viewSize();
1567 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1568 if (isDirectRendering()) {
1569 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1570 m_angle = ecore_evas_rotation_get(ee);
1571 renderer->setAngle(m_angle);
1572 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1574 if (m_angle == 90 || m_angle == 270) {
1575 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1577 matrix.translate(-ewkViewSize.width(), 0);
1578 else if (m_angle == 270)
1579 matrix.translate(0, -ewkViewSize.height());
1580 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1582 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1584 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1585 clipRect = IntRect(IntPoint(), ewkViewSize);
1590 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1591 clipRect = IntRect(IntPoint(), ewkViewSize);
1594 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1596 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1597 if (m_shouldMakeBackupTexture) {
1598 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1599 glClearColor(1, 1, 1, 1);
1600 glClear(GL_COLOR_BUFFER_BIT);
1601 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1602 m_shouldMakeBackupTexture = false;
1603 } else if (m_shouldShowBackupTexture) {
1604 matrix.makeIdentity();
1605 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1606 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1609 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1612 void PageClientEvasGL::didRenderFrame()
1614 ewkViewFrameRendered(m_viewImpl->view());
1615 PageClientImpl::didRenderFrame();
1618 bool PageClientEvasGL::makeContextCurrent()
1620 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1623 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1625 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1627 m_config = evas_gl_config_new();
1628 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1629 char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
1630 if (!directRenderingEnv || atoi(directRenderingEnv)) {
1631 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1632 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1635 m_config->color_format = EVAS_GL_RGBA_8888;
1636 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1637 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1639 m_evasGL = evas_gl_new(evas);
1641 evas_gl_config_free(m_config);
1643 TIZEN_LOGE("failed to create evas_gl");
1647 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1649 evas_gl_free(m_evasGL);
1651 evas_gl_config_free(m_config);
1653 TIZEN_LOGE("failed to get evas_gl_api");
1656 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1658 m_context = evas_gl_context_create(m_evasGL, 0);
1660 evas_gl_free(m_evasGL);
1662 evas_gl_config_free(m_config);
1664 TIZEN_LOGE("failed to create evas_gl_context");
1669 m_isAcceleratedCompositingModeInitialized = true;
1672 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1676 evas_gl_surface_destroy(m_evasGL, m_surface);
1680 evas_gl_context_destroy(m_evasGL, m_context);
1684 evas_gl_config_free(m_config);
1687 evas_gl_free(m_evasGL);
1691 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1692 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1694 m_isAcceleratedCompositingModeInitialized = false;
1697 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1699 if (!m_isAcceleratedCompositingModeInitialized)
1700 initializeAcceleratedCompositingMode();
1703 void PageClientEvasGL::exitAcceleratedCompositingMode()
1705 if (m_isAcceleratedCompositingModeInitialized)
1706 finalizeAcceleratedCompositingMode();
1709 void PageClientEvasGL::setTargetSurface()
1715 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1716 if (width == 0 || height == 0)
1719 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1721 TIZEN_LOGE("failed to create Evas_GL_Surface");
1725 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1726 if (isDirectRendering())
1727 makeContextCurrent();
1731 if (makeContextCurrent()) {
1732 glViewport(0, 0, width, height);
1733 glClearColor(1.0, 1.0, 1.0, 1.0);
1734 glClear(GL_COLOR_BUFFER_BIT);
1739 Evas_Native_Surface nativeSurface;
1740 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1741 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1745 } // namespace WebKit