2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "PageClientImpl.h"
29 #include "EwkViewImpl.h"
30 #include "InputMethodContextEfl.h"
31 #include "NativeWebKeyboardEvent.h"
32 #include "NotImplemented.h"
33 #include "TransformationMatrix.h"
34 #include "WebContext.h"
35 #include "WebContextMenuProxy.h"
36 #include "WebPageProxy.h"
37 #include "WebPopupMenuProxyEfl.h"
38 #include "ewk_context.h"
39 #include "ewk_context_private.h"
40 #include "ewk_download_job.h"
41 #include "ewk_download_job_private.h"
45 #include "DrawingAreaProxyImpl.h"
47 #include "EflScreenUtilities.h"
48 #include "LayerTreeCoordinatorProxy.h"
49 #include "OpenGLShims.h"
50 #include "WebContextMenuProxyTizen.h"
51 #include "WebLayerTreeRenderer.h"
52 #include "WebPageGroup.h"
53 #include "WebPageMessages.h"
54 #include "WebPopupMenuProxyEfl.h"
55 #include "WebPreferences.h"
57 #include <Ecore_Evas.h>
60 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
61 #include "MainFrameScrollbarTizen.h"
64 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
65 #include "ClipboardHelper.h"
68 #if ENABLE(TIZEN_DRAG_SUPPORT)
73 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
74 #include "ewk_context_private.h"
77 using namespace WebCore;
82 PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
83 : m_viewImpl(viewImpl)
85 , m_viewportConstraints()
86 , m_viewFocused(false)
87 , m_viewWindowActive(true)
88 , m_pageDidRendered(true)
90 , m_viewportFitsToContent(false)
91 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
92 , m_visibleContentRect(IntRect())
94 , m_hasSuspendedContent(false)
96 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
97 , m_restoredScaleFactor(0)
99 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
100 , m_scrollPositionBeforePageRendered(IntPoint())
103 , m_deferUpdateViewportSize(false)
104 , m_isScrollableLayerFocused(false)
105 , m_isScrollableNodeFocused(false)
106 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
107 , m_shouldMakeBackupTexture(false)
108 , m_shouldShowBackupTexture(false)
110 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
111 , m_isContextMenuVisible(false)
113 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
114 , m_waitFrameOfNewViewortSize(false)
116 , m_nonemptyLayoutRendered(false)
117 #endif // #if OS(TIZEN)
119 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
120 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
121 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
125 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
126 m_textSelection = TextSelection::create(m_viewImpl);
128 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
129 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
131 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
132 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
134 #if ENABLE(TIZEN_DRAG_SUPPORT)
135 m_drag = Drag::create(m_viewImpl);
137 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
138 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
140 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
141 m_viewportAngle = ecore_evas_rotation_get(ee);
144 setBackgroundColor(1, 1, 1, 1);
147 PageClientImpl::~PageClientImpl()
149 if (m_viewImpl && m_viewImpl->page())
150 m_viewImpl->page()->close();
154 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
156 PageClientImpl::ViewportConstraints constraints;
157 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
158 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
159 constraints.userScalable = attributes.userScalable;
160 constraints.layoutSize = attributes.layoutSize;
161 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
163 bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
164 if (autoFittingEnabled)
165 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
167 // if content doesn't set initial scale value, set readable scale factor
168 // if not, set initial scale factor of viewport attribute
169 if (attributes.initialScale == ViewportArguments::ValueAuto)
170 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
172 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
175 // adjust scale with both minimum and maximum scale factor
176 constraints.initialScale = adjustScaleWithViewport(constraints.initialScale);
181 double PageClientImpl::adjustScaleWithViewport(double scale)
183 double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
184 return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale);
187 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
188 void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle)
190 #if ENABLE(TIZEN_DLOG_SUPPORT)
191 TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle);
193 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
194 if (m_deferUpdateViewportSize) {
195 m_visibleContentRect.setSize(viewportSize);
196 m_viewImpl->page()->setViewportSize(viewportSize);
197 m_deferUpdateViewportSize = false;
202 // update viewport size of webkit
203 m_viewImpl->page()->setViewportSize(viewportSize);
206 void PageClientImpl::updateVisibleContentRectSize(const IntSize& size)
208 // update visible content rect's size
209 m_visibleContentRect.setSize(size);
213 void PageClientImpl::prepareRestoredVisibleContectRect()
215 m_restoredScaleFactor = scaleFactor();
216 m_restoredScrollPosition = scrollPosition();
217 #if ENABLE(TIZEN_DLOG_SUPPORT)
218 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
222 void PageClientImpl::initializeVisibleContentRect()
224 _ewk_view_resume_painting(m_viewImpl->view());
226 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
227 IntPoint initialScrollPosition;
228 float initialScaleFactor = m_viewportConstraints.initialScale;
229 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
230 initialScrollPosition = m_scrollPositionBeforePageRendered;
231 m_scrollPositionBeforePageRendered = IntPoint();
233 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
234 // if scroll position and scale factor are restored by history controller,
235 // move scroll position and scale factor with them
236 if (m_restoredScaleFactor) {
237 initialScrollPosition = m_restoredScrollPosition;
238 initialScaleFactor = m_restoredScaleFactor;
240 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
241 m_restoredScaleFactor = 0;
243 #if ENABLE(TIZEN_DLOG_SUPPORT)
244 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", initialScrollPosition.x(), initialScrollPosition.y(), initialScaleFactor);
247 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
249 // Set initial scale.
250 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
254 double PageClientImpl::availableMinimumScale()
256 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
257 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
258 IntSize contentsSize = m_viewImpl->page()->contentsSize();
259 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
260 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
261 // If there's only a bit ignorable difference between horizontalMinScale and verticalMinScale,
262 // ignore verticalMinScale to fit content's width to view
263 const double ignorableThreshold = 0.01;
264 if (fabs(horizontalMinScale - verticalMinScale) < ignorableThreshold)
265 verticalMinScale = horizontalMinScale;
266 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
269 void PageClientImpl::fitViewportToContent()
271 #if ENABLE(TIZEN_DLOG_SUPPORT)
272 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), m_viewportConstraints.minimumScale);
274 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
277 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
279 m_focusedNodeRect = focusedNodeRect;
282 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
283 bool PageClientImpl::scrollBy(IntSize scrollOffset)
285 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
286 // scrollOffset means device screen coordiate, not an actual offset of contents.
287 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
288 // in the actual scale.
289 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
290 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
291 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
297 IntPoint oldScrollPosition = scrollPosition();
298 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
303 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
305 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
307 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
309 #endif // #if OS(TIZEN)
311 EwkViewImpl* PageClientImpl::viewImpl() const
317 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
319 return DrawingAreaProxyImpl::create(m_viewImpl->page());
322 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
325 ewk_view_mark_for_sync(m_viewImpl->view());
327 m_viewImpl->redrawRegion(rect);
331 void PageClientImpl::displayView()
336 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
338 setViewNeedsDisplay(scrollRect);
341 WebCore::IntSize PageClientImpl::viewSize()
343 return m_viewImpl->size();
346 bool PageClientImpl::isViewVisible()
351 return m_viewImpl->isVisible();
355 bool PageClientImpl::isViewInWindow()
361 void PageClientImpl::processDidCrash()
363 // Check if loading was ongoing, when web process crashed.
364 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
365 if (loadProgress >= 0 && loadProgress < 1)
366 m_viewImpl->informLoadProgress(1);
368 m_viewImpl->informWebProcessCrashed();
371 void PageClientImpl::didRelaunchProcess()
373 const char* themePath = m_viewImpl->themePath();
375 m_viewImpl->page()->setThemePath(themePath);
378 void PageClientImpl::pageClosed()
383 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
385 m_viewImpl->informTooltipTextChange(newToolTip);
388 void PageClientImpl::setCursor(const Cursor& cursor)
390 m_viewImpl->setCursor(cursor);
393 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
398 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
400 double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
401 m_viewportConstraints = computeViewportConstraints(attributes);
403 #if ENABLE(TIZEN_GESTURE)
404 m_viewImpl->setDoubleTapEnabled(userScalable());
407 // Initially, m_scaleFactor is not decided yet.
408 // So, we should update visible content rect at here.
409 if (!m_scaleFactor) {
410 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale);
414 // if content is reloaded, contents size will not be changed
415 // so, we need to calculate minimum scale here.
416 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
417 if (m_viewportConstraints.userScalable) {
418 if (fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
419 m_viewportConstraints.initialScale = availableMinimumScale();
420 m_viewportConstraints.minimumScale = availableMinimumScale();
423 #if ENABLE(TIZEN_DLOG_SUPPORT)
424 TIZEN_LOGI("layout size: [%d, %d], scale: [%.2f, %.2f, %.2f], user scalable: [%s]",
425 m_viewportConstraints.layoutSize.width(), m_viewportConstraints.layoutSize.height(),
426 m_viewportConstraints.initialScale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale,
427 m_viewportConstraints.userScalable ? "TRUE" : "FALSE");
430 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
431 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
434 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
435 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
438 float newScale = scaleFactor();
439 IntPoint newScrollPosition = m_visibleContentRect.location();
440 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
441 int angle = ecore_evas_rotation_get(ee);
442 bool isRotated = (angle != m_viewportAngle);
444 // if it's rotated, we need to fit content to viewport by minimize the scale
446 m_viewportAngle = angle;
447 newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
448 if (m_viewportFitsToContent)
449 newScale = m_viewportConstraints.minimumScale;
450 newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
453 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
454 if (m_waitFrameOfNewViewortSize)
455 ewk_view_resume(m_viewImpl->view());
457 #if ENABLE(TIZEN_DLOG_SUPPORT)
458 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated");
461 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
462 setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
464 m_viewImpl->page()->scalePage(newScale, newScrollPosition);
467 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
468 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
469 if (smartData->api->formdata_candidate_is_showing(smartData))
470 smartData->api->formdata_candidate_hide(smartData);
473 #if ENABLE(TIZEN_FULLSCREEN_API)
474 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
475 m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle();
480 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
482 if (undoOrRedo == WebPageProxy::Undo) {
483 m_undoCommands.append(command);
485 int undoSize = m_undoCommands.size();
486 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
489 m_redoCommands.append(command);
491 int redoSize = m_redoCommands.size();
492 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
496 void PageClientImpl::clearAllEditCommands()
498 m_undoCommands.clear();
499 m_redoCommands.clear();
501 int undoSize = m_undoCommands.size();
502 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
504 int redoSize = m_redoCommands.size();
505 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
508 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
510 if (undoOrRedo == WebPageProxy::Undo)
511 return !m_undoCommands.isEmpty();
513 return !m_redoCommands.isEmpty();
516 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
518 if (undoOrRedo == WebPageProxy::Undo) {
519 m_undoCommands.last()->unapply();
520 m_undoCommands.removeLast();
522 int undoSize = m_undoCommands.size();
523 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
525 m_redoCommands.last()->reapply();
526 m_redoCommands.removeLast();
528 int redoSize = m_redoCommands.size();
529 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
533 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
538 void PageClientImpl::clearAllEditCommands()
543 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
549 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
555 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
561 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
567 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
573 IntRect PageClientImpl::windowToScreen(const IntRect&)
579 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
584 #if ENABLE(GESTURE_EVENTS)
585 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
591 #if ENABLE(TOUCH_EVENTS)
592 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
595 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
598 #endif // #if OS(TIZEN)
602 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
604 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
607 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
609 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
610 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
617 #if ENABLE(INPUT_TYPE_COLOR)
618 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
625 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
631 #if USE(ACCELERATED_COMPOSITING)
632 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
634 m_viewImpl->enterAcceleratedCompositingMode();
637 void PageClientImpl::exitAcceleratedCompositingMode()
639 m_viewImpl->exitAcceleratedCompositingMode();
642 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
646 #endif // USE(ACCELERATED_COMPOSITING)
649 void PageClientImpl::initializeAcceleratedCompositingMode()
653 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
654 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
658 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
660 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
662 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
663 m_bgColor.setRGB(rgba);
666 void PageClientImpl::didChangeScrollbarsForMainFrame() const
672 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
674 m_nonemptyLayoutRendered = true;
675 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
676 m_initialViewRect.setSize(viewSize());
680 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
682 #if ENABLE(TIZEN_DLOG_SUPPORT)
683 TIZEN_LOGI(" [%d, %d]", size.width(), size.height());
685 #if USE(TILED_BACKING_STORE)
689 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
690 if (drawingArea()->layerTreeCoordinatorProxy())
691 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
694 // if minimum scale factor is changed, update minimumScale.
695 if (m_viewportConstraints.userScalable) {
696 double minimumScale = availableMinimumScale();
698 // Sometimes initializeVisibleContentRect can be called after content size change.
699 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
700 if (!m_viewportConstraints.contentsDefinedInitialScale
701 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
702 m_viewportConstraints.initialScale = minimumScale;
703 m_viewportConstraints.minimumScale = minimumScale;
706 m_viewImpl->informContentsSizeChange(size);
708 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
711 // FIXME: Do we really need to adjust visible content rect at here?
712 // if contents size is changed smaller and visible content rect is outside of content area,
713 // adjust visible content rect
714 bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect);
715 bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits<float>::epsilon());
716 if (needScrollAdjustment || needScaleAdjustment) {
717 #if ENABLE(TIZEN_DLOG_SUPPORT)
718 TIZEN_LOGI(" setVisibleContentRect: [%d, %d], [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), scaleFactor());
720 setVisibleContentRect(m_visibleContentRect, scaleFactor());
724 void PageClientImpl::pageScaleFactorDidChange()
726 ewk_view_focused_node_adjust(m_viewImpl->view());
728 #endif // #if OS(TIZEN)
730 void PageClientImpl::didCommitLoadForMainFrame(bool)
733 m_pageDidRendered = false;
734 m_viewportFitsToContent = false;
735 m_nonemptyLayoutRendered = false;
741 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
746 double PageClientImpl::customRepresentationZoomFactor()
752 void PageClientImpl::setCustomRepresentationZoomFactor(double)
757 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
762 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
767 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
772 void PageClientImpl::updateTextInputState()
774 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
775 m_textSelection->update();
776 if (isTextSelectionMode() && isTextSelectionHandleDowned())
780 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
781 if (inputMethodContext)
782 inputMethodContext->updateTextInputState();
785 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
787 Ewk_Context* context = m_viewImpl->ewkContext();
788 context->downloadManager()->registerDownload(download, m_viewImpl);
791 #if USE(TILED_BACKING_STORE)
792 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
794 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
795 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
796 if (smartData->api->formdata_candidate_is_showing(smartData))
799 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
800 IntPoint newPoint = point;
801 newPoint.scale(scaleFactor(), scaleFactor());
802 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
803 if (!m_pageDidRendered)
804 m_scrollPositionBeforePageRendered = newPoint;
806 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
808 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
815 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
816 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
818 m_restoredScrollPosition = point;
819 m_restoredScrollPosition.scale(scale, scale);
820 m_restoredScaleFactor = scale;
821 #if ENABLE(TIZEN_DLOG_SUPPORT)
822 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
825 // Before contents size is fixed, just update visible content rect's position
826 m_visibleContentRect.setLocation(m_restoredScrollPosition);
830 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
831 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
833 if (value == m_formDataCandidate->getCandidateValue()) {
834 m_formDataCandidate->updateCandidateValue(emptyString());
838 m_formDataCandidate->updateCandidateValue(value);
839 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
843 void PageClientImpl::updateFormNavigation(int length, int offset)
848 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
849 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
850 DrawingAreaProxy* PageClientImpl::drawingArea() const
852 return m_viewImpl->page()->drawingArea();
856 // Before rendering, scale factor and scroll position is different from m_viewImpl.
857 float PageClientImpl::scaleFactor()
859 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
862 const IntPoint PageClientImpl::scrollPosition()
864 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
867 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
869 IntSize contentsSize = m_viewImpl->page()->contentsSize();
870 contentsSize.scale(targetScale);
871 if (contentsSize.width() < visibleContentRect.width())
872 visibleContentRect.setX(0);
874 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
876 if (contentsSize.height() < visibleContentRect.height())
877 visibleContentRect.setY(0);
879 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
880 return visibleContentRect;
883 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
886 IntPoint previousScrollPosition(scrollPosition());
887 float previousScale = m_scaleFactor;
890 m_scaleFactor = adjustScaleWithViewport(newScale);
891 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
892 m_visibleContentRect.setLocation(newRect.location());
893 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
895 // update both drawing scale factor and scroll position after page is rendered
896 if (m_pageDidRendered) {
897 if (!m_hasSuspendedContent) {
898 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
899 // PageViewport's values are updated when resuming content in the webkit opensource,
900 // but we have to update viewImpl's values here to sync with PageClient's values.
901 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
902 // The values will be updated when resuming content.
903 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
904 m_viewImpl->setScaleFactor(m_scaleFactor);
905 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
909 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
910 // So we removed enclosingIntRect and replaced with floorf and ceilf.
911 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
912 floorf(m_visibleContentRect.y() / m_scaleFactor),
913 ceilf(m_visibleContentRect.width() / m_scaleFactor),
914 ceilf(m_visibleContentRect.height() / m_scaleFactor));
917 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
918 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
919 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
920 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
925 if (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale)
926 m_viewImpl->didChangeScrollAndScale(previousScrollPosition, previousScale);
929 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
930 if (!isClipboardWindowOpened())
931 updateTextSelectionHandlesAndContextMenu(true);
935 void PageClientImpl::displayViewport()
937 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
939 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
944 void PageClientImpl::drawContents()
948 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
951 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
952 cairo_transform(context, &matrix);
955 if (drawingArea()->layerTreeCoordinatorProxy()) {
956 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
957 renderer->paintToGraphicsContext(context, m_bgColor);
961 cairo_restore(context);
964 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
966 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
967 // We don't want to process scaling in the FullScreen mode.
968 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
972 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
973 m_textSelection->hideHandlers();
976 // Adjust scaleFactor.
977 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
978 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
979 scaleFactor = adjustScaleWithViewport(scaleFactor);
981 scaleFactor = adjustScaleWithViewport(scaleFactor);
984 scaleContents(scaleFactor, scrollPosition);
987 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
989 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
990 // We don't want to process scaling in the FullScreen mode.
991 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
994 scaleFactor = adjustScaleWithViewport(scaleFactor);
996 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
999 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1000 // so below code should be replaced when PageViewportController codes are merged.
1001 // Please do not use below codes. They are only for scaling contents.
1002 void PageClientImpl::suspendContent()
1004 if (m_hasSuspendedContent)
1007 m_hasSuspendedContent = true;
1010 void PageClientImpl::resumeContent()
1012 if (!m_hasSuspendedContent)
1015 #if ENABLE(TIZEN_DLOG_SUPPORT)
1016 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_viewImpl->scrollPosition().x(), m_viewImpl->scrollPosition().y(), m_viewImpl->scaleFactor());
1019 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
1020 // The concept is that the values of EwkViewImpl and PageClient can be different
1021 // during suspending content and they become same when content is resumed.
1022 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1023 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
1024 m_hasSuspendedContent = false;
1027 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1029 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1030 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1032 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
1033 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1034 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1036 FloatPoint position;
1037 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1038 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1039 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1044 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1045 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1047 // create if needed.
1048 if (horizontalBar && !m_horizontalScrollbar) {
1049 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
1050 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1051 m_horizontalScrollbar->setFrameRect(hBarRect);
1052 } else if (!horizontalBar && m_horizontalScrollbar)
1053 m_horizontalScrollbar = 0;
1055 if (verticalBar && !m_verticalScrollbar) {
1056 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
1057 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1058 m_verticalScrollbar->setFrameRect(vBarRect);
1059 } else if (!verticalBar && m_verticalScrollbar)
1060 m_verticalScrollbar = 0;
1063 void PageClientImpl::updateScrollbar()
1065 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
1066 scaledContentsSize.scale(scaleFactor());
1068 bool newHasHorizontalScrollbar = false;
1069 bool newVerticalScrollbar = false;
1070 if (viewSize().width() < scaledContentsSize.width())
1071 newHasHorizontalScrollbar = true;
1072 if (viewSize().height() < scaledContentsSize.height())
1073 newVerticalScrollbar = true;
1074 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1076 if (m_horizontalScrollbar) {
1077 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1078 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
1080 if (m_verticalScrollbar) {
1081 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1082 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1086 void PageClientImpl::frameRectChanged()
1088 if (m_horizontalScrollbar) {
1089 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1090 m_horizontalScrollbar->setFrameRect(hBarRect);
1092 if (m_verticalScrollbar) {
1093 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1094 m_verticalScrollbar->setFrameRect(vBarRect);
1098 void PageClientImpl::updateVisibility()
1100 if (m_horizontalScrollbar)
1101 m_horizontalScrollbar->updateVisibility();
1102 if (m_verticalScrollbar)
1103 m_verticalScrollbar->updateVisibility();
1106 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1108 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1109 bool PageClientImpl::isTextSelectionDowned()
1111 return m_textSelection->isTextSelectionDowned();
1114 bool PageClientImpl::isTextSelectionMode()
1116 return m_textSelection->isTextSelectionMode();
1119 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1121 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1124 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1126 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1127 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1130 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point)
1132 if (!evas_object_focus_get(m_viewImpl->view())) {
1133 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1134 if (inputMethodContext)
1135 inputMethodContext->hideIMFContext();
1137 evas_object_focus_set(m_viewImpl->view(), true);
1140 return m_textSelection->textSelectionDown(point);
1143 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point)
1145 m_textSelection->textSelectionMove(point);
1148 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1150 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1153 bool PageClientImpl::isTextSelectionHandleDowned()
1155 return m_textSelection->isTextSelectionHandleDowned();
1158 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1159 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1161 m_textSelection->textSelectionHandleDown(point);
1164 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1166 m_textSelection->textSelectionHandleMove(point);
1169 void PageClientImpl::textSelectonHandleUp()
1171 m_textSelection->textSelectionHandleUp();
1175 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1177 m_textSelection->requestToShow();
1180 void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
1182 m_textSelection->initHandlesMouseDownedStatus();
1185 void PageClientImpl::changeContextMenuPosition(IntPoint& point)
1187 m_textSelection->changeContextMenuPosition(point);
1191 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1192 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1194 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1197 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1199 m_offlinePageSave->saveSubresourcesData(subresourceData);
1202 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1204 m_offlinePageSave->startOfflinePageSave(path, url, title);
1208 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1209 void PageClientImpl::pasteContextMenuSelected()
1211 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1215 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1216 void PageClientImpl::setClipboardData(const String& data, const String& type)
1218 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1219 m_clipboardHelper->setData(data, type);
1223 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1224 void PageClientImpl::clipboardContextMenuSelected()
1226 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1229 bool PageClientImpl::isClipboardWindowOpened()
1231 return m_clipboardHelper->isClipboardWindowOpened();
1234 void PageClientImpl::closeClipboardWindow()
1236 m_clipboardHelper->closeClipboardWindow();
1240 void PageClientImpl::clearClipboardData()
1242 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1243 m_clipboardHelper->clear();
1248 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1249 void PageClientImpl::setIsVisible(bool isVisible)
1251 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1252 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1253 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1254 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1255 int angle = ecore_evas_rotation_get(ee);
1256 if (angle == 0 || angle == 180) {
1257 m_shouldMakeBackupTexture = true;
1258 m_shouldShowBackupTexture = true;
1265 m_isVisible = isVisible;
1267 WebPageProxy* pageProxy = m_viewImpl->page();
1269 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1271 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1273 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1278 #if ENABLE(TIZEN_DRAG_SUPPORT)
1279 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1281 m_drag->setDragPoint(point);
1283 bool PageClientImpl::isDragMode()
1285 return m_drag->isDragMode();
1287 void PageClientImpl::setDragMode(bool isDragMode)
1289 m_drag->setDragMode(isDragMode);
1291 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1293 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1294 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1296 String dragStorageName("Drag");
1297 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1299 m_drag->setDragData(dragInfo, dragImage);
1304 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1305 bool PageClientImpl::isShowingFormDataCandidate()
1307 return m_formDataCandidate->isShowing();
1310 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1312 m_formDataCandidate->updateFormData(data);
1315 void PageClientImpl::hideFormDataCandidate()
1317 m_formDataCandidate->hide();
1320 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1322 m_formDataCandidate->show(rect);
1326 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1327 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1329 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1333 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1334 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1336 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1339 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1341 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1345 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1346 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1348 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1351 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1353 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1356 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1358 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1362 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1363 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1365 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1368 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1370 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1374 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1375 bool PageClientImpl::getStandaloneStatus()
1377 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1381 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1382 bool PageClientImpl::lockOrientation(int willLockOrientation)
1384 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1387 void PageClientImpl::unlockOrientation()
1389 ewk_view_orientation_unlock(m_viewImpl->view());
1393 void PageClientImpl::didRenderFrame()
1395 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1396 if (m_shouldShowBackupTexture && m_isVisible)
1397 m_shouldShowBackupTexture = false;
1399 if (!m_pageDidRendered) {
1400 m_pageDidRendered = true;
1401 initializeVisibleContentRect();
1404 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
1405 if (m_waitFrameOfNewViewortSize) {
1406 m_waitFrameOfNewViewortSize = false;
1407 ewkViewRotatePrepared(m_viewImpl->view());
1412 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1413 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1415 setIsScrollableLayerFocused(false);
1416 setIsScrollableNodeFocused(false);
1420 setIsScrollableLayerFocused(true);
1421 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1423 setIsScrollableNodeFocused(true);
1428 void PageClientImpl::findScrollableNode(const IntPoint& point)
1430 WebPageProxy* pageProxy = m_viewImpl->page();
1431 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1432 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1433 WebLayerID webLayerID = 0;
1434 bool checkOverflowLayer = false;
1435 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1436 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1437 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1439 bool result = pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID);
1440 setOverflowResult(result, webLayerID);
1445 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1447 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1450 #if ENABLE(TIZEN_ICON_DATABASE)
1451 void PageClientImpl::didReceiveIcon()
1453 ewkViewIconReceived(m_viewImpl->view());
1457 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1458 void PageClientImpl::hideFocusRing()
1460 ewkViewFocusRingHide(m_viewImpl->view());
1463 #endif // #if OS(TIZEN)
1466 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1467 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1468 : PageClientImpl(viewImpl)
1474 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1477 , m_isAcceleratedCompositingModeInitialized(false)
1479 initializeAcceleratedCompositingMode();
1482 PageClientEvasGL::~PageClientEvasGL()
1484 if (m_viewImpl && m_viewImpl->page())
1485 m_viewImpl->page()->close();
1488 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
1490 PageClientImpl::updateViewportSize(viewportSize, angle);
1493 void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size)
1496 evas_gl_surface_destroy(m_evasGL, m_surface);
1501 PageClientImpl::updateVisibleContentRectSize(size);
1504 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1506 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1507 if (!isDirectRendering())
1510 m_viewImpl->redrawRegion(rect);
1513 void PageClientEvasGL::displayViewport()
1515 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1516 // We should not draw here when Direct Rendering is enabled.
1517 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1518 if (isDirectRendering())
1519 ewk_view_mark_for_sync(m_viewImpl->view());
1522 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1524 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1529 void PageClientEvasGL::drawContents()
1531 if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()) || !m_isVisible)
1534 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1538 if (!makeContextCurrent())
1541 WebCore::TransformationMatrix matrix;
1543 IntSize ewkViewSize = viewSize();
1545 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1546 if (isDirectRendering()) {
1547 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1548 m_angle = ecore_evas_rotation_get(ee);
1549 renderer->setAngle(m_angle);
1550 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1552 if (m_angle == 90 || m_angle == 270) {
1553 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1555 matrix.translate(-ewkViewSize.width(), 0);
1556 else if (m_angle == 270)
1557 matrix.translate(0, -ewkViewSize.height());
1558 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1560 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1562 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1563 clipRect = IntRect(IntPoint(), ewkViewSize);
1568 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1569 clipRect = IntRect(IntPoint(), ewkViewSize);
1572 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1574 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1575 if (m_shouldMakeBackupTexture) {
1576 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1577 glClearColor(1, 1, 1, 1);
1578 glClear(GL_COLOR_BUFFER_BIT);
1579 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1580 m_shouldMakeBackupTexture = false;
1581 } else if (m_shouldShowBackupTexture) {
1582 matrix.makeIdentity();
1583 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1584 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1587 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1590 void PageClientEvasGL::didRenderFrame()
1592 ewkViewFrameRendered(m_viewImpl->view());
1593 PageClientImpl::didRenderFrame();
1596 bool PageClientEvasGL::makeContextCurrent()
1598 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1601 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1603 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1605 m_config = evas_gl_config_new();
1606 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1607 char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
1608 if (!directRenderingEnv || atoi(directRenderingEnv)) {
1609 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1610 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1613 m_config->color_format = EVAS_GL_RGBA_8888;
1614 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1615 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1617 m_evasGL = evas_gl_new(evas);
1619 evas_gl_config_free(m_config);
1621 TIZEN_LOGE("failed to create evas_gl");
1625 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1627 evas_gl_free(m_evasGL);
1629 evas_gl_config_free(m_config);
1631 TIZEN_LOGE("failed to get evas_gl_api");
1634 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1636 m_context = evas_gl_context_create(m_evasGL, 0);
1638 evas_gl_free(m_evasGL);
1640 evas_gl_config_free(m_config);
1642 TIZEN_LOGE("failed to create evas_gl_context");
1647 m_isAcceleratedCompositingModeInitialized = true;
1650 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1654 evas_gl_surface_destroy(m_evasGL, m_surface);
1658 evas_gl_context_destroy(m_evasGL, m_context);
1662 evas_gl_config_free(m_config);
1665 evas_gl_free(m_evasGL);
1669 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1670 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1672 m_isAcceleratedCompositingModeInitialized = false;
1675 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1677 if (!m_isAcceleratedCompositingModeInitialized)
1678 initializeAcceleratedCompositingMode();
1681 void PageClientEvasGL::exitAcceleratedCompositingMode()
1683 if (m_isAcceleratedCompositingModeInitialized)
1684 finalizeAcceleratedCompositingMode();
1687 void PageClientEvasGL::setTargetSurface()
1693 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1694 if (width == 0 || height == 0)
1697 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1699 TIZEN_LOGE("failed to create Evas_GL_Surface");
1703 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1704 if (isDirectRendering())
1705 makeContextCurrent();
1709 if (makeContextCurrent()) {
1710 glViewport(0, 0, width, height);
1711 glClearColor(1.0, 1.0, 1.0, 1.0);
1712 glClear(GL_COLOR_BUFFER_BIT);
1717 Evas_Native_Surface nativeSurface;
1718 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1719 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1723 } // namespace WebKit