Changeset 164168 in webkit


Ignore:
Timestamp:
Feb 15, 2014 12:39:12 AM (10 years ago)
Author:
ryuan.choi@samsung.com
Message:

[EFL][WK1] Do not include cairo header in the public headers
https://bugs.webkit.org/show_bug.cgi?id=128779

Reviewed by Gyuyoung Kim.

Source/WebKit/efl:

Although ewebkit used cairo internally, it's not good for EFL developers
to use it.
Indeed, almost APIs which returns cairo_surface are duplicated with other APIs
which returns evas_object.

  • ewk/ewk_history.cpp:

Removed ewk_history_item_icon_surface_get.
ewk_history_item_icon_object_add will be used instead.

  • ewk/ewk_history.h:
  • ewk/ewk_settings.cpp:

Removed ewk_settings_icon_database_icon_surface_get.
ewk_settings_icon_database_icon_object_get will be used instead.

  • ewk/ewk_settings.h:
  • ewk/ewk_view.cpp:

(ewk_view_screenshot_contents_get):
Implemented to replace ewk_view_paint and ewk_view_paint_contents.

  • ewk/ewk_view.h:
  • tests/test_ewk_view.cpp:

(TEST_F): Added test case for ewk_view_screenshot_contents_get

Tools:

  • DumpRenderTree/PlatformEfl.cmake:
  • DumpRenderTree/efl/PixelDumpSupportEfl.cpp:

(createBitmapContextFromWebView):
Used ewk_view_screenshot_contents_get instead of ewk_view_paint.

  • EWebLauncher/main.c:

(print_history): Replaced ewk_history_item_icon_surface_get to ewk_history_item_icon_object_add
(on_key_down):

  • Scripts/webkitpy/style/checker.py:

