Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 04e2ddb

Browse files
committed
[[ Bug 12225 ]] Transform coordinates when getting/setting browser rect
1 parent 540a130 commit 04e2ddb

File tree

2 files changed

+44
-6
lines changed

2 files changed

+44
-6
lines changed

revbrowser/src/cefbrowser_w32.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,19 @@ bool MCCefWin32AppendPath(const char *p_base, const char *p_path, char *&r_path)
114114
return MCCStringFormat(r_path, "%s\\%s", p_base, p_path);
115115
}
116116

117+
#ifdef _DEBUG
118+
#define CEF_PATH_PREFIX ""
119+
#else
120+
#define CEF_PATH_PREFIX "CEF\\"
121+
#endif
122+
117123
// IM-2014-03-25: [[ revBrowserCEF ]] locales located in CEF subfolder relative to revbrowser dll
118124
const char *MCCefPlatformGetLocalePath(void)
119125
{
120126
static char *s_locale_path = nil;
121127

122128
if (s_locale_path == nil)
123-
/* UNCHECKED */ MCCefWin32AppendPath(MCCefWin32GetExternalPath(), "CEF\\locales", s_locale_path);
129+
/* UNCHECKED */ MCCefWin32AppendPath(MCCefWin32GetExternalPath(), CEF_PATH_PREFIX"locales", s_locale_path);
124130

125131
return s_locale_path;
126132
}
@@ -131,7 +137,7 @@ const char *MCCefPlatformGetSubProcessName(void)
131137
static char *s_exe_path = nil;
132138

133139
if (s_exe_path == nil)
134-
/* UNCHECKED */ MCCefWin32AppendPath(MCCefWin32GetExternalPath(), "CEF\\revbrowser-cefprocess.exe", s_exe_path);
140+
/* UNCHECKED */ MCCefWin32AppendPath(MCCefWin32GetExternalPath(), CEF_PATH_PREFIX"revbrowser-cefprocess.exe", s_exe_path);
135141

136142
return s_exe_path;
137143
}
@@ -142,7 +148,7 @@ const char *MCCefPlatformGetCefLibraryPath(void)
142148
static char *s_lib_path = nil;
143149

144150
if (s_lib_path == nil)
145-
/* UNCHECKED */ MCCefWin32AppendPath(MCCefWin32GetExternalPath(), "CEF\\libcef.dll", s_lib_path);
151+
/* UNCHECKED */ MCCefWin32AppendPath(MCCefWin32GetExternalPath(), CEF_PATH_PREFIX"libcef.dll", s_lib_path);
146152

147153
return s_lib_path;
148154
}

revbrowser/src/revbrowser.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,17 +1424,39 @@ void revBrowserGetProp(CWebBrowserBase *p_instance, char *args[], int nargs, cha
14241424
{
14251425
int t_left, t_top, t_right, t_bottom;
14261426
t_browser -> GetRect(t_left, t_top, t_right, t_bottom);
1427+
1428+
// IM-2014-07-09: [[ Bug 12225 ]] Convert browser rect to stack coords
1429+
MCRectangle32 t_rect;
1430+
t_rect.x = t_left;
1431+
t_rect.y = t_top;
1432+
t_rect.width = t_right - t_left;
1433+
t_rect.height = t_bottom - t_top;
1434+
1435+
int t_success;
1436+
/* UNCHECKED */ WindowToStackRect(t_browser->GetWindowId(), &t_rect, &t_success);
1437+
14271438
// AL-2013-11-01 [[ Bug 11289 ]] Use libcore methods to prevent potential buffer overflows in revbrowser
1428-
MCCStringFormat(result,"%d,%d,%d,%d", t_left, t_top, t_right, t_bottom);
1439+
MCCStringFormat(result,"%d,%d,%d,%d", t_rect.x, t_rect.y, t_rect.x + t_rect.width, t_rect.y + t_rect.height);
14291440
}
14301441
break;
14311442

14321443
case BROWSERPROP_FORMATTEDRECT:
14331444
{
14341445
int t_left, t_top, t_right, t_bottom;
14351446
t_browser -> GetFormattedRect(t_left, t_top, t_right, t_bottom);
1447+
1448+
// IM-2014-07-09: [[ Bug 12225 ]] Convert browser rect to stack coords
1449+
MCRectangle32 t_rect;
1450+
t_rect.x = t_left;
1451+
t_rect.y = t_top;
1452+
t_rect.width = t_right - t_left;
1453+
t_rect.height = t_bottom - t_top;
1454+
1455+
int t_success;
1456+
/* UNCHECKED */ WindowToStackRect(t_browser->GetWindowId(), &t_rect, &t_success);
1457+
14361458
// AL-2013-11-01 [[ Bug 11289 ]] Use libcore methods to prevent potential buffer overflows in revbrowser
1437-
MCCStringFormat(result,"%d,%d,%d,%d", t_left, t_top, t_right, t_bottom);
1459+
MCCStringFormat(result,"%d,%d,%d,%d", t_rect.x, t_rect.y, t_rect.x + t_rect.width, t_rect.y + t_rect.height);
14381460
}
14391461
break;
14401462

@@ -1630,7 +1652,17 @@ void revBrowserSetProp(CWebBrowserBase *p_instance, char *args[], int nargs, cha
16301652

16311653
if (sscanf(args[1], "%lf,%lf,%lf,%lf", &t_left, &t_top, &t_right, &t_bottom) == 4)
16321654
{
1633-
t_browser -> SetRect((int)(t_left + 0.00000001), (int)(t_top + 0.00000001), (int)(t_right + 0.00000001), (int)(t_bottom + 0.00000001));
1655+
// IM-2014-07-09: [[ Bug 12225 ]] Convert stack rect to window coords
1656+
MCRectangle32 t_rect;
1657+
t_rect.x = (int)(t_left + 0.00000001);
1658+
t_rect.y = (int)(t_top + 0.00000001);
1659+
t_rect.width = ((int)(t_right + 0.00000001)) - t_rect.x;
1660+
t_rect.height = ((int)(t_bottom + 0.00000001)) - t_rect.y;
1661+
1662+
int t_success;
1663+
/* UNCHECKED */ StackToWindowRect(t_browser->GetWindowId(), &t_rect, &t_success);
1664+
1665+
t_browser -> SetRect(t_rect.x, t_rect.y, t_rect.x + t_rect.width, t_rect.y + t_rect.height);
16341666
}
16351667
else
16361668
{

0 commit comments

Comments
 (0)