Source/WebKit/efl/ChangeLog

 12011-10-26 Gyuyoung Kim <gyuyoung.kim@samsung.com>
 2
 3 [EFL} Use template functions instead of memory allocation of C functions.
 4 https://bugs.webkit.org/show_bug.cgi?id=70883
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This is a fourth step in order to be more compliant with WebKit coding style.
 9 Use memory macros instead of malloc, calloc and realloc directly. It makes efl port
 10 is more close to C++ coding style.
 11
 12 * ewk/ewk_auth_soup.cpp:
 13 * ewk/ewk_contextmenu.cpp:
 14 * ewk/ewk_frame.cpp:
 15 * ewk/ewk_js.cpp:
 16 * ewk/ewk_memory_allocation.h: Added.
 17 * ewk/ewk_tiled_backing_store.cpp:
 18 * ewk/ewk_tiled_model.cpp:
 19 * ewk/ewk_view.cpp:
 20 * ewk/ewk_window_features.cpp:
 21
1222011-10-25 KwangHyuk Kim <hyuki.kim@samsung.com>
223
324 Fix occurrence of unpainted tiles while scrolling and zooming.

Source/WebKit/efl/ewk/ewk_auth_soup.cpp

2424#include "EWebKit.h"
2525#include "ewk_auth.h"
2626#include "ewk_logging.h"
 27#include "ewk_memory_allocation.h"
2728#include <glib-object.h>
2829#include <glib.h>
2930#include <libsoup/soup.h>

@@static void session_authenticate(SoupSession* session, SoupMessage* message, Sou
9495 if (!ewk_auth_show_dialog_callback)
9596 return;
9697
97  authenticationData = static_cast<Ewk_Auth_Data*>(calloc(1, sizeof(Ewk_Auth_Data)));
 98 authenticationData = eCalloc<Ewk_Auth_Data>(1);
9899
99100 if (!authenticationData) {
100101 CRITICAL("could not allocate Ewk_Auth_Data");

Source/WebKit/efl/ewk/ewk_contextmenu.cpp

2525#include "ContextMenuController.h"
2626#include "ContextMenuItem.h"
2727#include "EWebKit.h"
 28#include "ewk_memory_allocation.h"
2829#include "ewk_private.h"
2930
3031#include <Eina.h>

@@Ewk_Context_Menu_Item* ewk_context_menu_item_new(Ewk_Context_Menu_Item_Type type
103104 Ewk_Context_Menu_Action action, Ewk_Context_Menu* submenu,
104105 const char* title, Eina_Bool checked, Eina_Bool enabled)
105106{
106  Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(malloc(sizeof(*item)));
 107 Ewk_Context_Menu_Item* item = eMalloc<Ewk_Context_Menu_Item>(1);
107108 if (!item)
108109 return 0;
109110

@@Ewk_Context_Menu* ewk_context_menu_new(Evas_Object* view, WebCore::ContextMenuCo
228229 EINA_SAFETY_ON_NULL_RETURN_VAL(view, 0);
229230 EINA_SAFETY_ON_NULL_RETURN_VAL(controller, 0);
230231
231  menu = static_cast<Ewk_Context_Menu*>(malloc(sizeof(*menu)));
 232 menu = eMalloc<Ewk_Context_Menu>;
232233 if (!menu) {
233234 CRITICAL("Could not allocate context menu memory.");
234235 return 0;

Source/WebKit/efl/ewk/ewk_frame.cpp

5050#include "SharedBuffer.h"
5151#include "SubstituteData.h"
5252#include "WindowsKeyboardCodes.h"
 53#include "ewk_memory_allocation.h"
5354#include "ewk_private.h"
5455
5556#include <Eina.h>

@@static void _ewk_frame_smart_add(Evas_Object* ewkFrame)
166167 EWK_FRAME_SD_GET(ewkFrame, smartData);
167168
168169 if (!smartData) {
169  smartData = static_cast<Ewk_Frame_Smart_Data*>(calloc(1, sizeof(Ewk_Frame_Smart_Data)));
 170 smartData = eCalloc<Ewk_Frame_Smart_Data>(1);
170171 if (!smartData) {
171172 CRITICAL("could not allocate Ewk_Frame_Smart_Data");
172173 return;

@@Evas_Object* ewk_frame_view_get(const Evas_Object* ewkFrame)
285286Eina_Iterator* ewk_frame_children_iterator_new(Evas_Object* ewkFrame)
286287{
287288 EWK_FRAME_SD_GET_OR_RETURN(ewkFrame, smartData, 0);
288  Eina_Iterator_Ewk_Frame* iterator = static_cast<Eina_Iterator_Ewk_Frame*>
289  (calloc(1, sizeof(Eina_Iterator_Ewk_Frame)));
 289 Eina_Iterator_Ewk_Frame* iterator = eCalloc<Eina_Iterator_Ewk_Frame>(1);
290290 if (!iterator)
291291 return 0;
292292

@@Ewk_Hit_Test* ewk_frame_hit_test_new(const Evas_Object* ewkFrame, int x, int y)
659659 if (!result.innerNode())
660660 return 0;
661661
662  Ewk_Hit_Test* hitTest = static_cast<Ewk_Hit_Test*>(calloc(1, sizeof(Ewk_Hit_Test)));
 662 Ewk_Hit_Test* hitTest = eCalloc<Ewk_Hit_Test>(1);
663663 if (!hitTest) {
664664 CRITICAL("Could not allocate memory for hit test.");
665665 return 0;

Source/WebKit/efl/ewk/ewk_js.cpp

@@static bool ewk_js_property_get(NPObject* npObject, NPIdentifier name, NPVariant
117117 return false;
118118 }
119119
120  value = static_cast<Ewk_JS_Variant*>(malloc(sizeof(Ewk_JS_Variant)));
 120 value = eMalloc<Ewk_JS_Variant>(1);
121121 if (!value) {
122122 ERR("Could not allocate memory for ewk_js_variant");
123123 return false;

@@static bool ewk_js_property_set(NPObject* npObject, NPIdentifier name, const NPV
160160 return fail;
161161 }
162162
163  value = static_cast<Ewk_JS_Variant*>(malloc(sizeof(Ewk_JS_Variant)));
 163 value = eMalloc<Ewk_JS_Variant>(1);
164164 if (!value) {
165165 ERR("Could not allocate memory for ewk_js_variant");
166166 return false;

@@static bool ewk_js_properties_enumerate(NPObject* npObject, NPIdentifier** value
221221 EINA_MAGIC_CHECK_OR_RETURN(object, false);
222222
223223 *count = eina_hash_population(object->properties);
224  *value = static_cast<NPIdentifier*>(malloc(sizeof(NPIdentifier) * *count));
 224 *value = eMalloc<NPIdentifier>(1);
225225 if (!*value) {
226226 ERR("Could not allocate memory for NPIdentifier");
227227 return false;

@@static bool ewk_js_method_invoke(NPObject* npObject, NPIdentifier name, const NP
268268 if (!method)
269269 return false;
270270
271  args = static_cast<Ewk_JS_Variant*>(malloc(sizeof(Ewk_JS_Variant) *npArgCount));
 271 args = eMalloc<Ewk_JS_Variant>(npArgCount);
272272 if (!args) {
273273 ERR("Could not allocate memory for ewk_js_variant");
274274 return false;

@@Ewk_JS_Class* ewk_js_class_new(const Ewk_JS_Class_Meta* jsMetaClass)
333333
334334 EINA_SAFETY_ON_NULL_RETURN_VAL(jsMetaClass, 0);
335335
336  cls = static_cast<Ewk_JS_Class*>(malloc(sizeof(Ewk_JS_Class)));
 336 cls = eMalloc<Ewk_JS_Class>(1);
337337 if (!cls) {
338338 ERR("Could not allocate memory for ewk_js_class");
339339 return 0;

@@static Ewk_JS_Object* ewk_js_npobject_to_object(NPObject* npObject)
404404 if (!_NPN_Enumerate(0, npObject, &values, &np_props_count))
405405 return 0;
406406
407  cls = static_cast<Ewk_JS_Class*>(malloc(sizeof(Ewk_JS_Class)));
 407 cls = eMalloc<Ewk_JS_Class>(1);
408408 if (!cls) {
409409 ERR("Could not allocate memory for ewk_js_class");
410410 return 0;

@@static Ewk_JS_Object* ewk_js_npobject_to_object(NPObject* npObject)
422422 for (uint32_t i = 0; i < np_props_count; i++) {
423423 if (_NPN_HasProperty(0, npObject, values[i])) {
424424 NPVariant var;
425  Ewk_JS_Property* prop = static_cast<Ewk_JS_Property*>(calloc(sizeof(Ewk_JS_Property), 1));
 425 Ewk_JS_Property* prop = eCalloc<Ewk_JS_Property>(1);
426426 if (!prop) {
427427 ERR("Could not allocate memory for ewk_js_property");
428428 goto error;

@@static Ewk_JS_Object* ewk_js_npobject_to_object(NPObject* npObject)
436436 }
437437
438438 // Can't use ewk_js_object_new(cls) because it expects cls->meta to exist.
439  object = static_cast<Ewk_JS_Object*>(malloc(sizeof(Ewk_JS_Object)));
 439 object = eMalloc<Ewk_JS_Object>(1);
440440 if (!object) {
441441 ERR("Could not allocate memory for ewk_js_object");
442442 goto error;

@@static Eina_Bool ewk_js_npvariant_to_variant(Ewk_JS_Variant* data, const NPVaria
503503 break;
504504 case NPVariantType_String:
505505 sz = NPVARIANT_TO_STRING(*result).UTF8Length;
506  data->value.s = static_cast<char*>(malloc(sizeof(char) * (sz + 1)));
 506 data->value.s = eMalloc<char>(sz + 1);
507507 if (!data->value.s)
508508 return EINA_FALSE;
509509 memcpy(data->value.s, NPVARIANT_TO_STRING(*result).UTF8Characters, sz);

@@Ewk_JS_Object* ewk_js_object_new(const Ewk_JS_Class_Meta* jsMetaClass)
531531
532532 EINA_SAFETY_ON_NULL_RETURN_VAL(jsMetaClass, 0);
533533
534  object = static_cast<Ewk_JS_Object*>(malloc(sizeof(Ewk_JS_Object)));
 534 object = eMalloc<Ewk_JS_Object>(1);
535535 if (!object) {
536536 ERR("Could not allocate memory for ewk_js_object");
537537 return 0;

@@Ewk_JS_Object* ewk_js_object_new(const Ewk_JS_Class_Meta* jsMetaClass)
551551 for (int i = 0; object->cls->meta->properties && object->cls->meta->properties[i].name; i++) {
552552 Ewk_JS_Property prop = object->cls->meta->properties[i];
553553 const char* key = object->cls->meta->properties[i].name;
554  Ewk_JS_Variant* value = static_cast<Ewk_JS_Variant*>(malloc(sizeof(Ewk_JS_Variant)));
 554 Ewk_JS_Variant* value = eMalloc<Ewk_JS_Variant>(1);
555555 if (!value) {
556556 ERR("Could not allocate memory for ewk_js_variant");
557557 goto error;

@@Eina_Bool ewk_js_object_invoke(Ewk_JS_Object* jsObject, Ewk_JS_Variant* args, in
637637 if (argCount)
638638 EINA_SAFETY_ON_NULL_RETURN_VAL(args, EINA_FALSE);
639639
640  np_args = static_cast<NPVariant*>(malloc(sizeof(NPVariant) *argCount));
 640 np_args = eMalloc<NPVariant>(argCount);
641641 if (!np_args) {
642642 ERR("Could not allocate memory to method arguments");
643643 return EINA_FALSE;

Source/WebKit/efl/ewk/ewk_main.cpp

@@static int _ewkInitCount = 0;
6363 * \var _ewk_log_dom
6464 * @brief the log domain identifier that is used with EINA's macros
6565 */
66 int _ewk_log_dom = -1;
 66int _ewk_log_dom = 1;
6767
6868static Eina_Bool _ewk_init_body(void);
6969

@@int ewk_init(void)
7676 goto error_eina;
7777
7878 _ewk_log_dom = eina_log_domain_register("ewebkit", EINA_COLOR_ORANGE);
 79 printf("<< _ewk_log_dom : %d \n", _ewk_log_dom);
7980 if (_ewk_log_dom < 0) {
8081 EINA_LOG_CRIT("could not register log domain 'ewebkit'");
8182 goto error_log_domain;

Source/WebKit/efl/ewk/ewk_memory_allocation.h

 1/*
 2 Copyright (C) 2011 Samsung Electronics.
 3
 4 This library is free software; you can redistribute it and/or
 5 modify it under the terms of the GNU Library General Public
 6 License as published by the Free Software Foundation; either
 7 version 2 of the License, or (at your option) any later version.
 8
 9 This library is distributed in the hope that it will be useful,
 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 Library General Public License for more details.
 13
 14 You should have received a copy of the GNU Library General Public License
 15 along with this library; see the file COPYING.LIB. If not, write to
 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 Boston, MA 02110-1301, USA.
 18*/
 19
 20/**
 21 * @file ewk_memory_allocation.h
 22 * @brief Template for memory allocation of WebKit-EFL.
 23 */
 24
 25#ifndef ewk_memory_allocation_h
 26#define ewk_memory_allocation_h
 27
 28template <typename struct_type> struct_type* eMalloc(size_t amount = 1)
 29{
 30 return static_cast<struct_type*>(malloc(amount * sizeof(struct_type)));
 31}
 32
 33template <typename struct_type> struct_type* eCalloc(size_t amount = 1)
 34{
 35 return static_cast<struct_type*>(calloc(amount, sizeof(struct_type)));
 36}
 37
 38template <typename struct_type> struct_type* eRealloc(void* T, size_t amount = 1)
 39{
 40 return static_cast<struct_type*>(realloc(T, amount * sizeof(struct_type)));
 41}
 42
 43#endif // ewk_memory_allocation_h

Source/WebKit/efl/ewk/ewk_tiled_backing_store.cpp

2121#include "config.h"
2222#include "ewk_tiled_backing_store.h"
2323
 24#include "ewk_memory_allocation.h"
2425#include "ewk_tiled_matrix.h"
2526#include "ewk_tiled_private.h"
2627#include <Ecore.h>

@@static inline Eina_Bool _ewk_tiled_backing_store_pre_render_request_add(Ewk_Tile
252253{
253254 Ewk_Tiled_Backing_Store_Pre_Render_Request* request;
254255
255  request = static_cast<Ewk_Tiled_Backing_Store_Pre_Render_Request*>(malloc(sizeof(*request)));
 256 request = eMalloc<Ewk_Tiled_Backing_Store_Pre_Render_Request>(1);
256257 if (!request)
257258 return EINA_FALSE;
258259

@@static Ewk_Tiled_Backing_Store_Item* _ewk_tiled_backing_store_item_add(Ewk_Tiled
478479
479480 DBG("ewkTile%p", priv->self);
480481
481  item = static_cast<Ewk_Tiled_Backing_Store_Item*>(malloc(sizeof(*item)));
 482 item = eMalloc<Ewk_Tiled_Backing_Store_Item>(1);
482483 if (!item)
483484 return 0;
484485

@@static void _ewk_tiled_backing_store_smart_add(Evas_Object* ewkTile)
693694
694695 DBG("ewkTile=%p", ewkTile);
695696
696  priv = static_cast<Ewk_Tiled_Backing_Store_Data*>(calloc(1, sizeof(*priv)));
 697 priv = eCalloc<Ewk_Tiled_Backing_Store_Data>(1);
697698 if (!priv)
698699 return;
699700

@@static void _ewk_tiled_backing_store_recalc_renderers(Ewk_Tiled_Backing_Store_Da
831832 _ewk_tiled_backing_store_view_rows_range_del(priv, start, end);
832833 }
833834
834  void* newItems = realloc(priv->view.items, sizeof(Eina_Inlist*) * rows);
 835 void* newItems = eRealloc<Eina_Inlist>(priv->view.items, rows);
835836 if (!newItems)
836837 return;
837838

Source/WebKit/efl/ewk/ewk_tiled_model.cpp

2121#include "config.h"
2222#include "ewk_tiled_model.h"
2323
 24#include "ewk_memory_allocation.h"
2425#include "ewk_tiled_backing_store.h"
2526#include "ewk_tiled_private.h"
2627#include <Ecore_Evas.h>

@@Ewk_Tile* ewk_tile_new(Evas* evas, Evas_Coord width, Evas_Coord height, float zo
261262
262263 DBG("size: %dx%d (%d), zoom: %f, cspace=%d", width, height, area, (double)zoom, colorSpace);
263264
264  tile = static_cast<Ewk_Tile*>(malloc(sizeof(Ewk_Tile)));
 265 tile = eMalloc<Ewk_Tile>(1);
265266 if (!tile)
266267 return 0;
267268

@@Ewk_Tile_Unused_Cache* ewk_tile_unused_cache_new(size_t max)
523524{
524525 Ewk_Tile_Unused_Cache* tileUnusedCache;
525526
526  tileUnusedCache = static_cast<Ewk_Tile_Unused_Cache*>(calloc(1, sizeof(Ewk_Tile_Unused_Cache)));
 527 tileUnusedCache = eCalloc<Ewk_Tile_Unused_Cache>(1);
527528 if (!tileUnusedCache)
528529 return 0;
529530

@@Eina_Bool ewk_tile_unused_cache_tile_put(Ewk_Tile_Unused_Cache* tileUnusedCache,
804805 return EINA_FALSE;
805806 }
806807
807  unusedCacheEntry = static_cast<Ewk_Tile_Unused_Cache_Entry*>(malloc(sizeof(Ewk_Tile_Unused_Cache_Entry)));
 808 unusedCacheEntry = eMalloc<Ewk_Tile_Unused_Cache_Entry>(1);
808809 if (!unusedCacheEntry)
809810 return EINA_FALSE;
810811

Source/WebKit/efl/ewk/ewk_view.cpp

5050#include "ProgressTracker.h"
5151#include "RenderTheme.h"
5252#include "c_instance.h"
 53#include "ewk_memory_allocation.h"
5354#include "ewk_private.h"
5455#include "ewk_protocol_handler.h"
5556

@@static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
277278
278279static Eina_Bool _ewk_view_repaints_resize(Ewk_View_Private_Data* priv, size_t size)
279280{
280  void* tmp = realloc(priv->repaints.array, size * sizeof(Eina_Rectangle));
 281 void* tmp = eRealloc<Eina_Rectangle>(priv->repaints.array, size);
281282 if (!tmp) {
282283 CRITICAL("could not realloc repaints array to %zu elements.", size);
283284 return EINA_FALSE;

@@static void _ewk_view_repaints_flush(Ewk_View_Private_Data* priv)
323324
324325static Eina_Bool _ewk_view_scrolls_resize(Ewk_View_Private_Data* priv, size_t size)
325326{
326  void* tmp = realloc(priv->scrolls.array, size * sizeof(Ewk_Scroll_Request));
 327 void* tmp = eRealloc<Ewk_Scroll_Request>(priv->scrolls.array, size);
327328 if (!tmp) {
328329 CRITICAL("could not realloc scrolls array to %zu elements.", size);
329330 return EINA_FALSE;

@@static Evas_Smart_Class _parent_sc = EVAS_SMART_CLASS_INIT_NULL;
592593
593594static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
594595{
595  Ewk_View_Private_Data* priv =
596  static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data)));
 596 Ewk_View_Private_Data* priv = eCalloc<Ewk_View_Private_Data>(1);
597597 AtomicString string;
598598 WebCore::KURL url;
599599

@@static void _ewk_view_smart_add(Evas_Object* ewkView)
768768 EWK_VIEW_SD_GET(ewkView, smartData);
769769
770770 if (!smartData) {
771  smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
 771 smartData = eCalloc<Ewk_View_Smart_Data>(1);
772772 if (!smartData) {
773773 CRITICAL("could not allocate Ewk_View_Smart_Data");
774774 return;

@@Ewk_View_Paint_Context* ewk_view_paint_context_new(Ewk_View_Private_Data* priv,
25612561 EINA_SAFETY_ON_NULL_RETURN_VAL(priv->mainFrame, 0);
25622562 WebCore::FrameView* view = priv->mainFrame->view();
25632563 EINA_SAFETY_ON_NULL_RETURN_VAL(view, 0);
2564  Ewk_View_Paint_Context* context = static_cast<Ewk_View_Paint_Context*>(malloc(sizeof(*context)));
 2564 Ewk_View_Paint_Context* context = eMalloc<Ewk_View_Paint_Context>(1);
25652565 EINA_SAFETY_ON_NULL_RETURN_VAL(context, 0);
25662566
25672567 context->graphicContext = new WebCore::GraphicsContext(cr);

@@void ewk_view_popup_new(Evas_Object* ewkView, WebCore::PopupMenuClient* client,
34383438 // populate items
34393439 const int size = client->listSize();
34403440 for (int i = 0; i < size; ++i) {
3441  Ewk_Menu_Item* item = static_cast<Ewk_Menu_Item*>(malloc(sizeof(*item)));
 3441 Ewk_Menu_Item* item = eMalloc<Ewk_Menu_Item>(1);
34423442 if (client->itemIsSeparator(i))
34433443 item->type = EWK_MENU_SEPARATOR;
34443444 else if (client->itemIsLabel(i))

Source/WebKit/efl/ewk/ewk_window_features.cpp

2222#include "ewk_window_features.h"
2323
2424#include "WindowFeatures.h"
 25#include "ewk_memory_allocation.h"
2526#include "ewk_private.h"
2627
2728#include <Eina.h>

@@void ewk_window_features_int_property_get(const Ewk_Window_Features* windowFeatu
109110 */
110111Ewk_Window_Features* ewk_window_features_new_from_core(const WebCore::WindowFeatures* core)
111112{
112  Ewk_Window_Features* window_features = static_cast<Ewk_Window_Features*>(malloc(sizeof(*window_features)));
 113 Ewk_Window_Features* window_features = eMalloc<Ewk_Window_Features>(1);
113114 if (!window_features) {
114115 CRITICAL("Could not allocate Ewk_Window_Features.");
115116 return 0;