qtwebkit/webkit-qtwebkit-type-casting.patch
Rex Dieter ea356d4f11 import
2011-05-19 11:08:10 -05:00

364 lines
19 KiB
Diff

diff -up webkit-qtwebkit/Source/WebCore/bindings/js/JSDocumentCustom.cpp.type-cast webkit-qtwebkit/Source/WebCore/bindings/js/JSDocumentCustom.cpp
--- webkit-qtwebkit/Source/WebCore/bindings/js/JSDocumentCustom.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/bindings/js/JSDocumentCustom.cpp 2011-05-13 13:39:06.626230025 -0500
@@ -118,7 +118,7 @@ JSValue JSDocument::createTouchList(Exec
{
RefPtr<TouchList> touchList = TouchList::create();
- for (int i = 0; i < exec->argumentCount(); i++)
+ for (uint i = 0; i < exec->argumentCount(); i++)
touchList->append(toTouch(exec->argument(i)));
return toJS(exec, globalObject(), touchList.release());
diff -up webkit-qtwebkit/Source/WebCore/editing/qt/SmartReplaceQt.cpp.type-cast webkit-qtwebkit/Source/WebCore/editing/qt/SmartReplaceQt.cpp
--- webkit-qtwebkit/Source/WebCore/editing/qt/SmartReplaceQt.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/editing/qt/SmartReplaceQt.cpp 2011-05-13 13:39:06.626230025 -0500
@@ -55,8 +55,8 @@ bool isCharacterSmartReplaceExempt(UChar
const char prev[] = "([\"\'#$/-`{\0";
const char next[] = ")].,;:?\'!\"%*-/}\0";
const char* str = (isPreviousCharacter) ? prev : next;
- for (int i = 0; i < strlen(str); ++i) {
- if (str[i] == c)
+ for (uint i = 0; i < strlen(str); ++i) {
+ if ((UChar32)str[i] == c)
return true;
}
diff -up webkit-qtwebkit/Source/WebCore/page/ContextMenuController.cpp.type-cast webkit-qtwebkit/Source/WebCore/page/ContextMenuController.cpp
--- webkit-qtwebkit/Source/WebCore/page/ContextMenuController.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/page/ContextMenuController.cpp 2011-05-13 13:39:06.627229928 -0500
@@ -1050,6 +1050,11 @@ void ContextMenuController::checkOrEnabl
shouldEnable = true;
break;
#endif
+#if PLATFORM(QT)
+ case ContextMenuItemTagSelectAll:
+ shouldEnable = true;
+ break;
+#endif
case ContextMenuItemTagUnderline: {
shouldCheck = frame->editor()->selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline") != FalseTriState;
shouldEnable = frame->editor()->canEditRichly();
diff -up webkit-qtwebkit/Source/WebCore/page/Frame.cpp.type-cast webkit-qtwebkit/Source/WebCore/page/Frame.cpp
--- webkit-qtwebkit/Source/WebCore/page/Frame.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/page/Frame.cpp 2011-05-13 13:39:06.627229928 -0500
@@ -969,7 +969,7 @@ void Frame::tiledBackingStorePaintEnd(co
return;
unsigned size = paintedArea.size();
// Request repaint from the system
- for (int n = 0; n < size; ++n)
+ for (uint n = 0; n < size; ++n)
m_page->chrome()->invalidateContentsAndWindow(m_view->contentsToWindow(paintedArea[n]), false);
}
diff -up webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp
--- webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp 2011-05-13 13:39:06.627229928 -0500
@@ -73,8 +73,9 @@ FontPlatformData::FontPlatformData(const
font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
const bool smallCaps = description.smallCaps();
font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
font.setStyleStrategy(QFont::ForceIntegerMetrics);
-
+#endif
m_data->bold = font.bold();
// WebKit allows font size zero but QFont does not. We will return
// m_data->size if a font size of zero is requested and pixelSize()
diff -up webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontQt.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontQt.cpp
--- webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontQt.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/graphics/qt/FontQt.cpp 2011-05-13 13:39:06.627229928 -0500
@@ -186,17 +186,20 @@ static void drawTextCommon(GraphicsConte
p->restore();
return;
}
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
int skipWidth = QFontMetrics(font).width(string, from, Qt::TextBypassShaping);
pt.setX(pt.x() + skipWidth);
string = fromRawDataWithoutRef(sanitized, from, to - from);
+#endif
}
p->setFont(font);
int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
if (!isComplexText && !(ctx->textDrawingMode() & TextModeStroke))
flags |= Qt::TextBypassShaping;
-
+#endif
QPainterPath textStrokePath;
if (ctx->textDrawingMode() & TextModeStroke)
textStrokePath.addText(pt, font, string);
@@ -212,7 +215,11 @@ static void drawTextCommon(GraphicsConte
p->restore();
} else {
QFontMetrics fm(font);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height());
+#else
+ QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1), fm.height());
+#endif
QPainter* shadowPainter = ctxShadow->beginShadowLayer(ctx, boundingRect);
if (shadowPainter) {
// Since it will be blurred anyway, we don't care about render hints.
@@ -229,7 +236,11 @@ static void drawTextCommon(GraphicsConte
p->translate(-ctxShadow->offset());
} else {
QFontMetrics fm(font);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height());
+#else
+ QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1), fm.height());
+#endif
QPainter* shadowPainter = ctxShadow->beginShadowLayer(ctx, boundingRect);
if (shadowPainter) {
// Since it will be blurred anyway, we don't care about render hints.
@@ -254,7 +265,11 @@ static void drawTextCommon(GraphicsConte
void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
{
- drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */true);
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ drawTextCommon(ctx, run, point, from, to, font(), /* isComplexText = */false);
+#else
+ Q_ASSERT(false);
+#endif
}
float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*, GlyphOverflow*) const
@@ -402,6 +417,7 @@ int Font::offsetForPositionForSimpleText
float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
if (!primaryFont()->platformData().size())
return 0;
@@ -418,11 +434,16 @@ float Font::floatWidthForSimpleText(cons
w -= m_wordSpacing;
return w + run.expansion();
+#else
+ Q_ASSERT(false);
+ return 0.0f;
+#endif
}
FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const
{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
String sanitized = Font::normalizeSpaces(run.characters(), run.length());
QString wholeText = fromRawDataWithoutRef(sanitized);
QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from));
@@ -431,6 +452,10 @@ FloatRect Font::selectionRectForSimpleTe
int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping);
return FloatRect(pt.x() + startX, pt.y(), width, h);
+#else
+ Q_ASSERT(false);
+ return FloatRect();
+#endif
}
bool Font::canExpandAroundIdeographsInComplexText()
diff -up webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp
--- webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageBufferQt.cpp 2011-05-13 13:39:06.628229831 -0500
@@ -233,8 +233,11 @@ PassRefPtr<ByteArray> getImageData(const
ASSERT(!image.isNull());
const int bytesPerLine = image.bytesPerLine();
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
const uchar* bits = image.constBits();
-
+#else
+ const uchar* bits = image.bits();
+#endif
quint32* destRows = reinterpret_cast_ptr<quint32*>(&data[desty * rect.width() * 4 + destx * 4]);
if (multiplied == Unmultiplied) {
diff -up webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
--- webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/graphics/qt/ImageDecoderQt.cpp 2011-05-13 13:39:06.628229831 -0500
@@ -184,7 +184,7 @@ void ImageDecoderQt::internalReadImage(s
setFailed();
// Attempt to return some memory
- for (int i = 0; i < m_frameBufferCache.size(); ++i) {
+ for (uint i = 0; i < m_frameBufferCache.size(); ++i) {
if (m_frameBufferCache[i].status() != ImageFrame::FrameComplete)
return;
}
@@ -194,8 +194,15 @@ void ImageDecoderQt::internalReadImage(s
bool ImageDecoderQt::internalHandleCurrentImage(size_t frameIndex)
{
- QPixmap pixmap = QPixmap::fromImageReader(m_reader.get());
+ QPixmap pixmap;
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ pixmap = QPixmap::fromImageReader(m_reader.get());
+#else
+ QImage img;
+ if (m_reader->read(&img))
+ pixmap = QPixmap::fromImage(img);
+#endif
if (pixmap.isNull()) {
frameCount();
repetitionCount();
diff -up webkit-qtwebkit/Source/WebCore/platform/graphics/TiledBackingStore.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/graphics/TiledBackingStore.cpp
--- webkit-qtwebkit/Source/WebCore/platform/graphics/TiledBackingStore.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/graphics/TiledBackingStore.cpp 2011-05-13 13:39:06.628229831 -0500
@@ -76,8 +76,8 @@ void TiledBackingStore::invalidate(const
Tile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.location());
Tile::Coordinate bottomRight = tileCoordinateForPoint(IntPoint(dirtyRect.maxX(), dirtyRect.maxY()));
- for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
- for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
+ for (signed yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
+ for (signed xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
RefPtr<Tile> currentTile = tileAt(Tile::Coordinate(xCoordinate, yCoordinate));
if (!currentTile)
continue;
@@ -135,8 +135,8 @@ void TiledBackingStore::paint(GraphicsCo
Tile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.location());
Tile::Coordinate bottomRight = tileCoordinateForPoint(IntPoint(dirtyRect.maxX(), dirtyRect.maxY()));
- for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
- for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
+ for (signed yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
+ for (signed xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
RefPtr<Tile> currentTile = tileAt(currentCoordinate);
if (currentTile && currentTile->isReadyToPaint())
@@ -231,8 +231,8 @@ void TiledBackingStore::createTiles()
unsigned requiredTileCount = 0;
Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location());
Tile::Coordinate bottomRight = tileCoordinateForPoint(IntPoint(coverRect.maxX(), coverRect.maxY()));
- for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
- for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
+ for (signed yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
+ for (signed xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
if (tileAt(currentCoordinate))
continue;
diff -up webkit-qtwebkit/Source/WebCore/platform/network/MIMESniffing.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/network/MIMESniffing.cpp
--- webkit-qtwebkit/Source/WebCore/platform/network/MIMESniffing.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/network/MIMESniffing.cpp 2011-05-13 13:39:06.628229831 -0500
@@ -223,7 +223,7 @@ const size_t imageTypesSize = sizeof(ima
static inline size_t dataSizeNeededForImageSniffing()
{
size_t result = 0;
- for (int i = 0; i < imageTypesSize; ++i) {
+ for (uint i = 0; i < imageTypesSize; ++i) {
if (imageTypes[i].size > result)
result = imageTypes[i].size;
}
diff -up webkit-qtwebkit/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
--- webkit-qtwebkit/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp 2011-05-13 13:46:40.024092720 -0500
@@ -71,7 +71,7 @@ FormDataIODevice::~FormDataIODevice()
qint64 FormDataIODevice::computeSize()
{
- for (int i = 0; i < m_formElements.size(); ++i) {
+ for (uint i = 0; i < m_formElements.size(); ++i) {
const FormDataElement& element = m_formElements[i];
if (element.m_type == FormDataElement::data)
m_dataSize += element.m_data.size();
@@ -124,7 +124,7 @@ qint64 FormDataIODevice::readData(char*
m_currentDelta += toCopy;
copied += toCopy;
- if (m_currentDelta == element.m_data.size())
+ if ((unsigned)m_currentDelta == element.m_data.size())
moveToNextElement();
} else {
const QByteArray data = m_currentFile->read(available);
@@ -362,8 +362,10 @@ String QNetworkReplyHandler::httpMethod(
return "PUT";
case QNetworkAccessManager::DeleteOperation:
return "DELETE";
+#if QT_VERSION >= 0x040700
case QNetworkAccessManager::CustomOperation:
return m_resourceHandle->firstRequest().httpMethod();
+#endif
default:
ASSERT_NOT_REACHED();
return "GET";
@@ -390,7 +392,11 @@ QNetworkReplyHandler::QNetworkReplyHandl
else if (r.httpMethod() == "DELETE")
m_method = QNetworkAccessManager::DeleteOperation;
else
+#if QT_VERSION >= 0x040700
m_method = QNetworkAccessManager::CustomOperation;
+#else
+ m_method = QNetworkAccessManager::UnknownOperation;
+#endif
QObject* originatingObject = 0;
if (m_resourceHandle->getInternal()->m_context)
@@ -511,10 +517,16 @@ void QNetworkReplyHandler::sendResponseI
response.setHTTPStatusText(m_replyWrapper->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData());
// Add remaining headers.
- foreach (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs())
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
+ foreach (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs()) {
response.setHTTPHeaderField(QString::fromLatin1(pair.first), QString::fromLatin1(pair.second));
+ }
+#else
+ foreach (const QByteArray& headerName, m_replyWrapper->reply()->rawHeaderList()) {
+ response.setHTTPHeaderField(QString::fromAscii(headerName), QString::fromAscii(m_replyWrapper->reply()->rawHeader(headerName)));
+ }
+#endif
}
-
QUrl redirection = m_replyWrapper->reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (redirection.isValid()) {
redirect(response, redirection);
@@ -641,8 +653,10 @@ QNetworkReply* QNetworkReplyHandler::sen
case QNetworkAccessManager::DeleteOperation: {
return manager->deleteResource(m_request);
}
+#if QT_VERSION >= 0x040700
case QNetworkAccessManager::CustomOperation:
return manager->sendCustomRequest(m_request, m_resourceHandle->firstRequest().httpMethod().latin1().data());
+#endif
case QNetworkAccessManager::UnknownOperation:
ASSERT_NOT_REACHED();
return 0;
diff -up webkit-qtwebkit/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp
--- webkit-qtwebkit/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/network/qt/QtMIMETypeSniffer.cpp 2011-05-13 13:39:06.629229734 -0500
@@ -44,7 +44,7 @@ bool QtMIMETypeSniffer::sniff()
// See QNetworkReplyWrapper::setFinished().
const bool isReplyFinished = m_reply->property("_q_isFinished").toBool();
- if (!isReplyFinished && m_reply->bytesAvailable() < m_sniffer.dataSize())
+ if (!isReplyFinished && (unsigned)m_reply->bytesAvailable() < m_sniffer.dataSize())
return false;
QByteArray data = m_reply->peek(m_sniffer.dataSize());
diff -up webkit-qtwebkit/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp.type-cast webkit-qtwebkit/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp
--- webkit-qtwebkit/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp.type-cast 2011-05-12 09:42:28.000000000 -0500
+++ webkit-qtwebkit/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp 2011-05-13 13:39:06.629229734 -0500
@@ -82,13 +82,13 @@ QNetworkRequest ResourceRequest::toNetwo
default:
break;
}
-
+#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
if (!allowCookies()) {
request.setAttribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Manual);
request.setAttribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Manual);
request.setAttribute(QNetworkRequest::AuthenticationReuseAttribute, QNetworkRequest::Manual);
}
-
+#endif
return request;
}