From 904ddfa28f82b2cc5071c3c24db941b777a88dfa Mon Sep 17 00:00:00 2001 From: Martok Date: Sun, 25 Dec 2022 16:41:45 +0100 Subject: [PATCH 01/13] Follow-up #2060 - Correctly handle \k in non-unicode expressions --- js/src/irregexp/RegExpParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/irregexp/RegExpParser.cpp b/js/src/irregexp/RegExpParser.cpp index 0deb3c658d..c609f5940d 100644 --- a/js/src/irregexp/RegExpParser.cpp +++ b/js/src/irregexp/RegExpParser.cpp @@ -2069,8 +2069,8 @@ RegExpParser::ParseDisjunction() // an identity escape for non-Unicode patterns without named // capture groups, and as the beginning of a named back-reference // in all other cases. + Advance(2); if (unicode_ || HasNamedCaptures()) { - Advance(2); if (!ParseNamedBackReference(builder, state)) { return ReportError(JSMSG_INVALID_IDENTITY_ESCAPE); } From 09cbcd3413283169ee7569d34e66c8b704736a27 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Fri, 23 Dec 2022 19:21:40 +0800 Subject: [PATCH 02/13] Issue #2063 - Ensure a floated ::first-letter inherits from ::first-line. This fixes the 24 year old Mozilla bug 13610. Co-authored-by: Ryo Onodera --- layout/generic/nsFrame.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 291270db99..69d9376e5b 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -9033,6 +9033,13 @@ nsFrame::CorrectStyleParentFrame(nsIFrame* aProspectiveParent, parent = sibling; } } + + // Ensure ::first-letter inherits from ::first-line even when floated, see + // Issue #2063 / Mozilla bug 13610. + if (parent->GetType() == nsGkAtoms::lineFrame && + parent == parent->FirstInFlow()) { + return parent; + } nsIAtom* parentPseudo = parent->StyleContext()->GetPseudo(); if (!parentPseudo || From b67d7520b6841d865732d7ec31acff9523db223e Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 5 Aug 2022 12:30:54 +0800 Subject: [PATCH 03/13] Issue #2065 - Part 2: Expand pattern when track file is created rather than read This fixes build bustage on Windows when using `mach build faster`. Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1416465 --- .../action/process_install_manifest.py | 4 ++- python/mozbuild/mozpack/manifests.py | 25 +++++++++++++------ .../mozbuild/mozpack/test/test_manifests.py | 23 +++++++++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/python/mozbuild/mozbuild/action/process_install_manifest.py b/python/mozbuild/mozbuild/action/process_install_manifest.py index e19fe4edae..47b7aef5ba 100644 --- a/python/mozbuild/mozbuild/action/process_install_manifest.py +++ b/python/mozbuild/mozbuild/action/process_install_manifest.py @@ -70,7 +70,9 @@ def process_manifest(destdir, paths, track=None, remove_empty_directories=remove_empty_directories) if track: - manifest.write(path=track) + # We should record files that we actually copied. + # It is too late to expand wildcards when the track file is read. + manifest.write(path=track, expand_pattern=True) return result diff --git a/python/mozbuild/mozpack/manifests.py b/python/mozbuild/mozpack/manifests.py index 93bd6c2cab..b77931101a 100644 --- a/python/mozbuild/mozpack/manifests.py +++ b/python/mozbuild/mozpack/manifests.py @@ -228,7 +228,7 @@ class InstallManifest(object): """ return json.loads(data) - def write(self, path=None, fileobj=None): + def write(self, path=None, fileobj=None, expand_pattern=False): """Serialize this manifest to a file or file object. If path is specified, that file will be written to. If fileobj is specified, @@ -242,10 +242,21 @@ class InstallManifest(object): for dest in sorted(self._dests): entry = self._dests[dest] - parts = ['%d' % entry[0], dest] - parts.extend(entry[1:]) - fh.write('%s\n' % self.FIELD_SEPARATOR.join( - p.encode('utf-8') for p in parts)) + if expand_pattern and entry[0] in (self.PATTERN_SYMLINK, self.PATTERN_COPY): + type, base, pattern, dest = entry + type = self.SYMLINK if type == self.PATTERN_SYMLINK else self.COPY + finder = FileFinder(base) + paths = [f[0] for f in finder.find(pattern)] + for path in paths: + source = mozpath.join(base, path) + parts = ['%d' % type, mozpath.join(dest, path), source] + fh.write('%s\n' % self.FIELD_SEPARATOR.join( + p.encode('utf-8') for p in parts)) + else: + parts = ['%d' % entry[0], dest] + parts.extend(entry[1:]) + fh.write('%s\n' % self.FIELD_SEPARATOR.join( + p.encode('utf-8') for p in parts)) def add_symlink(self, source, dest): """Add a symlink to this manifest. @@ -289,7 +300,7 @@ class InstallManifest(object): /foo/bar.h -> /foo/bar.h """ - self._add_entry(mozpath.join(base, pattern, dest), + self._add_entry(mozpath.join(dest, pattern), (self.PATTERN_SYMLINK, base, pattern, dest)) def add_pattern_copy(self, base, pattern, dest): @@ -297,7 +308,7 @@ class InstallManifest(object): See ``add_pattern_symlink()`` for usage. """ - self._add_entry(mozpath.join(base, pattern, dest), + self._add_entry(mozpath.join(dest, pattern), (self.PATTERN_COPY, base, pattern, dest)) def add_preprocess(self, source, dest, deps, marker='#', defines={}, diff --git a/python/mozbuild/mozpack/test/test_manifests.py b/python/mozbuild/mozpack/test/test_manifests.py index b785d014a4..7d926a0c8a 100644 --- a/python/mozbuild/mozpack/test/test_manifests.py +++ b/python/mozbuild/mozpack/test/test_manifests.py @@ -156,6 +156,29 @@ class TestInstallManifest(TestWithTmpDir): self.assertIn('s_dest2', m1) self.assertIn('c_dest2', m1) + def test_write_expand_pattern(self): + source = self.tmppath('source') + os.mkdir(source) + os.mkdir('%s/base' % source) + os.mkdir('%s/base/foo' % source) + + with open('%s/base/foo/file1' % source, 'a'): + pass + + with open('%s/base/foo/file2' % source, 'a'): + pass + + m = InstallManifest() + m.add_pattern_link('%s/base' % source, '**', 'dest') + + track = self.tmppath('track') + m.write(path=track, expand_pattern=True) + + m = InstallManifest(path=track) + self.assertEqual([dest for dest in m._dests], + ['dest/foo/file1', 'dest/foo/file2']) + + def test_copier_application(self): dest = self.tmppath('dest') os.mkdir(dest) From 558b83975ce9b2038d6bdaa3415a9f517fcfa4cf Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 5 Aug 2022 12:38:10 +0800 Subject: [PATCH 04/13] Issue #2065 - Part 3: Process install manifests with --track in the recursive make backend This excludes parts that remove support for building the Mozilla SDK. Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1390916 --- Makefile.in | 20 ++----- js/src/Makefile.in | 2 +- .../action/process_install_manifest.py | 58 ++++++++----------- xpcom/xpidl/Makefile.in | 2 +- 4 files changed, 32 insertions(+), 50 deletions(-) diff --git a/Makefile.in b/Makefile.in index 6c23273884..429bcabab3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -187,16 +187,7 @@ tup: @$(TUP) $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),,--verbose) $(call BUILDSTATUS,TIER_FINISH tup) -# process_install_manifest needs to be invoked with --no-remove when building -# js as standalone because automated builds are building nspr separately and -# that would remove the resulting files. -# Eventually, a standalone js build would just be able to build nspr itself, -# removing the need for the former. -ifdef JS_STANDALONE -NO_REMOVE=1 -endif - -.PHONY: $(addprefix install-,$(subst /,_,$(install_manifests))) +.PHONY: $(addprefix install-,$(install_manifests)) $(addprefix install-,$(install_manifests)): install-%: $(install_manifest_depends) ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) @# If we're using the hybrid FasterMake/RecursiveMake backend, we want @@ -204,7 +195,7 @@ ifneq (,$(filter FasterMake+RecursiveMake,$(BUILD_BACKENDS))) @# same directory, because that would blow up $(if $(wildcard _build_manifests/install/$(subst /,_,$*)),$(if $(wildcard faster/install_$(subst /,_,$*)*),$(error FasterMake and RecursiveMake ends of the hybrid build system want to handle $*))) endif - $(addprefix $(call py_action,process_install_manifest,$(if $(NO_REMOVE),--no-remove )$*) ,$(wildcard _build_manifests/install/$(subst /,_,$*))) + $(addprefix $(call py_action,process_install_manifest,--track install_$(subst /,_,$*).track $*) ,$(wildcard _build_manifests/install/$(subst /,_,$*))) # Dummy wrapper rule to allow the faster backend to piggy back $(addprefix install-,$(subst /,_,$(filter dist/%,$(install_manifests)))): install-dist_%: install-dist/% ; @@ -217,10 +208,9 @@ install-tests: install-test-files .PHONY: run-tests-deps run-tests-deps: $(install_manifest_depends) -# Force --no-remove, because $objdir/_tests is handled by multiple manifests. .PHONY: install-test-files install-test-files: - $(call py_action,process_install_manifest,--no-remove _tests _build_manifests/install/_test_files) + $(call py_action,process_install_manifest,--track install__test_files.track _tests _build_manifests/install/_test_files) include $(topsrcdir)/build/moz-automation.mk @@ -240,13 +230,13 @@ ifndef NO_PROFILE_GUIDED_OPTIMIZE ifneq ($(OS_ARCH)_$(GNU_CC), WINNT_) recurse_pre-export:: install-manifests binaries:: - @$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include + @$(MAKE) install-manifests install_manifests=dist/include endif endif else # !MOZ_PROFILE_USE (normal build) recurse_pre-export:: install-manifests binaries:: - @$(MAKE) install-manifests NO_REMOVE=1 install_manifests=dist/include + @$(MAKE) install-manifests install_manifests=dist/include endif # For historical reasons that are unknown, $(DIST)/sdk is always blown away diff --git a/js/src/Makefile.in b/js/src/Makefile.in index bc99e62b5d..a8b685ef02 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -185,7 +185,7 @@ install:: js-config.h # install:: - $(call py_action,process_install_manifest,--no-remove --no-symlinks $(DESTDIR)$(includedir) $(DEPTH)/_build_manifests/install/dist_include) + $(call py_action,process_install_manifest,--track install_dist_include.track --no-symlinks $(DESTDIR)$(includedir) $(DEPTH)/_build_manifests/install/dist_include) # # END SpiderMonkey header installation diff --git a/python/mozbuild/mozbuild/action/process_install_manifest.py b/python/mozbuild/mozbuild/action/process_install_manifest.py index 47b7aef5ba..a97a72cc6e 100644 --- a/python/mozbuild/mozbuild/action/process_install_manifest.py +++ b/python/mozbuild/mozbuild/action/process_install_manifest.py @@ -29,33 +29,31 @@ COMPLETE = 'Elapsed: {elapsed:.2f}s; From {dest}: Kept {existing} existing; ' \ 'Removed {rm_files} files and {rm_dirs} directories.' -def process_manifest(destdir, paths, track=None, - remove_unaccounted=True, - remove_all_directory_symlinks=True, - remove_empty_directories=True, +def process_manifest(destdir, paths, track, no_symlinks=False, defines={}): - if track: - if os.path.exists(track): - # We use the same format as install manifests for the tracking - # data. - manifest = InstallManifest(path=track) - remove_unaccounted = FileRegistry() - dummy_file = BaseFile() + if os.path.exists(track): + # We use the same format as install manifests for the tracking + # data. + manifest = InstallManifest(path=track) + remove_unaccounted = FileRegistry() + dummy_file = BaseFile() - finder = FileFinder(destdir, find_executables=False, - find_dotfiles=True) - for dest in manifest._dests: - for p, f in finder.find(dest): - remove_unaccounted.add(p, dummy_file) + finder = FileFinder(destdir, find_executables=False, + find_dotfiles=True) + for dest in manifest._dests: + for p, f in finder.find(dest): + remove_unaccounted.add(p, dummy_file) - else: - # If tracking is enabled and there is no file, we don't want to - # be removing anything. - remove_unaccounted=False - remove_empty_directories=False - remove_all_directory_symlinks=False + remove_empty_directories=True + remove_all_directory_symlinks=True + else: + # If tracking is enabled and there is no file, we don't want to + # be removing anything. + remove_unaccounted=False + remove_empty_directories=False + remove_all_directory_symlinks=False manifest_cls = InstallManifestNoSymlinks if no_symlinks else InstallManifest manifest = manifest_cls() @@ -83,15 +81,9 @@ def main(argv): parser.add_argument('destdir', help='Destination directory.') parser.add_argument('manifests', nargs='+', help='Path to manifest file(s).') - parser.add_argument('--no-remove', action='store_true', - help='Do not remove unaccounted files from destination.') - parser.add_argument('--no-remove-all-directory-symlinks', action='store_true', - help='Do not remove all directory symlinks from destination.') - parser.add_argument('--no-remove-empty-directories', action='store_true', - help='Do not remove empty directories from destination.') parser.add_argument('--no-symlinks', action='store_true', help='Do not install symbolic links. Always copy files') - parser.add_argument('--track', metavar="PATH", + parser.add_argument('--track', metavar="PATH", required=True, help='Use installed files tracking information from the given path.') parser.add_argument('-D', action=DefinesAction, dest='defines', metavar="VAR[=VAL]", @@ -101,11 +93,11 @@ def main(argv): start = time.time() - result = process_manifest(args.destdir, args.manifests, - track=args.track, remove_unaccounted=not args.no_remove, - remove_all_directory_symlinks=not args.no_remove_all_directory_symlinks, - remove_empty_directories=not args.no_remove_empty_directories, + result = process_manifest( + args.destdir, + args.manifests, no_symlinks=args.no_symlinks, + track=args.track, defines=args.defines) elapsed = time.time() - start diff --git a/xpcom/xpidl/Makefile.in b/xpcom/xpidl/Makefile.in index b58ad48664..dff31a2bab 100644 --- a/xpcom/xpidl/Makefile.in +++ b/xpcom/xpidl/Makefile.in @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. export:: - $(call py_action,process_install_manifest,$(DIST)/idl $(DEPTH)/_build_manifests/install/dist_idl) + $(call py_action,process_install_manifest,--track install-xpidl.track $(DIST)/idl $(DEPTH)/_build_manifests/install/dist_idl) $(call SUBMAKE,xpidl,$(DEPTH)/config/makefiles/xpidl) clean clobber realclean clobber_all distclean:: From b1b4c7d0eeb8fae207d2a1e06360bd1eddceaeb2 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Wed, 17 Aug 2022 11:10:53 +0800 Subject: [PATCH 05/13] Issue #2065 - Part 4: Revise comments and remove parts dependent on hybrid FasterMake/RecursiveMake backend --- config/faster/rules.mk | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/config/faster/rules.mk b/config/faster/rules.mk index 9d7b322fa2..cd3c799cf5 100644 --- a/config/faster/rules.mk +++ b/config/faster/rules.mk @@ -10,13 +10,12 @@ # things happening at each step required other things happening in previous # steps without any documentation of those dependencies. # -# This new build system tries to start afresh by establishing what files or -# operations are needed for the build, and applying the necessary rules to -# have those in place, relying on make dependencies to get them going. +# This build system establishes what files or operations are needed for the +# build, and applying the necessary rules to have those in place, relying on +# make dependencies to get them going. # -# As of writing, only building non-compiled parts of Firefox is supported -# here (a few other things are also left out). This is a starting point, with -# the intent to grow this build system to make it more complete. +# Only non-compiled parts of the application and platform are built and +# supported here (a few other things are also left out). # # This file contains rules and dependencies to get things working. The intent # is for a Makefile to define some dependencies and variables, and include @@ -42,19 +41,11 @@ ifndef NO_XPIDL default: $(TOPOBJDIR)/config/makefiles/xpidl/xpidl endif -# Mac builds require to copy things in dist/bin/*.app -# TODO: remove the MOZ_WIDGET_TOOLKIT and MOZ_BUILD_APP variables from -# faster/Makefile and python/mozbuild/mozbuild/test/backend/test_build.py -# when this is not required anymore. -# We however don't need to do this when using the hybrid -# FasterMake/RecursiveMake backend (FASTER_RECURSIVE_MAKE is set when -# recursing from the RecursiveMake backend) -ifndef FASTER_RECURSIVE_MAKE +# Mac builds require copying files in dist/bin/*.app ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) default: $(MAKE) -C $(TOPOBJDIR)/$(MOZ_BUILD_APP)/app repackage endif -endif .PHONY: FORCE @@ -99,12 +90,9 @@ $(addprefix install-,$(INSTALL_MANIFESTS)): install-%: $(addprefix $(TOPOBJDIR)/ # that are not supported by data in moz.build. # The xpidl target in config/makefiles/xpidl requires the install manifest for -# dist/idl to have been processed. When using the hybrid -# FasterMake/RecursiveMake backend, this dependency is handled in the top-level -# Makefile. -ifndef FASTER_RECURSIVE_MAKE +# dist/idl to have been processed. $(TOPOBJDIR)/config/makefiles/xpidl/xpidl: $(TOPOBJDIR)/install-dist_idl -endif + # It also requires all the install manifests for dist/bin to have been processed # because it adds interfaces.manifest references with buildlist.py. $(TOPOBJDIR)/config/makefiles/xpidl/xpidl: $(addprefix install-,$(filter dist/bin%,$(INSTALL_MANIFESTS))) From 9c51368727118b6fe85fe2c7c68aaa5e46ac9230 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Wed, 17 Aug 2022 19:54:01 +0800 Subject: [PATCH 06/13] Issue #2065 - Part 5: Fix incorrect inclusion of base file name in destination path for generated FasterMake track files I'm not sure about what they had in mind when they first wrote this, but this is completely unnecessary. The base name is the file name. This part will break building with `mach faster` once partial filenames with wildcards are included in the package manifest, which became the case when we began supporting the newer MSVC runtime. This also aligns FasterMake with how RecursiveMake treats wildcard copy directives. They fixed this in bug 1416465, but it included a conditional that will almost always be true and kept this incorrect joining of the path and base name in the destination path. Since the value for the base name is either empty or contains a partial file name, that conditional effectively does nothing. --- python/mozbuild/mozbuild/backend/fastermake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/backend/fastermake.py b/python/mozbuild/mozbuild/backend/fastermake.py index d55928e8c7..0ca385187b 100644 --- a/python/mozbuild/mozbuild/backend/fastermake.py +++ b/python/mozbuild/mozbuild/backend/fastermake.py @@ -79,7 +79,7 @@ class FasterMakeBackend(CommonBackend, PartialBackend): .add_pattern_symlink( prefix, f.full_path[len(prefix):], - mozpath.join(path, f.target_basename)) + path) else: self._install_manifests[obj.install_target].add_symlink( f.full_path, From 704a1bcfab02a514147b6108adfae141ac1410dc Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Sun, 4 Dec 2022 14:54:40 +0800 Subject: [PATCH 07/13] No issue - Replace use of deprecated GetPreventDefault in GTK menu bar --- widget/gtk/nsMenuBar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/gtk/nsMenuBar.cpp b/widget/gtk/nsMenuBar.cpp index e7caf119c6..89416ec8d1 100644 --- a/widget/gtk/nsMenuBar.cpp +++ b/widget/gtk/nsMenuBar.cpp @@ -35,7 +35,7 @@ using namespace mozilla; static bool ShouldHandleKeyEvent(nsIDOMEvent* aEvent) { bool handled, trusted = false; - aEvent->GetPreventDefault(&handled); + aEvent->GetDefaultPrevented(&handled); aEvent->GetIsTrusted(&trusted); if (handled || !trusted) { From ca3361fb57b33d97ce333a4662e2cdd1974837b8 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Sat, 24 Dec 2022 17:41:31 +0800 Subject: [PATCH 08/13] Issue #2068 - Only wrap the last line of inline elements when positively padding to the right. This fixes the 21 year old Mozilla bug 122795. Co-authored-by: Jonathan Kew --- layout/generic/nsInlineFrame.cpp | 5 +++-- layout/generic/nsLineLayout.cpp | 17 +++++++++++++---- layout/generic/nsLineLayout.h | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index fb77422a34..8f24af73c1 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -580,9 +580,10 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, nscoord availableISize = aReflowInput.AvailableISize(); NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE, "should no longer use available widths"); - // Subtract off inline axis border+padding from availableISize + // Subtract off inline axis border+padding from availableISize; + // we don't subtract the end border+padding as we don't yet know whether + // the end of the element will occur on the same line. availableISize -= startEdge; - availableISize -= framePadding.IEnd(frameWM); lineLayout->BeginSpan(this, &aReflowInput, startEdge, startEdge + availableISize, &mBaseline); diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 8cac02d603..579c4ae0b0 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -1101,7 +1101,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, "The frame ctor should've dealt with this."); if (CanPlaceFrame(pfd, notSafeToBreak, continuingTextRun, savedOptionalBreakFrame != nullptr, reflowOutput, - aReflowStatus, &optionalBreakAfterFits)) { + aReflowStatus, &optionalBreakAfterFits, + isText && availableSpaceOnLine < 0)) { if (!isEmpty) { psd->mHasNonemptyContent = true; mLineIsEmpty = false; @@ -1259,6 +1260,10 @@ nsLineLayout::SyncAnnotationBounds(PerFrameData* aRubyFrame) * ReflowFrame above would have returned false, preventing this method * from being called. The logic in this method assumes that. * + * We can always place an empty frame *unless* aAlreadyOverflowed is true, + * in which case the line has already overflowed and we'd rather back up + * to an earlier break (if available). + * * Note that there is no check against the Y coordinate because we * assume that the caller will take care of that. */ @@ -1269,7 +1274,8 @@ nsLineLayout::CanPlaceFrame(PerFrameData* pfd, bool aCanRollBackBeforeFrame, ReflowOutput& aMetrics, nsReflowStatus& aStatus, - bool* aOptionalBreakAfterFits) + bool* aOptionalBreakAfterFits, + bool aAlreadyOverflowed) { NS_PRECONDITION(pfd && pfd->mFrame, "bad args, null pointers for frame data"); @@ -1340,8 +1346,11 @@ nsLineLayout::CanPlaceFrame(PerFrameData* pfd, // When it doesn't fit, check for a few special conditions where we // allow it to fit anyway. - if (0 == startMargin + pfd->mBounds.ISize(lineWM) + endMargin) { - // Empty frames always fit right where they are + if (0 == startMargin + pfd->mBounds.ISize(lineWM) + endMargin && + !aAlreadyOverflowed) { + // Empty frames always fit right where they are, unless we have text that + // has already overflowed the line width, in which case we should try to + // back up to an earlier break. #ifdef NOISY_CAN_PLACE_FRAME printf(" ==> empty frame fits\n"); #endif diff --git a/layout/generic/nsLineLayout.h b/layout/generic/nsLineLayout.h index a612a96668..7f3750fd88 100644 --- a/layout/generic/nsLineLayout.h +++ b/layout/generic/nsLineLayout.h @@ -677,7 +677,8 @@ protected: bool aCanRollBackBeforeFrame, ReflowOutput& aMetrics, nsReflowStatus& aStatus, - bool* aOptionalBreakAfterFits); + bool* aOptionalBreakAfterFits, + bool aAlreadyOverflowed); void PlaceFrame(PerFrameData* pfd, ReflowOutput& aMetrics); From 5c505b86ca1f7265d19f22ce39876dc6bbb94fee Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Sun, 25 Dec 2022 14:50:24 +0800 Subject: [PATCH 09/13] No issue - Fallthrough attributes must be terminated with semicolon. This also fixes building with Clang 15 on Linux. --- js/src/irregexp/RegExpParser.cpp | 2 +- js/src/vm/RegExpObject.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/src/irregexp/RegExpParser.cpp b/js/src/irregexp/RegExpParser.cpp index c609f5940d..ed86fe2464 100644 --- a/js/src/irregexp/RegExpParser.cpp +++ b/js/src/irregexp/RegExpParser.cpp @@ -987,7 +987,7 @@ RegExpParser::ParseClassEscape(char16_t* char_class, widechar *value, } return true; } - MOZ_FALLTHROUGH + MOZ_FALLTHROUGH; default: if (!ParseClassCharacterEscape(value)) return false; diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index e96db29edb..2c6d66381f 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -1558,7 +1558,7 @@ ParseRegExpFlags(const CharT* chars, size_t length, RegExpFlag* flagsOut, char16 return false; break; } - MOZ_FALLTHROUGH + MOZ_FALLTHROUGH; default: return false; } From c95a80207893aa7998ce61ebda5156324da31526 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 25 Dec 2022 11:42:42 +0000 Subject: [PATCH 10/13] Issue #2070 - When multiple HSTS headers are received, only consider the first. This implements a plain interpretations of RFC 6797, which says to only consider the first HSTS header. This slightly conflicts with RFC 7230, which says that sending multiple headers which can't be merged is illegal (except for a specific whitelist which HSTS isn't in), so this situation should never occur in the first place (and would therefore not need the explicit entry in RFC 6797). It improves HSTS robustness dealing with non-compliant servers. Resolves #2070 --- netwerk/protocol/http/nsHttpAtomList.h | 1 + netwerk/protocol/http/nsHttpHeaderArray.cpp | 4 +-- netwerk/protocol/http/nsHttpHeaderArray.h | 19 +++++++++++++- netwerk/test/gtest/TestHeaders.cpp | 29 +++++++++++++++++++++ netwerk/test/gtest/moz.build | 1 + 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 netwerk/test/gtest/TestHeaders.cpp diff --git a/netwerk/protocol/http/nsHttpAtomList.h b/netwerk/protocol/http/nsHttpAtomList.h index e082564548..2ac6ee7cf3 100644 --- a/netwerk/protocol/http/nsHttpAtomList.h +++ b/netwerk/protocol/http/nsHttpAtomList.h @@ -79,6 +79,7 @@ HTTP_ATOM(Service_Worker_Allowed, "Service-Worker-Allowed") HTTP_ATOM(Set_Cookie, "Set-Cookie") HTTP_ATOM(Set_Cookie2, "Set-Cookie2") HTTP_ATOM(Status_URI, "Status-URI") +HTTP_ATOM(Strict_Transport_Security, "Strict-Transport-Security") HTTP_ATOM(TE, "TE") HTTP_ATOM(Title, "Title") HTTP_ATOM(Timeout, "Timeout") diff --git a/netwerk/protocol/http/nsHttpHeaderArray.cpp b/netwerk/protocol/http/nsHttpHeaderArray.cpp index 1030bc91ee..2b779da359 100644 --- a/netwerk/protocol/http/nsHttpHeaderArray.cpp +++ b/netwerk/protocol/http/nsHttpHeaderArray.cpp @@ -79,7 +79,7 @@ nsHttpHeaderArray::SetHeader(nsHttpAtom header, return SetHeader_internal(header, headerName, value, variety); } else if (merge && !IsSingletonHeader(header)) { return MergeHeader(header, entry, value, variety); - } else { + } else if (!IsIgnoreMultipleHeader(header)) { // Replace the existing string with the new value if (entry->variety == eVarietyResponseNetOriginalAndResponse) { MOZ_ASSERT(variety == eVarietyResponse); @@ -190,7 +190,7 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, eVarietyResponseNetOriginal); } return rv; - } else { + } else if (!IsIgnoreMultipleHeader(header)) { // Multiple instances of non-mergeable header received from network // - ignore if same value if (!entry->value.Equals(value)) { diff --git a/netwerk/protocol/http/nsHttpHeaderArray.h b/netwerk/protocol/http/nsHttpHeaderArray.h index cfa7fc6a81..b65b36fcdd 100644 --- a/netwerk/protocol/http/nsHttpHeaderArray.h +++ b/netwerk/protocol/http/nsHttpHeaderArray.h @@ -160,6 +160,8 @@ private: // Header cannot be merged: only one value possible bool IsSingletonHeader(nsHttpAtom header); + // Header cannot be merged, and subsequent values should be ignored + bool IsIgnoreMultipleHeader(nsHttpAtom header); // For some headers we want to track empty values to prevent them being // combined with non-empty ones as a CRLF attack vector bool TrackEmptyHeader(nsHttpAtom header); @@ -231,7 +233,22 @@ nsHttpHeaderArray::IsSingletonHeader(nsHttpAtom header) header == nsHttp::If_Unmodified_Since || header == nsHttp::From || header == nsHttp::Location || - header == nsHttp::Max_Forwards; + header == nsHttp::Max_Forwards || + // Ignore-multiple-headers are singletons in the sense that they + // shouldn't be merged. + IsIgnoreMultipleHeader(header); +} + +// These are headers for which, in the presence of multiple values, we only +// consider the first. +inline bool nsHttpHeaderArray::IsIgnoreMultipleHeader(nsHttpAtom header) +{ + // https://tools.ietf.org/html/rfc6797#section-8: + // + // If a UA receives more than one STS header field in an HTTP + // response message over secure transport, then the UA MUST process + // only the first such header field. + return header == nsHttp::Strict_Transport_Security; } inline bool diff --git a/netwerk/test/gtest/TestHeaders.cpp b/netwerk/test/gtest/TestHeaders.cpp new file mode 100644 index 0000000000..ead56ec9ab --- /dev/null +++ b/netwerk/test/gtest/TestHeaders.cpp @@ -0,0 +1,29 @@ +#include "gtest/gtest.h" + +#include "nsHttpHeaderArray.h" + + +TEST(TestHeaders, DuplicateHSTS) { + // When the Strict-Transport-Security header is sent multiple times, its + // effective value is the value of the first item. It is not coalesced like + // other headers are. + mozilla::net::nsHttpHeaderArray headers; + nsresult rv = headers.SetHeaderFromNet( + mozilla::net::nsHttp::Strict_Transport_Security, NS_LITERAL_CSTRING("max-age=360"), true + ); + ASSERT_EQ(rv, NS_OK); + + nsAutoCString h; + rv = headers.GetHeader(mozilla::net::nsHttp::Strict_Transport_Security, h); + ASSERT_EQ(rv, NS_OK); + ASSERT_EQ(h.get(), "max-age=360"); + + rv = headers.SetHeaderFromNet( + mozilla::net::nsHttp::Strict_Transport_Security, NS_LITERAL_CSTRING("max-age=720"), true + ); + ASSERT_EQ(rv, NS_OK); + + rv = headers.GetHeader(mozilla::net::nsHttp::Strict_Transport_Security, h); + ASSERT_EQ(rv, NS_OK); + ASSERT_EQ(h.get(), "max-age=360"); +} diff --git a/netwerk/test/gtest/moz.build b/netwerk/test/gtest/moz.build index 588c1275d8..7b2782ca8a 100644 --- a/netwerk/test/gtest/moz.build +++ b/netwerk/test/gtest/moz.build @@ -5,6 +5,7 @@ UNIFIED_SOURCES += [ 'TestBase64Stream.cpp', + 'TestHeaders.cpp', 'TestProtocolProxyService.cpp', 'TestStandardURL.cpp', ] From 9958e387d8b28ee65abf0efd79201c5bb9713a00 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 26 Dec 2022 11:21:32 +0000 Subject: [PATCH 11/13] Issue #2053 - Disable DOM Performance API navigation timing. We may eventually want to make this permanent in the front-end of Pale Moon for privacy reasons. Disabling this to avoid usage expecting changed spec results. --- modules/libpref/init/all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 0ef3903c22..8e9a780512 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -187,7 +187,7 @@ pref("dom.enable_resource_timing", true); pref("dom.enable_user_timing", true); // Whether performance.GetEntries* will contain an entry for the active document -pref("dom.enable_performance_navigation_timing", true); +pref("dom.enable_performance_navigation_timing", false); // Enable printing performance marks/measures to log pref("dom.performance.enable_user_timing_logging", false); From ba1887ff4c66bebed7e04495aedbeb3455a970e5 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Thu, 29 Dec 2022 19:29:53 +0800 Subject: [PATCH 12/13] Issue #80 - Fix deprot in dom/base. This regression was introduced by my PR #2015. Found while building dom/base de-unified. --- dom/base/CustomElementRegistry.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 007dfcb4d5..b97115e7c4 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -15,6 +15,7 @@ #include "nsContentUtils.h" #include "nsHTMLTags.h" #include "jsapi.h" +#include "ShadowRoot.h" namespace mozilla { namespace dom { From 507ed86ef5a683b5f19ea3da329438a4721070a9 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Thu, 29 Dec 2022 19:32:55 +0800 Subject: [PATCH 13/13] Issue #80 - Fix deprot in js/src/irregexp. Regression seems to have been introduced by PR #2060? This tree didn't fail building before we've reinstated unified building for js/src. Found while building js/src de-unified. --- js/src/irregexp/InfallibleVector.h | 7 +++++-- js/src/irregexp/RegExpCharRanges.cpp | 31 +++++++++++++++------------- js/src/irregexp/RegExpCharRanges.h | 2 ++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/js/src/irregexp/InfallibleVector.h b/js/src/irregexp/InfallibleVector.h index 1c0e5bca22..bc3770e0ce 100644 --- a/js/src/irregexp/InfallibleVector.h +++ b/js/src/irregexp/InfallibleVector.h @@ -30,6 +30,9 @@ #ifndef V8_INFALLIBLEVECTOR_H_ #define V8_INFALLIBLEVECTOR_H_ +#include "ds/LifoAlloc.h" +#include "mozilla/Vector.h" + namespace js { namespace irregexp { @@ -39,7 +42,7 @@ namespace irregexp { template class InfallibleVector { - Vector> vector_; + mozilla::Vector> vector_; InfallibleVector(const InfallibleVector&) = delete; void operator=(const InfallibleVector&) = delete; @@ -100,4 +103,4 @@ typedef InfallibleVector IntegerVector; } } // namespace js::irregexp -#endif // V8_INFALLIBLEVECTOR_H_ \ No newline at end of file +#endif // V8_INFALLIBLEVECTOR_H_ diff --git a/js/src/irregexp/RegExpCharRanges.cpp b/js/src/irregexp/RegExpCharRanges.cpp index 87a4f94aa1..8266d351d3 100644 --- a/js/src/irregexp/RegExpCharRanges.cpp +++ b/js/src/irregexp/RegExpCharRanges.cpp @@ -29,7 +29,10 @@ #include "irregexp/RegExpCharRanges.h" +#include "ds/LifoAlloc.h" +#include "mozilla/Unused.h" #include "unicode/uniset.h" +#include "vm/Unicode.h" // Generated table #include "irregexp/RegExpCharacters-inl.h" @@ -447,7 +450,7 @@ bool IsExactPropertyValueAlias(const std::string& property_value_name, UProperty return false; } -bool LookupPropertyValueName(LifoAlloc* alloc, +bool LookupPropertyValueName(js::LifoAlloc* alloc, UProperty property, const std::string& property_value_name, bool negate, CharacterRangeVector* ranges, @@ -485,7 +488,7 @@ bool LookupPropertyValueName(LifoAlloc* alloc, return success; } -bool LookupSpecialPropertyValueName(LifoAlloc* alloc, +bool LookupSpecialPropertyValueName(js::LifoAlloc* alloc, const std::string& name, bool negate, CharacterRangeVector* ranges, CharacterRangeVector* lead_ranges, @@ -497,14 +500,14 @@ bool LookupSpecialPropertyValueName(LifoAlloc* alloc, // is the empty set. } else { CharacterRange::AddUnicodeRange(alloc, ranges, lead_ranges, trail_ranges, wide_ranges, - 0, unicode::NonBMPMax); + 0, js::unicode::NonBMPMax); } } else if (name == "ASCII") { if (negate) { // negative ASCII contains all planes CharacterRange::AddUnicodeRange(alloc, ranges, lead_ranges, trail_ranges, wide_ranges, - 0x80, unicode::NonBMPMax); + 0x80, js::unicode::NonBMPMax); } else { // positve ASCII is just low codepoints ranges->append(CharacterRange::Range(0x00, 0x7F)); @@ -748,12 +751,12 @@ CharacterRange::InsertRangeInCanonicalList(CharacterRangeVector& list, } int -irregexp::GetCaseIndependentLetters(char16_t character, - bool ascii_subject, - bool unicode, - const char16_t* choices, - size_t choices_length, - char16_t* letters) +js::irregexp::GetCaseIndependentLetters(char16_t character, + bool ascii_subject, + bool unicode, + const char16_t* choices, + size_t choices_length, + char16_t* letters) { size_t count = 0; for (size_t i = 0; i < choices_length; i++) { @@ -781,10 +784,10 @@ irregexp::GetCaseIndependentLetters(char16_t character, } int -irregexp::GetCaseIndependentLetters(char16_t character, - bool ascii_subject, - bool unicode, - char16_t* letters) +js::irregexp::GetCaseIndependentLetters(char16_t character, + bool ascii_subject, + bool unicode, + char16_t* letters) { if (unicode) { const char16_t choices[] = { diff --git a/js/src/irregexp/RegExpCharRanges.h b/js/src/irregexp/RegExpCharRanges.h index 16a1c00b06..2798ca35ea 100644 --- a/js/src/irregexp/RegExpCharRanges.h +++ b/js/src/irregexp/RegExpCharRanges.h @@ -32,8 +32,10 @@ #include +#include "ds/LifoAlloc.h" #include "irregexp/RegExpCharacters.h" #include "irregexp/InfallibleVector.h" +#include "vm/Unicode.h" namespace js {