Title: [108850] trunk/Source/WebKit/mac
Revision
108850
Author
[email protected]
Date
2012-02-24 14:46:35 -0800 (Fri, 24 Feb 2012)

Log Message

<rdar://problem/10805709> and https://bugs.webkit.org/show_bug.cgi?id=79421
Need a WK1 Mac API to filter which subframes go into WebArchives as they are created

Reviewed by Sam Weinig (with additional comments by Adam Roben)

Add webArchiveByFilteringSubframes: which takes a callback block:
* DOM/WebDOMOperationsPrivate.h:

Add FrameFilter that adapts the block, and use it to implement the new SPI:
* DOM/WebDOMOperations.mm:
(WebFrameFilter):
(WebFrameFilter::WebFrameFilter):
(WebFrameFilter::~WebFrameFilter):
(WebFrameFilter::shouldIncludeSubframe):
(-[DOMNode webArchiveByFilteringSubframes:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (108849 => 108850)


--- trunk/Source/WebKit/mac/ChangeLog	2012-02-24 22:39:54 UTC (rev 108849)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-02-24 22:46:35 UTC (rev 108850)
@@ -1,3 +1,21 @@
+2012-02-24  Brady Eidson  <[email protected]>
+
+        <rdar://problem/10805709> and https://bugs.webkit.org/show_bug.cgi?id=79421
+        Need a WK1 Mac API to filter which subframes go into WebArchives as they are created
+
+        Reviewed by Sam Weinig (with additional comments by Adam Roben)
+
+        Add webArchiveByFilteringSubframes: which takes a callback block:
+        * DOM/WebDOMOperationsPrivate.h:
+
+        Add FrameFilter that adapts the block, and use it to implement the new SPI:
+        * DOM/WebDOMOperations.mm:
+        (WebFrameFilter):
+        (WebFrameFilter::WebFrameFilter):
+        (WebFrameFilter::~WebFrameFilter):
+        (WebFrameFilter::shouldIncludeSubframe):
+        (-[DOMNode webArchiveByFilteringSubframes:]):
+
 2012-02-24  Shinya Kawanaka  <[email protected]>
 
         SpellCheckRequest needs to know the context where the spellcheck happened.

Modified: trunk/Source/WebKit/mac/DOM/WebDOMOperations.mm (108849 => 108850)


--- trunk/Source/WebKit/mac/DOM/WebDOMOperations.mm	2012-02-24 22:39:54 UTC (rev 108849)
+++ trunk/Source/WebKit/mac/DOM/WebDOMOperations.mm	2012-02-24 22:46:35 UTC (rev 108850)
@@ -35,10 +35,12 @@
 #import "WebArchiveInternal.h"
 #import "WebDataSourcePrivate.h"
 #import "WebFrameInternal.h"
+#import "WebFrameLoaderClient.h"
 #import "WebFramePrivate.h"
 #import "WebKitNSStringExtras.h"
 #import <_javascript_Core/APICast.h>
 #import <WebCore/Document.h>
+#import <WebCore/Frame.h>
 #import <WebCore/HTMLInputElement.h>
 #import <WebCore/HTMLParserIdioms.h>
 #import <WebCore/JSElement.h>
@@ -76,6 +78,35 @@
 
 @end
 
+class WebFrameFilter : public WebCore::FrameFilter {
+public:
+    WebFrameFilter(WebArchiveSubframeFilter filterBlock);
+    ~WebFrameFilter();
+private:
+    virtual bool shouldIncludeSubframe(Frame*) const OVERRIDE;
+
+    WebArchiveSubframeFilter m_filterBlock;
+};
+
+WebFrameFilter::WebFrameFilter(WebArchiveSubframeFilter filterBlock)
+    : m_filterBlock(Block_copy(filterBlock))
+{
+}
+
+WebFrameFilter::~WebFrameFilter()
+{
+    Block_release(m_filterBlock);
+}
+
+bool WebFrameFilter::shouldIncludeSubframe(Frame* frame) const
+{
+    if (!m_filterBlock)
+        return true;
+        
+    WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(frame->loader()->client())->webFrame();
+    return m_filterBlock(webFrame);
+}
+
 @implementation DOMNode (WebDOMNodeOperations)
 
 - (WebArchive *)webArchive
@@ -83,6 +114,12 @@
     return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self))] autorelease];
 }
 
+- (WebArchive *)webArchiveByFilteringSubframes:(WebArchiveSubframeFilter)webArchiveSubframeFilter
+{
+    WebFrameFilter filter(webArchiveSubframeFilter);
+    return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self), &filter)] autorelease];
+}
+
 @end
 
 @implementation DOMNode (WebDOMNodeOperationsPendingPublic)

Modified: trunk/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h (108849 => 108850)


--- trunk/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h	2012-02-24 22:39:54 UTC (rev 108849)
+++ trunk/Source/WebKit/mac/DOM/WebDOMOperationsPrivate.h	2012-02-24 22:46:35 UTC (rev 108850)
@@ -47,3 +47,9 @@
 - (NSString *)markupString;
 - (NSRect)_renderRect:(bool *)isReplaced;
 @end
+
+typedef BOOL (^WebArchiveSubframeFilter)(WebFrame* subframe);
+
+@interface DOMNode (WebDOMNodeOperationsPrivate)
+- (WebArchive *)webArchiveByFilteringSubframes:(WebArchiveSubframeFilter)webArchiveSubframeFilter;
+@end
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to