[EFL][WK2] defaultTextEncodingName should be stored as a member variable of EwkSettings

https://bugs.webkit.org/show_bug.cgi?id=127420

Reviewed by Gyuyoung Kim.

As the defaultTextEncodingName is returned as a local WKEinaSharedString variable,
the stringshared data is de-refed by eina_stringshare_del().
To maintain the reference counter, the defaultTextEncodingName should be stored
as a member variable of EwkSettings class.

* UIProcess/API/efl/ewk_settings.cpp:
(ewk_settings_encoding_detector_enabled_get): Reordering.
(ewk_settings_default_text_encoding_name_set):
(ewk_settings_default_text_encoding_name_get):
(EwkSettings::setDefaultTextEncodingName):
(EwkSettings::defaultTextEncodingName):
* UIProcess/API/efl/ewk_settings_private.h:
(EwkSettings::EwkSettings): Add m_defaultTextEncodingName and setter/getter methods.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 043ef674
2014-01-22 Jinwoo Song <jinwoo7.song@samsung.com>
[EFL][WK2] defaultTextEncodingName should be stored as a member variable of EwkSettings
https://bugs.webkit.org/show_bug.cgi?id=127420
Reviewed by Gyuyoung Kim.
As the defaultTextEncodingName is returned as a local WKEinaSharedString variable,
the stringshared data is de-refed by eina_stringshare_del().
To maintain the reference counter, the defaultTextEncodingName should be stored
as a member variable of EwkSettings class.
* UIProcess/API/efl/ewk_settings.cpp:
(ewk_settings_encoding_detector_enabled_get): Reordering.
(ewk_settings_default_text_encoding_name_set):
(ewk_settings_default_text_encoding_name_get):
(EwkSettings::setDefaultTextEncodingName):
(EwkSettings::defaultTextEncodingName):
* UIProcess/API/efl/ewk_settings_private.h:
(EwkSettings::EwkSettings): Add m_defaultTextEncodingName and setter/getter methods.
2014-01-22 Enrica Casucci <enrica@apple.com>
Support WebSelections in WK2 on iOS.
......
......@@ -174,29 +174,27 @@ Eina_Bool ewk_settings_encoding_detector_enabled_set(Ewk_Settings* settings, Ein
return true;
}
const char* ewk_settings_default_text_encoding_name_get(const Ewk_Settings* settings)
Eina_Bool ewk_settings_encoding_detector_enabled_get(const Ewk_Settings* settings)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, nullptr);
WKEinaSharedString name = settings->preferences()->defaultTextEncodingName().utf8().data();
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
return name;
return settings->preferences()->usesEncodingDetector();
}
Eina_Bool ewk_settings_default_text_encoding_name_set(Ewk_Settings* settings, const char* encoding)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
settings->preferences()->setDefaultTextEncodingName(String::fromUTF8(encoding));
settings->setDefaultTextEncodingName(encoding);
return true;
}
Eina_Bool ewk_settings_encoding_detector_enabled_get(const Ewk_Settings* settings)
const char* ewk_settings_default_text_encoding_name_get(const Ewk_Settings* settings)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, nullptr);
return settings->preferences()->usesEncodingDetector();
return settings->defaultTextEncodingName();
}
Eina_Bool ewk_settings_preferred_minimum_contents_width_set(Ewk_Settings *settings, unsigned width)
......@@ -351,3 +349,17 @@ Eina_Bool ewk_settings_spatial_navigation_enabled_get(const Ewk_Settings* settin
return settings->preferences()->spatialNavigationEnabled();
}
void EwkSettings::setDefaultTextEncodingName(const char* name)
{
if (m_defaultTextEncodingName == name)
return;
preferences()->setDefaultTextEncodingName(String::fromUTF8(name));
m_defaultTextEncodingName = name;
}
const char* EwkSettings::defaultTextEncodingName() const
{
return m_defaultTextEncodingName;
}
......@@ -41,13 +41,18 @@ public:
: m_view(viewImpl)
{
ASSERT(m_view);
m_defaultTextEncodingName = preferences()->defaultTextEncodingName().utf8().data();
}
const WebKit::WebPreferences* preferences() const;
WebKit::WebPreferences* preferences();
const char* defaultTextEncodingName() const;
void setDefaultTextEncodingName(const char*);
private:
EwkView* m_view;
WKEinaSharedString m_defaultTextEncodingName;
};
#endif // ewk_settings_private_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment