Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
scripts.htmleventgenerator.HtmlEventGenerator Class Reference
Inheritance diagram for scripts.htmleventgenerator.HtmlEventGenerator:

Public Member Functions

def __init__ (self, database, renamer, metadata, template_loader)
 
def EmitStreamProviders (self, interface, custom_events, members_emitter, library_name)
 
def EmitStreamGetters (self, interface, custom_events, members_emitter, library_name, stream_getter_signatures_emitter=None, element_stream_getters_emitter=None)
 
def GetEvents (self, interface, custom_events)
 

Detailed Description

Definition at line 277 of file htmleventgenerator.py.

Constructor & Destructor Documentation

◆ __init__()

def scripts.htmleventgenerator.HtmlEventGenerator.__init__ (   self,
  database,
  renamer,
  metadata,
  template_loader 
)

Definition at line 279 of file htmleventgenerator.py.

279 def __init__(self, database, renamer, metadata, template_loader):
280 self._event_classes = set()
281 self._database = database
282 self._renamer = renamer
283 self._metadata = metadata
284 self._template_loader = template_loader
285 self._media_events = None
286
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
Definition: switches.h:76

Member Function Documentation

◆ EmitStreamGetters()

def scripts.htmleventgenerator.HtmlEventGenerator.EmitStreamGetters (   self,
  interface,
  custom_events,
  members_emitter,
  library_name,
  stream_getter_signatures_emitter = None,
  element_stream_getters_emitter = None 
)

Definition at line 316 of file htmleventgenerator.py.

322 element_stream_getters_emitter=None):
323
324 events = self.GetEvents(interface, custom_events)
325 if not events:
326 return
327
328 for event_info in events:
329 (dom_name, html_name, event_type) = event_info
330 getter_name = 'on%s%s' % (html_name[:1].upper(), html_name[1:])
331 annotation_name = 'on' + dom_name
332
333 # If the provider is declared elsewhere, point to that.
334 redirection = self._GetEventRedirection(interface, html_name,
335 event_type)
336 if redirection:
337 provider = '%s.%sEvent' % (redirection, html_name)
338 else:
339 provider = html_name + 'Event'
340
341 annotations = self._metadata.GetFormattedMetadata(
342 library_name, interface, annotation_name, ' ')
343
344 isElement = False
345 for parent in self._database.Hierarchy(interface):
346 if parent.id == 'Element':
347 isElement = True
348 # We add the same event stream getters Element, ElementList, and
349 # _FrozenElementList. So, in impl_Element.darttemplate, we have two
350 # additional emitters to add the correct variation of the stream getter
351 # for that context.
352 for emitter in [
353 members_emitter, stream_getter_signatures_emitter,
354 element_stream_getters_emitter
355 ]:
356 if emitter == None:
357 continue
358 elem_type = 'Element' if isElement else ''
359 call_name = 'forElement' if isElement else 'forTarget'
360 if emitter == element_stream_getters_emitter:
361 call_name = '_forElementList'
362 emitter.Emit(
363 "\n"
364 " $(ANNOTATIONS)$(ELEM_TYPE)Stream<$TYPE> get $(NAME)$BODY;\n",
365 ANNOTATIONS=annotations,
366 ELEM_TYPE=elem_type,
367 NAME=getter_name,
368 BODY=('' if emitter == stream_getter_signatures_emitter else
369 ' => %s.%s(this)' % ((
370 ('' if emitter != element_stream_getters_emitter
371 else 'Element.') + provider), call_name)),
372 TYPE=event_type)
373

◆ EmitStreamProviders()

def scripts.htmleventgenerator.HtmlEventGenerator.EmitStreamProviders (   self,
  interface,
  custom_events,
  members_emitter,
  library_name 
)

Definition at line 287 of file htmleventgenerator.py.

288 library_name):
289
290 events = self.GetEvents(interface, custom_events)
291 if not events:
292 return
293
294 for event_info in events:
295 (dom_name, html_name, event_type) = event_info
296 annotation_name = dom_name + 'Event'
297
298 # If we're using a different provider, then don't declare one.
299 if self._GetEventRedirection(interface, html_name, event_type):
300 continue
301
302 annotations = self._metadata.FormatMetadata(
303 self._metadata.GetMetadata(library_name, interface,
304 annotation_name, 'on' + dom_name),
305 ' ')
306
307 members_emitter.Emit(
308 "\n"
309 " $(ANNOTATIONS)static const EventStreamProvider<$TYPE> "
310 "$(NAME)Event = const EventStreamProvider<$TYPE>('$DOM_NAME');\n",
311 ANNOTATIONS=annotations,
312 NAME=html_name,
313 DOM_NAME=dom_name,
314 TYPE=event_type)
315

◆ GetEvents()

def scripts.htmleventgenerator.HtmlEventGenerator.GetEvents (   self,
  interface,
  custom_events 
)
 Gets a list of all of the events for the specified interface.

Definition at line 389 of file htmleventgenerator.py.

389 def GetEvents(self, interface, custom_events):
390 """ Gets a list of all of the events for the specified interface.
391 """
392 html_interface_name = interface.doc_js_name
393
394 events = self._GetRawEvents(interface)
395
396 if html_interface_name in _html_manual_events:
397 events.update(_html_manual_events[html_interface_name])
398
399 if not events and interface.id not in _html_explicit_event_classes:
400 return None
401
402 dom_event_names = set()
403 for event in events:
404 dom_name = event[2:]
405 dom_name = _on_attribute_to_event_name_mapping.get(
406 dom_name, dom_name)
407 dom_event_names.add(dom_name)
408
409 events = []
410 for dom_name in sorted(dom_event_names):
411 event_info = self._FindEventInfo(html_interface_name, dom_name)
412 if not event_info:
413 continue
414
415 (html_name, event_type) = event_info
416 if self._IsEventSuppressed(interface, html_name, event_type):
417 continue
418
419 full_event_name = '%sEvents.%s' % (html_interface_name, html_name)
420 if not full_event_name in custom_events:
421 events.append((dom_name, html_name, event_type))
422 return events
423

The documentation for this class was generated from the following file: