Commit 3ab65053 authored by hyatt's avatar hyatt
Browse files

"Linkify" view source mode links.

        Reviewed by andersca

        * css/view-source.css:
        * html/HTMLViewSourceDocument.cpp:
        (WebCore::HTMLViewSourceDocument::addViewSourceToken):
        (WebCore::HTMLViewSourceDocument::addSpanWithClassName):
        (WebCore::HTMLViewSourceDocument::addLink):
        * html/HTMLViewSourceDocument.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21597 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fada1d18
2007-05-18 David Hyatt <hyatt@apple.com>
"Linkify" view source mode links.
Reviewed by andersca
* css/view-source.css:
* html/HTMLViewSourceDocument.cpp:
(WebCore::HTMLViewSourceDocument::addViewSourceToken):
(WebCore::HTMLViewSourceDocument::addSpanWithClassName):
(WebCore::HTMLViewSourceDocument::addLink):
* html/HTMLViewSourceDocument.h:
2007-05-18 Oliver Hunt <oliver@apple.com>
 
Reviewed by Sam
......@@ -42,7 +42,7 @@ td {
.webkit-line-number {
padding: 0 2px;
min-width: 17px;
min-width: 21px;
background-color: rgb(240, 240, 240);
border-right: 1px solid rgb(128, 128, 128) !important;
-webkit-user-select: none;
......@@ -73,7 +73,7 @@ td {
}
.webkit-html-attribute-value {
color: rgb(26, 26, 166)
color: rgb(26, 26, 166) !important
}
.webkit-html-comment {
......
......@@ -26,8 +26,8 @@
#include "HTMLViewSourceDocument.h"
#include "HTMLTokenizer.h"
#include "HTMLHtmlElement.h"
#include "HTMLAnchorElement.h"
#include "HTMLBodyElement.h"
#include "HTMLPreElement.h"
#include "HTMLTableElement.h"
#include "HTMLTableCellElement.h"
#include "HTMLTableRowElement.h"
......@@ -122,10 +122,13 @@ void HTMLViewSourceDocument::addViewSourceToken(Token* token)
if (doctype)
addText(value, "webkit-html-doctype");
else {
m_current = addSpanWithClassName("webkit-html-attribute-value");
if (equalIgnoringCase(attr->name().localName(), "src") || equalIgnoringCase(attr->name().localName(), "href"))
m_current = addLink(value);
else
m_current = addSpanWithClassName("webkit-html-attribute-value");
addText(value, "webkit-html-attribute-value");
if (m_current != m_tbody)
m_current = m_current->parent();
m_current = static_cast<Element*>(m_current->parent());
}
currAttr++;
}
......@@ -147,8 +150,11 @@ void HTMLViewSourceDocument::addViewSourceToken(Token* token)
Element* HTMLViewSourceDocument::addSpanWithClassName(const String& className)
{
if (m_current == m_tbody)
if (m_current == m_tbody) {
addLine(className);
return m_current;
}
Element* span = new HTMLElement(spanTag, this);
Attribute* a = new MappedAttribute(classAttr, className);
NamedMappedAttrMap* attrs = new NamedMappedAttrMap(0);
......@@ -223,4 +229,24 @@ void HTMLViewSourceDocument::addText(const String& text, const String& className
m_current = m_tbody;
}
Element* HTMLViewSourceDocument::addLink(const String& url)
{
if (m_current == m_tbody)
addLine("webkit-html-tag");
// Now create a link for the attribute value instead of a span.
Element* anchor = new HTMLAnchorElement(aTag, this);
NamedMappedAttrMap* attrs = new NamedMappedAttrMap(0);
Attribute* classAttribute = new MappedAttribute(classAttr, "webkit-html-attribute-value");
attrs->insertAttribute(classAttribute, true);
Attribute* targetAttribute = new MappedAttribute(targetAttr, "_blank");
attrs->insertAttribute(targetAttribute, true);
Attribute* hrefAttribute = new MappedAttribute(hrefAttr, url);
attrs->insertAttribute(hrefAttribute, true);
anchor->setAttributeMap(attrs);
m_current->addChild(anchor);
anchor->attach();
return anchor;
}
}
......@@ -43,11 +43,12 @@ private:
Element* addSpanWithClassName(const String&);
void addLine(const String& className);
void addText(const String& text, const String& className);
Element* addLink(const String& url);
private:
Node* m_current;
Node* m_tbody;
Node* m_td;
Element* m_current;
Element* m_tbody;
Element* m_td;
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment