[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:44:33 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 78156ec684763b37fb9f987fbf3c7dd95059548d
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jun 9 19:36:21 2003 +0000

            Reviewed by John.
    
            - fixed 3277733 -- REGRESSION: \ in JavaScript mishandled when encoding is Japanese (istweb.apple.com)
    
            This is the third time I've fixed handling of backslash and yen sign. Each time I fixed part
            of the problem but either didn't fix the whole thing or caused a regression. This time I did
            more experiments with other browsers, and I came to the conclusion that all other browsers keep
            the backslash character internally unchanged, and only change to the yen sign when displaying
            rather than decoding to the Unicode "yen sign" character. This makes the backslash character
            different from any other, and requires special code, but it's the only way to match the other
            browsers' behavior. This seems to work great; I retested all the backslash/yen bugs from the
            past to make sure I didn't cause new regressions. The only loose end is the DOM API. It's not
            clear whether the DOM API should return the strings with backslashes or with yen signs, but
            we can probably ship 1.0 without getting that 100% right.
    
            * kwq/KWQTextCodec.h: Added backslashAsCurrencySymbol() member function.
            * kwq/KWQTextCodec.mm:
            (QTextCodec::fromUnicode): Removed the old workaround for tilde problems, which is not needed
            now that we are back to using "force ASCII" mode, so tildes are always tildes. Updated the comment
            about the backslash hack to better reflect the new situation and change it to use the new
            backslashAsCurrencySymbol() member function.
            (QTextCodec::backslashAsCurrencySymbol): Added. Returns the yen sign for the encodings where
            it's appropriate. Later might do the same thing with the won sign for Korean, depending on what
            we discover as we research bug 3221037 (Korean currency symbol should replace backslash).
            (KWQTextDecoder::convertUsingTEC): Add back the call to TECSetBasicOptions since we once-again
            want to use force-ASCII mode; we turn backslashes into yen signs at a higher level now; internally
            they are kept as backslashes.
    
            * khtml/xml/dom_docimpl.h: Made setDecoder no longer be inline, and added a decoder member
            function so callers could get the decoder (they need it to figure out what to do with
            backslashes).
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::setDecoder): Made this no longer be an inline. Also made sure it derefs the
            existing decoder. This probably does not happen in practice, but the old version would leak
            if it was ever called twice on the same document.
    
            * kwq/KWQString.mm: (QString::replace): Made sure that the case of replacing a character
            with the same character has an early out, since that's now the common case with this
            "map backslash to currency character if needed" feature.
    
            * khtml/xml/dom_stringimpl.h: Made capitalize() const and added a new replace() member function.
            * khtml/xml/dom_stringimpl.cpp: (DOMStringImpl::replace): Implemented this new function
            that replaces one character with another. Returns the existing string if there is no replacing
            to do, otherwise makes a new one.
    
            * khtml/rendering/render_object.h: Added backslashAsCurrencySymbol() member function.
            * khtml/rendering/render_object.cpp: (RenderObject::backslashAsCurrencySymbol): Added.
            Helper function so render objects have an easier time digging for the "do I need to turn
            the backslashes into currency symbols" flag.
    
            * kwq/KWQKHTMLPart.h: Added backslashAsCurrencySymbol() member function.
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPart::setTitle): Convert title to use yen sign.
            (KWQKHTMLPart::setStatusBarText): Convert status bar text to use yen sign.
            (KWQKHTMLPart::runJavaScriptAlert): Convert message text to use yen sign.
            (KWQKHTMLPart::runJavaScriptConfirm): Convert message text to use yen sign.
            (KWQKHTMLPart::runJavaScriptPrompt): Convert message text and default value to use yen sign,
            convert result back from yen sign to backslash.
            (KWQKHTMLPart::attributedString): Convert pieces of text to use yen sign when building up
            the attributed text.
            (KWQKHTMLPart::backslashAsCurrencySymbol): Added.
            Helper function so render objects have an easier time digging for the "do I need to turn
            the backslashes into currency symbols" flag.
    
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge selectedString]): Convert text to use yen sign before returning to WebKit.
            (-[WebCoreBridge elementAtPoint:]): Convert title and alt strings to use yen sign before
            returning them to WebKit.
    
            * khtml/rendering/render_form.cpp:
            (RenderSubmitButton::rawText): Convert button label to use yen sign.
            (RenderLineEdit::updateFromElement): Convert text for line edit to use yen sign.
            (RenderLineEdit::slotTextChanged): Convert yen sign to backslash on the way in from line edit.
            (RenderSelect::updateFromElement): Convert text for select items to use yen sign.
            (RenderTextArea::updateFromElement): Convert text for text areas to use yen sign.
            (RenderTextArea::text): Convert yen sign to backslash on the way in from text area.
            * khtml/rendering/render_image.cpp:
            (RenderImage::paintObject): Convert alt text to use yen sign before drawing it.
            * khtml/rendering/render_text.cpp:
            (RenderText::RenderText): Convert text to use yen sign before drawing it.
            (RenderText::setText): Ditto.
    
            - fix a problem that was bugging the shit out of me where we kept rebuilding config.h
    
            * Makefile.am: Use the config-timestamp file to decide when to remake config.h so
            we don't end up making it over and over again. Also don't bother to grep out NO_LICENSE
            any more since that's long gone.
            * .cvsignore: Ignore the config-timestamp file.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4502 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/.cvsignore b/WebCore/.cvsignore
