void EwkView::handleEvasObjectCalculate(Evas_Object* evasObject) { Ewk_View_Smart_Data* smartData = toSmartData(evasObject); ASSERT(smartData); EwkView* view = toEwkView(smartData); ASSERT(view); smartData->changed.any = false; Evas_Coord x, y, width, height; evas_object_geometry_get(evasObject, &x, &y, &width, &height); if (smartData->changed.position) { smartData->changed.position = false; smartData->view.x = x; smartData->view.y = y; evas_object_move(smartData->image, x, y); } if (smartData->changed.size) { smartData->changed.size = false; smartData->view.w = width; smartData->view.h = height; if (view->page()->drawingArea()) view->page()->drawingArea()->setSize(IntSize(width, height), IntSize()); view->setNeedsSurfaceResize(); view->pageClient()->updateViewportSize(); } }
WKPageRef EwkView::createNewPage(PassRefPtr<EwkUrlRequest>, WKDictionaryRef windowFeatures) { Ewk_View_Smart_Data* sd = smartData(); ASSERT(sd->api); if (!sd->api->window_create) return 0; WKPageRef wkPageRef = wkPage(); RefPtr<EwkWindowFeatures> ewkWindowFeatures = EwkWindowFeatures::create(windowFeatures, this); WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageCopyPageConfiguration(wkPageRef)); WKPageConfigurationSetRelatedPage(configuration.get(), wkPageRef); Ref<EwkViewConfiguration> ewkViewConfiguration = EwkViewConfiguration::create(configuration.get()); Evas_Object* newEwkView = sd->api->window_create(sd, &ewkViewConfiguration.get(), ewkWindowFeatures.get()); if (!newEwkView) return 0; EwkView* newViewImpl = toEwkView(newEwkView); ASSERT(newViewImpl); newViewImpl->m_windowFeatures = ewkWindowFeatures; return static_cast<WKPageRef>(WKRetain(newViewImpl->page())); }
void EwkView::handleEvasObjectCalculate(Evas_Object* evasObject) { Ewk_View_Smart_Data* smartData = toSmartData(evasObject); ASSERT(smartData); EwkView* self = toEwkView(smartData); smartData->changed.any = false; Evas_Coord x, y, width, height; evas_object_geometry_get(evasObject, &x, &y, &width, &height); if (smartData->changed.position) { smartData->changed.position = false; smartData->view.x = x; smartData->view.y = y; evas_object_move(smartData->image, x, y); WKViewSetUserViewportTranslation(self->wkView(), x, y); } if (smartData->changed.size) { smartData->changed.size = false; smartData->view.w = width; smartData->view.h = height; self->setSize(IntSize(width, height)); self->setNeedsSurfaceResize(); } }
void EwkView::handleFaviconChanged(const char* pageURL, void* eventInfo) { EwkView* view = static_cast<EwkView*>(eventInfo); if (!view->url() || strcasecmp(view->url(), pageURL)) return; }
void PageLoadClientEfl::didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; EwkView* view = toPageLoadClientEfl(clientInfo)->view(); view->informURLChange(); }
void ViewClientEfl::didChangeViewportAttributes(WKViewRef, WKViewportAttributesRef attributes, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); ASSERT(WKPageUseFixedLayout(ewkView->wkPage())); // FIXME: pageViewportController should accept WKViewportAttributesRef. ewkView->pageViewportController().didChangeViewportAttributes(toImpl(attributes)->originalAttributes()); }
void ViewClientEfl::didRenderFrame(WKViewRef, WKSize contentsSize, WKRect coveredRect, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); if (WKPageUseFixedLayout(ewkView->wkPage())) ewkView->pageViewportController().didRenderFrame(toIntSize(contentsSize), toIntRect(coveredRect)); else ewkView->scheduleUpdateDisplay(); }
void PageLoadClientEfl::didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; EwkView* view = toPageLoadClientEfl(clientInfo)->view(); view->pageClient()->didCommitLoad(); }
void PageLoadClientEfl::didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef /*userData*/, const void* clientInfo) { if (!WKFrameIsMainFrame(frame)) return; EwkView* view = toPageLoadClientEfl(clientInfo)->view(); view->informURLChange(); view->smartCallback<ProvisionalLoadRedirect>().call(); }
void ViewClientEfl::didChangeContentsPosition(WKViewRef, WKPoint position, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); if (WKPageUseFixedLayout(ewkView->wkPage())) { ewkView->pageViewportController().pageDidRequestScroll(toIntPoint(position)); return; } ewkView->scheduleUpdateDisplay(); }
Eina_Bool EwkView::handleEwkViewMouseUp(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent) { EwkView* self = toEwkView(smartData); self->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, self->webView()->transformFromScene(), self->transformToScreen())); if (InputMethodContextEfl* inputMethodContext = self->inputMethodContext()) inputMethodContext->handleMouseUpEvent(upEvent); return true; }
void ViewClientEfl::didChangeViewportAttributes(WKViewRef, WKViewportAttributesRef attributes, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); if (WKPageUseFixedLayout(ewkView->wkPage())) { // FIXME: pageViewportController should accept WKViewportAttributesRef. ewkView->pageViewportController().didChangeViewportAttributes(toImpl(attributes)->originalAttributes()); return; } ewkView->scheduleUpdateDisplay(); }
void ViewClientEfl::didCompletePageTransition(WKViewRef, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); if (WKPageUseFixedLayout(ewkView->wkPage())) { ewkView->pageViewportController().pageTransitionViewportReady(); return; } ewkView->scheduleUpdateDisplay(); }
Eina_Bool EwkView::handleEwkViewKeyDown(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent) { bool isFiltered = false; EwkView* self = toEwkView(smartData); if (InputMethodContextEfl* inputMethodContext = self->inputMethodContext()) inputMethodContext->handleKeyDownEvent(downEvent, &isFiltered); self->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent, isFiltered)); return true; }
void ViewClientEfl::didChangeContentsSize(WKViewRef, WKSize size, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); if (WKPageUseFixedLayout(ewkView->wkPage())) ewkView->pageViewportController().didChangeContentsSize(toIntSize(size)); else ewkView->scheduleUpdateDisplay(); ewkView->smartCallback<ContentsSizeChanged>().call(size); }
void ViewClientEfl::didChangeContentsSize(WKViewRef, WKSize size, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); if (WKPageUseFixedLayout(ewkView->wkPage())) #if USE(ACCELERATED_COMPOSITING) ewkView->pageViewportController().didChangeContentsSize(toIntSize(size)); #else { } #endif else
void PageLoadClientEfl::didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo) { EwkView* view = toPageLoadClientEfl(clientInfo)->view(); ASSERT(view); Ewk_Back_Forward_List* list = ewk_view_back_forward_list_get(view->view()); ASSERT(list); list->update(addedItem, removedItems); view->smartCallback<BackForwardListChange>().call(); }
void EwkViewEventHandler<EVAS_CALLBACK_MOUSE_IN>::handleEvent(void* data, Evas* evas, Evas_Object*, void*) { #ifdef HAVE_ECORE_X Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); EwkView* self = toEwkView(smartData); Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(evas); Ecore_X_Window window = getEcoreXWindow(ecoreEvas); self->updateCursor(window); #endif }
void GestureHandler::handleSingleTap(const IntPoint& position) { Evas* evas = evas_object_evas_get(m_ewkView->evasObject()); ASSERT(evas); // Send mouse move, down and up event to create fake click event. Evas_Event_Mouse_Move mouseMove; mouseMove.buttons = 0; mouseMove.prev.output.x = mouseMove.prev.canvas.x = position.x(); mouseMove.prev.output.y = mouseMove.prev.canvas.y = position.y(); mouseMove.cur.output.x = mouseMove.cur.canvas.x = position.x(); mouseMove.cur.output.y = mouseMove.cur.canvas.y = position.y(); mouseMove.data = 0; mouseMove.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas)); mouseMove.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas)); mouseMove.timestamp = ecore_loop_time_get(); mouseMove.event_flags = EVAS_EVENT_FLAG_NONE; mouseMove.dev = 0; WKViewSendMouseMoveEvent(m_ewkView->wkView(), &mouseMove); Evas_Event_Mouse_Down mouseDown; mouseDown.button = 1; mouseDown.output.x = mouseDown.canvas.x = position.x(); mouseDown.output.y = mouseDown.canvas.y = position.y(); mouseDown.data = 0; mouseDown.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas)); mouseDown.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas)); mouseDown.flags = EVAS_BUTTON_NONE; mouseDown.timestamp = ecore_loop_time_get(); mouseDown.event_flags = EVAS_EVENT_FLAG_NONE; mouseDown.dev = 0; WKViewSendMouseDownEvent(m_ewkView->wkView(), &mouseDown); Evas_Event_Mouse_Up mouseUp; mouseUp.button = 1; mouseUp.output.x = mouseUp.canvas.x = position.x(); mouseUp.output.y = mouseUp.canvas.y = position.y(); mouseUp.data = 0; mouseUp.modifiers = const_cast<Evas_Modifier*>(evas_key_modifier_get(evas)); mouseUp.locks = const_cast<Evas_Lock*>(evas_key_lock_get(evas)); mouseUp.flags = EVAS_BUTTON_NONE; mouseUp.timestamp = ecore_loop_time_get(); mouseUp.event_flags = EVAS_EVENT_FLAG_NONE; mouseUp.dev = 0; WKViewSendMouseUpEvent(m_ewkView->wkView(), &mouseUp); }
void EwkView::handleEvasObjectCalculate(Evas_Object* evasObject) { Ewk_View_Smart_Data* smartData = toSmartData(evasObject); ASSERT(smartData); EwkView* self = toEwkView(smartData); smartData->changed.any = false; Evas_Coord x, y, width, height; evas_object_geometry_get(evasObject, &x, &y, &width, &height); if (smartData->changed.position) { smartData->changed.position = false; smartData->view.x = x; smartData->view.y = y; evas_object_move(smartData->image, x, y); WKViewSetUserViewportTranslation(self->wkView(), x, y); } if (smartData->changed.size) { smartData->changed.size = false; smartData->view.w = width; smartData->view.h = height; WKViewSetSize(self->wkView(), WKSizeMake(width, height)); #if USE(ACCELERATED_COMPOSITING) if (WKPageUseFixedLayout(self->wkPage())) self->pageViewportController().didChangeViewportSize(self->size()); self->setNeedsSurfaceResize(); #endif } }
void EwkView::handleEvasObjectColorSet(Evas_Object* evasObject, int red, int green, int blue, int alpha) { Ewk_View_Smart_Data* smartData = toSmartData(evasObject); ASSERT(smartData); EwkView* view = toEwkView(smartData); ASSERT(view); alpha = clampTo(alpha, 0, 255); red = clampTo(red, 0, alpha); green = clampTo(green, 0, alpha); blue = clampTo(blue, 0, alpha); evas_object_image_alpha_set(smartData->image, alpha < 255); WKViewSetDrawsBackground(view->wkView(), red || green || blue); WKViewSetDrawsTransparentBackground(view->wkView(), alpha < 255); parentSmartClass.color_set(evasObject, red, green, blue, alpha); }
WKPageRef EwkView::createNewPage(PassRefPtr<EwkUrlRequest>, WKDictionaryRef windowFeatures) { Ewk_View_Smart_Data* sd = smartData(); ASSERT(sd->api); if (!sd->api->window_create) return 0; RefPtr<EwkWindowFeatures> ewkWindowFeatures = EwkWindowFeatures::create(windowFeatures, this); Evas_Object* newEwkView = sd->api->window_create(sd, ewkWindowFeatures.get()); if (!newEwkView) return 0; EwkView* newViewImpl = toEwkView(newEwkView); ASSERT(newViewImpl); newViewImpl->m_windowFeatures = ewkWindowFeatures; return static_cast<WKPageRef>(WKRetain(newViewImpl->page())); }
Eina_Bool ewk_view_contents_size_get(const Evas_Object* ewkView, Evas_Coord* width, Evas_Coord* height) { EwkView* impl = toEwkViewChecked(ewkView); if (EINA_UNLIKELY(!impl)) { EINA_LOG_CRIT("no private data for object %p", ewkView); if (width) *width = 0; if (height) *height = 0; return false; } WKSize contentsSize = WKViewGetContentsSize(impl->wkView()); if (width) *width = contentsSize.width; if (height) *height = contentsSize.height; return true; }
void ViewClientEfl::webProcessCrashed(WKViewRef, WKURLRef url, const void* clientInfo) { EwkView* ewkView = toEwkView(clientInfo); // Check if loading was ongoing, when web process crashed. double loadProgress = WKPageGetEstimatedProgress(ewkView->wkPage()); if (loadProgress >= 0 && loadProgress < 1) { loadProgress = 1; ewkView->smartCallback<LoadProgress>().call(&loadProgress); } ewkView->smartCallback<TooltipTextUnset>().call(); bool handled = false; ewkView->smartCallback<WebProcessCrashed>().call(&handled); if (!handled) { WKEinaSharedString urlString(url); WARN("WARNING: The web process experienced a crash on '%s'.\n", static_cast<const char*>(urlString)); // Display an error page ewk_view_html_string_load(ewkView->evasObject(), "The web process has crashed.", 0, urlString); } }
void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo) { if (!m_backingStore) m_backingStore = WidgetBackingStore::create(m_webPageProxy->viewWidget(), size()); scroll(updateInfo.scrollRect, updateInfo.scrollOffset); // Paint all update rects. IntPoint updateRectLocation = updateInfo.updateRectBounds.location(); RefPtr<cairo_t> context(adoptRef(cairo_create(m_backingStore->cairoSurface()))); GraphicsContext graphicsContext(context.get()); for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) { IntRect updateRect = updateInfo.updateRects[i]; IntRect srcRect = updateRect; srcRect.move(-updateRectLocation.x(), -updateRectLocation.y()); bitmap->paint(graphicsContext, updateRect.location(), srcRect); } #if PLATFORM(EFL) // Update ewk_view with new backingStore image. EwkView* view = EwkView::fromEvasObject(m_webPageProxy->viewWidget()); view->setImageData(cairo_image_surface_get_data(m_backingStore->cairoSurface()), m_size); #endif }
WKImageRef WKViewCreateSnapshot(WKViewRef viewRef) { EwkView* ewkView = toEwkView(toImpl(viewRef)->evasObject()); return WKImageCreateFromCairoSurface(ewkView->takeSnapshot().get(), 0 /* options */); }
Eina_Bool EwkView::handleEwkViewMouseMove(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent) { EwkView* self = toEwkView(smartData); self->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, self->webView()->transformFromScene(), self->transformToScreen())); return true; }
Eina_Bool EwkView::handleEwkViewMouseWheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent) { EwkView* self = toEwkView(smartData); self->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, self->transformFromScene(), self->transformToScreen())); return true; }