Reviewed by Darin.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2008 22:27:34 +0000 (22:27 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jan 2008 22:27:34 +0000 (22:27 +0000)
        <rdar://problem/5611712> xsl:sort does not use a case folding sort, and the 'case-order' attribute is ignored (16077)

        Enable the fix on Windows.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29177 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/win/Skipped
WebCore/ChangeLog
WebCore/xml/XSLTProcessor.cpp
WebCore/xml/XSLTUnicodeSort.cpp
WebCore/xml/XSLTUnicodeSort.h
WebKit/win/ChangeLog
WebKit/win/WebKit.vcproj/WebKit.vcproj

index 0f4bc1c..82d2eed 100644 (file)
@@ -1,3 +1,11 @@
+2008-01-04  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        <rdar://problem/5611712> xsl:sort does not use a case folding sort, and the 'case-order' attribute is ignored (16077)
+
+        * platform/win/Skipped: The fix for this bug is now enabled on Windows, take the test out of Skipped list.
+
 2008-01-04  Adam Roben  <aroben@apple.com>
 
         Added a test for <rdar://4968855> Shift-PageUp/Shift-PageDown only select one line of text
index 3cd46d2..88a7798 100644 (file)
@@ -359,9 +359,6 @@ svg/custom/visibility-override-filter.svg
 # Results are wildly wrong <rdar://5563746>
 svg/css/glyph-orientation-rounding-test.xhtml
 
-# The fix for this test is disabled on Windows <rdar://5611712>
-fast/xsl/sort-unicode.xml
-
 # This test intermittently crashes <rdar://5621979>
 editing/selection/5241148.html
 
index 0af34a7..bea20f3 100644 (file)
@@ -1,3 +1,19 @@
+2008-01-04  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        <rdar://problem/5611712> xsl:sort does not use a case folding sort, and the 'case-order' attribute is ignored (16077)
+
+        Enable the fix on Windows.
+
+        * xml/XSLTProcessor.cpp: (WebCore::XSLTProcessor::transformToString):
+        Always set a custom sort function, even if it doesn't implement proper collation on the platform.
+
+        * xml/XSLTUnicodeSort.cpp:
+        (WebCore::xsltUnicodeSortFunction):
+        * xml/XSLTUnicodeSort.h:
+        If the platform does not use ICU, or ICU has collation support disabled, fall back to binary comparison.
+
 2008-01-04  Antti Koivisto  <antti@apple.com>
 
         Fix build.
index 9576e2f..07efe75 100644 (file)
@@ -362,12 +362,9 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
 
         xsltTransformContextPtr transformContext = xsltNewTransformContext(sheet, sourceDoc);
         registerXSLTExtensions(transformContext);
-// FIXME: <rdar://5611712> Remove the PLATFORM(WIN) check once ICU on Windows has collation support.
-#if USE(ICU_UNICODE) && !PLATFORM(WIN)
+
         // <http://bugs.webkit.org/show_bug.cgi?id=16077>: XSLT processor <xsl:sort> algorithm only compares by code point
-        // Only implemented for ICU yet.
         xsltSetCtxtSortFunc(transformContext, xsltUnicodeSortFunction);
-#endif
 
         // This is a workaround for a bug in libxslt. 
         // The bug has been fixed in version 1.1.13, so once we ship that this can be removed.
index 32a6c1e..e1ecdc4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "XSLTUnicodeSort.h"
 
-// FIXME: <rdar://5611712> Remove the PLATFORM(WIN) check once ICU on Windows has collation support.
-#if ENABLE(XSLT) && USE(ICU_UNICODE) && !PLATFORM(WIN)
+#if ENABLE(XSLT)
 
 #include <libxslt/templates.h>
 #include <libxslt/xsltutils.h>
+
+#if USE(ICU_UNICODE)
 #include <unicode/ucnv.h>
 #include <unicode/ucol.h>
 #include <unicode/ustring.h>
+#define WTF_USE_ICU_COLLATION !UCONFIG_NO_COLLATION
+#endif
 
 #if PLATFORM(MAC)
 #include "SoftLinking.h"
@@ -119,13 +122,13 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
     xmlXPathObjectPtr tmp;    
     int tempstype[XSLT_MAX_SORT], temporder[XSLT_MAX_SORT];
 
-    /* Start ICU change */
+#if USE(ICU_COLLATION)
     UCollator *coll = 0;
     UConverter *conv;
     UErrorCode status;
     UChar *target,*target2;
     int targetlen, target2len;
-    /* End ICU change */
+#endif
 
     if ((ctxt == NULL) || (sorts == NULL) || (nbsorts <= 0) ||
         (nbsorts >= XSLT_MAX_SORT))
@@ -198,7 +201,7 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
     if (results == NULL)
         return;
 
-    /* Start ICU change */
+#if USE(ICU_COLLATION)
     status = U_ZERO_ERROR;
     conv = ucnv_open("UTF8", &status);
     if (U_FAILURE(status))
@@ -219,7 +222,7 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
         ucol_setAttribute(coll,UCOL_CASE_FIRST,UCOL_UPPER_FIRST,&status);
     if (U_FAILURE(status))
         xsltTransformError(ctxt, NULL, NULL, "xsltICUSortFunction: Error setting collator attribute\n");
-    /* End ICU change */
+#endif
 
     /* Shell's sort of node-set */
     for (incr = len / 2; incr > 0; incr /= 2) {
@@ -250,9 +253,9 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
                             tst = 1;
                         else tst = -1;
                     } else {
-                        /* Start ICU change */
-                        targetlen = xmlStrlen(results[j]->stringval) * 2;
-                        target2len = xmlStrlen(results[j + incr]->stringval) * 2;
+#if USE(ICU_COLLATION)
+                        targetlen = xmlStrlen(results[j]->stringval) + 1;
+                        target2len = xmlStrlen(results[j + incr]->stringval) + 1;
                         target = (UChar*)xmlMalloc(targetlen * sizeof(UChar));
                         target2 = (UChar*)xmlMalloc(target2len * sizeof(UChar));
                         targetlen = ucnv_toUChars(conv, target, targetlen, (const char*)results[j]->stringval, -1, &status);
@@ -260,7 +263,10 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
                         tst = ucol_strcoll(coll, target, u_strlen(target), target2, u_strlen(target2));
                         xmlFree(target);
                         xmlFree(target2);
-                        /* End ICU change */
+#else
+                        tst = xmlStrcmp(results[j]->stringval,
+                            results[j + incr]->stringval); 
+#endif
                     }
                     if (descending)
                         tst = -tst;
@@ -313,9 +319,9 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
                                     tst = 1;
                                 else tst = -1;
                             } else {
-                                /* Start ICU change */
-                                targetlen = xmlStrlen(res[j]->stringval) * 2;
-                                target2len = xmlStrlen(res[j + incr]->stringval) * 2;
+#if USE(ICU_COLLATION)
+                                targetlen = xmlStrlen(res[j]->stringval) + 1;
+                                target2len = xmlStrlen(res[j + incr]->stringval) + 1;
                                 target = (UChar*)xmlMalloc(targetlen * sizeof(UChar));
                                 target2 = (UChar*)xmlMalloc(target2len * sizeof(UChar));
                                 targetlen = ucnv_toUChars(conv, target, targetlen, (const char*)res[j]->stringval, -1, &status);
@@ -323,7 +329,10 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
                                 tst = ucol_strcoll(coll, target, u_strlen(target), target2, u_strlen(target2));
                                 xmlFree(target);
                                 xmlFree(target2);
-                                /* End ICU change */
+#else
+                                tst = xmlStrcmp(res[j]->stringval,
+                                    res[j + incr]->stringval); 
+#endif
                             }
                             if (desc)
                                 tst = -tst;
