Commit 249c069d authored by darin's avatar darin

WebCore:

        Reviewed by Maciej.

        - support for WebKit fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=5187
          UTF-8 in long text files breaks at some point

        No layout test added: only affects plain text view and requires loading the
        file in multiple chunks.

        * WebCore.exp: Added WebCoreTextDecoder.
        * kwq/WebCoreTextDecoder.h: Added.
        * kwq/WebCoreTextDecoder.mm: Added.
        * WebCore.xcodeproj/project.pbxproj: Added files, made header private (SPI).

WebKit:

        Reviewed by Maciej.

        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5187
          UTF-8 in long text files breaks at some point

        * WebView.subproj/WebTextRepresentation.m:
        (-[WebTextRepresentation finishedLoadingWithDataSource:]):
        Call flushReceivedData on the WebTextView so it can decode any final bytes.

        * WebView.subproj/WebTextView.h: Added WebCoreTextDecoder field and flushReceivedData method.
        * WebView.subproj/WebTextView.m:
        (-[WebTextView dealloc]): Release WebCoreTextDecoder.
        (-[WebTextView appendReceivedData:fromDataSource:]): Create a WebCoreTextDecoder to decode
        the text; use the textEncodingName from the data source. Use it to decode instead of the
        data source's stringWithData.
        (-[WebTextView flushReceivedData]): Call flush on the decoder and append any last bytes to
        the text view.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@10797 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e96b80bf
