Diff
Modified: trunk/LayoutTests/ChangeLog (272113 => 272114)
--- trunk/LayoutTests/ChangeLog 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/LayoutTests/ChangeLog 2021-01-30 08:53:10 UTC (rev 272114)
@@ -1,3 +1,15 @@
+2021-01-30 Ryosuke Niwa <[email protected]>
+
+ StaticRange should keep its start and end containers alive
+ https://bugs.webkit.org/show_bug.cgi?id=221175
+
+ Reviewed by Wenson Hsieh.
+
+ Added a regression test.
+
+ * fast/dom/static-range-gc-expected.txt: Added.
+ * fast/dom/static-range-gc.html: Added.
+
2021-01-29 Zalan Bujtas <[email protected]>
[LFC][RenderTreeAsText] Apply the "adjustForTableCells" quirk to line break runs
Added: trunk/LayoutTests/fast/dom/static-range-gc-expected.txt (0 => 272114)
--- trunk/LayoutTests/fast/dom/static-range-gc-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/static-range-gc-expected.txt 2021-01-30 08:53:10 UTC (rev 272114)
@@ -0,0 +1,49 @@
+This tests keeping nodes alive via StaticRange
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS range.startContainer.getRootNode().localName is "div"
+PASS range.endContainer.getRootNode().localName is "p"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/static-range-gc.html (0 => 272114)
--- trunk/LayoutTests/fast/dom/static-range-gc.html (rev 0)
+++ trunk/LayoutTests/fast/dom/static-range-gc.html 2021-01-30 08:53:10 UTC (rev 272114)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="container" contenteditable></div>
+<script src=""
+<script src=""
+<script>
+
+if (window.testRunner)
+ testRunner.dumpAsText();
+
+description('This tests keeping nodes alive via StaticRange');
+
+function createRange() {
+ container.innerHTML = '<div><em>hello</em></div><p><b><span>world</span></p>';
+ container.focus();
+ getSelection().setBaseAndExtent(container, 0, container, 2);
+ let range;
+ container.addEventListener('beforeinput', (event) => {
+ event.preventDefault();
+ range = event.getTargetRanges()[0];
+ }, {once: true});
+ document.execCommand('delete', false, null);
+ return range;
+}
+
+const ranges = [];
+for (let i = 0; i < 20; ++i) {
+ ranges.push(createRange());
+ gc();
+}
+container.innerHTML = '';
+
+let range;
+for (range of ranges) {
+ shouldBeEqualToString('range.startContainer.getRootNode().localName', 'div');
+ shouldBeEqualToString('range.endContainer.getRootNode().localName', 'p');
+}
+
+successfullyParsed = true;
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (272113 => 272114)
--- trunk/Source/WebCore/ChangeLog 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/Source/WebCore/ChangeLog 2021-01-30 08:53:10 UTC (rev 272114)
@@ -1,3 +1,24 @@
+2021-01-30 Ryosuke Niwa <[email protected]>
+
+ StaticRange should keep its start and end containers alive
+ https://bugs.webkit.org/show_bug.cgi?id=221175
+
+ Reviewed by Wenson Hsieh.
+
+ Fixed the bug that the root nodes of StaticRange's start and end containers were not kept alive by GC.
+ To do that, we add them as opaque roots during the marking phase in visitAdditionalChildren.
+
+ Test: fast/dom/static-range-gc.html
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSStaticRangeCustom.cpp:
+ (WebCore::JSStaticRange::visitAdditionalChildren):
+ * dom/StaticRange.cpp:
+ (WebCore::StaticRange::visitNodesConcurrently const):
+ * dom/StaticRange.h:
+ * dom/StaticRange.idl:
+
2021-01-29 Zalan Bujtas <[email protected]>
[LFC][RenderTreeAsText] Apply the "adjustForTableCells" quirk to line break runs
Modified: trunk/Source/WebCore/Sources.txt (272113 => 272114)
--- trunk/Source/WebCore/Sources.txt 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/Source/WebCore/Sources.txt 2021-01-30 08:53:10 UTC (rev 272114)
@@ -601,6 +601,7 @@
bindings/js/JSSVGViewSpecCustom.cpp
bindings/js/JSServiceWorkerClientCustom.cpp
bindings/js/JSServiceWorkerGlobalScopeCustom.cpp
+bindings/js/JSStaticRangeCustom.cpp
bindings/js/JSStyleSheetCustom.cpp
bindings/js/JSTextCustom.cpp
bindings/js/JSTextTrackCueCustom.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (272113 => 272114)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-01-30 08:53:10 UTC (rev 272114)
@@ -12100,6 +12100,7 @@
9BDD18261F7E05F400E8E577 /* WebCorePasteboardFileReader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCorePasteboardFileReader.cpp; sourceTree = "<group>"; };
9BE671091D5AEB0400345514 /* JSCustomElementRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomElementRegistry.cpp; sourceTree = "<group>"; };
9BE6710A1D5AEB0400345514 /* JSCustomElementRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomElementRegistry.h; sourceTree = "<group>"; };
+ 9BE84EDC25C5112E00665E93 /* JSStaticRangeCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSStaticRangeCustom.cpp; sourceTree = "<group>"; };
9BED2CAF1F7CC06200666018 /* PasteboardCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PasteboardCocoa.mm; sourceTree = "<group>"; };
9BF433761F67619B00E1FD71 /* WebContentReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContentReader.h; sourceTree = "<group>"; };
9BF9A87E1648DD2F001C6B23 /* JSHTMLFormControlsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFormControlsCollection.cpp; sourceTree = "<group>"; };
@@ -21914,8 +21915,8 @@
445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */,
445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */,
1402645D0AFDC19B005919E2 /* LoggingMac.mm */,
+ CD8ACA8D1D23971900ECC59E /* MediaRemoteSoftLink.h */,
CD8ACA8C1D23971900ECC59E /* MediaRemoteSoftLink.mm */,
- CD8ACA8D1D23971900ECC59E /* MediaRemoteSoftLink.h */,
93500F3113FDE3BE0099EC24 /* NSScrollerImpDetails.h */,
52F52E1014A0134F00ACC397 /* NSScrollerImpDetails.mm */,
4B2709810AF2E5E00065127F /* PasteboardMac.mm */,
@@ -22778,6 +22779,7 @@
5884FE5622813E2D0040AFF6 /* JSResizeObserverEntryCustom.cpp */,
83F572941FA1066F003837BE /* JSServiceWorkerClientCustom.cpp */,
460D19441FCE21DD00C3DB85 /* JSServiceWorkerGlobalScopeCustom.cpp */,
+ 9BE84EDC25C5112E00665E93 /* JSStaticRangeCustom.cpp */,
BC98A27C0C0C9950004BEBF7 /* JSStyleSheetCustom.cpp */,
AD726FEC16D9F4B9003A4E6D /* JSStyleSheetCustom.h */,
B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
@@ -27406,9 +27408,9 @@
CBB6B2D21CB7ADD0009EDE1A /* LinkPreloadResourceClients.h */,
51ABF64C16392E2800132A7A /* LoaderStrategy.cpp */,
51E6820F16387302003BBF3C /* LoaderStrategy.h */,
+ E47FC8A125B84D71005495FC /* LoadSchedulingMode.h */,
861C2EA313FB4FDD00062ABB /* LoadTiming.cpp */,
8A12E35C11FA33280025836A /* LoadTiming.h */,
- E47FC8A125B84D71005495FC /* LoadSchedulingMode.h */,
CEEFCD7719DB31F7003876D7 /* MediaResourceLoader.cpp */,
CEEFCD7819DB31F7003876D7 /* MediaResourceLoader.h */,
52F10862162B6D82009AC81E /* MixedContentChecker.cpp */,
@@ -33645,6 +33647,7 @@
9759E94914EF1D490026A2DD /* LoadableTextTrack.h in Headers */,
656D37320ADBA5DE00A4554D /* LoaderNSURLExtras.h in Headers */,
51E6821016387302003BBF3C /* LoaderStrategy.h in Headers */,
+ E47FC8A325B84D72005495FC /* LoadSchedulingMode.h in Headers */,
8A12E35D11FA33280025836A /* LoadTiming.h in Headers */,
06E81ED70AB5D5E900C87837 /* LocalCurrentGraphicsContext.h in Headers */,
1C43DE6B22AB4B8A001527D9 /* LocalCurrentTraitCollection.h in Headers */,
@@ -34342,7 +34345,6 @@
436708D512D9CA4B00044234 /* RenderSVGResourceFilterPrimitive.h in Headers */,
436708D712D9CA4B00044234 /* RenderSVGResourceGradient.h in Headers */,
436708D912D9CA4B00044234 /* RenderSVGResourceLinearGradient.h in Headers */,
- 4114FE3225BEBD19009D9F20 /* RTCRtcpParameters.h in Headers */,
436708DB12D9CA4B00044234 /* RenderSVGResourceMarker.h in Headers */,
436708DD12D9CA4B00044234 /* RenderSVGResourceMasker.h in Headers */,
436708DF12D9CA4B00044234 /* RenderSVGResourcePattern.h in Headers */,
@@ -34456,6 +34458,7 @@
078E094217D16E1C00420AA1 /* RTCPeerConnectionHandlerClient.h in Headers */,
419E6EC92566D278002B5010 /* RTCPeerConnectionIceErrorEvent.h in Headers */,
078E092417D14D1C00420AA1 /* RTCPeerConnectionIceEvent.h in Headers */,
+ 4114FE3225BEBD19009D9F20 /* RTCRtcpParameters.h in Headers */,
412DE4B8219285C00075F3A7 /* RTCRtpCapabilities.h in Headers */,
5E2C43631BCEE32B0001E2BC /* RTCRtpReceiver.h in Headers */,
413C8B352552F27D00E65055 /* RTCRtpReceiverWithTransform.h in Headers */,
@@ -34957,7 +34960,6 @@
71A57DF2154BE25C0009D120 /* SVGPathUtilities.h in Headers */,
B2227A880D00BF220071B782 /* SVGPatternElement.h in Headers */,
7CE58D4A1DD64A5B00128552 /* SVGPoint.h in Headers */,
- E47FC8A325B84D72005495FC /* LoadSchedulingMode.h in Headers */,
B2227A8C0D00BF220071B782 /* SVGPointList.h in Headers */,
B2227A8F0D00BF220071B782 /* SVGPolyElement.h in Headers */,
B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */,
Added: trunk/Source/WebCore/bindings/js/JSStaticRangeCustom.cpp (0 => 272114)
--- trunk/Source/WebCore/bindings/js/JSStaticRangeCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSStaticRangeCustom.cpp 2021-01-30 08:53:10 UTC (rev 272114)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSStaticRange.h"
+
+#include "StaticRange.h"
+
+namespace WebCore {
+
+void JSStaticRange::visitAdditionalChildren(JSC::SlotVisitor& visitor)
+{
+ wrapped().visitNodesConcurrently(visitor);
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/dom/StaticRange.cpp (272113 => 272114)
--- trunk/Source/WebCore/dom/StaticRange.cpp 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/Source/WebCore/dom/StaticRange.cpp 2021-01-30 08:53:10 UTC (rev 272114)
@@ -27,6 +27,7 @@
#include "StaticRange.h"
#include "ContainerNode.h"
+#include "JSNode.h"
#include "Text.h"
#include <wtf/IsoMallocInlines.h>
@@ -75,4 +76,10 @@
return create({ { init.startContainer.releaseNonNull(), init.startOffset }, { init.endContainer.releaseNonNull(), init.endOffset } });
}
+void StaticRange::visitNodesConcurrently(JSC::SlotVisitor& visitor) const
+{
+ visitor.addOpaqueRoot(root(start.container.get()));
+ visitor.addOpaqueRoot(root(end.container.get()));
}
+
+}
Modified: trunk/Source/WebCore/dom/StaticRange.h (272113 => 272114)
--- trunk/Source/WebCore/dom/StaticRange.h 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/Source/WebCore/dom/StaticRange.h 2021-01-30 08:53:10 UTC (rev 272114)
@@ -28,6 +28,12 @@
#include "AbstractRange.h"
#include "SimpleRange.h"
+namespace JSC {
+
+class SlotVisitor;
+
+}
+
namespace WebCore {
template<typename> class ExceptionOr;
@@ -52,6 +58,8 @@
unsigned endOffset() const final { return SimpleRange::endOffset(); }
bool collapsed() const final { return SimpleRange::collapsed(); }
+ void visitNodesConcurrently(JSC::SlotVisitor&) const;
+
private:
StaticRange(SimpleRange&&);
Modified: trunk/Source/WebCore/dom/StaticRange.idl (272113 => 272114)
--- trunk/Source/WebCore/dom/StaticRange.idl 2021-01-30 05:41:40 UTC (rev 272113)
+++ trunk/Source/WebCore/dom/StaticRange.idl 2021-01-30 08:53:10 UTC (rev 272114)
@@ -26,6 +26,7 @@
[
Exposed=Window,
JSGenerateToNativeObject,
+ JSCustomMarkFunction,
] interface StaticRange : AbstractRange {
constructor(StaticRangeInit init);
};