Commit b05165b3 authored by kenneth@webkit.org's avatar kenneth@webkit.org

[EFL] Fuzzy load the Edje theme for HTML forms

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

Reviewed by Gyuyoung Kim.

Change the theme so that it is first loaded when actually used.
This also fixed the case that it was impossible to change theme
a second time.

Tested by current tests. API unit test coming in separate patch.

* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::themePartCacheEntryReset):
(WebCore::RenderThemeEfl::cacheThemePartNew):
(WebCore::RenderThemeEfl::paintThemePart):
(WebCore::RenderThemeEfl::setThemePath):
(WebCore::RenderThemeEfl::edje):
(WebCore::RenderThemeEfl::applyPartDescriptions):
* platform/efl/RenderThemeEfl.h:
(RenderThemeEfl):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127573 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 67491e63
2012-09-05 Kenneth Rohde Christiansen <kenneth@webkit.org>
[EFL] Fuzzy load the Edje theme for HTML forms
https://bugs.webkit.org/show_bug.cgi?id=95832
Reviewed by Gyuyoung Kim.
Change the theme so that it is first loaded when actually used.
This also fixed the case that it was impossible to change theme
a second time.
Tested by current tests. API unit test coming in separate patch.
* platform/efl/RenderThemeEfl.cpp:
(WebCore::RenderThemeEfl::themePartCacheEntryReset):
(WebCore::RenderThemeEfl::cacheThemePartNew):
(WebCore::RenderThemeEfl::paintThemePart):
(WebCore::RenderThemeEfl::setThemePath):
(WebCore::RenderThemeEfl::edje):
(WebCore::RenderThemeEfl::applyPartDescriptions):
* platform/efl/RenderThemeEfl.h:
(RenderThemeEfl):
2012-09-05 Chris Guan <chris.guan@torchmobile.com.cn>
[Blackberry] Add document url and securityOrigin to platform request.
......@@ -103,9 +103,6 @@ bool RenderThemeEfl::themePartCacheEntryReset(struct ThemePartCacheEntry* entry,
{
const char *file, *group;
ASSERT(entry);
ASSERT(m_edje);
edje_object_file_get(m_edje, &file, 0);
group = edjeGroupFromFormType(type);
ASSERT(file);
......@@ -159,7 +156,7 @@ bool RenderThemeEfl::isFormElementTooLargeToDisplay(const IntSize& elementSize)
struct RenderThemeEfl::ThemePartCacheEntry* RenderThemeEfl::cacheThemePartNew(FormType type, const IntSize& size)
{
if (isFormElementTooLargeToDisplay(size)) {
EINA_LOG_ERR("cannot render an element of size %dx%d", size.width(), size.height());
EINA_LOG_ERR("Cannot render an element of size %dx%d.", size.width(), size.height());
return 0;
}
......@@ -311,13 +308,15 @@ void RenderThemeEfl::applyEdjeStateFromForm(Evas_Object* object, ControlStates s
bool RenderThemeEfl::paintThemePart(RenderObject* object, FormType type, const PaintInfo& info, const IntRect& rect)
{
if (!edje()) {
EINA_LOG_ERR("Could not paint native HTML part due to missing theme.");
return false;
}
ThemePartCacheEntry* entry;
Eina_List* updates;
cairo_t* cairo;
ASSERT(m_canvas);
ASSERT(m_edje);
entry = cacheThemePartGet(type, rect.size());
if (!entry)
return false;
......@@ -438,44 +437,59 @@ void RenderThemeEfl::setThemePath(const String& path)
return;
m_themePath = path;
themeChanged();
}
void RenderThemeEfl::createCanvas()
{
ASSERT(!m_canvas);
m_canvas = ecore_evas_buffer_new(1, 1);
ASSERT(m_canvas);
if (m_themePath.isEmpty()) {
EINA_LOG_ERR("No theme defined, unable to set theme for HTML Forms.");
return;
}
if (!m_canvas) {
m_canvas = ecore_evas_buffer_new(1, 1);
if (!m_canvas)
EINA_LOG_ERR("Could not create canvas.");
}
if (m_edje) {
// Get rid of current theme.
cacheThemePartFlush();
evas_object_del(m_edje);
m_edje = 0;
}
}
void RenderThemeEfl::createEdje()
Evas_Object* RenderThemeEfl::edje()
{
ASSERT(!m_edje);
if (m_themePath.isEmpty())
EINA_LOG_ERR("No theme defined, unable to set RenderThemeEfl.");
else {
if (!m_edje) {
m_edje = edje_object_add(ecore_evas_get(m_canvas));
if (!m_edje)
EINA_LOG_ERR("Could not create base edje object.");
else if (!edje_object_file_set(m_edje, m_themePath.utf8().data(), "webkit/base")) {
if (!m_edje) {
EINA_LOG_CRIT("Could not create base Edje object.");
return 0;
}
if (!edje_object_file_set(m_edje, m_themePath.utf8().data(), "webkit/base")) {
Edje_Load_Error err = edje_object_load_error_get(m_edje);
const char* errmsg = edje_load_error_str(err);
EINA_LOG_ERR("Could not set file: %s", errmsg);
EINA_LOG_CRIT("Could not set file '%s': %s", m_themePath.utf8().data(), errmsg);
evas_object_del(m_edje);
m_edje = 0;
} else {
return 0;
}
#define CONNECT(cc, func) \
edje_object_signal_callback_add(m_edje, "color_class,set", \
"webkit/"cc, func, this)
CONNECT("selection/active",
renderThemeEflColorClassSelectionActive);
CONNECT("selection/inactive",
renderThemeEflColorClassSelectionInactive);
CONNECT("focus_ring", renderThemeEflColorClassFocusRing);
CONNECT("selection/active", renderThemeEflColorClassSelectionActive);
CONNECT("selection/inactive", renderThemeEflColorClassSelectionInactive);
CONNECT("focus_ring", renderThemeEflColorClassFocusRing);
#undef CONNECT
}
applyEdjeColors();
applyPartDescriptions();
}
return m_edje;
}
void RenderThemeEfl::applyEdjeColors()
......@@ -611,11 +625,14 @@ void RenderThemeEfl::applyPartDescriptions()
unsigned int i;
const char* file;
ASSERT(m_canvas);
ASSERT(m_edje);
edje_object_file_get(m_edje, &file, 0);
ASSERT(file);
if (!file) {
EINA_LOG_ERR("Could not retrieve Edje theme file.");
return;
}
object = edje_object_add(ecore_evas_get(m_canvas));
if (!object) {
......@@ -640,26 +657,6 @@ void RenderThemeEfl::applyPartDescriptions()
evas_object_del(object);
}
void RenderThemeEfl::themeChanged()
{
cacheThemePartFlush();
if (!m_canvas) {
createCanvas();
if (!m_canvas)
return;
}
if (!m_edje) {
createEdje();
if (!m_edje)
return;
}
applyEdjeColors();
applyPartDescriptions();
}
RenderThemeEfl::RenderThemeEfl(Page* page)
: RenderTheme()
, m_page(page)
......
......@@ -102,8 +102,6 @@ public:
virtual Color platformInactiveSelectionForegroundColor() const { return m_inactiveSelectionForegroundColor; }
virtual Color platformFocusRingColor() const { return m_focusRingColor; }
virtual void themeChanged();
// Set platform colors and notify they changed
void setActiveSelectionColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
void setInactiveSelectionColor(int foreR, int foreG, int foreB, int foreA, int backR, int backG, int backB, int backA);
......@@ -212,10 +210,11 @@ protected:
static float defaultFontSize;
private:
void createCanvas();
void createEdje();
Evas_Object* edje();
void applyEdjeColors();
void applyPartDescriptions();
const char* edjeGroupFromFormType(FormType) const;
void applyEdjeStateFromForm(Evas_Object*, ControlStates);
bool paintThemePart(RenderObject*, FormType, const PaintInfo&, const IntRect&);
......
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