index 221fc8c..bb62829 100644
--- a/WebCore/.cvsignore
+++ b/WebCore/.cvsignore
@@ -1,4 +1,5 @@
 Makefile
 Makefile.in
+config-timestamp
 previous-clean-timestamp
 previous-js-clean-timestamp
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 5ac40df..85fbbf2 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,6 +1,97 @@
+2003-06-09  Darin Adler  <darin at apple.com>
+
+        Reviewed by John.
+
+        - fixed 3277733 -- REGRESSION: \ in JavaScript mishandled when encoding is Japanese (istweb.apple.com)
+        
+        This is the third time I've fixed handling of backslash and yen sign. Each time I fixed part
+        of the problem but either didn't fix the whole thing or caused a regression. This time I did
+        more experiments with other browsers, and I came to the conclusion that all other browsers keep
+        the backslash character internally unchanged, and only change to the yen sign when displaying
+        rather than decoding to the Unicode "yen sign" character. This makes the backslash character
+        different from any other, and requires special code, but it's the only way to match the other
+        browsers' behavior. This seems to work great; I retested all the backslash/yen bugs from the
+        past to make sure I didn't cause new regressions. The only loose end is the DOM API. It's not
+        clear whether the DOM API should return the strings with backslashes or with yen signs, but
+        we can probably ship 1.0 without getting that 100% right.
+
+        * kwq/KWQTextCodec.h: Added backslashAsCurrencySymbol() member function.
+        * kwq/KWQTextCodec.mm:
+        (QTextCodec::fromUnicode): Removed the old workaround for tilde problems, which is not needed
+        now that we are back to using "force ASCII" mode, so tildes are always tildes. Updated the comment
+        about the backslash hack to better reflect the new situation and change it to use the new
+        backslashAsCurrencySymbol() member function.
+        (QTextCodec::backslashAsCurrencySymbol): Added. Returns the yen sign for the encodings where
+        it's appropriate. Later might do the same thing with the won sign for Korean, depending on what
+        we discover as we research bug 3221037 (Korean currency symbol should replace backslash).
+        (KWQTextDecoder::convertUsingTEC): Add back the call to TECSetBasicOptions since we once-again
+        want to use force-ASCII mode; we turn backslashes into yen signs at a higher level now; internally
+        they are kept as backslashes.
+
+        * khtml/xml/dom_docimpl.h: Made setDecoder no longer be inline, and added a decoder member
+        function so callers could get the decoder (they need it to figure out what to do with
+        backslashes).
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::setDecoder): Made this no longer be an inline. Also made sure it derefs the
+        existing decoder. This probably does not happen in practice, but the old version would leak
+        if it was ever called twice on the same document.
+
+        * kwq/KWQString.mm: (QString::replace): Made sure that the case of replacing a character
+        with the same character has an early out, since that's now the common case with this
+        "map backslash to currency character if needed" feature.
+
+        * khtml/xml/dom_stringimpl.h: Made capitalize() const and added a new replace() member function.
+        * khtml/xml/dom_stringimpl.cpp: (DOMStringImpl::replace): Implemented this new function
+        that replaces one character with another. Returns the existing string if there is no replacing
+        to do, otherwise makes a new one.
+
+        * khtml/rendering/render_object.h: Added backslashAsCurrencySymbol() member function.
+        * khtml/rendering/render_object.cpp: (RenderObject::backslashAsCurrencySymbol): Added.
+        Helper function so render objects have an easier time digging for the "do I need to turn
+        the backslashes into currency symbols" flag.
+
+        * kwq/KWQKHTMLPart.h: Added backslashAsCurrencySymbol() member function.
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::setTitle): Convert title to use yen sign.
+        (KWQKHTMLPart::setStatusBarText): Convert status bar text to use yen sign.
+        (KWQKHTMLPart::runJavaScriptAlert): Convert message text to use yen sign.
+        (KWQKHTMLPart::runJavaScriptConfirm): Convert message text to use yen sign.
+        (KWQKHTMLPart::runJavaScriptPrompt): Convert message text and default value to use yen sign,
+        convert result back from yen sign to backslash.
+        (KWQKHTMLPart::attributedString): Convert pieces of text to use yen sign when building up
+        the attributed text.
+        (KWQKHTMLPart::backslashAsCurrencySymbol): Added.
+        Helper function so render objects have an easier time digging for the "do I need to turn
+        the backslashes into currency symbols" flag.
+
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge selectedString]): Convert text to use yen sign before returning to WebKit.
+        (-[WebCoreBridge elementAtPoint:]): Convert title and alt strings to use yen sign before
+        returning them to WebKit.
+
+        * khtml/rendering/render_form.cpp:
+        (RenderSubmitButton::rawText): Convert button label to use yen sign.
+        (RenderLineEdit::updateFromElement): Convert text for line edit to use yen sign.
+        (RenderLineEdit::slotTextChanged): Convert yen sign to backslash on the way in from line edit.
+        (RenderSelect::updateFromElement): Convert text for select items to use yen sign.
+        (RenderTextArea::updateFromElement): Convert text for text areas to use yen sign.
+        (RenderTextArea::text): Convert yen sign to backslash on the way in from text area.
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::paintObject): Convert alt text to use yen sign before drawing it.
+        * khtml/rendering/render_text.cpp:
+        (RenderText::RenderText): Convert text to use yen sign before drawing it.
+        (RenderText::setText): Ditto.
+
+        - fix a problem that was bugging the shit out of me where we kept rebuilding config.h
+
+        * Makefile.am: Use the config-timestamp file to decide when to remake config.h so
+        we don't end up making it over and over again. Also don't bother to grep out NO_LICENSE
+        any more since that's long gone.
+        * .cvsignore: Ignore the config-timestamp file.
+
 === Safari-83 ===
 
