[webkit-changes] cvs commit: LayoutTests/fast/xsl xslt-doc-enc-expected.txt xslt-doc-enc.xml xslt-doc-enc.xsl xslt-doc-noenc-expected.txt xslt-doc-noenc.xml xslt-doc-noenc.xsl

Darin darin at opensource.apple.com
Sun Dec 18 14:23:30 PST 2005


darin       05/12/18 14:23:30

  Modified:    .        ChangeLog
               khtml/xsl xslt_processorimpl.cpp xslt_processorimpl.h
               khtml/xml dom_docimpl.cpp
               .        ChangeLog
  Added:       fast/xsl xslt-doc-enc-expected.txt xslt-doc-enc.xml
                        xslt-doc-enc.xsl xslt-doc-noenc-expected.txt
                        xslt-doc-noenc.xml xslt-doc-noenc.xsl
  Log:
  LayoutTests:
  
          Reviewed and landed by Darin.
  
          - XSLT document encoding tests
  
          * fast/xsl/xslt-doc-enc-expected.txt: Added.
          * fast/xsl/xslt-doc-enc.xml: Added.
          * fast/xsl/xslt-doc-enc.xsl: Added.
          * fast/xsl/xslt-doc-noenc-expected.txt: Added.
          * fast/xsl/xslt-doc-noenc.xml: Added.
          * fast/xsl/xslt-doc-noenc.xsl: Added.
  
  WebCore:
  
          Reviewed and landed by Darin.
  
          - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5927
            Result of XSLT transformation has no charset defined
  
          * khtml/xml/dom_docimpl.cpp: (DocumentImpl::applyXSLTransform):
          Get encoding from transform and pass in to XSLTProcessor.
  
          * khtml/xsl/xslt_processorimpl.h:
          * khtml/xsl/xslt_processorimpl.cpp:
          (DOM::XSLTProcessorImpl::createDocumentFromSource): Added encoding parameter.
          Create a Decoder and use it to decode the source document (default encoding UTF-8).
          (DOM::XSLTProcessorImpl::transformToString): Add an encoding result. Set it to the
          encoding from the libxml2 document object.
          (DOM::XSLTProcessorImpl::transformToDocument): Get encoding from transform and pass
          in to XSLTProcessor.
          (DOM::XSLTProcessorImpl::transformToFragment): Ditto.
  
  Revision  Changes    Path
  1.560     +20 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.559
  retrieving revision 1.560
  diff -u -r1.559 -r1.560
  --- ChangeLog	18 Dec 2005 22:13:16 -0000	1.559
  +++ ChangeLog	18 Dec 2005 22:23:23 -0000	1.560
  @@ -1,5 +1,25 @@
   2005-12-18  Alexey Proskuryakov  <ap at nypop.com>
   
  +        Reviewed and landed by Darin.
  +
  +        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5927
  +          Result of XSLT transformation has no charset defined
  +
  +        * khtml/xml/dom_docimpl.cpp: (DocumentImpl::applyXSLTransform):
  +        Get encoding from transform and pass in to XSLTProcessor.
  +
  +        * khtml/xsl/xslt_processorimpl.h:
  +        * khtml/xsl/xslt_processorimpl.cpp:
  +        (DOM::XSLTProcessorImpl::createDocumentFromSource): Added encoding parameter.
  +        Create a Decoder and use it to decode the source document (default encoding UTF-8).
  +        (DOM::XSLTProcessorImpl::transformToString): Add an encoding result. Set it to the
  +        encoding from the libxml2 document object.
  +        (DOM::XSLTProcessorImpl::transformToDocument): Get encoding from transform and pass
  +        in to XSLTProcessor.
  +        (DOM::XSLTProcessorImpl::transformToFragment): Ditto.
  +
  +2005-12-18  Alexey Proskuryakov  <ap at nypop.com>
  +
           Reviewed by Eric, landed by Darin.
   
           - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5631
  
  
  
  1.18      +14 -5     WebCore/khtml/xsl/xslt_processorimpl.cpp
  
  Index: xslt_processorimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xsl/xslt_processorimpl.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- xslt_processorimpl.cpp	1 Dec 2005 10:32:30 -0000	1.17
  +++ xslt_processorimpl.cpp	18 Dec 2005 22:23:27 -0000	1.18
  @@ -177,7 +177,7 @@
   }
   
   
  -RefPtr<DocumentImpl> XSLTProcessorImpl::createDocumentFromSource(const QString &sourceString, const QString &sourceMIMEType, NodeImpl *sourceNode, KHTMLView *view)
  +RefPtr<DocumentImpl> XSLTProcessorImpl::createDocumentFromSource(const QString &sourceString, const QString &sourceEncoding, const QString &sourceMIMEType, NodeImpl *sourceNode, KHTMLView *view)
   {
       RefPtr<DocumentImpl> ownerDocument = sourceNode->getDocument();
       bool sourceIsDocument = (sourceNode == ownerDocument.get());
  @@ -208,6 +208,12 @@
           result->setBaseURL(ownerDocument->baseURL());
       }
       result->determineParseMode(documentSource); // Make sure we parse in the correct mode.
  +    
  +    Decoder *decoder = new Decoder;
  +    decoder->setEncoding(sourceEncoding.isEmpty() ? "UTF-8" : sourceEncoding.latin1(), Decoder::EncodingFromXMLHeader);
  +    result->setDecoder(decoder);
  +    decoder->deref();
  +    
       result->write(documentSource);
       result->finishParsing();
       result->setParsing(false);
  @@ -283,7 +289,7 @@
       return QString("application/xml");
   }
   
  -bool XSLTProcessorImpl::transformToString(NodeImpl *sourceNode, QString &mimeType, QString &resultString)
  +bool XSLTProcessorImpl::transformToString(NodeImpl *sourceNode, QString &mimeType, QString &resultString, QString &resultEncoding)
   {
       RefPtr<DocumentImpl> ownerDocument = sourceNode->getDocument();
       RefPtr<XSLStyleSheetImpl> cachedStylesheet = m_stylesheet;
  @@ -307,6 +313,7 @@
           return false;
       
       mimeType = resultMIMEType(resultDoc, sheet);
  +    resultEncoding = (char *)resultDoc->encoding;
       
       xsltFreeStylesheet(sheet);
       xmlFreeDoc(resultDoc);
  @@ -318,16 +325,18 @@
   {
       QString resultMIMEType;
       QString resultString;
  -    if (!transformToString(sourceNode, resultMIMEType, resultString))
  +    QString resultEncoding;
  +    if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncoding))
           return 0;
  -    return createDocumentFromSource(resultString, resultMIMEType, sourceNode);
  +    return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, sourceNode);
   }
   
   RefPtr<DocumentFragmentImpl> XSLTProcessorImpl::transformToFragment(NodeImpl *sourceNode, DocumentImpl *outputDoc)
   {
       QString resultMIMEType;
       QString resultString;
  -    if (!transformToString(sourceNode, resultMIMEType, resultString))
  +    QString resultEncoding;
  +    if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncoding))
           return 0;
       return createFragmentFromSource(resultString, resultMIMEType, sourceNode, outputDoc);
   }
  
  
  
  1.7       +2 -2      WebCore/khtml/xsl/xslt_processorimpl.h
  
  Index: xslt_processorimpl.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xsl/xslt_processorimpl.h,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- xslt_processorimpl.h	1 Dec 2005 10:32:30 -0000	1.6
  +++ xslt_processorimpl.h	18 Dec 2005 22:23:27 -0000	1.7
  @@ -48,8 +48,8 @@
       XSLTProcessorImpl() { m_parameters.setAutoDelete(true); };
   
       void setXSLStylesheet(XSLStyleSheetImpl *styleSheet) { m_stylesheet = styleSheet; }
  -    bool transformToString(NodeImpl *source, QString &resultMIMEType, QString &resultString);
  -    RefPtr<DocumentImpl> createDocumentFromSource(const QString &source, const QString &sourceMIMEType, NodeImpl *sourceNode, KHTMLView *view = 0);
  +    bool transformToString(NodeImpl *source, QString &resultMIMEType, QString &resultString, QString &resultEncoding);
  +    RefPtr<DocumentImpl> createDocumentFromSource(const QString &source, const QString &sourceEncoding, const QString &sourceMIMEType, NodeImpl *sourceNode, KHTMLView *view = 0);
       
       // DOM methods
       void importStylesheet(NodeImpl *style) { m_stylesheetRootNode = style; }
  
  
  
  1.287     +3 -2      WebCore/khtml/xml/dom_docimpl.cpp
  
  Index: dom_docimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
  retrieving revision 1.286
  retrieving revision 1.287
  diff -u -r1.286 -r1.287
  --- dom_docimpl.cpp	16 Dec 2005 08:08:21 -0000	1.286
  +++ dom_docimpl.cpp	18 Dec 2005 22:23:27 -0000	1.287
  @@ -3143,10 +3143,11 @@
       
       QString resultMIMEType;
       QString newSource;
  -    if (!processor->transformToString(this, resultMIMEType, newSource))
  +    QString resultEncoding;
  +    if (!processor->transformToString(this, resultMIMEType, newSource, resultEncoding))
           return;
       // FIXME: If the transform failed we should probably report an error (like Mozilla does).
  -    processor->createDocumentFromSource(newSource, resultMIMEType, this, view());
  +    processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, this, view());
   }
   
   #endif
  
  
  
  1.166     +13 -0     LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.165
  retrieving revision 1.166
  diff -u -r1.165 -r1.166
  --- ChangeLog	18 Dec 2005 13:28:33 -0000	1.165
  +++ ChangeLog	18 Dec 2005 22:23:28 -0000	1.166
  @@ -1,3 +1,16 @@
  +2005-12-18  Alexey Proskuryakov  <ap at nypop.com>
  +
  +        Reviewed and landed by Darin.
  +
  +        - XSLT document encoding tests
  +
  +        * fast/xsl/xslt-doc-enc-expected.txt: Added.
  +        * fast/xsl/xslt-doc-enc.xml: Added.
  +        * fast/xsl/xslt-doc-enc.xsl: Added.
  +        * fast/xsl/xslt-doc-noenc-expected.txt: Added.
  +        * fast/xsl/xslt-doc-noenc.xml: Added.
  +        * fast/xsl/xslt-doc-noenc.xsl: Added.
  +
   2005-12-18  Anders Carlsson  <andersca at mac.com>
   
           Reviewed by Darin.
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-doc-enc-expected.txt
  
  Index: xslt-doc-enc-expected.txt
  ===================================================================
  Encoding: KOI8-R
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-doc-enc.xml
  
  Index: xslt-doc-enc.xml
  ===================================================================
  <?xml version="1.0" encoding="windows-1251"?>
  <?xml-stylesheet type="text/xsl" href="xslt-doc-enc.xsl"?>
  
  <TEST/>
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-doc-enc.xsl
  
  Index: xslt-doc-enc.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso8859-5"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="html" encoding="KOI8-R"/>
      <xsl:template match="TEST">
          <html>
              <body>
                <script>
                  if (window.layoutTestController)
                    layoutTestController.dumpAsText();
                  
                	//alert(document.characterSet); // works in Firefox
                	document.write("Encoding: " + document.characterSet);
                </script>
              </body>
          </html>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-doc-noenc-expected.txt
  
  Index: xslt-doc-noenc-expected.txt
  ===================================================================
  Encoding: UTF-8
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-doc-noenc.xml
  
  Index: xslt-doc-noenc.xml
  ===================================================================
  <?xml version="1.0" encoding="windows-1251"?>
  <?xml-stylesheet type="text/xsl" href="xslt-doc-noenc.xsl"?>
  
  <TEST/>
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-doc-noenc.xsl
  
  Index: xslt-doc-noenc.xsl
  ===================================================================
  <?xml version="1.0" encoding="iso8859-5"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="html"/>
      <xsl:template match="TEST">
          <html>
              <body>
                <script>
                  if (window.layoutTestController)
                    layoutTestController.dumpAsText();
                  
                	//alert(document.characterSet); // -- works in Firefox
                	document.write("Encoding: " + document.characterSet);
                </script>
              </body>
          </html>
    </xsl:template>
  
  </xsl:stylesheet>
  
  
  



More information about the webkit-changes mailing list