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_hasSuspendedContent(false)
96 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
97 , m_restoredScaleFactor(0)
100 , m_isScrollableLayerFocused(false)
101 , m_isScrollableNodeFocused(false)
102 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
103 , m_shouldMakeBackupTexture(false)
104 , m_shouldShowBackupTexture(false)
106 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
107 , m_isContextMenuVisible(false)
109 #endif // #if OS(TIZEN)
111 #if ENABLE(TIZEN_CANVAS_CAIRO_GLES_RENDERING)
112 setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
113 setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
115 m_page = context->createWebPage(this, pageGroup);
118 m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
119 m_page->pageGroup()->preferences()->setForceCompositingMode(true);
120 m_page->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
121 m_page->pageGroup()->preferences()->setAllowUniversalAccessFromFileURLs(true);
124 int deviceWidth, deviceHeight;
125 ecore_evas_screen_geometry_get(ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget)), 0, 0, &deviceWidth, &deviceHeight);
126 m_page->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
127 m_page->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
132 m_page->initializeWebPage();
134 #if ENABLE(TIZEN_VIEWPORT_META_TAG)
135 m_page->setCustomDeviceScaleFactor((float)getMobileDPI() / 160);
137 m_page->setCustomDeviceScaleFactor((float)getDPI() / 160);
141 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
142 m_textSelection = TextSelection::create(viewWidget, m_page.get(), this);
144 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
145 m_offlinePageSave = OfflinePageSave::create(viewWidget, m_page.get());
147 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
148 m_clipboardHelper = ClipboardHelper::create(viewWidget, this);
150 #if ENABLE(TIZEN_DRAG_SUPPORT)
151 m_drag = Drag::create(m_page.get());
153 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
154 m_formDataCandidate = FormDataCandidate::create(m_page.get());
158 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE) && !ENABLE(TIZEN_WEBKIT2_EFL_WTR)
159 m_page->setUseFixedLayout(true);
161 #if ENABLE(FULLSCREEN_API)
162 m_page->fullScreenManager()->setWebView(viewWidget);
165 setBackgroundColor(1, 1, 1, 1);
168 m_viewImpl = EwkViewImpl::fromEvasObject(m_viewWidget);
172 PageClientImpl::~PageClientImpl()
178 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
180 PageClientImpl::ViewportConstraints constraints;
181 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
182 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
183 constraints.userScalable = attributes.userScalable;
184 constraints.layoutSize = attributes.layoutSize;
185 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
187 double defaultViewLevel = m_page->pageGroup()->preferences()->defaultViewLevel();
188 // If defaultViewLevel is 1, "Default View" is set as "Readable"
189 // if not, "Default View" is set as "Fit to width"
190 if (defaultViewLevel) {
191 // if content doesn't set initial scale value, set readable scale factor
192 // if not, set initial scale factor of viewport attribute
193 if (attributes.initialScale == ViewportArguments::ValueAuto)
194 constraints.initialScale = m_page->deviceScaleFactor();
196 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
198 // Minimize initial scale factor
199 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
202 // adjust scale with both minimum and maximum scale factor
203 constraints.initialScale = clampTo(constraints.initialScale, constraints.minimumScale, constraints.maximumScale);
208 double PageClientImpl::adjustScaleWithViewport(double scale)
210 return clampTo(scale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
213 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
214 void PageClientImpl::updateViewportSize(const IntSize& viewportSize)
216 // update device width & height
217 int deviceWidth = WebCore::getDefaultScreenResolution().width();
218 int deviceHeight = WebCore::getDefaultScreenResolution().height();
219 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
220 int angle = ecore_evas_rotation_get(ee);
221 if (angle == 90 || angle == 270) {
222 int tempWidth = deviceWidth;
223 deviceWidth = deviceHeight;
224 deviceHeight = tempWidth;
226 m_page->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
227 m_page->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
229 // update viewport size of webkit
230 m_visibleContentRect.setSize(viewportSize);
232 // Update visible content rect before resize viewport
233 // setVisibleContentRect() should be called once at here or ewk_view_focused_node_adjust()
234 if (!ewk_view_focused_node_adjust(m_viewWidget) && m_pageDidRendered)
235 setVisibleContentRect(m_visibleContentRect, scaleFactor());
237 m_page->setViewportSize(viewportSize);
241 void PageClientImpl::initializeVisibleContentRect()
243 _ewk_view_resume_painting(m_viewWidget);
245 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
246 IntPoint initialScrollPosition;
247 float initialScaleFactor = m_viewportConstraints.initialScale;
248 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
249 // if scroll position and scale factor are restored by history controller,
250 // move scroll position and scale factor with them
251 if (m_restoredScaleFactor) {
252 initialScrollPosition = m_restoredScrollPosition;
253 initialScaleFactor = m_restoredScaleFactor;
256 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
258 // Set initial scale.
259 m_page->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
263 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
265 m_focusedNodeRect = focusedNodeRect;
268 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
269 bool PageClientImpl::scrollBy(IntSize scrollOffset)
271 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
272 // scrollOffset means device screen coordiate, not an actual offset of contents.
273 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
274 // in the actual scale.
275 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
276 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
277 && page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
283 IntPoint oldScrollPosition = scrollPosition();
284 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
289 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
291 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
293 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
295 #endif // #if OS(TIZEN)
298 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
300 return DrawingAreaProxyImpl::create(m_page.get());
303 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
305 ewk_view_mark_for_sync(m_viewWidget);
307 #if ENABLE(TIZEN_SCREEN_READER)
308 if (rect.intersects(ewkViewGetFocusRing(m_viewWidget)->rect()))
309 m_page->recalcScreenReaderFocusRect();
313 void PageClientImpl::displayView()
318 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
320 setViewNeedsDisplay(scrollRect);
323 WebCore::IntSize PageClientImpl::viewSize()
325 return ewk_view_size_get(m_viewWidget);
328 bool PageClientImpl::isViewVisible()
333 bool PageClientImpl::isViewInWindow()
339 void PageClientImpl::processDidCrash()
344 void PageClientImpl::didRelaunchProcess()
346 const char* themePath = ewk_view_theme_get(m_viewWidget);
348 ewk_view_page_get(m_viewWidget)->setThemePath(themePath);
351 void PageClientImpl::pageClosed()
356 void PageClientImpl::toolTipChanged(const String&, const String&)
361 void PageClientImpl::setCursor(const Cursor& cursor)
363 ewk_view_cursor_set(m_viewWidget, cursor);
366 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
371 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
373 float prevMinimumScale = m_viewportConstraints.minimumScale;
374 m_viewportConstraints = computeViewportConstraints(attributes);
375 // setVisibleContentRect() is called to adjust visible content rect after device rotation
376 // In below cases, it shouldn't be called
377 // 1. page is not rendered yet
378 // 2. viewport attributes are changed by WebCore's empty document(progress == 0.1)
379 // 3. there's no input field zoom(device rotation without IME)
380 if (m_pageDidRendered && page()->estimatedProgress() > 0.1 && !ewk_view_focused_node_adjust(m_viewWidget)) {
381 IntSize contentsSize = m_page->contentsSize();
382 double minimumScaleByContentWidth = max(((double)viewSize().width() / contentsSize.width()), 0.25);
383 float newScale = scaleFactor();
385 // If contents width exceeds viewport layout width and content is userScalable, update minimumScale.
386 if (m_viewportConstraints.userScalable)
387 m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
389 // If zoom was fitted to width before the rotation, newScale should be fitted to width again.
390 if (fabs(scaleFactor() - prevMinimumScale) < numeric_limits<double>::epsilon())
391 newScale = m_viewportConstraints.minimumScale;
392 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
393 setVisibleContentRect(m_visibleContentRect, newScale);
395 m_page->scalePage(newScale, m_visibleContentRect.location());
399 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
400 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewWidget));
401 if (smartData->api->formdata_candidate_is_showing(smartData))
402 smartData->api->formdata_candidate_hide(smartData);
407 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
409 if (undoOrRedo == WebPageProxy::Undo) {
410 m_undoCommands.append(command);
412 int undoSize = m_undoCommands.size();
413 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
416 m_redoCommands.append(command);
418 int redoSize = m_redoCommands.size();
419 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
423 void PageClientImpl::clearAllEditCommands()
425 m_undoCommands.clear();
426 m_redoCommands.clear();
428 int undoSize = m_undoCommands.size();
429 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
431 int redoSize = m_redoCommands.size();
432 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
435 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
437 if (undoOrRedo == WebPageProxy::Undo)
438 return !m_undoCommands.isEmpty();
440 return !m_redoCommands.isEmpty();
443 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
445 if (undoOrRedo == WebPageProxy::Undo) {
446 m_undoCommands.last()->unapply();
447 m_undoCommands.removeLast();
449 int undoSize = m_undoCommands.size();
450 evas_object_smart_callback_call(m_viewWidget, "undo,size", &undoSize);
452 m_redoCommands.last()->reapply();
453 m_redoCommands.removeLast();
455 int redoSize = m_redoCommands.size();
456 evas_object_smart_callback_call(m_viewWidget, "redo,size", &redoSize);
460 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
465 void PageClientImpl::clearAllEditCommands()
470 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
476 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
482 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
488 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
494 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
500 IntRect PageClientImpl::windowToScreen(const IntRect&)
506 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
511 #if ENABLE(GESTURE_EVENTS)
512 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
518 #if ENABLE(TOUCH_EVENTS)
519 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
522 ewk_view_touch_event_handler_result_set(m_viewWidget, event.type(), wasEventHandled);
525 #endif // #if OS(TIZEN)
529 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
531 return WebPopupMenuProxyEfl::create(m_viewWidget, page);
534 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
536 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
537 return WebContextMenuProxyTizen::create(m_viewWidget, page, this);
544 #if ENABLE(INPUT_TYPE_COLOR)
545 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
552 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
558 #if USE(ACCELERATED_COMPOSITING)
559 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
561 ewk_view_accelerated_compositing_mode_enter(m_viewWidget);
564 void PageClientImpl::exitAcceleratedCompositingMode()
566 ewk_view_accelerated_compositing_mode_exit(m_viewWidget);
569 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
573 #endif // USE(ACCELERATED_COMPOSITING)
576 void PageClientImpl::initializeAcceleratedCompositingMode()
580 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
581 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
585 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
587 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
589 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
590 m_bgColor.setRGB(rgba);
593 void PageClientImpl::didChangeScrollbarsForMainFrame() const
599 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
601 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
602 m_initialViewRect.setSize(viewSize());
606 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
611 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
612 if (drawingArea()->layerTreeCoordinatorProxy())
613 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
616 // But we should recalculate this when viewport argument's minimum scale is not fixed.
617 // if contents' width exceeds viewport layout width and userScalable is true.
618 // And minimumScaleByContentWidth shouldn't be smaller than 0.25(minimum zoom level)
619 double oldMinimumScale = m_viewportConstraints.minimumScale;
620 double newMinimumScale = max(((double)viewSize().width() / size.width()), 0.25);
621 bool isMinimized = fabs(scaleFactor() - oldMinimumScale) < numeric_limits<float>::epsilon();
623 // if minimum scale factor is changed, update minimumScale.
624 if (m_viewportConstraints.userScalable
625 && fabs(oldMinimumScale - newMinimumScale) > numeric_limits<float>::epsilon()) {
626 // Sometimes initializeVisibleContentRect can be called after content size change.
627 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
628 if (!m_viewportConstraints.contentsDefinedInitialScale
629 && fabs(m_viewportConstraints.initialScale - oldMinimumScale) < numeric_limits<float>::epsilon())
630 m_viewportConstraints.initialScale = newMinimumScale;
631 m_viewportConstraints.minimumScale = newMinimumScale;
634 // If current scale factor was minimized, minimize new scale factor
635 if (m_pageDidRendered && isMinimized && m_viewportConstraints.userScalable) {
636 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
637 setVisibleContentRect(m_visibleContentRect, newMinimumScale);
639 m_page->scalePage(newMinimumScale, m_visibleContentRect.location());
644 void PageClientImpl::pageScaleFactorDidChange()
646 ewk_view_focused_node_adjust(m_viewWidget);
648 #endif // #if OS(TIZEN)
650 void PageClientImpl::didCommitLoadForMainFrame(bool)
653 m_pageDidRendered = false;
654 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
655 m_restoredScaleFactor = 0;
662 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
667 double PageClientImpl::customRepresentationZoomFactor()
673 void PageClientImpl::setCustomRepresentationZoomFactor(double)
678 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
683 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
688 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
693 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
695 Ewk_Download_Job* ewkDownload = ewk_download_job_new(download, m_viewWidget);
696 // For now we only support one default context, but once we support
697 // multiple contexts, we will need to retrieve the context from the
699 ewk_context_download_job_add(ewk_context_default_get(), ewkDownload);
700 ewk_download_job_unref(ewkDownload);
703 #if USE(TILED_BACKING_STORE)
704 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
706 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
707 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewWidget));
708 if (smartData->api->formdata_candidate_is_showing(smartData))
711 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
712 IntPoint newPoint = point;
713 newPoint.scale(scaleFactor(), scaleFactor());
714 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
720 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
721 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
723 m_restoredScrollPosition = point;
724 m_restoredScrollPosition.scale(scale, scale);
725 m_restoredScaleFactor = scale;
727 // Before contents size is fixed, just update visible content rect's position
728 m_visibleContentRect.setLocation(m_restoredScrollPosition);
732 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
733 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
735 if (value == m_formDataCandidate->getCandidateValue()) {
736 m_formDataCandidate->updateCandidateValue(emptyString());
740 m_formDataCandidate->updateCandidateValue(value);
741 ewk_view_text_change_in_textfield(m_viewWidget, name, value);
745 #if ENABLE(TIZEN_ISF_PORT)
746 void PageClientImpl::setInputMethodState(bool active, const String& type, const String& value)
749 ewk_view_imf_context_hide(m_viewWidget);
750 LOG(ISF, "- Keypad status : hide\n");
754 Ewk_Settings* settings = ewk_view_settings_get(m_viewWidget);
755 bool defaultKeypadEnabled = ewk_settings_default_keypad_enabled_get(settings);
757 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
758 if (m_clipboardHelper->isClipboardWindowOpened()) {
759 LOG(ISF, "[FAIL] Clipboard\n");
764 LOG(ISF, "- Type (%s), Value (%s)\n", type.utf8().data(), value.utf8().data());
766 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
767 if (type == "date") {
768 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATE, value);
770 } else if (type == "datetime") {
771 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIME, value);
773 } else if (type == "datetime-local") {
774 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_DATETIMELOCAL, value);
776 } else if (type == "month") {
777 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_MONTH, value);
779 } else if (type == "time") {
780 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_TIME, value);
782 } else if (type == "week") {
783 ewkViewInputPickerRequest(m_viewWidget, EWK_INPUT_TYPE_WEEK, value);
787 #if ENABLE(TIZEN_DATALIST_ELEMENT)
788 Vector<String> optionList = page()->getFocusedInputElementDataList();
789 if (optionList.size() > 0) {
791 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TELEPHONE, optionList);
792 else if (type == "number")
793 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_NUMBER, optionList);
794 else if (type == "email")
795 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_EMAIL, optionList);
796 else if (type == "url")
797 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_URL, optionList);
799 ewkViewDataListShowRequest(m_viewWidget, EWK_INPUT_TYPE_TEXT, optionList);
803 #endif // ENABLE(TIZEN_DATALIST_ELEMENT)
804 #endif // ENABLE(TIZEN_INPUT_TAG_EXTENSION)
806 bool hasFocus = evas_object_focus_get(m_viewWidget);
808 if (!defaultKeypadEnabled) {
809 ewk_view_imf_context_destroy(m_viewWidget);
811 Eina_Rectangle dummyRectForCustomKeypadCallback;
812 memset(&dummyRectForCustomKeypadCallback, 0, sizeof(Eina_Rectangle));
813 evas_object_smart_callback_call(m_viewWidget, "inputmethod,changed", &dummyRectForCustomKeypadCallback);
818 Ecore_IMF_Input_Panel_Layout layout;
819 if (type == "number")
820 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER;
821 else if (type == "email")
822 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL;
823 else if (type == "url")
824 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_URL;
825 else if (type == "tel")
826 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
827 else if (type == "password")
828 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD;
830 layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
832 Ecore_IMF_Context* imfContext = ewk_view_imf_context_set(m_viewWidget, layout);
836 if (type == "password")
837 ecore_imf_context_prediction_allow_set(imfContext, false);
839 ecore_imf_context_prediction_allow_set(imfContext, true);
841 if (type.isEmpty() || type == "textarea")
842 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE);
844 ecore_imf_context_autocapital_type_set(imfContext, ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
846 Evas* evas = evas_object_evas_get(m_viewWidget);
847 ecore_imf_context_client_window_set(imfContext, (void*)ecore_evas_window_get(ecore_evas_ecore_evas_get(evas)));
848 ecore_imf_context_client_canvas_set(imfContext, evas);
850 #if ENABLE(TIZEN_SUPPORT_EMOJI)
851 if (type.isEmpty() && !value.isEmpty()) {
852 CString emojiSetting = value.utf8();
853 ecore_imf_context_input_panel_imdata_set(imfContext, emojiSetting.data(), emojiSetting.length());
860 ecore_imf_context_focus_in(imfContext);
861 ecore_imf_context_input_panel_show(imfContext);
862 ecore_imf_context_cursor_position_set(imfContext, page()->getCursorOffset());
864 // input field zoom for external keyboard
865 ewk_view_focused_node_adjust(m_viewWidget, EINA_TRUE);
867 LOG(ISF, "- Keypad status : show\n");
870 void PageClientImpl::setInputMethodState(bool) { }
871 #endif // #if ENABLE(TIZEN_ISF_PORT)
873 #if ENABLE(TIZEN_ISF_PORT)
874 void PageClientImpl::updateTextInputState()
876 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
877 m_textSelection->update();
881 void PageClientImpl::updateCursorOffset(int offset)
883 Ecore_IMF_Context* imfContext = ewk_view_imf_context_get(m_viewWidget);
887 ecore_imf_context_cursor_position_set(imfContext, offset);
890 void PageClientImpl::imContextCommitted(Ecore_IMF_Context* context, char* string)
892 if (!page()->focusedFrame())
895 page()->confirmComposition(String::fromUTF8(string));
898 void PageClientImpl::imContextPreeditChanged(Ecore_IMF_Context* context)
900 if (!page()->focusedFrame())
903 char* preeditStr = 0;
904 Eina_List* preeditAttrs = 0;
905 int cursorPosition = 0;
907 ecore_imf_context_preedit_string_with_attributes_get(context, &preeditStr, &preeditAttrs, &cursorPosition);
911 EINA_LIST_FREE(preeditAttrs, item)
918 page()->getCaretPosition(caretRect);
919 caretRect.scale(scaleFactor());
922 evas_object_geometry_get(m_viewWidget, &viewX, &viewY, 0, 0);
924 int x = caretRect.x() - scrollPosition().x() + viewX;
925 int y = caretRect.y() - scrollPosition().y() + viewY;
926 int w = caretRect.width();
927 int h = caretRect.height();
928 ecore_imf_context_cursor_location_set(context, x, y, w, h);
930 String preeditString = String::fromUTF8(preeditStr);
934 Vector<CompositionUnderline> underlines;
936 #if ENABLE(TIZEN_WEBKIT2_SUPPORT_JAPANESE_IME)
938 Eina_List* listIterator = 0;
940 EINA_LIST_FOREACH(preeditAttrs, listIterator, item) {
941 Ecore_IMF_Preedit_Attr* preeditAttr = static_cast<Ecore_IMF_Preedit_Attr*>(item);
943 switch (preeditAttr->preedit_type) {
944 case ECORE_IMF_PREEDIT_TYPE_SUB1:
945 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), false));
947 case ECORE_IMF_PREEDIT_TYPE_SUB2:
948 case ECORE_IMF_PREEDIT_TYPE_SUB3:
949 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(255, 255, 255), false));
951 case ECORE_IMF_PREEDIT_TYPE_SUB4:
952 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(46, 168, 255), false));
954 case ECORE_IMF_PREEDIT_TYPE_SUB5:
955 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 98, 195), false));
957 case ECORE_IMF_PREEDIT_TYPE_SUB6:
958 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(118, 222, 55), false));
960 case ECORE_IMF_PREEDIT_TYPE_SUB7:
961 underlines.append(CompositionUnderline(preeditAttr->start_index, preeditAttr->end_index, Color(0, 0, 0), Color(153, 153, 153), false));
965 EINA_LIST_FREE(preeditAttrs, item)
969 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
971 underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
974 page()->setComposition(preeditString, underlines, cursorPosition);
976 #endif // #if ENABLE(TIZEN_ISF_PORT)
978 void PageClientImpl::updateFormNavigation(int length, int offset)
983 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
984 // Before rendering, scale factor and scroll position is different from m_viewImpl.
985 float PageClientImpl::scaleFactor()
987 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
990 const IntPoint PageClientImpl::scrollPosition()
992 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
995 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
997 IntSize contentsSize = page()->contentsSize();
998 contentsSize.scale(targetScale);
999 if (contentsSize.width() < visibleContentRect.width())
1000 visibleContentRect.setX(0);
1002 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
1004 if (contentsSize.height() < visibleContentRect.height())
1005 visibleContentRect.setY(0);
1007 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
1008 return visibleContentRect;
1011 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
1013 #if ENABLE(TIZEN_SCREEN_READER)
1014 IntPoint previousScrollPosition(scrollPosition());
1015 float previousScale = m_scaleFactor;
1018 m_scaleFactor = adjustScaleWithViewport(newScale);
1019 m_visibleContentRect.setLocation(newRect.location());
1020 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
1022 // update both drawing scale factor and scroll position after page is rendered
1023 if (m_pageDidRendered) {
1024 if (!m_hasSuspendedContent) {
1025 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
1026 // PageViewport's values are updated when resuming content in the webkit opensource,
1027 // but we have to update viewImpl's values here to sync with PageClient's values.
1028 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
1029 // The values will be updated when resuming content.
1030 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1031 m_viewImpl->setScaleFactor(m_scaleFactor);
1032 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
1036 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
1037 // So we removed enclosingIntRect and replaced with floorf and ceilf.
1038 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
1039 floorf(m_visibleContentRect.y() / m_scaleFactor),
1040 ceilf(m_visibleContentRect.width() / m_scaleFactor),
1041 ceilf(m_visibleContentRect.height() / m_scaleFactor));
1044 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
1045 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1046 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
1047 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
1051 #if ENABLE(TIZEN_SCREEN_READER)
1052 if (ScreenReaderProxy::screenReader().isEnabled()
1053 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
1054 ewkViewGetFocusRing(m_viewWidget)->updateScrollAndScale(previousScrollPosition, previousScale);
1057 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1058 if (!isClipboardWindowOpened())
1059 updateTextSelectionHandlesAndContextMenu(true);
1063 void PageClientImpl::displayViewport()
1065 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1067 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1071 #if ENABLE(TIZEN_SCREEN_READER)
1072 m_page->recalcScreenReaderFocusRect();
1076 void PageClientImpl::drawContents()
1080 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
1082 cairo_save(context);
1083 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
1084 cairo_transform(context, &matrix);
1086 if (drawingArea()) {
1087 if (drawingArea()->layerTreeCoordinatorProxy()) {
1088 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1089 renderer->paintToGraphicsContext(context, m_bgColor);
1093 cairo_restore(context);
1096 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
1098 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1099 // We don't want to process scaling in the FullScreen mode.
1100 if (page()->fullScreenManager()->isFullScreen())
1104 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1105 m_textSelection->hideHandlers();
1108 // Adjust scaleFactor.
1109 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
1110 if (!page()->pageGroup()->preferences()->textZoomEnabled())
1111 scaleFactor = adjustScaleWithViewport(scaleFactor);
1113 scaleFactor = adjustScaleWithViewport(scaleFactor);
1116 scaleContents(scaleFactor, scrollPosition);
1119 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
1121 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
1122 // We don't want to process scaling in the FullScreen mode.
1123 if (page()->fullScreenManager()->isFullScreen())
1126 scaleFactor = adjustScaleWithViewport(scaleFactor);
1128 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
1131 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
1132 // so below code should be replaced when PageViewportController codes are merged.
1133 // Please do not use below codes. They are only for scaling contents.
1134 void PageClientImpl::suspendContent()
1136 if (m_hasSuspendedContent)
1139 m_hasSuspendedContent = true;
1142 void PageClientImpl::resumeContent()
1144 if (!m_hasSuspendedContent)
1147 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
1148 // The concept is that the values of EwkViewImpl and PageClient can be different
1149 // during suspending content and they become same when content is resumed.
1150 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
1151 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
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_viewImpl->scrollPosition().x());
1208 if (m_verticalScrollbar) {
1209 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
1210 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().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 m_pageDidRendered = true;
1513 initializeVisibleContentRect();
1517 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1518 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1520 setIsScrollableLayerFocused(false);
1521 setIsScrollableNodeFocused(false);
1525 setIsScrollableLayerFocused(true);
1526 m_page->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1528 setIsScrollableNodeFocused(true);
1533 void PageClientImpl::findScrollableNode(const IntPoint& point)
1535 if (m_page && m_page->isLoadingFinished() && m_page->askOverflow()) {
1536 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1537 WebLayerID webLayerID = 0;
1538 bool checkOverflowLayer = false;
1539 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1540 DrawingAreaProxy* drawingArea = m_page->drawingArea();
1541 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1543 setOverflowResult(m_page->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1548 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1549 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1551 WebCore::IntPoint startPoint, endPoint;
1552 WebCore::IntRect leftRect, rightRect;
1554 WebCore::IntRect caretRect;
1555 page()->getCaretPosition(caretRect);
1556 if (!caretRect.isEmpty()) {
1557 startPoint.setX(caretRect.x());
1558 startPoint.setY(caretRect.y() + caretRect.height());
1560 endPoint.setX(caretRect.x() + caretRect.width());
1561 endPoint.setY(caretRect.y() + caretRect.height());
1563 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1564 else if (page()->getSelectionHandlers(leftRect, rightRect)) {
1565 startPoint.setX(leftRect.x());
1566 startPoint.setY(leftRect.y() + leftRect.height());
1568 endPoint.setX(rightRect.x() + rightRect.width());
1569 endPoint.setY(rightRect.y() + rightRect.height());
1573 startPoint.scale(scaleFactor(), scaleFactor());
1574 endPoint.scale(scaleFactor(), scaleFactor());
1576 int viewPositionX, viewPositionY;
1577 evas_object_geometry_get(m_viewWidget, &viewPositionX, &viewPositionY, NULL, NULL);
1579 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1580 startPoint.move(viewPositionX, viewPositionY);
1582 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1583 endPoint.move(viewPositionX, viewPositionY);
1585 ewkViewDidGetTextStyleStateForSelection(m_viewWidget, underlineState, italicState, boldState, startPoint, endPoint);
1589 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1591 ewk_view_zoomable_area_set(m_viewWidget, target, area);
1594 #if ENABLE(TIZEN_ICON_DATABASE)
1595 void PageClientImpl::didReceiveIcon()
1597 ewkViewIconReceived(viewWidget());
1601 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1602 void PageClientImpl::hideFocusRing()
1604 ewkViewFocusRingHide(viewWidget());
1607 #endif // #if OS(TIZEN)
1610 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1611 PageClientEvasGL::PageClientEvasGL(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewWidget)
1612 : PageClientImpl(context, pageGroup, viewWidget)
1618 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1621 , m_isAcceleratedCompositingModeInitialized(false)
1623 initializeAcceleratedCompositingMode();
1626 PageClientEvasGL::~PageClientEvasGL()
1631 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1634 evas_gl_surface_destroy(m_evasGL, m_surface);
1639 PageClientImpl::updateViewportSize(viewportSize);
1642 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1644 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1647 ewk_view_display(viewWidget(), rect);
1649 #if ENABLE(TIZEN_SCREEN_READER)
1650 if (rect.intersects(ewkViewGetFocusRing(m_viewWidget)->rect()))
1651 m_page->recalcScreenReaderFocusRect();
1655 void PageClientEvasGL::displayViewport()
1657 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1658 // We should not draw here when Direct Rendering is enabled.
1659 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1660 ewk_view_mark_for_sync(m_viewWidget);
1662 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1665 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1669 #if ENABLE(TIZEN_SCREEN_READER)
1670 m_page->recalcScreenReaderFocusRect();
1674 void PageClientEvasGL::drawContents()
1676 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1679 WebCore::TransformationMatrix matrix;
1681 IntSize ewkViewSize = viewSize();
1683 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1684 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewWidget));
1685 m_angle = ecore_evas_rotation_get(ee);
1687 drawingArea()->setAngle(m_angle);
1688 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1690 if (m_angle == 90 || m_angle == 270) {
1691 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1693 matrix.translate(-ewkViewSize.width(), 0);
1694 else if (m_angle == 270)
1695 matrix.translate(0, -ewkViewSize.height());
1696 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1698 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1700 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1701 clipRect = IntRect(IntPoint(), ewkViewSize);
1704 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1705 clipRect = IntRect(IntPoint(), ewkViewSize);
1707 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1709 if (drawingArea()) {
1710 if (drawingArea()->layerTreeCoordinatorProxy()) {
1711 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1712 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1713 if (m_shouldMakeBackupTexture) {
1714 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1715 glClearColor(1, 1, 1, 1);
1716 glClear(GL_COLOR_BUFFER_BIT);
1717 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1718 m_shouldMakeBackupTexture = false;
1719 } else if (m_shouldShowBackupTexture) {
1720 matrix.makeIdentity();
1721 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1722 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1725 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1730 void PageClientEvasGL::didRenderFrame()
1732 ewkViewFrameRendered(m_viewWidget);
1733 PageClientImpl::didRenderFrame();
1736 bool PageClientEvasGL::makeContextCurrent()
1738 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1741 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1743 Evas* evas = evas_object_evas_get(viewWidget());
1745 m_config = evas_gl_config_new();
1746 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1747 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1748 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1750 m_config->color_format = EVAS_GL_RGBA_8888;
1751 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1752 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1754 m_evasGL = evas_gl_new(evas);
1756 evas_gl_config_free(m_config);
1758 TIZEN_LOGE("failed to create evas_gl");
1762 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1764 evas_gl_free(m_evasGL);
1766 evas_gl_config_free(m_config);
1768 TIZEN_LOGE("failed to get evas_gl_api");
1771 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1773 m_context = evas_gl_context_create(m_evasGL, 0);
1775 evas_gl_free(m_evasGL);
1777 evas_gl_config_free(m_config);
1779 TIZEN_LOGE("failed to create evas_gl_context");
1784 m_isAcceleratedCompositingModeInitialized = true;
1787 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1791 evas_gl_surface_destroy(m_evasGL, m_surface);
1795 evas_gl_context_destroy(m_evasGL, m_context);
1799 evas_gl_config_free(m_config);
1802 evas_gl_free(m_evasGL);
1806 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1807 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1809 m_isAcceleratedCompositingModeInitialized = false;
1812 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1814 if (!m_isAcceleratedCompositingModeInitialized)
1815 initializeAcceleratedCompositingMode();
1818 void PageClientEvasGL::exitAcceleratedCompositingMode()
1820 if (m_isAcceleratedCompositingModeInitialized)
1821 finalizeAcceleratedCompositingMode();
1824 void PageClientEvasGL::setTargetSurface()
1830 evas_object_geometry_get(viewWidget(), 0, 0, &width, &height);
1831 if (width == 0 || height == 0)
1834 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1836 TIZEN_LOGE("failed to create Evas_GL_Surface");
1840 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1841 makeContextCurrent();
1843 if (makeContextCurrent()) {
1844 glViewport(0, 0, width, height);
1845 glClearColor(1.0, 1.0, 1.0, 1.0);
1846 glClear(GL_COLOR_BUFFER_BIT);
1851 Evas_Native_Surface nativeSurface;
1852 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1853 ewk_view_image_native_surface_set(viewWidget(), &nativeSurface);
1857 } // namespace WebKit