Despite common sense, native doesn't seem to look for exact match first; it simply case-insensitively compares the props and returns as soon as it finds one. This is also reliant on implementation details in case the object has multiple props with same case-insensitive names, e.g. an object having `Foo` prop, with `foo` prop on its prototype, can still find `Foo` even if you look up `foo` instead (which matches exactly on the prototype). Which is not always reliable, sometimes it finds the prototype first.
See the following diff to illustrate possible behavior on native (which is what I get). Note that especially for jscript, the behavior makes no sense logically; first it picks 'Foo', despite 'foo' being available on the prototype (i.e. exact match). You might think it just looks up on props first, and prototype later, but the second ok() added shows that it finds the prototype's prop first, instead!
```diff
diff --git a/dlls/jscript/tests/jscript.c b/dlls/jscript/tests/jscript.c
index 03774da..2428363 100644
--- a/dlls/jscript/tests/jscript.c
+++ b/dlls/jscript/tests/jscript.c
@@ -999,6 +999,7 @@ static void test_case_sens(void)
/* Native picks one "arbitrarily" here, depending how it's laid out, so can't compare exact id */
hr = IDispatchEx_GetDispID(disp, bstr, fdexNameCaseInsensitive, &id2);
ok(hr == S_OK, "GetDispID failed: %08lx\n", hr);
+ ok(id != id2, "id == id2\n");
hr = IDispatchEx_GetIDsOfNames(disp, &IID_NULL, &bstr, 1, 0, &id2);
ok(hr == S_OK, "GetIDsOfNames failed: %08lx\n", hr);
@@ -1031,6 +1032,7 @@ static void test_case_sens(void)
hr = IDispatchEx_GetDispID(disp, bstr, fdexNameCaseInsensitive | fdexNameEnsure, &id2);
ok(hr == S_OK, "GetDispID failed: %08lx\n", hr);
+ ok(id == id2, "id != id2\n");
SysFreeString(bstr);
IDispatchEx_Release(disp);
diff --git a/dlls/mshtml/tests/script.c b/dlls/mshtml/tests/script.c
index 14e3a14..563b87a 100644
--- a/dlls/mshtml/tests/script.c
+++ b/dlls/mshtml/tests/script.c
@@ -241,6 +241,7 @@ static void test_script_vars(unsigned argc, VARIANTARG *argv)
/* Native picks one "arbitrarily" here, depending how it's laid out, so can't compare exact id */
hres = IDispatchEx_GetDispID(disp, bstr, fdexNameCaseInsensitive, &id2);
ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+ ok(id != id2, "id == id2\n");
hres = IDispatchEx_GetIDsOfNames(disp, &IID_NULL, &bstr, 1, 0, &id2);
ok(hres == S_OK, "GetIDsOfNames failed: %08lx\n", hres);
@@ -273,6 +274,7 @@ static void test_script_vars(unsigned argc, VARIANTARG *argv)
hres = IDispatchEx_GetDispID(disp, bstr, fdexNameCaseInsensitive | fdexNameEnsure, &id2);
ok(hres == S_OK, "GetDispID failed: %08lx\n", hres);
+ ok(id != id2, "id == id2\n");
SysFreeString(bstr);
IDispatchEx_Release(disp);
```
Strangely, mshtml's jscript still finds the prop on the object the second time, but that could be to different underlying implementation. I don't think it's necessary to replicate this quirk.
The main point of this case insensitive handling is that it will be needed later when IE9+ modes use jscript proxy objects for the mshtml objects, because those default to case-insensitive search in GetIDsOfNames, likely to preserve backwards compatibility with pre-IE9 modes. It's a weird quirk, I know, but we have tests for that, which would otherwise break when proxies get added. I'll also add more tests around it later, to prove this, of course, that it also applies to jscript props (e.g. hasOwnProperty on the prototype is still looked case-insensitively if GetIDsOfNames is used).
--
v2: jscript: Implement fdexNameCaseInsensitive flag handling.
https://gitlab.winehq.org/wine/wine/-/merge_requests/656
- Based on !463
- _RunAndWait and exception handling implemented in later commits
@piotr
--
v27: msvcr100: Implement _StructuredTaskCollection::_Schedule and _Schedule_loc.
msvcr100: Factor out the mapping of a context to a scheduler.
msvcr100: Factor out EXCEPTION_RECORD to exception_ptr conversion.
msvcr100: Move exception_ptr functions to a separate file.
https://gitlab.winehq.org/wine/wine/-/merge_requests/464
function call from windows dll to unix function should use `__wine_unix_call` instead of callback function pointer. remove callback struct unix_funcs and add wrapper function of `unixlib_entry_t` type.
--
v2: win32u: replace calling unix functions by unix_call and remove callback unix_funcs
https://gitlab.winehq.org/wine/wine/-/merge_requests/655
On Wed Aug 17 10:20:46 2022 +0000, Jiajin Cui wrote:
> This is to ensure that the second_name is english in a non-english environment.
> When we get the name of another non-english environment before get the
> local environment name, it causes the second_name to be the name of the
> other non-english environment.
> As a result, when looking up a font using an English name, the
> corresponding font cannot be found.
But should it overwrite a second_name if one has already been found?
Note also that this MR has failed the build pipeline.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/628#note_6406
On Wed Aug 17 10:06:52 2022 +0000, Huw Davies wrote:
> I'm afraid I don't understand the logic behind this change.
This is to ensure that the second_name is english in a non-english environment.
When we get the name of another non-english environment before get the local environment name, it causes the second_name to be the name of the other non-english environment.
As a result, when looking up a font using an English name, the corresponding font cannot be found.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/628#note_6405
Manipulating the font size results in the script_cache going stale. From MSDN[1]
`The application should never pass the same handle for different fonts or different sizes.`
This is however exactly what happens when the font size changes as a result of zooming(both in and out). ScriptShape and relative functions will only inspect the hardware device context only if the required data is not cached[2] and hence the data from a previous call to these functions is retrieved even though the font size has changed hence the bug where text both doesn't wrap and doesn't paint as it should.
In patch one, I have tried to keep track of the script_cache objects alongside the relevant font.
Patch two fixes an issue where the cursor doesn't scale after zooming until after one interacts with the editor.
Signed-off-by: David Kahurani <k.kahurani(a)gmail.com>
1. https://docs.microsoft.com/en-us/windows/win32/intl/caching
2. https://docs.microsoft.com/en-us/windows/win32/intl/script-cache
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/626