[webkit-changes] cvs commit: WebCore/kwq KWQTextArea.h KWQTextArea.mm KWQTextEdit.h KWQTextEdit.mm

Beth bdakin at opensource.apple.com
Mon Oct 3 13:55:05 PDT 2005


bdakin      05/10/03 13:55:05

  Modified:    .        ChangeLog
               .        ChangeLog
               khtml/rendering render_form.cpp
               kwq      KWQTextArea.h KWQTextArea.mm KWQTextEdit.h
                        KWQTextEdit.mm
  Added:       fast/forms textAreaLineHeight-expected.txt
                        textAreaLineHeight.html
  Log:
  
  
  Revision  Changes    Path
  1.4       +10 -0     LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ChangeLog	3 Oct 2005 06:08:53 -0000	1.3
  +++ ChangeLog	3 Oct 2005 20:55:00 -0000	1.4
  @@ -1,3 +1,13 @@
  +2005-10-03  Beth Dakin  <bdakin at apple.com>
  +
  +        Reviewed by Darin.
  +
  +	The new layout test for <rdar://problem/4235722> line-height 
  +	style settings not reflected in textarea.
  +
  +        * fast/forms/textAreaLineHeight-expected.txt: Added.
  +        * fast/forms/textAreaLineHeight.html: Added.
  +
   2005-10-02  Alexey Proskuryakov  <ap at nypop.com>
   
           Reviewed by eseidel.
  
  
  
  1.1                  LayoutTests/fast/forms/textAreaLineHeight-expected.txt
  
  Index: textAreaLineHeight-expected.txt
  ===================================================================
  layer at (0,0) size 785x1183
    RenderCanvas at (0,0) size 785x600
  layer at (0,0) size 785x1183
    RenderBlock {HTML} at (0,0) size 785x1183
      RenderBody {BODY} at (8,8) size 769x1159
        RenderBlock (anonymous) at (0,0) size 769x18
          RenderText {TEXT} at (0,0) size 269x18
            text run at (0,0) width 269: "line-height settings not reflected in textarea"
          RenderBR {BR} at (269,0) size 0x18
        RenderBlock {P} at (0,34) size 769x258
          RenderText {TEXT} at (0,0) size 87x18
            text run at (0,0) width 87: "TEXTAREA"
          RenderBR {BR} at (87,0) size 0x18
          RenderTextArea {TEXTAREA} at (0,18) size 400x200
          RenderText {TEXT} at (400,204) size 4x18
            text run at (400,204) width 4: " "
          RenderBR {BR} at (0,0) size 0x0
          RenderBR {BR} at (0,222) size 0x18
          RenderText {TEXT} at (0,240) size 152x18
            text run at (0,240) width 152: "PARAGRAPH - works"
        RenderBlock {P} at (0,308) size 402x202 [border: (1px dotted #C0C0C0)]
          RenderText {TEXT} at (1,19) size 382x104
            text run at (1,19) width 382: "Demo text here that wraps a bit and should demonstrate"
            text run at (1,71) width 182: "the goodness of line-height"
        RenderBlock (anonymous) at (0,523) size 769x36
          RenderBR {BR} at (0,0) size 0x18
          RenderText {TEXT} at (0,18) size 81x18
            text run at (0,18) width 81: "DIV - works"
          RenderBR {BR} at (81,18) size 0x18
        RenderBlock {DIV} at (0,559) size 402x202 [border: (1px dotted #C0C0C0)]
          RenderText {TEXT} at (1,19) size 382x104
            text run at (1,19) width 382: "Demo text here that wraps a bit and should demonstrate"
            text run at (1,71) width 182: "the goodness of line-height"
        RenderBlock (anonymous) at (0,761) size 769x398
          RenderBR {BR} at (0,0) size 0x18
          RenderBR {BR} at (0,18) size 0x18
          RenderText {TEXT} at (0,36) size 124x18
            text run at (0,36) width 124: "Un-Styled Textarea"
          RenderBR {BR} at (124,36) size 0x18
          RenderTextArea {TEXTAREA} at (2,56) size 167x28
          RenderText {TEXT} at (171,70) size 4x18
            text run at (171,70) width 4: " "
          RenderBR {BR} at (0,0) size 0x0
          RenderBR {BR} at (0,88) size 0x18
          RenderText {TEXT} at (0,106) size 215x18
            text run at (0,106) width 215: "Totally Blank Un-Styled Textarea"
          RenderBR {BR} at (215,106) size 0x18
          RenderTextArea {TEXTAREA} at (2,126) size 167x28
          RenderText {TEXT} at (171,140) size 4x18
            text run at (171,140) width 4: " "
          RenderBR {BR} at (0,0) size 0x0
          RenderBR {BR} at (0,158) size 0x18
          RenderText {TEXT} at (0,176) size 213x18
            text run at (0,176) width 213: "Totally Blank STYLED Textarea"
          RenderBR {BR} at (213,176) size 0x18
          RenderTextArea {TEXTAREA} at (0,194) size 400x200
          RenderText {TEXT} at (0,0) size 0x0
        RenderBlock {P} at (0,1175) size 769x0
  
  
  
  1.1                  LayoutTests/fast/forms/textAreaLineHeight.html
  
  Index: textAreaLineHeight.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
          "http://www.w3.org/TR/html4/strict.dtd">
  <html lang="en">
  <head>
  	<meta http-equiv="content-type" content="text/html; charset=utf-8">
  	<title>StyledTA</title>
  	<meta name="generator" content="BBEdit 8.2">
  	<style type="text/css">
  		.p { 			
  				border: dotted silver 1px;
  				font-style:italic;
  				font-family: Verdana, Arial, Helvetica;
  				font-size: 10pt;
  				line-height:400%;
  				width:400px; height:200px;
  			}	
  	
  	</style>
  </head>
  <body>
  line-height settings not reflected in textarea<br/>
  <p>	TEXTAREA<br/>
  		<textarea id="myTA" class="p">Demo text here that wraps a bit and should demonstrate the goodness of line-height</textarea>
      <br/><br/>PARAGRAPH - works
     		<p class="p">Demo text here that wraps a bit and should demonstrate the goodness of line-height</p>
     <br/>DIV - works<br/>
                  <div class="p">Demo text here that wraps a bit and should demonstrate the goodness of line-height</div>
      <br/><br/>Un-Styled Textarea<br/>
                  <textarea>Demo text here that wraps a bit and should demonstrate the goodness of line-height</textarea>
      <br/><br/>Totally Blank Un-Styled Textarea<br/>
                  <textarea></textarea>
      <br/><br/>Totally Blank STYLED Textarea<br/>
                  <textarea id="myTA" class="p"></textarea>
          
  </p>
  </body>
  </html>
  
  
  
  1.187     +20 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.186
  retrieving revision 1.187
  diff -u -r1.186 -r1.187
  --- ChangeLog	3 Oct 2005 08:55:22 -0000	1.186
  +++ ChangeLog	3 Oct 2005 20:55:00 -0000	1.187
  @@ -1,3 +1,23 @@
  +2005-10-03  Beth Dakin  <bdakin at apple.com>
  +
  +        Reviewed by Darin.
  +
  +	Fix for <rdar://problem/4235722> line-height style settings not reflected in 
  +	textarea. 
  +
  +        * khtml/rendering/render_form.cpp:
  +        (RenderTextArea::setStyle): Make setStyle call new setLineHeight function and
  +				computer correct line height using RenderObject::lineHeight
  +        * kwq/KWQTextArea.h:
  +        * kwq/KWQTextArea.mm:
  +        (-[KWQTextAreaTextView setFont:]): setFont updates lineHeight if necessary.
  +        (-[KWQTextAreaTextView setLineHeight:]): sets the line height
  +        (-[NSTextView _KWQ_updateTypingAttributes:forLineHeight:fontHeight:]): Applies the 
  +				new line height to the paragraph style attributes. 
  +        * kwq/KWQTextEdit.h:
  +        * kwq/KWQTextEdit.mm:
  +        (QTextEdit::setLineHeight): calls setLineHeight in KWQTextAreaTextView
  +
   2005-10-03  Rob Buis  <rwlbuis at xs4all.nl>
   
           Reviewed by eseidel.
  
  
  
  1.124     +2 -0      WebCore/khtml/rendering/render_form.cpp
  
  Index: render_form.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/rendering/render_form.cpp,v
  retrieving revision 1.123
  retrieving revision 1.124
  diff -u -r1.123 -r1.124
  --- render_form.cpp	29 Sep 2005 20:10:57 -0000	1.123
  +++ render_form.cpp	3 Oct 2005 20:55:03 -0000	1.124
  @@ -1497,6 +1497,8 @@
   
       QTextEdit* w = static_cast<QTextEdit*>(m_widget);
       w->setAlignment(textAlignment());
  +    w->setLineHeight(RenderObject::lineHeight(true));
  +
   #if APPLE_CHANGES
       w->setWritingDirection(style()->direction() == RTL ? QPainter::RTL : QPainter::LTR);
   #endif
  
  
  
  1.23      +2 -0      WebCore/kwq/KWQTextArea.h
  
  Index: KWQTextArea.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTextArea.h,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- KWQTextArea.h	24 Jun 2005 05:53:29 -0000	1.22
  +++ KWQTextArea.h	3 Oct 2005 20:55:03 -0000	1.23
  @@ -34,6 +34,7 @@
       KWQTextAreaTextView *textView;
       QTextEdit *widget;
       NSFont *_font;
  +    float _lineHeight;
       BOOL wrap;
       BOOL inNextValidKeyView;
       BOOL inDrawingMachinery;
  @@ -46,6 +47,7 @@
   - (void)detachQTextEdit;
   
   - (void)setAlignment:(NSTextAlignment)alignment;
  +- (void)setLineHeight:(float)lineHeight;
   - (void)setBaseWritingDirection:(NSWritingDirection)direction;
   
   - (void)setEditable:(BOOL)flag;
  
  
  
  1.91      +74 -1     WebCore/kwq/KWQTextArea.mm
  
  Index: KWQTextArea.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTextArea.mm,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- KWQTextArea.mm	27 Sep 2005 22:37:32 -0000	1.90
  +++ KWQTextArea.mm	3 Oct 2005 20:55:04 -0000	1.91
  @@ -67,6 +67,7 @@
   @interface NSTextView (KWQTextArea)
   - (NSParagraphStyle *)_KWQ_typingParagraphStyle;
   - (void)_KWQ_setTypingParagraphStyle:(NSParagraphStyle *)style;
  +- (void)_KWQ_updateTypingAttributes:(NSParagraphStyle *)style forLineHeight:(float)lineHeight fontHeight:(float)fontHeight;
   @end
   
   @interface NSTextStorage (KWQTextArea)
  @@ -541,6 +542,60 @@
       [_font release];
       _font = font;
       [textView setFont:font];
  +    
  +    NSParagraphStyle *style = [textView _KWQ_typingParagraphStyle];
  +    if (_lineHeight) {
  +        ASSERT(style);
  +        [textView _KWQ_updateTypingAttributes:style forLineHeight:_lineHeight fontHeight:([_font ascender] - [_font descender])];
  +    }
  +}
  +
  +- (void)setLineHeight:(float)lineHeight
  +{
  +    NSRange range = [textView rangeForUserParagraphAttributeChange];
  +    if (range.location == NSNotFound)
  +        return;
  +    
  +    _lineHeight = lineHeight;
  +    NSTextStorage *storage = [textView textStorage];
  +    NSParagraphStyle *paraStyle = nil;
  +    
  +    if (storage && range.length > 0) {
  +        unsigned loc = range.location;
  +        unsigned end = NSMaxRange(range);
  +        
  +        [storage beginEditing];
  +        while (loc < end) {
  +            NSRange effectiveRange;
  +            paraStyle = [storage attribute:NSParagraphStyleAttributeName atIndex:loc longestEffectiveRange:&effectiveRange inRange:range];
  +            if (!paraStyle)
  +                paraStyle = [textView defaultParagraphStyle];
  +            if (!paraStyle) 
  +                paraStyle = [NSParagraphStyle defaultParagraphStyle];
  +            if ([paraStyle minimumLineHeight] != lineHeight) {
  +                NSMutableParagraphStyle *newStyle = [paraStyle mutableCopy];
  +                [newStyle setMinimumLineHeight:lineHeight];
  +                [storage addAttribute:NSParagraphStyleAttributeName value:newStyle range:effectiveRange];
  +                [newStyle release];
  +            }
  +            loc = NSMaxRange(effectiveRange);
  +        }
  +        [storage endEditing];
  +        [textView didChangeText];
  +        paraStyle = [storage attribute:NSParagraphStyleAttributeName atIndex:range.location effectiveRange:NULL];
  +    }
  +    
  +    if (!paraStyle) {
  +        paraStyle = [[textView typingAttributes] objectForKey:NSParagraphStyleAttributeName];
  +        if (!paraStyle) 
  +            paraStyle = [textView defaultParagraphStyle];
  +        if (!paraStyle) 
  +            paraStyle = [NSParagraphStyle defaultParagraphStyle];
  +    }
  +    NSMutableParagraphStyle *newStyle = [paraStyle mutableCopy];
  +    [newStyle setMinimumLineHeight:lineHeight];
  +    [textView _KWQ_updateTypingAttributes:newStyle forLineHeight:lineHeight fontHeight:([_font ascender] - [_font descender])];
  +    [newStyle release];
   }
   
   - (void)setTextColor:(NSColor *)color
  @@ -1226,6 +1281,24 @@
       [attributes release];
   }
   
  +- (void)_KWQ_updateTypingAttributes:(NSParagraphStyle *)style forLineHeight:(float)lineHeight fontHeight:(float)fontHeight
  +{
  +    NSDictionary *typingAttrs = [self typingAttributes];
  +    NSMutableDictionary *dict;
  +    float h = (lineHeight / 2.0f) - (fontHeight / 2.0f);
  +    
  +    if (typingAttrs)
  +        dict = [typingAttrs mutableCopy];
  +    else
  +        dict = [[NSMutableDictionary alloc] init];
  +            
  +    [dict setObject:style forKey:NSParagraphStyleAttributeName];
  +    [dict setObject:[NSNumber numberWithFloat:h] forKey:NSBaselineOffsetAttributeName];
  +    
  +    [self setTypingAttributes:dict];
  +    [dict release];
  +}
  +
   @end
   
   @implementation NSTextStorage (KWQTextArea)
  @@ -1254,4 +1327,4 @@
       }
   }
   
  - at end
  + at end
  \ No newline at end of file
  
  
  
  1.28      +1 -0      WebCore/kwq/KWQTextEdit.h
  
  Index: KWQTextEdit.h
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTextEdit.h,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- KWQTextEdit.h	16 Sep 2005 22:42:24 -0000	1.27
  +++ KWQTextEdit.h	3 Oct 2005 20:55:04 -0000	1.28
  @@ -49,6 +49,7 @@
       virtual void setPalette(const QPalette &);
   
       void setAlignment(AlignmentFlags);
  +    void setLineHeight(int lineHeight);
   
       void setCursorPosition(int, int);
       void getCursorPosition(int *, int *) const;
  
  
  
  1.54      +10 -0     WebCore/kwq/KWQTextEdit.mm
  
  Index: KWQTextEdit.mm
  ===================================================================
  RCS file: /cvs/root/WebCore/kwq/KWQTextEdit.mm,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- KWQTextEdit.mm	27 Sep 2005 22:37:32 -0000	1.53
  +++ KWQTextEdit.mm	3 Oct 2005 20:55:04 -0000	1.54
  @@ -344,6 +344,16 @@
       KWQ_UNBLOCK_EXCEPTIONS;
   }
   
  +void QTextEdit::setLineHeight(int lineHeight)
  +{
  +    KWQ_BLOCK_EXCEPTIONS;
  +
  +    KWQTextArea *textArea = static_cast<KWQTextArea *>(getView());
  +    [textArea setLineHeight:lineHeight];
  +
  +    KWQ_UNBLOCK_EXCEPTIONS;
  +}
  +
   void QTextEdit::setWritingDirection(QPainter::TextDirection direction)
   {
       KWQ_BLOCK_EXCEPTIONS;
  
  
  



More information about the webkit-changes mailing list