-2003-06-07  Darin Adler  <darin at apple.com>
+2003-06-09  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
 
@@ -2480,8 +2571,6 @@
 
 === Safari-75 ===
 
-=== Safari-74 ===
-
 2003-04-24  John Sullivan  <sullivan at apple.com>
 
 	- fixed 3151501 -- Toggling "Check Spelling As You Type" in a
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5ac40df..85fbbf2 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,6 +1,97 @@
+2003-06-09  Darin Adler  <darin at apple.com>
+
+        Reviewed by John.
+
+        - fixed 3277733 -- REGRESSION: \ in JavaScript mishandled when encoding is Japanese (istweb.apple.com)
+        
+        This is the third time I've fixed handling of backslash and yen sign. Each time I fixed part
+        of the problem but either didn't fix the whole thing or caused a regression. This time I did
+        more experiments with other browsers, and I came to the conclusion that all other browsers keep
+        the backslash character internally unchanged, and only change to the yen sign when displaying
+        rather than decoding to the Unicode "yen sign" character. This makes the backslash character
+        different from any other, and requires special code, but it's the only way to match the other
+        browsers' behavior. This seems to work great; I retested all the backslash/yen bugs from the
+        past to make sure I didn't cause new regressions. The only loose end is the DOM API. It's not
+        clear whether the DOM API should return the strings with backslashes or with yen signs, but
+        we can probably ship 1.0 without getting that 100% right.
+
+        * kwq/KWQTextCodec.h: Added backslashAsCurrencySymbol() member function.
+        * kwq/KWQTextCodec.mm:
+        (QTextCodec::fromUnicode): Removed the old workaround for tilde problems, which is not needed
+        now that we are back to using "force ASCII" mode, so tildes are always tildes. Updated the comment
+        about the backslash hack to better reflect the new situation and change it to use the new
+        backslashAsCurrencySymbol() member function.
+        (QTextCodec::backslashAsCurrencySymbol): Added. Returns the yen sign for the encodings where
+        it's appropriate. Later might do the same thing with the won sign for Korean, depending on what
+        we discover as we research bug 3221037 (Korean currency symbol should replace backslash).
+        (KWQTextDecoder::convertUsingTEC): Add back the call to TECSetBasicOptions since we once-again
+        want to use force-ASCII mode; we turn backslashes into yen signs at a higher level now; internally
+        they are kept as backslashes.
+
+        * khtml/xml/dom_docimpl.h: Made setDecoder no longer be inline, and added a decoder member
+        function so callers could get the decoder (they need it to figure out what to do with
+        backslashes).
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::setDecoder): Made this no longer be an inline. Also made sure it derefs the
+        existing decoder. This probably does not happen in practice, but the old version would leak
+        if it was ever called twice on the same document.
+
+        * kwq/KWQString.mm: (QString::replace): Made sure that the case of replacing a character
+        with the same character has an early out, since that's now the common case with this
+        "map backslash to currency character if needed" feature.
+
+        * khtml/xml/dom_stringimpl.h: Made capitalize() const and added a new replace() member function.
+        * khtml/xml/dom_stringimpl.cpp: (DOMStringImpl::replace): Implemented this new function
+        that replaces one character with another. Returns the existing string if there is no replacing
+        to do, otherwise makes a new one.
+
+        * khtml/rendering/render_object.h: Added backslashAsCurrencySymbol() member function.
+        * khtml/rendering/render_object.cpp: (RenderObject::backslashAsCurrencySymbol): Added.
+        Helper function so render objects have an easier time digging for the "do I need to turn
+        the backslashes into currency symbols" flag.
+
+        * kwq/KWQKHTMLPart.h: Added backslashAsCurrencySymbol() member function.
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::setTitle): Convert title to use yen sign.
+        (KWQKHTMLPart::setStatusBarText): Convert status bar text to use yen sign.
+        (KWQKHTMLPart::runJavaScriptAlert): Convert message text to use yen sign.
+        (KWQKHTMLPart::runJavaScriptConfirm): Convert message text to use yen sign.
+        (KWQKHTMLPart::runJavaScriptPrompt): Convert message text and default value to use yen sign,
+        convert result back from yen sign to backslash.
+        (KWQKHTMLPart::attributedString): Convert pieces of text to use yen sign when building up
+        the attributed text.
+        (KWQKHTMLPart::backslashAsCurrencySymbol): Added.
+        Helper function so render objects have an easier time digging for the "do I need to turn
+        the backslashes into currency symbols" flag.
+
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge selectedString]): Convert text to use yen sign before returning to WebKit.
+        (-[WebCoreBridge elementAtPoint:]): Convert title and alt strings to use yen sign before
+        returning them to WebKit.
+
+        * khtml/rendering/render_form.cpp:
+        (RenderSubmitButton::rawText): Convert button label to use yen sign.
+        (RenderLineEdit::updateFromElement): Convert text for line edit to use yen sign.
+        (RenderLineEdit::slotTextChanged): Convert yen sign to backslash on the way in from line edit.
+        (RenderSelect::updateFromElement): Convert text for select items to use yen sign.
+        (RenderTextArea::updateFromElement): Convert text for text areas to use yen sign.
+        (RenderTextArea::text): Convert yen sign to backslash on the way in from text area.
+        * khtml/rendering/render_image.cpp:
+        (RenderImage::paintObject): Convert alt text to use yen sign before drawing it.
+        * khtml/rendering/render_text.cpp:
+        (RenderText::RenderText): Convert text to use yen sign before drawing it.
+        (RenderText::setText): Ditto.
+
+        - fix a problem that was bugging the shit out of me where we kept rebuilding config.h
+
+        * Makefile.am: Use the config-timestamp file to decide when to remake config.h so
+        we don't end up making it over and over again. Also don't bother to grep out NO_LICENSE
+        any more since that's long gone.
+        * .cvsignore: Ignore the config-timestamp file.
+
 === Safari-83 ===
 
