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_FORM_DATABASE)
402 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewWidget));
403 if (smartData->api->formdata_candidate_is_showing(smartData))
404 smartData->api->formdata_candidate_hide(smartData);
409 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
411 if (undoOrRedo == WebPageProxy::Undo) {
412 m_undoCommands.append(command);
414 int undoSize = m_undoCommands.size();
415 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
418 m_redoCommands.append(command);
420 int redoSize = m_redoCommands.size();
421 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
425 void PageClientImpl::clearAllEditCommands()
427 m_undoCommands.clear();
428 m_redoCommands.clear();
430 int undoSize = m_undoCommands.size();
431 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
433 int redoSize = m_redoCommands.size();
434 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
437 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
439 if (undoOrRedo == WebPageProxy::Undo)
440 return !m_undoCommands.isEmpty();
442 return !m_redoCommands.isEmpty();
445 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
447 if (undoOrRedo == WebPageProxy::Undo) {
448 m_undoCommands.last()->unapply();
449 m_undoCommands.removeLast();
451 int undoSize = m_undoCommands.size();
452 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
454 m_redoCommands.last()->reapply();
455 m_redoCommands.removeLast();
457 int redoSize = m_redoCommands.size();
458 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
462 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
467 void PageClientImpl::clearAllEditCommands()
472 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
478 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
484 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
490 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
496 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
502 IntRect PageClientImpl::windowToScreen(const IntRect&)
508 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
513 #if ENABLE(GESTURE_EVENTS)
514 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
520 #if ENABLE(TOUCH_EVENTS)
521 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
524 ewk_view_touch_event_handler_result_set(m_viewWidget, event.type(), wasEventHandled);
527 #endif // #if OS(TIZEN)
531 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
533 return WebPopupMenuProxyEfl::create(m_viewWidget, page);
536 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
538 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
539 return WebContextMenuProxyTizen::create(m_viewWidget, page, this);
546 #if ENABLE(INPUT_TYPE_COLOR)
547 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
554 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
560 #if USE(ACCELERATED_COMPOSITING)
561 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
563 ewk_view_accelerated_compositing_mode_enter(m_viewWidget);
566 void PageClientImpl::exitAcceleratedCompositingMode()
568 ewk_view_accelerated_compositing_mode_exit(m_viewWidget);
571 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
575 #endif // USE(ACCELERATED_COMPOSITING)
578 void PageClientImpl::initializeAcceleratedCompositingMode()
582 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
583 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
587 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
589 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
591 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
592 m_bgColor.setRGB(rgba);
595 void PageClientImpl::didChangeScrollbarsForMainFrame() const
601 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
603 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
604 m_initialViewRect.setSize(viewSize());
608 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
613 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
614 if (drawingArea()->layerTreeCoordinatorProxy())
615 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
618 // But we should recalculate this when viewport argument's minimum scale is not fixed.
619 // if contents' width exceeds viewport layout width and userScalable is true.
620 // And minimumScaleByContentWidth shouldn't be smaller than 0.25(minimum zoom level)
621 double oldMinimumScale = m_viewportConstraints.minimumScale;
622 double newMinimumScale = max(((double)viewSize().width() / size.width()), 0.25);
623 bool isMinimized = fabs(scaleFactor() - oldMinimumScale) < numeric_limits<float>::epsilon();
625 // if minimum scale factor is changed, update minimumScale.
626 if (m_viewportConstraints.userScalable
627 && fabs(oldMinimumScale - newMinimumScale) > numeric_limits<float>::epsilon()) {
628 // Sometimes initializeVisibleContentRect can be called after content size change.
629 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
630 if (!m_viewportConstraints.contentsDefinedInitialScale
631 && fabs(m_viewportConstraints.initialScale - oldMinimumScale) < numeric_limits<float>::epsilon())
632 m_viewportConstraints.initialScale = newMinimumScale;
633 m_viewportConstraints.minimumScale = newMinimumScale;
636 // If current scale factor was minimized, minimize new scale factor
637 if (m_pageDidRendered && isMinimized && m_viewportConstraints.userScalable) {
638 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
639 setVisibleContentRect(m_visibleContentRect, newMinimumScale);
641 m_page->scalePage(newMinimumScale, m_visibleContentRect.location());
646 void PageClientImpl::pageScaleFactorDidChange()
648 ewk_view_focused_node_adjust(m_viewWidget);
650 #endif // #if OS(TIZEN)
652 void PageClientImpl::didCommitLoadForMainFrame(bool)
655 m_pageDidRendered = false;
656 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
657 m_restoredScaleFactor = 0;
664 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
669 double PageClientImpl::customRepresentationZoomFactor()
675 void PageClientImpl::setCustomRepresentationZoomFactor(double)
680 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
685 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
690 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
695 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
697 Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget);
698 // For now we only support one default context, but once we support
699 // multiple contexts, we will need to retrieve the context from the
701 ewk_context_download_job_add(ewk_context_default_get(), ewkDownload);
702 ewk_download_job_unref(ewkDownload);
705 #if USE(TILED_BACKING_STORE)
706 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
708 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
709 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewWidget));
710 if (smartData->api->formdata_candidate_is_showing(smartData))
713 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
714 IntPoint newPoint = point;
715 newPoint.scale(scaleFactor(), scaleFactor());
716 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
722 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
723 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
725 m_restoredScrollPosition = point;
726 m_restoredScrollPosition.scale(scale, scale);
727 m_restoredScaleFactor = scale;
729 // Before contents size is fixed, just update visible content rect's position
730 m_visibleContentRect.setLocation(m_restoredScrollPosition);
734 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
735 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
737 if (value == m_formDataCandidate->getCandidateValue()) {
738 m_formDataCandidate->updateCandidateValue(emptyString());
742 m_formDataCandidate->updateCandidateValue(value);
743 ewk_view_text_change_in_textfield(m_viewWidget, name, value);
747 #if ENABLE(TIZEN_ISF_PORT)
748 void PageClientImpl::setInputMethodState(bool active, const String& type, const String& value)
751 ewk_view_imf_context_hide(m_viewWidget);
752 LOG(ISF, "- Keypad status : hide\n");
756 Ewk_Settings* settings = ewk_view_settings_get(m_viewWidget);
757 bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
759 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
760 if (m_clipboardHelper->isClipboardWindowOpened()) {
761 LOG(ISF, "[FAIL] Clipboard\n");
766 LOG(ISF, "- Type (%s), Value (%s)\n", type.utf8().data(), value.utf8().data());
768 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
769 if (type == "date") {
770 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATE, value);
772 } else if (type == "datetime") {
773 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIME, value);
775 } else if (type == "datetime-local") {
776 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIMELOCAL, value);
778 } else if (type == "month") {
779 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_MONTH, value);
781 } else if (type == "time") {
782 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_TIME, value);
784 } else if (type == "week") {
785 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_WEEK, value);
789 #if ENABLE(TIZEN_DATALIST_ELEMENT)
790 Vector<String> optionList = page()->getFocusedInputElementDataList();
791 if (optionList.size() > 0) {
793 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TELEPHONE, optionList);
794 else if (type == "number")
795 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_NUMBER, optionList);
796 else if (type == "email")
797 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_EMAIL, optionList);
798 else if (type == "url")
799 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_URL, optionList);
801 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TEXT, optionList);
805 #endif // ENABLE(TIZEN_DATALIST_ELEMENT)
806 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
808 bool hasFocus = evas_object_focus_get(m_viewWidget);
810 if (!defaultKeypadEnabled) {
811 ewk_view_imf_context_destroy(m_viewWidget);
813 Eina_Rectangle dummyRectForCustomKeypadCallback;
814 memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle));
815 evas_object_smart_callback_call(m_viewWidget, "inputmethod,changed", &dummyRectForCustomKeypadCallback);
820 Ecore_IMF_Input_Panel_Layout layout;
821 if (type == "number")
822 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
823 else if (type == "email")
824 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
825 else if (type == "url")
826 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
827 else if (type == "tel")
828 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
829 else if (type == "password")
830 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
832 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
834 Ecore_IMF_Context* imfContext = ewk_view_imf_context_set(m_viewWidget, layout);
838 if (type == "password")
839 ecore_imf_context_prediction_allow_set(imfContext, false);
841 ecore_imf_context_prediction_allow_set(imfContext, true);
843 if (type.isEmpty() || type == "textarea")
844 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE);
846 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
848 Evas* evas = evas_object_evas_get(m_viewWidget);
849 ecore_imf_context_client_window_set(imfContext, (void*)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas)));
850 ecore_imf_context_client_canvas_set(imfContext, evas);
852 #if ENABLE(TIZEN_SUPPORT_EMOJI)
853 if (type.isEmpty() && !value.isEmpty()) {
854 CString emojiSetting = value.utf8();
855 ecore_imf_context_input_panel_imdata_set(imfContext, emojiSetting.data(), emojiSetting.length());
862 ecore_imf_context_focus_in(imfContext);
863 ecore_imf_context_input_panel_show(imfContext);
864 ecore_imf_context_cursor_position_set(imfContext, page()->getCursorOffset());
866 // input field zoom for external keyboard
867 ewk_view_focused_node_adjust(m_viewWidget, EINA_TRUE);
869 LOG(ISF, "- Keypad status : show\n");
872 void PageClientImpl::setInputMethodState(bool) { }
873 #endif // #if ENABLE(TIZEN_ISF_PORT)
875 #if ENABLE(TIZEN_ISF_PORT)
876 void PageClientImpl::updateTextInputState()
878 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
879 m_textSelection->update();
883 void PageClientImpl::updateCursorOffset(int offset)
885 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
889 ecore_imf_context_cursor_position_set(imfContext, offset);
892 void PageClientImpl::imContextCommitted(Ecore_IMF_Context* context, char* string)
894 if (!page()->focusedFrame())
897 page()->confirmComposition(String::fromUTF8(string));
900 void PageClientImpl::imContextPreeditChanged(Ecore_IMF_Context* context)
902 if (!page()->focusedFrame())
905 char* preeditStr = 0;
906 Eina_List* preeditAttrs = 0;
907 int cursorPosition = 0;
909 ecore_imf_context_preedit_string_with_attributes_get(context, &preeditStr, &preeditAttrs, &cursorPosition);
913 EINA_LIST_FREE(preeditAttrs, item)
920 page()->getCaretPosition(caretRect);
921 caretRect.scale(scaleFactor());
924 evas_object_geometry_get(m_viewWidget, &viewX, &viewY, 0, 0);
926 int x = caretRect.x() - scrollPosition().x() + viewX;
927 int y = caretRect.y() - scrollPosition().y() + viewY;
928 int w = caretRect.width();
929 int h = caretRect.height();
930 ecore_imf_context_cursor_location_set(context, x, y, w, h);
932 String preeditString = String::fromUTF8(preeditStr);
936 Vector<CompositionUnderline> underlines;
938 #if ENABLE(TIZEN_WEBKIT2_SUPPORT_JAPANESE_IME)
940 Eina_List* listIterator = 0;
942 EINA_LIST_FOREACH(preeditAttrs, listIterator, item) {
943 Ecore_IMF_Preedit_Attr* preeditAttr = static_cast<Ecore_IMF_Preedit_Attr*>(item);
945 switch (preeditAttr->preedit_type) {
946 case ECORE_IMF_PREEDIT_TYPE_SUB1:
947 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), false));
949 case ECORE_IMF_PREEDIT_TYPE_SUB2:
950 case ECORE_IMF_PREEDIT_TYPE_SUB3:
951 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(255, 255, 255), false));
953 case ECORE_IMF_PREEDIT_TYPE_SUB4:
954 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(46, 168, 255), false));
956 case ECORE_IMF_PREEDIT_TYPE_SUB5:
957 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 98, 195), false));
959 case ECORE_IMF_PREEDIT_TYPE_SUB6:
960 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(118, 222, 55), false));
962 case ECORE_IMF_PREEDIT_TYPE_SUB7:
963 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 153, 153), false));
967 EINA_LIST_FREE(preeditAttrs, item)
971 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
973 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
976 page()->setComposition(preeditString, underlines, cursorPosition);
978 #endif // #if ENABLE(TIZEN_ISF_PORT)
980 void PageClientImpl::updateFormNavigation(int length, int offset)
985 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
986 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
988 IntSize contentsSize = page()->contentsSize();
989 contentsSize.scale(targetScale);
990 if (contentsSize.width() < visibleContentRect.width())
991 visibleContentRect.setX(0);
993 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
995 if (contentsSize.height() < visibleContentRect.height())
996 visibleContentRect.setY(0);
998 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
999 return visibleContentRect;
1002 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
1004 #if ENABLE(TIZEN_SCREEN_READER)
1005 IntPoint previousScrollPosition(scrollPosition());
1006 float previousScale = m_scaleFactor;
1009 m_scaleFactor = adjustScaleWithViewport(newScale);
1010 m_visibleContentRect.setLocation(newRect.location());
1011 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
1013 // update both drawing scale factor and scroll position after page is rendered
1014 if (m_pageDidRendered) {
1015 m_drawingScaleFactor = m_scaleFactor;
1016 m_drawingScrollPosition = m_visibleContentRect.location();
1019 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
1020 // So we removed enclosingIntRect and replaced with floorf and ceilf.
1021 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
1022 floorf(m_visibleContentRect.y() / m_scaleFactor),
1023 ceilf(m_visibleContentRect.width() / m_scaleFactor),
1024 ceilf(m_visibleContentRect.height() / m_scaleFactor));
1027 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_drawingScrollPosition));
1028 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1029 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
1030 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
1034 #if ENABLE(TIZEN_SCREEN_READER)
1035 if (ScreenReaderProxy::screenReader().isEnabled()
1036 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
1037 ewkViewGetFocusRing(m_viewWidget)->updateScrollAndScale(previousScrollPosition, previousScale);
1040 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1041 if (!isClipboardWindowOpened())
1042 updateTextSelectionHandlesAndContextMenu(true);
1046 void PageClientImpl::displayViewport()
1048 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1050 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1054 #if ENABLE(TIZEN_SCREEN_READER)
1055 m_page->recalcScreenReaderFocusRect();
1059 void PageClientImpl::drawContents()
1063 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
1065 if (!m_hasSuspendedContent) {
1066 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
1067 // PageViewport's values are updated when resuming content in the webkit opensource,
1068 // but we have to update viewImpl's values here to sync with PageClient's values.
1069 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
1070 // The values will be updated when resuming content.
1071 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1072 m_viewImpl->setScaleFactor(m_drawingScaleFactor);
1073 m_viewImpl->setScrollPosition(m_drawingScrollPosition);
1076 cairo_save(context);
1077 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
1078 cairo_transform(context, &matrix);
1080 if (drawingArea()) {
1081 if (drawingArea()->layerTreeCoordinatorProxy()) {
1082 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1083 renderer->paintToGraphicsContext(context, m_bgColor);
1087 cairo_restore(context);
1090 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
1092 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1093 // We don't want to process scaling in the FullScreen mode.
1094 if (page()->fullScreenManager()->isFullScreen())
1098 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1099 m_textSelection->hideHandlers();
1102 // Adjust scaleFactor.
1103 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
1104 if (!page()->pageGroup()->preferences()->textZoomEnabled())
1105 scaleFactor = adjustScaleWithViewport(scaleFactor);
1107 scaleFactor = adjustScaleWithViewport(scaleFactor);
1110 scaleContents(scaleFactor, scrollPosition);
1113 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
1115 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1116 // We don't want to process scaling in the FullScreen mode.
1117 if (page()->fullScreenManager()->isFullScreen())
1120 scaleFactor = adjustScaleWithViewport(scaleFactor);
1122 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
1125 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1126 // so below code should be replaced when PageViewportController codes are merged.
1127 // Please do not use below codes. They are only for scaling contents.
1128 void PageClientImpl::suspendContent()
1130 if (m_hasSuspendedContent)
1133 m_hasSuspendedContent = true;
1136 void PageClientImpl::resumeContent()
1138 // FIXME: Update viewImpl's values after resuming content.
1139 // Actually PageViewport's values are updated when resuming content in the webkit opensource,
1140 // but we have to update viewImpl's values here(Tizen) to sync with PageClient's values.
1141 // The concept is that the values of EwkViewImpl and PageClient can be different during suspending
1142 // content and they become same when content is resumed.
1143 m_viewImpl->setScaleFactor(m_drawingScaleFactor);
1144 m_viewImpl->setScrollPosition(m_drawingScrollPosition);
1146 if (!m_hasSuspendedContent)
1149 m_hasSuspendedContent = false;
1152 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
1154 // We need to floor the viewport here as to allow aligning the content in device units. If not,
1155 // it might not be possible to scroll the last pixel and that affects fixed position elements.
1157 const IntSize& contentsSize = m_page->contentsSize();
1158 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
1159 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
1161 FloatPoint position;
1162 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
1163 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
1164 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
1169 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1170 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
1172 // create if needed.
1173 if (horizontalBar && !m_horizontalScrollbar) {
1174 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewWidget, HorizontalScrollbar);
1175 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1176 m_horizontalScrollbar->setFrameRect(hBarRect);
1177 } else if (!horizontalBar && m_horizontalScrollbar)
1178 m_horizontalScrollbar = 0;
1180 if (verticalBar && !m_verticalScrollbar) {
1181 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewWidget, VerticalScrollbar);
1182 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1183 m_verticalScrollbar->setFrameRect(vBarRect);
1184 } else if (!verticalBar && m_verticalScrollbar)
1185 m_verticalScrollbar = 0;
1188 void PageClientImpl::updateScrollbar()
1190 IntSize scaledContentsSize = m_page->contentsSize();
1191 scaledContentsSize.scale(scaleFactor());
1193 bool newHasHorizontalScrollbar = false;
1194 bool newVerticalScrollbar = false;
1195 if (viewSize().width() < scaledContentsSize.width())
1196 newHasHorizontalScrollbar = true;
1197 if (viewSize().height() < scaledContentsSize.height())
1198 newVerticalScrollbar = true;
1199 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
1201 if (m_horizontalScrollbar) {
1202 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
1203 m_horizontalScrollbar->setPosition(m_drawingScrollPosition.x());
1205 if (m_verticalScrollbar) {
1206 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1207 m_verticalScrollbar->setPosition(m_drawingScrollPosition.y());
1211 void PageClientImpl::frameRectChanged()
1213 if (m_horizontalScrollbar) {
1214 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
1215 m_horizontalScrollbar->setFrameRect(hBarRect);
1217 if (m_verticalScrollbar) {
1218 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
1219 m_verticalScrollbar->setFrameRect(vBarRect);
1223 void PageClientImpl::updateVisibility()
1225 if (m_horizontalScrollbar)
1226 m_horizontalScrollbar->updateVisibility();
1227 if (m_verticalScrollbar)
1228 m_verticalScrollbar->updateVisibility();
1231 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1233 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1234 bool PageClientImpl::isTextSelectionDowned()
1236 return m_textSelection->isTextSelectionDowned();
1239 bool PageClientImpl::isTextSelectionMode()
1241 return m_textSelection->isTextSelectionMode();
1244 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1246 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1249 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1251 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewWidget))
1252 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1255 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1257 if (!evas_object_focus_get(m_viewWidget)) {
1258 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
1259 if (imfContext && (ecore_imf_context_input_panel_state_get(imfContext) == ECORE_IMF_INPUT_PANEL_STATE_HIDE))
1260 ewk_view_imf_context_hide(m_viewWidget);
1262 evas_object_focus_set(m_viewWidget, true);
1265 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1268 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1270 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1273 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1275 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1278 bool PageClientImpl::isTextSelectionHandleDowned()
1280 return m_textSelection->isTextSelectionHandleDowned();
1283 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1284 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1286 m_textSelection->textSelectionHandleDown(point);
1289 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1291 m_textSelection->textSelectionHandleMove(point);
1294 void PageClientImpl::textSelectonHandleUp()
1296 m_textSelection->textSelectionHandleUp();
1301 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1302 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1304 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1307 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1309 m_offlinePageSave->saveSubresourcesData(subresourceData);
1312 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1314 m_offlinePageSave->startOfflinePageSave(path, url, title);
1318 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1319 void PageClientImpl::pasteContextMenuSelected()
1321 m_clipboardHelper->pasteClipboardLastItem(page()->editorState().isContentRichlyEditable);
1325 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1326 void PageClientImpl::setClipboardData(const String& data, const String& type)
1328 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1329 m_clipboardHelper->setData(data, type);
1333 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1334 void PageClientImpl::clipboardContextMenuSelected()
1336 m_clipboardHelper->openClipboardWindow(page()->editorState().isContentRichlyEditable);
1339 bool PageClientImpl::isClipboardWindowOpened()
1341 return m_clipboardHelper->isClipboardWindowOpened();
1344 void PageClientImpl::clearClipboardSelectionHandler()
1346 m_clipboardHelper->clearClipboardSelectionHandler();
1350 void PageClientImpl::clearClipboardData()
1352 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1353 m_clipboardHelper->clear();
1358 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1359 void PageClientImpl::setIsVisible(bool isVisible)
1361 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1362 if (m_isVisible != isVisible && m_viewWidget && m_pageDidRendered) {
1363 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1364 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
1365 int angle = ecore_evas_rotation_get(ee);
1366 if (angle == 0 || angle == 180) {
1367 m_shouldMakeBackupTexture = true;
1368 m_shouldShowBackupTexture = true;
1375 m_isVisible = isVisible;
1378 m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
1380 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1382 ewk_context_decoded_data_clear_all(ewk_view_context_get(m_viewWidget));
1387 #if ENABLE(TIZEN_DRAG_SUPPORT)
1388 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1390 m_drag->setDragPoint(point);
1392 bool PageClientImpl::isDragMode()
1394 return m_drag->isDragMode();
1396 void PageClientImpl::setDragMode(bool isDragMode)
1398 m_drag->setDragMode(isDragMode);
1400 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1402 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1403 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1405 String dragStorageName("Drag");
1406 m_page->dragEntered(dragInfo, dragStorageName);
1408 m_drag->setDragData(dragInfo);
1413 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1414 bool PageClientImpl::isShowingFormDataCandidate()
1416 return m_formDataCandidate->isShowing();
1419 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1421 m_formDataCandidate->updateFormData(data);
1424 void PageClientImpl::hideFormDataCandidate()
1426 m_formDataCandidate->hide();
1429 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1431 m_formDataCandidate->show(rect);
1435 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1436 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1438 ewkViewRegisterProtocolHandlers(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1442 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1443 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1445 return ewkViewIsProtocolHandlerRegistered(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1448 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1450 ewkViewUnregisterProtocolHandlers(m_viewWidget, scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1454 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1455 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1457 ewkViewRegisterContentHandlers(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1460 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1462 return ewkViewIsContentHandlerRegistered(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1465 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1467 ewkViewUnregisterContentHandlers(m_viewWidget, mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1471 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1472 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1474 ewkViewAddSearchProvider(m_viewWidget, baseURL.utf8().data(), engineURL.utf8().data());
1477 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1479 return ewkViewIsSearchProviderInstalled(m_viewWidget, baseURL.utf8().data(), engineURL.utf8().data());
1483 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1484 bool PageClientImpl::getStandaloneStatus()
1486 return ewkViewGetStandaloneStatus(m_viewWidget);
1490 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1491 bool PageClientImpl::lockOrientation(int willLockOrientation)
1493 return ewk_view_orientation_lock(m_viewWidget, willLockOrientation);
1496 void PageClientImpl::unlockOrientation()
1498 ewk_view_orientation_unlock(m_viewWidget);
1502 void PageClientImpl::didRenderFrame()
1504 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1505 if (m_shouldShowBackupTexture && m_isVisible)
1506 m_shouldShowBackupTexture = false;
1508 if (!m_pageDidRendered) {
1509 // adjustPositionForFixedLayers is calclulated based on m_drawingScrollPosition values which initially set.
1510 // We need to set this values here, otherwise while navigating to new page, m_accurateVisibleContentsPosition will be having the previous scrolled position
1511 // which makes positioning of the FixedLayer on wrong place
1512 drawingArea()->setAccurateVisibleContentsPosition(FloatPoint(m_visibleContentRect.location()));
1513 m_pageDidRendered = true;
1514 initializeVisibleContentRect();
1519 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1520 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1522 setIsScrollableLayerFocused(false);
1523 setIsScrollableNodeFocused(false);
1527 setIsScrollableLayerFocused(true);
1528 m_page->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1530 setIsScrollableNodeFocused(true);
1535 void PageClientImpl::findScrollableNode(const IntPoint& point)
1537 if (m_page && m_page->isLoadingFinished() && m_page->askOverflow()) {
1538 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1539 WebLayerID webLayerID = 0;
1540 bool checkOverflowLayer = false;
1541 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1542 DrawingAreaProxy* drawingArea = m_page->drawingArea();
1543 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1545 setOverflowResult(m_page->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1550 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1551 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1553 WebCore::IntPoint startPoint, endPoint;
1554 WebCore::IntRect leftRect, rightRect;
1556 WebCore::IntRect caretRect;
1557 page()->getCaretPosition(caretRect);
1558 if (!caretRect.isEmpty()) {
1559 startPoint.setX(caretRect.x());
1560 startPoint.setY(caretRect.y() + caretRect.height());
1562 endPoint.setX(caretRect.x() + caretRect.width());
1563 endPoint.setY(caretRect.y() + caretRect.height());
1565 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1566 else if (page()->getSelectionHandlers(leftRect, rightRect)) {
1567 startPoint.setX(leftRect.x());
1568 startPoint.setY(leftRect.y() + leftRect.height());
1570 endPoint.setX(rightRect.x() + rightRect.width());
1571 endPoint.setY(rightRect.y() + rightRect.height());
1575 startPoint.scale(scaleFactor(), scaleFactor());
1576 endPoint.scale(scaleFactor(), scaleFactor());
1578 int viewPositionX, viewPositionY;
1579 evas_object_geometry_get(m_viewWidget, &viewPositionX, &viewPositionY, NULL, NULL);
1581 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1582 startPoint.move(viewPositionX, viewPositionY);
1584 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1585 endPoint.move(viewPositionX, viewPositionY);
1587 ewkViewDidGetTextStyleStateForSelection(m_viewWidget, underlineState, italicState, boldState, startPoint, endPoint);
1591 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1593 ewk_view_zoomable_area_set(m_viewWidget, target, area);
1596 #if ENABLE(TIZEN_ICON_DATABASE)
1597 void PageClientImpl::didReceiveIcon()
1599 ewkViewIconReceived(viewWidget());
1603 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1604 void PageClientImpl::hideFocusRing()
1606 ewkViewFocusRingHide(viewWidget());
1609 #endif // #if OS(TIZEN)
1612 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1613 PageClientEvasGL::PageClientEvasGL(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
1614 : PageClientImpl(context, pageGroup, viewWidget)
1620 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1623 , m_isAcceleratedCompositingModeInitialized(false)
1625 initializeAcceleratedCompositingMode();
1628 PageClientEvasGL::~PageClientEvasGL()
1633 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1636 evas_gl_surface_destroy(m_evasGL, m_surface);
1641 PageClientImpl::updateViewportSize(viewportSize);
1644 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1646 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1649 ewk_view_display(viewWidget(), rect);
1651 #if ENABLE(TIZEN_SCREEN_READER)
1652 if (rect.intersects(ewkViewGetFocusRing(m_viewWidget)->rect()))
1653 m_page->recalcScreenReaderFocusRect();
1657 void PageClientEvasGL::displayViewport()
1659 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1660 // We should not draw here when Direct Rendering is enabled.
1661 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1662 ewk_view_mark_for_sync(m_viewWidget);
1664 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1667 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1671 #if ENABLE(TIZEN_SCREEN_READER)
1672 m_page->recalcScreenReaderFocusRect();
1676 void PageClientEvasGL::drawContents()
1678 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1681 WebCore::TransformationMatrix matrix;
1683 IntSize ewkViewSize = viewSize();
1685 if (!m_hasSuspendedContent) {
1686 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
1687 // PageViewport's values are updated when resuming content in the webkit opensource,
1688 // but we have to update viewImpl's values here to sync with PageClient's values.
1689 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
1690 // The values will be updated when resuming content.
1691 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1692 m_viewImpl->setScaleFactor(m_drawingScaleFactor);
1693 m_viewImpl->setScrollPosition(m_drawingScrollPosition);
1696 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1697 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
1698 m_angle = ecore_evas_rotation_get(ee);
1700 drawingArea()->setAngle(m_angle);
1701 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1703 if (m_angle == 90 || m_angle == 270) {
1704 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1706 matrix.translate(-ewkViewSize.width(), 0);
1707 else if (m_angle == 270)
1708 matrix.translate(0, -ewkViewSize.height());
1709 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1711 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1713 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1714 clipRect = IntRect(IntPoint(), ewkViewSize);
1717 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1718 clipRect = IntRect(IntPoint(), ewkViewSize);
1720 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1722 if (drawingArea()) {
1723 if (drawingArea()->layerTreeCoordinatorProxy()) {
1724 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1725 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1726 if (m_shouldMakeBackupTexture) {
1727 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1728 glClearColor(1, 1, 1, 1);
1729 glClear(GL_COLOR_BUFFER_BIT);
1730 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1731 m_shouldMakeBackupTexture = false;
1732 } else if (m_shouldShowBackupTexture) {
1733 matrix.makeIdentity();
1734 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1735 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1738 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1743 void PageClientEvasGL::didRenderFrame()
1745 ewkViewFrameRendered(m_viewWidget);
1746 PageClientImpl::didRenderFrame();
1749 bool PageClientEvasGL::makeContextCurrent()
1751 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1754 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1756 Evas* evas = evas_object_evas_get(viewWidget());
1758 m_config = evas_gl_config_new();
1759 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1760 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1761 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1763 m_config->color_format = EVAS_GL_RGBA_8888;
1764 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1765 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1767 m_evasGL = evas_gl_new(evas);
1769 evas_gl_config_free(m_config);
1771 TIZEN_LOGE("failed to create evas_gl");
1775 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1777 evas_gl_free(m_evasGL);
1779 evas_gl_config_free(m_config);
1781 TIZEN_LOGE("failed to get evas_gl_api");
1784 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1786 m_context = evas_gl_context_create(m_evasGL, 0);
1788 evas_gl_free(m_evasGL);
1790 evas_gl_config_free(m_config);
1792 TIZEN_LOGE("failed to create evas_gl_context");
1797 m_isAcceleratedCompositingModeInitialized = true;
1800 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1804 evas_gl_surface_destroy(m_evasGL, m_surface);
1808 evas_gl_context_destroy(m_evasGL, m_context);
1812 evas_gl_config_free(m_config);
1815 evas_gl_free(m_evasGL);
1819 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1820 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1822 m_isAcceleratedCompositingModeInitialized = false;
1825 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1827 if (!m_isAcceleratedCompositingModeInitialized)
1828 initializeAcceleratedCompositingMode();
1831 void PageClientEvasGL::exitAcceleratedCompositingMode()
1833 if (m_isAcceleratedCompositingModeInitialized)
1834 finalizeAcceleratedCompositingMode();
1837 void PageClientEvasGL::setTargetSurface()
1843 evas_object_geometry_get(viewWidget(), 0, 0, &width, &height);
1844 if (width == 0 || height == 0)
1847 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1849 TIZEN_LOGE("failed to create Evas_GL_Surface");
1853 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1854 makeContextCurrent();
1856 if (makeContextCurrent()) {
1857 glViewport(0, 0, width, height);
1858 glClearColor(1.0, 1.0, 1.0, 1.0);
1859 glClear(GL_COLOR_BUFFER_BIT);
1864 Evas_Native_Surface nativeSurface;
1865 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1866 ewk_view_image_native_surface_set(viewWidget(), &nativeSurface);
1870 } // namespace WebKit