diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API/efl')
21 files changed, 1183 insertions, 13 deletions
diff --git a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h index 9a052da4b..d98023de6 100644 --- a/Source/WebKit2/UIProcess/API/efl/EWebKit2.h +++ b/Source/WebKit2/UIProcess/API/efl/EWebKit2.h @@ -28,6 +28,8 @@ #ifndef EWebKit2_h #define EWebKit2_h +#include "ewk_back_forward_list.h" +#include "ewk_back_forward_list_item.h" #include "ewk_context.h" #include "ewk_cookie_manager.h" #include "ewk_download_job.h" diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp new file mode 100644 index 000000000..f5740822e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.cpp @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "EflViewportHandler.h" + +#if USE(COORDINATED_GRAPHICS) + +#include "LayerTreeCoordinatorProxy.h" +#include "LayerTreeRenderer.h" +#include "TransformationMatrix.h" + +using namespace WebCore; + +namespace WebKit { + +EflViewportHandler::EflViewportHandler(PageClientImpl* pageClientImpl) + : m_pageClientImpl(pageClientImpl) + , m_scaleFactor(1) +{ + ASSERT(m_pageClientImpl); +} + +EflViewportHandler::~EflViewportHandler() +{ +} + +void EflViewportHandler::display(const IntRect& rect) +{ + WebCore::TransformationMatrix matrix; + matrix.setMatrix(m_scaleFactor, 0, 0, m_scaleFactor, -m_visibleContentRect.x(), -m_visibleContentRect.y()); + + LayerTreeRenderer* renderer = drawingArea()->layerTreeCoordinatorProxy()->layerTreeRenderer(); + renderer->setActive(true); + renderer->syncRemoteContent(); + renderer->paintToCurrentGLContext(matrix, 1, rect); +} + +void EflViewportHandler::updateViewportSize(const IntSize& viewportSize) +{ + m_viewportSize = viewportSize; + m_pageClientImpl->page()->setViewportSize(viewportSize); + setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint()); +} + +void EflViewportHandler::setVisibleContentsRect(const IntPoint& newScrollPosition, float newScale, const FloatPoint& trajectory) +{ + m_scaleFactor = newScale; + m_visibleContentRect = IntRect(newScrollPosition, m_viewportSize); + + // Move visibleContentRect inside contentsRect when visibleContentRect goes outside contentsRect. + IntSize contentsSize = m_contentsSize; + contentsSize.scale(m_scaleFactor); + if (m_visibleContentRect.x() > contentsSize.width() - m_visibleContentRect.width()) + m_visibleContentRect.setX(contentsSize.width() - m_visibleContentRect.width()); + if (m_visibleContentRect.x() < 0) + m_visibleContentRect.setX(0); + if (m_visibleContentRect.y() > contentsSize.height() - m_visibleContentRect.height()) + m_visibleContentRect.setY(contentsSize.height() - m_visibleContentRect.height()); + if (m_visibleContentRect.y() < 0) + m_visibleContentRect.setY(0); + + FloatRect mapRectToWebContent = m_visibleContentRect; + mapRectToWebContent.scale(1 / m_scaleFactor); + drawingArea()->setVisibleContentsRect(enclosingIntRect(mapRectToWebContent), m_scaleFactor, trajectory); +} + +void EflViewportHandler::didChangeContentsSize(const WebCore::IntSize& size) +{ + m_contentsSize = size; + setVisibleContentsRect(m_visibleContentRect.location(), m_scaleFactor, FloatPoint()); + drawingArea()->layerTreeCoordinatorProxy()->setContentsSize(WebCore::FloatSize(size.width(), size.height())); +} + +} // namespace WebKit +#endif // USE(COORDINATED_GRAPHICS) + diff --git a/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h new file mode 100644 index 000000000..cc6b3d957 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/EflViewportHandler.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EflViewportHandler_h +#define EflViewportHandler_h + +#if USE(COORDINATED_GRAPHICS) + +#include "PageClientImpl.h" +#include <wtf/PassOwnPtr.h> + +namespace WebKit { + +class EflViewportHandler { +public: + static PassOwnPtr<EflViewportHandler> create(PageClientImpl* pageClientImpl) + { + return adoptPtr(new EflViewportHandler(pageClientImpl)); + } + ~EflViewportHandler(); + + DrawingAreaProxy* drawingArea() const { return m_pageClientImpl->page()->drawingArea(); } + WebCore::IntSize viewSize() { return m_viewportSize; } + + void display(const WebCore::IntRect& rect); + void updateViewportSize(const WebCore::IntSize& viewportSize); + void setVisibleContentsRect(const WebCore::IntPoint&, float, const WebCore::FloatPoint&); + void didChangeContentsSize(const WebCore::IntSize& size); + +private: + explicit EflViewportHandler(PageClientImpl*); + + PageClientImpl* m_pageClientImpl; + WebCore::IntRect m_visibleContentRect; + WebCore::IntSize m_contentsSize; + WebCore::IntSize m_viewportSize; + float m_scaleFactor; +}; + +} // namespace WebKit + +#endif + +#endif // EflViewportHandler_h diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp index 79d20a17d..726caaae1 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp @@ -31,7 +31,9 @@ #include "NotImplemented.h" #include "WebContext.h" #include "WebContextMenuProxy.h" +#include "WebPageGroup.h" #include "WebPageProxy.h" +#include "WebPreferences.h" #include "ewk_context.h" #include "ewk_context_private.h" #include "ewk_download_job.h" @@ -46,6 +48,13 @@ PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Eva : m_viewWidget(viewWidget) { m_page = context->createWebPage(this, pageGroup); + +#if USE(COORDINATED_GRAPHICS) + m_page->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); + m_page->pageGroup()->preferences()->setForceCompositingMode(true); + m_page->setUseFixedLayout(true); +#endif + m_page->initializeWebPage(); } @@ -295,4 +304,9 @@ void PageClientImpl::pageDidRequestScroll(const IntPoint&) } #endif +void PageClientImpl::didChangeContentsSize(const WebCore::IntSize& size) +{ + ewk_view_contents_size_changed(m_viewWidget, size); +} + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h index 1bd22934a..861850263 100644 --- a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h @@ -112,6 +112,8 @@ private: virtual void pageDidRequestScroll(const WebCore::IntPoint&); #endif + virtual void didChangeContentsSize(const WebCore::IntSize&); + private: RefPtr<WebPageProxy> m_page; Evas_Object* m_viewWidget; diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp new file mode 100644 index 000000000..5b8e2d7ea --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_back_forward_list.h" + +#include "WKAPICast.h" +#include "WKArray.h" +#include "WKBackForwardList.h" +#include "WKRetainPtr.h" +#include "ewk_back_forward_list_item_private.h" +#include <wtf/text/CString.h> + +using namespace WebKit; + +typedef HashMap<WKBackForwardListItemRef, Ewk_Back_Forward_List_Item*> ItemsMap; + +/** + * \struct _Ewk_Back_Forward_List + * @brief Contains the Back Forward List data. + */ +struct _Ewk_Back_Forward_List { + WKRetainPtr<WKBackForwardListRef> wkList; + mutable ItemsMap wrapperCache; + + _Ewk_Back_Forward_List(WKBackForwardListRef listRef) + : wkList(listRef) + { } + + ~_Ewk_Back_Forward_List() + { + ItemsMap::iterator it = wrapperCache.begin(); + ItemsMap::iterator end = wrapperCache.end(); + for (; it != end; ++it) + ewk_back_forward_list_item_unref(it->second); + } +}; + +#define EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList_, ...) \ + if (!(list)) { \ + EINA_LOG_CRIT("list is NULL."); \ + return __VA_ARGS__; \ + } \ + if (!(list)->wkList) { \ + EINA_LOG_CRIT("list->wkList is NULL."); \ + return __VA_ARGS__; \ + } \ + WKBackForwardListRef wkList_ = (list)->wkList.get() + + +static inline Ewk_Back_Forward_List_Item* addItemToWrapperCache(const Ewk_Back_Forward_List* list, WKBackForwardListItemRef wkItem) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(list, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(wkItem, 0); + + Ewk_Back_Forward_List_Item* item = list->wrapperCache.get(wkItem); + if (!item) { + item = ewk_back_forward_list_item_new(wkItem); + list->wrapperCache.set(wkItem, item); + } + + return item; +} + +Ewk_Back_Forward_List_Item* ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List* list) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + return addItemToWrapperCache(list, WKBackForwardListGetCurrentItem(wkList)); +} + +Ewk_Back_Forward_List_Item* ewk_back_forward_list_previous_item_get(const Ewk_Back_Forward_List* list) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + return addItemToWrapperCache(list, WKBackForwardListGetBackItem(wkList)); +} + +Ewk_Back_Forward_List_Item* ewk_back_forward_list_next_item_get(const Ewk_Back_Forward_List* list) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + return addItemToWrapperCache(list, WKBackForwardListGetForwardItem(wkList)); +} + +Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_at_index_get(const Ewk_Back_Forward_List* list, int index) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + return addItemToWrapperCache(list, WKBackForwardListGetItemAtIndex(wkList, index)); +} + +unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List* list) +{ + EWK_BACK_FORWARD_LIST_WK_GET_OR_RETURN(list, wkList, 0); + + const unsigned currentItem = ewk_back_forward_list_current_item_get(list) ? 1 : 0; + + return WKBackForwardListGetBackListCount(wkList) + WKBackForwardListGetForwardListCount(wkList) + currentItem; +} + + +/** + * @internal + * Updates items cache. + */ +void ewk_back_forward_list_changed(Ewk_Back_Forward_List* list, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems) +{ + addItemToWrapperCache(list, wkAddedItem); // Puts new item to the cache. + + const size_t removedItemsSize = wkRemovedItems ? WKArrayGetSize(wkRemovedItems) : 0; + for (size_t i = 0; i < removedItemsSize; ++i) { + WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkRemovedItems, i)); + if (Ewk_Back_Forward_List_Item* item = list->wrapperCache.take(wkItem)) + ewk_back_forward_list_item_unref(item); + } +} + +/** + * @internal + * Constructs a Ewk_Back_Forward_List from a WKBackForwardListRef. + */ +Ewk_Back_Forward_List* ewk_back_forward_list_new(WKBackForwardListRef wkBackForwardListRef) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(wkBackForwardListRef, 0); + + return new Ewk_Back_Forward_List(wkBackForwardListRef); +} + +/** + * @internal + * Frees a Ewk_Back_Forward_List object. + */ +void ewk_back_forward_list_free(Ewk_Back_Forward_List* list) +{ + EINA_SAFETY_ON_NULL_RETURN(list); + + delete list; +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h new file mode 100644 index 000000000..5b9cca726 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list.h @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_back_forward_list.h + * @brief Describes the Ewk Back Forward List API. + */ + +#ifndef ewk_back_forward_list_h +#define ewk_back_forward_list_h + +#include "ewk_back_forward_list_item.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Back_Forward_List */ +typedef struct _Ewk_Back_Forward_List Ewk_Back_Forward_List; + +/** + * Returns the current item in the @a list. + * + * @param list the back-forward list instance + * + * @return the current item in the @a list or @c NULL in case of error + */ +EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_current_item_get(const Ewk_Back_Forward_List *list); + +/** + * Returns the item that precedes the current item in the @a list. + * + * @param list the back-forward list instance + * + * @return the item that precedes the current item the @a list or @c NULL in case of error + */ +EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_previous_item_get(const Ewk_Back_Forward_List *list); + +/** + * Returns the item that follows the current item in the @a list. + * + * @param list the back-forward list instance + * + * @return the item that follows the current item in the @a list or @c NULL in case of error + */ +EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_next_item_get(const Ewk_Back_Forward_List *list); + +/** + * Returns the item at a given @a index relative to the current item. + * + * @param list the back-forward list instance + * @param index the index of the item + * + * @return the item at a given @a index relative to the current item or @c NULL in case of error + */ +EAPI Ewk_Back_Forward_List_Item *ewk_back_forward_list_item_at_index_get(const Ewk_Back_Forward_List *list, int index); + +/** + * Returns the length of the back-forward list including current item. + * + * @param list the back-forward list instance + * + * @return the length of the back-forward list including current item or @c 0 in case of error + */ +EAPI unsigned ewk_back_forward_list_count(Ewk_Back_Forward_List *list); + +#ifdef __cplusplus +} +#endif +#endif // ewk_back_forward_list_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp new file mode 100644 index 000000000..a8586b23d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this item of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this item of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ewk_back_forward_list_item.h" + +#include "WKAPICast.h" +#include "WKBackForwardListItem.h" +#include "WKEinaSharedString.h" + +using namespace WebKit; + +/** + * \struct _Ewk_Back_Forward_List + * @brief Contains the Back Forward List data. + */ +struct _Ewk_Back_Forward_List_Item { + unsigned int __ref; /**< the reference count of the object */ + WKRetainPtr<WKBackForwardListItemRef> wkItem; + WKEinaSharedString uri; + WKEinaSharedString title; + WKEinaSharedString originalUri; + + _Ewk_Back_Forward_List_Item(WKBackForwardListItemRef itemRef) + : __ref(1) + , wkItem(itemRef) + , uri(AdoptWK, WKBackForwardListItemCopyURL(itemRef)) + , title(AdoptWK, WKBackForwardListItemCopyTitle(itemRef)) + , originalUri(AdoptWK, WKBackForwardListItemCopyOriginalURL(itemRef)) + { } + + ~_Ewk_Back_Forward_List_Item() + { + ASSERT(!__ref); + } +}; + +void ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN(item); + ++item->__ref; +} + +void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN(item); + + if (--item->__ref) + return; + + delete item; +} + +const char* ewk_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + + return item->uri; +} + +const char* ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + + return item->title; +} + +const char* ewk_back_forward_list_item_original_uri_get(const Ewk_Back_Forward_List_Item* item) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(item, 0); + + return item->originalUri; +} + +Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_new(WKBackForwardListItemRef backForwardListItemData) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(backForwardListItemData, 0); + + return new Ewk_Back_Forward_List_Item(backForwardListItemData); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h new file mode 100644 index 000000000..811f0e104 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item.h @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file ewk_back_forward_list_item.h + * @brief Describes the Ewk Back Forward List Item API. + */ + +#ifndef ewk_back_forward_list_item_h +#define ewk_back_forward_list_item_h + +#include <Eina.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** Creates a type name for _Ewk_Back_Forward_List_Item */ +typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item; + +/** + * Increases the reference count of the given object. + * + * @param item the back-forward list item instance to increase the reference count + */ +EAPI void ewk_back_forward_list_item_ref(Ewk_Back_Forward_List_Item *item); + +/** + * Decreases the reference count of the given object, possibly freeing it. + * + * When the reference count reaches 0, the item is freed. + * + * @param item the back-forward list item instance to decrease the reference count + */ +EAPI void ewk_back_forward_list_item_unref(Ewk_Back_Forward_List_Item *item); + +/** + * Returns URI of the item. + * + * The returned URI may differ from the original URI (For example if the page was redirected). + * + * @see ewk_back_forward_list_item_original_uri_get() + * + * @param item the back-forward list item instance + * + * @return the URI of the @a item or @c NULL in case of error. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup() + */ +EAPI const char *ewk_back_forward_list_item_uri_get(const Ewk_Back_Forward_List_Item *item); + +/** + * Returns title of the item. + * + * @param item the back-forward list item instance + * + * @return the title of the @a item or @c NULL in case of error. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup() + */ +EAPI const char *ewk_back_forward_list_item_title_get(const Ewk_Back_Forward_List_Item *item); + +/** + * Returns original URI of the item. + * + * @see ewk_back_forward_list_item_uri_get() + * + * @param item the back-forward list item instance + * + * @return the original URI of the @a item or @c NULL in case of error. This pointer is + * guaranteed to be eina_stringshare, so whenever possible + * save yourself some cpu cycles and use + * eina_stringshare_ref() instead of eina_stringshare_add() or + * strdup() + */ +EAPI const char *ewk_back_forward_list_item_original_uri_get(const Ewk_Back_Forward_List_Item *item); + +#ifdef __cplusplus +} +#endif +#endif // ewk_back_forward_list_item_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h new file mode 100644 index 000000000..8c2c684d4 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_item_private.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this item of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this item of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_back_forward_list_item_private_h +#define ewk_back_forward_list_item_private_h + +#include <WebKit2/WKBase.h> + +typedef struct _Ewk_Back_Forward_List_Item Ewk_Back_Forward_List_Item; + +Ewk_Back_Forward_List_Item* ewk_back_forward_list_item_new(WKBackForwardListItemRef wkBackForwardListItemRef); + +#endif // ewk_back_forward_list_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h new file mode 100644 index 000000000..592a4f48d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_back_forward_list_private.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2012 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_back_forward_list_private_h +#define ewk_back_forward_list_private_h + +#include <WebKit2/WKBase.h> + +typedef struct _Ewk_Back_Forward_List Ewk_Back_Forward_List; + +void ewk_back_forward_list_changed(Ewk_Back_Forward_List*, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems); +Ewk_Back_Forward_List* ewk_back_forward_list_new(WKBackForwardListRef wkBackForwardListRef); +void ewk_back_forward_list_free(Ewk_Back_Forward_List* list); + +#endif // ewk_back_forward_list_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index f2ed417fc..d6453757e 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -118,6 +118,17 @@ WKContextRef ewk_context_WKContext_get(const Ewk_Context* ewkContext) /** * @internal + * Create Ewk_Context from WKContext. + */ +Ewk_Context* ewk_context_new_from_WKContext(WKContextRef contextRef) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0); + + return new Ewk_Context(contextRef); +} + +/** + * @internal * Registers that a new download has been requested. */ void ewk_context_download_job_add(Ewk_Context* ewkContext, Ewk_Download_Job* ewkDownload) @@ -189,7 +200,7 @@ void ewk_context_url_scheme_request_received(Ewk_Context* ewkContext, Ewk_Url_Sc static inline Ewk_Context* createDefaultEwkContext() { - return new Ewk_Context(WKContextGetSharedProcessContext()); + return new Ewk_Context(WKContextCreate()); } Ewk_Context* ewk_context_default_get() diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h index db9e911d2..d1b695e0c 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context_private.h @@ -27,6 +27,7 @@ typedef struct _Ewk_Download_Job Ewk_Download_Job; typedef struct _Ewk_Url_Scheme_Request Ewk_Url_Scheme_Request; WKContextRef ewk_context_WKContext_get(const Ewk_Context*); +Ewk_Context* ewk_context_new_from_WKContext(WKContextRef); WKSoupRequestManagerRef ewk_context_request_manager_get(const Ewk_Context*); void ewk_context_url_scheme_request_received(Ewk_Context*, Ewk_Url_Scheme_Request*); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index b1b1bcc08..7d8b1ce05 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -26,17 +26,22 @@ #include "NativeWebWheelEvent.h" #include "PageClientImpl.h" #include "WKAPICast.h" +#include "WKFindOptions.h" #include "WKRetainPtr.h" #include "WKString.h" #include "WKURL.h" +#include "ewk_back_forward_list_private.h" #include "ewk_context.h" #include "ewk_context_private.h" #include "ewk_intent_private.h" +#include "ewk_private.h" +#include "ewk_view_find_client_private.h" #include "ewk_view_form_client_private.h" #include "ewk_view_loader_client_private.h" #include "ewk_view_policy_client_private.h" #include "ewk_view_private.h" #include "ewk_view_resource_load_client_private.h" +#include "ewk_view_ui_client_private.h" #include "ewk_web_resource.h" #include <Ecore_Evas.h> #include <Edje.h> @@ -48,6 +53,10 @@ #include <Evas_GL.h> #endif +#if USE(COORDINATED_GRAPHICS) +#include "EflViewportHandler.h" +#endif + using namespace WebKit; using namespace WebCore; @@ -60,6 +69,10 @@ static void _ewk_view_priv_loading_resources_clear(LoadingResourcesMap& loadingR struct _Ewk_View_Private_Data { OwnPtr<PageClientImpl> pageClient; +#if USE(COORDINATED_GRAPHICS) + OwnPtr<EflViewportHandler> viewportHandler; +#endif + const char* uri; const char* title; const char* theme; @@ -67,6 +80,7 @@ struct _Ewk_View_Private_Data { const char* cursorGroup; Evas_Object* cursorObject; LoadingResourcesMap loadingResourcesMap; + Ewk_Back_Forward_List* backForwardList; #ifdef HAVE_ECORE_X bool isUsingEcoreX; @@ -85,6 +99,7 @@ struct _Ewk_View_Private_Data { , customEncoding(0) , cursorGroup(0) , cursorObject(0) + , backForwardList(0) #ifdef HAVE_ECORE_X , isUsingEcoreX(false) #endif @@ -105,6 +120,8 @@ struct _Ewk_View_Private_Data { if (cursorObject) evas_object_del(cursorObject); + + ewk_back_forward_list_free(backForwardList); } }; @@ -521,6 +538,10 @@ static void _ewk_view_smart_calculate(Evas_Object* ewkView) evas_object_geometry_get(ewkView, &x, &y, &width, &height); if (smartData->changed.size) { +#if USE(COORDINATED_GRAPHICS) + priv->viewportHandler->updateViewportSize(IntSize(width, height)); +#endif + if (priv->pageClient->page()->drawingArea()) priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize()); @@ -590,7 +611,7 @@ static void _ewk_view_smart_color_set(Evas_Object* ewkView, int red, int green, g_parentSmartClass.color_set(ewkView, red, green, blue, alpha); } -Eina_Bool ewk_view_smart_class_init(Ewk_View_Smart_Class* api) +Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class* api) { EINA_SAFETY_ON_NULL_RETURN_VAL(api, false); @@ -635,16 +656,46 @@ static inline Evas_Smart* _ewk_view_smart_class_new(void) static Evas_Smart* smart = 0; if (EINA_UNLIKELY(!smart)) { - ewk_view_smart_class_init(&api); + ewk_view_smart_class_set(&api); smart = evas_smart_class_new(&api.sc); } return smart; } -Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef) +static void _ewk_view_initialize(Evas_Object* ewkView, Ewk_Context* context, WKPageGroupRef pageGroupRef) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv) + EINA_SAFETY_ON_NULL_RETURN(context); + + if (priv->pageClient) + return; + + priv->pageClient = PageClientImpl::create(toImpl(ewk_context_WKContext_get(context)), toImpl(pageGroupRef), ewkView); + priv->backForwardList = ewk_back_forward_list_new(toAPI(priv->pageClient->page()->backForwardList())); + +#if USE(COORDINATED_GRAPHICS) + priv->viewportHandler = EflViewportHandler::create(priv->pageClient.get()); +#endif + + WKPageRef wkPage = toAPI(priv->pageClient->page()); + ewk_view_find_client_attach(wkPage, ewkView); + ewk_view_form_client_attach(wkPage, ewkView); + ewk_view_loader_client_attach(wkPage, ewkView); + ewk_view_policy_client_attach(wkPage, ewkView); + ewk_view_resource_load_client_attach(wkPage, ewkView); + ewk_view_ui_client_attach(wkPage, ewkView); + + ewk_view_theme_set(ewkView, DEFAULT_THEME_PATH"/default.edj"); +} + +static Evas_Object* _ewk_view_add_with_smart(Evas* canvas, Evas_Smart* smart) { - Evas_Object* ewkView = evas_object_smart_add(canvas, _ewk_view_smart_class_new()); + EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0); + + Evas_Object* ewkView = evas_object_smart_add(canvas, smart); if (!ewkView) return 0; @@ -660,22 +711,44 @@ Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGrou return 0; } - priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), ewkView); + return ewkView; +} - WKPageRef wkPage = toAPI(priv->pageClient->page()); - ewk_view_form_client_attach(wkPage, ewkView); - ewk_view_loader_client_attach(wkPage, ewkView); - ewk_view_policy_client_attach(wkPage, ewkView); - ewk_view_resource_load_client_attach(wkPage, ewkView); +/** + * @internal + * Constructs a ewk_view Evas_Object with WKType parameters. + */ +Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(contextRef, 0); + Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, _ewk_view_smart_class_new()); + if (!ewkView) + return 0; - ewk_view_theme_set(ewkView, DEFAULT_THEME_PATH"/default.edj"); + _ewk_view_initialize(ewkView, ewk_context_new_from_WKContext(contextRef), pageGroupRef); + + return ewkView; +} + +Evas_Object* ewk_view_smart_add(Evas* canvas, Evas_Smart* smart, Ewk_Context* context) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(smart, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0); + + Evas_Object* ewkView = _ewk_view_add_with_smart(canvas, smart); + if (!ewkView) + return 0; + + _ewk_view_initialize(ewkView, context, 0); return ewkView; } Evas_Object* ewk_view_add_with_context(Evas* canvas, Ewk_Context* context) { - return ewk_view_base_add(canvas, ewk_context_WKContext_get(context), 0); + return ewk_view_smart_add(canvas, _ewk_view_smart_class_new(), context); } Evas_Object* ewk_view_add(Evas* canvas) @@ -867,6 +940,17 @@ const char* ewk_view_title_get(const Evas_Object* ewkView) /** * @internal + * Reports that the requested text was found. + * + * Emits signal: "text,found" with the number of matches. + */ +void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount) +{ + evas_object_smart_callback_call(ewkView, "text,found", &matchCount); +} + +/** + * @internal * The view title was changed by the frame loader. * * Emits signal: "title,changed" with pointer to new title string. @@ -1020,6 +1104,13 @@ void ewk_view_display(Evas_Object* ewkView, const IntRect& rect) if (!smartData->image) return; +#if USE(COORDINATED_GRAPHICS) + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + + evas_gl_make_current(priv->evasGl, priv->evasGlSurface, priv->evasGlContext); + priv->viewportHandler->display(rect); +#endif + evas_object_image_data_update_add(smartData->image, rect.x(), rect.y(), rect.width(), rect.height()); } @@ -1128,6 +1219,14 @@ Eina_Bool ewk_view_forward_possible(Evas_Object* ewkView) return priv->pageClient->page()->canGoForward(); } +Ewk_Back_Forward_List* ewk_view_back_forward_list_get(const Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0); + + return priv->backForwardList; +} + void ewk_view_image_data_set(Evas_Object* ewkView, void* imageData, const IntSize& size) { EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); @@ -1297,3 +1396,61 @@ Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object* ewkView, const char* return true; } + +void ewk_view_page_close(Evas_Object* ewkView) +{ + evas_object_smart_callback_call(ewkView, "close,window", 0); +} + +WKPageRef ewk_view_page_create(Evas_Object* ewkView) +{ + Evas_Object* newEwkView = 0; + evas_object_smart_callback_call(ewkView, "create,window", &newEwkView); + + if (!newEwkView) + return 0; + + return static_cast<WKPageRef>(WKRetain(ewk_view_page_get(newEwkView))); +} + +// EwkFindOptions should be matched up orders with WkFindOptions. +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_CASE_INSENSITIVE, kWKFindOptionsCaseInsensitive); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_AT_WORD_STARTS, kWKFindOptionsAtWordStarts); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, kWKFindOptionsTreatMedialCapitalAsWordStart); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_BACKWARDS, kWKFindOptionsBackwards); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_WRAP_AROUND, kWKFindOptionsWrapAround); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_OVERLAY, kWKFindOptionsShowOverlay); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR, kWKFindOptionsShowFindIndicator); +COMPILE_ASSERT_MATCHING_ENUM(EWK_FIND_OPTIONS_SHOW_HIGHLIGHT, kWKFindOptionsShowHighlight); + +Eina_Bool ewk_view_text_find(Evas_Object* ewkView, const char* text, Ewk_Find_Options options, unsigned int maxMatchCount) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + EINA_SAFETY_ON_NULL_RETURN_VAL(text, false); + + WKRetainPtr<WKStringRef> findText(AdoptWK, WKStringCreateWithUTF8CString(text)); + WKPageFindString(toAPI(priv->pageClient->page()), findText.get(), static_cast<WKFindOptions>(options), maxMatchCount); + + return true; +} + +Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object* ewkView) +{ + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); + + WKPageHideFindUI(toAPI(priv->pageClient->page())); + + return true; +} + +void ewk_view_contents_size_changed(const Evas_Object* ewkView, const IntSize& size) +{ +#if USE(COORDINATED_GRAPHICS) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv); + + priv->viewportHandler->didChangeContentsSize(size); +#endif +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index 057f725bd..423f9e143 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -26,6 +26,8 @@ * * The following signals (see evas_object_smart_callback_add()) are emitted: * + * - "close,window", void: window is closed. + * - "create,window", Evas_Object**: a new window is created. * - "download,cancelled", Ewk_Download_Job*: reports that a download was effectively cancelled. * - "download,failed", Ewk_Download_Job_Error*: reports that a download failed with the given error. * - "download,finished", Ewk_Download_Job*: reports that a download completed successfully. @@ -59,6 +61,7 @@ * - "resource,request,new", const Ewk_Web_Resource_Request*: a resource request was initiated. * - "resource,request,response", Ewk_Web_Resource_Load_Response*: a response to a resource request was received. * - "resource,request,sent", const Ewk_Web_Resource_Request*: a resource request was sent. + * - "text,found", unsigned int*: the requested text was found and it gives the number of matches. * - "title,changed", const char*: title of the main frame was changed. * - "uri,changed", const char*: uri of the main frame was changed. */ @@ -66,6 +69,7 @@ #ifndef ewk_view_h #define ewk_view_h +#include "ewk_back_forward_list.h" #include "ewk_context.h" #include "ewk_download_job.h" #include "ewk_intent.h" @@ -216,6 +220,62 @@ struct _Ewk_Download_Job_Error { }; /** + * Enum values used to specify search options. + * @brief Provides option to find text + * @info Keep this in sync with WKFindOptions.h + */ +enum _Ewk_Find_Options { + EWK_FIND_OPTIONS_NONE, /**< no search flags, this means a case sensitive, no wrap, forward only search. */ + EWK_FIND_OPTIONS_CASE_INSENSITIVE = 1 << 0, /**< case insensitive search. */ + EWK_FIND_OPTIONS_AT_WORD_STARTS = 1 << 1, /**< search text only at the beginning of the words. */ + EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START = 1 << 2, /**< treat capital letters in the middle of words as word start. */ + EWK_FIND_OPTIONS_BACKWARDS = 1 << 3, /**< search backwards. */ + EWK_FIND_OPTIONS_WRAP_AROUND = 1 << 4, /**< if not present search will stop at the end of the document. */ + EWK_FIND_OPTIONS_SHOW_OVERLAY = 1 << 5, /**< show overlay */ + EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR = 1 << 6, /**< show indicator */ + EWK_FIND_OPTIONS_SHOW_HIGHLIGHT = 1 << 7 /**< show highlight */ +}; +typedef enum _Ewk_Find_Options Ewk_Find_Options; + +/** + * Sets the smart class APIs, enabling view to be inherited. + * + * @param api class definition to set, all members with the + * exception of @a Evas_Smart_Class->data may be overridden, must + * @b not be @c NULL + * + * @note @a Evas_Smart_Class->data is used to implement type checking and + * is not supposed to be changed/overridden. If you need extra + * data for your smart class to work, just extend + * Ewk_View_Smart_Class instead. + * The Evas_Object which inherits the ewk_view should use + * ewk_view_smart_add() to create Evas_Object instead of + * evas_object_smart_add() because it performs additional initialization + * for the ewk_view. + * + * @return @c EINA_TRUE on success or @c EINA_FALSE on failure (probably + * version mismatch) + * + * @see ewk_view_smart_add() + */ +EAPI Eina_Bool ewk_view_smart_class_set(Ewk_View_Smart_Class *api); + +/** + * Creates a new EFL WebKit view object with Evas_Smart and Ewk_Context. + * + * @note The Evas_Object which inherits the ewk_view should create its + * Evas_Object using this API instead of evas_object_smart_add() + * because the default initialization for ewk_view is done in this API. + * + * @param e canvas object where to create the view object + * @param smart Evas_Smart object. Its type should be EWK_VIEW_TYPE_STR + * @param context Ewk_Context object which is used for initializing + * + * @return view object on success or @c NULL on failure + */ +Evas_Object *ewk_view_smart_add(Evas *e, Evas_Smart *smart, Ewk_Context *context); + +/** * Creates a new EFL WebKit view object. * * @param e canvas object where to create the view object @@ -336,6 +396,21 @@ EAPI Eina_Bool ewk_view_back_possible(Evas_Object *o); EAPI Eina_Bool ewk_view_forward_possible(Evas_Object *o); /** + * Gets the back-forward list associated with this view. + * + * The returned instance is unique for this view and thus multiple calls + * to this function with the same view as parameter returns the same + * handle. This handle is alive while view is alive, thus one + * might want to listen for EVAS_CALLBACK_DEL on given view + * (@a o) to know when to stop using returned handle. + * + * @param o view object to get navigation back-forward list + * + * @return the back-forward list instance handle associated with this view + */ +EAPI Ewk_Back_Forward_List *ewk_view_back_forward_list_get(const Evas_Object *o); + +/** * Gets the current title of the main frame. * * It returns an internal string and should not @@ -494,6 +569,27 @@ EAPI const char *ewk_view_setting_encoding_custom_get(const Evas_Object *o); */ EAPI Eina_Bool ewk_view_setting_encoding_custom_set(Evas_Object *o, const char *encoding); +/** +* Searches the given string in the document. +* +* @param o view object to find text +* @param text text to find +* @param options options to find +* @param max count to find, unlimited if 0 +* +* @return @c EINA_TRUE on success, @c EINA_FALSE on errors +*/ +EAPI Eina_Bool ewk_view_text_find(Evas_Object *o, const char *text, Ewk_Find_Options options, unsigned int max_match_count); + +/** +* Clears the highlight of searched text. +* +* @param o view object to find text +* +* @return @c EINA_TRUE on success, @c EINA_FALSE on errors +*/ +EAPI Eina_Bool ewk_view_text_find_highlight_clear(Evas_Object *o); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp new file mode 100644 index 000000000..2a0dacaa3 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "WKPage.h" +#include "ewk_view_find_client_private.h" +#include "ewk_view_private.h" + +static inline Evas_Object* toEwkView(const void* clientInfo) +{ + return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); +} + +static void didFindString(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo) +{ + ewk_view_text_found(toEwkView(clientInfo), static_cast<unsigned int>(matchCount)); +} + +void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView) +{ + WKPageFindClient findClient; + memset(&findClient, 0, sizeof(WKPageFindClient)); + findClient.version = kWKPageFindClientCurrentVersion; + findClient.clientInfo = ewkView; + findClient.didFindString = didFindString; + WKPageSetPageFindClient(pageRef, &findClient); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h new file mode 100644 index 000000000..c17143360 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_find_client_private.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_view_find_client_private_h +#define ewk_view_find_client_private_h + +#include <Evas.h> +#include <WebKit2/WKBase.h> + +void ewk_view_find_client_attach(WKPageRef pageRef, Evas_Object* ewkView); + +#endif // ewk_view_find_client_private_h diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp index cc8b120cd..2deb38e19 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp @@ -24,8 +24,10 @@ */ #include "config.h" +#include "ewk_view.h" #include "WKFrame.h" +#include "ewk_back_forward_list_private.h" #include "ewk_intent.h" #include "ewk_intent_private.h" #include "ewk_intent_service.h" @@ -123,6 +125,14 @@ static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef f ewk_web_error_free(ewkError); } +static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo) +{ + Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); + ASSERT(ewkView); + + ewk_back_forward_list_changed(ewk_view_back_forward_list_get(ewkView), addedItem, removedItems); +} + void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView) { WKPageLoaderClient loadClient; @@ -144,5 +154,6 @@ void ewk_view_loader_client_attach(WKPageRef pageRef, Evas_Object* ewkView) loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; loadClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame; loadClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame; + loadClient.didChangeBackForwardList = didChangeBackForwardList; WKPageSetPageLoaderClient(pageRef, &loadClient); } diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index 3b57a7618..f40298587 100644 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -61,12 +61,16 @@ void ewk_view_load_provisional_redirect(Evas_Object* ewkView); void ewk_view_load_provisional_started(Evas_Object* ewkView); void ewk_view_navigation_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision); void ewk_view_new_window_policy_decision(Evas_Object* ewkView, Ewk_Navigation_Policy_Decision* decision); +void ewk_view_page_close(Evas_Object* ewkView); +WKPageRef ewk_view_page_create(Evas_Object* ewkView); void ewk_view_title_changed(Evas_Object* ewkView, const char* title); void ewk_view_resource_load_failed(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Error* error); void ewk_view_resource_load_finished(Evas_Object* ewkView, uint64_t resourceIdentifier); void ewk_view_resource_load_initiated(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Web_Resource* resource, Ewk_Url_Request* request); void ewk_view_resource_load_response(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Response* response); void ewk_view_resource_request_sent(Evas_Object* ewkView, uint64_t resourceIdentifier, Ewk_Url_Request* request, Ewk_Url_Response* redirectResponse); +void ewk_view_text_found(Evas_Object* ewkView, unsigned int matchCount); +void ewk_view_contents_size_changed(const Evas_Object* ewkView, const WebCore::IntSize&); Evas_Object* ewk_view_base_add(Evas* canvas, WKContextRef, WKPageGroupRef); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp new file mode 100644 index 000000000..18ede08a1 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "ewk_view_private.h" +#include "ewk_view_ui_client_private.h" + +static inline Evas_Object* toEwkView(const void* clientInfo) +{ + return static_cast<Evas_Object*>(const_cast<void*>(clientInfo)); +} + +static void closePage(WKPageRef, const void* clientInfo) +{ + ewk_view_page_close(toEwkView(clientInfo)); +} + +static WKPageRef createNewPage(WKPageRef, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void* clientInfo) +{ + return ewk_view_page_create(toEwkView(clientInfo)); +} + +void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView) +{ + WKPageUIClient uiClient; + memset(&uiClient, 0, sizeof(WKPageUIClient)); + uiClient.version = kWKPageUIClientCurrentVersion; + uiClient.clientInfo = ewkView; + uiClient.close = closePage; + uiClient.createNewPage = createNewPage; + WKPageSetPageUIClient(pageRef, &uiClient); +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h new file mode 100644 index 000000000..4c9c492a5 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_ui_client_private.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 Samsung Electronics. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ewk_view_ui_client_private_h +#define ewk_view_ui_client_private_h + +#include <Evas.h> +#include <WebKit2/WKBase.h> + +void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView); + +#endif // ewk_view_ui_client_private_h |