-2003-06-07  Darin Adler  <darin at apple.com>
+2003-06-09  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
 
@@ -2480,8 +2571,6 @@
 
 === Safari-75 ===
 
-=== Safari-74 ===
-
 2003-04-24  John Sullivan  <sullivan at apple.com>
 
 	- fixed 3151501 -- Toggling "Check Spelling As You Type" in a
diff --git a/WebCore/Makefile.am b/WebCore/Makefile.am
index 580ac2b..b1cf396 100644
--- a/WebCore/Makefile.am
+++ b/WebCore/Makefile.am
@@ -1,6 +1,6 @@
 SUBDIRS = khtml kwq
 
-all-am: previous-clean-timestamp previous-js-clean-timestamp
+all-am: previous-clean-timestamp previous-js-clean-timestamp config-timestamp
 	pbxbuild -buildstyle $(BUILDSTYLE) OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS) 
 clean-am:
 	pbxbuild clean OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS) 
@@ -11,13 +11,13 @@ clean-am:
 WebCore-combined.exp: WebCore.exp WebCore-tests.exp previous-clean-timestamp
 	cat $^ > $@
 
-config.h: ../config.h previous-clean-timestamp
-	grep -v NO_LICENSE ../config.h > new-config.h
-	if cmp -s config.h new-config.h; then \
-		rm -f new-config.h; \
-	else \
-		mv new-config.h config.h; \
+config.h: config-timestamp
+
+config-timestamp: ../config.h previous-clean-timestamp
+	if ! cmp -s config.h ../config.h; then \
+	    cat ../config.h > config.h; \
 	fi
