Commit fe921ca2 authored by beidson@apple.com's avatar beidson@apple.com

WebCore:

2008-03-28  Brady Eidson  <beidson@apple.com>

        Reviewed by Sam Weinig

        WebArchive saga continues - Can now make archives from ranges in WebCore

        Again, previous layout test coverage exercised this code

        * WebCore.base.exp:

        * editing/markup.cpp:
        (WebCore::createFullMarkup): Added a "markup from range" variant that copies the previous WebKit implementation
        * editing/markup.h:

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

WebKit/mac:

2008-03-28  Brady Eidson  <beidson@apple.com>

        Reviewed by Sam Weinig

        WebArchive saga continues - Can now make archives from ranges in WebCore

        * DOM/WebDOMOperations.mm:
        (-[DOMRange webArchive]):
        (-[DOMRange markupString]):

        * WebView/WebArchiver.h: Remove newly obsolete [WebArchiver archiveRange:]
        * WebView/WebArchiver.mm:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31412 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c629ee72
2008-03-28 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
WebArchive saga continues - Can now make archives from ranges in WebCore
Again, previous layout test coverage exercised this code
* WebCore.base.exp:
* editing/markup.cpp:
(WebCore::createFullMarkup): Added a "markup from range" variant that copies the previous WebKit implementation
* editing/markup.h:
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::create):
* loader/archive/cf/LegacyWebArchive.h:
2008-03-28 Stephanie Lewis <slewis@apple.com>
windows build fix.
......@@ -343,6 +343,7 @@ __ZN7WebCore16LegacyWebArchive6createEN3WTF10PassRefPtrINS_15ArchiveResourceEEER
__ZN7WebCore16LegacyWebArchive6createEPNS_12SharedBufferE
__ZN7WebCore16LegacyWebArchive6createEPNS_4NodeE
__ZN7WebCore16LegacyWebArchive6createEPNS_5FrameE
__ZN7WebCore16LegacyWebArchive6createEPNS_5RangeE
__ZN7WebCore16LegacyWebArchive6createERKNS_6StringEPNS_5FrameERN3WTF6VectorIPNS_4NodeELm0EEE
__ZN7WebCore16LegacyWebArchive6createEv
__ZN7WebCore16MIMETypeRegistry24isSupportedImageMIMETypeERKNS_6StringE
......@@ -354,6 +355,7 @@ __ZN7WebCore16NavigationActionC1ERKNS_4KURLENS_14NavigationTypeE
__ZN7WebCore16NavigationActionC1Ev
__ZN7WebCore16colorFromNSColorEP7NSColor
__ZN7WebCore16createFullMarkupEPKNS_4NodeE
__ZN7WebCore16createFullMarkupEPKNS_5RangeE
__ZN7WebCore16enclosingIntRectERK7_NSRect
__ZN7WebCore16isEndOfParagraphERKNS_15VisiblePositionE
__ZN7WebCore17DOMImplementation14isTextMIMETypeERKNS_6StringE
......
......@@ -1124,4 +1124,25 @@ String createFullMarkup(const Node* node)
return frame->documentTypeString() + createMarkup(node, IncludeNode, 0);
}
String createFullMarkup(const Range* range)
{
if (!range)
return String();
Node* node = range->startContainer();
if (!node)
return String();
Document* document = node->document();
if (!document)
return String();
Frame* frame = document->frame();
if (!frame)
return String();
// FIXME: This is always "for interchange". Is that right? See the previous method.
return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInterchange);
}
}
......@@ -49,6 +49,7 @@ namespace WebCore {
String createMarkup(const Node*, EChildrenOnly = IncludeNode, Vector<Node*>* = 0);
String createFullMarkup(const Node*);
String createFullMarkup(const Range*);
}
......
......@@ -41,6 +41,7 @@
#include "Logging.h"
#include "markup.h"
#include "Node.h"
#include "Range.h"
#include "SharedBuffer.h"
#include <wtf/RetainPtr.h>
......@@ -442,6 +443,31 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Frame* frame)
return LegacyWebArchive::create(documentLoader->mainResource(), subresources, subframeArchives);
}
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(Range* range)
{
if (!range)
return 0;
Node* startContainer = range->startContainer();
if (!startContainer)
return 0;
Document* document = startContainer->document();
if (!document)
return 0;
Frame* frame = document->frame();
if (!frame)
return 0;
Vector<Node*> nodeList;
// FIXME: This is always "for interchange". Is that right? See the previous method.
String markupString = frame->documentTypeString() + createMarkup(range, &nodeList, AnnotateForInterchange);
return create(markupString, frame, nodeList);
}
PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString, Frame* frame, Vector<Node*>& nodes)
{
ASSERT(frame);
......
......@@ -37,6 +37,7 @@ namespace WebCore {
class Frame;
class Node;
class Range;
class LegacyWebArchive : public Archive {
public:
......@@ -45,6 +46,7 @@ public:
static PassRefPtr<LegacyWebArchive> create(PassRefPtr<ArchiveResource> mainResource, Vector<PassRefPtr<ArchiveResource> >& subresources, Vector<PassRefPtr<LegacyWebArchive> >& subframeArchives);
static PassRefPtr<LegacyWebArchive> create(Node*);
static PassRefPtr<LegacyWebArchive> create(Frame*);
static PassRefPtr<LegacyWebArchive> create(Range*);
static PassRefPtr<LegacyWebArchive> create(const String& markupString, Frame*, Vector<Node*>& nodes);
RetainPtr<CFDataRef> rawDataRepresentation();
......
2008-03-28 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
WebArchive saga continues - Can now make archives from ranges in WebCore
* DOM/WebDOMOperations.mm:
(-[DOMRange webArchive]):
(-[DOMRange markupString]):
* WebView/WebArchiver.h: Remove newly obsolete [WebArchiver archiveRange:]
* WebView/WebArchiver.mm:
2008-03-28 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig
......
......@@ -29,6 +29,7 @@
#import "WebDOMOperationsPrivate.h"
#import "DOMNodeInternal.h"
#import "DOMRangeInternal.h"
#import "WebArchiveInternal.h"
#import "WebArchiver.h"
#import "WebDataSourcePrivate.h"
......@@ -120,12 +121,12 @@ using namespace WebCore;
- (WebArchive *)webArchive
{
return [WebArchiver archiveRange:self];
return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create([self _range])] autorelease];
}
- (NSString *)markupString
{
return [[[[self startContainer] ownerDocument] webFrame] _markupStringFromRange:self nodes:nil];
return createFullMarkup([self _range]);
}
@end
......
......@@ -37,7 +37,6 @@
{
}
+ (WebArchive *)archiveRange:(DOMRange *)range;
+ (WebArchive *)archiveSelectionInFrame:(WebFrame *)frame;
@end
......@@ -59,14 +59,6 @@ using namespace WebCore;
return [[[WebArchive alloc] _initWithCoreLegacyWebArchive:LegacyWebArchive::create(markupString, core(frame), coreNodes)] autorelease];
}
+ (WebArchive *)archiveRange:(DOMRange *)range
{
WebFrame *frame = [[[range startContainer] ownerDocument] webFrame];
NSArray *nodes;
NSString *markupString = [frame _markupStringFromRange:range nodes:&nodes];
return [self _archiveWithMarkupString:markupString fromFrame:frame nodes:nodes];
}
+ (WebArchive *)archiveSelectionInFrame:(WebFrame *)frame
{
Frame* coreFrame = core(frame);
......
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