Added -runtime/ctype_function for EWebLauncher because EWebLauncher is sample
and it does not use WTF.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/efl/ChangeLog

    r164028 r164168  
     12014-02-15  Ryuan Choi  <ryuan.choi@samsung.com>
     2
     3        [EFL][WK1] Do not include cairo header in the public headers
     4        https://bugs.webkit.org/show_bug.cgi?id=128779
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        Although ewebkit used cairo internally, it's not good for EFL developers
     9        to use it.
     10        Indeed, almost APIs which returns cairo_surface are duplicated with other APIs
     11        which returns evas_object.
     12
     13        * ewk/ewk_history.cpp:
     14        Removed ewk_history_item_icon_surface_get.
     15        ewk_history_item_icon_object_add will be used instead.
     16        * ewk/ewk_history.h:
     17        * ewk/ewk_settings.cpp:
     18        Removed ewk_settings_icon_database_icon_surface_get.
     19        ewk_settings_icon_database_icon_object_get will be used instead.
     20        * ewk/ewk_settings.h:
     21        * ewk/ewk_view.cpp:
     22        (ewk_view_screenshot_contents_get):
     23        Implemented to replace ewk_view_paint and ewk_view_paint_contents.
     24        * ewk/ewk_view.h:
     25        * tests/test_ewk_view.cpp:
     26        (TEST_F): Added test case for ewk_view_screenshot_contents_get
     27
    1282014-02-13  Ryuan Choi  <ryuan.choi@samsung.com>
    229
  • trunk/Source/WebKit/efl/ewk/ewk_history.cpp

    r162919 r164168  
    327327}
    328328
    329 cairo_surface_t* ewk_history_item_icon_surface_get(const Ewk_History_Item* item)
    330 {
    331     EWK_HISTORY_ITEM_CORE_GET_OR_RETURN(item, core, 0);
    332 
    333     RefPtr<cairo_surface_t> icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(core->url(), WebCore::IntSize(16, 16));
    334     if (!icon)
    335         ERR("icon is NULL.");
    336 
    337     return icon.get();
    338 }
    339 
    340329Evas_Object* ewk_history_item_icon_object_add(const Ewk_History_Item* item, Evas* canvas)
    341330{
  • trunk/Source/WebKit/efl/ewk/ewk_history.h

    r162919 r164168  
    2424#include <Eina.h>
    2525#include <Evas.h>
    26 #include <cairo.h>
    2726
    2827#ifdef __cplusplus
     
    353352
    354353/**
    355  * Get the icon (aka favicon) associated with this history item.
    356  *
    357  * @note in order to have this working, one must open icon database
    358  *       with ewk_settings_icon_database_path_set().
    359  *
    360  * @param item history item to query.
    361  *
    362  * @return the surface reference or @c NULL on errors. Note that the
    363  *         reference may be to a standard fallback icon.
    364  */
    365 EAPI cairo_surface_t  *ewk_history_item_icon_surface_get(const Ewk_History_Item *item);
    366 
    367 /**
    368354 * Add an Evas_Object of type 'image' to given canvas with history item icon.
    369355 *
  • trunk/Source/WebKit/efl/ewk/ewk_settings.cpp

    r164131 r164168  
    212212}
    213213
    214 cairo_surface_t* ewk_settings_icon_database_icon_surface_get(const char* url)
    215 {
    216     EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
    217 
    218     WebCore::URL kurl(WebCore::URL(), WTF::String::fromUTF8(url));
    219     RefPtr<cairo_surface_t> icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(kurl.string(), WebCore::IntSize(16, 16));
    220     if (!icon)
    221         ERR("no icon for url %s", url);
    222 
    223     return icon.get();
    224 }
    225 
    226214Evas_Object* ewk_settings_icon_database_icon_object_get(const char* url, Evas* canvas)
    227215{
  • trunk/Source/WebKit/efl/ewk/ewk_settings.h

    r149719 r164168  
    2525#include <Eina.h>
    2626#include <Evas.h>
    27 #include <cairo.h>
    2827
    2928#ifdef __cplusplus
     
    160159 */
    161160EAPI Eina_Bool        ewk_settings_icon_database_clear(void);
    162 
    163 /**
    164  * Queries icon for given URL, returning associated cairo surface.
    165  *
    166  * @note In order to have this working, one must open icon database
    167  *       with ewk_settings_icon_database_path_set().
    168  *
    169  * @param url which url to query icon
    170  *
    171  * @return cairo surface if any, or @c NULL on failure
    172  */
    173 EAPI cairo_surface_t *ewk_settings_icon_database_icon_surface_get(const char *url);
    174161
    175162/**
  • trunk/Source/WebKit/efl/ewk/ewk_view.cpp

    r164028 r164168  
    29312931}
    29322932
    2933 Eina_Bool ewk_view_paint(Ewk_View_Private_Data* priv, cairo_t* cr, const Eina_Rectangle* area)
    2934 {
    2935     EINA_SAFETY_ON_NULL_RETURN_VAL(priv, false);
    2936     EINA_SAFETY_ON_NULL_RETURN_VAL(cr, false);
    2937     EINA_SAFETY_ON_NULL_RETURN_VAL(area, false);
    2938 
    2939     WebCore::FrameView* view = priv->page->mainFrame().view();
    2940     EINA_SAFETY_ON_NULL_RETURN_VAL(view, false);
    2941 
    2942     view->updateLayoutAndStyleIfNeededRecursive();
    2943 
    2944     Ewk_Paint_Context* context = ewk_paint_context_new(cr);
    2945     bool result = ewk_view_paint(priv, context, area);
    2946     ewk_paint_context_free(context);
    2947 
    2948     return result;
    2949 }
    2950 
    2951 Eina_Bool ewk_view_paint_contents(Ewk_View_Private_Data* priv, cairo_t* cr, const Eina_Rectangle* area)
    2952 {
    2953     EINA_SAFETY_ON_NULL_RETURN_VAL(cr, false);
    2954 
    2955     Ewk_Paint_Context* context = ewk_paint_context_new(cr);
    2956     bool result = ewk_view_paint_contents(priv, context, area);
    2957     ewk_paint_context_free(context);
    2958 
    2959     return result;
    2960 }
    2961 
    29622933/* internal methods ****************************************************/
    29632934/**
     
    48504821}
    48514822
     4823Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* ewkView, const Eina_Rectangle* area, float scale)
     4824{
     4825    if (!area || !area->w || !area->h) {
     4826        ERR("empty area is not allowed");
     4827        return 0;
     4828    }
     4829
     4830    if (scale < std::numeric_limits<float>::epsilon()) {
     4831        ERR("scale factor should be bigger than zero");
     4832        return 0;
     4833    }
     4834
     4835    EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
     4836    EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
     4837
     4838    Evas* canvas = evas_object_evas_get(ewkView);
     4839    EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);
     4840
     4841    Evas_Object* screenshotImage = evas_object_image_add(canvas);
     4842    int surfaceWidth = area->w * scale;
     4843    int surfaceHeight = area->h * scale;
     4844    evas_object_image_size_set(screenshotImage, surfaceWidth, surfaceHeight);
     4845    evas_object_image_fill_set(screenshotImage, 0, 0, surfaceWidth, surfaceHeight);
     4846    evas_object_resize(screenshotImage, surfaceWidth, surfaceHeight);
     4847    evas_object_image_colorspace_set(screenshotImage, EVAS_COLORSPACE_ARGB8888);
     4848    evas_object_image_smooth_scale_set(screenshotImage, true);
     4849
     4850    Ewk_Paint_Context* context = ewk_paint_context_from_image_new(screenshotImage);
     4851    ewk_paint_context_save(context);
     4852    ewk_paint_context_scale(context, scale, scale);
     4853    ewk_paint_context_translate(context, -1 * area->x, -1 * area->y);
     4854
     4855    ewk_view_paint(priv, context, area);
     4856
     4857    ewk_paint_context_restore(context);
     4858    ewk_paint_context_free(context);
     4859
     4860    return screenshotImage;
     4861}
     4862
    48524863Eina_Bool ewk_view_setting_tiled_backing_store_enabled_set(Evas_Object* ewkView, Eina_Bool enable)
    48534864{
  • trunk/Source/WebKit/efl/ewk/ewk_view.h

    r164028 r164168  
    123123
    124124#include <Evas.h>
    125 #include <cairo.h>
    126125
    127126#ifdef __cplusplus
     
    20532052
    20542053/**
    2055  * Paints using given graphics context the given area.
    2056  *
    2057  * This uses viewport relative area and will also handle scrollbars
    2058  * and other extra elements. See ewk_view_paint_contents() for the
    2059  * alternative function.
    2060  *
    2061  * @param priv the pointer to the private data of the view to use as paint source
    2062  * @param cr the cairo context to use as paint destination, its state will
    2063  *        be saved before operation and restored afterwards
    2064  * @param area viewport relative geometry to paint
    2065  *
    2066  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
    2067  *
    2068  * @note This is an easy to use version, but internal structures are
    2069  *       always created, then graphics context is clipped, then
    2070  *       painted, restored and destroyed. This might not be optimum,
    2071  *       so using @a Ewk_View_Paint_Context may be a better solutions
    2072  *       for large number of operations.
    2073  *
    2074  * @see ewk_view_paint_contents()
    2075  * @see ewk_view_paint_context_paint()
    2076  *
    2077  * @note This is not for general use but just for subclasses that want
    2078  *       to define their own backing store.
    2079  */
    2080 EAPI Eina_Bool ewk_view_paint(Ewk_View_Private_Data *priv, cairo_t *cr, const Eina_Rectangle *area);
    2081 
    2082 /**
    2083  * Paints just contents using given graphics context the given area.
    2084  *
    2085  * This uses absolute coordinates for area and will just handle
    2086  * contents, no scrollbars or extras. See ewk_view_paint() for the
    2087  * alternative solution.
    2088  *
    2089  * @param priv the pointer to the private data of the view to use as paint source
    2090  * @param cr the cairo context to use as paint destination, its state will
    2091  *        be saved before operation and restored afterwards
    2092  * @param area absolute geometry to paint
    2093  *
    2094  * @return @c EINA_TRUE on success or @c EINA_FALSE on failure
    2095  *
    2096  * @note This is an easy to use version, but internal structures are
    2097  *       always created, then graphics context is clipped, then
    2098  *       painted, restored and destroyed. This might not be optimum,
    2099  *       so using @a Ewk_View_Paint_Context may be a better solutions
    2100  *       for large number of operations.
    2101  *
    2102  * @see ewk_view_paint()
    2103  * @see ewk_view_paint_context_paint_contents()
    2104  *
    2105  * @note This is not for general use but just for subclasses that want
    2106  *       to define their own backing store.
    2107  */
    2108 EAPI Eina_Bool ewk_view_paint_contents(Ewk_View_Private_Data *priv, cairo_t *cr, const Eina_Rectangle *area);
    2109 
    2110 /**
    21112054 * Gets the attributes of the viewport meta tag.
    21122055 *
     
    25432486EAPI Ewk_Context_Menu *ewk_view_context_menu_get(const Evas_Object *o);
    25442487
     2488/**
     2489 * Gets the image object of the specified area of the page
     2490 *
     2491 * The returned image object @b should be freed after use.
     2492 *
     2493 * @param o view object to be captured
     2494 * @param area The area of the page will be captured.
     2495 * @param scale scale factor of captured object.
     2496 *
     2497 * @return newly allocated image object on sucess or @c NULL on failure.
     2498 */
     2499EAPI Evas_Object *ewk_view_screenshot_contents_get(const Evas_Object *o, const Eina_Rectangle *area, float scale);
     2500
    25452501#ifdef __cplusplus
    25462502}
  • trunk/Source/WebKit/efl/tests/test_ewk_view.cpp

    r161331 r164168  
    126126    ASSERT_TRUE(ewk_view_context_menu_get(webView()));
    127127}
     128
     129TEST_F(EWKTestBase, ewk_view_screenshot_contents_get)
     130{
     131    loadUrl();
     132
     133    Evas_Coord width, height;
     134
     135    float scale = 2;
     136    Eina_Rectangle area;
     137    area.x = 10;
     138    area.y = 10;
     139    area.w = 20;
     140    area.h = 30;
     141    Evas_Object* screenshot = ewk_view_screenshot_contents_get(webView(), &area, scale);
     142    evas_object_geometry_get(screenshot, 0, 0, &width, &height);
     143    ASSERT_EQ(area.w * scale, width);
     144    ASSERT_EQ(area.h * scale, height);
     145    evas_object_del(screenshot);
     146
     147    screenshot = ewk_view_screenshot_contents_get(webView(), &area, 0);
     148    ASSERT_FALSE(screenshot);
     149
     150    screenshot = ewk_view_screenshot_contents_get(webView(), 0, 1);
     151    ASSERT_FALSE(screenshot);
     152
     153    area.w = 0;
     154    area.h = 0;
     155    screenshot = ewk_view_screenshot_contents_get(webView(), &area, scale);
     156    ASSERT_FALSE(screenshot);
     157}
  • trunk/Tools/ChangeLog

    r164165 r164168  
     12014-02-15  Ryuan Choi  <ryuan.choi@samsung.com>
     2
     3        [EFL][WK1] Do not include cairo header in the public headers
     4        https://bugs.webkit.org/show_bug.cgi?id=128779
     5
     6        Reviewed by Gyuyoung Kim.
     7
     8        * DumpRenderTree/PlatformEfl.cmake:
     9        * DumpRenderTree/efl/PixelDumpSupportEfl.cpp:
     10        (createBitmapContextFromWebView):
     11        Used ewk_view_screenshot_contents_get instead of ewk_view_paint.
     12        * EWebLauncher/main.c:
     13        (print_history): Replaced ewk_history_item_icon_surface_get to ewk_history_item_icon_object_add
     14        (on_key_down):
     15        * Scripts/webkitpy/style/checker.py:
     16        Added -runtime/ctype_function for EWebLauncher because EWebLauncher is sample
     17        and it does not use WTF.
     18
    1192014-02-15  Samuel White  <samuel_white@apple.com>
    220
  • trunk/Tools/DumpRenderTree/PlatformEfl.cmake

    r162060 r164168  
    4747    ${WEBCORE_DIR}/platform/graphics/cairo
    4848    ${WEBCORE_DIR}/platform/network/soup
     49    ${WTF_DIR}/wtf/efl
    4950    ${TOOLS_DIR}/DumpRenderTree/atk
    5051    ${TOOLS_DIR}/DumpRenderTree/cairo
  • trunk/Tools/DumpRenderTree/efl/PixelDumpSupportEfl.cpp

    r135118 r164168  
    3838#include "PixelDumpSupportCairo.h"
    3939#include "RefPtrCairo.h"
     40#include "RefPtrEfl.h"
    4041#include "WebCoreSupport/DumpRenderTreeSupportEfl.h"
    4142#include "ewk_view.h"
     
    5455    RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
    5556
    56     if (!ewk_view_paint(privateData, context.get(), &rect))
     57    RefPtr<Evas_Object> screenshot = ewk_view_screenshot_contents_get(browser->mainView(), &rect, 1);
     58    if (!screenshot)
    5759        return 0;
     60
     61    uint8_t* pixels = static_cast<uint8_t*>(evas_object_image_data_get(screenshot.get(), false));
     62    RefPtr<cairo_surface_t> sourceSurface = adoptRef(cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, rect.w, rect.h, rect.w * 4));
     63    cairo_set_source_surface(context.get(), sourceSurface.get(), 0, 0);
    5864
    5965    if (DumpRenderTreeSupportEfl::isTrackingRepaints(mainFrame)) {
  • trunk/Tools/EWebLauncher/main.c

    r163079 r164168  
    22 * Copyright (C) 2008 INdT - Instituto Nokia de Tecnologia
    33 * Copyright (C) 2009, 2010 ProFUSION embedded systems
    4  * Copyright (C) 2009, 2010, 2011 Samsung Electronics
     4 * Copyright (C) 2009-2014 Samsung Electronics
    55 * Copyright (C) 2012 Intel Corporation
    66 *
     
    9898    "(C)2008 INdT (The Nokia Technology Institute)\n"
    9999    "(C)2009, 2010 ProFUSION embedded systems\n"
    100     "(C)2009, 2010, 2011 Samsung Electronics\n"
     100    "(C)2009-2014 Samsung Electronics\n"
    101101    "(C)2012 Intel Corporation\n",
    102102    "GPL",
     
    183183
    184184static void
    185 print_history(Eina_List *list)
     185print_history(Eina_List *list, Evas *e)
    186186{
    187187    Eina_List *l;
     
    189189
    190190    if (!verbose)
    191        return;
     191        return;
    192192
    193193    printf("Session history contains:\n");
    194194
    195195    EINA_LIST_FOREACH(list, l, d) {
    196        Ewk_History_Item *item = (Ewk_History_Item*)d;
    197        cairo_surface_t *cs = ewk_history_item_icon_surface_get(item);
    198        char buf[PATH_MAX];
    199        int s = snprintf(buf, sizeof(buf), "/tmp/favicon-%s.png", ewk_history_item_uri_original_get(item));
    200        for (s--; s >= (int)sizeof("/tmp/favicon-"); s--) {
    201            if (!isalnum(buf[s]) && buf[s] != '.')
    202                buf[s] = '_';
    203        }
    204        cs = ewk_history_item_icon_surface_get(item);
    205 
    206        if (cs && cairo_surface_status(cs) == CAIRO_STATUS_SUCCESS)
    207            cairo_surface_write_to_png(cs, buf);
    208        else
    209            buf[0] = '\0';
    210 
    211        printf("* '%s' title='%s' icon='%s'\n",
    212               ewk_history_item_uri_original_get(item),
    213               ewk_history_item_title_get(item), buf);
     196        Ewk_History_Item *item = (Ewk_History_Item*)d;
     197        Evas_Object *icon = ewk_history_item_icon_object_add(item, e);
     198        char buf[PATH_MAX];
     199        int s = snprintf(buf, sizeof(buf), "/tmp/favicon-%s.png", ewk_history_item_uri_original_get(item));
     200        for (s--; s >= (int)sizeof("/tmp/favicon-"); s--) {
     201            if (!isalnum(buf[s]) && buf[s] != '.')
     202                buf[s] = '_';
     203        }
     204
     205        evas_object_image_save(icon, buf, NULL, NULL);
     206
     207        printf("* '%s' title='%s' icon='%s'\n", ewk_history_item_uri_original_get(item), ewk_history_item_title_get(item), buf);
    214208    }
    215209}
     
    500494            Ewk_History *history = ewk_view_history_get(obj);
    501495            Eina_List *list = ewk_history_back_list_get(history);
    502             print_history(list);
     496            print_history(list, e);
    503497            ewk_history_item_list_free(list);
    504498            ewk_view_back(obj);
     
    510504            Ewk_History *history = ewk_view_history_get(obj);
    511505            Eina_List *list = ewk_history_forward_list_get(history);
    512             print_history(list);
     506            print_history(list, e);
    513507            ewk_history_item_list_free(list);
    514508            ewk_view_forward(obj);
  • trunk/Tools/Scripts/webkitpy/style/checker.py

    r161366 r164168  
    205205     ["-readability/naming",
    206206      "-readability/parameter_name",
     207      "-runtime/ctype_function",
    207208      "-whitespace/declaration",
    208209      "-build/include_order"]),
Note: See TracChangeset for help on using the changeset viewer.