Opened 3 years ago

Closed 4 months ago

#5144 closed change (rejected)

[emscripten] Move FilterListener functionality into FilterNotifier

Reported by: trev Assignee:
Priority: P3 Milestone:
Module: Core Keywords: closed-in-favor-of-gitlab
Cc: Blocked By: #5063, #5137, #5141, #5142, #5143
Blocking: #4122 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description

Background

In order to reduce the number of calls from Emscripten to JavaScript, it would be beneficial to avoid calling JavaScript FilterNotifier callbacks. Most of the time, all callbacks come from FilterListener, these can be moved into C++.

What to change

  • Add ActiveFilter.listedSubscriptionCount property, initially 0.
  • Handle some notification topics within FilterNotifier:
    • FILTER_ADDED: if the filter is added to a listed subscription, perform filter addition checks.
    • FILTER_REMOVED: if the filter is removed from a listed subscription, perform filter removal checks.
    • FILTER_DISABLED: if filter type is deriving from ActiveFilter and listedSubscriptionCount is non-zero:
      • For enabled filters, perform filter addition.
      • For disabled filters, perform filter removal.
    • SUBSCRIPTION_ADDED: if the subscription is enabled, perform filter addition checks for all subscription filters.
    • SUBSCRIPTION_REMOVED: if the subscription is enabled, perform filter removal checks for all subscription filters.
  • Filter addition checks:
    • Ignore filter types not deriving from ActiveFilter.
    • Increase ActiveFilter.listedSubscriptionCount.
    • If filter is enabled and listedSubscriptionCount is 1, perform filter addition.
  • Filter addition:
    • Add filter to Matcher, ElemHide or ElemHideEmulation depending on type.
  • Filter removal checks:
    • Ignore filter types not deriving from ActiveFilter.
    • Decrease ActiveFilter.listedSubscriptionCount.
    • If filter is enabled and listedSubscriptionCount is 0, perform filter removal.
  • Filter removal:
    • Remove filter from Matcher, ElemHide or ElemHideEmulation depending on type.
  • Once the other changes are implemented, notifying JavaScript will become unnecessary most of the time. Expose FilterNotifier as a namespace with the methods _enableCallbacks and _disableCallbacks. The existing lib/filterNotifier.js should extend that namespace and call _enableCallbacks when a first callback is added for a topic and _disableCallbacks when the last callback is removed for a topic (CATCH_ALL being a "topic" as well). FilterNotifier should then only call into JavaScript if callbacks are enabled for the respective topic or CATCH_ALL.

Change History (3)

comment:1 Changed 3 years ago by trev

  • Blocked By 5137, 5141, 5142, 5143 added

comment:2 Changed 3 years ago by trev

  • Blocked By 5063 added

comment:3 Changed 4 months ago by sebastian

  • Keywords closed-in-favor-of-gitlab added
  • Resolution set to rejected
  • Status changed from new to closed

Sorry, but we switched to GitLab. If this issue is still relevant, please file it again in the new issue tracker.

Note: See TracTickets for help on using tickets.