+	touch $@
 
 noinst_DATA = WebCore-combined.exp
 noinst_HEADERS = config.h
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index bbd5154..4ff2be1 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -322,6 +322,7 @@ QString RenderSubmitButton::rawText()
 {
     QString value = element()->value().isEmpty() ? defaultLabel() : element()->value().string();
     value = value.stripWhiteSpace();
+    value.replace('\\', backslashAsCurrencySymbol());
 #if APPLE_CHANGES
     return value;
 #else
@@ -546,12 +547,15 @@ void RenderLineEdit::updateFromElement()
     if ( w->maxLength() != ml )
         w->setMaxLength( ml );
 
-    if (element()->value().string() != w->text()) {
+    QString newText = element()->value().string();
+    newText.replace('\\', backslashAsCurrencySymbol());
+
+    if (newText != w->text()) {
         w->blockSignals(true);
         int pos = w->cursorPosition();
 
         m_updating = true;
-        w->setText(element()->value().string());
+        w->setText(newText);
         m_updating = false;
         
         w->setEdited( false );
@@ -571,7 +575,9 @@ void RenderLineEdit::slotTextChanged(const QString &string)
     // don't use setValue here!
     if (m_updating) // Don't alter m_value if we are in the middle of initing the control, since
         return;     // we may have gotten our initial value from the attribute.
-    element()->m_value = string;
+    QString newText = string;
+    newText.replace(backslashAsCurrencySymbol(), '\\');
+    element()->m_value = newText;
 }
 
 void RenderLineEdit::select()
@@ -963,21 +969,21 @@ void RenderSelect::updateFromElement()
                 DOMString text = listItems[listIndex]->getAttribute(ATTR_LABEL);
                 if (text.isNull())
                     text = "";
+                QString label = QString(text.implementation()->s, text.implementation()->l);
+                label.replace('\\', backslashAsCurrencySymbol());
 
                 if(m_useListBox) {
 #if APPLE_CHANGES
-                    static_cast<KListBox*>(m_widget)
-                        ->insertGroupLabel(QString(text.implementation()->s, text.implementation()->l), listIndex);
+                    static_cast<KListBox*>(m_widget)->insertGroupLabel(label, listIndex);
 #else
-                    QListBoxText *item = new QListBoxText(QString(text.implementation()->s, text.implementation()->l));
+                    QListBoxText *item = new QListBoxText(label);
                     static_cast<KListBox*>(m_widget)
                         ->insertItem(item, listIndex);
                     item->setSelectable(false);
 #endif
                 }
                 else
-                    static_cast<KComboBox*>(m_widget)
-                        ->insertItem(QString(text.implementation()->s, text.implementation()->l), listIndex);
+                    static_cast<KComboBox*>(m_widget)->insertItem(label, listIndex);
             }
             else if (listItems[listIndex]->id() == ID_OPTION) {
                 DOMString text = static_cast<HTMLOptionElementImpl*>(listItems[listIndex])->text();
@@ -985,13 +991,13 @@ void RenderSelect::updateFromElement()
                     text = "";
                 if (listItems[listIndex]->parentNode()->id() == ID_OPTGROUP)
                     text = DOMString("    ")+text;
+                QString itemText = QString(text.implementation()->s, text.implementation()->l);
+                itemText.replace('\\', backslashAsCurrencySymbol());
 
                 if(m_useListBox)
-                    static_cast<KListBox*>(m_widget)
-                        ->insertItem(QString(text.implementation()->s, text.implementation()->l), listIndex);
+                    static_cast<KListBox*>(m_widget)->insertItem(itemText, listIndex);
                 else
-                    static_cast<KComboBox*>(m_widget)
-                        ->insertItem(QString(text.implementation()->s, text.implementation()->l), listIndex);
+                    static_cast<KComboBox*>(m_widget)->insertItem(itemText, listIndex);
             }
             else
                 KHTMLAssert(false);
@@ -1342,6 +1348,7 @@ void RenderTextArea::updateFromElement()
     w->setReadOnly(element()->readOnly());
     w->setAlignment(style()->direction() == RTL ? Qt::AlignRight : Qt::AlignLeft);
     QString text = element()->value().string();
+    text.replace('\\', backslashAsCurrencySymbol());
     if (w->text() != text) {
         w->blockSignals(true);
         int line, col;
@@ -1392,6 +1399,7 @@ QString RenderTextArea::text()
     else
         txt = w->text();
 
+    txt.replace(backslashAsCurrencySymbol(), '\\');
     return txt;
 }
 
diff --git a/WebCore/khtml/rendering/render_image.cpp b/WebCore/khtml/rendering/render_image.cpp
index 633d16b..db8cc62 100644
--- a/WebCore/khtml/rendering/render_image.cpp
+++ b/WebCore/khtml/rendering/render_image.cpp
@@ -236,6 +236,7 @@ void RenderImage::paintObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
             
             if(!alt.isEmpty()) {
                 QString text = alt.string();
+                text.replace('\\', backslashAsCurrencySymbol());
                 p->setFont (style()->font());
                 p->setPen (style()->color());
                 int ax = _tx + leftBorder + leftPad;
@@ -267,6 +268,7 @@ void RenderImage::paintObject(QPainter *p, int /*_x*/, int /*_y*/, int /*_w*/, i
             }
             if(!alt.isEmpty()) {
                 QString text = alt.string();
+                text.replace('\\', backslashAsCurrencySymbol());
                 p->setFont(style()->font());
                 p->setPen( style()->color() );
                 int ax = _tx + leftBorder + leftPad + 2;
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 3bb803a..592d532 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -1591,3 +1591,24 @@ void RenderObject::getTextDecorationColors(int decorations, QColor& underline, Q
             linethrough = curr->style()->color();
     }        
 }
+
+QChar RenderObject::backslashAsCurrencySymbol() const
+{
+#if !APPLE_CHANGES
+    return '\\';
+#else
+    NodeImpl *node = element();
+    if (!node)
+        return '\\';
+    DocumentImpl *document = node->getDocument();
+    if (!document)
+        return '\\';
+    Decoder *decoder = document->decoder();
+    if (!decoder)
+        return '\\';
+    const QTextCodec *codec = decoder->codec();
+    if (!codec)
+        return '\\';
+    return codec->backslashAsCurrencySymbol();
+#endif
+}
diff --git a/WebCore/khtml/rendering/render_object.h b/WebCore/khtml/rendering/render_object.h
index 055acee..815f333 100644
--- a/WebCore/khtml/rendering/render_object.h
+++ b/WebCore/khtml/rendering/render_object.h
@@ -598,6 +598,10 @@ public:
     const QFontMetrics &fontMetrics(bool firstLine) const {
 	return style( firstLine )->fontMetrics();
     }
+
+    // Convenience, to avoid repeating the code to dig down to get this.
+    QChar backslashAsCurrencySymbol() const;
+
 protected:
     virtual void selectionStartEnd(int& spos, int& epos);
 
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index f5046d3..00f40ac 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -330,7 +330,10 @@ RenderText::RenderText(DOM::NodeImpl* node, DOMStringImpl *_str)
 #endif
 
     str = _str;
-    if(str) str->ref();
+    if (str) {
+        str = str->replace('\\', backslashAsCurrencySymbol());
+        str->ref();
+    }
     KHTMLAssert(!str || !str->l || str->s);
 
     m_selectionState = SelectionNone;
@@ -1109,19 +1112,22 @@ void RenderText::setText(DOMStringImpl *text, bool force)
 #endif
     if( !force && str == text ) return;
     if(str) str->deref();
-    str = text;
 
-    if ( str && style() ) {
-        if ( style()->fontVariant() == SMALL_CAPS )
-            str = str->upper();
-        else
-            switch(style()->textTransform()) {
-            case CAPITALIZE:   str = str->capitalize();  break;
-            case UPPERCASE:   str = str->upper();       break;
-            case LOWERCASE:  str = str->lower();       break;
-            case NONE:
-            default:;
-            }
+    str = text;
+    if (str) {
+        str = str->replace('\\', backslashAsCurrencySymbol());
+        if ( style() ) {
+            if ( style()->fontVariant() == SMALL_CAPS )
+                str = str->upper();
+            else
+                switch(style()->textTransform()) {
+                case CAPITALIZE:   str = str->capitalize();  break;
+                case UPPERCASE:   str = str->upper();       break;
+                case LOWERCASE:  str = str->lower();       break;
+                case NONE:
+                default:;
+                }
+        }
         str->ref();
     }
 
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 3b621aa..4b78bf0 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -2288,6 +2288,15 @@ void DocumentImpl::removeCheckedRadioButton(HTMLInputElementImpl *b)
 
 #if APPLE_CHANGES
 
+void DocumentImpl::setDecoder(Decoder *decoder)
+{
+    decoder->ref();
+    if (m_decoder) {
+        m_decoder->deref();
+    }
+    m_decoder = decoder;
+}
+
 QString DocumentImpl::completeURL(const QString &URL)
 {
     return KURL(baseURL(), URL, m_decoder ? m_decoder->codec() : 0).url();
@@ -2335,7 +2344,6 @@ bool DocumentImpl::hasSecureForm() const
     return m_secureForms > 0;
 }
 
-#if APPLE_CHANGES
 void DocumentImpl::setShouldCreateRenderers(bool f)
 {
     m_createRenderers = f;
@@ -2345,8 +2353,6 @@ bool DocumentImpl::shouldCreateRenderers()
 {
     return m_createRenderers;
 }
-#endif
-    
 
 #endif // APPLE_CHANGES
 
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index aa65710..d4913cd 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -263,7 +263,6 @@ public:
     void setBaseTarget(const QString& baseTarget) { m_baseTarget = baseTarget; }
 
 #if APPLE_CHANGES
-    void setDecoder(khtml::Decoder *d) { m_decoder = d; d->ref();}
     QString completeURL(const QString &);
 #else
     QString completeURL(const QString& url) { return KURL(baseURL(),url).url(); };
@@ -544,6 +543,9 @@ public:
     void setShouldCreateRenderers(bool f);
     bool shouldCreateRenderers();
     
+    void setDecoder(khtml::Decoder *);
+    khtml::Decoder *decoder() const { return m_decoder; }
+
 private:
     bool m_inPageCache;
     int m_passwordFields;
diff --git a/WebCore/khtml/xml/dom_stringimpl.cpp b/WebCore/khtml/xml/dom_stringimpl.cpp
index e266902..9773d90 100644
--- a/WebCore/khtml/xml/dom_stringimpl.cpp
+++ b/WebCore/khtml/xml/dom_stringimpl.cpp
@@ -281,7 +281,7 @@ DOMStringImpl *DOMStringImpl::upper() const
     return c;
 }
 
-DOMStringImpl *DOMStringImpl::capitalize()
+DOMStringImpl *DOMStringImpl::capitalize() const
 {
     DOMStringImpl *c = new DOMStringImpl;
     if(!l) return c;
@@ -324,4 +324,30 @@ int DOMStringImpl::toInt(bool *ok) const
     return QConstString(s, i).string().toInt(ok);
 }
 
+DOMStringImpl *DOMStringImpl::replace(QChar oldC, QChar newC)
+{
+    if (oldC == newC)
+        return this;
+    unsigned i;
+    for (i = 0; i != l; ++i)
+	if (s[i] == oldC)
+            break;
+    if (i == l)
+        return this;
+
+    DOMStringImpl *c = new DOMStringImpl;
+
+    c->s = QT_ALLOC_QCHAR_VEC(l);
+    c->l = l;
+
+    for (i = 0; i != l; ++i) {
+        QChar ch = s[i];
+	if (ch == oldC)
+            ch = newC;
+        c->s[i] = ch;
+    }
+
+    return c;
+}
+
 } // namespace DOM
diff --git a/WebCore/khtml/xml/dom_stringimpl.h b/WebCore/khtml/xml/dom_stringimpl.h
index 0daa719..d5c073e 100644
--- a/WebCore/khtml/xml/dom_stringimpl.h
+++ b/WebCore/khtml/xml/dom_stringimpl.h
@@ -86,7 +86,10 @@ public:
     bool isLower() const;
     DOMStringImpl *lower() const;
     DOMStringImpl *upper() const;
-    DOMStringImpl *capitalize();
+    DOMStringImpl *capitalize() const;
+
+    // This modifies the string in place if there is only one ref, makes a new string otherwise.
+    DOMStringImpl *replace(QChar, QChar);
 
     unsigned int l;
     QChar *s;
diff --git a/WebCore/kwq/KWQKHTMLPart.h b/WebCore/kwq/KWQKHTMLPart.h
index c56017b..73bbdbc 100644
--- a/WebCore/kwq/KWQKHTMLPart.h
+++ b/WebCore/kwq/KWQKHTMLPart.h
@@ -205,6 +205,9 @@ public:
     void setUsesInactiveTextBackgroundColor(bool u) { _usesInactiveTextBackgroundColor = u; }
     bool usesInactiveTextBackgroundColor() const { return _usesInactiveTextBackgroundColor; }
 
+    // Convenience, to avoid repeating the code to dig down to get this.
+    QChar backslashAsCurrencySymbol() const;
+
 private:
     virtual void khtmlMousePressEvent(khtml::MousePressEvent *);
     virtual void khtmlMouseDoubleClickEvent(khtml::MouseDoubleClickEvent *);
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index abb8eed..1289133 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -650,12 +650,16 @@ KHTMLView *KWQKHTMLPart::view() const
 
 void KWQKHTMLPart::setTitle(const DOMString &title)
 {
-    [_bridge setTitle:title.string().getNSString()];
+    QString text = title.string();
+    text.replace('\\', backslashAsCurrencySymbol());
+    [_bridge setTitle:text.getNSString()];
 }
 
 void KWQKHTMLPart::setStatusBarText(const QString &status)
 {
-    [_bridge setStatusText:status.getNSString()];
+    QString text = status;
+    text.replace('\\', backslashAsCurrencySymbol());
+    [_bridge setStatusText:text.getNSString()];
 }
 
 void KWQKHTMLPart::scheduleClose()
@@ -1168,21 +1172,33 @@ void KWQKHTMLPart::sendResizeEvent()
 
 void KWQKHTMLPart::runJavaScriptAlert(const QString &message)
 {
-    [_bridge runJavaScriptAlertPanelWithMessage:message.getNSString()];
+    QString text = message;
+    text.replace('\\', backslashAsCurrencySymbol());
+    [_bridge runJavaScriptAlertPanelWithMessage:text.getNSString()];
 }
 
 bool KWQKHTMLPart::runJavaScriptConfirm(const QString &message)
 {
-    return [_bridge runJavaScriptConfirmPanelWithMessage:message.getNSString()];
+    QString text = message;
+    text.replace('\\', backslashAsCurrencySymbol());
+    return [_bridge runJavaScriptConfirmPanelWithMessage:text.getNSString()];
 }
 
 bool KWQKHTMLPart::runJavaScriptPrompt(const QString &prompt, const QString &defaultValue, QString &result)
 {
+    QString promptText = prompt;
+    promptText.replace('\\', backslashAsCurrencySymbol());
+    QString defaultValueText = defaultValue;
+    defaultValueText.replace('\\', backslashAsCurrencySymbol());
+
     NSString *returnedText;
     bool ok = [_bridge runJavaScriptTextInputPanelWithPrompt:prompt.getNSString()
         defaultText:defaultValue.getNSString() returningText:&returnedText];
-    if (ok)
+    if (ok) {
         result = QString::fromNSString(returnedText);
+        result.replace(backslashAsCurrencySymbol(), '\\');
+    }
+
     return ok;
 }
 
@@ -1752,6 +1768,7 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_startNode, int sta
                     text = str;
     
                 text = text.stripWhiteSpace();
+                text.replace('\\', renderer->backslashAsCurrencySymbol());
                 if (text.length() > 1)
                     text += ' ';
     
@@ -1932,3 +1949,20 @@ void KWQKHTMLPart::setMediaType(const QString &type)
         d->m_view->setMediaType(type);
     }
 }
