summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/xml
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-06-02 12:07:03 +0100
committerBen Murdoch <benm@google.com>2011-06-10 10:47:21 +0100
commit2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch)
treee4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/xml
parent87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff)
downloadexternal_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz
external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/xml')
-rw-r--r--Source/WebCore/xml/XMLHttpRequest.cpp18
-rw-r--r--Source/WebCore/xml/XMLHttpRequest.h8
-rw-r--r--Source/WebCore/xml/XMLTreeViewer.cpp71
-rw-r--r--Source/WebCore/xml/XMLViewer.css76
-rw-r--r--Source/WebCore/xml/XMLViewer.js434
-rw-r--r--Source/WebCore/xml/XMLViewer.xsl398
-rw-r--r--Source/WebCore/xml/XSLStyleSheet.h8
7 files changed, 533 insertions, 480 deletions
diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp
index d6e6182..41d8afb 100644
--- a/Source/WebCore/xml/XMLHttpRequest.cpp
+++ b/Source/WebCore/xml/XMLHttpRequest.cpp
@@ -56,7 +56,7 @@
#if USE(JSC)
#include "JSDOMBinding.h"
#include "JSDOMWindow.h"
-#include <collector/handles/Global.h>
+#include <heap/Strong.h>
#include <runtime/JSLock.h>
#endif
@@ -271,7 +271,6 @@ Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const
}
#endif
-#if ENABLE(WEBGL) || ENABLE(BLOB)
ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec)
{
if (m_responseTypeCode != ResponseTypeArrayBuffer) {
@@ -292,7 +291,6 @@ ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec)
return 0;
}
-#endif
void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec)
{
@@ -312,9 +310,7 @@ void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode&
m_responseTypeCode = ResponseTypeBlob;
#endif
} else if (responseType == "arraybuffer") {
-#if ENABLE(WEBGL) || ENABLE(BLOB)
m_responseTypeCode = ResponseTypeArrayBuffer;
-#endif
} else
ec = SYNTAX_ERR;
}
@@ -586,7 +582,6 @@ void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec)
createRequest(ec);
}
-#if ENABLE(WEBGL) || ENABLE(BLOB)
void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec)
{
if (!initSend(ec))
@@ -600,7 +595,6 @@ void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec)
createRequest(ec);
}
-#endif
void XMLHttpRequest::createRequest(ExceptionCode& ec)
{
@@ -739,10 +733,8 @@ void XMLHttpRequest::clearResponseBuffers()
#if ENABLE(XHR_RESPONSE_BLOB)
m_responseBlob = 0;
#endif
-#if ENABLE(WEBGL) || ENABLE(BLOB)
m_binaryResponseBuilder.clear();
m_responseArrayBuffer.clear();
-#endif
}
void XMLHttpRequest::clearRequest()
@@ -792,11 +784,9 @@ void XMLHttpRequest::dropProtection()
// out. But it is protected from GC while loading, so this
// can't be recouped until the load is done, so only
// report the extra cost at that point.
+ JSC::JSLock lock(JSC::SilenceAssertionsOnly);
JSC::JSGlobalData* globalData = scriptExecutionContext()->globalData();
- if (hasCachedDOMObjectWrapper(globalData, this)) {
- JSC::JSLock lock(JSC::SilenceAssertionsOnly);
- globalData->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
- }
+ globalData->heap.reportExtraMemoryCost(m_responseBuilder.length() * 2);
#endif
unsetPendingActivity(this);
@@ -1076,14 +1066,12 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
if (useDecoder)
m_responseBuilder.append(m_decoder->decode(data, len));
-#if ENABLE(WEBGL) || ENABLE(BLOB)
else if (responseTypeCode() == ResponseTypeArrayBuffer) {
// Buffer binary data.
if (!m_binaryResponseBuilder)
m_binaryResponseBuilder = SharedBuffer::create();
m_binaryResponseBuilder->append(data, len);
}
-#endif
if (!m_error) {
long long expectedLength = m_response.expectedContentLength();
diff --git a/Source/WebCore/xml/XMLHttpRequest.h b/Source/WebCore/xml/XMLHttpRequest.h
index 0f461e1..cca8c36 100644
--- a/Source/WebCore/xml/XMLHttpRequest.h
+++ b/Source/WebCore/xml/XMLHttpRequest.h
@@ -95,9 +95,7 @@ public:
void send(const String&, ExceptionCode&);
void send(Blob*, ExceptionCode&);
void send(DOMFormData*, ExceptionCode&);
-#if ENABLE(WEBGL) || ENABLE(BLOB)
void send(ArrayBuffer*, ExceptionCode&);
-#endif
void abort();
void setRequestHeader(const AtomicString& name, const String& value, ExceptionCode&);
void overrideMimeType(const String& override);
@@ -115,11 +113,9 @@ public:
String responseType();
ResponseTypeCode responseTypeCode() const { return m_responseTypeCode; }
-#if ENABLE(WEBGL) || ENABLE(BLOB)
// response attribute has custom getter.
ArrayBuffer* responseArrayBuffer(ExceptionCode&);
ArrayBuffer* optionalResponseArrayBuffer() const { return m_responseArrayBuffer.get(); }
-#endif
void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lineNumber; }
void setLastSendURL(const String& url) { m_lastSendURL = url; }
@@ -153,7 +149,7 @@ private:
virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
virtual void didReceiveResponse(const ResourceResponse&);
- virtual void didReceiveData(const char* data, int lengthReceived);
+ virtual void didReceiveData(const char* data, int dataLength);
virtual void didFinishLoading(unsigned long identifier, double finishTime);
virtual void didFail(const ResourceError&);
virtual void didFailRedirectCheck();
@@ -207,10 +203,8 @@ private:
mutable bool m_createdDocument;
mutable RefPtr<Document> m_responseXML;
-#if ENABLE(WEBGL) || ENABLE(BLOB)
RefPtr<SharedBuffer> m_binaryResponseBuilder;
mutable RefPtr<ArrayBuffer> m_responseArrayBuffer;
-#endif
bool m_error;
diff --git a/Source/WebCore/xml/XMLTreeViewer.cpp b/Source/WebCore/xml/XMLTreeViewer.cpp
index f1e2c0f..a2110db 100644
--- a/Source/WebCore/xml/XMLTreeViewer.cpp
+++ b/Source/WebCore/xml/XMLTreeViewer.cpp
@@ -27,37 +27,20 @@
*/
#include "config.h"
-
-#if ENABLE(XSLT)
#include "XMLTreeViewer.h"
+#if ENABLE(XSLT)
-#include "Base64.h"
-#include "Element.h"
#include "Document.h"
+#include "Element.h"
#include "Frame.h"
-#include "HTMLNames.h"
#include "Page.h"
-#include "ProcessingInstruction.h"
+#include "ScriptController.h"
+#include "ScriptSourceCode.h"
#include "Settings.h"
-#include "TransformSource.h"
-#include "XLinkNames.h"
-#include "XMLViewerXSL.h"
-#include "XPathResult.h"
-#include "XSLStyleSheet.h"
-#include "XSLTProcessor.h"
-
-#include <libxslt/xslt.h>
-
-#if ENABLE(MATHML)
-#include "MathMLNames.h"
-#endif
-#if ENABLE(SVG)
-#include "SVGNames.h"
-#endif
-#if ENABLE(WML)
-#include "WMLNames.h"
-#endif
+#include "Text.h"
+#include "XMLViewerCSS.h"
+#include "XMLViewerJS.h"
using namespace std;
@@ -82,39 +65,23 @@ bool XMLTreeViewer::hasNoStyleInformation() const
if (m_document->frame()->tree()->parent(true))
return false; // This document is not in a top frame
- if (m_document->frame()->loader()->opener())
- return false; // This document is not opened manually by user
return true;
}
void XMLTreeViewer::transformDocumentToTreeView()
{
- String sheetString(reinterpret_cast<const char*>(XMLViewer_xsl), sizeof(XMLViewer_xsl));
- RefPtr<XSLStyleSheet> styleSheet = XSLStyleSheet::createForXMLTreeViewer(m_document, sheetString);
-
- RefPtr<XSLTProcessor> processor = XSLTProcessor::create();
- processor->setXSLStyleSheet(styleSheet);
-
- processor->setParameter("", "xml_has_no_style_message", "This XML file does not appear to have any style information associated with it. The document tree is shown below.");
-
- String resultMIMEType;
- String newSource;
- String resultEncoding;
-
- Frame* frame = m_document->frame();
- // FIXME: We should introduce error handling
- if (processor->transformToString(m_document, resultMIMEType, newSource, resultEncoding))
- processor->createDocumentFromSource(newSource, resultEncoding, resultMIMEType, m_document, frame);
-
- // Adding source xml for dealing with namespaces and CDATA issues and for extensions use.
- Element* sourceXmlElement = frame->document()->getElementById(AtomicString("source-xml"));
- if (sourceXmlElement)
- m_document->cloneChildNodes(sourceXmlElement);
-
- // New document should have been loaded in frame. Tell it to use view source styles.
- frame->document()->setUsesViewSourceStyles(true);
- frame->document()->styleSelectorChanged(RecalcStyleImmediately);
-
+ String scriptString(reinterpret_cast<const char*>(XMLViewer_js), sizeof(XMLViewer_js));
+ m_document->frame()->script()->evaluate(ScriptSourceCode(scriptString));
+ String noStyleMessage("This XML file does not appear to have any style information associated with it. The document tree is shown below.");
+ m_document->frame()->script()->evaluate(ScriptSourceCode("prepareWebKitXMLViewer('" + noStyleMessage + "');"));
+
+ String cssString(reinterpret_cast<const char*>(XMLViewer_css), sizeof(XMLViewer_css));
+ RefPtr<Text> text = m_document->createTextNode(cssString);
+ ExceptionCode exceptionCode;
+ m_document->getElementById("xml-viewer-style")->appendChild(text, exceptionCode);
+
+ m_document->setUsesViewSourceStyles(true);
+ m_document->styleSelectorChanged(RecalcStyleImmediately);
}
} // namespace WebCore
diff --git a/Source/WebCore/xml/XMLViewer.css b/Source/WebCore/xml/XMLViewer.css
new file mode 100644
index 0000000..2a1d5fd
--- /dev/null
+++ b/Source/WebCore/xml/XMLViewer.css
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
+ * “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+div.header {
+ border-bottom: 2px solid black;
+ padding-bottom: 5px;
+ margin: 10px;
+}
+
+div.collapsible > div.hidden {
+ display:none;
+}
+
+.pretty-print {
+ margin-top: 1em;
+ margin-left: 20px;
+ font-family: monospace;
+ font-size: 13px;
+}
+
+#webkit-xml-viewer-source-xml {
+ display: none;
+}
+
+.collapsible-content {
+ margin-left: 1em;
+}
+.comment {
+ whitespace: pre;
+}
+
+.button {
+ -webkit-user-select: none;
+ cursor: pointer;
+ display: inline-block;
+ margin-left: -10px;
+ width: 10px;
+ background-repeat: no-repeat;
+ background-position: left top;
+ vertical-align: bottom;
+}
+
+.collapse-button {
+ background-image: -webkit-canvas(arrowDown);
+ height: 10px;
+}
+
+.expand-button {
+ background-image: -webkit-canvas(arrowRight);
+ height: 11px;
+}
diff --git a/Source/WebCore/xml/XMLViewer.js b/Source/WebCore/xml/XMLViewer.js
new file mode 100644
index 0000000..22405e0
--- /dev/null
+++ b/Source/WebCore/xml/XMLViewer.js
@@ -0,0 +1,434 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
+ * “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+var nodeParentPairs = [];
+
+// Script entry point.
+
+function prepareWebKitXMLViewer(noStyleMessage)
+{
+ var html = createHTMLElement('html');
+ var head = createHTMLElement('head');
+ html.appendChild(head);
+ var style = createHTMLElement('style');
+ style.id = 'xml-viewer-style';
+ head.appendChild(style);
+ var body = createHTMLElement('body');
+ html.appendChild(body);
+ var sourceXML = createHTMLElement('div');
+ sourceXML.id = 'webkit-xml-viewer-source-xml';
+ body.appendChild(sourceXML);
+
+ var child;
+ while (child = document.firstChild) {
+ document.removeChild(child);
+ if (child.nodeType != Node.DOCUMENT_TYPE_NODE)
+ sourceXML.appendChild(child);
+ }
+ document.appendChild(html);
+
+ var header = createHTMLElement('div');
+ body.appendChild(header);
+ header.classList.add('header');
+ var headerSpan = createHTMLElement('span');
+ header.appendChild(headerSpan);
+ headerSpan.textContent = noStyleMessage;
+ header.appendChild(createHTMLElement('br'));
+
+ var tree = createHTMLElement('div');
+ body.appendChild(tree);
+ tree.classList.add('pretty-print');
+ tree.id = 'tree';
+ window.onload = sourceXMLLoaded;
+}
+
+function sourceXMLLoaded()
+{
+ var sourceXML = document.getElementById('webkit-xml-viewer-source-xml');
+ if (!sourceXML)
+ return; // Stop if some XML tree extension is already processing this document
+ //var style = document.head.firstChild;
+ //document.head.removeChild(style);
+ //document.head.appendChild(style);
+ var root = document.getElementById('tree');
+
+ for (var child = sourceXML.firstChild; child; child = child.nextSibling)
+ nodeParentPairs.push({parentElement: root, node: child});
+
+ for (var i = 0; i < nodeParentPairs.length; i++)
+ processNode(nodeParentPairs[i].parentElement, nodeParentPairs[i].node);
+
+ drawArrows();
+ initButtons();
+
+ if (typeof(onAfterWebkitXMLViewerLoaded) == 'function')
+ onAfterWebkitXMLViewerLoaded();
+}
+
+// Tree processing.
+
+function processNode(parentElement, node)
+{
+ if (!processNode.processorsMap) {
+ processNode.processorsMap = {};
+ processNode.processorsMap[Node.PROCESSING_INSTRUCTION_NODE] = processProcessingInstruction;
+ processNode.processorsMap[Node.ELEMENT_NODE] = processElement;
+ processNode.processorsMap[Node.COMMENT_NODE] = processComment;
+ processNode.processorsMap[Node.TEXT_NODE] = processText;
+ processNode.processorsMap[Node.CDATA_SECTION_NODE] = processCDATA;
+ }
+ if (processNode.processorsMap[node.nodeType])
+ processNode.processorsMap[node.nodeType].call(this, parentElement, node);
+}
+
+function processElement(parentElement, node)
+{
+ if (!node.firstChild)
+ processEmptyElement(parentElement, node);
+ else {
+ var child = node.firstChild;
+ if (child.nodeType == Node.TEXT_NODE && isShort(child.nodeValue) && !child.nextSibling)
+ processShortTextOnlyElement(parentElement, node);
+ else
+ processComplexElement(parentElement, node);
+ }
+}
+
+function processEmptyElement(parentElement, node)
+{
+ var line = createLine();
+ line.appendChild(createTag(node, false, true));
+ parentElement.appendChild(line);
+}
+
+function processShortTextOnlyElement(parentElement, node)
+{
+ var line = createLine();
+ line.appendChild(createTag(node, false, false));
+ for (var child = node.firstChild; child; child = child.nextSibling)
+ line.appendChild(createText(child.nodeValue));
+ line.appendChild(createTag(node, true, false));
+ parentElement.appendChild(line);
+}
+
+function processComplexElement(parentElement, node)
+{
+ var collapsible = createCollapsible();
+
+ collapsible.expanded.start.appendChild(createTag(node, false, false));
+ for (var child = node.firstChild; child; child = child.nextSibling)
+ nodeParentPairs.push({parentElement: collapsible.expanded.content, node: child});
+ collapsible.expanded.end.appendChild(createTag(node, true, false));
+
+ collapsible.collapsed.content.appendChild(createTag(node, false, false));
+ collapsible.collapsed.content.appendChild(createText('...'));
+ collapsible.collapsed.content.appendChild(createTag(node, true, false));
+ parentElement.appendChild(collapsible);
+}
+
+function processComment(parentElement, node)
+{
+ if (isShort(node.nodeValue)) {
+ var line = createLine();
+ line.appendChild(createComment('<!-- ' + node.nodeValue + ' -->'));
+ parentElement.appendChild(line);
+ } else {
+ var collapsible = createCollapsible();
+
+ collapsible.expanded.start.appendChild(createComment('<!--'));
+ collapsible.expanded.content.appendChild(createComment(node.nodeValue));
+ collapsible.expanded.end.appendChild(createComment('-->'));
+
+ collapsible.collapsed.content.appendChild(createComment('<!--'));
+ collapsible.collapsed.content.appendChild(createComment('...'));
+ collapsible.collapsed.content.appendChild(createComment('-->'));
+ parentElement.appendChild(collapsible);
+ }
+}
+
+function processCDATA(parentElement, node)
+{
+ if (isShort(node.nodeValue)) {
+ var line = createLine();
+ line.appendChild(createText('<![CDATA[ ' + node.nodeValue + ' ]]>'));
+ parentElement.appendChild(line);
+ } else {
+ var collapsible = createCollapsible();
+
+ collapsible.expanded.start.appendChild(createText('<![CDATA['));
+ collapsible.expanded.content.appendChild(createText(node.nodeValue));
+ collapsible.expanded.end.appendChild(createText(']]>'));
+
+ collapsible.collapsed.content.appendChild(createText('<![CDATA['));
+ collapsible.collapsed.content.appendChild(createText('...'));
+ collapsible.collapsed.content.appendChild(createText(']]>'));
+ parentElement.appendChild(collapsible);
+ }
+}
+
+function processProcessingInstruction(parentElement, node)
+{
+ if (isShort(node.nodeValue)) {
+ var line = createLine();
+ line.appendChild(createComment('<?' + node.nodeName + ' ' + node.nodeValue + '?>'));
+ parentElement.appendChild(line);
+ } else {
+ var collapsible = createCollapsible();
+
+ collapsible.expanded.start.appendChild(createComment('<?' + node.nodeName));
+ collapsible.expanded.content.appendChild(createComment(node.nodeValue));
+ collapsible.expanded.end.appendChild(createComment('?>'));
+
+ collapsible.collapsed.content.appendChild(createComment('<?' + node.nodeName));
+ collapsible.collapsed.content.appendChild(createComment('...'));
+ collapsible.collapsed.content.appendChild(createComment('?>'));
+ parentElement.appendChild(collapsible);
+ }
+}
+
+function processText(parentElement, node)
+{
+ parentElement.appendChild(createText(node.nodeValue));
+}
+
+// Processing utils.
+
+function trim(value)
+{
+ return value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
+}
+
+function isShort(value)
+{
+ return trim(value).length <= 50;
+}
+
+// Tree rendering.
+
+function createHTMLElement(elementName)
+{
+ return document.createElementNS('http://www.w3.org/1999/xhtml', elementName)
+}
+
+function createCollapsible()
+{
+ var collapsible = createHTMLElement('div');
+ collapsible.classList.add('collapsible');
+ collapsible.expanded = createHTMLElement('div');
+ collapsible.expanded.classList.add('expanded');
+ collapsible.appendChild(collapsible.expanded);
+
+ collapsible.expanded.start = createLine();
+ collapsible.expanded.start.appendChild(createCollapseButton());
+ collapsible.expanded.appendChild(collapsible.expanded.start);
+
+ collapsible.expanded.content = createHTMLElement('div');
+ collapsible.expanded.content.classList.add('collapsible-content');
+ collapsible.expanded.appendChild(collapsible.expanded.content);
+
+ collapsible.expanded.end = createLine();
+ collapsible.expanded.appendChild(collapsible.expanded.end);
+
+ collapsible.collapsed = createHTMLElement('div');
+ collapsible.collapsed.classList.add('collapsed');
+ collapsible.collapsed.classList.add('hidden');
+ collapsible.appendChild(collapsible.collapsed);
+ collapsible.collapsed.content = createLine();
+ collapsible.collapsed.content.appendChild(createExpandButton());
+ collapsible.collapsed.appendChild(collapsible.collapsed.content);
+
+ return collapsible;
+}
+
+function createButton()
+{
+ var button = createHTMLElement('span');
+ button.classList.add('button');
+ return button;
+}
+
+function createCollapseButton(str)
+{
+ var button = createButton();
+ button.classList.add('collapse-button');
+ return button;
+}
+
+function createExpandButton(str)
+{
+ var button = createButton();
+ button.classList.add('expand-button');
+ return button;
+}
+
+function createComment(commentString)
+{
+ var comment = createHTMLElement('span');
+ comment.classList.add('webkit-html-comment');
+ comment.textContent = commentString;
+ return comment;
+}
+
+function createText(value)
+{
+ var text = createHTMLElement('span');
+ text.textContent = trim(value);
+ text.classList.add('text');
+ return text;
+}
+
+function createLine()
+{
+ var line = createHTMLElement('div');
+ line.classList.add('line');
+ return line;
+}
+
+function createTag(node, isClosing, isEmpty)
+{
+ var tag = createHTMLElement('span');
+ tag.classList.add('webkit-html-tag');
+
+ var stringBeforeAttrs = '<';
+ if (isClosing)
+ stringBeforeAttrs += '/';
+ stringBeforeAttrs += node.nodeName;
+ var textBeforeAttrs = document.createTextNode(stringBeforeAttrs);
+ tag.appendChild(textBeforeAttrs);
+
+ if (!isClosing) {
+ for (var i = 0; i < node.attributes.length; i++)
+ tag.appendChild(createAttribute(node.attributes[i]));
+ }
+
+ var stringAfterAttrs = '';
+ if (isEmpty)
+ stringAfterAttrs += '/';
+ stringAfterAttrs += '>';
+ var textAfterAttrs = document.createTextNode(stringAfterAttrs);
+ tag.appendChild(textAfterAttrs);
+
+ return tag;
+}
+
+function createAttribute(attributeNode)
+{
+ var attribute = createHTMLElement('span');
+ attribute.classList.add('webkit-html-attribute');
+
+ var attributeName = createHTMLElement('span');
+ attributeName.classList.add('webkit-html-attribute-name');
+ attributeName.textContent = attributeNode.name;
+
+ var textBefore = document.createTextNode(' ');
+ var textBetween = document.createTextNode('="');
+
+ var attributeValue = createHTMLElement('span');
+ attributeValue.classList.add('webkit-html-attribute-value');
+ attributeValue.textContent = attributeNode.value;
+
+ var textAfter = document.createTextNode('"');
+
+ attribute.appendChild(textBefore);
+ attribute.appendChild(attributeName);
+ attribute.appendChild(textBetween);
+ attribute.appendChild(attributeValue);
+ attribute.appendChild(textAfter);
+ return attribute;
+}
+
+// Tree behaviour.
+
+function drawArrows()
+{
+ var ctx = document.getCSSCanvasContext("2d", "arrowRight", 10, 11);
+
+ ctx.fillStyle = "rgb(90,90,90)";
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(0, 8);
+ ctx.lineTo(7, 4);
+ ctx.lineTo(0, 0);
+ ctx.fill();
+ ctx.closePath();
+
+ var ctx = document.getCSSCanvasContext("2d", "arrowDown", 10, 10);
+
+ ctx.fillStyle = "rgb(90,90,90)";
+ ctx.beginPath();
+ ctx.moveTo(0, 0);
+ ctx.lineTo(8, 0);
+ ctx.lineTo(4, 7);
+ ctx.lineTo(0, 0);
+ ctx.fill();
+ ctx.closePath();
+}
+
+function expandFunction(sectionId)
+{
+ return function()
+ {
+ document.querySelector('#' + sectionId + ' > .expanded').className = 'expanded';
+ document.querySelector('#' + sectionId + ' > .collapsed').className = 'collapsed hidden';
+ };
+}
+
+function collapseFunction(sectionId)
+{
+ return function()
+ {
+ document.querySelector('#' + sectionId + ' > .expanded').className = 'expanded hidden';
+ document.querySelector('#' + sectionId + ' > .collapsed').className = 'collapsed';
+ };
+}
+
+function initButtons()
+{
+ var sections = document.querySelectorAll('.collapsible');
+ for (var i = 0; i < sections.length; i++) {
+ var sectionId = 'collapsible' + i;
+ sections[i].id = sectionId;
+
+ var expandedPart = sections[i].querySelector('#' + sectionId + ' > .expanded');
+ var collapseButton = expandedPart.querySelector('.collapse-button');
+ collapseButton.onclick = collapseFunction(sectionId);
+ collapseButton.onmousedown = handleButtonMouseDown;
+
+ var collapsedPart = sections[i].querySelector('#' + sectionId + ' > .collapsed');
+ var expandButton = collapsedPart.querySelector('.expand-button');
+ expandButton.onclick = expandFunction(sectionId);
+ expandButton.onmousedown = handleButtonMouseDown;
+ }
+
+}
+
+function handleButtonMouseDown(e)
+{
+ // To prevent selection on double click
+ e.preventDefault();
+}
diff --git a/Source/WebCore/xml/XMLViewer.xsl b/Source/WebCore/xml/XMLViewer.xsl
deleted file mode 100644
index 4ee3ca8..0000000
--- a/Source/WebCore/xml/XMLViewer.xsl
+++ /dev/null
@@ -1,398 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!--
- - Copyright (C) 2011 Google Inc. All rights reserved.
- -
- - Redistribution and use in source and binary forms, with or without
- - modification, are permitted provided that the following conditions are
- - met:
- -
- - 1. Redistributions of source code must retain the above copyright
- - notice, this list of conditions and the following disclaimer.
- -
- - 2. Redistributions in binary form must reproduce the above
- - copyright notice, this list of conditions and the following disclaimer
- - in the documentation and/or other materials provided with the
- - distribution.
- -
- - THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
- - “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
- - OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- -->
-
-<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
- <xsl:output method="html"/>
- <xsl:param name="xml_has_no_style_message"/>
- <xsl:param name="downArrowBase64"/>
- <xsl:param name="rightArrowBase64"/>
-
- <xsl:template match="/">
- <xsl:call-template name="main"/>
- </xsl:template>
-
- <!-- Empty element -->
- <xsl:template match="*">
- <div class="line">
- <span class="webkit-html-tag">
- <xsl:text>&lt;</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:apply-templates select="@*"/>
- <xsl:text>/&gt;</xsl:text>
- </span>
- </div>
- </xsl:template>
-
- <!-- Element with short text only -->
- <xsl:template match="*[node()]">
- <div class="line">
- <span class="webkit-html-tag">
- <xsl:text>&lt;</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:apply-templates select="@*"/>
- <xsl:text>&gt;</xsl:text>
- </span>
-
- <span class="text"><xsl:value-of select="."/></span>
-
- <span class="webkit-html-tag">
- <xsl:text>&lt;/</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text>&gt;</xsl:text>
- </span>
- </div>
- </xsl:template>
-
- <!-- Collapsable element -->
- <xsl:template match="*[* or processing-instruction() or comment() or string-length() &gt; 50]">
- <div class="collapsable">
- <div class="expanded">
- <div class="line">
- <xsl:call-template name="collapse-button"/>
- <span class="webkit-html-tag">
- <xsl:text>&lt;</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:apply-templates select="@*"/>
- <xsl:text>&gt;</xsl:text>
- </span>
- </div>
-
- <div class="collapsable-content">
- <xsl:apply-templates/>
- </div>
-
- <div class="line">
- <span class="webkit-html-tag">
- <xsl:text>&lt;/</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text>&gt;</xsl:text>
- </span>
- </div>
- </div>
-
- <div class="collapsed hidden">
- <div class="line">
- <xsl:call-template name="expand-button"/>
- <span class="webkit-html-tag">
- <xsl:text>&lt;</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:apply-templates select="@*"/>
- <xsl:text>&gt;</xsl:text>
- <xsl:text>...</xsl:text>
- <xsl:text>&lt;/</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text>&gt;</xsl:text>
- </span>
- </div>
- </div>
- </div>
- </xsl:template>
-
- <!-- Any attribute -->
- <xsl:template match="@*">
- <xsl:text> </xsl:text>
- <span class="webkit-html-attribute-name"><xsl:value-of select="name()"/></span>
- <xsl:text>=&quot;</xsl:text>
- <span class="webkit-html-attribute-value"><xsl:value-of select="."/></span>
- <xsl:text>&quot;</xsl:text>
- </xsl:template>
-
- <!-- Short comment -->
- <xsl:template match="comment()">
- <div class="line">
- <span class="webkit-html-comment">
- <xsl:text>&lt;!--</xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>--&gt;</xsl:text>
- </span>
- </div>
- </xsl:template>
-
- <!-- Long comment -->
- <xsl:template match="comment()[string-length() &gt; 50]">
- <div class="collapsable">
- <div class="expanded">
- <div class="line">
- <xsl:call-template name="collapse-button"/>
- <span class="webkit-html-comment">
- <xsl:text>&lt;!--</xsl:text>
- </span>
- </div>
-
- <div class="collapsable-content comment">
- <span class="webkit-html-comment"><xsl:value-of select="."/></span>
- </div>
-
- <div class="line">
- <span class="webkit-html-comment">
- <xsl:text>--&gt;</xsl:text>
- </span>
- </div>
- </div>
-
- <div class="collapsed hidden">
- <div class="line">
- <xsl:call-template name="expand-button"/>
- <span class="webkit-html-comment">
- <xsl:text>&lt;!--</xsl:text>
- </span>
-
- <span class="webkit-html-comment"><xsl:text>...</xsl:text></span>
-
- <span class="webkit-html-comment">
- <xsl:text>--&gt;</xsl:text>
- </span>
- </div>
- </div>
- </div>
- </xsl:template>
-
- <!-- Short processing instruction -->
- <xsl:template match="processing-instruction()[name() != 'xml-stylesheet']">
- <div class="line">
- <span class="webkit-html-comment">
- <xsl:text>&lt;?</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>?&gt;</xsl:text>
- </span>
- </div>
- </xsl:template>
-
- <!-- Long processing instruction -->
- <xsl:template match="processing-instruction()[(string-length() &gt; 50) and (name() != 'xml-stylesheet')]">
- <div class="collapsable">
- <div class="expanded">
- <div class="line">
- <xsl:call-template name="collapse-button"/>
- <span class="webkit-html-comment">
- <xsl:text>&lt;?</xsl:text>
- <xsl:value-of select="name()"/>
- <xsl:text> </xsl:text>
- </span>
- </div>
-
- <div class="collapsable-content">
- <span class="webkit-html-comment"><xsl:value-of select="."/></span>
- </div>
-
- <div class="line">
- <span class="webkit-html-comment">
- <xsl:text>?&gt;</xsl:text>
- </span>
- </div>
- </div>
- <div class="collapsed hidden">
- <div class="line">
- <xsl:call-template name="expand-button"/>
- <span class="webkit-html-comment">
- <xsl:text>&lt;?</xsl:text>
- <xsl:value-of select="name()"/>
- </span>
-
- <span class="webkit-html-comment"><xsl:text>...</xsl:text></span>
-
- <span class="webkit-html-comment">
- <xsl:text>?&gt;</xsl:text>
- </span>
- </div>
- </div>
- </div>
- </xsl:template>
-
- <!-- Text node -->
- <xsl:template match="text()">
- <xsl:value-of select="."/>
- </xsl:template>
-
- <xsl:template name="collapse-button">
- <span class="button collapse-button">
- </span>
- </xsl:template>
-
- <xsl:template name="expand-button">
- <span class="button expand-button">
- </span>
- </xsl:template>
-
- <xsl:template name="main">
- <html>
- <head>
- <xsl:call-template name="style"/>
- <xsl:call-template name="script"/>
- </head>
- <body onload="onWebKitXMLViewerLoad()">
- <div class="header">
- <span> <xsl:value-of select="$xml_has_no_style_message"/> </span>
- <br/>
- </div>
-
- <div class="pretty-print">
- <xsl:apply-templates/>
- </div>
- <div id="source-xml"></div>
- </body>
- </html>
- </xsl:template>
-
- <xsl:template name="script">
- <script type="text/javascript">
- <xsl:text>
- function onWebKitXMLViewerLoad()
- {
- drawArrows();
- initButtons();
- }
-
- function drawArrows()
- {
- var ctx = document.getCSSCanvasContext("2d", "arrowRight", 10, 11);
-
- ctx.fillStyle = "rgb(90,90,90)";
- ctx.beginPath();
- ctx.moveTo(0, 0);
- ctx.lineTo(0, 8);
- ctx.lineTo(7, 4);
- ctx.lineTo(0, 0);
- ctx.fill();
- ctx.closePath();
-
- var ctx = document.getCSSCanvasContext("2d", "arrowDown", 10, 10);
-
- ctx.fillStyle = "rgb(90,90,90)";
- ctx.beginPath();
- ctx.moveTo(0, 0);
- ctx.lineTo(8, 0);
- ctx.lineTo(4, 7);
- ctx.lineTo(0, 0);
- ctx.fill();
- ctx.closePath();
- }
-
- function expandFunction(sectionId)
- {
- return function()
- {
- document.querySelector('#' + sectionId + ' > .expanded').className = 'expanded';
- document.querySelector('#' + sectionId + ' > .collapsed').className = 'collapsed hidden';
- };
- }
-
- function collapseFunction(sectionId)
- {
- return function()
- {
- document.querySelector('#' + sectionId + ' > .expanded').className = 'expanded hidden';
- document.querySelector('#' + sectionId + ' > .collapsed').className = 'collapsed';
- };
- }
-
- function initButtons()
- {
- var sections = document.querySelectorAll('.collapsable');
- for (var i = 0; i &lt; sections.length; i++) {
- var sectionId = 'collapsable' + i;
- sections[i].id = sectionId;
-
- var expandedPart = sections[i].querySelector('#' + sectionId + ' > .expanded');
- var collapseButton = expandedPart.querySelector('.collapse-button');
- collapseButton.onclick = collapseFunction(sectionId);
- collapseButton.onmousedown = handleButtonMouseDown;
-
- var collapsedPart = sections[i].querySelector('#' + sectionId + ' > .collapsed');
- var expandButton = collapsedPart.querySelector('.expand-button');
- expandButton.onclick = expandFunction(sectionId);
- expandButton.onmousedown = handleButtonMouseDown;
- }
-
- }
-
- function handleButtonMouseDown(e)
- {
- // To prevent selection on double click
- e.preventDefault();
- }
- </xsl:text>
- </script>
- </xsl:template>
-
- <xsl:template name="style">
- <style type="text/css">
- div.header {
- border-bottom: 2px solid black;
- padding-bottom: 5px;
- margin: 10px;
- }
-
- div.collapsable > div.hidden {
- display:none;
- }
-
- .pretty-print {
- margin-top: 1em;
- margin-left: 20px;
- font-family: monospace;
- font-size: 13px;
- }
-
- #source-xml {
- display: none;
- }
-
- .collapsable-content {
- margin-left: 1em;
- }
- .comment {
- whitespace: pre;
- }
-
- .button {
- -webkit-user-select: none;
- cursor: pointer;
- display: inline-block;
- margin-left: -10px;
- width: 10px;
- background-repeat: no-repeat;
- background-position: left top;
- vertical-align: bottom;
- }
-
- .collapse-button {
- background-image: -webkit-canvas(arrowDown);
- height: 10px;
- }
-
- .expand-button {
- background-image: -webkit-canvas(arrowRight);
- height: 11px;
- }
- </style>
- </xsl:template>
-</xsl:stylesheet>
diff --git a/Source/WebCore/xml/XSLStyleSheet.h b/Source/WebCore/xml/XSLStyleSheet.h
index dbe87b5..b36ac1d 100644
--- a/Source/WebCore/xml/XSLStyleSheet.h
+++ b/Source/WebCore/xml/XSLStyleSheet.h
@@ -63,14 +63,6 @@ public:
return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false));
}
- static PassRefPtr<XSLStyleSheet> createForXMLTreeViewer(Node* node, const String& sheetString)
- {
- RefPtr<XSLStyleSheet> sheet = adoptRef(new XSLStyleSheet(node, String(), KURL(), false));
- sheet->parseString(sheetString);
-
- return sheet.release();
- }
-
virtual ~XSLStyleSheet();
virtual bool isXSLStyleSheet() const { return true; }