Commit 54b12055 authored by andersca@apple.com's avatar andersca@apple.com

FrameFilter can just be an std::function instead

https://bugs.webkit.org/show_bug.cgi?id=124176

Reviewed by Tim Horton.

Source/WebCore:

* WebCore.exp.in:
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/archive/cf/LegacyWebArchive.h:

Source/WebKit/mac:

* DOM/WebDOMOperations.mm:
(-[DOMNode webArchiveByFilteringSubframes:]):

Source/WebKit2:

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::webArchiveData):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159089 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6f9ac118
2013-11-11 Anders Carlsson <andersca@apple.com>
FrameFilter can just be an std::function instead
https://bugs.webkit.org/show_bug.cgi?id=124176
Reviewed by Tim Horton.
* WebCore.exp.in:
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/archive/cf/LegacyWebArchive.h:
2013-11-11 Simon Fraser <simon.fraser@apple.com>
REGRESSION (r155660): box-shadow causes overlay scrollbars to be in the wrong position when element is composited (85647)
......
......@@ -624,7 +624,7 @@ __ZN7WebCore16LegacyWebArchive19createFromSelectionEPNS_5FrameE
__ZN7WebCore16LegacyWebArchive21rawDataRepresentationEv
__ZN7WebCore16LegacyWebArchive6createEN3WTF10PassRefPtrINS_15ArchiveResourceEEERNS1_6VectorIS4_Lm0ENS1_15CrashOnOverflowEEERNS5_INS2_IS0_EELm0ES6_EE
__ZN7WebCore16LegacyWebArchive6createEPNS_12SharedBufferE
__ZN7WebCore16LegacyWebArchive6createEPNS_4NodeEPNS_11FrameFilterE
__ZN7WebCore16LegacyWebArchive6createEPNS_4NodeENSt3__18functionIFbRNS_5FrameEEEE
__ZN7WebCore16LegacyWebArchive6createEPNS_5FrameE
__ZN7WebCore16LegacyWebArchive6createEPNS_5RangeE
__ZN7WebCore16LegacyWebArchive6createEv
......
......@@ -422,7 +422,7 @@ RetainPtr<CFDataRef> LegacyWebArchive::createPropertyListRepresentation(const Re
#endif
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Node* node, FrameFilter* filter)
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Node* node, std::function<bool (Frame&)> frameFilter)
{
ASSERT(node);
if (!node)
......@@ -447,7 +447,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Node* node, FrameFilter* f
if (nodeType != Node::DOCUMENT_NODE && nodeType != Node::DOCUMENT_TYPE_NODE)
markupString = documentTypeString(node->document()) + markupString;
return create(markupString, frame, nodeList, filter);
return create(markupString, frame, nodeList, std::move(frameFilter));
}
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Frame* frame)
......@@ -496,7 +496,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
return create(markupString, frame, nodeList, 0);
}
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame* frame, const Vector<Node*>& nodes, FrameFilter* frameFilter)
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame* frame, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter)
{
ASSERT(frame);
......@@ -520,7 +520,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
Frame* childFrame;
if ((isHTMLFrameElement(node) || isHTMLIFrameElement(node) || isHTMLObjectElement(node))
&& (childFrame = toHTMLFrameOwnerElement(node).contentFrame())) {
if (frameFilter && !frameFilter->shouldIncludeSubframe(childFrame))
if (frameFilter && !frameFilter(*childFrame))
continue;
RefPtr<LegacyWebArchive> subframeArchive = create(childFrame->document(), frameFilter);
......
......@@ -30,6 +30,7 @@
#define LegacyWebArchive_h
#include "Archive.h"
#include <functional>
namespace WebCore {
......@@ -37,19 +38,13 @@ class Frame;
class Node;
class Range;
class FrameFilter {
public:
virtual ~FrameFilter() { }
virtual bool shouldIncludeSubframe(Frame*) const = 0;
};
class LegacyWebArchive : public Archive {
public:
static PassRefPtr<LegacyWebArchive> create();
static PassRefPtr<LegacyWebArchive> create(SharedBuffer*);
static PassRefPtr<LegacyWebArchive> create(const URL&, SharedBuffer*);
static PassRefPtr<LegacyWebArchive> create(PassRefPtr<ArchiveResource> mainResource, Vector<PassRefPtr<ArchiveResource>>& subresources, Vector<PassRefPtr<LegacyWebArchive>>& subframeArchives);
static PassRefPtr<LegacyWebArchive> create(Node*, FrameFilter* = 0);
static PassRefPtr<LegacyWebArchive> create(Node*, std::function<bool (Frame&)> frameFilter = nullptr);
static PassRefPtr<LegacyWebArchive> create(Frame*);
static PassRefPtr<LegacyWebArchive> createFromSelection(Frame*);
static PassRefPtr<LegacyWebArchive> create(Range*);
......@@ -63,7 +58,7 @@ private:
enum MainResourceStatus { Subresource, MainResource };
static PassRefPtr<LegacyWebArchive> create(const String& markupString, Frame*, const Vector<Node*>& nodes, FrameFilter*);
static PassRefPtr<LegacyWebArchive> create(const String& markupString, Frame*, const Vector<Node*>& nodes, std::function<bool (Frame&)> frameFilter);
static PassRefPtr<ArchiveResource> createResource(CFDictionaryRef);
static ResourceResponse createResourceResponseFromMacArchivedData(CFDataRef);
static ResourceResponse createResourceResponseFromPropertyListData(CFDataRef, CFStringRef responseDataType);
......
2013-11-11 Anders Carlsson <andersca@apple.com>
FrameFilter can just be an std::function instead
https://bugs.webkit.org/show_bug.cgi?id=124176
Reviewed by Tim Horton.
* DOM/WebDOMOperations.mm:
(-[DOMNode webArchiveByFilteringSubframes:]):
2013-11-11 Dan Bernstein <mitz@apple.com>
[Mac] .exp files are not source code
......
......@@ -75,34 +75,6 @@ using namespace JSC;
@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;
return m_filterBlock(kit(frame));
}
@implementation DOMNode (WebDOMNodeOperations)
- (WebArchive *)webArchive
......@@ -112,8 +84,11 @@ bool WebFrameFilter::shouldIncludeSubframe(Frame* frame) const
- (WebArchive *)webArchiveByFilteringSubframes:(WebArchiveSubframeFilter)webArchiveSubframeFilter
{
WebFrameFilter filter(webArchiveSubframeFilter);
return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self), &filter)] autorelease];
WebArchive *webArchive = [[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(core(self), [webArchiveSubframeFilter](Frame& subframe) -> bool {
return webArchiveSubframeFilter(kit(&subframe));
})];
return [webArchive autorelease];
}
@end
......
2013-11-11 Anders Carlsson <andersca@apple.com>
FrameFilter can just be an std::function instead
https://bugs.webkit.org/show_bug.cgi?id=124176
Reviewed by Tim Horton.
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::webArchiveData):
2013-11-11 Anders Carlsson <andersca@apple.com>
Remove unused Qt cruft
......
......@@ -734,46 +734,23 @@ void WebFrame::setTextDirection(const String& direction)
}
#if PLATFORM(MAC)
class WebFrameFilter : public FrameFilter {
public:
WebFrameFilter(WebFrame*, WebFrame::FrameFilterFunction, void* context);
private:
virtual bool shouldIncludeSubframe(Frame*) const OVERRIDE;
WebFrame* m_topLevelWebFrame;
WebFrame::FrameFilterFunction m_callback;
void* m_context;
};
WebFrameFilter::WebFrameFilter(WebFrame* topLevelWebFrame, WebFrame::FrameFilterFunction callback, void* context)
: m_topLevelWebFrame(topLevelWebFrame)
, m_callback(callback)
, m_context(context)
{
}
bool WebFrameFilter::shouldIncludeSubframe(Frame* frame) const
RetainPtr<CFDataRef> WebFrame::webArchiveData(FrameFilterFunction callback, void* context)
{
if (!m_callback)
return true;
RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreFrame()->document(), [this, callback, context](Frame& frame) -> bool {
if (!callback)
return true;
WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame->loader().client());
WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
ASSERT(webFrame);
WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame.loader().client());
WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0;
ASSERT(webFrame);
return m_callback(toAPI(m_topLevelWebFrame), toAPI(webFrame), m_context);
}
return callback(toAPI(this), toAPI(webFrame), context);
});
RetainPtr<CFDataRef> WebFrame::webArchiveData(FrameFilterFunction callback, void* context)
{
WebFrameFilter filter(this, callback, context);
if (!archive)
return nullptr;
if (RefPtr<LegacyWebArchive> archive = LegacyWebArchive::create(coreFrame()->document(), &filter))
return archive->rawDataRepresentation();
return 0;
return archive->rawDataRepresentation();
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment