[webkit-changes] cvs commit: WebCore/kwq KWQTextArea.h
KWQTextArea.mm KWQTextEdit.h KWQTextEdit.mm
Timothy
thatcher at opensource.apple.com
Thu Nov 10 17:18:58 PST 2005
thatcher 05/11/10 17:18:58
Modified: . Tag: Safari-2-0-branch ChangeLog
khtml/rendering Tag: Safari-2-0-branch render_form.cpp
kwq Tag: Safari-2-0-branch KWQTextArea.h KWQTextArea.mm
KWQTextEdit.h KWQTextEdit.mm
Log:
Merged fix from TOT to Safari-2-0-branch
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
Revision Changes Path
No revision
No revision
1.1.2.48 +24 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.1.2.47
retrieving revision 1.1.2.48
diff -u -r1.1.2.47 -r1.1.2.48
--- ChangeLog 10 Nov 2005 23:50:22 -0000 1.1.2.47
+++ ChangeLog 11 Nov 2005 01:18:50 -0000 1.1.2.48
@@ -2,6 +2,30 @@
Merged fix from TOT to Safari-2-0-branch
+ 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-11-10 Timothy Hatcher <timothy at apple.com>
+
+ Merged fix from TOT to Safari-2-0-branch
+
2005-11-10 Eric Seidel <eseidel at apple.com>
Reviewed by ggaren.
No revision
No revision
1.102.8.4 +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.102.8.3
retrieving revision 1.102.8.4
diff -u -r1.102.8.3 -r1.102.8.4
--- render_form.cpp 2 Sep 2005 22:14:09 -0000 1.102.8.3
+++ render_form.cpp 11 Nov 2005 01:18:55 -0000 1.102.8.4
@@ -1530,6 +1530,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
No revision
No revision
1.18.10.1 +2 -0 WebCore/kwq/KWQTextArea.h
Index: KWQTextArea.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQTextArea.h,v
retrieving revision 1.18
retrieving revision 1.18.10.1
diff -u -r1.18 -r1.18.10.1
--- KWQTextArea.h 30 Nov 2004 21:08:49 -0000 1.18
+++ KWQTextArea.h 11 Nov 2005 01:18:56 -0000 1.18.10.1
@@ -34,6 +34,7 @@
KWQTextAreaTextView *textView;
QTextEdit *widget;
NSFont *_font;
+ float _lineHeight;
BOOL wrap;
BOOL inNextValidKeyView;
BOOL inDrawingMachinery;
@@ -43,6 +44,7 @@
- (void)detachQTextEdit;
- (void)setAlignment:(NSTextAlignment)alignment;
+- (void)setLineHeight:(float)lineHeight;
- (void)setBaseWritingDirection:(NSWritingDirection)direction;
- (void)setEditable:(BOOL)flag;
1.72.8.4 +74 -1 WebCore/kwq/KWQTextArea.mm
Index: KWQTextArea.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQTextArea.mm,v
retrieving revision 1.72.8.3
retrieving revision 1.72.8.4
diff -u -r1.72.8.3 -r1.72.8.4
--- KWQTextArea.mm 10 Nov 2005 18:22:34 -0000 1.72.8.3
+++ KWQTextArea.mm 11 Nov 2005 01:18:56 -0000 1.72.8.4
@@ -61,6 +61,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)
@@ -378,6 +379,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
@@ -891,6 +946,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)
@@ -919,4 +992,4 @@
}
}
- at end
+ at end
\ No newline at end of file
1.23.8.1 +1 -0 WebCore/kwq/KWQTextEdit.h
Index: KWQTextEdit.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQTextEdit.h,v
retrieving revision 1.23
retrieving revision 1.23.8.1
diff -u -r1.23 -r1.23.8.1
--- KWQTextEdit.h 10 Dec 2004 22:15:59 -0000 1.23
+++ KWQTextEdit.h 11 Nov 2005 01:18:57 -0000 1.23.8.1
@@ -48,6 +48,7 @@
virtual void setPalette(const QPalette &);
void setAlignment(AlignmentFlags);
+ void setLineHeight(int lineHeight);
void setCursorPosition(int, int);
void getCursorPosition(int *, int *) const;
1.44.8.2 +10 -0 WebCore/kwq/KWQTextEdit.mm
Index: KWQTextEdit.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQTextEdit.mm,v
retrieving revision 1.44.8.1
retrieving revision 1.44.8.2
diff -u -r1.44.8.1 -r1.44.8.2
--- KWQTextEdit.mm 22 Jul 2005 01:18:36 -0000 1.44.8.1
+++ KWQTextEdit.mm 11 Nov 2005 01:18:57 -0000 1.44.8.2
@@ -219,6 +219,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