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 "WebPopupMenuProxyEfl.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 #if ENABLE(TIZEN_SCREEN_READER)
76 #include "ScreenReaderProxy.h"
79 using namespace WebCore;
84 PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
85 : m_viewWidget(viewWidget)
87 , m_viewportConstraints()
88 , m_viewFocused(false)
89 , m_viewWindowActive(true)
90 , m_pageDidRendered(false)
91 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
92 , m_visibleContentRect(IntRect())
94 , m_drawingScrollPosition(IntPoint())
95 , m_drawingScaleFactor(1.0f)
96 , m_hasSuspendedContent(false)
98 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
99 , m_restoredScaleFactor(0)
102 , m_isScrollableLayerFocused(false)
103 , m_isScrollableNodeFocused(false)
104 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
105 , m_shouldMakeBackupTexture(false)
106 , m_shouldShowBackupTexture(false)
108 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
109 , m_isContextMenuVisible(false)
111 #endif // #if OS(TIZEN)
113 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
114 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
115 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
117 m_page = context->createWebPage(this, pageGroup);
120 m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
121 m_page->pageGroup()->preferences()->setForceCompositingMode(true);
122 m_page->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
123 m_page->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
126 int deviceWidth, deviceHeight;
127 ecore_evas_screen_geometry_get(ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget)), 0, 0, &deviceWidth, &deviceHeight);
128 m_page->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
129 m_page->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
134 m_page->initializeWebPage();
136 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
137 m_page->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
139 m_page->setCustomDeviceScaleFactor((float)getDPI() / 160);
143 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
144 m_textSelection = TextSelection::create(viewWidget, m_page.get(), this);
146 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
147 m_offlinePageSave = OfflinePageSave::create(viewWidget, m_page.get());
149 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
150 m_clipboardHelper = ClipboardHelper::create(viewWidget, this);
152 #if ENABLE(TIZEN_DRAG_SUPPORT)
153 m_drag = Drag::create(m_page.get());
155 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
156 m_formDataCandidate = FormDataCandidate::create(m_page.get());
160 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
161 m_page->setUseFixedLayout(true);
163 #if ENABLE(FULLSCREEN_API)
164 m_page->fullScreenManager()->setWebView(viewWidget);
167 setBackgroundColor(1, 1, 1, 1);
170 m_viewImpl = EwkViewImpl::fromEvasObject(m_viewWidget);
174 PageClientImpl::~PageClientImpl()
180 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
182 PageClientImpl::ViewportConstraints constraints;
183 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
184 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
185 constraints.userScalable = attributes.userScalable;
186 constraints.layoutSize = attributes.layoutSize;
187 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
189 double defaultViewLevel = m_page->pageGroup()->preferences()->defaultViewLevel();
190 // If defaultViewLevel is 1, "Default View" is set as "Readable"
191 // if not, "Default View" is set as "Fit to width"
192 if (defaultViewLevel) {
193 // if content doesn't set initial scale value, set readable scale factor
194 // if not, set initial scale factor of viewport attribute
195 if (attributes.initialScale == ViewportArguments::ValueAuto)
196 constraints.initialScale = m_page->deviceScaleFactor();
198 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
200 // Minimize initial scale factor
201 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
204 // adjust scale with both minimum and maximum scale factor
205 constraints.initialScale = clampTo(constraints.initialScale, constraints.minimumScale, constraints.maximumScale);
210 double PageClientImpl::adjustScaleWithViewport(double scale)
212 return clampTo(scale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
215 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
216 void PageClientImpl::updateViewportSize(const IntSize& viewportSize)
218 // update device width & height
219 int deviceWidth = WebCore::getDefaultScreenResolution().width();
220 int deviceHeight = WebCore::getDefaultScreenResolution().height();
221 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
222 int angle = ecore_evas_rotation_get(ee);
223 if (angle == 90 || angle == 270) {
224 int tempWidth = deviceWidth;
225 deviceWidth = deviceHeight;
226 deviceHeight = tempWidth;
228 m_page->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
229 m_page->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
231 // update viewport size of webkit
232 m_visibleContentRect.setSize(viewportSize);
234 // Update visible content rect before resize viewport
235 // setVisibleContentRect() should be called once at here or ewk_view_focused_node_adjust()
236 if (!ewk_view_focused_node_adjust(m_viewWidget) && m_pageDidRendered)
237 setVisibleContentRect(m_visibleContentRect, scaleFactor());
239 m_page->setViewportSize(viewportSize);
243 void PageClientImpl::initializeVisibleContentRect()
245 _ewk_view_resume_painting(m_viewWidget);
247 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
248 IntPoint initialScrollPosition;
249 float initialScaleFactor = m_viewportConstraints.initialScale;
250 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
251 // if scroll position and scale factor are restored by history controller,
252 // move scroll position and scale factor with them
253 if (m_restoredScaleFactor) {
254 initialScrollPosition = m_restoredScrollPosition;
255 initialScaleFactor = m_restoredScaleFactor;
258 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
260 // Set initial scale.
261 m_page->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
265 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
267 m_focusedNodeRect = focusedNodeRect;
270 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
271 bool PageClientImpl::scrollBy(IntSize scrollOffset)
273 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
274 // scrollOffset means device screen coordiate, not an actual offset of contents.
275 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
276 // in the actual scale.
277 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
278 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
279 && page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
285 IntPoint oldScrollPosition = scrollPosition();
286 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
291 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
293 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
295 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
297 #endif // #if OS(TIZEN)
300 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
302 return DrawingAreaProxyImpl::create(m_page.get());
305 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
307 ewk_view_mark_for_sync(m_viewWidget);
309 #if ENABLE(TIZEN_SCREEN_READER)
310 if (rect.intersects(ewkViewGetFocusRing(m_viewWidget)->rect()))
311 m_page->recalcScreenReaderFocusRect();
315 void PageClientImpl::displayView()
320 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
322 setViewNeedsDisplay(scrollRect);
325 WebCore::IntSize PageClientImpl::viewSize()
327 return ewk_view_size_get(m_viewWidget);
330 bool PageClientImpl::isViewVisible()
335 bool PageClientImpl::isViewInWindow()
341 void PageClientImpl::processDidCrash()
346 void PageClientImpl::didRelaunchProcess()
348 const char* themePath = ewk_view_theme_get(m_viewWidget);
350 ewk_view_page_get(m_viewWidget)->setThemePath(themePath);
353 void PageClientImpl::pageClosed()
358 void PageClientImpl::toolTipChanged(const String&, const String&)
363 void PageClientImpl::setCursor(const Cursor& cursor)
365 ewk_view_cursor_set(m_viewWidget, cursor);
368 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
373 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
375 float prevMinimumScale = m_viewportConstraints.minimumScale;
376 m_viewportConstraints = computeViewportConstraints(attributes);
377 // setVisibleContentRect() is called to adjust visible content rect after device rotation
378 // In below cases, it shouldn't be called
379 // 1. page is not rendered yet
380 // 2. viewport attributes are changed by WebCore's empty document(progress == 0.1)
381 // 3. there's no input field zoom(device rotation without IME)
382 if (m_pageDidRendered && page()->estimatedProgress() > 0.1 && !ewk_view_focused_node_adjust(m_viewWidget)) {
383 IntSize contentsSize = m_page->contentsSize();
384 double minimumScaleByContentWidth = max(((double)viewSize().width() / contentsSize.width()), 0.25);
385 float newScale = scaleFactor();
387 // If contents width exceeds viewport layout width and content is userScalable, update minimumScale.
388 if (m_viewportConstraints.userScalable)
389 m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
391 // If zoom was fitted to width before the rotation, newScale should be fitted to width again.
392 if (fabs(scaleFactor() - prevMinimumScale) < numeric_limits<double>::epsilon())
393 newScale = m_viewportConstraints.minimumScale;
394 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
395 setVisibleContentRect(m_visibleContentRect, newScale);
397 m_page->scalePage(newScale, m_visibleContentRect.location());
401 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
402 updateTextSelectionHandlesAndContextMenu(true);
405 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
406 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewWidget));
407 if (smartData->api->formdata_candidate_is_showing(smartData))
408 smartData->api->formdata_candidate_hide(smartData);
413 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
415 if (undoOrRedo == WebPageProxy::Undo) {
416 m_undoCommands.append(command);
418 int undoSize = m_undoCommands.size();
419 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
422 m_redoCommands.append(command);
424 int redoSize = m_redoCommands.size();
425 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
429 void PageClientImpl::clearAllEditCommands()
431 m_undoCommands.clear();
432 m_redoCommands.clear();
434 int undoSize = m_undoCommands.size();
435 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
437 int redoSize = m_redoCommands.size();
438 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
441 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
443 if (undoOrRedo == WebPageProxy::Undo)
444 return !m_undoCommands.isEmpty();
446 return !m_redoCommands.isEmpty();
449 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
451 if (undoOrRedo == WebPageProxy::Undo) {
452 m_undoCommands.last()->unapply();
453 m_undoCommands.removeLast();
455 int undoSize = m_undoCommands.size();
456 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
458 m_redoCommands.last()->reapply();
459 m_redoCommands.removeLast();
461 int redoSize = m_redoCommands.size();
462 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
466 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
471 void PageClientImpl::clearAllEditCommands()
476 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
482 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
488 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
494 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
500 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
506 IntRect PageClientImpl::windowToScreen(const IntRect&)
512 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
517 #if ENABLE(GESTURE_EVENTS)
518 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
524 #if ENABLE(TOUCH_EVENTS)
525 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
528 ewk_view_touch_event_handler_result_set(m_viewWidget, event.type(), wasEventHandled);
531 #endif // #if OS(TIZEN)
535 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
537 return WebPopupMenuProxyEfl::create(m_viewWidget, page);
540 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
542 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
543 return WebContextMenuProxyTizen::create(m_viewWidget, page, this);
550 #if ENABLE(INPUT_TYPE_COLOR)
551 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
558 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
564 #if USE(ACCELERATED_COMPOSITING)
565 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
567 ewk_view_accelerated_compositing_mode_enter(m_viewWidget);
570 void PageClientImpl::exitAcceleratedCompositingMode()
572 ewk_view_accelerated_compositing_mode_exit(m_viewWidget);
575 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
579 #endif // USE(ACCELERATED_COMPOSITING)
582 void PageClientImpl::initializeAcceleratedCompositingMode()
586 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
587 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
591 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
593 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
595 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
596 m_bgColor.setRGB(rgba);
599 void PageClientImpl::didChangeScrollbarsForMainFrame() const
605 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
607 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
608 m_initialViewRect.setSize(viewSize());
612 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
617 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
618 if (drawingArea()->layerTreeCoordinatorProxy())
619 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
622 // But we should recalculate this when viewport argument's minimum scale is not fixed.
623 // if contents' width exceeds viewport layout width and userScalable is true.
624 // And minimumScaleByContentWidth shouldn't be smaller than 0.25(minimum zoom level)
625 double oldMinimumScale = m_viewportConstraints.minimumScale;
626 double newMinimumScale = max(((double)viewSize().width() / size.width()), 0.25);
627 bool isMinimized = fabs(scaleFactor() - oldMinimumScale) < numeric_limits<float>::epsilon();
629 // if minimum scale factor is changed, update minimumScale.
630 if (m_viewportConstraints.userScalable
631 && fabs(oldMinimumScale - newMinimumScale) > numeric_limits<float>::epsilon()) {
632 // Sometimes initializeVisibleContentRect can be called after content size change.
633 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
634 if (!m_viewportConstraints.contentsDefinedInitialScale
635 && fabs(m_viewportConstraints.initialScale - oldMinimumScale) < numeric_limits<float>::epsilon())
636 m_viewportConstraints.initialScale = newMinimumScale;
637 m_viewportConstraints.minimumScale = newMinimumScale;
640 // If current scale factor was minimized, minimize new scale factor
641 if (m_pageDidRendered && isMinimized && m_viewportConstraints.userScalable) {
642 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
643 setVisibleContentRect(m_visibleContentRect, newMinimumScale);
645 m_page->scalePage(newMinimumScale, m_visibleContentRect.location());
650 void PageClientImpl::pageScaleFactorDidChange()
652 ewk_view_focused_node_adjust(m_viewWidget);
654 #endif // #if OS(TIZEN)
656 void PageClientImpl::didCommitLoadForMainFrame(bool)
659 m_pageDidRendered = false;
660 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
661 m_restoredScaleFactor = 0;
668 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
673 double PageClientImpl::customRepresentationZoomFactor()
679 void PageClientImpl::setCustomRepresentationZoomFactor(double)
684 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
689 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
694 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
699 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
701 Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget);
702 // For now we only support one default context, but once we support
703 // multiple contexts, we will need to retrieve the context from the
705 ewk_context_download_job_add(ewk_context_default_get(), ewkDownload);
706 ewk_download_job_unref(ewkDownload);
709 #if USE(TILED_BACKING_STORE)
710 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
712 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
713 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewWidget));
714 if (smartData->api->formdata_candidate_is_showing(smartData))
717 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
718 IntPoint newPoint = point;
719 newPoint.scale(scaleFactor(), scaleFactor());
720 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
726 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
727 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
729 m_restoredScrollPosition = point;
730 m_restoredScrollPosition.scale(scale, scale);
731 m_restoredScaleFactor = scale;
733 // Before contents size is fixed, just update visible content rect's position
734 m_visibleContentRect.setLocation(m_restoredScrollPosition);
738 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
739 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
741 if (value == m_formDataCandidate->getCandidateValue()) {
742 m_formDataCandidate->updateCandidateValue(emptyString());
746 m_formDataCandidate->updateCandidateValue(value);
747 ewk_view_text_change_in_textfield(m_viewWidget, name, value);
751 #if ENABLE(TIZEN_ISF_PORT)
752 void PageClientImpl::setInputMethodState(bool active, const String& type, const String& value)
755 ewk_view_imf_context_hide(m_viewWidget);
756 LOG(ISF, "- Keypad status : hide\n");
760 Ewk_Settings* settings = ewk_view_settings_get(m_viewWidget);
761 bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
763 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
764 if (m_clipboardHelper->isClipboardWindowOpened()) {
765 LOG(ISF, "[FAIL] Clipboard\n");
770 LOG(ISF, "- Type (%s), Value (%s)\n", type.utf8().data(), value.utf8().data());
772 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
773 if (type == "date") {
774 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATE, value);
776 } else if (type == "datetime") {
777 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIME, value);
779 } else if (type == "datetime-local") {
780 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIMELOCAL, value);
782 } else if (type == "month") {
783 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_MONTH, value);
785 } else if (type == "time") {
786 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_TIME, value);
788 } else if (type == "week") {
789 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_WEEK, value);
793 #if ENABLE(TIZEN_DATALIST_ELEMENT)
794 Vector<String> optionList = page()->getFocusedInputElementDataList();
795 if (optionList.size() > 0) {
797 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TELEPHONE, optionList);
798 else if (type == "number")
799 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_NUMBER, optionList);
800 else if (type == "email")
801 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_EMAIL, optionList);
802 else if (type == "url")
803 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_URL, optionList);
805 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TEXT, optionList);
809 #endif // ENABLE(TIZEN_DATALIST_ELEMENT)
810 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
812 bool hasFocus = evas_object_focus_get(m_viewWidget);
814 if (!defaultKeypadEnabled) {
815 ewk_view_imf_context_destroy(m_viewWidget);
817 Eina_Rectangle dummyRectForCustomKeypadCallback;
818 memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle));
819 evas_object_smart_callback_call(m_viewWidget, "inputmethod,changed", &dummyRectForCustomKeypadCallback);
824 Ecore_IMF_Input_Panel_Layout layout;
825 if (type == "number")
826 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
827 else if (type == "email")
828 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
829 else if (type == "url")
830 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
831 else if (type == "tel")
832 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
833 else if (type == "password")
834 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
836 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
838 Ecore_IMF_Context* imfContext = ewk_view_imf_context_set(m_viewWidget, layout);
842 if (type == "password")
843 ecore_imf_context_prediction_allow_set(imfContext, false);
845 ecore_imf_context_prediction_allow_set(imfContext, true);
847 if (type.isEmpty() || type == "textarea")
848 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE);
850 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
852 Evas* evas = evas_object_evas_get(m_viewWidget);
853 ecore_imf_context_client_window_set(imfContext, (void*)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas)));
854 ecore_imf_context_client_canvas_set(imfContext, evas);
856 #if ENABLE(TIZEN_SUPPORT_EMOJI)
857 if (type.isEmpty() && !value.isEmpty()) {
858 CString emojiSetting = value.utf8();
859 ecore_imf_context_input_panel_imdata_set(imfContext, emojiSetting.data(), emojiSetting.length());
866 ecore_imf_context_focus_in(imfContext);
867 ecore_imf_context_input_panel_show(imfContext);
868 ecore_imf_context_cursor_position_set(imfContext, page()->getCursorOffset());
870 // input field zoom for external keyboard
871 ewk_view_focused_node_adjust(m_viewWidget, EINA_TRUE);
873 LOG(ISF, "- Keypad status : show\n");
876 void PageClientImpl::setInputMethodState(bool) { }
877 #endif // #if ENABLE(TIZEN_ISF_PORT)
879 #if ENABLE(TIZEN_ISF_PORT)
880 void PageClientImpl::updateTextInputState()
882 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
883 m_textSelection->update();
887 void PageClientImpl::updateCursorOffset(int offset)
889 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
893 ecore_imf_context_cursor_position_set(imfContext, offset);
896 void PageClientImpl::imContextCommitted(Ecore_IMF_Context* context, char* string)
898 if (!page()->focusedFrame())
901 page()->confirmComposition(String::fromUTF8(string));
904 void PageClientImpl::imContextPreeditChanged(Ecore_IMF_Context* context)
906 if (!page()->focusedFrame())
909 char* preeditStr = 0;
910 Eina_List* preeditAttrs = 0;
911 int cursorPosition = 0;
913 ecore_imf_context_preedit_string_with_attributes_get(context, &preeditStr, &preeditAttrs, &cursorPosition);
917 EINA_LIST_FREE(preeditAttrs, item)
924 page()->getCaretPosition(caretRect);
925 caretRect.scale(scaleFactor());
928 evas_object_geometry_get(m_viewWidget, &viewX, &viewY, 0, 0);
930 int x = caretRect.x() - scrollPosition().x() + viewX;
931 int y = caretRect.y() - scrollPosition().y() + viewY;
932 int w = caretRect.width();
933 int h = caretRect.height();
934 ecore_imf_context_cursor_location_set(context, x, y, w, h);
936 String preeditString = String::fromUTF8(preeditStr);
940 Vector<CompositionUnderline> underlines;
942 #if ENABLE(TIZEN_WEBKIT2_SUPPORT_JAPANESE_IME)
944 Eina_List* listIterator = 0;
946 EINA_LIST_FOREACH(preeditAttrs, listIterator, item) {
947 Ecore_IMF_Preedit_Attr* preeditAttr = static_cast<Ecore_IMF_Preedit_Attr*>(item);
949 switch (preeditAttr->preedit_type) {
950 case ECORE_IMF_PREEDIT_TYPE_SUB1:
951 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), false));
953 case ECORE_IMF_PREEDIT_TYPE_SUB2:
954 case ECORE_IMF_PREEDIT_TYPE_SUB3:
955 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(255, 255, 255), false));
957 case ECORE_IMF_PREEDIT_TYPE_SUB4:
958 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(46, 168, 255), false));
960 case ECORE_IMF_PREEDIT_TYPE_SUB5:
961 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 98, 195), false));
963 case ECORE_IMF_PREEDIT_TYPE_SUB6:
964 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(118, 222, 55), false));
966 case ECORE_IMF_PREEDIT_TYPE_SUB7:
967 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 153, 153), false));
971 EINA_LIST_FREE(preeditAttrs, item)
975 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
977 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
980 page()->setComposition(preeditString, underlines, cursorPosition);
982 #endif // #if ENABLE(TIZEN_ISF_PORT)
984 void PageClientImpl::updateFormNavigation(int length, int offset)
989 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
990 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
992 IntSize contentsSize = page()->contentsSize();
993 contentsSize.scale(targetScale);
994 if (contentsSize.width() < visibleContentRect.width())
995 visibleContentRect.setX(0);
997 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
999 if (contentsSize.height() < visibleContentRect.height())
1000 visibleContentRect.setY(0);
1002 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
1003 return visibleContentRect;
1006 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
1008 #if ENABLE(TIZEN_SCREEN_READER)
1009 IntPoint previousScrollPosition(scrollPosition());
1010 float previousScale = m_scaleFactor;
1013 m_scaleFactor = adjustScaleWithViewport(newScale);
1014 m_visibleContentRect.setLocation(newRect.location());
1015 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
1017 // update both drawing scale factor and scroll position after page is rendered
1018 if (m_pageDidRendered) {
1019 m_drawingScaleFactor = m_scaleFactor;
1020 m_drawingScrollPosition = m_visibleContentRect.location();
1023 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
1024 // So we removed enclosingIntRect and replaced with floorf and ceilf.
1025 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
1026 floorf(m_visibleContentRect.y() / m_scaleFactor),
1027 ceilf(m_visibleContentRect.width() / m_scaleFactor),
1028 ceilf(m_visibleContentRect.height() / m_scaleFactor));
1031 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_drawingScrollPosition));
1032 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1033 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
1034 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
1038 #if ENABLE(TIZEN_SCREEN_READER)
1039 if (ScreenReaderProxy::screenReader().isEnabled()
1040 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
1041 ewkViewGetFocusRing(m_viewWidget)->updateScrollAndScale(previousScrollPosition, previousScale);
1044 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1045 updateTextSelectionHandlesAndContextMenu(true);
1049 void PageClientImpl::displayViewport()
1051 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1053 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1057 #if ENABLE(TIZEN_SCREEN_READER)
1058 m_page->recalcScreenReaderFocusRect();
1062 void PageClientImpl::drawContents()
1066 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
1068 if (!m_hasSuspendedContent) {
1069 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
1070 // PageViewport's values are updated when resuming content in the webkit opensource,
1071 // but we have to update viewImpl's values here to sync with PageClient's values.
1072 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
1073 // The values will be updated when resuming content.
1074 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1075 m_viewImpl->setScaleFactor(m_drawingScaleFactor);
1076 m_viewImpl->setScrollPosition(m_drawingScrollPosition);
1079 cairo_save(context);
1080 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
1081 cairo_transform(context, &matrix);
1083 if (drawingArea()) {
1084 if (drawingArea()->layerTreeCoordinatorProxy()) {
1085 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1086 renderer->paintToGraphicsContext(context, m_bgColor);
1090 cairo_restore(context);
1093 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
1095 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1096 // We don't want to process scaling in the FullScreen mode.
1097 if (page()->fullScreenManager()->isFullScreen())
1101 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1102 m_textSelection->hideHandlers();
1105 // Adjust scaleFactor.
1106 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
1107 if (!page()->pageGroup()->preferences()->textZoomEnabled())
1108 scaleFactor = adjustScaleWithViewport(scaleFactor);
1110 scaleFactor = adjustScaleWithViewport(scaleFactor);
1113 scaleContents(scaleFactor, scrollPosition);
1116 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
1118 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1119 // We don't want to process scaling in the FullScreen mode.
1120 if (page()->fullScreenManager()->isFullScreen())
1123 scaleFactor = adjustScaleWithViewport(scaleFactor);
1125 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
1128 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1129 // so below code should be replaced when PageViewportController codes are merged.
1130 // Please do not use below codes. They are only for scaling contents.
1131 void PageClientImpl::suspendContent()
1133 if (m_hasSuspendedContent)
1136 m_hasSuspendedContent = true;
1139 void PageClientImpl::resumeContent()
1141 // FIXME: Update viewImpl's values after resuming content.
1142 // Actually PageViewport's values are updated when resuming content in the webkit opensource,
1143 // but we have to update viewImpl's values here(Tizen) to sync with PageClient's values.
1144 // The concept is that the values of EwkViewImpl and PageClient can be different during suspending
1145 // content and they become same when content is resumed.
1146 m_viewImpl->setScaleFactor(m_drawingScaleFactor);
1147 m_viewImpl->setScrollPosition(m_drawingScrollPosition);
1149 if (!m_hasSuspendedContent)
1152 m_hasSuspendedContent = false;
1155 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1157 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1158 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1160 const IntSize& contentsSize = m_page->contentsSize();
1161 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1162 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1164 FloatPoint position;
1165 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1166 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1167 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1172 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1173 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1175 // create if needed.
1176 if (horizontalBar && !m_horizontalScrollbar) {
1177 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewWidget, HorizontalScrollbar);
1178 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1179 m_horizontalScrollbar->setFrameRect(hBarRect);
1180 } else if (!horizontalBar && m_horizontalScrollbar)
1181 m_horizontalScrollbar = 0;
1183 if (verticalBar && !m_verticalScrollbar) {
1184 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewWidget, VerticalScrollbar);
1185 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1186 m_verticalScrollbar->setFrameRect(vBarRect);
1187 } else if (!verticalBar && m_verticalScrollbar)
1188 m_verticalScrollbar = 0;
1191 void PageClientImpl::updateScrollbar()
1193 IntSize scaledContentsSize = m_page->contentsSize();
1194 scaledContentsSize.scale(scaleFactor());
1196 bool newHasHorizontalScrollbar = false;
1197 bool newVerticalScrollbar = false;
1198 if (viewSize().width() < scaledContentsSize.width())
1199 newHasHorizontalScrollbar = true;
1200 if (viewSize().height() < scaledContentsSize.height())
1201 newVerticalScrollbar = true;
1202 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1204 if (m_horizontalScrollbar) {
1205 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1206 m_horizontalScrollbar->setPosition(m_drawingScrollPosition.x());
1208 if (m_verticalScrollbar) {
1209 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1210 m_verticalScrollbar->setPosition(m_drawingScrollPosition.y());
1214 void PageClientImpl::frameRectChanged()
1216 if (m_horizontalScrollbar) {
1217 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1218 m_horizontalScrollbar->setFrameRect(hBarRect);
1220 if (m_verticalScrollbar) {
1221 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1222 m_verticalScrollbar->setFrameRect(vBarRect);
1226 void PageClientImpl::updateVisibility()
1228 if (m_horizontalScrollbar)
1229 m_horizontalScrollbar->updateVisibility();
1230 if (m_verticalScrollbar)
1231 m_verticalScrollbar->updateVisibility();
1234 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1236 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1237 bool PageClientImpl::isTextSelectionDowned()
1239 return m_textSelection->isTextSelectionDowned();
1242 bool PageClientImpl::isTextSelectionMode()
1244 return m_textSelection->isTextSelectionMode();
1247 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1249 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1252 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1254 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewWidget))
1255 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1258 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1260 if (!evas_object_focus_get(m_viewWidget)) {
1261 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
1262 if (imfContext && (ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
1263 ewk_view_imf_context_hide(m_viewWidget);
1265 evas_object_focus_set(m_viewWidget, true);
1268 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1271 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1273 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1276 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1278 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1281 bool PageClientImpl::isTextSelectionHandleDowned()
1283 return m_textSelection->isTextSelectionHandleDowned();
1286 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1287 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1289 m_textSelection->textSelectionHandleDown(point);
1292 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1294 m_textSelection->textSelectionHandleMove(point);
1297 void PageClientImpl::textSelectonHandleUp()
1299 m_textSelection->textSelectionHandleUp();
1304 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1305 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1307 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1310 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1312 m_offlinePageSave->saveSubresourcesData(subresourceData);
1315 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1317 m_offlinePageSave->startOfflinePageSave(path, url, title);
1321 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1322 void PageClientImpl::pasteContextMenuSelected()
1324 m_clipboardHelper->pasteClipboardLastItem(page()->editorState().isContentRichlyEditable);
1328 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1329 void PageClientImpl::setClipboardData(const String& data, const String& type)
1331 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1332 m_clipboardHelper->setData(data, type);
1336 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1337 void PageClientImpl::clipboardContextMenuSelected()
1339 m_clipboardHelper->openClipboardWindow(page()->editorState().isContentRichlyEditable);
1342 bool PageClientImpl::isClipboardWindowOpened()
1344 return m_clipboardHelper->isClipboardWindowOpened();
1347 void PageClientImpl::clearClipboardSelectionHandler()
1349 m_clipboardHelper->clearClipboardSelectionHandler();
1353 void PageClientImpl::clearClipboardData()
1355 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1356 m_clipboardHelper->clear();
1361 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1362 void PageClientImpl::setIsVisible(bool isVisible)
1364 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1365 if (m_isVisible != isVisible && m_viewWidget && m_pageDidRendered) {
1366 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1367 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
1368 int angle = ecore_evas_rotation_get(ee);
1369 if (angle == 0 || angle == 180) {
1370 m_shouldMakeBackupTexture = true;
1371 m_shouldShowBackupTexture = true;
1378 m_isVisible = isVisible;
1381 m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
1383 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1385 ewk_context_decoded_data_clear_all(ewk_view_context_get(m_viewWidget));
1390 #if ENABLE(TIZEN_DRAG_SUPPORT)
1391 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1393 m_drag->setDragPoint(point);
1395 bool PageClientImpl::isDragMode()
1397 return m_drag->isDragMode();
1399 void PageClientImpl::setDragMode(bool isDragMode)
1401 m_drag->setDragMode(isDragMode);
1403 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1405 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1406 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1408 String dragStorageName("Drag");
1409 m_page->dragEntered(dragInfo, dragStorageName);
1411 m_drag->setDragData(dragInfo);
1416 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1417 bool PageClientImpl::isShowingFormDataCandidate()
1419 return m_formDataCandidate->isShowing();
1422 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1424 m_formDataCandidate->updateFormData(data);
1427 void PageClientImpl::hideFormDataCandidate()
1429 m_formDataCandidate->hide();
1432 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1434 m_formDataCandidate->show(rect);
1438 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1439 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1441 ewkViewRegisterProtocolHandlers(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1445 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1446 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1448 return ewkViewIsProtocolHandlerRegistered(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1451 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1453 ewkViewUnregisterProtocolHandlers(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1457 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1458 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1460 ewkViewRegisterContentHandlers(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1463 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1465 return ewkViewIsContentHandlerRegistered(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1468 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1470 ewkViewUnregisterContentHandlers(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1474 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1475 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1477 ewkViewAddSearchProvider(m_viewWidget, baseURL.utf8().data(), engineURL.utf8().data());
1480 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1482 return ewkViewIsSearchProviderInstalled(m_viewWidget, baseURL.utf8().data(), engineURL.utf8().data());
1486 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1487 bool PageClientImpl::getStandaloneStatus()
1489 return ewkViewGetStandaloneStatus(m_viewWidget);
1493 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1494 bool PageClientImpl::lockOrientation(int willLockOrientation)
1496 return ewk_view_orientation_lock(m_viewWidget, willLockOrientation);
1499 void PageClientImpl::unlockOrientation()
1501 ewk_view_orientation_unlock(m_viewWidget);
1505 void PageClientImpl::didRenderFrame()
1507 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1508 if (m_shouldShowBackupTexture && m_isVisible)
1509 m_shouldShowBackupTexture = false;
1511 if (!m_pageDidRendered) {
1512 // adjustPositionForFixedLayers is calclulated based on m_drawingScrollPosition values which initially set.
1513 // We need to set this values here, otherwise while navigating to new page, m_accurateVisibleContentsPosition will be having the previous scrolled position
1514 // which makes positioning of the FixedLayer on wrong place
1515 drawingArea()->setAccurateVisibleContentsPosition(FloatPoint(m_visibleContentRect.location()));
1516 m_pageDidRendered = true;
1517 initializeVisibleContentRect();
1522 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1523 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1525 setIsScrollableLayerFocused(false);
1526 setIsScrollableNodeFocused(false);
1530 setIsScrollableLayerFocused(true);
1531 m_page->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1533 setIsScrollableNodeFocused(true);
1538 void PageClientImpl::findScrollableNode(const IntPoint& point)
1540 if (m_page && m_page->isLoadingFinished() && m_page->askOverflow()) {
1541 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1542 WebLayerID webLayerID = 0;
1543 bool checkOverflowLayer = false;
1544 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1545 DrawingAreaProxy* drawingArea = m_page->drawingArea();
1546 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1548 setOverflowResult(m_page->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1553 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1554 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1556 WebCore::IntPoint startPoint, endPoint;
1557 WebCore::IntRect leftRect, rightRect;
1559 WebCore::IntRect caretRect;
1560 page()->getCaretPosition(caretRect);
1561 if (!caretRect.isEmpty()) {
1562 startPoint.setX(caretRect.x());
1563 startPoint.setY(caretRect.y() + caretRect.height());
1565 endPoint.setX(caretRect.x() + caretRect.width());
1566 endPoint.setY(caretRect.y() + caretRect.height());
1568 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1569 else if (page()->getSelectionHandlers(leftRect, rightRect)) {
1570 startPoint.setX(leftRect.x());
1571 startPoint.setY(leftRect.y() + leftRect.height());
1573 endPoint.setX(rightRect.x() + rightRect.width());
1574 endPoint.setY(rightRect.y() + rightRect.height());
1578 startPoint.scale(scaleFactor(), scaleFactor());
1579 endPoint.scale(scaleFactor(), scaleFactor());
1581 int viewPositionX, viewPositionY;
1582 evas_object_geometry_get(m_viewWidget, &viewPositionX, &viewPositionY, NULL, NULL);
1584 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1585 startPoint.move(viewPositionX, viewPositionY);
1587 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1588 endPoint.move(viewPositionX, viewPositionY);
1590 ewkViewDidGetTextStyleStateForSelection(m_viewWidget, underlineState, italicState, boldState, startPoint, endPoint);
1594 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1596 ewk_view_zoomable_area_set(m_viewWidget, target, area);
1599 #if ENABLE(TIZEN_ICON_DATABASE)
1600 void PageClientImpl::didReceiveIcon()
1602 ewkViewIconReceived(viewWidget());
1606 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1607 void PageClientImpl::hideFocusRing()
1609 ewkViewFocusRingHide(viewWidget());
1612 #endif // #if OS(TIZEN)
1615 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1616 PageClientEvasGL::PageClientEvasGL(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
1617 : PageClientImpl(context, pageGroup, viewWidget)
1623 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1626 , m_isAcceleratedCompositingModeInitialized(false)
1628 initializeAcceleratedCompositingMode();
1631 PageClientEvasGL::~PageClientEvasGL()
1636 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1639 evas_gl_surface_destroy(m_evasGL, m_surface);
1644 PageClientImpl::updateViewportSize(viewportSize);
1647 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1649 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1652 ewk_view_display(viewWidget(), rect);
1654 #if ENABLE(TIZEN_SCREEN_READER)
1655 if (rect.intersects(ewkViewGetFocusRing(m_viewWidget)->rect()))
1656 m_page->recalcScreenReaderFocusRect();
1660 void PageClientEvasGL::displayViewport()
1662 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1663 // We should not draw here when Direct Rendering is enabled.
1664 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1665 ewk_view_mark_for_sync(m_viewWidget);
1667 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1670 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1674 #if ENABLE(TIZEN_SCREEN_READER)
1675 m_page->recalcScreenReaderFocusRect();
1679 void PageClientEvasGL::drawContents()
1681 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1684 WebCore::TransformationMatrix matrix;
1686 IntSize ewkViewSize = viewSize();
1688 if (!m_hasSuspendedContent) {
1689 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
1690 // PageViewport's values are updated when resuming content in the webkit opensource,
1691 // but we have to update viewImpl's values here to sync with PageClient's values.
1692 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
1693 // The values will be updated when resuming content.
1694 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1695 m_viewImpl->setScaleFactor(m_drawingScaleFactor);
1696 m_viewImpl->setScrollPosition(m_drawingScrollPosition);
1699 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1700 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
1701 m_angle = ecore_evas_rotation_get(ee);
1703 drawingArea()->setAngle(m_angle);
1704 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1706 if (m_angle == 90 || m_angle == 270) {
1707 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1709 matrix.translate(-ewkViewSize.width(), 0);
1710 else if (m_angle == 270)
1711 matrix.translate(0, -ewkViewSize.height());
1712 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1714 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1716 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1717 clipRect = IntRect(IntPoint(), ewkViewSize);
1720 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1721 clipRect = IntRect(IntPoint(), ewkViewSize);
1723 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1725 if (drawingArea()) {
1726 if (drawingArea()->layerTreeCoordinatorProxy()) {
1727 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1728 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1729 if (m_shouldMakeBackupTexture) {
1730 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1731 glClearColor(1, 1, 1, 1);
1732 glClear(GL_COLOR_BUFFER_BIT);
1733 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1734 m_shouldMakeBackupTexture = false;
1735 } else if (m_shouldShowBackupTexture) {
1736 matrix.makeIdentity();
1737 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1738 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1741 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1746 void PageClientEvasGL::didRenderFrame()
1748 ewkViewFrameRendered(m_viewWidget);
1749 PageClientImpl::didRenderFrame();
1752 bool PageClientEvasGL::makeContextCurrent()
1754 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1757 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1759 Evas* evas = evas_object_evas_get(viewWidget());
1761 m_config = evas_gl_config_new();
1762 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1763 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1764 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1766 m_config->color_format = EVAS_GL_RGBA_8888;
1767 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1768 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1770 m_evasGL = evas_gl_new(evas);
1772 evas_gl_config_free(m_config);
1774 TIZEN_LOGE("failed to create evas_gl");
1778 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1780 evas_gl_free(m_evasGL);
1782 evas_gl_config_free(m_config);
1784 TIZEN_LOGE("failed to get evas_gl_api");
1787 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1789 m_context = evas_gl_context_create(m_evasGL, 0);
1791 evas_gl_free(m_evasGL);
1793 evas_gl_config_free(m_config);
1795 TIZEN_LOGE("failed to create evas_gl_context");
1800 m_isAcceleratedCompositingModeInitialized = true;
1803 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1807 evas_gl_surface_destroy(m_evasGL, m_surface);
1811 evas_gl_context_destroy(m_evasGL, m_context);
1815 evas_gl_config_free(m_config);
1818 evas_gl_free(m_evasGL);
1822 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1823 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1825 m_isAcceleratedCompositingModeInitialized = false;
1828 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1830 if (!m_isAcceleratedCompositingModeInitialized)
1831 initializeAcceleratedCompositingMode();
1834 void PageClientEvasGL::exitAcceleratedCompositingMode()
1836 if (m_isAcceleratedCompositingModeInitialized)
1837 finalizeAcceleratedCompositingMode();
1840 void PageClientEvasGL::setTargetSurface()
1846 evas_object_geometry_get(viewWidget(), 0, 0, &width, &height);
1847 if (width == 0 || height == 0)
1850 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1852 TIZEN_LOGE("failed to create Evas_GL_Surface");
1856 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1857 makeContextCurrent();
1859 if (makeContextCurrent()) {
1860 glViewport(0, 0, width, height);
1861 glClearColor(1.0, 1.0, 1.0, 1.0);
1862 glClear(GL_COLOR_BUFFER_BIT);
1867 Evas_Native_Surface nativeSurface;
1868 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1869 ewk_view_image_native_surface_set(viewWidget(), &nativeSurface);
1873 } // namespace WebKit