Changeset 271207 in webkit
- Timestamp:
- Jan 6, 2021, 11:35:15 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
- 1 copied
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APIContentRuleList.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/APIContentRuleList.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKContentRuleList.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListInternal.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListPrivate.h (copied) (copied from trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListInternal.h ) (2 diffs)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r271206 r271207 1 2021-01-06 Alex Christensen <achristensen@webkit.org> 2 3 Add SPI to determine whether a regex is supported in WKContentRuleList 4 https://bugs.webkit.org/show_bug.cgi?id=220095 5 <rdar://problem/72058626> 6 7 Reviewed by Tim Horton. 8 9 This is a more efficient way than making a little rule list and seeing if it compiles. 10 Here, we don't need access to the disk, and we don't need to hop to another thread and back. 11 Covered by API tests. 12 13 * UIProcess/API/APIContentRuleList.cpp: 14 (API::ContentRuleList::supportsRegularExpression): 15 * UIProcess/API/APIContentRuleList.h: 16 * UIProcess/API/Cocoa/WKContentRuleList.mm: 17 (+[WKContentRuleList _supportsRegularExpression:]): 18 * UIProcess/API/Cocoa/WKContentRuleListInternal.h: 19 * UIProcess/API/Cocoa/WKContentRuleListPrivate.h: Copied from Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListInternal.h. 20 * WebKit.xcodeproj/project.pbxproj: 21 1 22 2021-01-06 Alex Christensen <achristensen@webkit.org> 2 23 -
trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp
r244597 r271207 30 30 31 31 #include "WebCompiledContentRuleList.h" 32 #include <WebCore/CombinedURLFilters.h> 33 #include <WebCore/URLFilterParser.h> 32 34 33 35 namespace API { … … 44 46 } 45 47 48 bool ContentRuleList::supportsRegularExpression(const WTF::String& regex) 49 { 50 using namespace WebCore::ContentExtensions; 51 CombinedURLFilters combinedURLFilters; 52 URLFilterParser urlFilterParser(combinedURLFilters); 53 54 switch (urlFilterParser.addPattern(regex, false, 0)) { 55 case URLFilterParser::Ok: 56 case URLFilterParser::MatchesEverything: 57 return true; 58 case URLFilterParser::NonASCII: 59 case URLFilterParser::UnsupportedCharacterClass: 60 case URLFilterParser::BackReference: 61 case URLFilterParser::ForwardReference: 62 case URLFilterParser::MisplacedStartOfLine: 63 case URLFilterParser::WordBoundary: 64 case URLFilterParser::AtomCharacter: 65 case URLFilterParser::Group: 66 case URLFilterParser::Disjunction: 67 case URLFilterParser::MisplacedEndOfLine: 68 case URLFilterParser::EmptyPattern: 69 case URLFilterParser::YarrError: 70 case URLFilterParser::InvalidQuantifier: 71 break; 72 } 73 return false; 74 } 75 46 76 } // namespace API 47 77 -
trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h
r244597 r271207 49 49 const WTF::String& name() const { return m_name; } 50 50 const WebKit::WebCompiledContentRuleList& compiledRuleList() const { return m_compiledRuleList.get(); } 51 52 static bool supportsRegularExpression(const WTF::String&); 51 53 52 54 private: -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleList.mm
r260366 r271207 51 51 52 52 @end 53 54 @implementation WKContentRuleList (WKPrivate) 55 56 + (BOOL)_supportsRegularExpression:(NSString *)regex 57 { 58 return API::ContentRuleList::supportsRegularExpression(regex); 59 } 60 61 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListInternal.h
r242339 r271207 24 24 */ 25 25 26 #import "WKContentRuleList .h"26 #import "WKContentRuleListPrivate.h" 27 27 28 28 #import "APIContentRuleList.h" -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListPrivate.h
r271206 r271207 1 1 /* 2 * Copyright (C) 20 17-2018Apple Inc. All rights reserved.2 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #import "WKContentRuleList.h"26 #import <WebKit/WKContentRuleList.h> 27 27 28 #import "APIContentRuleList.h" 29 #import "WKObject.h" 28 @interface WKContentRuleList (WKPrivate) 30 29 31 namespace WebKit { 30 + (BOOL)_supportsRegularExpression:(NSString *)regex WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 32 31 33 template<> struct WrapperTraits<API::ContentRuleList> {34 using WrapperClass = WKContentRuleList;35 };36 37 }38 39 @interface WKContentRuleList () <WKObject> {40 @package41 API::ObjectStorage<API::ContentRuleList> _contentRuleList;42 }43 32 @end -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r271180 r271207 1243 1243 5C4609E8224317BB009943C2 /* _WKContentRuleListActionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4609E422430E4D009943C2 /* _WKContentRuleListActionInternal.h */; }; 1244 1244 5C4B9D8B210A8CCF008F14D1 /* UndoOrRedo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4B9D8A210A8C46008F14D1 /* UndoOrRedo.h */; }; 1245 5C5139DB25927D80009C3E30 /* WKContentRuleListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5139DA259277A2009C3E30 /* WKContentRuleListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1245 1246 5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1246 1247 5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4336 4337 5C46C0AE21B71AE200BC5991 /* _WKWebsiteDataStoreConfigurationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebsiteDataStoreConfigurationInternal.h; sourceTree = "<group>"; }; 4337 4338 5C4B9D8A210A8C46008F14D1 /* UndoOrRedo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UndoOrRedo.h; sourceTree = "<group>"; }; 4339 5C5139DA259277A2009C3E30 /* WKContentRuleListPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentRuleListPrivate.h; sourceTree = "<group>"; }; 4338 4340 5C53DCDD24465BF900A93124 /* ApplePayPaymentSetupFeatures.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplePayPaymentSetupFeatures.mm; sourceTree = "<group>"; }; 4339 4341 5C53DCDE24465BF900A93124 /* PaymentSetupConfigurationWebKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaymentSetupConfigurationWebKit.h; sourceTree = "<group>"; }; … … 7851 7853 5CD2864B1E722F440094FDC8 /* WKContentRuleList.mm */, 7852 7854 5CD2864C1E722F440094FDC8 /* WKContentRuleListInternal.h */, 7855 5C5139DA259277A2009C3E30 /* WKContentRuleListPrivate.h */, 7853 7856 5CD2864D1E722F440094FDC8 /* WKContentRuleListStore.h */, 7854 7857 5CD2864E1E722F440094FDC8 /* WKContentRuleListStore.mm */, … … 12285 12288 5CD286541E7235B10094FDC8 /* WKContentRuleList.h in Headers */, 12286 12289 5CD286551E7235B80094FDC8 /* WKContentRuleListInternal.h in Headers */, 12290 5C5139DB25927D80009C3E30 /* WKContentRuleListPrivate.h in Headers */, 12287 12291 5CD286511E7235990094FDC8 /* WKContentRuleListStore.h in Headers */, 12288 12292 5CD286571E7235C90094FDC8 /* WKContentRuleListStoreInternal.h in Headers */, -
trunk/Tools/ChangeLog
r271205 r271207 1 2021-01-06 Alex Christensen <achristensen@webkit.org> 2 3 Add SPI to determine whether a regex is supported in WKContentRuleList 4 https://bugs.webkit.org/show_bug.cgi?id=220095 5 6 Reviewed by Tim Horton. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm: 9 (TEST): 10 1 11 2021-01-06 Sihui Liu <sihui_liu@appe.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentRuleListNotification.mm
r259843 r271207 27 27 28 28 #import "PlatformUtilities.h" 29 #import <WebKit/WKContentRuleListPrivate.h> 29 30 #import <WebKit/WKContentRuleListStore.h> 30 31 #import <WebKit/WKNavigationDelegatePrivate.h> … … 170 171 EXPECT_TRUE(expectedNotifications == notificationList); 171 172 } 173 174 TEST(ContentRuleList, SupportsRegex) 175 { 176 NSArray<NSString *> *allowed = @[ 177 @".*", 178 @"a.*b" 179 ]; 180 for (NSString *regex in allowed) 181 EXPECT_TRUE([WKContentRuleList _supportsRegularExpression:regex]); 182 183 NSArray<NSString *> *disallowed = @[ 184 @"Ä", 185 @"\\d\\D\\w\\s\\v\\h\\i\\c", 186 @"", 187 @"(?<A>a)\\k<A>", 188 @"a^", 189 @"\\b", 190 @"[\\d]", 191 @"(?!)", 192 @"this|that", 193 @"$$", 194 @"a{0,2}b" 195 ]; 196 for (NSString *regex in disallowed) 197 EXPECT_FALSE([WKContentRuleList _supportsRegularExpression:regex]); 198 }
Note:
See TracChangeset
for help on using the changeset viewer.