From cdaaf62f8c18cc72f7ed7ccaae7202cc43144f5c Mon Sep 17 00:00:00 2001 From: "gyuyoung.kim@samsung.com" Date: Wed, 18 Jan 2012 04:28:36 +0000 Subject: [PATCH] [EFL] Use static const insted of #define macro. https://bugs.webkit.org/show_bug.cgi?id=76499 Reviewed by Hajime Morita. WebKit coding style prefers const to #define. EFL port needs to use const insted of #define macro. This patch replace global variables defined by #define with const. * ewk/ewk_tiled_backing_store.cpp: (_ewk_tiled_backing_store_smart_add): (_ewk_tiled_backing_store_zoom_set_internal): * ewk/ewk_tiled_backing_store.h: * ewk/ewk_tiled_matrix.cpp: (ewk_tile_matrix_new): * ewk/ewk_view.cpp: (_ewk_view_repaint_add): (_ewk_view_repaints_flush): (_ewk_view_scroll_add): (_ewk_view_scrolls_flush): (_ewk_view_priv_new): (ewk_view_base_smart_set): * ewk/ewk_view_tiled.cpp: (_ewk_view_tiled_smart_pre_render_start): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105240 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebKit/efl/ChangeLog | 26 ++++++++++++ Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp | 8 ++-- Source/WebKit/efl/ewk/ewk_tiled_backing_store.h | 6 +-- Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp | 4 +- Source/WebKit/efl/ewk/ewk_view.cpp | 50 +++++++++++------------ Source/WebKit/efl/ewk/ewk_view_tiled.cpp | 6 +-- 6 files changed, 63 insertions(+), 37 deletions(-) diff --git a/Source/WebKit/efl/ChangeLog b/Source/WebKit/efl/ChangeLog index 2746dde..d87e04c 100644 --- a/Source/WebKit/efl/ChangeLog +++ b/Source/WebKit/efl/ChangeLog @@ -1,3 +1,29 @@ +2012-01-17 Gyuyoung Kim + + [EFL] Use static const insted of #define macro. + https://bugs.webkit.org/show_bug.cgi?id=76499 + + Reviewed by Hajime Morita. + + WebKit coding style prefers const to #define. EFL port needs to use const insted of #define macro. + This patch replace global variables defined by #define with const. + + * ewk/ewk_tiled_backing_store.cpp: + (_ewk_tiled_backing_store_smart_add): + (_ewk_tiled_backing_store_zoom_set_internal): + * ewk/ewk_tiled_backing_store.h: + * ewk/ewk_tiled_matrix.cpp: + (ewk_tile_matrix_new): + * ewk/ewk_view.cpp: + (_ewk_view_repaint_add): + (_ewk_view_repaints_flush): + (_ewk_view_scroll_add): + (_ewk_view_scrolls_flush): + (_ewk_view_priv_new): + (ewk_view_base_smart_set): + * ewk/ewk_view_tiled.cpp: + (_ewk_view_tiled_smart_pre_render_start): + 2012-01-13 Raphael Kubo da Costa [EFL] Emit "resource,request,willsend" from ewk_view. diff --git a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp index ffc671c..4cdd72d 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp +++ b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp @@ -696,8 +696,8 @@ static void _ewk_tiled_backing_store_smart_add(Evas_Object* ewkBackingStore) priv->self = ewkBackingStore; priv->view.tile.zoom = 1.0; - priv->view.tile.width = DEFAULT_TILE_W; - priv->view.tile.height = DEFAULT_TILE_H; + priv->view.tile.width = defaultTileWidth; + priv->view.tile.height = defaultTileHeigth; priv->view.offset.cur.x = 0; priv->view.offset.cur.y = 0; priv->view.offset.old.x = 0; @@ -1485,9 +1485,9 @@ static Eina_Bool _ewk_tiled_backing_store_zoom_set_internal(Ewk_Tiled_Backing_St *offsetX = priv->view.offset.cur.x; *offsetY = priv->view.offset.cur.y; - if (fabsf(priv->view.tile.zoom - *zoom) < ZOOM_STEP_MIN) { + if (fabsf(priv->view.tile.zoom - *zoom) < zoomStepMinimum) { DBG("ignored as zoom difference is < %f: %f", - (double)ZOOM_STEP_MIN, fabsf(priv->view.tile.zoom - *zoom)); + (double)zoomStepMinimum, fabsf(priv->view.tile.zoom - *zoom)); return true; } diff --git a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h index 44740cb..e93ccf7 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h +++ b/Source/WebKit/efl/ewk/ewk_tiled_backing_store.h @@ -33,10 +33,10 @@ */ #undef DEBUG_MEM_LEAKS -#define DEFAULT_TILE_W (256) -#define DEFAULT_TILE_H (256) +const int defaultTileWidth = 256; +const int defaultTileHeigth = 256; -#define ZOOM_STEP_MIN (0.01) +const float zoomStepMinimum = 0.01; #define TILE_SIZE_AT_ZOOM(SIZE, ZOOM) ((int)roundf((SIZE) * (ZOOM))) #define TILE_ZOOM_AT_SIZE(SIZE, ORIG_TILE) ((float)(SIZE) / (float)(ORIG_TILE)) diff --git a/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp b/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp index 95e2319..ab06042 100644 --- a/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp +++ b/Source/WebKit/efl/ewk/ewk_tiled_matrix.cpp @@ -225,8 +225,8 @@ Ewk_Tile_Matrix* ewk_tile_matrix_new(Ewk_Tile_Unused_Cache* tileUnusedCache, uns tileMatrix->cspace = colorSpace; tileMatrix->render.callback = renderCallback; tileMatrix->render.data = (void*)renderData; - tileMatrix->tile.width = DEFAULT_TILE_W; - tileMatrix->tile.height = DEFAULT_TILE_H; + tileMatrix->tile.width = defaultTileWidth; + tileMatrix->tile.height = defaultTileHeigth; return tileMatrix; } diff --git a/Source/WebKit/efl/ewk/ewk_view.cpp b/Source/WebKit/efl/ewk/ewk_view.cpp index 535400b..f3385bd 100644 --- a/Source/WebKit/efl/ewk/ewk_view.cpp +++ b/Source/WebKit/efl/ewk/ewk_view.cpp @@ -68,20 +68,20 @@ #include "DeviceOrientationClientEfl.h" #endif -#define ZOOM_MIN (0.05) -#define ZOOM_MAX (4.0) +static const float zoomMinimum = 0.05; +static const float zoomMaximum = 4.0; -#define DEVICE_PIXEL_RATIO (1.0) +static const float devicePixelRatio = 1.0; -static const char EWK_VIEW_TYPE_STR[] = "EWK_View"; +static const char ewkViewTypeString[] = "EWK_View"; -static const size_t EWK_VIEW_REPAINTS_SIZE_INITIAL = 32; -static const size_t EWK_VIEW_REPAINTS_SIZE_STEP = 8; -static const size_t EWK_VIEW_REPAINTS_SIZE_MAX_FREE = 64; +static const size_t ewkViewRepaintsSizeInitial = 32; +static const size_t ewkViewRepaintsSizeStep = 8; +static const size_t ewkViewRepaintsSizeMaximumFree = 64; -static const size_t EWK_VIEW_SCROLLS_SIZE_INITIAL = 8; -static const size_t EWK_VIEW_SCROLLS_SIZE_STEP = 2; -static const size_t EWK_VIEW_SCROLLS_SIZE_MAX_FREE = 32; +static const size_t ewkViewScrollsSizeInitial = 8; +static const size_t ewkViewScrollsSizeStep = 2; +static const size_t ewkViewScrollsSizeMaximumFree = 32; static const Evas_Smart_Cb_Description _ewk_view_callback_names[] = { { "download,request", "p" }, @@ -233,11 +233,11 @@ struct _Ewk_View_Private_Data { _tmp_otype ? _tmp_otype : "(null)"); \ return __VA_ARGS__; \ } \ - if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \ + if (EINA_UNLIKELY(_tmp_sc->data != ewkViewTypeString)) { \ EINA_LOG_CRIT \ ("%p (%s) is not of an ewk_view (need %p, got %p)!", \ ewkView, _tmp_otype ? _tmp_otype : "(null)", \ - EWK_VIEW_TYPE_STR, _tmp_sc->data); \ + ewkViewTypeString, _tmp_sc->data); \ return __VA_ARGS__; \ } \ } while (0) @@ -297,9 +297,9 @@ static void _ewk_view_repaint_add(Ewk_View_Private_Data* priv, Evas_Coord x, Eva size_t newSize = 0; if (priv->repaints.allocated == priv->repaints.count) - newSize = priv->repaints.allocated + EWK_VIEW_REPAINTS_SIZE_STEP; - else if (!priv->repaints.count && priv->repaints.allocated > EWK_VIEW_REPAINTS_SIZE_INITIAL) - newSize = EWK_VIEW_REPAINTS_SIZE_INITIAL; + newSize = priv->repaints.allocated + ewkViewRepaintsSizeStep; + else if (!priv->repaints.count && priv->repaints.allocated > ewkViewRepaintsSizeInitial) + newSize = ewkViewRepaintsSizeInitial; if (newSize) { if (!_ewk_view_repaints_resize(priv, newSize)) @@ -320,9 +320,9 @@ static void _ewk_view_repaint_add(Ewk_View_Private_Data* priv, Evas_Coord x, Eva static void _ewk_view_repaints_flush(Ewk_View_Private_Data* priv) { priv->repaints.count = 0; - if (priv->repaints.allocated <= EWK_VIEW_REPAINTS_SIZE_MAX_FREE) + if (priv->repaints.allocated <= ewkViewRepaintsSizeMaximumFree) return; - _ewk_view_repaints_resize(priv, EWK_VIEW_REPAINTS_SIZE_MAX_FREE); + _ewk_view_repaints_resize(priv, ewkViewRepaintsSizeMaximumFree); } static Eina_Bool _ewk_view_scrolls_resize(Ewk_View_Private_Data* priv, size_t size) @@ -366,9 +366,9 @@ static void _ewk_view_scroll_add(Ewk_View_Private_Data* priv, Evas_Coord deltaX, if (priv->scrolls.allocated == priv->scrolls.count) { size_t size; if (!priv->scrolls.allocated) - size = EWK_VIEW_SCROLLS_SIZE_INITIAL; + size = ewkViewScrollsSizeInitial; else - size = priv->scrolls.allocated + EWK_VIEW_SCROLLS_SIZE_STEP; + size = priv->scrolls.allocated + ewkViewScrollsSizeStep; if (!_ewk_view_scrolls_resize(priv, size)) return; } @@ -401,9 +401,9 @@ static void _ewk_view_scroll_add(Ewk_View_Private_Data* priv, Evas_Coord deltaX, static void _ewk_view_scrolls_flush(Ewk_View_Private_Data* priv) { priv->scrolls.count = 0; - if (priv->scrolls.allocated <= EWK_VIEW_SCROLLS_SIZE_MAX_FREE) + if (priv->scrolls.allocated <= ewkViewScrollsSizeMaximumFree) return; - _ewk_view_scrolls_resize(priv, EWK_VIEW_SCROLLS_SIZE_MAX_FREE); + _ewk_view_scrolls_resize(priv, ewkViewScrollsSizeMaximumFree); } // Default Event Handling ////////////////////////////////////////////// @@ -700,10 +700,10 @@ static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData) // Since there's no scale separated from zooming in webkit-efl, this functionality of // viewport meta tag is implemented using zoom. When scale zoom is supported by webkit-efl, // this functionality will be modified by the scale zoom patch. - priv->settings.zoomRange.minScale = ZOOM_MIN; - priv->settings.zoomRange.maxScale = ZOOM_MAX; + priv->settings.zoomRange.minScale = zoomMinimum; + priv->settings.zoomRange.maxScale = zoomMaximum; priv->settings.zoomRange.userScalable = true; - priv->settings.devicePixelRatio = DEVICE_PIXEL_RATIO; + priv->settings.devicePixelRatio = devicePixelRatio; priv->settings.domTimerInterval = priv->pageSettings->defaultMinDOMTimerInterval(); @@ -1136,7 +1136,7 @@ Eina_Bool ewk_view_base_smart_set(Ewk_View_Smart_Class* api) api->sc.calculate = _ewk_view_smart_calculate; api->sc.show = _ewk_view_smart_show; api->sc.hide = _ewk_view_smart_hide; - api->sc.data = EWK_VIEW_TYPE_STR; /* used by type checking */ + api->sc.data = ewkViewTypeString; /* used by type checking */ api->sc.callbacks = _ewk_view_callback_names; api->contents_resize = _ewk_view_smart_contents_resize; diff --git a/Source/WebKit/efl/ewk/ewk_view_tiled.cpp b/Source/WebKit/efl/ewk/ewk_view_tiled.cpp index 3101c12..b72d6ae 100644 --- a/Source/WebKit/efl/ewk/ewk_view_tiled.cpp +++ b/Source/WebKit/efl/ewk/ewk_view_tiled.cpp @@ -262,8 +262,8 @@ static Eina_Bool _ewk_view_tiled_smart_pre_render_start(Ewk_View_Smart_Data* sma // pre-render works when two conditions are met. // zoom has been changed. // and the view has been moved more than tile size. - if (abs(previousViewX - viewX) < DEFAULT_TILE_W - && abs(previousViewY - viewY) < DEFAULT_TILE_H + if (abs(previousViewX - viewX) < defaultTileWidth + && abs(previousViewY - viewY) < defaultTileHeigth && smartData->previousView.zoom == currentViewZoom) { return false; } @@ -295,7 +295,7 @@ static Eina_Bool _ewk_view_tiled_smart_pre_render_start(Ewk_View_Smart_Data* sma // Make a base rectangle as big as possible with using maxMemory. // and then reshape the base rectangle to fit to contents. const int baseSize = static_cast(sqrt(maxMemory / 4.0f)); - const float widthRate = (viewRect.w + (DEFAULT_TILE_W * 2)) / static_cast(baseSize); + const float widthRate = (viewRect.w + (defaultTileWidth * 2)) / static_cast(baseSize); const float heightRate = baseSize / static_cast(contentHeight); const float rectRate = std::max(widthRate, heightRate); -- 2.7.4