2005-10-08 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Maciej.
- support for WebKit fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=5187
UTF-8 in long text files breaks at some point
No layout test added: only affects plain text view and requires loading the
file in multiple chunks.
* WebCore.exp: Added WebCoreTextDecoder.
* kwq/WebCoreTextDecoder.h: Added.
* kwq/WebCoreTextDecoder.mm: Added.
* WebCore.xcodeproj/project.pbxproj: Added files, made header private (SPI).
2005-10-08 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Maciej.
......
......@@ -114,6 +114,7 @@
.objc_class_name_WebCoreScriptDebugger
.objc_class_name_WebCoreScrollView
.objc_class_name_WebCoreSettings
.objc_class_name_WebCoreTextDecoder
.objc_class_name_WebCoreTextRendererFactory
.objc_class_name_WebCoreViewFactory
.objc_class_name_WebDashboardRegion
......
......@@ -2292,6 +2292,10 @@
BC1798DA088DA4F8006068A5 /* render_theme_mac.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1798D9088DA4F8006068A5 /* render_theme_mac.h */; };
BCEF3434087B563E00BBF833 /* htmlfactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEF3432087B563E00BBF833 /* htmlfactory.cpp */; };
BCEF3435087B563E00BBF833 /* htmlfactory.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEF3433087B563E00BBF833 /* htmlfactory.h */; };
E1EE773708F1086C00166870 /* WebCoreTextDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1EE773808F1086C00166870 /* WebCoreTextDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */; };
E1EE773908F1086C00166870 /* WebCoreTextDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */; settings = {ATTRIBUTES = (Private, ); }; };
E1EE773A08F1086C00166870 /* WebCoreTextDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */; };
ED048ABC0833F132006E1E67 /* textAreaResizeCorner.tiff in Resources */ = {isa = PBXBuildFile; fileRef = ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */; };
/* End PBXBuildFile section */
......@@ -3891,6 +3895,8 @@
BECE67BD07087B250007C14B /* text_affinity.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = text_affinity.h; path = editing/text_affinity.h; sourceTree = "<group>"; };
BEF7EEA005FF8F0D009717EE /* KWQEditCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KWQEditCommand.h; sourceTree = "<group>"; };
BEF7EEA105FF8F0D009717EE /* KWQEditCommand.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQEditCommand.mm; sourceTree = "<group>"; };
E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreTextDecoder.h; sourceTree = "<group>"; };
E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreTextDecoder.mm; sourceTree = "<group>"; };
ED048ABB0833F132006E1E67 /* textAreaResizeCorner.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = textAreaResizeCorner.tiff; path = Resources/textAreaResizeCorner.tiff; sourceTree = "<group>"; };
EDA4AC97076FB89100DD23EC /* edit_actions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = edit_actions.h; path = editing/edit_actions.h; sourceTree = "<group>"; };
F5117BC902F9FFEF018635CE /* KWQSignal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = KWQSignal.h; path = kwq/KWQSignal.h; sourceTree = SOURCE_ROOT; };
......@@ -6628,6 +6634,8 @@
F587854902DE375901EA4122 /* WebCoreCookieAdapter.h */,
F587854A02DE375901EA4122 /* WebCoreCookieAdapter.m */,
F56234DF03026D7301629B47 /* WebCoreEncodings.h */,
E1EE773508F1086C00166870 /* WebCoreTextDecoder.h */,
E1EE773608F1086C00166870 /* WebCoreTextDecoder.mm */,
F56234E003026D7301629B47 /* WebCoreEncodings.mm */,
F587854C02DE375901EA4122 /* WebCoreFrameView.h */,
BE26F15305517DE000BFA0C3 /* WebCoreGraphicsBridge.h */,
......@@ -7245,6 +7253,7 @@
7E6FEED80898582300C44C3F /* WebCoreScriptDebugger.h in Headers */,
939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
65C97AF308EA908800ACD273 /* config.h in Headers */,
E1EE773708F1086C00166870 /* WebCoreTextDecoder.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -8128,6 +8137,7 @@
A8EA434908E14EAC004BC396 /* dom_kdomnodetreewrapper.h in Headers */,
A8EA434B08E14EAC004BC396 /* dom_kdomdocumentwrapper.h in Headers */,
65C97AF408EA908800ACD273 /* config.h in Headers */,
E1EE773908F1086C00166870 /* WebCoreTextDecoder.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -9549,6 +9559,7 @@
BC179893088D975F006068A5 /* render_theme.cpp in Sources */,
7E6FEED90898582300C44C3F /* WebCoreScriptDebugger.mm in Sources */,
939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */,
E1EE773808F1086C00166870 /* WebCoreTextDecoder.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -10331,6 +10342,7 @@
A8EA434A08E14EAC004BC396 /* dom_kdomnodetreewrapper.cpp in Sources */,
A8EA434C08E14EAC004BC396 /* dom_kdomdocumentwrapper.cpp in Sources */,
A863312F08E3AB25009CFEF4 /* CDFInterface.cpp in Sources */,
E1EE773A08F1086C00166870 /* WebCoreTextDecoder.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#ifdef __cplusplus
class QTextDecoder;
#else
@class QTextDecoder;
#endif
@interface WebCoreTextDecoder : NSObject
{
@private
QTextDecoder *_decoder;
}
- (WebCoreTextDecoder *)initWithEncodingName:(NSString *)encodingName;
+ (WebCoreTextDecoder *)decoderWithEncodingName:(NSString *)encodingName;
- (NSString *)decodeData:(NSData *)data;
- (NSString *)flush;
@end
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "config.h"
#import "WebCoreTextDecoder.h"
#import "KWQTextCodec.h"
@implementation WebCoreTextDecoder
- (WebCoreTextDecoder *)initWithEncodingName:(NSString *)encodingName
{
self = [super init];
QTextCodec *codec = QTextCodec::codecForName([encodingName cStringUsingEncoding:NSASCIIStringEncoding]);
if (!codec)
codec = QTextCodec::codecForName("ISO-8859-1");
_decoder = codec->makeDecoder();
return self;
}
+ (WebCoreTextDecoder *)decoderWithEncodingName:(NSString *)encodingName
{
return [[[WebCoreTextDecoder alloc] initWithEncodingName:encodingName] autorelease];
}
- (void)dealloc
{
delete _decoder;
[super dealloc];
}
- (void)finalize
{
delete _decoder;
[super finalize];
}
- (NSString *)decodeData:(NSData *)data
{
return _decoder->toUnicode((const char *)[data bytes], [data length], false).getNSString();
}
- (NSString *)flush
{
return _decoder->toUnicode("", 0, true).getNSString();
}
@end
2005-10-08 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Maciej.
- fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=5187
UTF-8 in long text files breaks at some point
* WebView.subproj/WebTextRepresentation.m:
(-[WebTextRepresentation finishedLoadingWithDataSource:]):
Call flushReceivedData on the WebTextView so it can decode any final bytes.
* WebView.subproj/WebTextView.h: Added WebCoreTextDecoder field and flushReceivedData method.
* WebView.subproj/WebTextView.m:
(-[WebTextView dealloc]): Release WebCoreTextDecoder.
(-[WebTextView appendReceivedData:fromDataSource:]): Create a WebCoreTextDecoder to decode
the text; use the textEncodingName from the data source. Use it to decode instead of the
data source's stringWithData.
(-[WebTextView flushReceivedData]): Call flush on the decoder and append any last bytes to
the text view.
2005-10-07 John Sullivan <sullivan@apple.com>
Reviewed by Tim Omernick.
......@@ -75,7 +75,9 @@ - (void)receivedError:(NSError *)error withDataSource:(WebDataSource *)dataSourc
- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
{
WebTextView *view = (WebTextView *)[[[dataSource webFrame] frameView] documentView];
ASSERT([view isKindOfClass:[WebTextView class]]);
[view flushReceivedData];
}
- (BOOL)canProvideDocumentSource
......
......@@ -30,10 +30,12 @@
#import <WebKit/WebSearchableTextView.h>
@class WebDataSource;
@class WebCoreTextDecoder;
@interface WebTextView : WebSearchableTextView <WebDocumentView, WebDocumentText, WebDocumentElement>
{
float _textSizeMultiplier;
WebCoreTextDecoder *_decoder;
}
+ (NSArray *)supportedMIMETypes;
......@@ -41,5 +43,6 @@
- (void)setFixedWidthFont;
- (void)appendReceivedData:(NSData *)data fromDataSource:(WebDataSource *)dataSource;
- (void)flushReceivedData;
@end
......@@ -44,6 +44,8 @@
#import <WebKit/WebViewPrivate.h>
#import <WebKit/WebTextRepresentation.h>
#import <WebCore/WebCoreTextDecoder.h>
#import <Foundation/NSURLResponse.h>
@interface NSTextView (AppKitSecret)
......@@ -100,6 +102,7 @@ - (id)initWithFrame:(NSRect)frame
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_decoder release];
[super dealloc];
}
......@@ -197,7 +200,7 @@ - (void)setDataSource:(WebDataSource *)dataSource
// of data received so far. This is a bad design in that it requires
// WebTextRepresentation to know that it's view is a WebTextView, but this
// bad design already existed.
- (void)appendReceivedData:(NSData *)data fromDataSource:(WebDataSource *)dataSource;
- (void)appendReceivedData:(NSData *)data fromDataSource:(WebDataSource *)dataSource
{
if ([self isRichText]) {
// FIXME: We should try to progressively load RTF.
......@@ -207,8 +210,27 @@ - (void)appendReceivedData:(NSData *)data fromDataSource:(WebDataSource *)dataSo
[self _adjustRichTextFontSizeByRatio:_textSizeMultiplier];
}
} else {
if (!_decoder) {
NSString *textEncodingName = [dataSource textEncodingName];
if (textEncodingName == nil)
textEncodingName = [[self _preferences] defaultTextEncodingName];
_decoder = [[WebCoreTextDecoder alloc] initWithEncodingName:textEncodingName];
}
[self replaceCharactersInRange:NSMakeRange([[self string] length], 0)
withString:[dataSource _stringWithData:data]];
withString:[_decoder decodeData:data]];
}
}
- (void)flushReceivedData
{
if ([self isRichText]) {
// FIXME: We should try to progressively load RTF.
} else {
if (_decoder)
[self replaceCharactersInRange:NSMakeRange([[self string] length], 0)
withString:[_decoder flush]];
}
}
......
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