2 * Copyright (C) 2011 Samsung Electronics
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "PageClientImpl.h"
29 #include "EwkViewImpl.h"
30 #include "InputMethodContextEfl.h"
31 #include "NativeWebKeyboardEvent.h"
32 #include "NotImplemented.h"
33 #include "TransformationMatrix.h"
34 #include "WebContext.h"
35 #include "WebContextMenuProxy.h"
36 #include "WebPageProxy.h"
37 #include "WebPopupMenuProxyEfl.h"
38 #include "ewk_context.h"
39 #include "ewk_context_private.h"
40 #include "ewk_download_job.h"
41 #include "ewk_download_job_private.h"
45 #include "DrawingAreaProxyImpl.h"
47 #include "EflScreenUtilities.h"
48 #include "LayerTreeCoordinatorProxy.h"
49 #include "OpenGLShims.h"
50 #include "WebContextMenuProxyTizen.h"
51 #include "WebLayerTreeRenderer.h"
52 #include "WebPageGroup.h"
53 #include "WebPageMessages.h"
54 #include "WebPopupMenuProxyEfl.h"
55 #include "WebPreferences.h"
57 #include <Ecore_Evas.h>
60 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
61 #include "MainFrameScrollbarTizen.h"
64 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
65 #include "ClipboardHelper.h"
68 #if ENABLE(TIZEN_DRAG_SUPPORT)
73 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
74 #include "ewk_context_private.h"
77 #if ENABLE(TIZEN_SCREEN_READER)
78 #include "ScreenReaderProxy.h"
81 using namespace WebCore;
86 PageClientImpl::PageClientImpl(EwkViewImpl* viewImpl)
87 : m_viewImpl(viewImpl)
89 , m_viewportConstraints()
90 , m_viewFocused(false)
91 , m_viewWindowActive(true)
92 , m_pageDidRendered(false)
93 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
94 , m_visibleContentRect(IntRect())
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);
119 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
120 m_textSelection = TextSelection::create(m_viewImpl);
122 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
123 m_offlinePageSave = OfflinePageSave::create(m_viewImpl);
125 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
126 m_clipboardHelper = ClipboardHelper::create(m_viewImpl);
128 #if ENABLE(TIZEN_DRAG_SUPPORT)
129 m_drag = Drag::create(m_viewImpl);
131 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
132 m_formDataCandidate = FormDataCandidate::create(m_viewImpl);
136 setBackgroundColor(1, 1, 1, 1);
139 PageClientImpl::~PageClientImpl()
141 m_viewImpl->page()->close();
145 PageClientImpl::ViewportConstraints PageClientImpl::computeViewportConstraints(const WebCore::ViewportAttributes& attributes)
147 PageClientImpl::ViewportConstraints constraints;
148 constraints.minimumScale = attributes.minimumScale * attributes.devicePixelRatio;
149 constraints.maximumScale = attributes.maximumScale * attributes.devicePixelRatio;
150 constraints.userScalable = attributes.userScalable;
151 constraints.layoutSize = attributes.layoutSize;
152 constraints.contentsDefinedInitialScale = (ViewportArguments::ValueAuto != attributes.initialScale);
154 double defaultViewLevel = m_viewImpl->page()->pageGroup()->preferences()->defaultViewLevel();
155 // If defaultViewLevel is 1, "Default View" is set as "Readable"
156 // if not, "Default View" is set as "Fit to width"
157 if (defaultViewLevel) {
158 // if content doesn't set initial scale value, set readable scale factor
159 // if not, set initial scale factor of viewport attribute
160 if (attributes.initialScale == ViewportArguments::ValueAuto)
161 constraints.initialScale = m_viewImpl->page()->deviceScaleFactor();
163 constraints.initialScale = attributes.initialScale * attributes.devicePixelRatio;
165 // Minimize initial scale factor
166 constraints.initialScale = attributes.minimumScale * attributes.devicePixelRatio;
169 // adjust scale with both minimum and maximum scale factor
170 constraints.initialScale = clampTo(constraints.initialScale, constraints.minimumScale, constraints.maximumScale);
175 double PageClientImpl::adjustScaleWithViewport(double scale)
177 return clampTo(scale, m_viewportConstraints.minimumScale, m_viewportConstraints.maximumScale);
180 #if USE(TILED_BACKING_STORE) && ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
181 void PageClientImpl::updateViewportSize(const IntSize& viewportSize)
183 // update device width & height
184 int deviceWidth = WebCore::getDefaultScreenResolution().width();
185 int deviceHeight = WebCore::getDefaultScreenResolution().height();
186 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
187 int angle = ecore_evas_rotation_get(ee);
188 if (angle == 90 || angle == 270) {
189 int tempWidth = deviceWidth;
190 deviceWidth = deviceHeight;
191 deviceHeight = tempWidth;
193 m_viewImpl->page()->pageGroup()->preferences()->setDeviceWidth(deviceWidth);
194 m_viewImpl->page()->pageGroup()->preferences()->setDeviceHeight(deviceHeight);
196 // update viewport size of webkit
197 m_visibleContentRect.setSize(viewportSize);
199 // Update visible content rect before resize viewport
200 // setVisibleContentRect() should be called once at here or ewk_view_focused_node_adjust()
201 if (!ewk_view_focused_node_adjust(m_viewImpl->view()) && m_pageDidRendered)
202 setVisibleContentRect(m_visibleContentRect, scaleFactor());
204 m_viewImpl->page()->setViewportSize(viewportSize);
208 void PageClientImpl::initializeVisibleContentRect()
210 _ewk_view_resume_painting(m_viewImpl->view());
212 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
213 IntPoint initialScrollPosition;
214 float initialScaleFactor = m_viewportConstraints.initialScale;
215 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
216 // if scroll position and scale factor are restored by history controller,
217 // move scroll position and scale factor with them
218 if (m_restoredScaleFactor) {
219 initialScrollPosition = m_restoredScrollPosition;
220 initialScaleFactor = m_restoredScaleFactor;
223 setVisibleContentRect(IntRect(initialScrollPosition, m_visibleContentRect.size()), initialScaleFactor);
225 // Set initial scale.
226 m_viewImpl->page()->scalePage(m_viewportConstraints.initialScale, IntPoint(0, 0));
230 void PageClientImpl::setFocusedNodeRect(const IntRect& focusedNodeRect)
232 m_focusedNodeRect = focusedNodeRect;
235 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
236 bool PageClientImpl::scrollBy(IntSize scrollOffset)
238 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
239 // scrollOffset means device screen coordiate, not an actual offset of contents.
240 // Therefore, scrollOffset should be nomalized in order to make a tiled backing store
241 // in the actual scale.
242 IntSize scaledScrollOffset = m_viewImpl->transformFromScene().mapSize(scrollOffset);
243 if ((m_isScrollableLayerFocused || m_isScrollableNodeFocused)
244 && m_viewImpl->page()->scrollOverflow(FloatPoint(scaledScrollOffset.width(), scaledScrollOffset.height()))) {
250 IntPoint oldScrollPosition = scrollPosition();
251 setVisibleContentRect(IntRect(oldScrollPosition + scrollOffset, m_visibleContentRect.size()), scaleFactor(), FloatPoint(scrollOffset.width(), scrollOffset.height()));
256 void PageClientImpl::scrollTo(IntPoint requestedScrollPosition)
258 setVisibleContentRect(IntRect(requestedScrollPosition, m_visibleContentRect.size()), scaleFactor());
260 #endif // #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
262 #endif // #if OS(TIZEN)
264 EwkViewImpl* PageClientImpl::viewImpl() const
270 PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
272 return DrawingAreaProxyImpl::create(m_viewImpl->page());
275 void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
278 ewk_view_mark_for_sync(m_viewImpl->view());
280 m_viewImpl->redrawRegion(rect);
283 #if ENABLE(TIZEN_SCREEN_READER)
284 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
285 m_viewImpl->page()->recalcScreenReaderFocusRect();
289 void PageClientImpl::displayView()
294 void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
296 setViewNeedsDisplay(scrollRect);
299 WebCore::IntSize PageClientImpl::viewSize()
301 return m_viewImpl->size();
304 bool PageClientImpl::isViewVisible()
309 return m_viewImpl->isVisible();
313 bool PageClientImpl::isViewInWindow()
319 void PageClientImpl::processDidCrash()
321 // Check if loading was ongoing, when web process crashed.
322 double loadProgress = ewk_view_load_progress_get(m_viewImpl->view());
323 if (loadProgress >= 0 && loadProgress < 1)
324 m_viewImpl->informLoadProgress(1);
326 m_viewImpl->informWebProcessCrashed();
329 void PageClientImpl::didRelaunchProcess()
331 const char* themePath = m_viewImpl->themePath();
333 m_viewImpl->page()->setThemePath(themePath);
336 void PageClientImpl::pageClosed()
341 void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
343 m_viewImpl->informTooltipTextChange(newToolTip);
346 void PageClientImpl::setCursor(const Cursor& cursor)
348 m_viewImpl->setCursor(cursor);
351 void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
356 void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes& attributes)
358 float prevMinimumScale = m_viewportConstraints.minimumScale;
359 m_viewportConstraints = computeViewportConstraints(attributes);
360 // setVisibleContentRect() is called to adjust visible content rect after device rotation
361 // In below cases, it shouldn't be called
362 // 1. page is not rendered yet
363 // 2. viewport attributes are changed by WebCore's empty document(progress == 0.1)
364 // 3. there's no input field zoom(device rotation without IME)
365 if (m_pageDidRendered && m_viewImpl->page()->estimatedProgress() > 0.1 && !ewk_view_focused_node_adjust(m_viewImpl->view())) {
366 IntSize contentsSize = m_viewImpl->page()->contentsSize();
367 double minimumScaleByContentWidth = max(((double)viewSize().width() / contentsSize.width()), 0.25);
368 float newScale = scaleFactor();
370 // If contents width exceeds viewport layout width and content is userScalable, update minimumScale.
371 if (m_viewportConstraints.userScalable)
372 m_viewportConstraints.minimumScale = minimumScaleByContentWidth;
374 // If zoom was fitted to width before the rotation, newScale should be fitted to width again.
375 if (fabs(scaleFactor() - prevMinimumScale) < numeric_limits<double>::epsilon())
376 newScale = m_viewportConstraints.minimumScale;
377 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
378 setVisibleContentRect(m_visibleContentRect, newScale);
380 m_viewImpl->page()->scalePage(newScale, m_visibleContentRect.location());
384 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
385 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
386 if (smartData->api->formdata_candidate_is_showing(smartData))
387 smartData->api->formdata_candidate_hide(smartData);
392 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
394 if (undoOrRedo == WebPageProxy::Undo) {
395 m_undoCommands.append(command);
397 int undoSize = m_undoCommands.size();
398 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
401 m_redoCommands.append(command);
403 int redoSize = m_redoCommands.size();
404 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
408 void PageClientImpl::clearAllEditCommands()
410 m_undoCommands.clear();
411 m_redoCommands.clear();
413 int undoSize = m_undoCommands.size();
414 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
416 int redoSize = m_redoCommands.size();
417 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
420 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
422 if (undoOrRedo == WebPageProxy::Undo)
423 return !m_undoCommands.isEmpty();
425 return !m_redoCommands.isEmpty();
428 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
430 if (undoOrRedo == WebPageProxy::Undo) {
431 m_undoCommands.last()->unapply();
432 m_undoCommands.removeLast();
434 int undoSize = m_undoCommands.size();
435 evas_object_smart_callback_call(m_viewImpl->view(), "undo,size", &undoSize);
437 m_redoCommands.last()->reapply();
438 m_redoCommands.removeLast();
440 int redoSize = m_redoCommands.size();
441 evas_object_smart_callback_call(m_viewImpl->view(), "redo,size", &redoSize);
445 void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
450 void PageClientImpl::clearAllEditCommands()
455 bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
461 void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
467 FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
473 FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
479 IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
485 IntRect PageClientImpl::windowToScreen(const IntRect&)
491 void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
496 #if ENABLE(GESTURE_EVENTS)
497 void PageClientImpl::doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled)
503 #if ENABLE(TOUCH_EVENTS)
504 void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
507 ewk_view_touch_event_handler_result_set(m_viewImpl->view(), event.type(), wasEventHandled);
510 #endif // #if OS(TIZEN)
514 PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
516 return WebPopupMenuProxyEfl::create(m_viewImpl, page);
519 PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
521 #if ENABLE(TIZEN_CONTEXT_MENU_WEBKIT_2)
522 return WebContextMenuProxyTizen::create(m_viewImpl->view(), page, this);
529 #if ENABLE(INPUT_TYPE_COLOR)
530 PassRefPtr<WebColorChooserProxy> PageClientImpl::createColorChooserProxy(WebPageProxy*, const WebCore::Color&)
537 void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
543 #if USE(ACCELERATED_COMPOSITING)
544 void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
546 m_viewImpl->enterAcceleratedCompositingMode();
549 void PageClientImpl::exitAcceleratedCompositingMode()
551 m_viewImpl->exitAcceleratedCompositingMode();
554 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
558 #endif // USE(ACCELERATED_COMPOSITING)
561 void PageClientImpl::initializeAcceleratedCompositingMode()
565 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
566 void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&)
570 #endif // ENABLE(TIZEN_WEBKIT2_TILED_AC)
572 void PageClientImpl::setBackgroundColor(double red, double green, double blue, double alpha)
574 WebCore::RGBA32 rgba= WebCore::makeRGBA32FromFloats((float)red, (float)green, (float)blue, (float)alpha);
575 m_bgColor.setRGB(rgba);
578 void PageClientImpl::didChangeScrollbarsForMainFrame() const
584 void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
586 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
587 m_initialViewRect.setSize(viewSize());
591 void PageClientImpl::didChangeContentsSize(const WebCore::IntSize size)
593 #if USE(TILED_BACKING_STORE)
597 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
598 if (drawingArea()->layerTreeCoordinatorProxy())
599 drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height()));
602 // But we should recalculate this when viewport argument's minimum scale is not fixed.
603 // if contents' width exceeds viewport layout width and userScalable is true.
604 // And minimumScaleByContentWidth shouldn't be smaller than 0.25(minimum zoom level)
605 double oldMinimumScale = m_viewportConstraints.minimumScale;
606 double newMinimumScale = max(((double)viewSize().width() / size.width()), 0.25);
607 bool isMinimized = fabs(scaleFactor() - oldMinimumScale) < numeric_limits<float>::epsilon();
609 // if minimum scale factor is changed, update minimumScale.
610 if (m_viewportConstraints.userScalable
611 && fabs(oldMinimumScale - newMinimumScale) > numeric_limits<float>::epsilon()) {
612 // Sometimes initializeVisibleContentRect can be called after content size change.
613 // So, if initialScale is not set explicitly in content's meta viewport tag and is same to minimumScale, update initialScale too.
614 if (!m_viewportConstraints.contentsDefinedInitialScale
615 && fabs(m_viewportConstraints.initialScale - oldMinimumScale) < numeric_limits<float>::epsilon())
616 m_viewportConstraints.initialScale = newMinimumScale;
617 m_viewportConstraints.minimumScale = newMinimumScale;
620 // If current scale factor was minimized, minimize new scale factor
621 if (m_pageDidRendered && isMinimized && m_viewportConstraints.userScalable) {
622 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
623 setVisibleContentRect(m_visibleContentRect, newMinimumScale);
625 m_viewImpl->page()->scalePage(newMinimumScale, m_visibleContentRect.location());
629 m_viewImpl->informContentsSizeChange(size);
633 void PageClientImpl::pageScaleFactorDidChange()
635 ewk_view_focused_node_adjust(m_viewImpl->view());
637 #endif // #if OS(TIZEN)
639 void PageClientImpl::didCommitLoadForMainFrame(bool)
642 m_pageDidRendered = false;
643 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
644 m_restoredScaleFactor = 0;
651 void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
656 double PageClientImpl::customRepresentationZoomFactor()
662 void PageClientImpl::setCustomRepresentationZoomFactor(double)
667 void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
672 void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
677 void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
682 void PageClientImpl::updateTextInputState()
684 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
685 if (inputMethodContext)
686 inputMethodContext->updateTextInputState();
688 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
689 m_textSelection->update();
693 void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
695 Ewk_Context* context = m_viewImpl->ewkContext();
696 context->downloadManager()->registerDownload(download, m_viewImpl);
699 #if USE(TILED_BACKING_STORE)
700 void PageClientImpl::pageDidRequestScroll(const IntPoint& point)
702 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
703 Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(evas_object_smart_data_get(m_viewImpl->view()));
704 if (smartData->api->formdata_candidate_is_showing(smartData))
707 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
708 IntPoint newPoint = point;
709 newPoint.scale(scaleFactor(), scaleFactor());
710 setVisibleContentRect(IntRect(newPoint, m_visibleContentRect.size()), scaleFactor());
716 #if ENABLE(TIZEN_WEBKIT2_HISTORICAL_RESTORE_VISIBLE_CONTENT_RECT)
717 void PageClientImpl::pageDidRequestRestoreVisibleContentRect(const IntPoint& point, float scale)
719 m_restoredScrollPosition = point;
720 m_restoredScrollPosition.scale(scale, scale);
721 m_restoredScaleFactor = scale;
723 // Before contents size is fixed, just update visible content rect's position
724 m_visibleContentRect.setLocation(m_restoredScrollPosition);
728 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
729 void PageClientImpl::textChangeInTextField(const String& name, const String& value)
731 if (value == m_formDataCandidate->getCandidateValue()) {
732 m_formDataCandidate->updateCandidateValue(emptyString());
736 m_formDataCandidate->updateCandidateValue(value);
737 ewk_view_text_change_in_textfield(m_viewImpl->view(), name, value);
741 void PageClientImpl::updateFormNavigation(int length, int offset)
746 #if ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
747 #if ENABLE(TIZEN_WEBKIT2_TILED_AC)
748 DrawingAreaProxy* PageClientImpl::drawingArea() const
750 return m_viewImpl->page()->drawingArea();
754 // Before rendering, scale factor and scroll position is different from m_viewImpl.
755 float PageClientImpl::scaleFactor()
757 return m_pageDidRendered ? m_viewImpl->scaleFactor() : (m_restoredScaleFactor ? m_restoredScaleFactor : m_viewportConstraints.initialScale);
760 const IntPoint PageClientImpl::scrollPosition()
762 return m_pageDidRendered ? m_viewImpl->scrollPosition() : (m_restoredScaleFactor ? m_restoredScrollPosition : IntPoint());
765 IntRect PageClientImpl::adjustVisibleContentRect(IntRect visibleContentRect, float targetScale)
767 IntSize contentsSize = m_viewImpl->page()->contentsSize();
768 contentsSize.scale(targetScale);
769 if (contentsSize.width() < visibleContentRect.width())
770 visibleContentRect.setX(0);
772 visibleContentRect.setX(clampTo(visibleContentRect.x(), 0, contentsSize.width() - visibleContentRect.width()));
774 if (contentsSize.height() < visibleContentRect.height())
775 visibleContentRect.setY(0);
777 visibleContentRect.setY(clampTo(visibleContentRect.y(), 0, contentsSize.height() - visibleContentRect.height()));
778 return visibleContentRect;
781 void PageClientImpl::setVisibleContentRect(const IntRect& newRect, float newScale, const FloatPoint& trajectory)
783 #if ENABLE(TIZEN_SCREEN_READER)
784 IntPoint previousScrollPosition(scrollPosition());
785 float previousScale = m_scaleFactor;
788 m_scaleFactor = adjustScaleWithViewport(newScale);
789 m_visibleContentRect.setLocation(newRect.location());
790 m_visibleContentRect = adjustVisibleContentRect(m_visibleContentRect, m_scaleFactor);
792 // update both drawing scale factor and scroll position after page is rendered
793 if (m_pageDidRendered) {
794 if (!m_hasSuspendedContent) {
795 // FIXME: We have to update EwkViewImpl's scale and position here because we use them to draw contents.
796 // PageViewport's values are updated when resuming content in the webkit opensource,
797 // but we have to update viewImpl's values here to sync with PageClient's values.
798 // However, We should not update them when hasSuspendedContent is true in order to maintain last values.
799 // The values will be updated when resuming content.
800 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
801 m_viewImpl->setScaleFactor(m_scaleFactor);
802 m_viewImpl->setScrollPosition(m_visibleContentRect.location());
806 // enclosingIntRect produces inconsistent width and height when scale factor is not 1.
807 // So we removed enclosingIntRect and replaced with floorf and ceilf.
808 IntRect mapToContentsVisibleContentRect = IntRect(floorf(m_visibleContentRect.x() / m_scaleFactor),
809 floorf(m_visibleContentRect.y() / m_scaleFactor),
810 ceilf(m_visibleContentRect.width() / m_scaleFactor),
811 ceilf(m_visibleContentRect.height() / m_scaleFactor));
814 drawingArea()->setVisibleContentsRect(mapToContentsVisibleContentRect, newScale, trajectory, FloatPoint(m_viewImpl->scrollPosition()));
815 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
816 // FIXME: We need to calculate exact visibleRect size here instead of mapToContentsVisibleContentRect.
817 drawingArea()->setVisibleContentsRectForScrollingContentsLayers(mapToContentsVisibleContentRect);
821 #if ENABLE(TIZEN_SCREEN_READER)
822 if (ScreenReaderProxy::screenReader().isEnabled()
823 && (scrollPosition() != previousScrollPosition || m_scaleFactor != previousScale))
824 ewkViewGetFocusRing(m_viewImpl->view())->updateScrollAndScale(previousScrollPosition, previousScale);
827 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
828 if (!isClipboardWindowOpened())
829 updateTextSelectionHandlesAndContextMenu(true);
833 void PageClientImpl::displayViewport()
835 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
837 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
841 #if ENABLE(TIZEN_SCREEN_READER)
842 m_viewImpl->page()->recalcScreenReaderFocusRect();
846 void PageClientImpl::drawContents()
850 void PageClientImpl::drawContents(BackingStore::PlatformGraphicsContext context)
853 const cairo_matrix_t matrix = cairo_matrix_t(m_viewImpl->transformToView());
854 cairo_transform(context, &matrix);
857 if (drawingArea()->layerTreeCoordinatorProxy()) {
858 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
859 renderer->paintToGraphicsContext(context, m_bgColor);
863 cairo_restore(context);
866 void PageClientImpl::scaleImage(double scaleFactor, IntPoint scrollPosition)
868 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
869 // We don't want to process scaling in the FullScreen mode.
870 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
874 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
875 m_textSelection->hideHandlers();
878 // Adjust scaleFactor.
879 #if ENABLE(TIZEN_WEBKIT2_TEXT_ZOOM)
880 if (!m_viewImpl->page()->pageGroup()->preferences()->textZoomEnabled())
881 scaleFactor = adjustScaleWithViewport(scaleFactor);
883 scaleFactor = adjustScaleWithViewport(scaleFactor);
886 scaleContents(scaleFactor, scrollPosition);
889 void PageClientImpl::scaleContents(double scaleFactor, const IntPoint& origin)
891 #if OS(TIZEN) && ENABLE(FULLSCREEN_API)
892 // We don't want to process scaling in the FullScreen mode.
893 if (m_viewImpl->page()->fullScreenManager()->isFullScreen())
896 scaleFactor = adjustScaleWithViewport(scaleFactor);
898 setVisibleContentRect(IntRect(origin, m_visibleContentRect.size()), scaleFactor);
901 // FIXME: The concept of suspending content comes from webkit opensource's PageViewportController,
902 // so below code should be replaced when PageViewportController codes are merged.
903 // Please do not use below codes. They are only for scaling contents.
904 void PageClientImpl::suspendContent()
906 if (m_hasSuspendedContent)
909 m_hasSuspendedContent = true;
912 void PageClientImpl::resumeContent()
914 if (!m_hasSuspendedContent)
917 // FIXME: Update visibleContentRect with m_viewImpl after resuming content.
918 // The concept is that the values of EwkViewImpl and PageClient can be different
919 // during suspending content and they become same when content is resumed.
920 // Below codes should be refactored when PageViewportController codes are merged into Tizen.
921 setVisibleContentRect(IntRect(m_viewImpl->scrollPosition(), m_visibleContentRect.size()), m_viewImpl->scaleFactor());
922 m_hasSuspendedContent = false;
925 FloatPoint PageClientImpl::boundContentsPositionAtScale(const FloatPoint& framePosition, float scale)
927 // We need to floor the viewport here as to allow aligning the content in device units. If not,
928 // it might not be possible to scroll the last pixel and that affects fixed position elements.
930 const IntSize& contentsSize = m_viewImpl->page()->contentsSize();
931 bounds.setWidth(std::max(0.f, contentsSize.width() - floorf(viewSize().width() / scale)));
932 bounds.setHeight(std::max(0.f, contentsSize.height() - floorf(viewSize().height() / scale)));
935 // Unfortunately it doesn't seem to be enough, so just always allow one pixel more.
936 position.setX(clampTo(framePosition.x(), bounds.x(), bounds.width() + 1));
937 position.setY(clampTo(framePosition.y(), bounds.y(), bounds.height() + 1));
942 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
943 void PageClientImpl::createScrollbarIfNeeded(bool horizontalBar, bool verticalBar)
946 if (horizontalBar && !m_horizontalScrollbar) {
947 m_horizontalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), HorizontalScrollbar);
948 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
949 m_horizontalScrollbar->setFrameRect(hBarRect);
950 } else if (!horizontalBar && m_horizontalScrollbar)
951 m_horizontalScrollbar = 0;
953 if (verticalBar && !m_verticalScrollbar) {
954 m_verticalScrollbar = MainFrameScrollbarTizen::createNativeScrollbar(m_viewImpl->view(), VerticalScrollbar);
955 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
956 m_verticalScrollbar->setFrameRect(vBarRect);
957 } else if (!verticalBar && m_verticalScrollbar)
958 m_verticalScrollbar = 0;
961 void PageClientImpl::updateScrollbar()
963 IntSize scaledContentsSize = m_viewImpl->page()->contentsSize();
964 scaledContentsSize.scale(scaleFactor());
966 bool newHasHorizontalScrollbar = false;
967 bool newVerticalScrollbar = false;
968 if (viewSize().width() < scaledContentsSize.width())
969 newHasHorizontalScrollbar = true;
970 if (viewSize().height() < scaledContentsSize.height())
971 newVerticalScrollbar = true;
972 createScrollbarIfNeeded(newHasHorizontalScrollbar, newVerticalScrollbar);
974 if (m_horizontalScrollbar) {
975 m_horizontalScrollbar->setProportion(viewSize().width(), scaledContentsSize.width());
976 m_horizontalScrollbar->setPosition(m_viewImpl->scrollPosition().x());
978 if (m_verticalScrollbar) {
979 m_verticalScrollbar->setProportion(viewSize().height(), scaledContentsSize.height());
980 m_verticalScrollbar->setPosition(m_viewImpl->scrollPosition().y());
984 void PageClientImpl::frameRectChanged()
986 if (m_horizontalScrollbar) {
987 IntRect hBarRect(0, viewSize().height(), viewSize().width(), 0);
988 m_horizontalScrollbar->setFrameRect(hBarRect);
990 if (m_verticalScrollbar) {
991 IntRect vBarRect(viewSize().width(), 0, 0, viewSize().height());
992 m_verticalScrollbar->setFrameRect(vBarRect);
996 void PageClientImpl::updateVisibility()
998 if (m_horizontalScrollbar)
999 m_horizontalScrollbar->updateVisibility();
1000 if (m_verticalScrollbar)
1001 m_verticalScrollbar->updateVisibility();
1004 #endif // ENABLE(TIZEN_WEBKIT2_TILED_BACKING_STORE)
1006 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1007 bool PageClientImpl::isTextSelectionDowned()
1009 return m_textSelection->isTextSelectionDowned();
1012 bool PageClientImpl::isTextSelectionMode()
1014 return m_textSelection->isTextSelectionMode();
1017 void PageClientImpl::setIsTextSelectionMode(bool isTextSelectionMode)
1019 m_textSelection->setIsTextSelectionMode(isTextSelectionMode);
1022 void PageClientImpl::updateTextSelectionHandlesAndContextMenu(bool isShow, bool isScrolling)
1024 if (m_textSelection->isTextSelectionMode() && evas_object_focus_get(m_viewImpl->view()))
1025 m_textSelection->updateHandlesAndContextMenu(isShow, isScrolling);
1028 bool PageClientImpl::textSelectionDown(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1030 if (!evas_object_focus_get(m_viewImpl->view())) {
1031 InputMethodContextEfl* inputMethodContext = m_viewImpl->inputMethodContext();
1032 if (inputMethodContext && !inputMethodContext->isShow())
1033 inputMethodContext->hideIMFContext();
1035 evas_object_focus_set(m_viewImpl->view(), true);
1038 return m_textSelection->textSelectionDown(point, isStartedTextSelectionFromOutside);
1041 void PageClientImpl::textSelectionMove(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1043 m_textSelection->textSelectionMove(point, isStartedTextSelectionFromOutside);
1046 void PageClientImpl::textSelectionUp(const WebCore::IntPoint& point, bool isStartedTextSelectionFromOutside)
1048 m_textSelection->textSelectionUp(point, isStartedTextSelectionFromOutside);
1051 bool PageClientImpl::isTextSelectionHandleDowned()
1053 return m_textSelection->isTextSelectionHandleDowned();
1056 #if ENABLE(TIZEN_WEBKIT2_FOR_MOVING_TEXT_SELECTION_HANDLE_FROM_OSP)
1057 void PageClientImpl::textSelectonHandleDown(const WebCore::IntPoint& point)
1059 m_textSelection->textSelectionHandleDown(point);
1062 void PageClientImpl::textSelectonHandleMove(const WebCore::IntPoint& point)
1064 m_textSelection->textSelectionHandleMove(point);
1067 void PageClientImpl::textSelectonHandleUp()
1069 m_textSelection->textSelectionHandleUp();
1073 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1074 void PageClientImpl::requestToShowTextSelectionHandlesAndContextMenu()
1076 m_textSelection->requestToShow();
1081 #if ENABLE(TIZEN_OFFLINE_PAGE_SAVE)
1082 void PageClientImpl::saveSerializedHTMLDataForMainPage(const String& serializedData, const String& fileName)
1084 m_offlinePageSave->saveSerializedHTMLDataForMainPage(serializedData, fileName);
1087 void PageClientImpl::saveSubresourcesData(Vector<WebSubresourceTizen>& subresourceData)
1089 m_offlinePageSave->saveSubresourcesData(subresourceData);
1092 void PageClientImpl::startOfflinePageSave(String& path, String& url, String& title)
1094 m_offlinePageSave->startOfflinePageSave(path, url, title);
1098 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1099 void PageClientImpl::pasteContextMenuSelected()
1101 m_clipboardHelper->pasteClipboardLastItem(m_viewImpl->page()->editorState().isContentRichlyEditable);
1105 #if ENABLE(TIZEN_CLIPBOARD) || ENABLE(TIZEN_PASTEBOARD)
1106 void PageClientImpl::setClipboardData(const String& data, const String& type)
1108 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1109 m_clipboardHelper->setData(data, type);
1113 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
1114 void PageClientImpl::clipboardContextMenuSelected()
1116 m_clipboardHelper->openClipboardWindow(m_viewImpl->page()->editorState().isContentRichlyEditable);
1119 bool PageClientImpl::isClipboardWindowOpened()
1121 return m_clipboardHelper->isClipboardWindowOpened();
1124 void PageClientImpl::clearClipboardSelectionHandler()
1126 m_clipboardHelper->clearClipboardSelectionHandler();
1130 void PageClientImpl::clearClipboardData()
1132 #if ENABLE(TIZEN_WEBKIT2_CLIPBOARD_HELPER)
1133 m_clipboardHelper->clear();
1138 #if ENABLE(TIZEN_WEBKIT2_VIEW_VISIBILITY)
1139 void PageClientImpl::setIsVisible(bool isVisible)
1141 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1142 if (m_isVisible != isVisible && m_viewImpl->view() && m_pageDidRendered) {
1143 if (!isVisible && (drawingArea() && drawingArea()->layerTreeCoordinatorProxy()) && !m_shouldShowBackupTexture) {
1144 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1145 int angle = ecore_evas_rotation_get(ee);
1146 if (angle == 0 || angle == 180) {
1147 m_shouldMakeBackupTexture = true;
1148 m_shouldShowBackupTexture = true;
1155 m_isVisible = isVisible;
1157 WebPageProxy* pageProxy = m_viewImpl->page();
1159 pageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
1161 #if ENABLE(TIZEN_CACHE_MEMORY_OPTIMIZATION)
1163 ewk_view_context_get(m_viewImpl->view())->clearAllDecodedData();
1168 #if ENABLE(TIZEN_DRAG_SUPPORT)
1169 void PageClientImpl::setDragPoint(const WebCore::IntPoint& point)
1171 m_drag->setDragPoint(point);
1173 bool PageClientImpl::isDragMode()
1175 return m_drag->isDragMode();
1177 void PageClientImpl::setDragMode(bool isDragMode)
1179 m_drag->setDragMode(isDragMode);
1181 void PageClientImpl::startDrag(const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
1183 DragData* dragInfo = new DragData(dragData.platformData(), m_drag->getDragPoint(),
1184 m_drag->getDragPoint(), dragData.draggingSourceOperationMask(), dragData.flags());
1186 String dragStorageName("Drag");
1187 m_viewImpl->page()->dragEntered(dragInfo, dragStorageName);
1189 m_drag->setDragData(dragInfo);
1194 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
1195 bool PageClientImpl::isShowingFormDataCandidate()
1197 return m_formDataCandidate->isShowing();
1200 void PageClientImpl::updateFormDataCandidate(const Vector<String>& data)
1202 m_formDataCandidate->updateFormData(data);
1205 void PageClientImpl::hideFormDataCandidate()
1207 m_formDataCandidate->hide();
1210 void PageClientImpl::showFormDataCandidate(const WebCore::IntRect& rect)
1212 m_formDataCandidate->show(rect);
1216 #if ENABLE(TIZEN_REGISTER_PROTOCOL_HANDLER)
1217 void PageClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title)
1219 ewkViewRegisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1223 #if ENABLE(TIZEN_CUSTOM_SCHEME_HANDLER)
1224 unsigned int PageClientImpl::isProtocolHandlerRegistered(const String& scheme, const String& baseURL, const String& url)
1226 return ewkViewIsProtocolHandlerRegistered(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1229 void PageClientImpl::unregisterProtocolHandler(const String& scheme, const String& baseURL, const String& url)
1231 ewkViewUnregisterProtocolHandlers(m_viewImpl->view(), scheme.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1235 #if ENABLE(TIZEN_REGISTER_CONTENT_HANDLER)
1236 void PageClientImpl::registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title)
1238 ewkViewRegisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data(), title.utf8().data());
1241 unsigned int PageClientImpl::isContentHandlerRegistered(const String& mimeType, const String& baseURL, const String& url)
1243 return ewkViewIsContentHandlerRegistered(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1246 void PageClientImpl::unregisterContentHandler(const String& mimeType, const String& baseURL, const String& url)
1248 ewkViewUnregisterContentHandlers(m_viewImpl->view(), mimeType.utf8().data(), baseURL.utf8().data(), url.utf8().data());
1252 #if ENABLE(TIZEN_SEARCH_PROVIDER)
1253 void PageClientImpl::addSearchProvider(const String& baseURL, const String& engineURL)
1255 ewkViewAddSearchProvider(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1258 unsigned long PageClientImpl::isSearchProviderInstalled(const String& baseURL, const String& engineURL)
1260 return ewkViewIsSearchProviderInstalled(m_viewImpl->view(), baseURL.utf8().data(), engineURL.utf8().data());
1264 #if ENABLE(TIZEN_SUPPORT_WEBAPP_META_TAG)
1265 bool PageClientImpl::getStandaloneStatus()
1267 return ewkViewGetStandaloneStatus(m_viewImpl->view());
1271 #if ENABLE(SCREEN_ORIENTATION_SUPPORT) && ENABLE(TIZEN_SCREEN_ORIENTATION_SUPPORT)
1272 bool PageClientImpl::lockOrientation(int willLockOrientation)
1274 return ewk_view_orientation_lock(m_viewImpl->view(), willLockOrientation);
1277 void PageClientImpl::unlockOrientation()
1279 ewk_view_orientation_unlock(m_viewImpl->view());
1283 void PageClientImpl::didRenderFrame()
1285 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1286 if (m_shouldShowBackupTexture && m_isVisible)
1287 m_shouldShowBackupTexture = false;
1289 if (!m_pageDidRendered) {
1290 m_pageDidRendered = true;
1291 initializeVisibleContentRect();
1295 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION)
1296 void PageClientImpl::setOverflowResult(bool pressed, WebLayerID webLayerID)
1298 setIsScrollableLayerFocused(false);
1299 setIsScrollableNodeFocused(false);
1303 setIsScrollableLayerFocused(true);
1304 m_viewImpl->page()->drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer()->setFocusedLayerID(webLayerID);
1306 setIsScrollableNodeFocused(true);
1311 void PageClientImpl::findScrollableNode(const IntPoint& point)
1313 WebPageProxy* pageProxy = m_viewImpl->page();
1314 if (pageProxy && pageProxy->isLoadingFinished() && pageProxy->askOverflow()) {
1315 IntPoint pointForPress(m_viewImpl->transformFromScene().mapPoint(point));
1316 WebLayerID webLayerID = 0;
1317 bool checkOverflowLayer = false;
1318 #if ENABLE(TIZEN_CSS_OVERFLOW_SCROLL_ACCELERATION_ON_UI_SIDE)
1319 DrawingAreaProxy* drawingArea = pageProxy->drawingArea();
1320 checkOverflowLayer = drawingArea && drawingArea->layerTreeCoordinatorProxy() && drawingArea->layerTreeCoordinatorProxy()->hasOverflowLayer();
1322 setOverflowResult(pageProxy->setPressedNodeAtPoint(pointForPress, checkOverflowLayer, webLayerID), webLayerID);
1327 #if ENABLE(TIZEN_WEBKIT2_GET_TEXT_STYLE_FOR_SELECTION)
1328 void PageClientImpl::didGetTextStyleStateForSelection(int underlineState, int italicState, int boldState)
1330 WebCore::IntPoint startPoint, endPoint;
1331 WebCore::IntRect leftRect, rightRect;
1333 WebCore::IntRect caretRect;
1334 m_viewImpl->page()->getCaretPosition(caretRect);
1335 if (!caretRect.isEmpty()) {
1336 startPoint.setX(caretRect.x());
1337 startPoint.setY(caretRect.y() + caretRect.height());
1339 endPoint.setX(caretRect.x() + caretRect.width());
1340 endPoint.setY(caretRect.y() + caretRect.height());
1342 #if ENABLE(TIZEN_WEBKIT2_TEXT_SELECTION)
1343 else if (m_viewImpl->page()->getSelectionHandlers(leftRect, rightRect)) {
1344 startPoint.setX(leftRect.x());
1345 startPoint.setY(leftRect.y() + leftRect.height());
1347 endPoint.setX(rightRect.x() + rightRect.width());
1348 endPoint.setY(rightRect.y() + rightRect.height());
1352 startPoint.scale(scaleFactor(), scaleFactor());
1353 endPoint.scale(scaleFactor(), scaleFactor());
1355 int viewPositionX, viewPositionY;
1356 evas_object_geometry_get(m_viewImpl->view(), &viewPositionX, &viewPositionY, NULL, NULL);
1358 startPoint.move(-scrollPosition().x(), -scrollPosition().y());
1359 startPoint.move(viewPositionX, viewPositionY);
1361 endPoint.move(-scrollPosition().x(), -scrollPosition().y());
1362 endPoint.move(viewPositionX, viewPositionY);
1364 ewkViewDidGetTextStyleStateForSelection(m_viewImpl->view(), underlineState, italicState, boldState, startPoint, endPoint);
1368 void PageClientImpl::didFindZoomableArea(const IntPoint& target, const IntRect& area)
1370 ewk_view_zoomable_area_set(m_viewImpl->view(), target, area);
1373 #if ENABLE(TIZEN_ICON_DATABASE)
1374 void PageClientImpl::didReceiveIcon()
1376 ewkViewIconReceived(m_viewImpl->view());
1380 #if ENABLE(TIZEN_WEBKIT2_FOCUS_RING)
1381 void PageClientImpl::hideFocusRing()
1383 ewkViewFocusRingHide(m_viewImpl->view());
1386 #endif // #if OS(TIZEN)
1389 #if ENABLE(TIZEN_WEBKIT2_TILED_AC) && ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION)
1390 PageClientEvasGL::PageClientEvasGL(EwkViewImpl* viewImpl)
1391 : PageClientImpl(viewImpl)
1397 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1400 , m_isAcceleratedCompositingModeInitialized(false)
1402 initializeAcceleratedCompositingMode();
1405 PageClientEvasGL::~PageClientEvasGL()
1407 m_viewImpl->page()->close();
1410 void PageClientEvasGL::updateViewportSize(const WebCore::IntSize& viewportSize)
1413 evas_gl_surface_destroy(m_evasGL, m_surface);
1418 PageClientImpl::updateViewportSize(viewportSize);
1421 void PageClientEvasGL::setViewNeedsDisplay(const WebCore::IntRect& rect)
1423 #if !ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1426 m_viewImpl->redrawRegion(rect);
1428 #if ENABLE(TIZEN_SCREEN_READER)
1429 if (rect.intersects(ewkViewGetFocusRing(m_viewImpl->view())->rect()))
1430 m_viewImpl->page()->recalcScreenReaderFocusRect();
1434 void PageClientEvasGL::displayViewport()
1436 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1437 // We should not draw here when Direct Rendering is enabled.
1438 // Because we will draw directly when evas is updated - on_pixels_for_accelerated_compositing().
1439 ewk_view_mark_for_sync(m_viewImpl->view());
1441 setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
1444 #if ENABLE(TIZEN_WEBKIT2_TILED_SCROLLBAR)
1448 #if ENABLE(TIZEN_SCREEN_READER)
1449 m_viewImpl->page()->recalcScreenReaderFocusRect();
1453 void PageClientEvasGL::drawContents()
1455 if (evas_gl_make_current(m_evasGL, m_surface, m_context) != EINA_TRUE)
1458 WebCore::TransformationMatrix matrix;
1460 IntSize ewkViewSize = viewSize();
1462 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1463 Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_viewImpl->view()));
1464 m_angle = ecore_evas_rotation_get(ee);
1466 drawingArea()->setAngle(m_angle);
1467 matrix.rotate3d(0.0, 0.0, 1.0, 360 - m_angle);
1469 if (m_angle == 90 || m_angle == 270) {
1470 glViewport(0, 0, ewkViewSize.height(), ewkViewSize.width());
1472 matrix.translate(-ewkViewSize.width(), 0);
1473 else if (m_angle == 270)
1474 matrix.translate(0, -ewkViewSize.height());
1475 clipRect = IntRect(IntPoint(), ewkViewSize.transposedSize());
1477 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1479 matrix.translate(-ewkViewSize.width(), -ewkViewSize.height());
1480 clipRect = IntRect(IntPoint(), ewkViewSize);
1483 glViewport(0, 0, ewkViewSize.width(), ewkViewSize.height());
1484 clipRect = IntRect(IntPoint(), ewkViewSize);
1486 matrix *= m_viewImpl->transformToView().toTransformationMatrix();
1488 if (drawingArea()) {
1489 if (drawingArea()->layerTreeCoordinatorProxy()) {
1490 WebLayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer();
1491 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE_BACKUP_IMAGE)
1492 if (m_shouldMakeBackupTexture) {
1493 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1494 glClearColor(1, 1, 1, 1);
1495 glClear(GL_COLOR_BUFFER_BIT);
1496 renderer->paintToBackupTexture(matrix, 1.0f, m_initialViewRect, m_bgColor);
1497 m_shouldMakeBackupTexture = false;
1498 } else if (m_shouldShowBackupTexture) {
1499 matrix.makeIdentity();
1500 glViewport(0, 0, m_initialViewRect.width(), m_initialViewRect.height());
1501 renderer->showBackupTexture(matrix, 1.0f, m_initialViewRect);
1504 renderer->paintToCurrentGLContext(matrix, 1.0f, clipRect, m_bgColor);
1509 void PageClientEvasGL::didRenderFrame()
1511 ewkViewFrameRendered(m_viewImpl->view());
1512 PageClientImpl::didRenderFrame();
1515 bool PageClientEvasGL::makeContextCurrent()
1517 return evas_gl_make_current(m_evasGL, m_surface, m_context);
1520 void PageClientEvasGL::initializeAcceleratedCompositingMode()
1522 Evas* evas = evas_object_evas_get(m_viewImpl->view());
1524 m_config = evas_gl_config_new();
1525 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1526 setenv("EVAS_GL_DIRECT_OVERRIDE", "1", 1);
1527 m_config->options_bits = EVAS_GL_OPTIONS_DIRECT;
1529 m_config->color_format = EVAS_GL_RGBA_8888;
1530 m_config->depth_bits = EVAS_GL_DEPTH_BIT_24;
1531 m_config->stencil_bits = EVAS_GL_STENCIL_BIT_8;
1533 m_evasGL = evas_gl_new(evas);
1535 evas_gl_config_free(m_config);
1537 TIZEN_LOGE("failed to create evas_gl");
1541 Evas_GL_API* evasGlApi = evas_gl_api_get(m_evasGL);
1543 evas_gl_free(m_evasGL);
1545 evas_gl_config_free(m_config);
1547 TIZEN_LOGE("failed to get evas_gl_api");
1550 WebCore::EvasGlApiInterface::shared().initialize(evasGlApi);
1552 m_context = evas_gl_context_create(m_evasGL, 0);
1554 evas_gl_free(m_evasGL);
1556 evas_gl_config_free(m_config);
1558 TIZEN_LOGE("failed to create evas_gl_context");
1563 m_isAcceleratedCompositingModeInitialized = true;
1566 void PageClientEvasGL::finalizeAcceleratedCompositingMode()
1570 evas_gl_surface_destroy(m_evasGL, m_surface);
1574 evas_gl_context_destroy(m_evasGL, m_context);
1578 evas_gl_config_free(m_config);
1581 evas_gl_free(m_evasGL);
1585 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1586 setenv("EVAS_GL_DIRECT_OVERRIDE", "0", 1);
1588 m_isAcceleratedCompositingModeInitialized = false;
1591 void PageClientEvasGL::enterAcceleratedCompositingMode(const LayerTreeContext&)
1593 if (!m_isAcceleratedCompositingModeInitialized)
1594 initializeAcceleratedCompositingMode();
1597 void PageClientEvasGL::exitAcceleratedCompositingMode()
1599 if (m_isAcceleratedCompositingModeInitialized)
1600 finalizeAcceleratedCompositingMode();
1603 void PageClientEvasGL::setTargetSurface()
1609 evas_object_geometry_get(m_viewImpl->view(), 0, 0, &width, &height);
1610 if (width == 0 || height == 0)
1613 m_surface = evas_gl_surface_create(m_evasGL, m_config, width, height);
1615 TIZEN_LOGE("failed to create Evas_GL_Surface");
1619 #if ENABLE(TIZEN_WEBKIT2_DIRECT_RENDERING)
1620 makeContextCurrent();
1622 if (makeContextCurrent()) {
1623 glViewport(0, 0, width, height);
1624 glClearColor(1.0, 1.0, 1.0, 1.0);
1625 glClear(GL_COLOR_BUFFER_BIT);
1630 Evas_Native_Surface nativeSurface;
1631 if (evas_gl_native_surface_get(m_evasGL, m_surface, &nativeSurface))
1632 ewk_view_image_native_surface_set(m_viewImpl->view(), &nativeSurface);
1636 } // namespace WebKit