Ignore:
Timestamp:
Mar 17, 2021, 7:00:25 PM (4 years ago)
Author:
[email protected]
Message:

modern-media-controls script should not be allocated in heap
https://bugs.webkit.org/show_bug.cgi?id=223309

Reviewed by Devin Rousso.

Source/JavaScriptCore:

Add --fail-if-non-ascii flag to ensure that input files do not include non-ASCII characters.

  • Scripts/make-js-file-arrays.py:

(main):

Source/WebCore:

Previously, we are concatenating several modern-media-controls scripts into one.
But this causes significant memory overhead (~600KB). Using NSBundle's data still
allocates memory since WTF::String(CFString) allocates heap memory.

Let's use existing mechanism designed for this purpose. We serialize modern-media-controls.js into const C array in
UserAgentScriptData.cpp. UserAgentScript is a mechanism for having user-agent specific script source, and this matches
to our purpose. (for example, UserAgentStyleSheets (CSS version of that) have html.css etc.).

We also InjectedScript_*.js name for these ModernMediaControls.js scripts while this is not directly related to the
heap usage reduction of this patch.

This patch does not do the same thing for CSS of modern-media-controls since this patch's focus is script files first.

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/plugins/QuickTimePluginReplacement.mm:

(WebCore::quickTimePluginReplacementScript):

  • WebCore.xcodeproj/project.pbxproj:
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript):

  • rendering/RenderTheme.h:

(WebCore::RenderTheme::mediaControlsScripts):
(WebCore::RenderTheme::mediaControlsScript): Deleted.

  • rendering/RenderThemeAdwaita.cpp:

(WebCore::RenderThemeAdwaita::mediaControlsScripts):
(WebCore::RenderThemeAdwaita::mediaControlsScript): Deleted.

  • rendering/RenderThemeAdwaita.h:
  • rendering/RenderThemeIOS.h:
  • rendering/RenderThemeIOS.mm:

(WebCore::RenderThemeIOS::purgeCaches):
(WebCore::RenderThemeIOS::mediaControlsScripts):
(WebCore::RenderThemeIOS::mediaControlsScript): Deleted.

  • rendering/RenderThemeMac.h:
  • rendering/RenderThemeMac.mm:

(WebCore::RenderThemeMac::purgeCaches):
(WebCore::RenderThemeMac::mediaControlsScripts):
(WebCore::RenderThemeMac::mediaControlsScript): Deleted.

  • rendering/RenderThemeWin.cpp:

(WebCore::RenderThemeWin::mediaControlsScripts):
(WebCore::RenderThemeWin::mediaControlsScript): Deleted.

  • rendering/RenderThemeWin.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/Scripts/make-js-file-arrays.py

    r249095 r274607  
    4646    parser = OptionParser(usage="usage: %prog [options] header source [input [input...]]")
    4747    parser.add_option('--no-minify', action='store_true', help='Do not run the input files through jsmin')
     48    parser.add_option('--fail-if-non-ascii', action='store_true', help='Fail if the input files include non-ASCII characters')
    4849    parser.add_option('-n', '--namespace', help='Namespace to use')
    4950    (options, arguments) = parser.parse_args()
     
    8384            characters = data
    8485
     86        if options.fail_if_non_ascii:
     87            for character in characters:
     88                if ord(character) >= 128:
     89                    raise Exception("%s is not ASCII" % character)
     90
    8591        if is_3:
    8692            codepoints = bytearray(characters, encoding='utf-8')
Note: See TracChangeset for help on using the changeset viewer.