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_isScrollableLayerFocused(false)
108 , m_isScrollableNodeFocused(false)
109 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
110 , m_shouldMakeBackupTexture(false)
111 , m_shouldShowBackupTexture(false)
113 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
114 , m_isContextMenuVisible(false)
116 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
117 , m_waitFrameOfNewViewortSize(false)
119 #if ENABLE(TIZEN_BACKGROUND_DISK_CACHE)
120 , m_isForeground(true)
122 , m_nonemptyLayoutRendered(false)
123 #endif // #if OS(TIZEN)
125 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
126 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
127 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
131 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
132 m_textSelection = TextSelection::create(m_viewImpl);
134 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
135 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
137 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
138 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
140 #if ENABLE(TIZEN_DRAG_SUPPORT)
141 m_drag = Drag::create(m_viewImpl);
143 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
144 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
146 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
147 m_viewportAngle = ecore_evas_rotation_get(ee);
150 setBackgroundColor(1, 1, 1, 1);
153 PageClientImpl::~PageClientImpl()
155 if (m_viewImpl && m_viewImpl->page())
156 m_viewImpl->page()->close();
160 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
162 PageClientImpl::ViewportConstraints constraints;
163 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
164 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
165 constraints.userScalable = attributes.userScalable;
166 constraints.layoutSize = attributes.layoutSize;
167 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
169 bool autoFittingEnabled = m_viewImpl->page()->pageGroup()->preferences()->autoFittingEnabled();
170 if (autoFittingEnabled)
171 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
173 // if content doesn't set initial scale value, set readable scale factor
174 // if not, set initial scale factor of viewport attribute
175 if (attributes.initialScale == ViewportArguments::ValueAuto)
176 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
178 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
181 // adjust scale with both minimum and maximum scale factor
182 constraints.initialScale = adjustScaleWithViewport(constraints.initialScale);
187 double PageClientImpl::adjustScaleWithViewport(double scale)
189 double minimumScale = min(m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
190 return clampTo(scale, minimumScale, m_viewportConstraints.maximumScale);
193 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
194 void PageClientImpl::updateViewportSize(const IntSize& viewportSize, const int angle)
196 #if ENABLE(TIZEN_DLOG_SUPPORT)
197 TIZEN_LOGI(" view size: [%d, %d], angle: [%d]", viewportSize.width(), viewportSize.height(), angle);
200 // update viewport size of webkit
201 m_viewImpl->page()->setViewportSize(viewportSize);
204 void PageClientImpl::updateVisibleContentRectSize(const IntSize& size)
206 // update visible content rect's size
207 m_visibleContentRect.setSize(size);
211 void PageClientImpl::prepareRestoredVisibleContectRect()
213 m_restoredScaleFactor = scaleFactor();
214 m_restoredScrollPosition = scrollPosition();
215 #if ENABLE(TIZEN_DLOG_SUPPORT)
216 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
220 void PageClientImpl::initializeVisibleContentRect()
222 _ewk_view_resume_painting(m_viewImpl->view());
224 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
225 IntPoint initialScrollPosition;
226 float initialScaleFactor = m_viewportConstraints.initialScale;
227 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
228 initialScrollPosition = m_scrollPositionBeforePageRendered;
229 m_scrollPositionBeforePageRendered = IntPoint();
231 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
232 // if scroll position and scale factor are restored by history controller,
233 // move scroll position and scale factor with them
234 if (m_restoredScaleFactor) {
235 initialScrollPosition = m_restoredScrollPosition;
236 initialScaleFactor = m_restoredScaleFactor;
238 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
239 m_restoredScaleFactor = 0;
241 #if ENABLE(TIZEN_DLOG_SUPPORT)
242 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", initialScrollPosition.x(), initialScrollPosition.y(), initialScaleFactor);
245 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
247 // Set initial scale.
248 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
252 double PageClientImpl::availableMinimumScale()
254 // recalculate minimum scale factor if contents' width exceeds viewport layout width and userScalable is true.
255 // minimum scale factor shouldn't be smaller than 0.25(minimum zoom level)
256 IntSize contentsSize = m_viewImpl->page()->contentsSize();
257 double horizontalMinScale = max(((double)viewSize().width() / contentsSize.width()), 0.25);
258 double verticalMinScale = max(((double)viewSize().height() / contentsSize.height()), 0.25);
259 // If there's only a bit ignorable difference between horizontalMinScale and verticalMinScale,
260 // ignore verticalMinScale to fit content's width to view
261 const double ignorableThreshold = 0.01;
262 if (fabs(horizontalMinScale - verticalMinScale) < ignorableThreshold)
263 verticalMinScale = horizontalMinScale;
264 return min(max(horizontalMinScale, verticalMinScale), m_viewportConstraints.maximumScale);
267 void PageClientImpl::fitViewportToContent()
269 #if ENABLE(TIZEN_DLOG_SUPPORT)
270 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), m_viewportConstraints.minimumScale);
272 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.minimumScale);
275 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
277 m_focusedNodeRect = focusedNodeRect;
280 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
281 bool PageClientImpl::scrollBy(IntSize scrollOffset)
283 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
284 // scrollOffset means device screen coordiate, not an actual offset of contents.
285 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
286 // in the actual scale.
287 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
288 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
289 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
295 IntPoint oldScrollPosition = scrollPosition();
296 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
301 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
303 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
305 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
307 #endif // #if OS(TIZEN)
309 EwkViewImpl* PageClientImpl::viewImpl() const
315 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
317 return DrawingAreaProxyImpl::create(m_viewImpl->page());
320 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
323 ewk_view_mark_for_sync(m_viewImpl->view());
325 m_viewImpl->redrawRegion(rect);
328 #if ENABLE(TIZEN_SCREEN_READER)
329 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
330 m_viewImpl->page()->recalcScreenReaderFocusRect();
334 void PageClientImpl::displayView()
339 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
341 setViewNeedsDisplay(scrollRect);
344 WebCore::IntSize PageClientImpl::viewSize()
346 return m_viewImpl->size();
349 bool PageClientImpl::isViewVisible()
354 return m_viewImpl->isVisible();
358 bool PageClientImpl::isViewInWindow()
364 void PageClientImpl::processDidCrash()
366 // Check if loading was ongoing, when web process crashed.
367 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
368 if (loadProgress >= 0 && loadProgress < 1)
369 m_viewImpl->informLoadProgress(1);
371 m_viewImpl->informWebProcessCrashed();
374 void PageClientImpl::didRelaunchProcess()
376 const char* themePath = m_viewImpl->themePath();
378 m_viewImpl->page()->setThemePath(themePath);
381 void PageClientImpl::pageClosed()
386 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
388 m_viewImpl->informTooltipTextChange(newToolTip);
391 void PageClientImpl::setCursor(const Cursor& cursor)
393 m_viewImpl->setCursor(cursor);
396 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
401 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
403 double scaleRatioBeforeRotation = m_scaleFactor / m_viewportConstraints.minimumScale;
404 m_viewportConstraints = computeViewportConstraints(attributes);
406 // Initially, m_scaleFactor is not decided yet.
407 // So, we should update visible content rect at here.
408 if (!m_scaleFactor) {
409 setVisibleContentRect(m_visibleContentRect, m_viewportConstraints.initialScale);
413 // if content is reloaded, contents size will not be changed
414 // so, we need to calculate minimum scale here.
415 // if content size is changed later, minimum scale will be re-calculated on didChangeContentsSize()
416 if (m_viewportConstraints.userScalable) {
417 if (fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
418 m_viewportConstraints.initialScale = availableMinimumScale();
419 m_viewportConstraints.minimumScale = availableMinimumScale();
422 #if ENABLE(TIZEN_DLOG_SUPPORT)
423 TIZEN_LOGI("layout size: [%d, %d], scale: [%.2f, %.2f, %.2f], user scalable: [%s]",
424 m_viewportConstraints.layoutSize.width(), m_viewportConstraints.layoutSize.height(),
425 m_viewportConstraints.initialScale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale,
426 m_viewportConstraints.userScalable ? "TRUE" : "FALSE");
429 // setVisibleContentRect() should be called to adjust visible content rect only when view is resized
430 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
433 // if IME is opened, visible content rect will be updated by ewk_view_focused_node_adjust()
434 if (ewk_view_focused_node_adjust(m_viewImpl->view()))
437 float newScale = scaleFactor();
438 IntPoint newScrollPosition = m_visibleContentRect.location();
439 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
440 int angle = ecore_evas_rotation_get(ee);
441 bool isRotated = (angle != m_viewportAngle);
443 // if it's rotated, we need to fit content to viewport by minimize the scale
445 m_viewportAngle = angle;
446 newScale = m_viewportConstraints.minimumScale * scaleRatioBeforeRotation;
447 newScrollPosition.scale(newScale / m_scaleFactor, newScale / m_scaleFactor);
450 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
451 if (m_waitFrameOfNewViewortSize)
452 ewk_view_resume(m_viewImpl->view());
454 #if ENABLE(TIZEN_DLOG_SUPPORT)
455 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f], rotated: [%s]", m_visibleContentRect.x(), m_visibleContentRect.y(), newScale, isRotated ? "Rotated" : "Not rotated");
458 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
459 setVisibleContentRect(IntRect(newScrollPosition, m_visibleContentRect.size()), newScale);
461 m_viewImpl->page()->scalePage(newScale, newScrollPosition);
464 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
465 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
466 if (smartData->api->formdata_candidate_is_showing(smartData))
467 smartData->api->formdata_candidate_hide(smartData);
470 #if ENABLE(TIZEN_FULLSCREEN_API)
471 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
472 m_viewImpl->page()->fullScreenManager()->updateMediaControlsStyle();
477 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
479 if (undoOrRedo == WebPageProxy::Undo) {
480 m_undoCommands.append(command);
482 int undoSize = m_undoCommands.size();
483 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
486 m_redoCommands.append(command);
488 int redoSize = m_redoCommands.size();
489 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
493 void PageClientImpl::clearAllEditCommands()
495 m_undoCommands.clear();
496 m_redoCommands.clear();
498 int undoSize = m_undoCommands.size();
499 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
501 int redoSize = m_redoCommands.size();
502 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
505 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
507 if (undoOrRedo == WebPageProxy::Undo)
508 return !m_undoCommands.isEmpty();
510 return !m_redoCommands.isEmpty();
513 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
515 if (undoOrRedo == WebPageProxy::Undo) {
516 m_undoCommands.last()->unapply();
517 m_undoCommands.removeLast();
519 int undoSize = m_undoCommands.size();
520 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
522 m_redoCommands.last()->reapply();
523 m_redoCommands.removeLast();
525 int redoSize = m_redoCommands.size();
526 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
530 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
535 void PageClientImpl::clearAllEditCommands()
540 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
546 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
552 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
558 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
564 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
570 IntRect PageClientImpl::windowToScreen(const IntRect&)
576 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
581 #if ENABLE(GESTURE_EVENTS)
582 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
588 #if ENABLE(TOUCH_EVENTS)
589 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
592 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
595 #endif // #if OS(TIZEN)
599 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
601 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
604 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
606 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
607 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
614 #if ENABLE(INPUT_TYPE_COLOR)
615 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
622 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
628 #if USE(ACCELERATED_COMPOSITING)
629 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
631 m_viewImpl->enterAcceleratedCompositingMode();
634 void PageClientImpl::exitAcceleratedCompositingMode()
636 m_viewImpl->exitAcceleratedCompositingMode();
639 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
643 #endif // USE(ACCELERATED_COMPOSITING)
646 void PageClientImpl::initializeAcceleratedCompositingMode()
650 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
651 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
655 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
657 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
659 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
660 m_bgColor.setRGB(rgba);
663 void PageClientImpl::didChangeScrollbarsForMainFrame() const
669 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
671 m_nonemptyLayoutRendered = true;
672 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
673 m_initialViewRect.setSize(viewSize());
677 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
679 #if ENABLE(TIZEN_DLOG_SUPPORT)
680 TIZEN_LOGI(" [%d, %d]", size.width(), size.height());
682 #if USE(TILED_BACKING_STORE)
686 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
687 if (drawingArea()->layerTreeCoordinatorProxy())
688 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
691 // if minimum scale factor is changed, update minimumScale.
692 if (m_viewportConstraints.userScalable) {
693 double minimumScale = availableMinimumScale();
695 // Sometimes initializeVisibleContentRect can be called after content size change.
696 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
697 if (!m_viewportConstraints.contentsDefinedInitialScale
698 && fabs(m_viewportConstraints.initialScale - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon())
699 m_viewportConstraints.initialScale = minimumScale;
700 m_viewportConstraints.minimumScale = minimumScale;
703 m_viewImpl->informContentsSizeChange(size);
705 if (!m_pageDidRendered || m_viewImpl->page()->estimatedProgress() <= 0.1)
708 // FIXME: Do we really need to adjust visible content rect at here?
709 // if contents size is changed smaller and visible content rect is outside of content area,
710 // adjust visible content rect
711 bool needScrollAdjustment = (adjustVisibleContentRect(m_visibleContentRect, scaleFactor()) != m_visibleContentRect);
712 bool needScaleAdjustment = (fabs(adjustScaleWithViewport(scaleFactor()) - scaleFactor()) > numeric_limits<float>::epsilon());
713 if (needScrollAdjustment || needScaleAdjustment) {
714 #if ENABLE(TIZEN_DLOG_SUPPORT)
715 TIZEN_LOGI(" setVisibleContentRect: [%d, %d], [%.2f]", m_visibleContentRect.x(), m_visibleContentRect.y(), scaleFactor());
717 setVisibleContentRect(m_visibleContentRect, scaleFactor());
721 void PageClientImpl::pageScaleFactorDidChange()
723 ewk_view_focused_node_adjust(m_viewImpl->view());
725 #endif // #if OS(TIZEN)
727 void PageClientImpl::didCommitLoadForMainFrame(bool)
730 m_pageDidRendered = false;
731 m_viewportFitsToContent = false;
732 m_nonemptyLayoutRendered = false;
738 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
743 double PageClientImpl::customRepresentationZoomFactor()
749 void PageClientImpl::setCustomRepresentationZoomFactor(double)
754 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
759 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
764 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
769 void PageClientImpl::updateTextInputState()
771 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
772 m_textSelection->update();
773 if (isTextSelectionMode() && isTextSelectionHandleDowned())
777 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
778 if (inputMethodContext)
779 inputMethodContext->updateTextInputState();
782 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
784 Ewk_Context* context = m_viewImpl->ewkContext();
785 context->downloadManager()->registerDownload(download, m_viewImpl);
788 #if USE(TILED_BACKING_STORE)
789 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
791 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
792 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
793 if (smartData->api->formdata_candidate_is_showing(smartData))
796 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
797 IntPoint newPoint = point;
798 newPoint.scale(scaleFactor(), scaleFactor());
799 #if ENABLE(TIZEN_WEBKIT2_BEFORE_PAGE_RENDERED_SCROLL_POSITION)
800 if (!m_pageDidRendered)
801 m_scrollPositionBeforePageRendered = newPoint;
803 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
805 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
812 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
813 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
815 m_restoredScrollPosition = point;
816 m_restoredScrollPosition.scale(scale, scale);
817 m_restoredScaleFactor = scale;
818 #if ENABLE(TIZEN_DLOG_SUPPORT)
819 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_restoredScrollPosition.x(), m_restoredScrollPosition.y(), m_restoredScaleFactor);
822 // Before contents size is fixed, just update visible content rect's position
823 m_visibleContentRect.setLocation(m_restoredScrollPosition);
827 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
828 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
830 if (value == m_formDataCandidate->getCandidateValue()) {
831 m_formDataCandidate->updateCandidateValue(emptyString());
835 m_formDataCandidate->updateCandidateValue(value);
836 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
840 void PageClientImpl::updateFormNavigation(int length, int offset)
845 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
846 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
847 DrawingAreaProxy* PageClientImpl::drawingArea() const
849 return m_viewImpl->page()->drawingArea();
853 // Before rendering, scale factor and scroll position is different from m_viewImpl.
854 float PageClientImpl::scaleFactor()
856 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
859 const IntPoint PageClientImpl::scrollPosition()
861 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
864 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
866 IntSize contentsSize = m_viewImpl->page()->contentsSize();
867 contentsSize.scale(targetScale);
868 if (contentsSize.width() < visibleContentRect.width())
869 visibleContentRect.setX(0);
871 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
873 if (contentsSize.height() < visibleContentRect.height())
874 visibleContentRect.setY(0);
876 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
877 return visibleContentRect;
880 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
882 #if ENABLE(TIZEN_SCREEN_READER)
883 IntPoint previousScrollPosition(scrollPosition());
884 float previousScale = m_scaleFactor;
887 m_scaleFactor = adjustScaleWithViewport(newScale);
888 m_viewportFitsToContent = fabs(m_scaleFactor - m_viewportConstraints.minimumScale) < numeric_limits<float>::epsilon();
889 m_visibleContentRect.setLocation(newRect.location());
890 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
892 // update both drawing scale factor and scroll position after page is rendered
893 if (m_pageDidRendered) {
894 if (!m_hasSuspendedContent) {
895 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
896 // PageViewport's values are updated when resuming content in the webkit opensource,
897 // but we have to update viewImpl's values here to sync with PageClient's values.
898 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
899 // The values will be updated when resuming content.
900 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
901 m_viewImpl->setScaleFactor(m_scaleFactor);
902 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
906 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
907 // So we removed enclosingIntRect and replaced with floorf and ceilf.
908 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
909 floorf(m_visibleContentRect.y() / m_scaleFactor),
910 ceilf(m_visibleContentRect.width() / m_scaleFactor),
911 ceilf(m_visibleContentRect.height() / m_scaleFactor));
914 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, m_scaleFactor, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
915 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
916 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
917 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
921 #if ENABLE(TIZEN_SCREEN_READER)
922 if (ScreenReaderProxy::screenReader().isEnabled()
923 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
924 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
927 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
928 if (!isClipboardWindowOpened())
929 updateTextSelectionHandlesAndContextMenu(true);
933 void PageClientImpl::displayViewport()
935 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
937 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
941 #if ENABLE(TIZEN_SCREEN_READER)
942 m_viewImpl->page()->recalcScreenReaderFocusRect();
946 void PageClientImpl::drawContents()
950 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
953 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
954 cairo_transform(context, &matrix);
957 if (drawingArea()->layerTreeCoordinatorProxy()) {
958 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
959 renderer->paintToGraphicsContext(context, m_bgColor);
963 cairo_restore(context);
966 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
968 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
969 // We don't want to process scaling in the FullScreen mode.
970 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
974 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
975 m_textSelection->hideHandlers();
978 // Adjust scaleFactor.
979 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
980 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
981 scaleFactor = adjustScaleWithViewport(scaleFactor);
983 scaleFactor = adjustScaleWithViewport(scaleFactor);
986 scaleContents(scaleFactor, scrollPosition);
989 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
991 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
992 // We don't want to process scaling in the FullScreen mode.
993 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
996 scaleFactor = adjustScaleWithViewport(scaleFactor);
998 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
1001 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1002 // so below code should be replaced when PageViewportController codes are merged.
1003 // Please do not use below codes. They are only for scaling contents.
1004 void PageClientImpl::suspendContent()
1006 if (m_hasSuspendedContent)
1009 m_hasSuspendedContent = true;
1012 void PageClientImpl::resumeContent()
1014 if (!m_hasSuspendedContent)
1017 #if ENABLE(TIZEN_DLOG_SUPPORT)
1018 TIZEN_LOGI("scroll position: [%d, %d], scale factor: [%.2f]", m_viewImpl->scrollPosition().x(), m_viewImpl->scrollPosition().y(), m_viewImpl->scaleFactor());
1021 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
1022 // The concept is that the values of EwkViewImpl and PageClient can be different
1023 // during suspending content and they become same when content is resumed.
1024 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1025 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
1026 m_hasSuspendedContent = false;
1029 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1031 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1032 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1034 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
1035 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1036 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1038 FloatPoint position;
1039 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1040 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1041 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1046 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1047 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1049 // create if needed.
1050 if (horizontalBar && !m_horizontalScrollbar) {
1051 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
1052 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1053 m_horizontalScrollbar->setFrameRect(hBarRect);
1054 } else if (!horizontalBar && m_horizontalScrollbar)
1055 m_horizontalScrollbar = 0;
1057 if (verticalBar && !m_verticalScrollbar) {
1058 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
1059 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1060 m_verticalScrollbar->setFrameRect(vBarRect);
1061 } else if (!verticalBar && m_verticalScrollbar)
1062 m_verticalScrollbar = 0;
1065 void PageClientImpl::updateScrollbar()
1067 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
1068 scaledContentsSize.scale(scaleFactor());
1070 bool newHasHorizontalScrollbar = false;
1071 bool newVerticalScrollbar = false;
1072 if (viewSize().width() < scaledContentsSize.width())
1073 newHasHorizontalScrollbar = true;
1074 if (viewSize().height() < scaledContentsSize.height())
1075 newVerticalScrollbar = true;
1076 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1078 if (m_horizontalScrollbar) {
1079 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1080 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
1082 if (m_verticalScrollbar) {
1083 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1084 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
1088 void PageClientImpl::frameRectChanged()
1090 if (m_horizontalScrollbar) {
1091 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1092 m_horizontalScrollbar->setFrameRect(hBarRect);
1094 if (m_verticalScrollbar) {
1095 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1096 m_verticalScrollbar->setFrameRect(vBarRect);
1100 void PageClientImpl::updateVisibility()
1102 if (m_horizontalScrollbar)
1103 m_horizontalScrollbar->updateVisibility();
1104 if (m_verticalScrollbar)
1105 m_verticalScrollbar->updateVisibility();
1108 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1110 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1111 bool PageClientImpl::isTextSelectionDowned()
1113 return m_textSelection->isTextSelectionDowned();
1116 bool PageClientImpl::isTextSelectionMode()
1118 return m_textSelection->isTextSelectionMode();
1121 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1123 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1126 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1128 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1129 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1132 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1134 if (!evas_object_focus_get(m_viewImpl->view())) {
1135 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1136 if (inputMethodContext)
1137 inputMethodContext->hideIMFContext();
1139 evas_object_focus_set(m_viewImpl->view(), true);
1142 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1145 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1147 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1150 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1152 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1155 bool PageClientImpl::isTextSelectionHandleDowned()
1157 return m_textSelection->isTextSelectionHandleDowned();
1160 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1161 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1163 m_textSelection->textSelectionHandleDown(point);
1166 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1168 m_textSelection->textSelectionHandleMove(point);
1171 void PageClientImpl::textSelectonHandleUp()
1173 m_textSelection->textSelectionHandleUp();
1177 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1179 m_textSelection->requestToShow();
1182 void PageClientImpl::initTextSelectionHandlesMouseDownedStatus()
1184 m_textSelection->initHandlesMouseDownedStatus();
1187 void PageClientImpl::changeContextMenuPosition(IntPoint& point)
1189 m_textSelection->changeContextMenuPosition(point);
1193 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1194 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1196 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1199 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1201 m_offlinePageSave->saveSubresourcesData(subresourceData);
1204 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1206 m_offlinePageSave->startOfflinePageSave(path, url, title);
1210 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1211 void PageClientImpl::pasteContextMenuSelected()
1213 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1217 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1218 void PageClientImpl::setClipboardData(const String& data, const String& type)
1220 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1221 m_clipboardHelper->setData(data, type);
1225 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1226 void PageClientImpl::clipboardContextMenuSelected()
1228 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1231 bool PageClientImpl::isClipboardWindowOpened()
1233 return m_clipboardHelper->isClipboardWindowOpened();
1236 void PageClientImpl::closeClipboardWindow()
1238 m_clipboardHelper->closeClipboardWindow();
1242 void PageClientImpl::clearClipboardData()
1244 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1245 m_clipboardHelper->clear();
1250 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1251 void PageClientImpl::setIsVisible(bool isVisible)
1253 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1254 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1255 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1256 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1257 int angle = ecore_evas_rotation_get(ee);
1258 if (angle == 0 || angle == 180) {
1259 m_shouldMakeBackupTexture = true;
1260 m_shouldShowBackupTexture = true;
1267 m_isVisible = isVisible;
1269 WebPageProxy* pageProxy = m_viewImpl->page();
1271 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1273 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1275 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1280 #if ENABLE(TIZEN_DRAG_SUPPORT)
1281 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1283 m_drag->setDragPoint(point);
1285 bool PageClientImpl::isDragMode()
1287 return m_drag->isDragMode();
1289 void PageClientImpl::setDragMode(bool isDragMode)
1291 m_drag->setDragMode(isDragMode);
1293 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1295 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1296 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1298 String dragStorageName("Drag");
1299 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1301 m_drag->setDragData(dragInfo);
1306 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1307 bool PageClientImpl::isShowingFormDataCandidate()
1309 return m_formDataCandidate->isShowing();
1312 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1314 m_formDataCandidate->updateFormData(data);
1317 void PageClientImpl::hideFormDataCandidate()
1319 m_formDataCandidate->hide();
1322 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1324 m_formDataCandidate->show(rect);
1328 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1329 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1331 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1335 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1336 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1338 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1341 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1343 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1347 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1348 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1350 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1353 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1355 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1358 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1360 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1364 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1365 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1367 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1370 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1372 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1376 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1377 bool PageClientImpl::getStandaloneStatus()
1379 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1383 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1384 bool PageClientImpl::lockOrientation(int willLockOrientation)
1386 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1389 void PageClientImpl::unlockOrientation()
1391 ewk_view_orientation_unlock(m_viewImpl->view());
1395 void PageClientImpl::didRenderFrame()
1398 if (m_nonemptyLayoutRendered)
1399 ewkViewFrameRendered(m_viewImpl->view());
1402 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1403 if (m_shouldShowBackupTexture && m_isVisible)
1404 m_shouldShowBackupTexture = false;
1406 if (!m_pageDidRendered) {
1407 m_pageDidRendered = true;
1408 initializeVisibleContentRect();
1411 #if ENABLE(TIZEN_PRERENDERING_FOR_ROTATION)
1412 if (m_waitFrameOfNewViewortSize) {
1413 m_waitFrameOfNewViewortSize = false;
1414 ewkViewRotatePrepared(m_viewImpl->view());
1419 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1420 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1422 setIsScrollableLayerFocused(false);
1423 setIsScrollableNodeFocused(false);
1427 setIsScrollableLayerFocused(true);
1428 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1430 setIsScrollableNodeFocused(true);
1435 void PageClientImpl::findScrollableNode(const IntPoint& point)
1437 WebPageProxy* pageProxy = m_viewImpl->page();
1438 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1439 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1440 WebLayerID webLayerID = 0;
1441 bool checkOverflowLayer = false;
1442 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1443 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1444 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1446 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1451 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1453 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1456 #if ENABLE(TIZEN_ICON_DATABASE)
1457 void PageClientImpl::didReceiveIcon()
1459 ewkViewIconReceived(m_viewImpl->view());
1463 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1464 void PageClientImpl::hideFocusRing()
1466 ewkViewFocusRingHide(m_viewImpl->view());
1469 #endif // #if OS(TIZEN)
1472 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1473 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1474 : PageClientImpl(viewImpl)
1480 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1483 , m_isAcceleratedCompositingModeInitialized(false)
1485 initializeAcceleratedCompositingMode();
1488 PageClientEvasGL::~PageClientEvasGL()
1490 if (m_viewImpl && m_viewImpl->page())
1491 m_viewImpl->page()->close();
1494 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize, const int angle)
1496 PageClientImpl::updateViewportSize(viewportSize, angle);
1499 void PageClientEvasGL::updateVisibleContentRectSize(const WebCore::IntSize& size)
1502 evas_gl_surface_destroy(m_evasGL, m_surface);
1507 PageClientImpl::updateVisibleContentRectSize(size);
1510 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1512 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1513 if (!isDirectRendering())
1516 m_viewImpl->redrawRegion(rect);
1518 #if ENABLE(TIZEN_SCREEN_READER)
1519 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1520 m_viewImpl->page()->recalcScreenReaderFocusRect();
1524 void PageClientEvasGL::displayViewport()
1526 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1527 // We should not draw here when Direct Rendering is enabled.
1528 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1529 if (isDirectRendering())
1530 ewk_view_mark_for_sync(m_viewImpl->view());
1533 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1535 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1539 #if ENABLE(TIZEN_SCREEN_READER)
1540 m_viewImpl->page()->recalcScreenReaderFocusRect();
1544 void PageClientEvasGL::drawContents()
1546 if (!drawingArea() || !(drawingArea()->layerTreeCoordinatorProxy()))
1549 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1553 if (!makeContextCurrent())
1556 WebCore::TransformationMatrix matrix;
1558 IntSize ewkViewSize = viewSize();
1560 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1561 if (isDirectRendering()) {
1562 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1563 m_angle = ecore_evas_rotation_get(ee);
1564 renderer->setAngle(m_angle);
1565 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1567 if (m_angle == 90 || m_angle == 270) {
1568 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1570 matrix.translate(-ewkViewSize.width(), 0);
1571 else if (m_angle == 270)
1572 matrix.translate(0, -ewkViewSize.height());
1573 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1575 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1577 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1578 clipRect = IntRect(IntPoint(), ewkViewSize);
1583 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1584 clipRect = IntRect(IntPoint(), ewkViewSize);
1587 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1589 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1590 if (m_shouldMakeBackupTexture) {
1591 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1592 glClearColor(1, 1, 1, 1);
1593 glClear(GL_COLOR_BUFFER_BIT);
1594 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1595 m_shouldMakeBackupTexture = false;
1596 } else if (m_shouldShowBackupTexture) {
1597 matrix.makeIdentity();
1598 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1599 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1602 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1605 void PageClientEvasGL::didRenderFrame()
1607 PageClientImpl::didRenderFrame();
1610 bool PageClientEvasGL::makeContextCurrent()
1612 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1615 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1617 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1619 m_config = evas_gl_config_new();
1620 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1621 char* directRenderingEnv = getenv("TIZEN_WEBKIT_DIRECT_RENDERING");
1622 if (!directRenderingEnv || atoi(directRenderingEnv)) {
1623 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1624 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1627 m_config->color_format = EVAS_GL_RGBA_8888;
1628 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1629 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1631 m_evasGL = evas_gl_new(evas);
1633 evas_gl_config_free(m_config);
1635 TIZEN_LOGE("failed to create evas_gl");
1639 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1641 evas_gl_free(m_evasGL);
1643 evas_gl_config_free(m_config);
1645 TIZEN_LOGE("failed to get evas_gl_api");
1648 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1650 m_context = evas_gl_context_create(m_evasGL, 0);
1652 evas_gl_free(m_evasGL);
1654 evas_gl_config_free(m_config);
1656 TIZEN_LOGE("failed to create evas_gl_context");
1661 m_isAcceleratedCompositingModeInitialized = true;
1664 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1668 evas_gl_surface_destroy(m_evasGL, m_surface);
1672 evas_gl_context_destroy(m_evasGL, m_context);
1676 evas_gl_config_free(m_config);
1679 evas_gl_free(m_evasGL);
1683 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1684 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1686 m_isAcceleratedCompositingModeInitialized = false;
1689 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1691 if (!m_isAcceleratedCompositingModeInitialized)
1692 initializeAcceleratedCompositingMode();
1695 void PageClientEvasGL::exitAcceleratedCompositingMode()
1697 if (m_isAcceleratedCompositingModeInitialized)
1698 finalizeAcceleratedCompositingMode();
1701 void PageClientEvasGL::setTargetSurface()
1707 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1708 if (width == 0 || height == 0)
1711 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1713 TIZEN_LOGE("failed to create Evas_GL_Surface");
1717 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1718 if (isDirectRendering())
1719 makeContextCurrent();
1723 if (makeContextCurrent()) {
1724 glViewport(0, 0, width, height);
1725 glClearColor(1.0, 1.0, 1.0, 1.0);
1726 glClear(GL_COLOR_BUFFER_BIT);
1731 Evas_Native_Surface nativeSurface;
1732 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1733 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1737 } // namespace WebKit