Diff
Modified: trunk/Source/WebCore/ChangeLog (258128 => 258129)
--- trunk/Source/WebCore/ChangeLog 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/ChangeLog 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,3 +1,82 @@
+2020-03-07 Darin Adler <[email protected]>
+
+ Begin moving off of live ranges for WebKit internals
+ https://bugs.webkit.org/show_bug.cgi?id=208432
+
+ Reviewed by Daniel Bates.
+
+ The DOM Range class is a live range. The live updating feature of these ranges mean
+ they are expensive to create and destroy and also make all DOM mutation more expensive
+ while they are alive. We will be able to speed up, likely measurable on Speedometer,
+ if we can cut down uses of live ranges.
+
+ - Refactored the StaticRange class to create two new structs.
+ - The BoundaryPoint struct implements what the DOM standard calls a boundary point:
+ a node and offset. Similar to the RangeBoundaryPoint class, which supports
+ being the boundary point of a live range, but simpler and not live.
+ - The SimpleRange struct implements what the DOM standard calls a range (not a live
+ range). Like StaticRange but without reference counting and DOM binding.
+ - Since StaticRange is derived publicly from SimpleRange you can pass either to any
+ function that takes a SimpleRange. And since there is a constructor to create a
+ SimpleRange from a Range you can pass a Range to those functions too.
+ - Renamed StaticRange::createFromRange to StaticRange::create.
+
+ * Headers.cmake: Added BoundaryPoint.h, SimpleRange.h, and StaticRange.h.
+ * Sources.txt: Added BoundaryPoint.cpp and SimpleRange.cpp.
+ * WebCore.xcodeproj/project.pbxproj: Added BoundaryPoint.cpp/h and SimpleRange.cpp/h.
+
+ * dom/BoundaryPoint.cpp: Added.
+ * dom/BoundaryPoint.h: Added.
+ * dom/SimpleRange.cpp: Added.
+ * dom/SimpleRange.h: Added.
+
+ * dom/StaticRange.cpp:
+ (WebCore::StaticRange::StaticRange): Take an rvalue reference to a SimpleRange.
+ (WebCore::StaticRange::create): Ditto. Changed the other overloads to create
+ a SimpleRange first then call through to the main one.
+ (WebCore::isDocumentTypeOrAttr): Wrote a much more efficient version of this.
+ The old version called the virtual function nodeType twice. This calls it at
+ most once, and mostly doesn't call it at all.
+ * dom/StaticRange.h: Simplified this class, putting most of the actual range
+ logic into the base class. Note that this change eliminated the peculiar code
+ that in the == operator that compared nodes using isEqualNode instead of using
+ node identity. There was no one who needed that other behavior. Also fixed
+ mistaken use of unsigned long in StaticRange::Init. It's unsigned long in
+ the IDL file, but confusingly that's just unsigned in .cpp files.
+
+ * dom/StaticRange.idl: Tweaked formatting.
+
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::targetRanges const): Updated for rename
+ of StaticRange::create.
+ * editing/ReplaceRangeWithTextCommand.cpp:
+ (WebCore::ReplaceRangeWithTextCommand::doApply): Updated since VisibleSelection
+ takes SimpleRange now.
+ (WebCore::ReplaceRangeWithTextCommand::targetRanges const): Updated for
+ rename of StaticRange::create.
+ * editing/SpellingCorrectionCommand.cpp:
+ (WebCore::SpellingCorrectionCommand::SpellingCorrectionCommand): Updated
+ since a selection now takes a SimpleRange&, not a StaticRange.
+ (WebCore::SpellingCorrectionCommand::targetRanges const): Updated for
+ rename of StaticRange::create.
+ * editing/TypingCommand.cpp:
+ (WebCore::TypingCommand::willAddTypingToOpenCommand): Ditto.
+
+ * editing/VisibleSelection.cpp:
+ (WebCore::VisibleSelection::VisibleSelection): Use SimpleRange
+ instead of StaticRange and Range.
+ * editing/VisibleSelection.h: Updated for the above.
+
+ * editing/mac/EditorMac.mm: Added include.
+ * page/DragController.cpp: Ditto.
+ * page/TextIndicator.cpp: Ditto.
+ (WebCore::TextIndicator::createWithRange): Updated since VisibleSelection
+ takes SimpleRange now.
+
+ * page/mac/EventHandlerMac.mm:
+ (WebCore::InlineTextBox::collectMarkedTextsForHighlights): Tweaked coding
+ style a bit.
+
2020-03-08 Per Arne Vollan <[email protected]>
Unreviewed, speculative link fix.
Modified: trunk/Source/WebCore/Headers.cmake (258128 => 258129)
--- trunk/Source/WebCore/Headers.cmake 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/Headers.cmake 2020-03-09 04:00:31 UTC (rev 258129)
@@ -356,6 +356,7 @@
dom/ActiveDOMObject.h
dom/Attr.h
dom/Attribute.h
+ dom/BoundaryPoint.h
dom/CDATASection.h
dom/CallbackResult.h
dom/CharacterData.h
@@ -451,8 +452,10 @@
dom/SecurityPolicyViolationEvent.h
dom/ShadowRoot.h
dom/ShadowRootMode.h
+ dom/SimpleRange.h
dom/SimulatedClickOptions.h
dom/SpaceSplitString.h
+ dom/StaticRange.h
dom/StyledElement.h
dom/SuccessOr.h
dom/TaskSource.h
Modified: trunk/Source/WebCore/Sources.txt (258128 => 258129)
--- trunk/Source/WebCore/Sources.txt 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/Sources.txt 2020-03-09 04:00:31 UTC (rev 258129)
@@ -824,6 +824,7 @@
dom/BeforeLoadEvent.cpp
dom/BeforeTextInsertedEvent.cpp
dom/BeforeUnloadEvent.cpp
+dom/BoundaryPoint.cpp
dom/CDATASection.cpp
dom/CharacterData.cpp
dom/ChildListMutationScope.cpp
@@ -949,6 +950,7 @@
dom/SecurityPolicyViolationEvent.cpp
dom/SelectorQuery.cpp
dom/ShadowRoot.cpp
+dom/SimpleRange.cpp
dom/SimulatedClick.cpp
dom/SlotAssignment.cpp
dom/SpaceSplitString.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (258128 => 258129)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2020-03-09 04:00:31 UTC (rev 258129)
@@ -2605,6 +2605,8 @@
93153BDA14181F7A00FCF5BE /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 93153BD914181F7A00FCF5BE /* [email protected] */; };
93153BDC141959BC00FCF5BE /* textAreaResizeCorner.png in Resources */ = {isa = PBXBuildFile; fileRef = 93153BDB141959BB00FCF5BE /* textAreaResizeCorner.png */; };
93153BE214195A5700FCF5BE /* missingImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 93153BE114195A5700FCF5BE /* missingImage.png */; };
+ 9316DDFB240C64B4009340AA /* SimpleRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 9316DDF8240C64B3009340AA /* SimpleRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 9316DE00240C64F9009340AA /* BoundaryPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 9316DDFE240C64F8009340AA /* BoundaryPoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
931BCC611124DFCB00BE70DD /* MediaCanStartListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 931BCC601124DFCB00BE70DD /* MediaCanStartListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
931CBD0D161A44E900E4C874 /* ScrollingStateNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD07161A44E900E4C874 /* ScrollingStateNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 931CBD09161A44E900E4C874 /* ScrollingStateScrollingNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10643,6 +10645,10 @@
93153BD914181F7A00FCF5BE /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
93153BDB141959BB00FCF5BE /* textAreaResizeCorner.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = textAreaResizeCorner.png; sourceTree = "<group>"; };
93153BE114195A5700FCF5BE /* missingImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = missingImage.png; sourceTree = "<group>"; };
+ 9316DDF8240C64B3009340AA /* SimpleRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleRange.h; sourceTree = "<group>"; };
+ 9316DDFA240C64B3009340AA /* SimpleRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleRange.cpp; sourceTree = "<group>"; };
+ 9316DDFD240C64F8009340AA /* BoundaryPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoundaryPoint.cpp; sourceTree = "<group>"; };
+ 9316DDFE240C64F8009340AA /* BoundaryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundaryPoint.h; sourceTree = "<group>"; };
931AE3B81FB80EAE00F5EFB2 /* JSValueInWrappedObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSValueInWrappedObject.h; sourceTree = "<group>"; };
931BCC601124DFCB00BE70DD /* MediaCanStartListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaCanStartListener.h; sourceTree = "<group>"; };
931CBD06161A44E900E4C874 /* ScrollingStateNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingStateNode.cpp; sourceTree = "<group>"; };
@@ -28051,6 +28057,8 @@
85031B260A44EFC700F992E0 /* BeforeUnloadEvent.cpp */,
85031B270A44EFC700F992E0 /* BeforeUnloadEvent.h */,
7C1E8CFF1ED0C2BE00B1D983 /* BeforeUnloadEvent.idl */,
+ 9316DDFD240C64F8009340AA /* BoundaryPoint.cpp */,
+ 9316DDFE240C64F8009340AA /* BoundaryPoint.h */,
7C1E8D001ED0C2BE00B1D983 /* CallbackResult.h */,
6550B693099DF0270090D781 /* CDATASection.cpp */,
6550B694099DF0270090D781 /* CDATASection.h */,
@@ -28445,6 +28453,8 @@
9B19B67E1B964E5200348745 /* ShadowRoot.idl */,
46DFF4961DC2601300B80B48 /* ShadowRootMode.h */,
46DFF4971DC2601300B80B48 /* ShadowRootMode.idl */,
+ 9316DDFA240C64B3009340AA /* SimpleRange.cpp */,
+ 9316DDF8240C64B3009340AA /* SimpleRange.h */,
572A7F221C6E5A66009C6149 /* SimulatedClick.cpp */,
572A7F201C6E5719009C6149 /* SimulatedClick.h */,
31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */,
@@ -29256,6 +29266,7 @@
BC5EB5E10E81BE8700B25965 /* BorderData.h in Headers */,
589556ED18D4A44000764B03 /* BorderEdge.h in Headers */,
BC5EB5DB0E81B7EA00B25965 /* BorderValue.h in Headers */,
+ 9316DE00240C64F9009340AA /* BoundaryPoint.h in Headers */,
6ED8C37A183BFF8C009E53BD /* BoxShape.h in Headers */,
93309DDB099E64920056E581 /* BreakBlockquoteCommand.h in Headers */,
C2E1F43F1D6254E10094625C /* BreakLines.h in Headers */,
@@ -32429,6 +32440,7 @@
112B34D51E60B98300BB310A /* SimpleLineLayoutPagination.h in Headers */,
E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */,
582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */,
+ 9316DDFB240C64B4009340AA /* SimpleRange.h in Headers */,
C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */,
31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
Copied: trunk/Source/WebCore/dom/BoundaryPoint.cpp (from rev 258128, trunk/Source/WebCore/dom/StaticRange.h) (0 => 258129)
--- trunk/Source/WebCore/dom/BoundaryPoint.cpp (rev 0)
+++ trunk/Source/WebCore/dom/BoundaryPoint.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 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 "BoundaryPoint.h"
+
+#include "Node.h"
+
+namespace WebCore {
+
+BoundaryPoint::BoundaryPoint(const BoundaryPoint& other)
+ : container(other.container.copyRef())
+ , offset(other.offset)
+{
+}
+
+BoundaryPoint& BoundaryPoint::operator=(const BoundaryPoint& other)
+{
+ container = other.container.copyRef();
+ offset = other.offset;
+ return *this;
+}
+
+BoundaryPoint& BoundaryPoint::operator=(BoundaryPoint&&) = default;
+
+Document& BoundaryPoint::document() const
+{
+ return container->document();
+}
+
+}
Copied: trunk/Source/WebCore/dom/BoundaryPoint.h (from rev 258128, trunk/Source/WebCore/dom/StaticRange.h) (0 => 258129)
--- trunk/Source/WebCore/dom/BoundaryPoint.h (rev 0)
+++ trunk/Source/WebCore/dom/BoundaryPoint.h 2020-03-09 04:00:31 UTC (rev 258129)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#include <wtf/Ref.h>
+
+namespace WebCore {
+
+class Document;
+class Node;
+
+struct BoundaryPoint {
+ Ref<Node> container;
+ unsigned offset { 0 };
+
+ BoundaryPoint(Ref<Node>&&, unsigned);
+
+ // Unlike Ref, we allow copying a BoundaryPoint without an explicit copyRef().
+ BoundaryPoint(const BoundaryPoint&);
+ BoundaryPoint(BoundaryPoint&&) = default;
+ BoundaryPoint& operator=(const BoundaryPoint&);
+ BoundaryPoint& operator=(BoundaryPoint&&);
+
+ Document& document() const;
+};
+
+bool operator==(const BoundaryPoint&, const BoundaryPoint&);
+
+inline BoundaryPoint::BoundaryPoint(Ref<Node>&& container, unsigned offset)
+ : container(WTFMove(container))
+ , offset(offset)
+{
+}
+
+inline bool operator==(const BoundaryPoint& a, const BoundaryPoint& b)
+{
+ return a.container.ptr() == b.container.ptr() && a.offset == b.offset;
+}
+
+}
Modified: trunk/Source/WebCore/dom/Document.cpp (258128 => 258129)
--- trunk/Source/WebCore/dom/Document.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/dom/Document.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -2752,7 +2752,7 @@
for (auto& rangeData : highlight.value->rangesData()) {
if (rangeData->startPosition && rangeData->endPosition)
continue;
- if (&rangeData->range->startContainer()->treeScope() != &rangeData->range->endContainer()->treeScope())
+ if (&rangeData->range->startContainer().treeScope() != &rangeData->range->endContainer().treeScope())
continue;
rangesData.append(makeWeakPtr(rangeData.ptr()));
}
Copied: trunk/Source/WebCore/dom/SimpleRange.cpp (from rev 258128, trunk/Source/WebCore/dom/StaticRange.h) (0 => 258129)
--- trunk/Source/WebCore/dom/SimpleRange.cpp (rev 0)
+++ trunk/Source/WebCore/dom/SimpleRange.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2020 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 "SimpleRange.h"
+
+#include "Range.h"
+
+namespace WebCore {
+
+SimpleRange::SimpleRange(const BoundaryPoint& start, const BoundaryPoint& end)
+ : start(start)
+ , end(end)
+{
+}
+
+SimpleRange::SimpleRange(BoundaryPoint&& start, BoundaryPoint&& end)
+ : start(WTFMove(start))
+ , end(WTFMove(end))
+{
+}
+
+SimpleRange::SimpleRange(const Range& other)
+ : start(other.startContainer(), other.startOffset())
+ , end(other.endContainer(), other.endOffset())
+{
+}
+
+bool operator==(const SimpleRange& a, const SimpleRange& b)
+{
+ return a.start == b.start && a.end == b.end;
+}
+
+Ref<Range> createLiveRange(const SimpleRange& range)
+{
+ return Range::create(range.start.document(), range.start.container.ptr(), range.start.offset, range.end.container.ptr(), range.end.offset);
+}
+
+RefPtr<Range> createLiveRange(const Optional<SimpleRange>& range)
+{
+ if (!range)
+ return nullptr;
+ return createLiveRange(*range);
+}
+
+}
Copied: trunk/Source/WebCore/dom/SimpleRange.h (from rev 258128, trunk/Source/WebCore/dom/StaticRange.h) (0 => 258129)
--- trunk/Source/WebCore/dom/SimpleRange.h (rev 0)
+++ trunk/Source/WebCore/dom/SimpleRange.h 2020-03-09 04:00:31 UTC (rev 258129)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#include "BoundaryPoint.h"
+
+namespace WebCore {
+
+class Range;
+
+struct SimpleRange {
+ BoundaryPoint start;
+ BoundaryPoint end;
+
+ Node& startContainer() const { return start.container.get(); }
+ unsigned startOffset() const { return start.offset; }
+ Node& endContainer() const { return end.container.get(); }
+ unsigned endOffset() const { return end.offset; }
+
+ bool collapsed() const { return start == end; }
+
+ SimpleRange(const BoundaryPoint&, const BoundaryPoint&);
+ SimpleRange(BoundaryPoint&&, BoundaryPoint&&);
+
+ WEBCORE_EXPORT SimpleRange(const Range&);
+
+ // Convenience overloads to help with transition from using a lot of live ranges. Consider removing these eventually.
+ SimpleRange(const Range*); // Crashes if passed a nullptr.
+ SimpleRange(const Ref<Range>&);
+};
+
+bool operator==(const SimpleRange&, const SimpleRange&);
+
+WEBCORE_EXPORT Ref<Range> createLiveRange(const SimpleRange&);
+WEBCORE_EXPORT RefPtr<Range> createLiveRange(const Optional<SimpleRange>&);
+
+inline SimpleRange::SimpleRange(const Range* range)
+ : SimpleRange(*range)
+{
+}
+
+inline SimpleRange::SimpleRange(const Ref<Range>& range)
+ : SimpleRange(range.get())
+{
+}
+
+}
Modified: trunk/Source/WebCore/dom/StaticRange.cpp (258128 => 258129)
--- trunk/Source/WebCore/dom/StaticRange.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/dom/StaticRange.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,35 +26,34 @@
#include "config.h"
#include "StaticRange.h"
-#include "DOMException.h"
-#include "Node.h"
#include "Range.h"
namespace WebCore {
-StaticRange::StaticRange(Ref<Node>&& startContainer, unsigned startOffset, Ref<Node>&& endContainer, unsigned endOffset)
- : m_startContainer(WTFMove(startContainer))
- , m_startOffset(startOffset)
- , m_endContainer(WTFMove(endContainer))
- , m_endOffset(endOffset)
+StaticRange::StaticRange(SimpleRange&& range)
+ : SimpleRange(WTFMove(range))
{
}
-StaticRange::~StaticRange() = default;
-
-Ref<StaticRange> StaticRange::create(Ref<Node>&& startContainer, unsigned startOffset, Ref<Node>&& endContainer, unsigned endOffset)
+Ref<StaticRange> StaticRange::create(SimpleRange&& range)
{
- return adoptRef(*new StaticRange(WTFMove(startContainer), startOffset, WTFMove(endContainer), endOffset));
+ return adoptRef(*new StaticRange(WTFMove(range)));
}
-Ref<StaticRange> StaticRange::createFromRange(const Range& range)
+static bool isDocumentTypeOrAttr(Node& node)
{
- return StaticRange::create(range.startContainer(), range.startOffset(), range.endContainer(), range.endOffset());
-}
+ // Before calling nodeType, do two fast non-virtual checks that cover almost all normal nodes, but are false for DocumentType and Attr.
+ if (is<ContainerNode>(node) || is<Text>(node))
+ return false;
-static inline bool isDocumentTypeOrAttr(Node& node)
-{
- return node.isDocumentTypeNode() || node.isAttributeNode();
+ // Call nodeType explicitly and use a switch so we don't have to call it twice.
+ switch (node.nodeType()) {
+ case Node::ATTRIBUTE_NODE:
+ case Node::DOCUMENT_TYPE_NODE:
+ return true;
+ default:
+ return false;
+ }
}
ExceptionOr<Ref<StaticRange>> StaticRange::create(Init&& init)
@@ -63,27 +62,7 @@
ASSERT(init.endContainer);
if (isDocumentTypeOrAttr(*init.startContainer) || isDocumentTypeOrAttr(*init.endContainer))
return Exception { InvalidNodeTypeError };
- return StaticRange::create(init.startContainer.releaseNonNull(), init.startOffset, init.endContainer.releaseNonNull(), init.endOffset);
+ return create({ { init.startContainer.releaseNonNull(), init.startOffset }, { init.endContainer.releaseNonNull(), init.endOffset } });
}
-Node* StaticRange::startContainer() const
-{
- return (Node*)m_startContainer.ptr();
}
-
-Node* StaticRange::endContainer() const
-{
- return (Node*)m_endContainer.ptr();
-}
-
-bool StaticRange::collapsed() const
-{
- return m_startOffset == m_endOffset && m_startContainer.ptr() == m_endContainer.ptr();
-}
-
-bool StaticRange::operator==(const StaticRange& other) const
-{
- return (m_startOffset == other.startOffset() && m_endOffset == other.endOffset() && m_startContainer->isEqualNode(other.startContainer()) && m_endContainer->isEqualNode(other.endContainer()));
-}
-
-}
Modified: trunk/Source/WebCore/dom/StaticRange.h (258128 => 258129)
--- trunk/Source/WebCore/dom/StaticRange.h 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/dom/StaticRange.h 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,45 +26,25 @@
#pragma once
#include "ExceptionOr.h"
-#include <wtf/Ref.h>
+#include "SimpleRange.h"
#include <wtf/RefCounted.h>
namespace WebCore {
-class Node;
-class Range;
-
-class StaticRange : public RefCounted<StaticRange> {
+class StaticRange : public RefCounted<StaticRange>, public SimpleRange {
public:
- ~StaticRange();
-
- static Ref<StaticRange> createFromRange(const Range&);
- static Ref<StaticRange> create(Ref<Node>&& startContainer, unsigned startOffset, Ref<Node>&& endContainer, unsigned endOffset);
-
struct Init {
RefPtr<Node> startContainer;
- unsigned long startOffset { 0 };
+ unsigned startOffset { 0 };
RefPtr<Node> endContainer;
- unsigned long endOffset { 0 };
+ unsigned endOffset { 0 };
};
static ExceptionOr<Ref<StaticRange>> create(Init&&);
+ static Ref<StaticRange> create(SimpleRange&&);
- unsigned startOffset() const { return m_startOffset; }
- unsigned endOffset() const { return m_endOffset; }
- Node* startContainer() const;
- Node* endContainer() const;
- bool collapsed() const;
-
- bool operator==(const StaticRange&) const;
-
private:
- StaticRange(Ref<Node>&& startContainer, unsigned startOffset, Ref<Node>&& endContainer, unsigned endOffset);
-
- Ref<Node> m_startContainer;
- unsigned m_startOffset;
- Ref<Node> m_endContainer;
- unsigned m_endOffset;
+ StaticRange(SimpleRange&&);
};
}
Modified: trunk/Source/WebCore/dom/StaticRange.idl (258128 => 258129)
--- trunk/Source/WebCore/dom/StaticRange.idl 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/dom/StaticRange.idl 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple, Inc. All Rights Reserved.
+ * Copyright (C) 2016 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,8 +38,8 @@
};
dictionary StaticRangeInit {
- required Node startContainer;
- required unsigned long startOffset;
- required Node endContainer;
- required unsigned long endOffset;
+ required Node startContainer;
+ required unsigned long startOffset;
+ required Node endContainer;
+ required unsigned long endOffset;
};
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (258128 => 258129)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -388,7 +388,7 @@
if (!firstRange)
return { };
- return { 1, StaticRange::createFromRange(*firstRange) };
+ return { 1, StaticRange::create(*firstRange) };
}
Vector<RefPtr<StaticRange>> CompositeEditCommand::targetRangesForBindings() const
Modified: trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp (258128 => 258129)
--- trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/ReplaceRangeWithTextCommand.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -55,7 +55,7 @@
void ReplaceRangeWithTextCommand::doApply()
{
- VisibleSelection selection = *m_rangeToBeReplaced;
+ VisibleSelection selection { *m_rangeToBeReplaced };
if (!m_rangeToBeReplaced)
return;
@@ -89,7 +89,7 @@
Vector<RefPtr<StaticRange>> ReplaceRangeWithTextCommand::targetRanges() const
{
- return { 1, StaticRange::createFromRange(*m_rangeToBeReplaced) };
+ return { 1, StaticRange::create(*m_rangeToBeReplaced) };
}
} // namespace WebCore
Modified: trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp (258128 => 258129)
--- trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/SpellingCorrectionCommand.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -86,7 +86,7 @@
SpellingCorrectionCommand::SpellingCorrectionCommand(Range& rangeToBeCorrected, const String& correction)
: CompositeEditCommand(rangeToBeCorrected.startContainer().document(), EditAction::InsertReplacement)
, m_rangeToBeCorrected(rangeToBeCorrected)
- , m_selectionToBeCorrected(m_rangeToBeCorrected)
+ , m_selectionToBeCorrected(m_rangeToBeCorrected.get())
, m_correction(correction)
{
}
@@ -124,7 +124,7 @@
Vector<RefPtr<StaticRange>> SpellingCorrectionCommand::targetRanges() const
{
- return { 1, StaticRange::createFromRange(m_rangeToBeCorrected) };
+ return { 1, StaticRange::create(m_rangeToBeCorrected) };
}
RefPtr<DataTransfer> SpellingCorrectionCommand::inputEventDataTransfer() const
Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (258128 => 258129)
--- trunk/Source/WebCore/editing/TypingCommand.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -499,7 +499,7 @@
if (!range || isEditingTextAreaOrTextInput())
return frame().editor().willApplyEditing(*this, CompositeEditCommand::targetRangesForBindings());
- return frame().editor().willApplyEditing(*this, { 1, StaticRange::createFromRange(*range) });
+ return frame().editor().willApplyEditing(*this, { 1, StaticRange::create(*range) });
}
void TypingCommand::typingAddedToOpenCommand(ETypingCommand commandTypeForAddedTyping)
Modified: trunk/Source/WebCore/editing/VisibleSelection.cpp (258128 => 258129)
--- trunk/Source/WebCore/editing/VisibleSelection.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/VisibleSelection.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -32,7 +32,7 @@
#include "HTMLInputElement.h"
#include "Settings.h"
#include "ShadowRoot.h"
-#include "StaticRange.h"
+#include "SimpleRange.h"
#include "TextIterator.h"
#include "VisibleUnits.h"
#include <stdio.h>
@@ -88,25 +88,16 @@
validate();
}
-VisibleSelection::VisibleSelection(const Range& range, EAffinity affinity, bool isDirectional)
- : m_base(range.startPosition())
- , m_extent(range.endPosition())
+VisibleSelection::VisibleSelection(const SimpleRange& range, EAffinity affinity, bool isDirectional)
+ : m_base(createLegacyEditingPosition(&range.startContainer(), range.startOffset()))
+ , m_extent(createLegacyEditingPosition(&range.endContainer(), range.endOffset()))
, m_affinity(affinity)
, m_isDirectional(isDirectional)
{
+ ASSERT(&range.startContainer().treeScope() == &range.endContainer().treeScope());
validate();
}
-VisibleSelection::VisibleSelection(const StaticRange& staticRange, EAffinity affinity, bool isDirectional)
- : m_base(createLegacyEditingPosition(staticRange.startContainer(), staticRange.startOffset()))
- , m_extent(createLegacyEditingPosition(staticRange.endContainer(), staticRange.endOffset()))
- , m_affinity(affinity)
- , m_isDirectional(isDirectional)
-{
- ASSERT(&staticRange.startContainer()->treeScope() == &staticRange.endContainer()->treeScope());
- validate();
-}
-
VisibleSelection VisibleSelection::selectionFromContentsOfNode(Node* node)
{
ASSERT(!editingIgnoresContent(*node));
Modified: trunk/Source/WebCore/editing/VisibleSelection.h (258128 => 258129)
--- trunk/Source/WebCore/editing/VisibleSelection.h 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/VisibleSelection.h 2020-03-09 04:00:31 UTC (rev 258129)
@@ -31,8 +31,9 @@
namespace WebCore {
class Position;
-class StaticRange;
+struct SimpleRange;
+
const EAffinity SEL_DEFAULT_AFFINITY = DOWNSTREAM;
enum SelectionDirection : uint8_t { DirectionForward, DirectionBackward, DirectionRight, DirectionLeft };
@@ -44,10 +45,7 @@
VisibleSelection(const Position&, EAffinity, bool isDirectional = false);
VisibleSelection(const Position&, const Position&, EAffinity = SEL_DEFAULT_AFFINITY, bool isDirectional = false);
-
- WEBCORE_EXPORT VisibleSelection(const Range&, EAffinity = SEL_DEFAULT_AFFINITY, bool isDirectional = false);
- WEBCORE_EXPORT VisibleSelection(const StaticRange&, EAffinity = SEL_DEFAULT_AFFINITY, bool isDirectional = false);
-
+ WEBCORE_EXPORT VisibleSelection(const SimpleRange&, EAffinity = SEL_DEFAULT_AFFINITY, bool isDirectional = false);
WEBCORE_EXPORT VisibleSelection(const VisiblePosition&, bool isDirectional = false);
WEBCORE_EXPORT VisibleSelection(const VisiblePosition&, const VisiblePosition&, bool isDirectional = false);
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (258128 => 258129)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2020-03-09 04:00:31 UTC (rev 258129)
@@ -50,6 +50,7 @@
#import "RenderImage.h"
#import "RuntimeApplicationChecks.h"
#import "RuntimeEnabledFeatures.h"
+#import "SimpleRange.h"
#import "StyleProperties.h"
#import "WebContentReader.h"
#import "WebNSAttributedStringExtras.h"
@@ -59,8 +60,6 @@
namespace WebCore {
-using namespace HTMLNames;
-
void Editor::showFontPanel()
{
auto* client = this->client();
Modified: trunk/Source/WebCore/page/DragController.cpp (258128 => 258129)
--- trunk/Source/WebCore/page/DragController.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/page/DragController.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -30,6 +30,7 @@
#include "SVGAElement.h"
#if ENABLE(DRAG_SUPPORT)
+
#include "CachedImage.h"
#include "CachedResourceLoader.h"
#include "DataTransfer.h"
@@ -79,6 +80,7 @@
#include "SecurityOrigin.h"
#include "Settings.h"
#include "ShadowRoot.h"
+#include "SimpleRange.h"
#include "StyleProperties.h"
#include "Text.h"
#include "TextEvent.h"
Modified: trunk/Source/WebCore/page/TextIndicator.cpp (258128 => 258129)
--- trunk/Source/WebCore/page/TextIndicator.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/page/TextIndicator.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -43,6 +43,7 @@
#include "RenderElement.h"
#include "RenderObject.h"
#include "RenderText.h"
+#include "SimpleRange.h"
#include "TextIterator.h"
#include "TextPaintStyle.h"
@@ -82,7 +83,7 @@
temporarySelectionOptions.add(TemporarySelectionOption::IgnoreSelectionChanges);
temporarySelectionOptions.add(TemporarySelectionOption::EnableAppearanceUpdates);
#endif
- TemporarySelectionChange selectionChange(*frame, { range }, temporarySelectionOptions);
+ TemporarySelectionChange selectionChange(*frame, { SimpleRange { range } }, temporarySelectionOptions);
TextIndicatorData data;
Modified: trunk/Source/WebCore/page/mac/EventHandlerMac.mm (258128 => 258129)
--- trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/page/mac/EventHandlerMac.mm 2020-03-09 04:00:31 UTC (rev 258129)
@@ -64,6 +64,7 @@
#include "Scrollbar.h"
#include "Settings.h"
#include "ShadowRoot.h"
+#include "SimpleRange.h"
#include "WheelEventDeltaFilter.h"
#include "WheelEventTestMonitor.h"
#include <wtf/BlockObjCExceptions.h>
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (258128 => 258129)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1038,7 +1038,6 @@
return markedTexts;
}
-
Vector<MarkedText> InlineTextBox::collectMarkedTextsForHighlights(TextPaintPhase phase) const
{
if (!RuntimeEnabledFeatures::sharedFeatures().highlightAPIEnabled())
@@ -1059,17 +1058,17 @@
continue;
for (auto& rangeData : highlight.value->rangesData()) {
if (rangeData->startPosition && rangeData->endPosition) {
- Position startPos = rangeData->startPosition.value();
- Position endPos = rangeData->endPosition.value();
- RenderObject* startRenderer = startPos.deprecatedNode()->renderer();
- int startOffset = startPos.deprecatedEditingOffset();
- RenderObject* endRenderer = endPos.deprecatedNode()->renderer();
- int endOffset = endPos.deprecatedEditingOffset();
- ASSERT(startOffset >= 0 && endOffset >= 0);
+ Position startPosition = rangeData->startPosition.value();
+ Position endPosition = rangeData->endPosition.value();
+ auto* startRenderer = startPosition.deprecatedNode()->renderer();
+ unsigned startOffset = startPosition.deprecatedEditingOffset();
+ auto* endRenderer = endPosition.deprecatedNode()->renderer();
+ unsigned endOffset = endPosition.deprecatedEditingOffset();
if (!startRenderer || !endRenderer)
continue;
+
auto highlightData = HighlightData(renderer().view());
- highlightData.setRenderRange({startRenderer, endRenderer, static_cast<unsigned>(startOffset), static_cast<unsigned>(endOffset)});
+ highlightData.setRenderRange({ startRenderer, endRenderer, startOffset, endOffset });
auto [highlightStart, highlightEnd] = highlightStartEnd(highlightData);
if (highlightStart < highlightEnd)
markedTexts.append({ highlightStart, highlightEnd, MarkedText::Highlight, nullptr, highlight.key });
Modified: trunk/Source/WebKit/ChangeLog (258128 => 258129)
--- trunk/Source/WebKit/ChangeLog 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKit/ChangeLog 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,3 +1,18 @@
+2020-03-07 Darin Adler <[email protected]>
+
+ Begin moving off of live ranges for WebKit internals
+ https://bugs.webkit.org/show_bug.cgi?id=208432
+
+ Reviewed by Daniel Bates.
+
+ * Shared/EditingRange.cpp:
+ (WebKit::EditingRange::fromRange): Initialize out arguments.
+
+ * WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp: Added include.
+ * WebProcess/WebPage/FindController.cpp: Ditto.
+ * WebProcess/WebPage/WebPage.cpp: Ditto.
+ * WebProcess/WebPage/mac/WebPageMac.mm: Ditto.
+
2020-03-08 Wenson Hsieh <[email protected]>
CAN_SECURELY_ARCHIVE_FILE_WRAPPER incorrectly excludes watchOS and tvOS
Modified: trunk/Source/WebKit/Shared/EditingRange.cpp (258128 => 258129)
--- trunk/Source/WebKit/Shared/EditingRange.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKit/Shared/EditingRange.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -67,7 +67,7 @@
if (!paragraphRange)
return nullptr;
- WebCore::ContainerNode& rootNode = paragraphRange.get()->startContainer().treeScope().rootNode();
+ auto& rootNode = paragraphRange.get()->startContainer().treeScope().rootNode();
int paragraphStartIndex = WebCore::TextIterator::rangeLength(WebCore::Range::create(rootNode.document(), &rootNode, 0, ¶graphRange->startContainer(), paragraphRange->startOffset()).ptr());
return WebCore::TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex + static_cast<int>(range.location), length);
}
@@ -76,8 +76,8 @@
{
ASSERT(editingRangeIsRelativeTo == EditingRangeIsRelativeTo::EditableRoot);
- size_t location;
- size_t length;
+ size_t location = 0;
+ size_t length = 0;
if (!range || !WebCore::TextIterator::getLocationAndLengthFromRange(frame.selection().rootEditableElementOrDocumentElement(), range, location, length))
return { };
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp (258128 => 258129)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -42,6 +42,7 @@
#include <WebCore/Page.h>
#include <WebCore/Range.h>
#include <WebCore/RenderView.h>
+#include <WebCore/SimpleRange.h>
#include <WebCore/VisibleSelection.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (258128 => 258129)
--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -46,6 +46,7 @@
#include <WebCore/PathUtilities.h>
#include <WebCore/PlatformMouseEvent.h>
#include <WebCore/PluginDocument.h>
+#include <WebCore/SimpleRange.h>
#if PLATFORM(COCOA)
#include <WebCore/TextIndicatorWindow.h>
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (258128 => 258129)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-03-09 04:00:31 UTC (rev 258129)
@@ -226,6 +226,7 @@
#include <WebCore/Settings.h>
#include <WebCore/ShadowRoot.h>
#include <WebCore/SharedBuffer.h>
+#include <WebCore/SimpleRange.h>
#include <WebCore/StyleProperties.h>
#include <WebCore/SubframeLoader.h>
#include <WebCore/SubstituteData.h>
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (258128 => 258129)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2020-03-09 04:00:31 UTC (rev 258129)
@@ -86,6 +86,7 @@
#import <WebCore/RenderView.h>
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/ScrollView.h>
+#import <WebCore/SimpleRange.h>
#import <WebCore/StyleInheritedData.h>
#import <WebCore/TextIterator.h>
#import <WebCore/VisibleUnits.h>
Modified: trunk/Source/WebKitLegacy/ios/ChangeLog (258128 => 258129)
--- trunk/Source/WebKitLegacy/ios/ChangeLog 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKitLegacy/ios/ChangeLog 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,3 +1,12 @@
+2020-03-07 Darin Adler <[email protected]>
+
+ Begin moving off of live ranges for WebKit internals
+ https://bugs.webkit.org/show_bug.cgi?id=208432
+
+ Reviewed by Daniel Bates.
+
+ * WebCoreSupport/WebFrameIOS.mm: Added include.
+
2020-03-03 Devin Rousso <[email protected]>
Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
Modified: trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm (258128 => 258129)
--- trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKitLegacy/ios/WebCoreSupport/WebFrameIOS.mm 2020-03-09 04:00:31 UTC (rev 258129)
@@ -44,6 +44,7 @@
#import <WebCore/RenderText.h>
#import <WebCore/RenderedDocumentMarker.h>
#import <WebCore/SelectionRect.h>
+#import <WebCore/SimpleRange.h>
#import <WebCore/TextBoundaries.h>
#import <WebCore/TextFlags.h>
#import <WebCore/VisiblePosition.h>
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (258128 => 258129)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2020-03-09 04:00:31 UTC (rev 258129)
@@ -1,3 +1,14 @@
+2020-03-07 Darin Adler <[email protected]>
+
+ Begin moving off of live ranges for WebKit internals
+ https://bugs.webkit.org/show_bug.cgi?id=208432
+
+ Reviewed by Daniel Bates.
+
+ * WebCoreSupport/WebContextMenuClient.mm: Added include.
+ * WebView/WebFrame.mm: Ditto.
+ (-[WebFrame _convertToNSRange:]): Initialized out arguments.
+
2020-03-07 Brent Fulgham <[email protected]>
Create a flag to disable in-app browser quirks
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm (258128 => 258129)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.mm 2020-03-09 04:00:31 UTC (rev 258129)
@@ -54,6 +54,7 @@
#import <WebCore/RenderObject.h>
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/SharedBuffer.h>
+#import <WebCore/SimpleRange.h>
#import <WebKitLegacy/DOMPrivate.h>
#import <pal/spi/mac/NSSharingServicePickerSPI.h>
#import <wtf/URL.h>
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (258128 => 258129)
--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm 2020-03-09 03:35:19 UTC (rev 258128)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm 2020-03-09 04:00:31 UTC (rev 258129)
@@ -100,6 +100,7 @@
#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/ScriptController.h>
#import <WebCore/SecurityOrigin.h>
+#import <WebCore/SimpleRange.h>
#import <WebCore/SmartReplace.h>
#import <WebCore/StyleProperties.h>
#import <WebCore/SubframeLoader.h>
@@ -806,8 +807,8 @@
if (!range)
return NSMakeRange(NSNotFound, 0);
- size_t location;
- size_t length;
+ size_t location = 0;
+ size_t length = 0;
if (!WebCore::TextIterator::getLocationAndLengthFromRange(_private->coreFrame->selection().rootEditableElementOrDocumentElement(), range, location, length))
return NSMakeRange(NSNotFound, 0);