Коммит
95ca7660c9
|
@ -149,27 +149,27 @@ PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(Page* page, bool useBin
|
|||
pageSerializer.serialize(page);
|
||||
|
||||
String boundary = generateRandomBoundary();
|
||||
String endOfResourceBoundary = makeString("--", boundary, "\r\n");
|
||||
String endOfResourceBoundary = makeString("--", boundary, "\n");
|
||||
|
||||
GregorianDateTime now;
|
||||
now.setToCurrentLocalTime();
|
||||
String dateString = makeRFC2822DateString(now.weekDay(), now.monthDay(), now.month(), now.year(), now.hour(), now.minute(), now.second(), now.utcOffset() / 60);
|
||||
|
||||
StringBuilder stringBuilder;
|
||||
stringBuilder.append("From: <Saved by WebKit>\r\n");
|
||||
stringBuilder.append("From: <Saved by WebKit>\n");
|
||||
stringBuilder.append("Subject: ");
|
||||
// We replace non ASCII characters with '?' characters to match IE's behavior.
|
||||
stringBuilder.append(replaceNonPrintableCharacters(page->mainFrame()->document()->title()));
|
||||
stringBuilder.append("\r\nDate: ");
|
||||
stringBuilder.append("\nDate: ");
|
||||
stringBuilder.append(dateString);
|
||||
stringBuilder.append("\r\nMIME-Version: 1.0\r\n");
|
||||
stringBuilder.append("Content-Type: multipart/related;\r\n");
|
||||
stringBuilder.append("\nMIME-Version: 1.0\n");
|
||||
stringBuilder.append("Content-Type: multipart/related;\n");
|
||||
stringBuilder.append("\ttype=\"");
|
||||
stringBuilder.append(page->mainFrame()->document()->suggestedMIMEType());
|
||||
stringBuilder.append("\";\r\n");
|
||||
stringBuilder.append("\";\n");
|
||||
stringBuilder.append("\tboundary=\"");
|
||||
stringBuilder.append(boundary);
|
||||
stringBuilder.append("\"\r\n\r\n");
|
||||
stringBuilder.append("\"\n\n");
|
||||
|
||||
// We use utf8() below instead of ascii() as ascii() replaces CRLFs with ?? (we still only have put ASCII characters in it).
|
||||
ASSERT(stringBuilder.toString().containsOnlyASCII());
|
||||
|
@ -193,11 +193,11 @@ PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(Page* page, bool useBin
|
|||
else
|
||||
contentEncoding = base64;
|
||||
|
||||
stringBuilder.append("\r\nContent-Transfer-Encoding: ");
|
||||
stringBuilder.append("\nContent-Transfer-Encoding: ");
|
||||
stringBuilder.append(contentEncoding);
|
||||
stringBuilder.append("\r\nContent-Location: ");
|
||||
stringBuilder.append("\nContent-Location: ");
|
||||
stringBuilder.append(resource.url);
|
||||
stringBuilder.append("\r\n\r\n");
|
||||
stringBuilder.append("\n\n");
|
||||
|
||||
asciiString = stringBuilder.toString().utf8();
|
||||
mhtmlData->append(asciiString.data(), asciiString.length());
|
||||
|
@ -215,9 +215,10 @@ PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(Page* page, bool useBin
|
|||
size_t dataLength = resource.data->size();
|
||||
Vector<char> encodedData;
|
||||
if (!strcmp(contentEncoding, quotedPrintable)) {
|
||||
mhtmlData->append("<!DOCTYPE html>", 15);
|
||||
quotedPrintableEncode(data, dataLength, encodedData);
|
||||
mhtmlData->append(encodedData.data(), encodedData.size());
|
||||
mhtmlData->append("\r\n", 2);
|
||||
mhtmlData->append("\n", 1);
|
||||
} else {
|
||||
ASSERT(!strcmp(contentEncoding, base64));
|
||||
// We are not specifying insertLFs = true below as it would cut the lines with LFs and MHTML requires CRLFs.
|
||||
|
@ -228,14 +229,14 @@ PassRefPtr<SharedBuffer> MHTMLArchive::generateMHTMLData(Page* page, bool useBin
|
|||
do {
|
||||
size_t lineLength = std::min(encodedDataLength - index, maximumLineLength);
|
||||
mhtmlData->append(encodedData.data() + index, lineLength);
|
||||
mhtmlData->append("\r\n", 2);
|
||||
mhtmlData->append("\n\n", 1);
|
||||
index += maximumLineLength;
|
||||
} while (index < encodedDataLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asciiString = makeString("--", boundary, "--\r\n").utf8();
|
||||
asciiString = makeString("--", boundary, "--\n\n").utf8();
|
||||
mhtmlData->append(asciiString.data(), asciiString.length());
|
||||
|
||||
return mhtmlData.release();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "Frame.h"
|
||||
|
||||
#include "MHTMLArchive.h"
|
||||
#include "AnimationController.h"
|
||||
#include "ApplyStyleCommand.h"
|
||||
#include "BackForwardController.h"
|
||||
|
@ -104,6 +104,7 @@
|
|||
#include <wtf/PassOwnPtr.h>
|
||||
#include <wtf/RefCountedLeakCounter.h>
|
||||
#include <wtf/StdLibExtras.h>
|
||||
#include "qstring.h"
|
||||
|
||||
#if USE(ACCELERATED_COMPOSITING)
|
||||
#include "RenderLayerCompositor.h"
|
||||
|
@ -895,6 +896,24 @@ void Frame::setTextZoomFactor(float factor)
|
|||
setPageAndTextZoomFactors(m_pageZoomFactor, factor);
|
||||
}
|
||||
|
||||
void Frame::GenerateMIMEHtml(QString m_str)
|
||||
{
|
||||
Page* page = this->page();
|
||||
RefPtr<SharedBuffer> mhtmlData = SharedBuffer::create();
|
||||
mhtmlData = MHTMLArchive::generateMHTMLData(page);
|
||||
|
||||
std::string mhtmlFileName = m_str.toStdString();
|
||||
const char * filePath = mhtmlFileName.c_str();
|
||||
const char * data = mhtmlData->data();
|
||||
FILE * pFile;
|
||||
pFile = fopen(filePath, "w");
|
||||
if (pFile != NULL)
|
||||
{
|
||||
fputs(data, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor)
|
||||
{
|
||||
if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "ScrollTypes.h"
|
||||
#include "UserScriptTypes.h"
|
||||
#include <wtf/RefCounted.h>
|
||||
#include "SharedBuffer.h"
|
||||
|
||||
#if PLATFORM(WIN)
|
||||
#include "FrameWin.h"
|
||||
|
@ -157,6 +158,7 @@ namespace WebCore {
|
|||
float textZoomFactor() const { return m_textZoomFactor; }
|
||||
void setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor);
|
||||
|
||||
void GenerateMIMEHtml(QString);
|
||||
// Scale factor of this frame with respect to the container.
|
||||
float frameScaleFactor() const;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace WebCore {
|
|||
|
||||
static const size_t maximumLineLength = 76;
|
||||
|
||||
static const char crlfLineEnding[] = "\r\n";
|
||||
static const char crlfLineEnding[] = "\n";
|
||||
|
||||
static size_t lengthOfLineEndingAtIndex(const char* input, size_t inputLength, size_t index)
|
||||
{
|
||||
|
|
|
@ -335,6 +335,11 @@ void QWebFrameAdapter::setZoomFactor(qreal factor)
|
|||
frame->setPageZoomFactor(factor);
|
||||
}
|
||||
|
||||
void QWebFrameAdapter::GenerateMHTML(QString m_str)
|
||||
{
|
||||
frame->GenerateMIMEHtml(m_str);
|
||||
}
|
||||
|
||||
void QWebFrameAdapter::setTextSizeMultiplier(qreal factor)
|
||||
{
|
||||
pageAdapter->settings->setAttribute(QWebSettings::ZoomTextOnly, true);
|
||||
|
|
|
@ -211,6 +211,7 @@ public:
|
|||
void setTextSizeMultiplier(qreal);
|
||||
qreal zoomFactor() const;
|
||||
|
||||
void GenerateMHTML(QString);
|
||||
void updateBackgroundRecursively(const QColor&);
|
||||
|
||||
void cancelLoad();
|
||||
|
|
|
@ -791,6 +791,11 @@ qreal QWebFrame::zoomFactor() const
|
|||
return d->zoomFactor();
|
||||
}
|
||||
|
||||
void QWebFrame::createMhtmlDocument()
|
||||
{
|
||||
d->GenerateMHTML(m_str);
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QWebFrame::focus
|
||||
\since 4.6
|
||||
|
|
|
@ -198,6 +198,7 @@ public:
|
|||
void setTextSizeMultiplier(qreal factor);
|
||||
qreal textSizeMultiplier() const;
|
||||
|
||||
void createMhtmlDocument();
|
||||
qreal zoomFactor() const;
|
||||
void setZoomFactor(qreal factor);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче