[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:30:26 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 6be32b86b319b8e7dedece3487f73cbe855ca61c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Mar 19 17:04:17 2003 +0000
Reviewed by Ken.
- fixed 3197684 -- <textarea wrap="hard"> behaves incorrectly (bugzilla)
By doing the line breaking inside the KWQ class for textarea we can both remove
the broken lineOfCharAtIndex: method and avoid the n-squared algorithm KHTML uses to
insert hard line breaks.
* khtml/rendering/render_form.cpp: (RenderTextArea::text):
Call textWithHardLineBreaks on widget instead of trying to break lines here.
* kwq/KWQTextEdit.h: Added textWithHardLineBreaks member function. Made text member function
const. Got rid of text(int), paragraphs, paragraphLength, and lineOfChar member functions.
* kwq/KWQTextEdit.mm:
(QTextEdit::text): Made this const, and move code that transforms CRLF and CR into LF
inside KWQTextArea.
(QTextEdit::textWithHardLineBreaks): Added. Calls new textWithHardLineBreaks method.
* kwq/KWQTextArea.h: Added textWithHardLineBreaks method. Removed numLines, textForLine:,
paragrahs, paragraphLength:, textForParagraph:, and lineOfCharAtIndex: methods.
* kwq/KWQTextArea.mm:
(-[KWQTextArea initWithQTextEdit:]): Call [self init] for clarity instead of [super init].
In both cases, we end up calling [self initWithFrame:].
(-[KWQTextArea text]): Added logic for transforming CRLF and CR into LF here instead of at
the KWQTextEdit level.
(-[KWQTextArea textWithHardLineBreaks]): Added. This method uses the layout manager to extract
the characters for one line at a time, and put line breaks in between.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3865 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index c905563..fd36783 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,33 @@
+2003-03-18 Darin Adler <darin at apple.com>
+
+ Reviewed by Ken.
+
+ - fixed 3197684 -- <textarea wrap="hard"> behaves incorrectly (bugzilla)
+
+ By doing the line breaking inside the KWQ class for textarea we can both remove
+ the broken lineOfCharAtIndex: method and avoid the n-squared algorithm KHTML uses to
+ insert hard line breaks.
+
+ * khtml/rendering/render_form.cpp: (RenderTextArea::text):
+ Call textWithHardLineBreaks on widget instead of trying to break lines here.
+
+ * kwq/KWQTextEdit.h: Added textWithHardLineBreaks member function. Made text member function
+ const. Got rid of text(int), paragraphs, paragraphLength, and lineOfChar member functions.
+ * kwq/KWQTextEdit.mm:
+ (QTextEdit::text): Made this const, and move code that transforms CRLF and CR into LF
+ inside KWQTextArea.
+ (QTextEdit::textWithHardLineBreaks): Added. Calls new textWithHardLineBreaks method.
+
+ * kwq/KWQTextArea.h: Added textWithHardLineBreaks method. Removed numLines, textForLine:,
+ paragrahs, paragraphLength:, textForParagraph:, and lineOfCharAtIndex: methods.
+ * kwq/KWQTextArea.mm:
+ (-[KWQTextArea initWithQTextEdit:]): Call [self init] for clarity instead of [super init].
+ In both cases, we end up calling [self initWithFrame:].
+ (-[KWQTextArea text]): Added logic for transforming CRLF and CR into LF here instead of at
+ the KWQTextEdit level.
+ (-[KWQTextArea textWithHardLineBreaks]): Added. This method uses the layout manager to extract
+ the characters for one line at a time, and put line breaks in between.
+
2003-03-18 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
@@ -29,6 +59,7 @@
2003-03-18 Maciej Stachowiak <mjs at apple.com>
+>>>>>>> 1.1521
Reviewed by John.
- fixed 3119663 - document.lastModified returns the wrong date format
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index c905563..fd36783 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,33 @@
+2003-03-18 Darin Adler <darin at apple.com>
+
+ Reviewed by Ken.
+
+ - fixed 3197684 -- <textarea wrap="hard"> behaves incorrectly (bugzilla)
+
+ By doing the line breaking inside the KWQ class for textarea we can both remove
+ the broken lineOfCharAtIndex: method and avoid the n-squared algorithm KHTML uses to
+ insert hard line breaks.
+
+ * khtml/rendering/render_form.cpp: (RenderTextArea::text):
+ Call textWithHardLineBreaks on widget instead of trying to break lines here.
+
+ * kwq/KWQTextEdit.h: Added textWithHardLineBreaks member function. Made text member function
+ const. Got rid of text(int), paragraphs, paragraphLength, and lineOfChar member functions.
+ * kwq/KWQTextEdit.mm:
+ (QTextEdit::text): Made this const, and move code that transforms CRLF and CR into LF
+ inside KWQTextArea.
+ (QTextEdit::textWithHardLineBreaks): Added. Calls new textWithHardLineBreaks method.
+
+ * kwq/KWQTextArea.h: Added textWithHardLineBreaks method. Removed numLines, textForLine:,
+ paragrahs, paragraphLength:, textForParagraph:, and lineOfCharAtIndex: methods.
+ * kwq/KWQTextArea.mm:
+ (-[KWQTextArea initWithQTextEdit:]): Call [self init] for clarity instead of [super init].
+ In both cases, we end up calling [self initWithFrame:].
+ (-[KWQTextArea text]): Added logic for transforming CRLF and CR into LF here instead of at
+ the KWQTextEdit level.
+ (-[KWQTextArea textWithHardLineBreaks]): Added. This method uses the layout manager to extract
+ the characters for one line at a time, and put line breaks in between.
+
2003-03-18 Maciej Stachowiak <mjs at apple.com>
Reviewed by Trey.
@@ -29,6 +59,7 @@
2003-03-18 Maciej Stachowiak <mjs at apple.com>
+>>>>>>> 1.1521
Reviewed by John.
- fixed 3119663 - document.lastModified returns the wrong date format
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 251baef..efa578e 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -1210,6 +1210,9 @@ QString RenderTextArea::text()
TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
if(element()->wrap() == DOM::HTMLTextAreaElementImpl::ta_Physical) {
+#if APPLE_CHANGES
+ txt = w->textWithHardLineBreaks();
+#else
// yeah, QTextEdit has no accessor for getting the visually wrapped text
for (int p=0; p < w->paragraphs(); ++p) {
int pl = w->paragraphLength(p);
@@ -1226,6 +1229,7 @@ QString RenderTextArea::text()
if (p < w->paragraphs() - 1)
txt += QString::fromLatin1("\n");
}
+#endif
}
else
txt = w->text();
diff --git a/WebCore/kwq/KWQTextArea.h b/WebCore/kwq/KWQTextArea.h
index aacce96..f3d6ac1 100644
--- a/WebCore/kwq/KWQTextArea.h
+++ b/WebCore/kwq/KWQTextArea.h
@@ -44,18 +44,13 @@ class QTextEdit;
- (BOOL)wordWrap;
- (void)setText:(NSString *)text;
- (NSString *)text;
-- (int)numLines;
-- (NSString *)textForLine:(int)line;
+- (NSString *)textWithHardLineBreaks;
- (void)selectAll;
- (void)setEditable:(BOOL)flag;
- (BOOL)isEditable;
- (void)setFont:(NSFont *)font;
// paragraph-oriented functions for the benefit of QTextEdit
-- (int)paragraphs;
-- (int)paragraphLength:(int)paragraph;
-- (NSString *)textForParagraph:(int)paragraph;
-- (int)lineOfCharAtIndex:(int)index inParagraph:(int)paragraph;
- (void)getCursorPositionAsIndex:(int *)index inParagraph:(int *)paragraph;
- (void)setCursorPositionToIndex:(int)index inParagraph:(int)paragraph;
diff --git a/WebCore/kwq/KWQTextArea.mm b/WebCore/kwq/KWQTextArea.mm
index 8c199dd..bbeb4b7 100644
--- a/WebCore/kwq/KWQTextArea.mm
+++ b/WebCore/kwq/KWQTextArea.mm
@@ -40,13 +40,7 @@
the user enters a return the line IS broken. This emulates
Mac IE 5.1.
SOFT|VIRTUAL - Text is wrapped, but not actually broken.
- HARD|PHYSICAL - Text is wrapped, and text is broken into seperate lines.
-
- KDE expects a line based widget. It uses a line API to convert text into multiple lines
- when wrapping is set to HARD. To support KDE we implement [textLine] and [numLines].
-
- If the wrap mode HARD KDE will repeatedly call textForLine: (via emulated API in KWQTextEdit)
- to construct the text with inserted \n.
+ HARD|PHYSICAL - Text is wrapped, and text is broken into separate lines.
*/
@interface NSView (KWQTextArea)
@@ -74,7 +68,8 @@ const float LargeNumberForText = 1.0e7;
textFrame.origin.x = textFrame.origin.y = 0;
if (frame.size.width > 0 && frame.size.height > 0)
- textFrame.size = [NSScrollView contentSizeForFrameSize:frame.size hasHorizontalScroller:NO hasVerticalScroller:YES borderType:[self borderType]];
+ textFrame.size = [NSScrollView contentSizeForFrameSize:frame.size
+ hasHorizontalScroller:NO hasVerticalScroller:YES borderType:[self borderType]];
else {
textFrame.size.width = LargeNumberForText;
textFrame.size.height = LargeNumberForText;
@@ -112,7 +107,7 @@ const float LargeNumberForText = 1.0e7;
- initWithQTextEdit:(QTextEdit *)w
{
- [super init];
+ [self init];
widget = w;
[textView setWidget:widget];
@@ -121,7 +116,7 @@ const float LargeNumberForText = 1.0e7;
}
- (void)dealloc
-{
+{
[textView release];
[super dealloc];
@@ -186,39 +181,49 @@ const float LargeNumberForText = 1.0e7;
- (NSString *)text
{
- return [textView string];
-}
-
-- (NSString *)textForLine:(int)line
-{
- NSRange glyphRange = NSMakeRange(0,0), characterRange;
- int lineCount = 0;
- NSLayoutManager *layoutManager = [textView layoutManager];
- unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
+ NSString *text = [textView string];
- while (NSMaxRange(glyphRange) < numberOfGlyphs) {
- [layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
- characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL];
- if (line == lineCount) {
- return [[[textView textStorage] attributedSubstringFromRange:characterRange] string];
- }
- lineCount++;
+ if ([text rangeOfString:@"\r" options:NSLiteralSearch].location != NSNotFound) {
+ NSMutableString *mutableText = [[text mutableCopy] autorelease];
+
+ [mutableText replaceOccurrencesOfString:@"\r\n" withString:@"\n"
+ options:NSLiteralSearch range:NSMakeRange(0, [text length])];
+ [mutableText replaceOccurrencesOfString:@"\r" withString:@"\n"
+ options:NSLiteralSearch range:NSMakeRange(0, [text length])];
+
+ text = mutableText;
}
- return @"";
+
+ return text;
}
-- (int)numLines
+- (NSString *)textWithHardLineBreaks
{
- NSRange glyphRange = NSMakeRange(0,0);
+ NSMutableString *textWithHardLineBreaks = [NSMutableString string];
+
+ NSString *text = [textView string];
NSLayoutManager *layoutManager = [textView layoutManager];
- unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
- int lineCount = 0;
- while (NSMaxRange(glyphRange) < numberOfGlyphs) {
- [layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
- lineCount++;
+ unsigned numberOfGlyphs = [layoutManager numberOfGlyphs];
+ NSRange lineGlyphRange = NSMakeRange(0, 0);
+ while (NSMaxRange(lineGlyphRange) < numberOfGlyphs) {
+ [layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(lineGlyphRange) effectiveRange:&lineGlyphRange];
+ NSRange lineRange = [layoutManager characterRangeForGlyphRange:lineGlyphRange actualGlyphRange:NULL];
+ if ([textWithHardLineBreaks length]) {
+ unichar lastCharacter = [textWithHardLineBreaks characterAtIndex:[textWithHardLineBreaks length] - 1];
+ if (lastCharacter != '\n' && lastCharacter != '\r') {
+ [textWithHardLineBreaks appendString:@"\n"];
+ }
+ }
+ [textWithHardLineBreaks appendString:[text substringWithRange:lineRange]];
}
- return lineCount;
+
+ [textWithHardLineBreaks replaceOccurrencesOfString:@"\r\n" withString:@"\n"
+ options:NSLiteralSearch range:NSMakeRange(0, [textWithHardLineBreaks length])];
+ [textWithHardLineBreaks replaceOccurrencesOfString:@"\r" withString:@"\n"
+ options:NSLiteralSearch range:NSMakeRange(0, [textWithHardLineBreaks length])];
+
+ return textWithHardLineBreaks;
}
- (void)selectAll
@@ -241,7 +246,10 @@ const float LargeNumberForText = 1.0e7;
[super setFrame:frameRect];
if ([self wordWrap]) {
- NSSize contentSize = [NSScrollView contentSizeForFrameSize:frameRect.size hasHorizontalScroller:[self hasHorizontalScroller] hasVerticalScroller:[self hasVerticalScroller] borderType:[self borderType]];
+ NSSize contentSize = [NSScrollView contentSizeForFrameSize:frameRect.size
+ hasHorizontalScroller:[self hasHorizontalScroller]
+ hasVerticalScroller:[self hasVerticalScroller]
+ borderType:[self borderType]];
NSRect textFrame = [textView frame];
textFrame.size.width = contentSize.width;
contentSize.height = LargeNumberForText;
@@ -250,27 +258,37 @@ const float LargeNumberForText = 1.0e7;
}
}
-- (int)paragraphs
+- (void)getCursorPositionAsIndex:(int *)index inParagraph:(int *)paragraph
{
NSString *text = [textView string];
+ NSRange selectedRange = [textView selectedRange];
+
+ if (selectedRange.location == NSNotFound) {
+ *paragraph = 0;
+ *index = 0;
+ return;
+ }
+
int paragraphSoFar = 0;
NSRange searchRange = NSMakeRange(0, [text length]);
while (true) {
+ // FIXME: Doesn't work for CR-separated or CRLF-separated text.
NSRange newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
- if (newlineRange.location == NSNotFound) {
+ if (newlineRange.location == NSNotFound || selectedRange.location <= newlineRange.location) {
break;
}
-
+
paragraphSoFar++;
unsigned advance = newlineRange.location + 1 - searchRange.location;
-
+
searchRange.length -= advance;
searchRange.location += advance;
}
-
- return paragraphSoFar + (searchRange.length == 0 ? 0 : 1);
+
+ *paragraph = paragraphSoFar;
+ *index = selectedRange.location - searchRange.location;
}
static NSRange RangeOfParagraph(NSString *text, int paragraph)
@@ -280,6 +298,7 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
NSRange newlineRange;
while (true) {
+ // FIXME: Doesn't work for CR-separated or CRLF-separated text.
newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
if (newlineRange.location == NSNotFound) {
break;
@@ -311,86 +330,6 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
}
}
-- (int)paragraphLength:(int)paragraph
-{
- NSString *text = [textView string];
- NSRange range = RangeOfParagraph(text, paragraph);
- if (range.location == NSNotFound) {
- return 0;
- } else {
- return range.length;
- }
-}
-
-- (NSString *)textForParagraph:(int)paragraph
-{
- NSString *text = [textView string];
- NSRange range = RangeOfParagraph(text, paragraph);
- if (range.location == NSNotFound) {
- return [NSString string];
- } else {
- return [text substringWithRange:range];
- }
-}
-
-- (int)lineOfCharAtIndex:(int)index inParagraph:(int)paragraph
-{
- NSString *text = [textView string];
- NSRange range = RangeOfParagraph(text, paragraph);
- NSLayoutManager *layoutManager = [textView layoutManager];
-
- if (range.location == NSNotFound) {
- return -1;
- }
-
- NSRange characterMaxRange = NSMakeRange(0, range.location);
- NSRange glyphMaxRange = [layoutManager glyphRangeForCharacterRange:characterMaxRange actualCharacterRange:NULL];
-
- // FIXME: factor line counting code out into something shared
- unsigned numberOfGlyphs = glyphMaxRange.location + glyphMaxRange.length;
- NSRange glyphRange = NSMakeRange(0,0);
- int lineCount = 0;
-
- while (NSMaxRange(glyphRange) < numberOfGlyphs) {
- [layoutManager lineFragmentRectForGlyphAtIndex:NSMaxRange(glyphRange) effectiveRange:&glyphRange];
- lineCount++;
- }
-
- return lineCount;
-}
-
-- (void)getCursorPositionAsIndex:(int *)index inParagraph:(int *)paragraph
-{
- NSString *text = [textView string];
- NSRange selectedRange = [textView selectedRange];
-
- if (selectedRange.location == NSNotFound) {
- *paragraph = 0;
- *index = 0;
- return;
- }
-
- int paragraphSoFar = 0;
- NSRange searchRange = NSMakeRange(0, [text length]);
-
- while (true) {
- NSRange newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
- if (newlineRange.location == NSNotFound || selectedRange.location <= newlineRange.location) {
- break;
- }
-
- paragraphSoFar++;
-
- unsigned advance = newlineRange.location + 1 - searchRange.location;
-
- searchRange.length -= advance;
- searchRange.location += advance;
- }
-
- *paragraph = paragraphSoFar;
- *index = selectedRange.location - searchRange.location;
-}
-
- (void)setCursorPositionToIndex:(int)index inParagraph:(int)paragraph
{
NSString *text = [textView string];
diff --git a/WebCore/kwq/KWQTextEdit.h b/WebCore/kwq/KWQTextEdit.h
index 42ad464..87fad76 100644
--- a/WebCore/kwq/KWQTextEdit.h
+++ b/WebCore/kwq/KWQTextEdit.h
@@ -44,20 +44,16 @@ class QTextEdit : public QScrollView
QTextEdit(QWidget *parent);
+ QString text() const;
void setText(const QString &);
- QString text(int);
- QString text();
-
- int paragraphs() const;
- int paragraphLength(int) const;
- int lineOfChar(int, int);
+ QString textWithHardLineBreaks() const;
WrapStyle wordWrap() const;
void setWordWrap(WrapStyle);
void setTextFormat(TextFormat);
void setTabStopWidth(int);
- bool isReadOnly () const;
- void setReadOnly (bool);
+ bool isReadOnly() const;
+ void setReadOnly(bool);
void getCursorPosition(int *, int *) const;
void setCursorPosition(int, int);
@@ -66,16 +62,17 @@ class QTextEdit : public QScrollView
int verticalScrollBarWidth() const;
int horizontalScrollBarHeight() const;
- void textChanged() { m_textChanged.call(); }
+ void textChanged() { _textChanged.call(); }
FocusPolicy focusPolicy() const;
void setFont(const QFont &);
void clicked();
+
private:
- KWQSignal m_clicked;
- KWQSignal m_textChanged;
+ KWQSignal _clicked;
+ KWQSignal _textChanged;
};
#endif /* QTEXTEDIT_H_ */
diff --git a/WebCore/kwq/KWQTextEdit.mm b/WebCore/kwq/KWQTextEdit.mm
index 60578ad..d76b529 100644
--- a/WebCore/kwq/KWQTextEdit.mm
+++ b/WebCore/kwq/KWQTextEdit.mm
@@ -28,8 +28,8 @@
#import "KWQTextArea.h"
QTextEdit::QTextEdit(QWidget *parent)
- : m_clicked(this, SIGNAL(clicked()))
- , m_textChanged(this, SIGNAL(textChanged()))
+ : _clicked(this, SIGNAL(clicked()))
+ , _textChanged(this, SIGNAL(textChanged()))
{
KWQTextArea *textView = [[KWQTextArea alloc] initWithQTextEdit:this];
setView(textView);
@@ -42,40 +42,16 @@ void QTextEdit::setText(const QString &string)
[textView setText:string.getNSString()];
}
-QString QTextEdit::text()
+QString QTextEdit::text() const
{
KWQTextArea *textView = (KWQTextArea *)getView();
- NSMutableString *text = [[[textView text] mutableCopy] autorelease];
- [text replaceOccurrencesOfString:@"\r\n" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0, [text length])];
- [text replaceOccurrencesOfString:@"\r" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0, [text length])];
- return QString::fromNSString(text);
+ return QString::fromNSString([textView text]);
}
-int QTextEdit::paragraphs() const
+QString QTextEdit::textWithHardLineBreaks() const
{
KWQTextArea *textView = (KWQTextArea *)getView();
- return [textView paragraphs];
-}
-
-int QTextEdit::paragraphLength(int paragraph) const
-{
- KWQTextArea *textView = (KWQTextArea *)getView();
- return [textView paragraphLength:paragraph];
-}
-
-QString QTextEdit::text(int paragraph)
-{
- KWQTextArea *textView = (KWQTextArea *)getView();
- NSMutableString *text = [[[textView textForParagraph:paragraph] mutableCopy] autorelease];
- [text replaceOccurrencesOfString:@"\r\n" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0, [text length])];
- [text replaceOccurrencesOfString:@"\r" withString:@"\n" options:NSLiteralSearch range:NSMakeRange(0, [text length])];
- return QString::fromNSString(text);
-}
-
-int QTextEdit::lineOfChar(int paragraph, int index)
-{
- KWQTextArea *textView = (KWQTextArea *)getView();
- return [textView lineOfCharAtIndex:index inParagraph:paragraph];
+ return QString::fromNSString([textView textWithHardLineBreaks]);
}
void QTextEdit::getCursorPosition(int *paragraph, int *index) const
@@ -154,5 +130,5 @@ QWidget::FocusPolicy QTextEdit::focusPolicy() const
void QTextEdit::clicked()
{
- m_clicked.call();
+ _clicked.call();
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list