[webkit-changes] cvs commit: WebKit/WebView.subproj WebTextRepresentation.m WebTextView.h WebTextView.m

Darin darin at opensource.apple.com
Sat Oct 8 21:17:44 PDT 2005


darin       05/10/08 21:17:43

  Modified:    .        ChangeLog WebCore.exp
               WebCore.xcodeproj project.pbxproj
               .        ChangeLog
               WebView.subproj WebTextRepresentation.m WebTextView.h
                        WebTextView.m
  Added:       kwq      WebCoreTextDecoder.h WebCoreTextDecoder.mm
  Log:
  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.
  
  Revision  Changes    Path
  1.225     +15 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.224
  retrieving revision 1.225
  diff -u -r1.224 -r1.225
  --- ChangeLog	9 Oct 2005 03:31:07 -0000	1.224
  +++ ChangeLog	9 Oct 2005 04:17:30 -0000	1.225
  @@ -2,6 +2,21 @@
   
           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 at nypop.com>
  +
  +        Reviewed by Maciej.
  +
           - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4821
             Text in submitted forms should be entity-encoded if the current encoding doesn't support it
   
  
  
  
  1.46      +1 -0      WebCore/WebCore.exp
  
  Index: WebCore.exp
  ===================================================================
  RCS file: /cvs/root/WebCore/WebCore.exp,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- WebCore.exp	6 Oct 2005 15:45:51 -0000	1.45
  +++ WebCore.exp	9 Oct 2005 04:17:31 -0000	1.46
  @@ -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
  
  
  
  1.34      +12 -0     WebCore/WebCore.xcodeproj/project.pbxproj
  
  Index: project.pbxproj
  ===================================================================
  RCS file: /cvs/root/WebCore/WebCore.xcodeproj/project.pbxproj,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- project.pbxproj	5 Oct 2005 08:21:36 -0000	1.33
  +++ project.pbxproj	9 Oct 2005 04:17:33 -0000	1.34
  @@ -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;
   		};
  
  
  
  1.1                  WebCore/kwq/WebCoreTextDecoder.h
  
  Index: WebCoreTextDecoder.h
  ===================================================================
  /*
   * 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
  
  
  
  1.1                  WebCore/kwq/WebCoreTextDecoder.mm
  
  Index: WebCoreTextDecoder.mm
  ===================================================================
  /*
   * 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
  
  
  
  1.3345    +20 -0     WebKit/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebKit/ChangeLog,v
  retrieving revision 1.3344
  retrieving revision 1.3345
  diff -u -r1.3344 -r1.3345
  --- ChangeLog	7 Oct 2005 18:31:46 -0000	1.3344
  +++ ChangeLog	9 Oct 2005 04:17:36 -0000	1.3345
  @@ -1,3 +1,23 @@
  +2005-10-08  Alexey Proskuryakov  <ap at 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 at apple.com>
   
           Reviewed by Tim Omernick.
  
  
  
  1.20      +3 -1      WebKit/WebView.subproj/WebTextRepresentation.m
  
  Index: WebTextRepresentation.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebTextRepresentation.m,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- WebTextRepresentation.m	20 Sep 2005 08:33:06 -0000	1.19
  +++ WebTextRepresentation.m	9 Oct 2005 04:17:42 -0000	1.20
  @@ -75,7 +75,9 @@
   
   - (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
   {
  -
  +    WebTextView *view = (WebTextView *)[[[dataSource webFrame] frameView] documentView];
  +    ASSERT([view isKindOfClass:[WebTextView class]]);
  +    [view flushReceivedData];
   }
   
   - (BOOL)canProvideDocumentSource
  
  
  
  1.21      +3 -0      WebKit/WebView.subproj/WebTextView.h
  
  Index: WebTextView.h
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- WebTextView.h	20 Sep 2005 08:33:06 -0000	1.20
  +++ WebTextView.h	9 Oct 2005 04:17:42 -0000	1.21
  @@ -30,10 +30,12 @@
   #import <WebKit/WebSearchableTextView.h>
   
   @class WebDataSource;
  + at 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
  
  
  
  1.65      +24 -2     WebKit/WebView.subproj/WebTextView.m
  
  Index: WebTextView.m
  ===================================================================
  RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.m,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- WebTextView.m	6 Oct 2005 15:46:12 -0000	1.64
  +++ WebTextView.m	9 Oct 2005 04:17:42 -0000	1.65
  @@ -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 @@
   - (void)dealloc
   {
       [[NSNotificationCenter defaultCenter] removeObserver:self];
  +    [_decoder release];
       [super dealloc];
   }
   
  @@ -197,7 +200,7 @@
   // 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 @@
               [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]];
       }
   }
   
  
  
  



More information about the webkit-changes mailing list