summaryrefslogtreecommitdiffstats
path: root/WebCore/html/HTMLViewSourceDocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/HTMLViewSourceDocument.cpp')
-rw-r--r--WebCore/html/HTMLViewSourceDocument.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/WebCore/html/HTMLViewSourceDocument.cpp b/WebCore/html/HTMLViewSourceDocument.cpp
index 13404cc..ba718d1 100644
--- a/WebCore/html/HTMLViewSourceDocument.cpp
+++ b/WebCore/html/HTMLViewSourceDocument.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,9 +47,6 @@ using namespace HTMLNames;
HTMLViewSourceDocument::HTMLViewSourceDocument(Frame* frame, const String& mimeType)
: HTMLDocument(frame)
, m_type(mimeType)
- , m_current(0)
- , m_tbody(0)
- , m_td(0)
{
setUsesBeforeAfterRules(true);
}
@@ -70,23 +67,23 @@ Tokenizer* HTMLViewSourceDocument::createTokenizer()
void HTMLViewSourceDocument::createContainingTable()
{
- RefPtr<Element> html = new HTMLHtmlElement(htmlTag, this);
+ RefPtr<HTMLHtmlElement> html = new HTMLHtmlElement(htmlTag, this);
addChild(html);
html->attach();
- RefPtr<Element> body = new HTMLBodyElement(bodyTag, this);
+ RefPtr<HTMLBodyElement> body = new HTMLBodyElement(bodyTag, this);
html->addChild(body);
body->attach();
// Create a line gutter div that can be used to make sure the gutter extends down the height of the whole
// document.
- RefPtr<Element> div = new HTMLDivElement(divTag, this);
+ RefPtr<HTMLDivElement> div = new HTMLDivElement(divTag, this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
attrs->addAttribute(MappedAttribute::create(classAttr, "webkit-line-gutter-backdrop"));
div->setAttributeMap(attrs.release());
body->addChild(div);
div->attach();
- RefPtr<Element> table = new HTMLTableElement(tableTag, this);
+ RefPtr<HTMLTableElement> table = new HTMLTableElement(tableTag, this);
body->addChild(table);
table->attach();
m_tbody = new HTMLTableSectionElement(tbodyTag, this);
@@ -205,31 +202,31 @@ void HTMLViewSourceDocument::addViewSourceDoctypeToken(DoctypeToken* doctypeToke
addText(text, "webkit-html-doctype");
}
-Element* HTMLViewSourceDocument::addSpanWithClassName(const String& className)
+PassRefPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(const String& className)
{
if (m_current == m_tbody) {
addLine(className);
return m_current;
}
- Element* span = new HTMLElement(spanTag, this);
+ RefPtr<HTMLElement> span = HTMLElement::create(spanTag, this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
attrs->addAttribute(MappedAttribute::create(classAttr, className));
span->setAttributeMap(attrs.release());
m_current->addChild(span);
span->attach();
- return span;
+ return span.release();
}
void HTMLViewSourceDocument::addLine(const String& className)
{
// Create a table row.
- RefPtr<Element> trow = new HTMLTableRowElement(trTag, this);
+ RefPtr<HTMLTableRowElement> trow = new HTMLTableRowElement(trTag, this);
m_tbody->addChild(trow);
trow->attach();
// Create a cell that will hold the line number (it is generated in the stylesheet using counters).
- Element* td = new HTMLTableCellElement(tdTag, this);
+ RefPtr<HTMLTableCellElement> td = new HTMLTableCellElement(tdTag, this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
attrs->addAttribute(MappedAttribute::create(classAttr, "webkit-line-number"));
td->setAttributeMap(attrs.release());
@@ -246,7 +243,7 @@ void HTMLViewSourceDocument::addLine(const String& className)
m_current = m_td = td;
#ifdef DEBUG_LINE_NUMBERS
- RefPtr<Text> lineNumberText = new Text(this, String::number(tokenizer()->lineNumber() + 1) + " ");
+ RefPtr<Text> lineNumberText = Text::create(this, String::number(tokenizer()->lineNumber() + 1) + " ");
td->addChild(lineNumberText);
lineNumberText->attach();
#endif
@@ -277,7 +274,7 @@ void HTMLViewSourceDocument::addText(const String& text, const String& className
}
if (m_current == m_tbody)
addLine(className);
- RefPtr<Text> t = new Text(this, substring);
+ RefPtr<Text> t = Text::create(this, substring);
m_current->addChild(t);
t->attach();
if (i < size - 1)
@@ -289,13 +286,13 @@ void HTMLViewSourceDocument::addText(const String& text, const String& className
m_current = m_tbody;
}
-Element* HTMLViewSourceDocument::addLink(const String& url, bool isAnchor)
+PassRefPtr<Element> HTMLViewSourceDocument::addLink(const String& url, bool isAnchor)
{
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);
+ RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(this);
RefPtr<NamedMappedAttrMap> attrs = NamedMappedAttrMap::create();
const char* classValue;
if (isAnchor)
@@ -308,7 +305,7 @@ Element* HTMLViewSourceDocument::addLink(const String& url, bool isAnchor)
anchor->setAttributeMap(attrs.release());
m_current->addChild(anchor);
anchor->attach();
- return anchor;
+ return anchor.release();
}
}