[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:38:28 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 1d2a91065f80be644914b69efc0ebcf518c146f7
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Apr 24 20:27:55 2003 +0000
WebCore:
Reviewed by Chris.
- fixed 3210096 -- server identifies page as UTF-8, page identifies itself as windows-1252, server must win
- fixed 3105796 -- www.thai.com does not display with correct encoding (<body> tag in comment before <meta>)
* khtml/khtml_part.cpp:
(KHTMLPart::write): Pass in an EncodingType rather than just a boolean. This lets us tell
the difference between EncodingFromHTTPHeader (which wins out over an encoding in a meta tag)
and DefaultEncoding (which loses).
(KHTMLPart::setEncoding): Put ifdef around the whole function. We use our own version in
KWQKHTMLPart instead.
* khtml/misc/decoder.h: Defined an EncodingType and changed the parameter to setEncoding to take
it instead of force and 8-bit-only parameters. Store it in m_type and get rid of haveEncoding.
* khtml/misc/decoder.cpp:
(Decoder::Decoder): Set m_type to DefaultEncoding.
(Decoder::setEncoding): Take a type parameter, instead of force and 8-bit-only parameters.
Use "eight-bit-only" mode for EncodingFromMetaTag only. Fix code so we don't clobber an existing
codec if we can't find a new one in a simpler way. Store the type in m_type, rather than using
the confusing "haveEncoding" flag.
(skipComment): Added. Used to skip comments found in the <head> section.
(Decoder::decode): Moved the check for the UTF-16 BOM out and do that check even when we have
an encoding (although not if we have one the user chose). Update check so that we look for a meta
tag when we have nothing except a default encoding. This fixes the bug where we have an encoding
from an HTTP header; in that case we do not want to look at the meta tag. Improve performance a bit
by not constructing a string just so we can append the data. Merged the APPLE_CHANGES case a bit
with the original case better. Added code to skip comments; this fixes the thai.com issue. Improved
the code to handle data after the first buffer full. We now avoid putting data into a QString once
we are past the header. Extended an APPLE_CHANGES ifdef to exclude more code we don't need.
* kwq/KWQKHTMLPart.h: Added setEncoding and addData to replace slotData.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::setEncoding): Added. Needs to be called only once and does the first-time work as
well as setting up the encoding for the page. In practice it is called before each time addData is.
(KWQKHTMLPart::addData): Added. Needs to be called for each run of data. Now just calls write(),
but does some assertions, which is why I have not removed it and changed the bridge to call write().
* kwq/WebCoreBridge.h: Replaced the old addData:withEncoding: and addData:withOverrideEncoding: with
setEncoding:userChosen: and addData:.
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge setEncoding:userChosen:]): Call setEncoding on the part.
(-[WebCoreBridge addData:]): Call addData on the part.
WebKit:
Reviewed by Chris.
- fixed 3210096 -- server identifies page as UTF-8, page identifies itself as windows-1252, server must win
* WebCoreSupport.subproj/WebBridge.m: (-[WebBridge receivedData:withDataSource:]):
Change for new WebCore API. Pass the encoding in a separate setEncoding call rather than
as a parameter in addData. Also don't handle default encoding here any more. Default encoding
is now handled the same way all the other preferences are, in a way that works better on the
WebCore side anyway; nil or empty string means use the default encoding.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4176 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index dc7163e..a57ac9f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,50 @@
2003-04-24 Darin Adler <darin at apple.com>
+ Reviewed by Chris.
+
+ - fixed 3210096 -- server identifies page as UTF-8, page identifies itself as windows-1252, server must win
+ - fixed 3105796 -- www.thai.com does not display with correct encoding (<body> tag in comment before <meta>)
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::write): Pass in an EncodingType rather than just a boolean. This lets us tell
+ the difference between EncodingFromHTTPHeader (which wins out over an encoding in a meta tag)
+ and DefaultEncoding (which loses).
+ (KHTMLPart::setEncoding): Put ifdef around the whole function. We use our own version in
+ KWQKHTMLPart instead.
+
+ * khtml/misc/decoder.h: Defined an EncodingType and changed the parameter to setEncoding to take
+ it instead of force and 8-bit-only parameters. Store it in m_type and get rid of haveEncoding.
+ * khtml/misc/decoder.cpp:
+ (Decoder::Decoder): Set m_type to DefaultEncoding.
+ (Decoder::setEncoding): Take a type parameter, instead of force and 8-bit-only parameters.
+ Use "eight-bit-only" mode for EncodingFromMetaTag only. Fix code so we don't clobber an existing
+ codec if we can't find a new one in a simpler way. Store the type in m_type, rather than using
+ the confusing "haveEncoding" flag.
+ (skipComment): Added. Used to skip comments found in the <head> section.
+ (Decoder::decode): Moved the check for the UTF-16 BOM out and do that check even when we have
+ an encoding (although not if we have one the user chose). Update check so that we look for a meta
+ tag when we have nothing except a default encoding. This fixes the bug where we have an encoding
+ from an HTTP header; in that case we do not want to look at the meta tag. Improve performance a bit
+ by not constructing a string just so we can append the data. Merged the APPLE_CHANGES case a bit
+ with the original case better. Added code to skip comments; this fixes the thai.com issue. Improved
+ the code to handle data after the first buffer full. We now avoid putting data into a QString once
+ we are past the header. Extended an APPLE_CHANGES ifdef to exclude more code we don't need.
+
+ * kwq/KWQKHTMLPart.h: Added setEncoding and addData to replace slotData.
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::setEncoding): Added. Needs to be called only once and does the first-time work as
+ well as setting up the encoding for the page. In practice it is called before each time addData is.
+ (KWQKHTMLPart::addData): Added. Needs to be called for each run of data. Now just calls write(),
+ but does some assertions, which is why I have not removed it and changed the bridge to call write().
+
+ * kwq/WebCoreBridge.h: Replaced the old addData:withEncoding: and addData:withOverrideEncoding: with
+ setEncoding:userChosen: and addData:.
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge setEncoding:userChosen:]): Call setEncoding on the part.
+ (-[WebCoreBridge addData:]): Call addData on the part.
+
+2003-04-24 Darin Adler <darin at apple.com>
+
Reviewed by John.
- improved the text encoding database
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index dc7163e..a57ac9f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,50 @@
2003-04-24 Darin Adler <darin at apple.com>
+ Reviewed by Chris.
+
+ - fixed 3210096 -- server identifies page as UTF-8, page identifies itself as windows-1252, server must win
+ - fixed 3105796 -- www.thai.com does not display with correct encoding (<body> tag in comment before <meta>)
+
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::write): Pass in an EncodingType rather than just a boolean. This lets us tell
+ the difference between EncodingFromHTTPHeader (which wins out over an encoding in a meta tag)
+ and DefaultEncoding (which loses).
+ (KHTMLPart::setEncoding): Put ifdef around the whole function. We use our own version in
+ KWQKHTMLPart instead.
+
+ * khtml/misc/decoder.h: Defined an EncodingType and changed the parameter to setEncoding to take
+ it instead of force and 8-bit-only parameters. Store it in m_type and get rid of haveEncoding.
+ * khtml/misc/decoder.cpp:
+ (Decoder::Decoder): Set m_type to DefaultEncoding.
+ (Decoder::setEncoding): Take a type parameter, instead of force and 8-bit-only parameters.
+ Use "eight-bit-only" mode for EncodingFromMetaTag only. Fix code so we don't clobber an existing
+ codec if we can't find a new one in a simpler way. Store the type in m_type, rather than using
+ the confusing "haveEncoding" flag.
+ (skipComment): Added. Used to skip comments found in the <head> section.
+ (Decoder::decode): Moved the check for the UTF-16 BOM out and do that check even when we have
+ an encoding (although not if we have one the user chose). Update check so that we look for a meta
+ tag when we have nothing except a default encoding. This fixes the bug where we have an encoding
+ from an HTTP header; in that case we do not want to look at the meta tag. Improve performance a bit
+ by not constructing a string just so we can append the data. Merged the APPLE_CHANGES case a bit
+ with the original case better. Added code to skip comments; this fixes the thai.com issue. Improved
+ the code to handle data after the first buffer full. We now avoid putting data into a QString once
+ we are past the header. Extended an APPLE_CHANGES ifdef to exclude more code we don't need.
+
+ * kwq/KWQKHTMLPart.h: Added setEncoding and addData to replace slotData.
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::setEncoding): Added. Needs to be called only once and does the first-time work as
+ well as setting up the encoding for the page. In practice it is called before each time addData is.
+ (KWQKHTMLPart::addData): Added. Needs to be called for each run of data. Now just calls write(),
+ but does some assertions, which is why I have not removed it and changed the bridge to call write().
+
+ * kwq/WebCoreBridge.h: Replaced the old addData:withEncoding: and addData:withOverrideEncoding: with
+ setEncoding:userChosen: and addData:.
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge setEncoding:userChosen:]): Call setEncoding on the part.
+ (-[WebCoreBridge addData:]): Call addData on the part.
+
+2003-04-24 Darin Adler <darin at apple.com>
+
Reviewed by John.
- improved the text encoding database
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 5a7b298..272e7f5 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -96,6 +96,7 @@ using namespace DOM;
#include <CoreServices/CoreServices.h>
#endif
+using khtml::Decoder;
using khtml::RenderObject;
using khtml::RenderText;
using khtml::TextRunArray;
@@ -1479,11 +1480,12 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset )
void KHTMLPart::write( const char *str, int len )
{
if ( !d->m_decoder ) {
- d->m_decoder = new khtml::Decoder();
+ d->m_decoder = new Decoder;
if (!d->m_encoding.isNull())
- d->m_decoder->setEncoding(d->m_encoding.latin1(), d->m_haveEncoding);
+ d->m_decoder->setEncoding(d->m_encoding.latin1(),
+ d->m_haveEncoding ? Decoder::UserChosenEncoding : Decoder::EncodingFromHTTPHeader);
else
- d->m_decoder->setEncoding(settings()->encoding().latin1(), d->m_haveEncoding);
+ d->m_decoder->setEncoding(settings()->encoding().latin1(), Decoder::DefaultEncoding);
#if APPLE_CHANGES
if (d->m_doc)
d->m_doc->setDecoder(d->m_decoder);
@@ -1904,12 +1906,13 @@ void KHTMLPart::slotRedirection(KIO::Job*, const KURL& url)
d->m_workingURL = url;
}
+#if !APPLE_CHANGES
+
bool KHTMLPart::setEncoding( const QString &name, bool override )
{
d->m_encoding = name;
d->m_haveEncoding = override;
-#if !APPLE_CHANGES
if( !m_url.isEmpty() ) {
// reload document
closeURL();
@@ -1919,11 +1922,12 @@ bool KHTMLPart::setEncoding( const QString &name, bool override )
openURL(url);
d->m_restored = false;
}
-#endif
return true;
}
+#endif
+
QString KHTMLPart::encoding() const
{
if(d->m_haveEncoding && !d->m_encoding.isEmpty())
diff --git a/WebCore/khtml/misc/decoder.cpp b/WebCore/khtml/misc/decoder.cpp
index c05ecf2..493f2f8 100644
--- a/WebCore/khtml/misc/decoder.cpp
+++ b/WebCore/khtml/misc/decoder.cpp
@@ -269,24 +269,22 @@ Decoder::Decoder()
m_codec = QTextCodec::codecForName("iso8859-1");
m_decoder = m_codec->makeDecoder();
enc = 0;
+ m_type = DefaultEncoding;
body = false;
beginning = true;
visualRTL = false;
- haveEncoding = false;
}
Decoder::~Decoder()
{
delete m_decoder;
}
-void Decoder::setEncoding(const char *_encoding, bool force, bool eightBitOnly)
+void Decoder::setEncoding(const char *_encoding, EncodingType type)
{
#ifdef DECODE_DEBUG
kdDebug(6005) << "setEncoding " << _encoding << " " << force << endl;
#endif
enc = _encoding;
-
- QTextCodec *old = m_codec;
#ifdef DECODE_DEBUG
kdDebug(6005) << "old encoding is:" << m_codec->name() << endl;
#endif
@@ -298,21 +296,22 @@ void Decoder::setEncoding(const char *_encoding, bool force, bool eightBitOnly)
return;
#if APPLE_CHANGES
- m_codec = eightBitOnly
+ QTextCodec *codec = (type == EncodingFromMetaTag)
? QTextCodec::codecForNameEightBitOnly(enc)
: QTextCodec::codecForName(enc);
- if (m_codec) {
- enc = m_codec->name();
- visualRTL = m_codec->usesVisualOrdering();
+ if (codec) {
+ enc = codec->name();
+ visualRTL = codec->usesVisualOrdering();
}
- bool b = m_codec;
#else
if(enc == "visual") // hebrew visually ordered
enc = "iso8859-8";
bool b;
- m_codec = KGlobal::charsets()->codecForName(enc, b);
+ QTextCodec *codec = KGlobal::charsets()->codecForName(enc, b);
+ if (!b)
+ codec = 0;
- if (m_codec->mibEnum() == 11) {
+ if (codec && codec->mibEnum() == 11) {
// visually ordered unless one of the following
if( !(enc == "iso-8859-8-i" || enc == "iso_8859-8-i"
|| enc == "csiso88598i" || enc == "logical") )
@@ -320,12 +319,13 @@ void Decoder::setEncoding(const char *_encoding, bool force, bool eightBitOnly)
}
#endif
- if( !b ) // in case the codec didn't exist, we keep the old one (fixes some sites specifying invalid codecs)
- m_codec = old;
- else
- haveEncoding = force;
- delete m_decoder;
- m_decoder = m_codec->makeDecoder();
+ if( codec ) { // in case the codec didn't exist, we keep the old one (fixes some sites specifying invalid codecs)
+ m_codec = codec;
+ m_type = type;
+ delete m_decoder;
+ m_decoder = m_codec->makeDecoder();
+ }
+
#ifdef DECODE_DEBUG
kdDebug(6005) << "Decoder::encoding used is" << m_codec->name() << endl;
#endif
@@ -336,29 +336,71 @@ const char *Decoder::encoding() const
return enc;
}
+// Other browsers allow comments in the head section, so we need to also.
+// It's important not to look for tags inside the comments.
+static void skipComment(const char *&ptr, const char *pEnd)
+{
+ const char *p = ptr;
+ // Allow <!-->; other browsers do.
+ if (*p == '>') {
+ p++;
+ } else {
+ while (p != pEnd) {
+ if (*p == '-') {
+ // This is the real end of comment, "-->".
+ if (p[1] == '-' && p[2] == '>') {
+ p += 3;
+ break;
+ }
+ // This is the incorrect end of comment that other browsers allow, "--!>".
+ if (p[1] == '-' && p[2] == '!' && p[3] == '>') {
+ p += 4;
+ break;
+ }
+ }
+ p++;
+ }
+ }
+ ptr = p;
+}
+
QString Decoder::decode(const char *data, int len)
{
+ // Check for BOM mark at the beginning, which is a sure sign of some kind of 16-bit Unicode.
+ if (beginning && buffer.length() + len >= 2) {
+ if (m_type != UserChosenEncoding) {
+ const uchar *udata = (const uchar *)data;
+ uchar c1;
+ if (buffer.length() != 0) {
+ assert(buffer.length() == 1);
+ c1 = buffer[0];
+ } else {
+ c1 = *udata++;
+ }
+ uchar c2 = *udata;
+ if ((c1 == 0xFE && c2 == 0xFF) || (c1 == 0xFF && c2 == 0xFE)) {
+ enc = "ISO-10646-UCS-2";
+ m_type = AutoDetectedEncoding;
+ m_codec = QTextCodec::codecForName(enc);
+ delete m_decoder;
+ m_decoder = m_codec->makeDecoder();
+ }
+ }
+ beginning = false;
+ }
+
// this is not completely efficient, since the function might go
// through the html head several times...
- if(!haveEncoding && !body) {
+ bool lookForMetaTag = m_type == DefaultEncoding && !body;
+
+ if (lookForMetaTag) {
#ifdef DECODE_DEBUG
kdDebug(6005) << "looking for charset definition" << endl;
#endif
- // check for UTF-16
- uchar * uchars = (uchar *) data;
- if( uchars[0] == 0xfe && uchars[1] == 0xff ||
- uchars[0] == 0xff && uchars[1] == 0xfe ) {
- enc = "ISO-10646-UCS-2";
- haveEncoding = true;
- m_codec = QTextCodec::codecForName(enc);
- delete m_decoder;
- m_decoder = m_codec->makeDecoder();
- } else {
-
+ { // extra level of braces to keep indenting matching original for better diff'ing
#if APPLE_CHANGES
- QString appendString(data, len);
- buffer += appendString;
+ buffer.append(data, len);
#else
if(m_codec->mibEnum() != 1000) // utf16
{
@@ -380,15 +422,20 @@ QString Decoder::decode(const char *data, int len)
#if APPLE_CHANGES
const char *ptr = buffer.latin1();
const char *pEnd = ptr + buffer.length();
- while(ptr != pEnd)
#else
const char *ptr = buffer.data();
- while(*ptr != '\0')
+ const char *pEnd = buffer.length();
#endif
+ while(ptr != pEnd)
{
if(*ptr == '<') {
bool end = false;
ptr++;
+ if (ptr[0] == '!' && ptr[1] == '-' && ptr[2] == '-') {
+ ptr += 3;
+ skipComment(ptr, pEnd);
+ continue;
+ }
if(*ptr == '/') ptr++, end=true;
char tmp[20];
int len = 0;
@@ -441,8 +488,8 @@ QString Decoder::decode(const char *data, int len)
#ifdef DECODE_DEBUG
kdDebug( 6005 ) << "Decoder: found charset: " << enc.data() << endl;
#endif
- setEncoding(enc, true, true);
- if( haveEncoding ) goto found;
+ setEncoding(enc, EncodingFromMetaTag);
+ if( m_type == EncodingFromMetaTag ) goto found;
if ( endpos >= str.length() || str[endpos] == '/' || str[endpos] == '>' ) break;
@@ -482,19 +529,13 @@ QString Decoder::decode(const char *data, int len)
return QString::null;
}
}
-#if APPLE_CHANGES
- else {
- QString appendString(data, len);
- buffer += appendString;
- }
-#endif /* APPLE_CHANGES */
found:
#if APPLE_CHANGES
// Do the auto-detect if our default encoding is one of the Japanese ones.
- if (!haveEncoding && m_codec && m_codec->isJapanese())
+ if (m_type != UserChosenEncoding && m_codec && m_codec->isJapanese())
#else
- if (!haveEncoding && KGlobal::locale()->languageList()[0] == "ja")
+ if (m_type == DefaultEncoding && KGlobal::locale()->languageList()[0] == "ja")
#endif
{
#ifdef DECODE_DEBUG
@@ -520,7 +561,7 @@ QString Decoder::decode(const char *data, int len)
<< (autoDetectedEncoding ? autoDetectedEncoding : "NULL") << endl;
#endif
if (autoDetectedEncoding != NULL) {
- setEncoding(autoDetectedEncoding, true);
+ setEncoding(autoDetectedEncoding, AutoDetectedEncoding);
}
}
@@ -542,6 +583,8 @@ QString Decoder::decode(const char *data, int len)
#if APPLE_CHANGES
if (!buffer.isEmpty()) {
+ if (!lookForMetaTag)
+ buffer.append(data, len);
out = m_decoder->toUnicode(buffer.latin1(), buffer.length());
buffer.truncate(0);
} else {
@@ -565,7 +608,6 @@ QString Decoder::decode(const char *data, int len)
}
out = m_decoder->toUnicode(data, len);
}
-#endif
if (out.isNull()) {
fprintf(stderr, "ERROR: decoded string is null\n");
@@ -576,6 +618,8 @@ QString Decoder::decode(const char *data, int len)
// the end...
else if(out[out.length()-1] == QChar::null)
out.truncate(out.length() - 1);
+#endif
+
return out;
}
diff --git a/WebCore/khtml/misc/decoder.h b/WebCore/khtml/misc/decoder.h
index bc6b60d..96f8833 100644
--- a/WebCore/khtml/misc/decoder.h
+++ b/WebCore/khtml/misc/decoder.h
@@ -33,10 +33,18 @@ namespace khtml {
class Decoder
{
public:
+ enum EncodingType {
+ DefaultEncoding,
+ AutoDetectedEncoding,
+ EncodingFromMetaTag,
+ EncodingFromHTTPHeader,
+ UserChosenEncoding
+ };
+
Decoder();
~Decoder();
- void setEncoding(const char *encoding, bool force = false, bool eightBitOnly = false);
+ void setEncoding(const char *encoding, EncodingType type);
const char *encoding() const;
QString decode(const char *data, int len);
@@ -52,16 +60,17 @@ protected:
QTextCodec *m_codec;
QTextDecoder *m_decoder; // only used for utf16
QCString enc;
+ EncodingType m_type;
#if APPLE_CHANGES
QString buffer;
#else
QCString buffer;
#endif
+
bool body;
bool beginning;
bool visualRTL;
- bool haveEncoding;
};
};
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index 7840d6a..e53c7c5 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -97,7 +97,8 @@ public:
void scrollToAnchor(const KURL &);
void jumpToSelection();
- void slotData(NSString *, bool forceEncoding, const char *bytes, int length, bool complete = false);
+ void setEncoding(const QString &encoding, bool userChosen);
+ void addData(const char *bytes, int length);
void setTitle(const DOM::DOMString &);
void setStatusBarText(const QString &status);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 0b1b5c0..c6fe277 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -541,21 +541,20 @@ void KWQKHTMLPart::submitForm(const KURL &url, const URLArgs &args)
clearRecordedFormValues();
}
-void KWQKHTMLPart::slotData(NSString *encoding, bool forceEncoding, const char *bytes, int length, bool complete)
+void KWQKHTMLPart::setEncoding(const QString &name, bool userChosen)
{
if (!d->m_workingURL.isEmpty()) {
receivedFirstData();
}
-
+ d->m_encoding = name;
+ d->m_haveEncoding = userChosen;
+}
+
+void KWQKHTMLPart::addData(const char *bytes, int length)
+{
+ ASSERT(d->m_workingURL.isEmpty());
ASSERT(d->m_doc);
ASSERT(d->m_doc->parsing());
-
- if (encoding) {
- setEncoding(QString::fromNSString(encoding), forceEncoding);
- } else {
- setEncoding(QString::null, false);
- }
-
write(bytes, length);
}
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 938221a..d110f3c 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -114,8 +114,8 @@ enum FrameBorderStyle {
- (void)openURL:(NSString *)URL reload:(BOOL)reload
contentType:(NSString *)contentType refresh:(NSString *)refresh lastModified:(NSDate *)lastModified
pageCache:(NSDictionary *)pageCache;
-- (void)addData:(NSData *)data withEncoding:(NSString *)encoding;
-- (void)addData:(NSData *)data withOverrideEncoding:(NSString *)encoding;
+- (void)setEncoding:(NSString *)encoding userChosen:(BOOL)userChosen;
+- (void)addData:(NSData *)data;
- (void)closeURL;
- (void)didNotOpenURL:(NSString *)URL;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 3564884..fdce5a0 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -67,6 +67,7 @@ using DOM::DocumentImpl;
using DOM::Node;
using DOM::NodeImpl;
+using khtml::Decoder;
using khtml::parseURL;
using khtml::RenderImage;
using khtml::RenderObject;
@@ -182,14 +183,14 @@ static bool initializedObjectCacheSize = FALSE;
}
}
-- (void)addData:(NSData *)data withEncoding:(NSString *)encoding
+- (void)setEncoding:(NSString *)encoding userChosen:(BOOL)userChosen
{
- _part->slotData(encoding, NO, (const char *)[data bytes], [data length], NO);
+ _part->setEncoding(QString::fromNSString(encoding), userChosen);
}
-- (void)addData:(NSData *)data withOverrideEncoding:(NSString *)encoding
+- (void)addData:(NSData *)data
{
- _part->slotData(encoding, YES, (const char *)[data bytes], [data length], NO);
+ _part->addData((const char *)[data bytes], [data length]);
}
- (void)closeURL
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 4e0a265..c374242 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,15 @@
+2003-04-24 Darin Adler <darin at apple.com>
+
+ Reviewed by Chris.
+
+ - fixed 3210096 -- server identifies page as UTF-8, page identifies itself as windows-1252, server must win
+
+ * WebCoreSupport.subproj/WebBridge.m: (-[WebBridge receivedData:withDataSource:]):
+ Change for new WebCore API. Pass the encoding in a separate setEncoding call rather than
+ as a parameter in addData. Also don't handle default encoding here any more. Default encoding
+ is now handled the same way all the other preferences are, in a way that works better on the
+ WebCore side anyway; nil or empty string means use the default encoding.
+
2003-04-24 Ken Kocienda <kocienda at apple.com>
Reviewed by Darin
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.m b/WebKit/WebCoreSupport.subproj/WebBridge.m
index 2062705..73afa7d 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.m
@@ -311,13 +311,15 @@
{
ASSERT([self dataSource] == withDataSource);
- if ([withDataSource _overrideEncoding]) {
- [self addData:data withOverrideEncoding:[withDataSource _overrideEncoding]];
- } else if ([[withDataSource response] textEncodingName]) {
- [self addData:data withEncoding:[[withDataSource response] textEncodingName]];
- } else {
- [self addData:data withEncoding:[[WebPreferences standardPreferences] defaultTextEncodingName]];
+ // Set the encoding. This only needs to be done once, but it's harmless to do it again later.
+ NSString *encoding = [withDataSource _overrideEncoding];
+ BOOL userChosen = encoding != nil;
+ if (encoding == nil) {
+ encoding = [[withDataSource response] textEncodingName];
}
+ [self setEncoding:encoding userChosen:userChosen];
+
+ [self addData:data];
}
- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)resourceLoader withURL:(NSString *)URL
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list