Title: [270750] trunk/Source/WebCore
Revision
270750
Author
[email protected]
Date
2020-12-13 09:55:09 -0800 (Sun, 13 Dec 2020)

Log Message

Move createAppHighlightRangeData into AppHighlightStorage source file
https://bugs.webkit.org/show_bug.cgi?id=219834

Reviewed by Devin Rousso.

The createAppHighlightRangeData function was defined statically in AppHighlightListData.cpp
but was only used in AppHighlightStorage.cpp. Moved the static functions from the former
into the later.

Additionally added forward declarations in the AppHighlightStorage header.

This allows the highlight module to compile with non-unified sources.

* Modules/highlight/AppHighlightListData.cpp:
(WebCore::computePathIndex): Deleted.
(WebCore::createNodePathComponent): Deleted.
(WebCore::makeNodePath): Deleted.
(WebCore::createAppHiglightRangeData): Deleted.
* Modules/highlight/AppHighlightStorage.cpp:
(WebCore::computePathIndex):
(WebCore::createNodePathComponent):
(WebCore::makeNodePath):
(WebCore::createAppHighlightRangeData):
(WebCore::AppHighlightStorage::createAppHighlightListData):
* Modules/highlight/AppHighlightStorage.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (270749 => 270750)


--- trunk/Source/WebCore/ChangeLog	2020-12-13 17:29:25 UTC (rev 270749)
+++ trunk/Source/WebCore/ChangeLog	2020-12-13 17:55:09 UTC (rev 270750)
@@ -1,3 +1,31 @@
+2020-12-13  Don Olmstead  <[email protected]>
+
+        Move createAppHighlightRangeData into AppHighlightStorage source file
+        https://bugs.webkit.org/show_bug.cgi?id=219834
+
+        Reviewed by Devin Rousso.
+
+        The createAppHighlightRangeData function was defined statically in AppHighlightListData.cpp
+        but was only used in AppHighlightStorage.cpp. Moved the static functions from the former
+        into the later.
+
+        Additionally added forward declarations in the AppHighlightStorage header.
+
+        This allows the highlight module to compile with non-unified sources.
+
+        * Modules/highlight/AppHighlightListData.cpp:
+        (WebCore::computePathIndex): Deleted.
+        (WebCore::createNodePathComponent): Deleted.
+        (WebCore::makeNodePath): Deleted.
+        (WebCore::createAppHiglightRangeData): Deleted.
+        * Modules/highlight/AppHighlightStorage.cpp:
+        (WebCore::computePathIndex):
+        (WebCore::createNodePathComponent):
+        (WebCore::makeNodePath):
+        (WebCore::createAppHighlightRangeData):
+        (WebCore::AppHighlightStorage::createAppHighlightListData):
+        * Modules/highlight/AppHighlightStorage.h:
+
 2020-12-13  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Offset the content logical left by the word-spacing value

Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightListData.cpp (270749 => 270750)


--- trunk/Source/WebCore/Modules/highlight/AppHighlightListData.cpp	2020-12-13 17:29:25 UTC (rev 270749)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightListData.cpp	2020-12-13 17:55:09 UTC (rev 270750)
@@ -39,48 +39,6 @@
 
 namespace WebCore {
 
-static unsigned computePathIndex(const Node& node)
-{
-    String nodeName = node.nodeName();
-    unsigned index = 0;
-    for (auto* previousSibling = node.previousSibling(); previousSibling; previousSibling = previousSibling->previousSibling()) {
-        if (previousSibling->nodeName() == nodeName)
-            index++;
-    }
-    return index;
-}
-
-static AppHighlightRangeData::NodePathComponent createNodePathComponent(const Node& node)
-{
-    return {
-        is<Element>(node) ? downcast<Element>(node).getIdAttribute().string() : nullString(),
-        node.nodeName(),
-        is<CharacterData>(node) ? downcast<CharacterData>(node).data() : nullString(),
-        computePathIndex(node)
-    };
-}
-
-static AppHighlightRangeData::NodePath makeNodePath(RefPtr<Node>&& node)
-{
-    AppHighlightRangeData::NodePath components;
-    auto body = node->document().body();
-    for (auto ancestor = node; ancestor && ancestor != body; ancestor = ancestor->parentNode())
-        components.append(createNodePathComponent(*ancestor));
-    components.reverse();
-    return { components };
-}
-
-static AppHighlightRangeData createAppHiglightRangeData(const StaticRange& range)
-{
-    return {
-        plainText(range),
-        makeNodePath(&range.startContainer()),
-        range.startOffset(),
-        makeNodePath(&range.endContainer()),
-        range.endOffset()
-    };
-}
-
 AppHighlightListData AppHighlightListData::create(const SharedBuffer& buffer)
 {
     auto decoder = buffer.decoder();

Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp (270749 => 270750)


--- trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp	2020-12-13 17:29:25 UTC (rev 270749)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp	2020-12-13 17:55:09 UTC (rev 270750)
@@ -160,6 +160,48 @@
     return findRangeBySearchingText(range, document);
 }
 
+static unsigned computePathIndex(const Node& node)
+{
+    String nodeName = node.nodeName();
+    unsigned index = 0;
+    for (auto* previousSibling = node.previousSibling(); previousSibling; previousSibling = previousSibling->previousSibling()) {
+        if (previousSibling->nodeName() == nodeName)
+            index++;
+    }
+    return index;
+}
+
+static AppHighlightRangeData::NodePathComponent createNodePathComponent(const Node& node)
+{
+    return {
+        is<Element>(node) ? downcast<Element>(node).getIdAttribute().string() : nullString(),
+        node.nodeName(),
+        is<CharacterData>(node) ? downcast<CharacterData>(node).data() : nullString(),
+        computePathIndex(node)
+    };
+}
+
+static AppHighlightRangeData::NodePath makeNodePath(RefPtr<Node>&& node)
+{
+    AppHighlightRangeData::NodePath components;
+    auto body = node->document().body();
+    for (auto ancestor = node; ancestor && ancestor != body; ancestor = ancestor->parentNode())
+        components.append(createNodePathComponent(*ancestor));
+    components.reverse();
+    return { components };
+}
+
+static AppHighlightRangeData createAppHighlightRangeData(const StaticRange& range)
+{
+    return {
+        plainText(range),
+        makeNodePath(&range.startContainer()),
+        range.startOffset(),
+        makeNodePath(&range.endContainer()),
+        range.endOffset()
+    };
+}
+
 AppHighlightStorage::AppHighlightStorage(Document& document)
     : m_document(makeWeakPtr(document))
 {
@@ -175,7 +217,7 @@
     if (auto appHighlightRegister = m_document->appHighlightRegisterIfExists()) {
         for (auto& highlight : appHighlightRegister->map()) {
             for (auto& rangeData : highlight.value->rangesData())
-                data.append(createAppHiglightRangeData(rangeData->range));
+                data.append(createAppHighlightRangeData(rangeData->range));
         }
     }
 

Modified: trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.h (270749 => 270750)


--- trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.h	2020-12-13 17:29:25 UTC (rev 270749)
+++ trunk/Source/WebCore/Modules/highlight/AppHighlightStorage.h	2020-12-13 17:55:09 UTC (rev 270750)
@@ -35,6 +35,9 @@
 namespace WebCore {
 
 class AppHighlightListData;
+class AppHighlightRangeData;
+class Document;
+class SharedBuffer;
 
 class AppHighlightStorage : RefCounted<AppHighlightStorage> {
     WTF_MAKE_FAST_ALLOCATED;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to