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 "NativeWebKeyboardEvent.h"
31 #include "NotImplemented.h"
32 #include "TransformationMatrix.h"
33 #include "WebContext.h"
34 #include "WebContextMenuProxy.h"
35 #include "WebPageProxy.h"
36 #include "ewk_context.h"
37 #include "ewk_context_private.h"
38 #include "ewk_download_job.h"
39 #include "ewk_download_job_private.h"
40 #include "ewk_view_private.h"
43 #include "DrawingAreaProxyImpl.h"
45 #include "EflScreenUtilities.h"
46 #include "LayerTreeCoordinatorProxy.h"
47 #include "OpenGLShims.h"
48 #include "WebContextMenuProxyTizen.h"
49 #include "WebLayerTreeRenderer.h"
50 #include "WebPageGroup.h"
51 #include "WebPageMessages.h"
52 #include "WebPopupMenuProxyTizen.h"
53 #include "WebPreferences.h"
55 #include <Ecore_Evas.h>
58 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
59 #include "MainFrameScrollbarTizen.h"
62 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
63 #include "ClipboardHelper.h"
66 #if ENABLE(TIZEN_DRAG_SUPPORT)
71 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
72 #include "ewk_context_private.h"
75 using namespace WebCore;
80 PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
81 : m_viewWidget(viewWidget)
83 , m_viewportConstraints()
84 , m_viewFocused(false)
85 , m_viewWindowActive(true)
86 , m_pageDidRendered(false)
87 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
88 , m_visibleContentRect(IntRect())
90 , m_visibleContentRectForDrawContents(IntRect())
91 , m_scaleFactorForDrawContents(1.0f)
93 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
94 , m_didRestoreVisibleContentRect(false)
97 , m_isScrollableLayerFocused(false)
98 , m_isScrollableNodeFocused(false)
99 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
100 , m_shouldMakeBackupTexture(false)
101 , m_shouldShowBackupTexture(false)
103 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
104 , m_isContextMenuVisible(false)
106 #endif // #if OS(TIZEN)
108 #if ENABLE(TIZEN_WEBKIT2) && ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
109 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
110 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
112 m_page = context->createWebPage(this, pageGroup);
115 m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
116 m_page->pageGroup()->preferences()->setForceCompositingMode(true);
117 m_page->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
118 m_page->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
121 int deviceWidth, deviceHeight;
122 ecore_evas_screen_geometry_get(ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget)), 0, 0, &deviceWidth, &deviceHeight);
123 m_page->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
124 m_page->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
129 m_page->initializeWebPage();
131 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
132 m_page->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
134 m_page->setCustomDeviceScaleFactor((float)getDPI() / 160);
138 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
139 m_textSelection = TextSelection::create(viewWidget, m_page.get(), this);
141 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
142 m_clipboardHelper = ClipboardHelper::create(viewWidget, this);
144 #if ENABLE(TIZEN_DRAG_SUPPORT)
145 m_drag = Drag::create(m_page.get());
149 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
150 m_page->setUseFixedLayout(true);
152 #if ENABLE(FULLSCREEN_API)
153 m_page->fullScreenManager()->setWebView(viewWidget);
156 setBackgroundColor(1, 1, 1, 1);
159 m_viewImpl = EwkViewImpl::fromEvasObject(m_viewWidget);
163 PageClientImpl::~PageClientImpl()
169 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
171 PageClientImpl::ViewportConstraints constraints;
172 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
173 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
174 constraints.userScalable = attributes.userScalable;
175 constraints.layoutSize = attributes.layoutSize;
177 double defaultViewLevel = m_page->pageGroup()->preferences()->defaultViewLevel();
178 // If defaultViewLevel is 1, "Default View" is set as "Readable"
179 // if not, "Default View" is set as "Fit to width"
180 if (defaultViewLevel) {
181 // if content doesn't set initial scale value, set readable scale factor
182 // if not, set initial scale factor of viewport attribute
183 if (attributes.initialScale == ViewportArguments::ValueAuto)
184 constraints.initialScale = m_page->deviceScaleFactor();
186 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
188 // Minimize initial scale factor
189 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
192 // adjust scale with both minimum and maximum scale factor
193 if (constraints.initialScale < constraints.minimumScale)
194 constraints.initialScale = constraints.minimumScale;
195 if (constraints.initialScale > constraints.maximumScale)
196 constraints.initialScale = constraints.maximumScale;
200 double PageClientImpl::adjustScaleWithViewport(double scale)
202 if (scale < m_viewportConstraints.minimumScale)
203 scale = m_viewportConstraints.minimumScale;
204 if (scale > m_viewportConstraints.maximumScale)
205 scale = m_viewportConstraints.maximumScale;
209 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
210 void PageClientImpl::updateViewportSize(const IntSize& viewportSize)
212 // update device width & height
213 int deviceWidth = WebCore::getDefaultScreenResolution().width();
214 int deviceHeight = WebCore::getDefaultScreenResolution().height();
215 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
216 int angle = ecore_evas_rotation_get(ee);
217 if (angle == 90 || angle == 270) {
218 int tempWidth = deviceWidth;
219 deviceWidth = deviceHeight;
220 deviceHeight = tempWidth;
222 m_page->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
223 m_page->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
225 m_visibleContentRectForDrawContents.setSize(viewSize());
226 if (m_visibleContentRect.size() == viewportSize) {
227 // We should call setVisibleContentRect() explicitly,
228 // because visible content rect can be exceeded over contents size by resized visibleContentRect by hidden IME
229 setVisibleContentRect(m_visibleContentRectForDrawContents, scaleFactor());
233 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
235 // Resize by IME operations of webkit.
236 // Imfconext is null, when the operation is not caused by webkit
237 if (imfContext && !(m_clipboardHelper && m_clipboardHelper->isClipboardWindowOpened())) {
238 // For webkit IME operaions viewport size can change in below cases
239 // 1)viewport size is changed when IME is hidden
240 // 2)viewport height is larger than before
241 Ecore_IMF_Input_Panel_State imeState = ecore_imf_context_input_panel_state_get(imfContext);
242 if ((imeState == ECORE_IMF_INPUT_PANEL_STATE_HIDE && m_visibleContentRect.size() != viewportSize)
243 || (imeState != ECORE_IMF_INPUT_PANEL_STATE_HIDE && m_visibleContentRect.height() < viewportSize.height())) {
244 m_visibleContentRect.setSize(viewportSize);
245 m_page->setViewportSize(viewportSize);
249 // Viewport width is changed, resize by rotate or app tile's resize
250 if (m_visibleContentRect.width() != viewportSize.width()) {
251 m_visibleContentRect.setSize(viewportSize);
252 m_page->setViewportSize(viewportSize);
255 // Input field zoom if viewport size is not changed
256 if (!ewk_view_focused_node_adjust(m_viewWidget))
257 setVisibleContentRect(m_visibleContentRectForDrawContents, scaleFactor());
261 void PageClientImpl::initializeVisibleContentRect()
263 _ewk_view_resume_painting(m_viewWidget);
265 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
266 // Call setVisibleContentRect() with current scroll position.
267 // Because scroll position can be changed by HistoryController when we go back and foward
268 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
269 if (m_didRestoreVisibleContentRect)
270 setVisibleContentRect(m_visibleContentRect, scaleFactor());
272 setVisibleContentRect(IntRect(IntPoint(), viewSize()), m_viewportConstraints.initialScale);
274 if (!m_didRestoreVisibleContentRect)
275 setVisibleContentRect(IntRect(IntPoint(), viewSize()), m_viewportConstraints.initialScale);
278 // Set initial scale.
279 m_page->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
281 #if !ENABLE(TIZEN_WEBKIT2_TILED_AC)
282 m_scaleFactorForDrawContents = m_scaleFactor;
286 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
288 m_focusedNodeRect = focusedNodeRect;
291 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
292 bool PageClientImpl::scrollBy(IntSize scrollOffset)
294 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
295 // scrollOffset means device screen coordiate, not an actual offset of contents.
296 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
297 // in the actual scale.
298 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
299 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
300 && page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
306 IntPoint oldScrollPosition = scrollPosition();
307 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, viewSize()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
308 IntPoint newScrollPosition = scrollPosition();
309 if (oldScrollPosition != newScrollPosition)
315 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
317 IntPoint oldScrollPosition = scrollPosition();
318 setVisibleContentRect(IntRect(requestedScrollPosition, viewSize()), scaleFactor());
319 IntPoint newScrollPosition = scrollPosition();
321 if (oldScrollPosition != newScrollPosition)
324 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
326 #endif // #if OS(TIZEN)
329 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
331 return DrawingAreaProxyImpl::create(m_page.get());
334 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
336 ewk_view_mark_for_sync(m_viewWidget);
339 void PageClientImpl::displayView()
344 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
346 setViewNeedsDisplay(scrollRect);
349 WebCore::IntSize PageClientImpl::viewSize()
351 return ewk_view_size_get(m_viewWidget);
354 bool PageClientImpl::isViewVisible()
359 bool PageClientImpl::isViewInWindow()
365 void PageClientImpl::processDidCrash()
370 void PageClientImpl::didRelaunchProcess()
372 const char* themePath = ewk_view_theme_get(m_viewWidget);
374 ewk_view_page_get(m_viewWidget)->setThemePath(themePath);
377 void PageClientImpl::pageClosed()
382 void PageClientImpl::toolTipChanged(const String&, const String&)
387 void PageClientImpl::setCursor(const Cursor& cursor)
389 ewk_view_cursor_set(m_viewWidget, cursor);
392 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
397 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
399 float prevMinimumScale = m_viewportConstraints.minimumScale;
400 m_viewportConstraints = computeViewportConstraints(attributes);
401 // setVisibleContentRect() is called to adjust visible content rect after device rotation
402 // In below cases, it shouldn't be called
403 // 1. page is not rendered yet
404 // 2. viewport attributes are changed by WebCore's empty document(progress == 0.1)
405 // 3. there's no input field zoom(device rotation without IME)
406 if (m_pageDidRendered && page()->estimatedProgress() > 0.1 && !ewk_view_focused_node_adjust(m_viewWidget)) {
407 float newScale = scaleFactor();
408 // If zoom was fitted to width before the rotation, newScale should be fitted to width again.
409 if (fabs(scaleFactor() - prevMinimumScale) < numeric_limits<double>::epsilon())
410 newScale = m_viewportConstraints.minimumScale;
411 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
412 setVisibleContentRect(IntRect(m_visibleContentRect.location(), viewSize()), newScale);
414 m_page->scalePage(newScale, m_visibleContentRect.location());
418 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
419 updateTextSelectionHandlesAndContextMenu(true);
424 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
426 if (undoOrRedo == WebPageProxy::Undo)
427 m_undoCommands.append(command);
429 m_redoCommands.append(command);
432 void PageClientImpl::clearAllEditCommands()
434 m_undoCommands.clear();
435 m_redoCommands.clear();
438 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
440 if (undoOrRedo == WebPageProxy::Undo)
441 return !m_undoCommands.isEmpty();
443 return !m_redoCommands.isEmpty();
446 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
448 if (undoOrRedo == WebPageProxy::Undo) {
449 m_undoCommands.last()->unapply();
450 m_undoCommands.removeLast();
452 m_redoCommands.last()->reapply();
453 m_redoCommands.removeLast();
457 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
462 void PageClientImpl::clearAllEditCommands()
467 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
473 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
479 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
485 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
491 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
497 IntRect PageClientImpl::windowToScreen(const IntRect&)
503 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
508 #if ENABLE(GESTURE_EVENTS)
509 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
515 #if ENABLE(TOUCH_EVENTS)
516 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
519 ewk_view_touch_event_handler_result_set(m_viewWidget, event.type(), wasEventHandled);
522 #endif // #if OS(TIZEN)
526 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
528 #if ENABLE(TIZEN_WEBKIT2_POPUP)
529 return WebPopupMenuProxyTizen::create(m_viewWidget, page);
533 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
535 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
536 return WebContextMenuProxyTizen::create(m_viewWidget, page, this);
543 #if ENABLE(INPUT_TYPE_COLOR)
544 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
551 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
557 #if USE(ACCELERATED_COMPOSITING)
558 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
560 ewk_view_accelerated_compositing_mode_enter(m_viewWidget);
563 void PageClientImpl::exitAcceleratedCompositingMode()
565 ewk_view_accelerated_compositing_mode_exit(m_viewWidget);
568 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
572 #endif // USE(ACCELERATED_COMPOSITING)
575 void PageClientImpl::initializeAcceleratedCompositingMode()
579 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
580 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
584 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
586 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
588 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
589 m_bgColor.setRGB(rgba);
592 void PageClientImpl::didChangeScrollbarsForMainFrame() const
598 void PageClientImpl::didStartProgress()
603 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
605 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
606 m_initialViewRect.setSize(viewSize());
610 void PageClientImpl::didFinishLoadForMainFrame()
615 void PageClientImpl::didFinishProgress()
620 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
625 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
626 IntSize scaledSize = size;
627 scaledSize.scale(scaleFactor());
629 if (m_horizontalScrollbar)
630 m_horizontalScrollbar->setProportion(viewSize().width(), scaledSize.width());
631 if (m_verticalScrollbar)
632 m_verticalScrollbar->setProportion(viewSize().height(), scaledSize.height());
635 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
636 if (drawingArea()->layerTreeCoordinatorProxy())
637 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
640 // FIXME: Currently minimum scale is recalculated by contents' width
641 // if contents' width exceeds viewport layout width and userScalable is true.
642 // But we should recalculate this when viewport argument's minimum scale is not fixed.
643 // And minimumScaleByContentWidth shouldn't be smaller than 0.25(minimum zoom level)
644 double previousMinimumScale = m_viewportConstraints.minimumScale;
645 double minimumScaleByContentWidth = max(((double)viewSize().width() / size.width()), 0.25);
646 double defaultViewLevel = m_page->pageGroup()->preferences()->defaultViewLevel();
648 // If contents width exceeds viewport layout width and content is userScalable,
649 // update minimumScale.
650 if (m_viewportConstraints.userScalable) {
651 m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
653 // Sometimes initializeVisibleContentRect can be called after content size change.
654 // So, if initialScale is same to minimumScale, update initialScale too.
655 if (fabs(m_viewportConstraints.initialScale - previousMinimumScale) < numeric_limits<float>::epsilon())
656 m_viewportConstraints.initialScale = minimumScaleByContentWidth;
659 // If current scale factor was minimized, minimize new scale factor
660 double newScaleFactor = scaleFactor();
661 if (fabs(scaleFactor() - previousMinimumScale) < numeric_limits<float>::epsilon()
662 && m_viewportConstraints.userScalable && !defaultViewLevel && m_pageDidRendered) {
663 newScaleFactor = m_viewportConstraints.minimumScale;
665 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
666 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
667 if (!m_didRestoreVisibleContentRect)
668 setVisibleContentRect(IntRect(m_visibleContentRect.location(), viewSize()), newScaleFactor);
670 setVisibleContentRect(IntRect(m_visibleContentRect.location(), viewSize()), newScaleFactor);
673 m_page->scalePage(newScaleFactor, m_visibleContentRect.location());
677 // FIXME: If content's size is changed after calling setVisibleContentRect(),
678 // we should call it again to adjust visible content rect.
679 IntRect rect = m_visibleContentRect;
680 adjustVisibleContentRect(rect, scaleFactor());
681 if (m_pageDidRendered && rect != m_visibleContentRect)
682 setVisibleContentRect(IntRect(m_visibleContentRect.location(), viewSize()), newScaleFactor);
684 // After contents size is changed, update scroll bar.
688 void PageClientImpl::setRequestedScaleFactor(double scale)
690 m_requestedScaleFactor = scale;
693 void PageClientImpl::pageScaleFactorDidChange()
695 ewk_view_focused_node_adjust(m_viewWidget);
698 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
699 void PageClientImpl::cancelTouchEvent()
701 ewkViewHandleTouchEvent(m_viewWidget, EWK_TOUCH_CANCEL);
704 #endif // #if OS(TIZEN)
706 void PageClientImpl::didCommitLoadForMainFrame(bool)
709 m_pageDidRendered = false;
710 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
711 m_didRestoreVisibleContentRect = false;
718 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
723 double PageClientImpl::customRepresentationZoomFactor()
729 void PageClientImpl::setCustomRepresentationZoomFactor(double)
734 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
739 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
744 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
749 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
751 Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget);
752 // For now we only support one default context, but once we support
753 // multiple contexts, we will need to retrieve the context from the
755 ewk_context_download_job_add(ewk_context_default_get(), ewkDownload);
756 ewk_download_job_unref(ewkDownload);
759 #if USE(TILED_BACKING_STORE)
760 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
762 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
763 // If requested point is same to current point, ignore this.
764 IntPoint currentPoint(m_visibleContentRect.location().x() / scaleFactor(), m_visibleContentRect.location().y() / scaleFactor());
765 if (point == currentPoint)
768 IntPoint newPoint = point;
769 newPoint.scale(scaleFactor(), scaleFactor());
770 setVisibleContentRect(IntRect(newPoint, viewSize()), scaleFactor());
773 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
780 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
781 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
783 IntPoint scaledPoint = point;
784 scaledPoint.scale(scale, scale);
785 setVisibleContentRect(IntRect(scaledPoint, viewSize()), scale);
786 m_didRestoreVisibleContentRect = true;
790 #if ENABLE(TIZEN_ISF_PORT)
791 void PageClientImpl::updateTextInputState()
793 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
794 m_textSelection->update();
799 #if ENABLE(TIZEN_ISF_PORT)
800 void PageClientImpl::setInputMethodState(bool active, const String& type, const String& value)
803 ewk_view_imf_context_hide(m_viewWidget);
804 LOG(ISF, "- Keypad status : hide\n");
808 Ewk_Settings* settings = ewk_view_settings_get(m_viewWidget);
809 bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
811 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
812 if (m_clipboardHelper->isClipboardWindowOpened()) {
813 LOG(ISF, "[FAIL] Clipboard\n");
818 LOG(ISF, "- Type (%s), Value (%s)\n", type.utf8().data(), value.utf8().data());
820 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
821 if (type == "date") {
822 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATE, value);
824 } else if (type == "datetime") {
825 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIME, value);
827 } else if (type == "datetime-local") {
828 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIMELOCAL, value);
830 } else if (type == "month") {
831 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_MONTH, value);
833 } else if (type == "time") {
834 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_TIME, value);
836 } else if (type == "week") {
837 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_WEEK, value);
841 #if ENABLE(TIZEN_DATALIST_ELEMENT)
842 Vector<String> optionList = page()->getFocusedInputElementDataList();
843 if (optionList.size() > 0) {
845 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TELEPHONE, optionList);
846 else if (type == "number")
847 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_NUMBER, optionList);
848 else if (type == "email")
849 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_EMAIL, optionList);
850 else if (type == "url")
851 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_URL, optionList);
853 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TEXT, optionList);
857 #endif // ENABLE(TIZEN_DATALIST_ELEMENT)
858 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
860 bool hasFocus = evas_object_focus_get(m_viewWidget);
862 if (!defaultKeypadEnabled) {
863 ewk_view_imf_context_destroy(m_viewWidget);
865 Eina_Rectangle dummyRectForCustomKeypadCallback;
866 memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle));
867 evas_object_smart_callback_call(m_viewWidget, "inputmethod,changed", &dummyRectForCustomKeypadCallback);
872 Ecore_IMF_Input_Panel_Layout layout;
873 if (type == "number")
874 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
875 else if (type == "email")
876 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
877 else if (type == "url")
878 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
879 else if (type == "tel")
880 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
881 else if (type == "password")
882 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
884 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
886 Ecore_IMF_Context* imfContext = ewk_view_imf_context_set(m_viewWidget, layout);
890 if (type == "password")
891 ecore_imf_context_prediction_allow_set(imfContext, false);
893 ecore_imf_context_prediction_allow_set(imfContext, true);
895 if (type.isEmpty() || type == "textarea")
896 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE);
898 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
900 Evas* evas = evas_object_evas_get(m_viewWidget);
901 ecore_imf_context_client_window_set(imfContext, (void*)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas)));
902 ecore_imf_context_client_canvas_set(imfContext, evas);
907 ecore_imf_context_focus_in(imfContext);
908 ecore_imf_context_input_panel_show(imfContext);
911 // input field zoom for external keyboard
912 ewk_view_focused_node_adjust(m_viewWidget, EINA_TRUE);
914 LOG(ISF, "- Keypad status : show\n");
917 void PageClientImpl::setInputMethodState(bool active)
920 #endif // #if ENABLE(TIZEN_ISF_PORT)
922 #if ENABLE(TIZEN_ISF_PORT)
923 void PageClientImpl::setCursorPosition(int preeditPosition)
925 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
929 int offset = page()->getCursorOffsetPosition();
930 ecore_imf_context_cursor_position_set(imfContext, offset);
931 LOG(ISF, "Cursor position : offset %d + preeditPosition %d\n", offset, preeditPosition);
934 void PageClientImpl::imContextCommitted(Ecore_IMF_Context* context, char* event)
936 LOG(ISF, "%s\n", __func__);
938 if (!page()->focusedFrame() || !event)
941 page()->confirmComposition(String::fromUTF8(event));
942 LOG(ISF, "confirmComposition : (%s)\n", event);
947 void PageClientImpl::imContextPreeditChanged(Ecore_IMF_Context* context)
949 LOG(ISF, "%s\n", __func__);
951 if (!page()->focusedFrame())
954 char* preeditStr = 0;
955 int cursorPosition = 0;
957 ecore_imf_context_preedit_string_get(context, &preeditStr, &cursorPosition);
961 if (!cursorPosition) {
966 IntRect caretRect(0, 0, 0, 0);
967 page()->getCaretPosition(caretRect);
968 caretRect.scale(scaleFactor());
971 evas_object_geometry_get(m_viewWidget, &viewX, &viewY, 0, 0);
973 int x = caretRect.x() - scrollPosition().x() + viewX;
974 int y = caretRect.y() - scrollPosition().y() + viewY;
975 int w = caretRect.width();
976 int h = caretRect.height();
977 ecore_imf_context_cursor_location_set(context, x, y, w, h);
979 int offset = page()->getCursorOffsetPosition();
981 String preeditString = String::fromUTF8(preeditStr);
984 Vector<CompositionUnderline> underlines;
985 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
986 page()->setComposition(preeditString, underlines, offset + cursorPosition);
987 LOG(ISF, "setComposition : %s\n", preeditStr);
989 setCursorPosition(cursorPosition);
991 #endif // #if ENABLE(TIZEN_ISF_PORT)
993 void PageClientImpl::updateFormNavigation(int length, int offset)
998 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
999 void PageClientImpl::adjustVisibleContentRect(IntRect& visibleContentRect, float targetScale)
1001 IntSize contentsSize = page()->contentsSize();
1002 contentsSize.scale(targetScale);
1003 if (visibleContentRect.x() > contentsSize.width() - visibleContentRect.width())
1004 visibleContentRect.setX(contentsSize.width() - visibleContentRect.width());
1005 if (visibleContentRect.x() < 0)
1006 visibleContentRect.setX(0);
1007 if (visibleContentRect.y() > contentsSize.height() - visibleContentRect.height())
1008 visibleContentRect.setY(contentsSize.height() - visibleContentRect.height());
1009 if (visibleContentRect.y() < 0)
1010 visibleContentRect.setY(0);
1013 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
1015 newScale = adjustScaleWithViewport(newScale);
1016 if (fabs(m_scaleFactor - newScale) >= numeric_limits<double>::epsilon()) {
1017 m_scaleFactor = newScale;
1018 if (m_pageDidRendered)
1019 m_scaleFactorForDrawContents = m_scaleFactor;
1020 m_viewImpl->setScaleFactor(newScale);
1023 if (m_pageDidRendered) {
1024 m_visibleContentRectForDrawContents = newRect;
1025 adjustVisibleContentRect(m_visibleContentRectForDrawContents, newScale);
1026 m_viewImpl->setScrollPosition(m_visibleContentRectForDrawContents.location());
1028 m_visibleContentRect.setLocation(m_visibleContentRectForDrawContents.location());
1030 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
1031 // So we removed enclosingIntRect and replaced with floorf and ceilf.
1032 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / newScale),
1033 floorf(m_visibleContentRect.y() / newScale),
1034 ceilf(m_visibleContentRect.width() / newScale),
1035 ceilf(m_visibleContentRect.height() / newScale));
1040 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_visibleContentRectForDrawContents.location()));
1041 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1042 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
1043 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
1045 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1050 void PageClientImpl::displayViewport()
1052 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1054 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1059 void PageClientImpl::drawContents()
1063 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
1065 m_visibleContentRectForDrawContents.setSize(viewSize());
1067 cairo_save(context);
1068 cairo_translate(context, -m_visibleContentRectForDrawContents.x(), -m_visibleContentRectForDrawContents.y());
1069 cairo_scale(context, m_scaleFactorForDrawContents, m_scaleFactorForDrawContents);
1071 if (drawingArea()) {
1072 if (drawingArea()->layerTreeCoordinatorProxy()) {
1073 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1074 renderer->paintToGraphicsContext(context);
1078 cairo_restore(context);
1081 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
1083 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1084 // We don't want to process scaling in the FullScreen mode.
1085 if (page()->fullScreenManager()->isFullScreen())
1089 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1090 m_textSelection->hideHandlers();
1093 // Adjust scaleFactor.
1094 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
1095 if (!page()->pageGroup()->preferences()->textZoomEnabled())
1096 scaleFactor = adjustScaleWithViewport(scaleFactor);
1098 scaleFactor = adjustScaleWithViewport(scaleFactor);
1101 scaleContents(scaleFactor, scrollPosition);
1104 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
1106 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1107 // We don't want to process scaling in the FullScreen mode.
1108 if (page()->fullScreenManager()->isFullScreen())
1111 scaleFactor = adjustScaleWithViewport(scaleFactor);
1113 setVisibleContentRect(IntRect(origin, viewSize()), scaleFactor);
1116 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1117 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1119 // create if needed.
1120 if (horizontalBar && !m_horizontalScrollbar) {
1121 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewWidget, HorizontalScrollbar);
1122 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1123 m_horizontalScrollbar->setFrameRect(hBarRect);
1124 } else if (!horizontalBar && m_horizontalScrollbar)
1125 m_horizontalScrollbar = 0;
1127 if (verticalBar && !m_verticalScrollbar) {
1128 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewWidget, VerticalScrollbar);
1129 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1130 m_verticalScrollbar->setFrameRect(vBarRect);
1131 } else if (!verticalBar && m_verticalScrollbar)
1132 m_verticalScrollbar = 0;
1135 void PageClientImpl::updateScrollbar()
1137 IntSize scaledContentsSize = m_page->contentsSize();
1138 scaledContentsSize.scale(scaleFactor());
1140 bool newHasHorizontalScrollbar = false;
1141 bool newVerticalScrollbar = false;
1142 if (viewSize().width() < scaledContentsSize.width())
1143 newHasHorizontalScrollbar = true;
1144 if (viewSize().height() < scaledContentsSize.height())
1145 newVerticalScrollbar = true;
1146 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1148 if (m_horizontalScrollbar) {
1149 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1150 m_horizontalScrollbar->setPosition(m_visibleContentRectForDrawContents.x());
1152 if (m_verticalScrollbar) {
1153 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1154 m_verticalScrollbar->setPosition(m_visibleContentRectForDrawContents.y());
1158 void PageClientImpl::frameRectChanged()
1160 if (m_horizontalScrollbar) {
1161 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1162 m_horizontalScrollbar->setFrameRect(hBarRect);
1164 if (m_verticalScrollbar) {
1165 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1166 m_verticalScrollbar->setFrameRect(vBarRect);
1170 void PageClientImpl::updateVisibility()
1172 if (m_horizontalScrollbar)
1173 m_horizontalScrollbar->updateVisibility();
1174 if (m_verticalScrollbar)
1175 m_verticalScrollbar->updateVisibility();
1178 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1180 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1181 bool PageClientImpl::isTextSelectionEnable()
1183 return m_textSelection->isTextSelectionEnable();
1186 void PageClientImpl::setIsTextSelectionEnable(bool isTextSelectionEnable)
1188 m_textSelection->setIsTextSelectionEnable(isTextSelectionEnable);
1191 bool PageClientImpl::isTextSelectionDowned()
1193 return m_textSelection->isTextSelectionDowned();
1196 bool PageClientImpl::isTextSelectionMode()
1198 return m_textSelection->isTextSelectionMode();
1201 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1203 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1206 bool PageClientImpl::autoClearTextSelectionMode()
1208 return m_textSelection->autoClearTextSelectionMode();
1211 void PageClientImpl::setAutoClearTextSelectionMode(bool autoClearTextSelectionMode)
1213 m_textSelection->setAutoClearTextSelectionMode(autoClearTextSelectionMode);
1216 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1218 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewWidget))
1219 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1222 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1224 #if ENABLE(TOUCH_EVENTS) && ENABLE(TIZEN_GESTURE)
1228 if (!evas_object_focus_get(m_viewWidget)) {
1229 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
1230 if (imfContext && (ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
1231 ewk_view_imf_context_hide(m_viewWidget);
1233 evas_object_focus_set(m_viewWidget, true);
1236 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1239 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1241 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1244 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1246 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1249 bool PageClientImpl::isTextSelectionHandleDowned()
1251 return m_textSelection->isTextSelectionHandleDowned();
1254 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1255 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1257 m_textSelection->textSelectionHandleDown(point);
1260 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1262 m_textSelection->textSelectionHandleMove(point);
1265 void PageClientImpl::textSelectonHandleUp()
1267 m_textSelection->textSelectionHandleUp();
1272 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1273 static void clipboarDataCallbackForContextMenu(const String& data, const String& type, void* context)
1275 PageClientImpl* pageClient = static_cast<PageClientImpl*>(context);
1276 pageClient->page()->didSelectPasteMenuFromContextMenu(data, type);
1279 void PageClientImpl::pasteContextMenuSelected()
1281 m_clipboardHelper->requestData(this, clipboarDataCallbackForContextMenu);
1285 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1286 void PageClientImpl::setClipboardData(const String& data, const String& type)
1288 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1289 m_clipboardHelper->setData(data, type);
1293 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1294 void PageClientImpl::clipboardContextMenuSelected()
1296 if(page()->editorState().isContentEditable)
1297 m_clipboardHelper->openClipboardWindow(page()->editorState().isContentRichlyEditable);
1300 bool PageClientImpl::isClipboardWindowOpened()
1302 return m_clipboardHelper->isClipboardWindowOpened();
1305 void PageClientImpl::clearClipboardSelectionClearHandler()
1307 m_clipboardHelper->clearClipboardSelectionClearHandler();
1311 void PageClientImpl::clearClipboardData()
1313 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1314 m_clipboardHelper->clear();
1319 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1320 void PageClientImpl::setIsVisible(bool isVisible)
1322 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1323 if (m_isVisible != isVisible && m_viewWidget && m_pageDidRendered) {
1324 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1325 m_shouldMakeBackupTexture = true;
1326 m_shouldShowBackupTexture = true;
1332 m_isVisible = isVisible;
1335 m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
1337 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1339 ewk_context_decoded_data_clear_all(ewk_view_context_get(m_viewWidget));
1344 #if ENABLE(TIZEN_DRAG_SUPPORT)
1345 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1347 m_drag->setDragPoint(point);
1349 bool PageClientImpl::isDragMode()
1351 return m_drag->isDragMode();
1353 void PageClientImpl::setDragMode(bool isDragMode)
1355 m_drag->setDragMode(isDragMode);
1357 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1359 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1360 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1362 String dragStorageName("Drag");
1363 m_page->dragEntered(dragInfo, dragStorageName);
1365 m_drag->setDragData(dragInfo);
1370 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1371 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1373 ewkViewRegisterProtocolHandlers(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1377 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1378 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1380 return ewkViewIsProtocolHandlerRegistered(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1383 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1385 ewkViewUnregisterProtocolHandlers(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1389 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1390 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1392 ewkViewRegisterContentHandlers(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1395 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1397 return ewkViewIsContentHandlerRegistered(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1400 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1402 ewkViewUnregisterContentHandlers(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1406 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1407 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1409 ewkViewAddSearchProvider(m_viewWidget, baseURL.utf8().data(), engineURL.utf8().data());
1412 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1414 return ewkViewIsSearchProviderInstalled(m_viewWidget, baseURL.utf8().data(), engineURL.utf8().data());
1418 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1419 bool PageClientImpl::getStandaloneStatus()
1421 return ewkViewGetStandaloneStatus(m_viewWidget);
1425 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1426 bool PageClientImpl::lockOrientation(int willLockOrientation)
1428 return ewk_view_orientation_lock(m_viewWidget, willLockOrientation);
1431 void PageClientImpl::unlockOrientation()
1433 ewk_view_orientation_unlock(m_viewWidget);
1437 void PageClientImpl::didRenderFrame()
1439 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1440 if (m_shouldShowBackupTexture && m_isVisible)
1441 m_shouldShowBackupTexture = false;
1443 if (!m_pageDidRendered) {
1444 m_visibleContentRectForDrawContents.setLocation(m_visibleContentRect.location());
1445 m_viewImpl->setScrollPosition(m_visibleContentRectForDrawContents.location());
1446 m_scaleFactorForDrawContents = m_scaleFactor;
1447 // adjustPositionForFixedLayers is calclulated based on m_visibleContentRectForDrawContents values which initially set.
1448 // We need to set this values here, otherwise while navigating to new page, m_accurateVisibleContentsPosition will be having the previous scrolled position
1449 // which makes positioning of the FixedLayer on wrong place
1450 drawingArea()->setAccurateVisibleContentsPosition(FloatPoint(m_visibleContentRectForDrawContents.location()));
1452 m_pageDidRendered = true;
1453 initializeVisibleContentRect();
1457 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1458 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1460 setIsScrollableLayerFocused(false);
1461 setIsScrollableNodeFocused(false);
1465 setIsScrollableLayerFocused(true);
1466 m_page->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1468 setIsScrollableNodeFocused(true);
1473 void PageClientImpl::findScrollableNode(const IntPoint& point)
1475 if (m_page && m_page->isLoadingFinished() && m_page->askOverflow()) {
1476 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1477 WebLayerID webLayerID = 0;
1478 bool checkOverflowLayer = false;
1479 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1480 DrawingAreaProxy* drawingArea = m_page->drawingArea();
1481 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1483 setOverflowResult(m_page->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1488 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1489 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1491 WebCore::IntPoint startPoint, endPoint;
1492 WebCore::IntRect leftRect, rightRect;
1494 WebCore::IntRect caretRect;
1495 page()->getCaretPosition(caretRect);
1496 if (!caretRect.isEmpty()) {
1497 startPoint.setX(caretRect.x());
1498 startPoint.setY(caretRect.y() + caretRect.height());
1500 endPoint.setX(caretRect.x() + caretRect.width());
1501 endPoint.setY(caretRect.y() + caretRect.height());
1503 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1504 else if (page()->getSelectionHandlers(leftRect, rightRect)) {
1505 startPoint.setX(leftRect.x());
1506 startPoint.setY(leftRect.y() + leftRect.height());
1508 endPoint.setX(rightRect.x() + rightRect.width());
1509 endPoint.setY(rightRect.y() + rightRect.height());
1513 startPoint.scale(scaleFactor(), scaleFactor());
1514 endPoint.scale(scaleFactor(), scaleFactor());
1516 int viewPositionX, viewPositionY;
1517 evas_object_geometry_get(m_viewWidget, &viewPositionX, &viewPositionY, NULL, NULL);
1519 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1520 startPoint.move(viewPositionX, viewPositionY);
1522 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1523 endPoint.move(viewPositionX, viewPositionY);
1525 ewkViewDidGetTextStyleStateForSelection(m_viewWidget, underlineState, italicState, boldState, startPoint, endPoint);
1529 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1531 ewk_view_zoomable_area_set(m_viewWidget, target, area);
1534 #if ENABLE(TIZEN_ICON_DATABASE)
1535 void PageClientImpl::didReceiveIcon()
1537 ewkViewIconReceived(viewWidget());
1540 #endif // #if OS(TIZEN)
1543 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1544 PageClientEvasGL::PageClientEvasGL(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
1545 : PageClientImpl(context, pageGroup, viewWidget)
1551 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1554 , m_isAcceleratedCompositingModeInitialized(false)
1556 initializeAcceleratedCompositingMode();
1559 PageClientEvasGL::~PageClientEvasGL()
1564 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1567 evas_gl_surface_destroy(m_evasGL, m_surface);
1572 PageClientImpl::updateViewportSize(viewportSize);
1575 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1577 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1580 ewk_view_display(viewWidget(), rect);
1583 void PageClientEvasGL::displayViewport()
1585 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1586 // We should not draw here when Direct Rendering is enabled.
1587 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1588 ewk_view_mark_for_sync(m_viewWidget);
1590 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1593 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1598 void PageClientEvasGL::drawContents()
1600 if (!ewk_view_image_get(m_viewWidget))
1603 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1606 WebCore::TransformationMatrix matrix;
1609 m_visibleContentRectForDrawContents.setSize(viewSize());
1611 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1612 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
1613 int angle = ecore_evas_rotation_get(ee);
1616 drawingArea()->setAngle(m_angle);
1617 matrix.makeIdentity();
1618 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1619 if (m_angle == 90 || m_angle == 270) {
1620 glViewport(0, 0, m_visibleContentRectForDrawContents.height(), m_visibleContentRectForDrawContents.width());
1622 matrix.translate(-m_visibleContentRectForDrawContents.x() -m_visibleContentRectForDrawContents.width(), -m_visibleContentRectForDrawContents.y());
1623 else if (m_angle == 270)
1624 matrix.translate(-m_visibleContentRectForDrawContents.x(), -m_visibleContentRectForDrawContents.y() - m_visibleContentRectForDrawContents.height());
1625 matrix.scale(m_scaleFactorForDrawContents);
1626 clipRect = IntRect(0, 0, m_visibleContentRectForDrawContents.size().height(), m_visibleContentRectForDrawContents.size().width());
1628 glViewport(0, 0, m_visibleContentRectForDrawContents.width(), m_visibleContentRectForDrawContents.height());
1629 if (m_angle == 180) {
1630 matrix.translate(-m_visibleContentRectForDrawContents.x() - m_visibleContentRectForDrawContents.width(), -m_visibleContentRectForDrawContents.y() - m_visibleContentRectForDrawContents.height());
1631 matrix.scale(m_scaleFactorForDrawContents);
1633 matrix.setMatrix(m_scaleFactorForDrawContents, 0, 0, m_scaleFactorForDrawContents, -m_visibleContentRectForDrawContents.x(), -m_visibleContentRectForDrawContents.y());
1634 clipRect = IntRect(IntPoint(), m_visibleContentRectForDrawContents.size());
1637 glViewport(0, 0, m_visibleContentRectForDrawContents.width(), m_visibleContentRectForDrawContents.height());
1638 matrix.setMatrix(m_scaleFactorForDrawContents, 0, 0, m_scaleFactorForDrawContents, -m_visibleContentRectForDrawContents.x(), -m_visibleContentRectForDrawContents.y());
1639 clipRect = IntRect(IntPoint(), m_visibleContentRectForDrawContents.size());
1642 if (drawingArea()) {
1643 if (drawingArea()->layerTreeCoordinatorProxy()) {
1644 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1645 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1646 if (m_shouldMakeBackupTexture) {
1647 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1648 glClearColor(1, 1, 1, 1);
1649 glClear(GL_COLOR_BUFFER_BIT);
1650 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1651 m_shouldMakeBackupTexture = false;
1652 } else if (m_shouldShowBackupTexture) {
1653 matrix.makeIdentity();
1654 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1655 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1658 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1663 void PageClientEvasGL::didRenderFrame()
1665 ewkViewFrameRendered(m_viewWidget);
1666 PageClientImpl::didRenderFrame();
1669 bool PageClientEvasGL::makeContextCurrent()
1671 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1674 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1676 Evas* evas = evas_object_evas_get(viewWidget());
1678 m_config = evas_gl_config_new();
1679 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1680 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1681 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1683 m_config->color_format = EVAS_GL_RGBA_8888;
1684 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1685 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1687 m_evasGL = evas_gl_new(evas);
1689 evas_gl_config_free(m_config);
1694 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1696 evas_gl_free(m_evasGL);
1698 evas_gl_config_free(m_config);
1702 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1704 m_context = evas_gl_context_create(m_evasGL, 0);
1706 evas_gl_free(m_evasGL);
1708 evas_gl_config_free(m_config);
1714 m_isAcceleratedCompositingModeInitialized = true;
1717 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1721 evas_gl_surface_destroy(m_evasGL, m_surface);
1725 evas_gl_context_destroy(m_evasGL, m_context);
1729 evas_gl_config_free(m_config);
1732 evas_gl_free(m_evasGL);
1736 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1737 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1739 m_isAcceleratedCompositingModeInitialized = false;
1742 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1744 if (!m_isAcceleratedCompositingModeInitialized)
1745 initializeAcceleratedCompositingMode();
1748 void PageClientEvasGL::exitAcceleratedCompositingMode()
1750 if (m_isAcceleratedCompositingModeInitialized)
1751 finalizeAcceleratedCompositingMode();
1754 void PageClientEvasGL::setTargetSurface()
1760 evas_object_geometry_get(viewWidget(), 0, 0, &width, &height);
1761 if (width == 0 || height == 0)
1764 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1766 fprintf(stderr, "[%p] PageClientEvasGL::%s() - failed to create Evas_GL_Surface\n", this, __FUNCTION__);
1770 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1771 makeContextCurrent();
1773 if (makeContextCurrent()) {
1774 glViewport(0, 0, width, height);
1775 glClearColor(1.0, 1.0, 1.0, 1.0);
1776 glClear(GL_COLOR_BUFFER_BIT);
1781 Evas_Native_Surface nativeSurface;
1782 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1783 ewk_view_image_native_surface_set(viewWidget(), &nativeSurface);
1787 } // namespace WebKit