From 9df89043d3d7dc1e49ea552bfc70948a87fe45f5 Mon Sep 17 00:00:00 2001 From: iska Date: Sun, 27 Nov 2016 03:12:58 +0100 Subject: [PATCH] Refactor all private extensions into own separate categories --- HTMLKit.xcodeproj/project.pbxproj | 20 +++++++++++++++++ Sources/HTMLCharacterData+Private.h | 3 +++ Sources/HTMLDocument+Private.h | 35 +++++++++++++++++++++++++++++ Sources/HTMLDocument.m | 7 +----- Sources/HTMLNodeIterator+Private.h | 28 +++++++++++++++++++++++ Sources/HTMLParser+Private.h | 23 +++++++++++++++++++ Sources/HTMLParser.m | 4 ---- Sources/HTMLTokenizer.m | 6 +---- Sources/include/HTMLTokenizer.h | 2 +- 9 files changed, 112 insertions(+), 16 deletions(-) create mode 100644 Sources/HTMLNodeIterator+Private.h create mode 100644 Sources/HTMLParser+Private.h diff --git a/HTMLKit.xcodeproj/project.pbxproj b/HTMLKit.xcodeproj/project.pbxproj index d3de318..51701fb 100644 --- a/HTMLKit.xcodeproj/project.pbxproj +++ b/HTMLKit.xcodeproj/project.pbxproj @@ -15,6 +15,14 @@ 621CC4921DEA704000D1992A /* HTMLDocument+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4931DEA704000D1992A /* HTMLDocument+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621CC4941DEA704000D1992A /* HTMLDocument+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 621CC49B1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; }; + 621CC49C1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; }; + 621CC49D1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; }; + 621CC49E1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */; }; + 621CC4A51DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 621CC4A61DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 621CC4A71DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; }; + 621CC4A81DEA721A00D1992A /* HTMLParser+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; 621FBE5B1BDAD68700BC9555 /* CSSSelectorParserTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 621FBE591BDAD68700BC9555 /* CSSSelectorParserTests.m */; }; 621FBE5E1BDAD90200BC9555 /* CSSCombinatorSelectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 621FBE5C1BDAD90200BC9555 /* CSSCombinatorSelectorTests.m */; }; 6236738F1AC0CE2500FF89B3 /* HTMLKitTokenizerPerformance.m in Sources */ = {isa = PBXBuildFile; fileRef = 6236738D1AC0CE2500FF89B3 /* HTMLKitTokenizerPerformance.m */; }; @@ -563,6 +571,8 @@ 62132E5B1C021FF200084175 /* css-tests */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "css-tests"; sourceTree = ""; }; 6216ACFC1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSExtensionSelectorsParsingTests.m; sourceTree = ""; }; 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLDocument+Private.h"; sourceTree = ""; }; + 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLNodeIterator+Private.h"; sourceTree = ""; }; + 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HTMLParser+Private.h"; sourceTree = ""; }; 621FBE591BDAD68700BC9555 /* CSSSelectorParserTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSSelectorParserTests.m; sourceTree = ""; }; 621FBE5C1BDAD90200BC9555 /* CSSCombinatorSelectorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSCombinatorSelectorTests.m; sourceTree = ""; }; 6223211D1A969B9300BACED5 /* HTMLElementTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HTMLElementTypes.h; path = include/HTMLElementTypes.h; sourceTree = ""; }; @@ -978,6 +988,8 @@ 621CC48F1DEA704000D1992A /* HTMLDocument+Private.h */, 625D0F011C2717DE00D7BEB0 /* HTMLNode+Private.h */, 626679CD1DEA3DAF004353E7 /* HTMLCharacterData+Private.h */, + 621CC4991DEA71D800D1992A /* HTMLNodeIterator+Private.h */, + 621CC4A31DEA721A00D1992A /* HTMLParser+Private.h */, ); name = Private; sourceTree = ""; @@ -1143,6 +1155,7 @@ 62ECBEF51C0B69FD00AF847B /* HTMLMarker.h in Headers */, 62ECBEF61C0B69FE00AF847B /* HTMLDOM.h in Headers */, 62ECBEF71C0B69FE00AF847B /* HTMLNode.h in Headers */, + 621CC4A51DEA721A00D1992A /* HTMLParser+Private.h in Headers */, 62ECBEF81C0B69FE00AF847B /* HTMLDocument.h in Headers */, 62ECBEF91C0B69FE00AF847B /* HTMLDocumentType.h in Headers */, 62ECBEFA1C0B69FE00AF847B /* HTMLDocumentFragment.h in Headers */, @@ -1168,6 +1181,7 @@ 62ECBF0F1C0B6A0100AF847B /* CSSSelector.h in Headers */, 62ECBF101C0B6A0100AF847B /* CSSSelectorBlock.h in Headers */, 62ECBF111C0B6A0200AF847B /* CSSTypeSelector.h in Headers */, + 621CC49B1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62ECBF121C0B6A0200AF847B /* CSSAttributeSelector.h in Headers */, 62ECBF131C0B6A0200AF847B /* CSSPseudoClassSelector.h in Headers */, 62ECBF141C0B6A0200AF847B /* CSSNthExpressionSelector.h in Headers */, @@ -1212,6 +1226,7 @@ 62857CDF1D3989CE008DC254 /* CSSCombinatorSelector.h in Headers */, 62857CA91D398973008DC254 /* HTMLNodeIterator.h in Headers */, 62857CAE1D398973008DC254 /* HTMLQuirksMode.h in Headers */, + 621CC4A81DEA721A00D1992A /* HTMLParser+Private.h in Headers */, 62857CAF1D398977008DC254 /* HTMLNodeTraversal.h in Headers */, 62857C771D398907008DC254 /* HTMLParseErrorToken.h in Headers */, 62857CDC1D3989CE008DC254 /* CSSPseudoClassSelector.h in Headers */, @@ -1237,6 +1252,7 @@ 62857CA11D398973008DC254 /* HTMLNode.h in Headers */, 62857CD41D3989BF008DC254 /* CSSCodePoints.h in Headers */, 62857C871D398927008DC254 /* HTMLElementTypes.h in Headers */, + 621CC49E1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62857C711D398907008DC254 /* HTMLTokenizerEntities.h in Headers */, 62857C6C1D3988EE008DC254 /* HTMLKitErrorDomain.h in Headers */, 62857CD51D3989BF008DC254 /* CSSInputStream.h in Headers */, @@ -1281,6 +1297,7 @@ 62857D551D39A411008DC254 /* HTMLParseErrorToken.h in Headers */, 62857D541D39A411008DC254 /* HTMLDOCTYPEToken.h in Headers */, 62857D871D39A476008DC254 /* CSSInputStream.h in Headers */, + 621CC4A71DEA721A00D1992A /* HTMLParser+Private.h in Headers */, 62857D8F1D39A47F008DC254 /* CSSCombinatorSelector.h in Headers */, 62857D5C1D39A41D008DC254 /* HTMLElementAdjustment.h in Headers */, 62857D891D39A47F008DC254 /* CSSSelectorBlock.h in Headers */, @@ -1306,6 +1323,7 @@ 62857D5B1D39A41D008DC254 /* HTMLElementTypes.h in Headers */, 62857D881D39A47F008DC254 /* CSSSelector.h in Headers */, 62857D4F1D39A40A008DC254 /* HTMLTokenizerEntities.h in Headers */, + 621CC49D1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62857D901D39A47F008DC254 /* CSSCompoundSelector.h in Headers */, 62857D4A1D39A3F4008DC254 /* HTMLKitErrorDomain.h in Headers */, 62857D7C1D39A452008DC254 /* HTMLQuirksMode.h in Headers */, @@ -1350,6 +1368,7 @@ 62ECBFBD1C0B6D3F00AF847B /* CSSSelectorParser.h in Headers */, 62ECBFBE1C0B6D4000AF847B /* CSSNthExpressionParser.h in Headers */, 62ECBFBF1C0B6D4000AF847B /* CSSSelector.h in Headers */, + 621CC4A61DEA721A00D1992A /* HTMLParser+Private.h in Headers */, 62ECBFC01C0B6D4000AF847B /* CSSSelectorBlock.h in Headers */, 62ECBFC11C0B6D4100AF847B /* CSSTypeSelector.h in Headers */, 62ECBFC21C0B6D4100AF847B /* CSSAttributeSelector.h in Headers */, @@ -1375,6 +1394,7 @@ 62ECBF9E1C0B6D3800AF847B /* HTMLEOFToken.h in Headers */, 62ECBFA01C0B6D3900AF847B /* HTMLStackOfOpenElements.h in Headers */, 62ECBFA11C0B6D3900AF847B /* HTMLListOfActiveFormattingElements.h in Headers */, + 621CC49C1DEA71D800D1992A /* HTMLNodeIterator+Private.h in Headers */, 62ECBFA21C0B6D3900AF847B /* HTMLElementTypes.h in Headers */, 62ECBFA31C0B6D3900AF847B /* HTMLElementAdjustment.h in Headers */, 62ECBFA41C0B6D3900AF847B /* HTMLParserInsertionModes.h in Headers */, diff --git a/Sources/HTMLCharacterData+Private.h b/Sources/HTMLCharacterData+Private.h index 50a9463..762a0d5 100644 --- a/Sources/HTMLCharacterData+Private.h +++ b/Sources/HTMLCharacterData+Private.h @@ -9,6 +9,9 @@ #import "HTMLCharacterData.h" #import "HTMLNode.h" +/** + Private HTML Character Data methods which are not intended for public API. + */ @interface HTMLCharacterData () /** diff --git a/Sources/HTMLDocument+Private.h b/Sources/HTMLDocument+Private.h index c66c926..1b30e5c 100644 --- a/Sources/HTMLDocument+Private.h +++ b/Sources/HTMLDocument+Private.h @@ -11,16 +11,51 @@ #import "HTMLNodeIterator.h" #import "HTMLRange.h" +/** + Private HTML Document methods which are not intended for public API. + */ @interface HTMLDocument () @property (nonatomic, assign) HTMLDocumentReadyState readyState; +/** + Runs the necessary steps after removing a node from the DOM. + + @param oldNode The old node that was removed. + @param oldParent The old parent of the node that was removed. + @param oldPreviousSibling The old previous sibling node of the node that was removed. + */ - (void)runRemovingStepsForNode:(HTMLNode *)oldNode withOldParent:(HTMLNode *)oldParent andOldPreviousSibling:(HTMLNode *)oldPreviousSibling; +/** + Attaches a node iterator to this document. + + @param iterator The iterator to attach. + */ - (void)attachNodeIterator:(HTMLNodeIterator *)iterator; + +/** + Detaches a node interator from this document. + + @param iterator The iterator to detach. + */ - (void)detachNodeIterator:(HTMLNodeIterator *)iterator; +/** + Attaches a range to this document. + + @param range The range to attach. + */ +- (void)attachRange:(HTMLRange *)range; + +/** + Detaches a range from this document. + + @param range The range to detach. + */ +- (void)detachRange:(HTMLRange *)range; + @end diff --git a/Sources/HTMLDocument.m b/Sources/HTMLDocument.m index 120cfac..6fd7996 100644 --- a/Sources/HTMLDocument.m +++ b/Sources/HTMLDocument.m @@ -11,12 +11,7 @@ #import "HTMLNodeIterator.h" #import "HTMLKitDOMExceptions.h" #import "HTMLNode+Private.h" - -@interface HTMLNodeIterator (Private) -- (void)runRemovingStepsForNode:(HTMLNode *)oldNode - withOldParent:(HTMLNode *)oldParent - andOldPreviousSibling:(HTMLNode *)oldPreviousSibling; -@end +#import "HTMLNodeIterator+Private.h" @interface HTMLDocument () { diff --git a/Sources/HTMLNodeIterator+Private.h b/Sources/HTMLNodeIterator+Private.h new file mode 100644 index 0000000..3714eac --- /dev/null +++ b/Sources/HTMLNodeIterator+Private.h @@ -0,0 +1,28 @@ +// +// HTMLNodeIterator+Private.h +// HTMLKit +// +// Created by Iska on 27/11/16. +// Copyright © 2016 BrainCookie. All rights reserved. +// + +#import "HTMLNodeIterator.h" +#import "HTMLNode.h" + +/** + Private HTML Node Iterator methods which are not intended for public API. + */ +@interface HTMLNodeIterator (Private) + +/** + Runs the necessary steps after removing a node from the DOM. + + @param oldNode The old node that was removed. + @param oldParent The old parent of the node that was removed. + @param oldPreviousSibling The old previous sibling node of the node that was removed. + */ +- (void)runRemovingStepsForNode:(HTMLNode *)oldNode + withOldParent:(HTMLNode *)oldParent + andOldPreviousSibling:(HTMLNode *)oldPreviousSibling; + +@end diff --git a/Sources/HTMLParser+Private.h b/Sources/HTMLParser+Private.h new file mode 100644 index 0000000..35db646 --- /dev/null +++ b/Sources/HTMLParser+Private.h @@ -0,0 +1,23 @@ +// +// HTLMLParser+Private.h +// HTMLKit +// +// Created by Iska on 27/11/16. +// Copyright © 2016 BrainCookie. All rights reserved. +// + +#import "HTMLParser.h" +#import "HTMLElement.h" + +/** + Private HTML Parser properties & methods which are not intended for public API. + */ +@interface HTMLParser (Private) + +/** + The adjusted current node in the context of HTML parsing as described in: + https://html.spec.whatwg.org/#adjusted-current-node + */ +@property (nonatomic, strong, readonly) HTMLElement *adjustedCurrentNode; + +@end diff --git a/Sources/HTMLParser.m b/Sources/HTMLParser.m index dd1714c..15f85ab 100644 --- a/Sources/HTMLParser.m +++ b/Sources/HTMLParser.m @@ -20,10 +20,6 @@ #import "CSSSelectors.h" #import "HTMLDocument+Private.h" -@interface HTMLTokenizer (Private) -@property (nonatomic, weak) HTMLParser *parser; -@end - @interface HTMLParser () { HTMLTokenizer *_tokenizer; diff --git a/Sources/HTMLTokenizer.m b/Sources/HTMLTokenizer.m index 34068c2..705eb45 100644 --- a/Sources/HTMLTokenizer.m +++ b/Sources/HTMLTokenizer.m @@ -13,10 +13,7 @@ #import "HTMLTokenizerStates.h" #import "HTMLTokenizerCharacters.h" #import "HTMLTokenizerEntities.h" - -@interface HTMLParser (Private) -@property (nonatomic, strong, readonly) HTMLElement *adjustedCurrentNode; -@end +#import "HTMLParser+Private.h" @interface HTMLTokenizer () { @@ -45,7 +42,6 @@ BOOL _eof; } -@property (nonatomic, weak) HTMLParser *parser; @end @implementation HTMLTokenizer diff --git a/Sources/include/HTMLTokenizer.h b/Sources/include/HTMLTokenizer.h index 04a0673..0c37262 100644 --- a/Sources/include/HTMLTokenizer.h +++ b/Sources/include/HTMLTokenizer.h @@ -37,7 +37,7 @@ @see HTMLParser */ -@property (nonatomic, weak, readonly) HTMLParser *parser; +@property (nonatomic, weak) HTMLParser *parser; /** Initializes a new Tokenizer with the given string.