Bug 163222 - Add support for languagechange event
Summary: Add support for languagechange event
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: WebExposed
Depends on: 163220
Blocks:
  Show dependency treegraph
 
Reported: 2016-10-10 10:50 PDT by Chris Dumez
Modified: 2016-10-10 21:36 PDT (History)
11 users (show)

See Also:


Attachments
Patch (16.68 KB, patch)
2016-10-10 16:42 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (16.64 KB, patch)
2016-10-10 16:43 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (16.62 KB, patch)
2016-10-10 21:01 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2016-10-10 10:50:13 PDT
Add support for languagechange event:
- https://html.spec.whatwg.org/#dom-navigator-languages
Comment 1 Chris Dumez 2016-10-10 16:42:19 PDT
Created attachment 291184 [details]
Patch
Comment 2 Chris Dumez 2016-10-10 16:43:41 PDT
Created attachment 291185 [details]
Patch
Comment 3 Ryosuke Niwa 2016-10-10 19:02:37 PDT
Comment on attachment 291185 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=291185&action=review

> Source/WebCore/page/DOMWindow.cpp:426
> +
> +    addLanguageChangeObserver(this, &languagesChangedCallback);

This would be racy with regards with the cache being invalidated in FontGenericFamilies.
We need to either force invalidating the cache in there first
or add some other mechanism to make sure this observer is called at the very end or very first
so that there is no observable race conditions.
Comment 4 Chris Dumez 2016-10-10 19:27:42 PDT
Comment on attachment 291185 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=291185&action=review

>> Source/WebCore/page/DOMWindow.cpp:426
>> +    addLanguageChangeObserver(this, &languagesChangedCallback);
> 
> This would be racy with regards with the cache being invalidated in FontGenericFamilies.
> We need to either force invalidating the cache in there first
> or add some other mechanism to make sure this observer is called at the very end or very first
> so that there is no observable race conditions.

Sorry, I do not understand your comment at all. I see that FontGenericFamilies is also registering a language change callback but I do not understand how this impacts Window registering its own callback.
Which cache are you referring to?
Comment 5 Chris Dumez 2016-10-10 19:32:45 PDT
Comment on attachment 291185 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=291185&action=review

>>> Source/WebCore/page/DOMWindow.cpp:426
>>> +    addLanguageChangeObserver(this, &languagesChangedCallback);
>> 
>> This would be racy with regards with the cache being invalidated in FontGenericFamilies.
>> We need to either force invalidating the cache in there first
>> or add some other mechanism to make sure this observer is called at the very end or very first
>> so that there is no observable race conditions.
> 
> Sorry, I do not understand your comment at all. I see that FontGenericFamilies is also registering a language change callback but I do not understand how this impacts Window registering its own callback.
> Which cache are you referring to?

Oh, I think I understand your worry now. How about we simply fire the JS event asynchronously?
Comment 6 Ryosuke Niwa 2016-10-10 19:41:15 PDT
(In reply to comment #5)
> Comment on attachment 291185 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=291185&action=review
> 
> >>> Source/WebCore/page/DOMWindow.cpp:426
> >>> +    addLanguageChangeObserver(this, &languagesChangedCallback);
> >> 
> >> This would be racy with regards with the cache being invalidated in FontGenericFamilies.
> >> We need to either force invalidating the cache in there first
> >> or add some other mechanism to make sure this observer is called at the very end or very first
> >> so that there is no observable race conditions.
> > 
> > Sorry, I do not understand your comment at all. I see that FontGenericFamilies is also registering a language change callback but I do not understand how this impacts Window registering its own callback.
> > Which cache are you referring to?
> 
> Oh, I think I understand your worry now. How about we simply fire the JS
> event asynchronously?

Yeah, that works too.
Comment 7 Chris Dumez 2016-10-10 21:01:27 PDT
Created attachment 291223 [details]
Patch
Comment 8 WebKit Commit Bot 2016-10-10 21:36:31 PDT
Comment on attachment 291223 [details]
Patch

Clearing flags on attachment: 291223

Committed r207040: <http://trac.webkit.org/changeset/207040>
Comment 9 WebKit Commit Bot 2016-10-10 21:36:37 PDT
All reviewed patches have been landed.  Closing bug.