Title: [286402] trunk
Revision
286402
Author
achristen...@apple.com
Date
2021-12-01 16:29:17 -0800 (Wed, 01 Dec 2021)

Log Message

Use Span instead of pointer/length in CompiledContentExtension
https://bugs.webkit.org/show_bug.cgi?id=233727

Reviewed by Tim Hatcher.

Source/WebCore:

No change in behavior.  Just simplifying the interface a bit.

* contentextensions/CompiledContentExtension.h:
* contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::ContentExtension):
(WebCore::ContentExtensions::ContentExtension::findFirstIgnorePreviousRules const):
(WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet):
(WebCore::ContentExtensions::ContentExtension::populateConditionCacheIfNeeded):
* contentextensions/ContentExtensionRule.cpp:
(WebCore::ContentExtensions::DeserializedAction::deserialize):
(WebCore::ContentExtensions::DeserializedAction::serializedLength):
* contentextensions/ContentExtensionRule.h:
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad const):

Source/WebKit:

* Shared/WebCompiledContentRuleList.cpp:
(WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
(WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
(WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
(WebKit::WebCompiledContentRuleList::serializedActions const):
(WebKit::WebCompiledContentRuleList::spanWithOffsetAndLength const):
(WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecodeLength const): Deleted.
(WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecodeLength const): Deleted.
(WebKit::WebCompiledContentRuleList::topURLFiltersBytecodeLength const): Deleted.
(WebKit::WebCompiledContentRuleList::actions const): Deleted.
(WebKit::WebCompiledContentRuleList::actionsLength const): Deleted.
* Shared/WebCompiledContentRuleList.h:

Tools:

* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286401 => 286402)


--- trunk/Source/WebCore/ChangeLog	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebCore/ChangeLog	2021-12-02 00:29:17 UTC (rev 286402)
@@ -1,3 +1,25 @@
+2021-12-01  Alex Christensen  <achristen...@webkit.org>
+
+        Use Span instead of pointer/length in CompiledContentExtension
+        https://bugs.webkit.org/show_bug.cgi?id=233727
+
+        Reviewed by Tim Hatcher.
+
+        No change in behavior.  Just simplifying the interface a bit.
+
+        * contentextensions/CompiledContentExtension.h:
+        * contentextensions/ContentExtension.cpp:
+        (WebCore::ContentExtensions::ContentExtension::ContentExtension):
+        (WebCore::ContentExtensions::ContentExtension::findFirstIgnorePreviousRules const):
+        (WebCore::ContentExtensions::ContentExtension::compileGlobalDisplayNoneStyleSheet):
+        (WebCore::ContentExtensions::ContentExtension::populateConditionCacheIfNeeded):
+        * contentextensions/ContentExtensionRule.cpp:
+        (WebCore::ContentExtensions::DeserializedAction::deserialize):
+        (WebCore::ContentExtensions::DeserializedAction::serializedLength):
+        * contentextensions/ContentExtensionRule.h:
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::actionsForResourceLoad const):
+
 2021-12-01  Nikolas Zimmermann  <nzimmerm...@igalia.com>
 
         [LBSE] Rename RenderSVGRoot -> LegacyRenderSVGRoot

Modified: trunk/Source/WebCore/contentextensions/CompiledContentExtension.h (286401 => 286402)


--- trunk/Source/WebCore/contentextensions/CompiledContentExtension.h	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebCore/contentextensions/CompiledContentExtension.h	2021-12-02 00:29:17 UTC (rev 286402)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-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
@@ -29,27 +29,22 @@
 
 #include "ContentExtensionRule.h"
 #include "DFABytecode.h"
+#include <wtf/Span.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
-namespace WebCore {
-namespace ContentExtensions {
+namespace WebCore::ContentExtensions {
 
 class WEBCORE_EXPORT CompiledContentExtension : public ThreadSafeRefCounted<CompiledContentExtension> {
 public:
     virtual ~CompiledContentExtension();
 
-    virtual const DFABytecode* filtersWithoutConditionsBytecode() const = 0;
-    virtual unsigned filtersWithoutConditionsBytecodeLength() const = 0;
-    virtual const DFABytecode* filtersWithConditionsBytecode() const = 0;
-    virtual unsigned filtersWithConditionsBytecodeLength() const = 0;
-    virtual const DFABytecode* topURLFiltersBytecode() const = 0;
-    virtual unsigned topURLFiltersBytecodeLength() const = 0;
-    virtual const SerializedActionByte* actions() const = 0;
-    virtual unsigned actionsLength() const = 0;
+    virtual Span<const uint8_t> filtersWithoutConditionsBytecode() const = 0;
+    virtual Span<const uint8_t> filtersWithConditionsBytecode() const = 0;
+    virtual Span<const uint8_t> topURLFiltersBytecode() const = 0;
+    virtual Span<const uint8_t> serializedActions() const = 0;
     virtual bool conditionsApplyOnlyToDomain() const = 0;
 };
 
-} // namespace ContentExtensions
-} // namespace WebCore
+} // namespace WebCore::ContentExtensions
 
 #endif // ENABLE(CONTENT_EXTENSIONS)

Modified: trunk/Source/WebCore/contentextensions/ContentExtension.cpp (286401 => 286402)


--- trunk/Source/WebCore/contentextensions/ContentExtension.cpp	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.cpp	2021-12-02 00:29:17 UTC (rev 286402)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-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
@@ -33,8 +33,7 @@
 
 #if ENABLE(CONTENT_EXTENSIONS)
 
-namespace WebCore {
-namespace ContentExtensions {
+namespace WebCore::ContentExtensions {
 
 Ref<ContentExtension> ContentExtension::create(const String& identifier, Ref<CompiledContentExtension>&& compiledExtension, URL&& extensionBaseURL, ShouldCompileCSS shouldCompileCSS)
 {
@@ -46,8 +45,8 @@
     , m_compiledExtension(WTFMove(compiledExtension))
     , m_extensionBaseURL(WTFMove(extensionBaseURL))
 {
-    DFABytecodeInterpreter withoutConditions({ m_compiledExtension->filtersWithoutConditionsBytecode(), m_compiledExtension->filtersWithoutConditionsBytecodeLength() });
-    DFABytecodeInterpreter withConditions({ m_compiledExtension->filtersWithConditionsBytecode(), m_compiledExtension->filtersWithConditionsBytecodeLength() });
+    DFABytecodeInterpreter withoutConditions(m_compiledExtension->filtersWithoutConditionsBytecode());
+    DFABytecodeInterpreter withConditions(m_compiledExtension->filtersWithConditionsBytecode());
     for (uint64_t action : withoutConditions.actionsMatchingEverything()) {
         ASSERT(static_cast<uint32_t>(action) == action);
         m_universalActionsWithoutConditions.append(static_cast<uint32_t>(action));
@@ -65,14 +64,12 @@
 
 uint32_t ContentExtension::findFirstIgnorePreviousRules() const
 {
-    auto* actions = m_compiledExtension->actions();
-    uint32_t actionsLength = m_compiledExtension->actionsLength();
+    auto serializedActions = m_compiledExtension->serializedActions();
     uint32_t currentActionIndex = 0;
-    while (currentActionIndex < actionsLength) {
-        RELEASE_ASSERT(currentActionIndex < actionsLength);
-        if (actions[currentActionIndex] == WTF::alternativeIndexV<IgnorePreviousRulesAction, ActionData>)
+    while (currentActionIndex < serializedActions.size()) {
+        if (serializedActions[currentActionIndex] == WTF::alternativeIndexV<IgnorePreviousRulesAction, ActionData>)
             return currentActionIndex;
-        currentActionIndex += DeserializedAction::serializedLength(actions, actionsLength, currentActionIndex);
+        currentActionIndex += DeserializedAction::serializedLength(serializedActions, currentActionIndex);
     }
     return std::numeric_limits<uint32_t>::max();
 }
@@ -86,12 +83,11 @@
 {
     uint32_t firstIgnorePreviousRules = findFirstIgnorePreviousRules();
     
-    auto* actions = m_compiledExtension->actions();
-    uint32_t actionsLength = m_compiledExtension->actionsLength();
+    auto serializedActions = m_compiledExtension->serializedActions();
 
     auto inGlobalDisplayNoneStyleSheet = [&](const uint32_t location) {
-        RELEASE_ASSERT(location < actionsLength);
-        return location < firstIgnorePreviousRules && actions[location] == WTF::alternativeIndexV<CSSDisplayNoneSelectorAction, ActionData>;
+        RELEASE_ASSERT(location < serializedActions.size());
+        return location < firstIgnorePreviousRules && serializedActions[location] == WTF::alternativeIndexV<CSSDisplayNoneSelectorAction, ActionData>;
     };
     
     StringBuilder css;
@@ -99,7 +95,7 @@
         if (inGlobalDisplayNoneStyleSheet(universalActionLocation)) {
             if (!css.isEmpty())
                 css.append(',');
-            auto action = "" actionsLength, universalActionLocation);
+            auto action = "" universalActionLocation);
             ASSERT(std::holds_alternative<CSSDisplayNoneSelectorAction>(action.data()));
             if (auto* actionData = std::get_if<CSSDisplayNoneSelectorAction>(&action.data()))
                 css.append(actionData->string);
@@ -123,7 +119,7 @@
 void ContentExtension::populateConditionCacheIfNeeded(const URL& topURL)
 {
     if (m_cachedTopURL != topURL) {
-        DFABytecodeInterpreter interpreter({ m_compiledExtension->topURLFiltersBytecode(), m_compiledExtension->topURLFiltersBytecodeLength() });
+        DFABytecodeInterpreter interpreter(m_compiledExtension->topURLFiltersBytecode());
         constexpr ResourceFlags allLoadTypesAndResourceTypes = LoadTypeMask | ResourceTypeMask | LoadContextMask;
         String string = m_compiledExtension->conditionsApplyOnlyToDomain() ? topURL.host().toString() : topURL.string();
         auto topURLActions = interpreter.interpret(string.utf8(), allLoadTypesAndResourceTypes);
@@ -156,8 +152,7 @@
     populateConditionCacheIfNeeded(topURL);
     return m_cachedUniversalConditionedActions;
 }
-    
-} // namespace ContentExtensions
-} // namespace WebCore
 
+} // namespace WebCore::ContentExtensions
+
 #endif // ENABLE(CONTENT_EXTENSIONS)

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp (286401 => 286402)


--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp	2021-12-02 00:29:17 UTC (rev 286402)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-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
@@ -30,10 +30,8 @@
 
 #if ENABLE(CONTENT_EXTENSIONS)
 
-namespace WebCore {
+namespace WebCore::ContentExtensions {
 
-namespace ContentExtensions {
-
 ContentExtensionRule::ContentExtensionRule(Trigger&& trigger, Action&& action)
     : m_trigger(WTFMove(trigger))
     , m_action(WTFMove(action))
@@ -85,16 +83,16 @@
     }
 };
 
-DeserializedAction DeserializedAction::deserialize(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location)
+DeserializedAction DeserializedAction::deserialize(Span<const uint8_t> serializedActions, uint32_t location)
 {
-    RELEASE_ASSERT(location < actionsLength);
-    return { location, VariantDeserializer<ActionData>::deserialize({ actions + location + 1, actionsLength - location - 1 }, actions[location]) };
+    RELEASE_ASSERT(location < serializedActions.size());
+    return { location, VariantDeserializer<ActionData>::deserialize(serializedActions.subspan(location + 1), serializedActions[location]) };
 }
 
-size_t DeserializedAction::serializedLength(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location)
+size_t DeserializedAction::serializedLength(Span<const uint8_t> serializedActions, uint32_t location)
 {
-    RELEASE_ASSERT(location < actionsLength);
-    return 1 + VariantDeserializer<ActionData>::serializedLength({ actions + location + 1, actionsLength - location - 1 }, actions[location]);
+    RELEASE_ASSERT(location < serializedActions.size());
+    return 1 + VariantDeserializer<ActionData>::serializedLength(serializedActions.subspan(location + 1), serializedActions[location]);
 }
 
 Trigger Trigger::isolatedCopy() const
@@ -114,8 +112,6 @@
     return { crossThreadCopy(m_data) };
 }
 
-} // namespace ContentExtensions
+} // namespace WebCore::ContentExtensions
 
-} // namespace WebCore
-
 #endif // ENABLE(CONTENT_EXTENSIONS)

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionRule.h (286401 => 286402)


--- trunk/Source/WebCore/contentextensions/ContentExtensionRule.h	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionRule.h	2021-12-02 00:29:17 UTC (rev 286402)
@@ -138,8 +138,8 @@
 };
 
 struct DeserializedAction : public Action {
-    static DeserializedAction deserialize(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location);
-    static size_t serializedLength(const SerializedActionByte* actions, const uint32_t actionsLength, uint32_t location);
+    static DeserializedAction deserialize(Span<const uint8_t>, uint32_t location);
+    static size_t serializedLength(Span<const uint8_t>, uint32_t location);
 
     uint32_t actionID() const { return m_actionID; }
 

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (286401 => 286402)


--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp	2021-12-02 00:29:17 UTC (rev 286402)
@@ -121,15 +121,14 @@
 
         const CompiledContentExtension& compiledExtension = contentExtension->compiledExtension();
         
-        DFABytecodeInterpreter withoutConditionsInterpreter({ compiledExtension.filtersWithoutConditionsBytecode(), compiledExtension.filtersWithoutConditionsBytecodeLength() });
+        DFABytecodeInterpreter withoutConditionsInterpreter(compiledExtension.filtersWithoutConditionsBytecode());
         DFABytecodeInterpreter::Actions withoutConditionsActions = withoutConditionsInterpreter.interpret(urlCString, flags);
         
         URL topURL = resourceLoadInfo.mainDocumentURL;
-        DFABytecodeInterpreter withConditionsInterpreter({ compiledExtension.filtersWithConditionsBytecode(), compiledExtension.filtersWithConditionsBytecodeLength() });
+        DFABytecodeInterpreter withConditionsInterpreter(compiledExtension.filtersWithConditionsBytecode());
         DFABytecodeInterpreter::Actions withConditionsActions = withConditionsInterpreter.interpretWithConditions(urlCString, flags, contentExtension->topURLActions(topURL));
         
-        const SerializedActionByte* actions = compiledExtension.actions();
-        const unsigned actionsLength = compiledExtension.actionsLength();
+        auto serializedActions = compiledExtension.serializedActions();
         
         const Vector<uint32_t>& universalWithConditions = contentExtension->universalActionsWithConditions(topURL);
         const Vector<uint32_t>& universalWithoutConditions = contentExtension->universalActionsWithoutConditions();
@@ -148,7 +147,7 @@
 
             // Add actions in reverse order to properly deal with IgnorePreviousRules.
             for (unsigned i = actionLocations.size(); i; i--) {
-                auto action = "" actionsLength, actionLocations[i - 1]);
+                auto action = "" actionLocations[i - 1]);
                 if (std::holds_alternative<IgnorePreviousRulesAction>(action.data())) {
                     actionsStruct.sawIgnorePreviousRules = true;
                     break;

Modified: trunk/Source/WebKit/ChangeLog (286401 => 286402)


--- trunk/Source/WebKit/ChangeLog	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebKit/ChangeLog	2021-12-02 00:29:17 UTC (rev 286402)
@@ -1,3 +1,23 @@
+2021-12-01  Alex Christensen  <achristen...@webkit.org>
+
+        Use Span instead of pointer/length in CompiledContentExtension
+        https://bugs.webkit.org/show_bug.cgi?id=233727
+
+        Reviewed by Tim Hatcher.
+
+        * Shared/WebCompiledContentRuleList.cpp:
+        (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecode const):
+        (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecode const):
+        (WebKit::WebCompiledContentRuleList::topURLFiltersBytecode const):
+        (WebKit::WebCompiledContentRuleList::serializedActions const):
+        (WebKit::WebCompiledContentRuleList::spanWithOffsetAndLength const):
+        (WebKit::WebCompiledContentRuleList::filtersWithoutConditionsBytecodeLength const): Deleted.
+        (WebKit::WebCompiledContentRuleList::filtersWithConditionsBytecodeLength const): Deleted.
+        (WebKit::WebCompiledContentRuleList::topURLFiltersBytecodeLength const): Deleted.
+        (WebKit::WebCompiledContentRuleList::actions const): Deleted.
+        (WebKit::WebCompiledContentRuleList::actionsLength const): Deleted.
+        * Shared/WebCompiledContentRuleList.h:
+
 2021-12-01  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r286037.

Modified: trunk/Source/WebKit/Shared/WebCompiledContentRuleList.cpp (286401 => 286402)


--- trunk/Source/WebKit/Shared/WebCompiledContentRuleList.cpp	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebKit/Shared/WebCompiledContentRuleList.cpp	2021-12-02 00:29:17 UTC (rev 286402)
@@ -49,46 +49,32 @@
     return *reinterpret_cast<const uint32_t*>(static_cast<const uint8_t*>(m_data.data->data()) + m_data.conditionsApplyOnlyToDomainOffset);
 }
 
-const WebCore::ContentExtensions::DFABytecode* WebCompiledContentRuleList::filtersWithoutConditionsBytecode() const
+Span<const uint8_t> WebCompiledContentRuleList::filtersWithoutConditionsBytecode() const
 {
-    return static_cast<const WebCore::ContentExtensions::DFABytecode*>(m_data.data->data()) + m_data.filtersWithoutConditionsBytecodeOffset;
+    return spanWithOffsetAndLength(m_data.filtersWithoutConditionsBytecodeOffset, m_data.filtersWithoutConditionsBytecodeSize);
 }
 
-unsigned WebCompiledContentRuleList::filtersWithoutConditionsBytecodeLength() const
+Span<const uint8_t> WebCompiledContentRuleList::filtersWithConditionsBytecode() const
 {
-    return m_data.filtersWithoutConditionsBytecodeSize;
+    return spanWithOffsetAndLength(m_data.filtersWithConditionsBytecodeOffset, m_data.filtersWithConditionsBytecodeSize);
 }
 
-const WebCore::ContentExtensions::DFABytecode* WebCompiledContentRuleList::filtersWithConditionsBytecode() const
+Span<const uint8_t> WebCompiledContentRuleList::topURLFiltersBytecode() const
 {
-    return static_cast<const WebCore::ContentExtensions::DFABytecode*>(m_data.data->data()) + m_data.filtersWithConditionsBytecodeOffset;
+    return spanWithOffsetAndLength(m_data.topURLFiltersBytecodeOffset, m_data.topURLFiltersBytecodeSize);
 }
 
-unsigned WebCompiledContentRuleList::filtersWithConditionsBytecodeLength() const
+Span<const uint8_t> WebCompiledContentRuleList::serializedActions() const
 {
-    return m_data.filtersWithConditionsBytecodeSize;
+    return spanWithOffsetAndLength(m_data.actionsOffset, m_data.actionsSize);
 }
 
-const WebCore::ContentExtensions::DFABytecode* WebCompiledContentRuleList::topURLFiltersBytecode() const
+Span<const uint8_t> WebCompiledContentRuleList::spanWithOffsetAndLength(size_t offset, size_t length) const
 {
-    return static_cast<const WebCore::ContentExtensions::DFABytecode*>(m_data.data->data()) + m_data.topURLFiltersBytecodeOffset;
+    RELEASE_ASSERT(offset + length <= m_data.data->size());
+    return { static_cast<const uint8_t*>(m_data.data->data()) + offset, length };
 }
 
-unsigned WebCompiledContentRuleList::topURLFiltersBytecodeLength() const
-{
-    return m_data.topURLFiltersBytecodeSize;
-}
-
-const WebCore::ContentExtensions::SerializedActionByte* WebCompiledContentRuleList::actions() const
-{
-    return static_cast<const WebCore::ContentExtensions::SerializedActionByte*>(m_data.data->data()) + m_data.actionsOffset;
-}
-
-unsigned WebCompiledContentRuleList::actionsLength() const
-{
-    return m_data.actionsSize;
-}
-
 } // namespace WebKit
 
 #endif // ENABLE(CONTENT_EXTENSIONS)

Modified: trunk/Source/WebKit/Shared/WebCompiledContentRuleList.h (286401 => 286402)


--- trunk/Source/WebKit/Shared/WebCompiledContentRuleList.h	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Source/WebKit/Shared/WebCompiledContentRuleList.h	2021-12-02 00:29:17 UTC (rev 286402)
@@ -43,17 +43,14 @@
 private:
     WebCompiledContentRuleList(WebCompiledContentRuleListData&&);
 
-    const WebCore::ContentExtensions::DFABytecode* filtersWithoutConditionsBytecode() const final;
-    unsigned filtersWithoutConditionsBytecodeLength() const final;
-    const WebCore::ContentExtensions::DFABytecode* filtersWithConditionsBytecode() const final;
-    unsigned filtersWithConditionsBytecodeLength() const final;
-    const WebCore::ContentExtensions::DFABytecode* topURLFiltersBytecode() const final;
-    unsigned topURLFiltersBytecodeLength() const final;
+    Span<const uint8_t> filtersWithoutConditionsBytecode() const final;
+    Span<const uint8_t> filtersWithConditionsBytecode() const final;
+    Span<const uint8_t> topURLFiltersBytecode() const final;
+    Span<const uint8_t> serializedActions() const final;
     bool conditionsApplyOnlyToDomain() const final;
     
-    const WebCore::ContentExtensions::SerializedActionByte* actions() const final;
-    unsigned actionsLength() const final;
-    
+    Span<const uint8_t> spanWithOffsetAndLength(size_t, size_t) const;
+
     WebCompiledContentRuleListData m_data;
 };
 

