Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
scripts.mdnreader.MDNReader Class Reference
Inheritance diagram for scripts.mdnreader.MDNReader:

Public Member Functions

 __init__ (self)
 
 is_compatible (self, attribute)
 
 set_compatible (self, attribute, compatible)
 

Protected Member Functions

 _get_attr_compatibility (self, compat_data)
 

Protected Attributes

 _compat_overrides
 

Static Protected Attributes

 _BROWSER_COMPAT_DATA = _get_browser_compat_data()
 

Detailed Description

Definition at line 255 of file mdnreader.py.

Constructor & Destructor Documentation

◆ __init__()

scripts.mdnreader.MDNReader.__init__ (   self)

Definition at line 259 of file mdnreader.py.

259 def __init__(self):
260 self._compat_overrides = {}
261

Member Function Documentation

◆ _get_attr_compatibility()

scripts.mdnreader.MDNReader._get_attr_compatibility (   self,
  compat_data 
)
protected

Definition at line 262 of file mdnreader.py.

262 def _get_attr_compatibility(self, compat_data):
263 # Parse schema syntax of MDN data:
264 # https://github.com/mdn/browser-compat-data/blob/master/schemas/compat-data.schema.json
265
266 # For now, we will require support for browsers since the last IDL roll.
267 # TODO(srujzs): Determine if this is too conservative.
268 browser_version_map = {
269 'chrome': '63',
270 'firefox': '57',
271 'safari': '11',
272 # We still support the latest version of IE.
273 'ie': '11',
274 'opera': '50',
275 }
276 for browser in browser_version_map.keys():
277 support_data = compat_data[_SUPPORT_KEY]
278 if browser not in support_data:
279 return False
280 support_statement = support_data[browser]
281 if not _is_simple_support_statement(support_statement):
282 return False
283 version = support_statement[_VERSION_ADDED_KEY]
284 # Compare version strings, target should be the more strict version.
285 target = browser_version_map[browser]
286 if _unify_versions(version, target) != target:
287 return False
288
289 # If the attribute is experimental, we assume it's not compatible.
290 status_data = compat_data[_STATUS_KEY]
291 if _EXPERIMENTAL_KEY in status_data and status_data[_EXPERIMENTAL_KEY]:
292 return False
293 return True
294

◆ is_compatible()

scripts.mdnreader.MDNReader.is_compatible (   self,
  attribute 
)

Definition at line 295 of file mdnreader.py.

295 def is_compatible(self, attribute):
296 # Since capitalization isn't consistent across MDN and WebCore, we
297 # compare lowercase equivalents for interface and attribute names.
298 interface = attribute.doc_js_interface_name.lower()
299 if interface in self._BROWSER_COMPAT_DATA and attribute.id and len(
300 attribute.id) > 0:
301 interface_dict = self._BROWSER_COMPAT_DATA[interface]
302 id_name = attribute.id.lower()
303 secure_context_key = 'isSecureContext'
304 if interface in self._compat_overrides and id_name in self._compat_overrides[
305 interface]:
306 return self._compat_overrides[interface][id_name]
307 elif secure_context_key in interface_dict:
308 # If the interface requires a secure context, all attributes are
309 # implicitly incompatible.
310 return False
311 elif id_name in interface_dict:
312 id_data = interface_dict[id_name]
313 return self._get_attr_compatibility(id_data[_COMPAT_KEY])
314 else:
315 # Might be an attribute that is defined in a parent interface.
316 # We defer until attribute emitting to determine if this is the
317 # case. Otherwise, return None.
318 pass
319 return None
320
static bool is_compatible(const GrSurfaceCharacterization &gsc, const GrBackendTexture &backendTex)

◆ set_compatible()

scripts.mdnreader.MDNReader.set_compatible (   self,
  attribute,
  compatible 
)

Definition at line 321 of file mdnreader.py.

321 def set_compatible(self, attribute, compatible):
322 # Override value in the MDN browser compatibility data.
323 if not compatible in [True, False, None]:
324 raise ValueError('Cannot set a non-boolean object for compatible')
325 interface = attribute.doc_js_interface_name.lower()
326 if not interface in self._compat_overrides:
327 self._compat_overrides[interface] = {}
328 if attribute.id and len(attribute.id) > 0:
329 id_name = attribute.id.lower()
330 self._compat_overrides[interface][id_name] = compatible

Member Data Documentation

◆ _BROWSER_COMPAT_DATA

scripts.mdnreader.MDNReader._BROWSER_COMPAT_DATA = _get_browser_compat_data()
staticprotected

Definition at line 257 of file mdnreader.py.

◆ _compat_overrides

scripts.mdnreader.MDNReader._compat_overrides
protected

Definition at line 260 of file mdnreader.py.


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