Changeset 128311 in webkit
- Timestamp:
- Sep 12, 2012 8:08:07 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128309 r128311 1 2012-09-12 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 3 [EFL] Avoid manual memory management in RenderThemeEfl 4 https://bugs.webkit.org/show_bug.cgi?id=96501 5 6 Reviewed by Simon Hausmann. 7 8 Use OwnPtr as it works for Evas_Object and Evas_Ecore objects. 9 10 * platform/efl/RenderThemeEfl.cpp: 11 (WebCore::RenderThemeEfl::ThemePartCacheEntry::ThemePartCacheEntry): 12 (WebCore::RenderThemeEfl::ThemePartCacheEntry::~ThemePartCacheEntry): 13 (WebCore::RenderThemeEfl::ThemePartCacheEntry::create): 14 (WebCore::RenderThemeEfl::ThemePartCacheEntry::reuse): 15 (WebCore::RenderThemeEfl::paintThemePart): 16 (WebCore::RenderThemeEfl::setColorFromThemeClass): 17 (WebCore::RenderThemeEfl::themePath): 18 (WebCore::RenderThemeEfl::loadTheme): 19 (WebCore::RenderThemeEfl::applyPartDescriptionsFrom): 20 (WebCore::RenderThemeEfl::RenderThemeEfl): 21 (WebCore::RenderThemeEfl::~RenderThemeEfl): 22 (WebCore::RenderThemeEfl::emitMediaButtonSignal): 23 * platform/efl/RenderThemeEfl.h: 24 (WebCore::RenderThemeEfl::canvas): 25 (WebCore::RenderThemeEfl::edje): 26 (RenderThemeEfl): 27 (WebCore::RenderThemeEfl::ThemePartCacheEntry::canvas): 28 (WebCore::RenderThemeEfl::ThemePartCacheEntry::edje): 29 (ThemePartCacheEntry): 30 1 31 2012-09-12 Florin Malita <fmalita@chromium.org> 2 32 -
trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp
r128275 r128311 164 164 165 165 RenderThemeEfl::ThemePartCacheEntry::ThemePartCacheEntry() 166 : ee(0), o(0),surface(0)166 : surface(0) 167 167 { 168 168 } … … 172 172 if (surface) 173 173 cairo_surface_destroy(surface); 174 if (o)175 evas_object_del(o);176 if (ee)177 ecore_evas_free(ee);178 174 } 179 175 … … 220 216 OwnPtr<ThemePartCacheEntry*> entry = adoptPtr(new ThemePartCacheEntry); 221 217 222 entry-> ee = ecore_evas_buffer_new(size.width(), size.height());223 if (!entry-> ee) {218 entry->m_canvas = adoptPtr(ecore_evas_buffer_new(size.width(), size.height())); 219 if (!entry->canvas()) { 224 220 EINA_LOG_ERR("ecore_evas_buffer_new(%d, %d) failed.", size.width(), size.height()); 225 221 return 0; … … 227 223 228 224 // By default EFL creates buffers without alpha. 229 ecore_evas_alpha_set(entry-> ee, EINA_TRUE);230 231 entry-> o = edje_object_add(ecore_evas_get(entry->ee));232 ASSERT(entry-> o);233 234 if (!setSourceGroupForEdjeObject(entry-> o, themePath, toEdjeGroup(type)))225 ecore_evas_alpha_set(entry->canvas(), EINA_TRUE); 226 227 entry->m_edje = adoptPtr(edje_object_add(ecore_evas_get(entry->canvas()))); 228 ASSERT(entry->edje()); 229 230 if (!setSourceGroupForEdjeObject(entry->edje(), themePath, toEdjeGroup(type))) 235 231 return 0; 236 232 237 entry->surface = createCairoSurfaceFor(entry-> ee);233 entry->surface = createCairoSurfaceFor(entry->canvas()); 238 234 if (!entry->surface) 239 235 return 0; 240 236 241 evas_object_resize(entry-> o, size.width(), size.height());242 evas_object_show(entry-> o);237 evas_object_resize(entry->edje(), size.width(), size.height()); 238 evas_object_show(entry->edje()); 243 239 244 240 entry->type = type; … … 256 252 257 253 size = newSize; 258 ecore_evas_resize( ee, newSize.width(), newSize.height());259 evas_object_resize( o, newSize.width(), newSize.height());260 261 surface = createCairoSurfaceFor( ee);254 ecore_evas_resize(canvas(), newSize.width(), newSize.height()); 255 evas_object_resize(edje(), newSize.width(), newSize.height()); 256 257 surface = createCairoSurfaceFor(canvas()); 262 258 if (!surface) { 263 259 type = FormTypeLast; // Invalidate; … … 266 262 } 267 263 268 if (!setSourceGroupForEdjeObject( o, themePath, toEdjeGroup(newType))) {264 if (!setSourceGroupForEdjeObject(edje(), themePath, toEdjeGroup(newType))) { 269 265 type = FormTypeLast; // Invalidate. 270 266 return; … … 352 348 { 353 349 loadThemeIfNeeded(); 354 _ASSERT_ON_RELEASE_RETURN_VAL( m_edje, false, "Could not paint native HTML part due to missing theme.");350 _ASSERT_ON_RELEASE_RETURN_VAL(edje(), false, "Could not paint native HTML part due to missing theme."); 355 351 356 352 ThemePartCacheEntry* entry; … … 362 358 return false; 363 359 364 applyEdjeStateFromForm(entry-> o, controlStatesForRenderer(object));360 applyEdjeStateFromForm(entry->edje(), controlStatesForRenderer(object)); 365 361 366 362 cairo = info.context->platformContext()->cr(); … … 391 387 392 388 msg->val[1] = (input->valueAsNumber() - input->minimum()) / valueRange; 393 edje_object_message_send(entry-> o, EDJE_MESSAGE_FLOAT_SET, 0, msg);389 edje_object_message_send(entry->edje(), EDJE_MESSAGE_FLOAT_SET, 0, msg); 394 390 #if ENABLE(PROGRESS_ELEMENT) 395 391 } else if (type == ProgressBar) { … … 408 404 msg->val[0] = 0; 409 405 msg->val[1] = value; 410 edje_object_message_send(entry-> o, EDJE_MESSAGE_FLOAT_SET, 0, msg);411 #endif 412 } 413 414 edje_object_calc_force(entry-> o);415 edje_object_message_signal_process(entry-> o);416 updates = evas_render_updates(ecore_evas_get(entry-> ee));406 edje_object_message_send(entry->edje(), EDJE_MESSAGE_FLOAT_SET, 0, msg); 407 #endif 408 } 409 410 edje_object_calc_force(entry->edje()); 411 edje_object_message_signal_process(entry->edje()); 412 updates = evas_render_updates(ecore_evas_get(entry->canvas())); 417 413 evas_render_updates_free(updates); 418 414 … … 465 461 void RenderThemeEfl::setColorFromThemeClass(const char* colorClass) 466 462 { 467 ASSERT( m_edje);463 ASSERT(edje()); 468 464 469 465 if (!strcmp("webkit/selection/active", colorClass)) 470 fillColorsFromEdjeClass( m_edje, colorClass, &m_activeSelectionForegroundColor, &m_activeSelectionBackgroundColor);466 fillColorsFromEdjeClass(edje(), colorClass, &m_activeSelectionForegroundColor, &m_activeSelectionBackgroundColor); 471 467 else if (!strcmp("webkit/selection/inactive", colorClass)) 472 fillColorsFromEdjeClass( m_edje, colorClass, &m_inactiveSelectionForegroundColor, &m_inactiveSelectionBackgroundColor);468 fillColorsFromEdjeClass(edje(), colorClass, &m_inactiveSelectionForegroundColor, &m_inactiveSelectionBackgroundColor); 473 469 else if (!strcmp("webkit/focus_ring", colorClass)) { 474 fillColorsFromEdjeClass( m_edje, colorClass, &m_focusRingColor);470 fillColorsFromEdjeClass(edje(), colorClass, &m_focusRingColor); 475 471 // platformFocusRingColor() is only used for the default theme (without page) 476 472 // The following is ugly, but no other way to do it unless we change it to use page themes as much as possible. … … 497 493 { 498 494 #ifndef NDEBUG 499 if ( m_edje) {495 if (edje()) { 500 496 const char* path; 501 edje_object_file_get( m_edje, &path, 0);497 edje_object_file_get(edje(), &path, 0); 502 498 ASSERT(m_themePath == path); 503 499 } … … 510 506 ASSERT(!m_themePath.isEmpty()); 511 507 512 if (! m_canvas) {513 m_canvas = ecore_evas_buffer_new(1, 1);514 _ASSERT_ON_RELEASE_RETURN_VAL( m_canvas, false,508 if (!canvas()) { 509 m_canvas = adoptPtr(ecore_evas_buffer_new(1, 1)); 510 _ASSERT_ON_RELEASE_RETURN_VAL(canvas(), false, 515 511 "Could not create canvas required by theme, things will not work properly."); 516 512 } 517 513 518 Evas_Object* o = edje_object_add(ecore_evas_get(m_canvas));514 OwnPtr<Evas_Object> o = adoptPtr(edje_object_add(ecore_evas_get(canvas()))); 519 515 _ASSERT_ON_RELEASE_RETURN_VAL(o, false, "Could not create new base Edje object."); 520 516 521 if (!setSourceGroupForEdjeObject(o, m_themePath, "webkit/base")) { 522 evas_object_del(o); 517 if (!setSourceGroupForEdjeObject(o.get(), m_themePath, "webkit/base")) 523 518 return false; // Keep current theme. 524 }525 519 526 520 // Get rid of existing theme. 527 if ( m_edje) {521 if (edje()) 528 522 flushThemePartCache(); 529 evas_object_del(m_edje);530 }531 523 532 524 // Set new loaded theme, and apply it. 533 m_edje = o;534 535 edje_object_signal_callback_add( m_edje, "color_class,set", "webkit/selection/active", applyColorCallback, this);536 edje_object_signal_callback_add( m_edje, "color_class,set", "webkit/selection/inactive", applyColorCallback, this);537 edje_object_signal_callback_add( m_edje, "color_class,set", "webkit/focus_ring", applyColorCallback, this);525 m_edje.swap(o); 526 527 edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/active", applyColorCallback, this); 528 edje_object_signal_callback_add(edje(), "color_class,set", "webkit/selection/inactive", applyColorCallback, this); 529 edje_object_signal_callback_add(edje(), "color_class,set", "webkit/focus_ring", applyColorCallback, this); 538 530 539 531 applyPartDescriptionsFrom(m_themePath); … … 612 604 void RenderThemeEfl::applyPartDescriptionsFrom(const String& themePath) 613 605 { 614 Evas_Object* temp = edje_object_add(ecore_evas_get(m_canvas));606 OwnPtr<Evas_Object> temp = adoptPtr(edje_object_add(ecore_evas_get(canvas()))); 615 607 _ASSERT_ON_RELEASE_RETURN(temp, "Could not create Edje object."); 616 608 … … 618 610 FormType type = static_cast<FormType>(i); 619 611 m_partDescs[i].type = type; 620 if (!setSourceGroupForEdjeObject(temp , themePath, toEdjeGroup(type)))612 if (!setSourceGroupForEdjeObject(temp.get(), themePath, toEdjeGroup(type))) 621 613 applyPartDescriptionFallback(m_partDescs + i); 622 614 else 623 applyPartDescription(temp, m_partDescs + i); 624 } 625 626 evas_object_del(temp); 615 applyPartDescription(temp.get(), m_partDescs + i); 616 } 627 617 } 628 618 … … 640 630 , m_mediaSliderColor(Color::white) 641 631 #endif 642 , m_canvas(0)643 , m_edje(0)644 632 { 645 633 } … … 648 636 { 649 637 flushThemePartCache(); 650 651 if (m_canvas) {652 if (m_edje)653 evas_object_del(m_edje);654 ecore_evas_free(m_canvas);655 }656 638 } 657 639 … … 1068 1050 { 1069 1051 loadThemeIfNeeded(); 1070 _ASSERT_ON_RELEASE_RETURN_VAL( m_edje, false, "Could not paint native HTML part due to missing theme.");1052 _ASSERT_ON_RELEASE_RETURN_VAL(edje(), false, "Could not paint native HTML part due to missing theme."); 1071 1053 1072 1054 ThemePartCacheEntry* entry = getThemePartFromCache(formType, rect.size()); … … 1074 1056 1075 1057 if (mediaElementType == MediaPlayButton) 1076 edje_object_signal_emit(entry-> o, "play", "");1058 edje_object_signal_emit(entry->edje(), "play", ""); 1077 1059 else if (mediaElementType == MediaPauseButton) 1078 edje_object_signal_emit(entry-> o, "pause", "");1060 edje_object_signal_emit(entry->edje(), "pause", ""); 1079 1061 else if (mediaElementType == MediaMuteButton) 1080 edje_object_signal_emit(entry-> o, "mute", "");1062 edje_object_signal_emit(entry->edje(), "mute", ""); 1081 1063 else if (mediaElementType == MediaUnMuteButton) 1082 edje_object_signal_emit(entry-> o, "sound", "");1064 edje_object_signal_emit(entry->edje(), "sound", ""); 1083 1065 else if (mediaElementType == MediaSeekForwardButton) 1084 edje_object_signal_emit(entry-> o, "seekforward", "");1066 edje_object_signal_emit(entry->edje(), "seekforward", ""); 1085 1067 else if (mediaElementType == MediaSeekBackButton) 1086 edje_object_signal_emit(entry-> o, "seekbackward", "");1068 edje_object_signal_emit(entry->edje(), "seekbackward", ""); 1087 1069 else if (mediaElementType == MediaEnterFullscreenButton) 1088 edje_object_signal_emit(entry-> o, "fullscreen", "");1070 edje_object_signal_emit(entry->edje(), "fullscreen", ""); 1089 1071 #if ENABLE(VIDEO_TRACK) 1090 1072 else if (mediaElementType == MediaShowClosedCaptionsButton) 1091 edje_object_signal_emit(entry-> o, "show_captions", "");1073 edje_object_signal_emit(entry->edje(), "show_captions", ""); 1092 1074 else if (mediaElementType == MediaHideClosedCaptionsButton) 1093 edje_object_signal_emit(entry-> o, "hide_captions", "");1075 edje_object_signal_emit(entry->edje(), "hide_captions", ""); 1094 1076 #endif 1095 1077 else -
trunk/Source/WebCore/platform/efl/RenderThemeEfl.h
r128274 r128311 223 223 } 224 224 225 ALWAYS_INLINE Ecore_Evas* canvas() { return m_canvas.get(); } 226 ALWAYS_INLINE Evas_Object* edje() { return m_edje.get(); } 227 225 228 void applyPartDescriptionsFrom(const String& themePath); 226 229 … … 246 249 247 250 String m_themePath; 248 Ecore_Evas* m_canvas; 249 Evas_Object* m_edje; 251 // Order so that the canvas gets destroyed at last. 252 OwnPtr<Ecore_Evas> m_canvas; 253 OwnPtr<Evas_Object> m_edje; 250 254 251 255 struct ThemePartDesc { … … 264 268 void reuse(const String& themePath, FormType, const IntSize& = IntSize()); 265 269 270 ALWAYS_INLINE Ecore_Evas* canvas() { return m_canvas.get(); } 271 ALWAYS_INLINE Evas_Object* edje() { return m_edje.get(); } 272 266 273 FormType type; 267 274 IntSize size; 268 Ecore_Evas* ee;269 Evas_Object* o;270 275 cairo_surface_t* surface; 276 277 private: 278 // Order so that the canvas gets destroyed at last. 279 OwnPtr<Ecore_Evas> m_canvas; 280 OwnPtr<Evas_Object> m_edje; 271 281 }; 272 282
Note: See TracChangeset
for help on using the changeset viewer.