Modified: trunk/Tools/ChangeLog (286401 => 286402)


--- trunk/Tools/ChangeLog	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Tools/ChangeLog	2021-12-02 00:29:17 UTC (rev 286402)
@@ -1,3 +1,12 @@
+2021-12-01  Alex Christensen  <achristen...@webkit.org>
+
+        Use Span instead of pointer/length in CompiledContentExtension
+        https://bugs.webkit.org/show_bug.cgi?id=233727
+
+        Reviewed by Tim Hatcher.
+
+        * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
+
 2021-12-01  Chris Dumez  <cdu...@apple.com>
 
         Unreviewed API test build fix.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (286401 => 286402)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp	2021-12-02 00:18:23 UTC (rev 286401)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp	2021-12-02 00:29:17 UTC (rev 286402)
@@ -143,14 +143,10 @@
     const CompiledContentExtensionData& data() { return m_data; };
 
 private:
-    const ContentExtensions::SerializedActionByte* actions() const final { return m_data.actions.data(); }
-    unsigned actionsLength() const final { return m_data.actions.size(); }
-    const ContentExtensions::DFABytecode* filtersWithoutConditionsBytecode() const final { return m_data.filtersWithoutConditions.data(); }
-    unsigned filtersWithoutConditionsBytecodeLength() const final { return m_data.filtersWithoutConditions.size(); }
-    const ContentExtensions::DFABytecode* filtersWithConditionsBytecode() const final { return m_data.filtersWithConditions.data(); }
-    unsigned filtersWithConditionsBytecodeLength() const final { return m_data.filtersWithConditions.size(); }
-    const ContentExtensions::DFABytecode* topURLFiltersBytecode() const final { return m_data.topURLFilters.data(); }
-    unsigned topURLFiltersBytecodeLength() const final { return m_data.topURLFilters.size(); }
+    Span<const uint8_t> serializedActions() const final { return { m_data.actions.data(), m_data.actions.size() }; }
+    Span<const uint8_t> filtersWithoutConditionsBytecode() const final { return { m_data.filtersWithoutConditions.data(), m_data.filtersWithoutConditions.size() }; }
+    Span<const uint8_t> filtersWithConditionsBytecode() const final { return { m_data.filtersWithConditions.data(), m_data.filtersWithConditions.size() }; }
+    Span<const uint8_t> topURLFiltersBytecode() const final { return { m_data.topURLFilters.data(), m_data.topURLFilters.size() }; }
     bool conditionsApplyOnlyToDomain() const final { return m_data.conditionsApplyOnlyToDomain; }
 
     InMemoryCompiledContentExtension(CompiledContentExtensionData&& data)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to