Add injected bundle equivalents of DOMHTMLDocument (DOMHTMLDocumentExtensions)
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2018 23:27:53 +0000 (23:27 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jan 2018 23:27:53 +0000 (23:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181345

Reviewed by Tim Horton.

* WebProcess/InjectedBundle/API/mac/WKDOMDocument.h: Declared new methods.
* WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm:
(-[WKDOMDocument createDocumentFragmentWithMarkupString:baseURL:]): Added. Calls WebCore’s
  createFragmentFromMarkup.
(-[WKDOMDocument createDocumentFragmentWithText:]): Added. Calls WebCore’s
  createFragmentFromText.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226467 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMDocument.h
Source/WebKit/WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm

index c138b84caf94d03688f68707ccc41386fc79d60a..8196a37e3c4a528b1fa67e90fb9c46d06a39dc58 100644 (file)
@@ -1,3 +1,17 @@
+2018-01-05  Dan Bernstein  <mitz@apple.com>
+
+        Add injected bundle equivalents of DOMHTMLDocument (DOMHTMLDocumentExtensions)
+        https://bugs.webkit.org/show_bug.cgi?id=181345
+
+        Reviewed by Tim Horton.
+
+        * WebProcess/InjectedBundle/API/mac/WKDOMDocument.h: Declared new methods.
+        * WebProcess/InjectedBundle/API/mac/WKDOMDocument.mm:
+        (-[WKDOMDocument createDocumentFragmentWithMarkupString:baseURL:]): Added. Calls WebCore’s
+          createFragmentFromMarkup.
+        (-[WKDOMDocument createDocumentFragmentWithText:]): Added. Calls WebCore’s
+          createFragmentFromText.
+
 2018-01-05  Don Olmstead  <don.olmstead@sony.com>
 
         [Curl] Add implementation stubs for Network Cache
index d7dda4b3c535b12c7955d9a5fab85106fac98c81..08d79c6463e612c16af896e1fe6adb8c58110541 100644 (file)
@@ -37,6 +37,8 @@ WK_CLASS_AVAILABLE(macosx(10.10), ios(8.0))
 
 - (WKDOMElement *)createElement:(NSString *)tagName;
 - (WKDOMText *)createTextNode:(NSString *)data;
+- (WKDOMNode *)createDocumentFragmentWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (WKDOMNode *)createDocumentFragmentWithText:(NSString *)text WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @property(readonly) WKDOMElement *body;
 
index 00e5627f613d8148e416018d172ab05aff63c22e..3ad04c71d8363f0ccf5492af3e233268c1937c83 100644 (file)
 
 #import "WKDOMInternals.h"
 #import <WebCore/Document.h>
+#import <WebCore/DocumentFragment.h>
 #import <WebCore/HTMLElement.h>
 #import <WebCore/Text.h>
+#import <WebCore/markup.h>
 
 @implementation WKDOMDocument
 
     return WebKit::toWKDOMElement(downcast<WebCore::Document>(*_impl).bodyOrFrameset());
 }
 
+- (WKDOMNode *)createDocumentFragmentWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL
+{
+    return WebKit::toWKDOMNode(createFragmentFromMarkup(downcast<WebCore::Document>(*_impl), markupString, baseURL.absoluteString).ptr());
+}
+
+- (WKDOMNode *)createDocumentFragmentWithText:(NSString *)text
+{
+    return WebKit::toWKDOMNode(createFragmentFromText(downcast<WebCore::Document>(*_impl).createRange().get(), text).ptr());
+}
+
 @end
 
 #endif // WK_API_ENABLED