@@ -367,10 +376,10 @@ void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr *sorts, in
         }
     }
 
-    /* Start ICU change */
+#if USE(ICU_COLLATION)
     ucol_close(coll);
     ucnv_close(conv);
-    /* End ICU change */
+#endif
 
     for (j = 0; j < nbsorts; j++) {
         comp = static_cast<xsltStylePreComp*>(sorts[j]->psvi);
index c5a76ec..ff5b253 100644 (file)
@@ -28,9 +28,9 @@
 #ifndef XSLTUnicodeSort_h
 #define XSLTUnicodeSort_h
 
-// Only implemented for ICU yet.
-// FIXME: We need to make an abstraction for Unicode collation to implement this for other libraries.
-#if ENABLE(XSLT) && USE(ICU_UNICODE)
+// FIXME: Only works as advertised for ICU with collation support enabled yet, falls back on binary comparison otherwise..
+// We need to make an abstraction for Unicode collation to implement this for other libraries.
+#if ENABLE(XSLT)
 
 #include <libxslt/xsltInternals.h>
 
index cb02654..7799e5b 100644 (file)
@@ -1,3 +1,11 @@
+2008-01-04  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin.
+
+        <rdar://problem/5611712> xsl:sort does not use a case folding sort, and the 'case-order' attribute is ignored (16077)
+
+        * WebKit.vcproj/WebKit.vcproj: Link to icuin{_debug}.lib
+
 2008-01-04  Adam Roben  <aroben@apple.com>
 
         Fix <rdar://4968855> Shift-PageUp/Shift-PageDown only select one line of text
index 47096f1..1c52efc 100644 (file)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="Windows-1252"?>\r
+<?xml version="1.0" encoding="windows-1251"?>\r
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
-       Version="8.00"\r
+       Version="8,00"\r
        Name="WebKit"\r
        ProjectGUID="{0662A8A9-82A3-4638-97D8-EC425D8D87C9}"\r
        RootNamespace="WebKit"\r
@@ -71,7 +71,7 @@
                        <Tool\r
                                Name="VCLinkerTool"\r
                                LinkLibraryDependencies="false"\r
-                               AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib"\r
+                               AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuin$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitDLLConfigSuffix).dll"\r
                                LinkIncremental="2"\r
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                LinkLibraryDependencies="false"\r
-                               AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib"\r
+                               AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuin$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitDLLConfigSuffix).dll"\r
                                LinkIncremental="1"\r
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;"\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                LinkLibraryDependencies="false"\r
-                               AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib"\r
+                               AdditionalDependencies="delayimp.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib usp10.lib comctl32.lib version.lib shlwapi.lib libxml2$(LibraryConfigSuffix).lib libxslt$(LibraryConfigSuffix).lib icuin$(LibraryConfigSuffix).lib icuuc$(LibraryConfigSuffix).lib SQLite3$(LibraryConfigSuffix).lib pthreadVC2$(LibraryConfigSuffix).lib CoreFoundation$(LibraryConfigSuffix).lib CFNetwork$(LibraryConfigSuffix).lib CoreGraphics$(LibraryConfigSuffix).lib JavaScriptCore$(WebKitConfigSuffix).lib WebKitGUID$(WebKitConfigSuffix).lib WebCore$(WebKitConfigSuffix).lib WTF$(WebKitConfigSuffix).lib WebKitSystemInterface$(WebKitConfigSuffix).lib msimg32.lib"\r
                                OutputFile="$(OutDir)\$(ProjectName)$(WebKitDLLConfigSuffix).dll"\r
                                LinkIncremental="2"\r
                                AdditionalLibraryDirectories="&quot;$(WebKitOutputDir)\lib&quot;;&quot;$(WebKitLibrariesDir)\lib&quot;"\r