+
+QChar KWQKHTMLPart::backslashAsCurrencySymbol() const
+{
+    DocumentImpl *doc = xmlDocImpl();
+    if (!doc) {
+        return '\\';
+    }
+    Decoder *decoder = doc->decoder();
+    if (!decoder) {
+        return '\\';
+    }
+    const QTextCodec *codec = decoder->codec();
+    if (!codec) {
+        return '\\';
+    }
+    return codec->backslashAsCurrencySymbol();
+}
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index 6d34ae9..fd2854f 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -2326,7 +2326,7 @@ QString &QString::replace(const QRegExp &qre, const QString &str)
 
 QString &QString::replace(QChar oldChar, QChar newChar)
 {
-    if (find(oldChar) != -1) {
+    if (oldChar != newChar && find(oldChar) != -1) {
         unsigned length = dataHandle[0]->_length;
         
         detach();
diff --git a/WebCore/kwq/KWQTextCodec.h b/WebCore/kwq/KWQTextCodec.h
index 6cbc69b..eac9626 100644
--- a/WebCore/kwq/KWQTextCodec.h
+++ b/WebCore/kwq/KWQTextCodec.h
@@ -43,6 +43,8 @@ public:
     const char *name() const;
     bool usesVisualOrdering() const { return _flags & VisualOrdering; }
     bool isJapanese() const { return _flags & IsJapanese; }
+    
+    QChar backslashAsCurrencySymbol() const;
 
     QTextDecoder *makeDecoder() const;
 
diff --git a/WebCore/kwq/KWQTextCodec.mm b/WebCore/kwq/KWQTextCodec.mm
index 772da33..987352a 100644
--- a/WebCore/kwq/KWQTextCodec.mm
+++ b/WebCore/kwq/KWQTextCodec.mm
@@ -30,6 +30,17 @@
 
 const UniChar BOM = 0xFEFF;
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
+
+struct TECObjectPeek {
+    UInt32 skip1;
+    UInt32 skip2;
+    UInt32 skip3;
+    OptionBits optionsControlFlags;
+};
+
+#endif
+
 class KWQTextDecoder : public QTextDecoder {
 public:
     KWQTextDecoder(CFStringEncoding, KWQEncodingFlags);
@@ -129,41 +140,20 @@ inline CFStringEncoding effectiveEncoding(CFStringEncoding e)
 
 QCString QTextCodec::fromUnicode(const QString &qcs) const
 {
-    // FIXME: Should really use the same API in both directions, not CF one way and TEC the other.
+    // FIXME: We should really use the same API in both directions.
+    // Currently we use TEC to decode and CFString to encode; it would be better to encode with TEC too.
     
     CFStringEncoding encoding = effectiveEncoding(_encoding);
 
+    // FIXME: Since there's no "force ASCII range" mode in CFString, we change the backslash into a yen sign.
+    // Encoding will change the yen sign back into a backslash.
     QString copy;
     bool usingCopy = false;
-    bool doingTildeWorkaround = false;
-
-    // This is a hack to work around bug 3254512 -- tilde does not make the round trip when encoding/decoding Shift-JIS.
-    // We change decoded tilde characters into U+0001 because that will survive the decoding process (turn into ASCII 0x01)
-    // and we don't care about preserving U+0001 characters; they should never occur.
-
-    // The other hack is to make \ character turn into 5C instead of 815F when converting to Shift-JIS.
-    // Although 815F is correct, strictly speaking, if we end up with a 5C, we almost always want to send
-    // it back as a 5C; there's no way to type a \ on a Japanese keyboard.
-
-    switch (encoding) {
-        case kCFStringEncodingShiftJIS_X0213_00:
-        case kCFStringEncodingEUC_JP: {
-            const QChar decodedTilde(0x203E);
-            if (qcs.find(decodedTilde) != -1) {
-                doingTildeWorkaround = true;
-                usingCopy = true;
-                copy = qcs;
-                copy.replace(decodedTilde, 0x0001);
-            }
-            if (qcs.find('\\') != -1) {
-                if (!usingCopy) {
-                    usingCopy = true;
-                    copy = qcs;
-                }
-                const QChar decodedBackslash(0x00A5);
-                copy.replace('\\', decodedBackslash);
-            }
-        }
+    QChar currencySymbol = backslashAsCurrencySymbol();
+    if (currencySymbol != '\\' && qcs.find('\\') != -1) {
+	usingCopy = true;
+        copy = qcs;
+	copy.replace('\\', currencySymbol);
     }
 
     CFStringRef cfs = usingCopy ? copy.getCFString() : qcs.getCFString();
@@ -174,12 +164,6 @@ QCString QTextCodec::fromUnicode(const QString &qcs) const
     QCString result(bufferLength + 1);
     CFStringGetBytes(cfs, range, encoding, '?', FALSE, reinterpret_cast<UInt8 *>(result.data()), bufferLength, &bufferLength);
     result[bufferLength] = 0;
-
-    // Change the decoded U+0001 characters (now 0x01) into tilde.
-    if (doingTildeWorkaround) {
-        result.replace(0x01, '~');
-    }
-
     return result;
 }
 
@@ -193,6 +177,18 @@ QString QTextCodec::toUnicode(const QByteArray &qba, int len) const
     return KWQTextDecoder(_encoding, _flags).toUnicode(qba, len, true);
 }
 
+QChar QTextCodec::backslashAsCurrencySymbol() const
+{
+    // FIXME: We should put this information into KWQCharsetData instead of having a switch here.
+    switch (_encoding) {
+        case kCFStringEncodingShiftJIS_X0213_00:
+        case kCFStringEncodingEUC_JP:
+            return 0x00A5; // yen sign
+        default:
+            return '\\';
+    }
+}
+
 bool operator==(const QTextCodec &a, const QTextCodec &b)
 {
     return a._encoding == b._encoding && a._flags == b._flags;
@@ -326,6 +322,13 @@ QString KWQTextDecoder::convertUsingTEC(const UInt8 *chs, int len, bool flush)
                 ERROR("the Text Encoding Converter won't convert from text encoding 0x%X, error %d", encoding, status);
                 return QString();
             }
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
+            // Workaround for missing TECSetBasicOptions call.
+            reinterpret_cast<TECObjectPeek **>(_converter)[0]->optionsControlFlags = kUnicodeForceASCIIRangeMask;
+#else
+            TECSetBasicOptions(_converter, kUnicodeForceASCIIRangeMask);
+#endif
         }
     }
     
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index 25d6511..6940803 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -309,7 +309,9 @@ static bool initializedObjectCacheSize = FALSE;
 
 - (NSString *)selectedString
 {
-    return [[_part->selectedText().getNSString() copy] autorelease];
+    QString text = _part->selectedText();
+    text.replace('\\', _part->backslashAsCurrencySymbol());
+    return [[text.getNSString() copy] autorelease];
 }
 
 - (void)selectAll
@@ -657,7 +659,9 @@ static HTMLFormElementImpl *formElementFromDOMElement(id <WebDOMElement>element)
         
         DOMString title = e->getAttribute(ATTR_TITLE);
         if (!title.isEmpty()) {
-            [element setObject:title.string().getNSString() forKey:WebCoreElementLinkTitleKey];
+            QString titleText = title.string();
+            titleText.replace('\\', _part->backslashAsCurrencySymbol());
+            [element setObject:titleText.getNSString() forKey:WebCoreElementLinkTitleKey];
         }
         
         DOMString link = e->getAttribute(ATTR_HREF);
@@ -704,7 +708,9 @@ static HTMLFormElementImpl *formElementFromDOMElement(id <WebDOMElement>element)
         
         DOMString alt = i->getAttribute(ATTR_ALT);
         if (!alt.isNull()) {
-            [element setObject:alt.string().getNSString() forKey:WebCoreElementImageAltStringKey];
+            QString altText = alt.string();
+            altText.replace('\\', _part->backslashAsCurrencySymbol());
+            [element setObject:altText.getNSString() forKey:WebCoreElementImageAltStringKey];
         }
         
         RenderImage *r = (RenderImage *)node->renderer();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list