Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: Source/core/html/HTMLViewSourceDocument.cpp

Issue 306953006: Remove webkit- prefix from classes used by View Source (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/view-source.css ('k') | Source/core/inspector/InspectorOverlayPage.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 RefPtrWillBeRawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*this); 74 RefPtrWillBeRawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*this);
75 parserAppendChild(html); 75 parserAppendChild(html);
76 RefPtrWillBeRawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this); 76 RefPtrWillBeRawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this);
77 html->parserAppendChild(head); 77 html->parserAppendChild(head);
78 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this); 78 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this);
79 html->parserAppendChild(body); 79 html->parserAppendChild(body);
80 80
81 // Create a line gutter div that can be used to make sure the gutter extends down the height of the whole 81 // Create a line gutter div that can be used to make sure the gutter extends down the height of the whole
82 // document. 82 // document.
83 RefPtrWillBeRawPtr<HTMLDivElement> div = HTMLDivElement::create(*this); 83 RefPtrWillBeRawPtr<HTMLDivElement> div = HTMLDivElement::create(*this);
84 div->setAttribute(classAttr, "webkit-line-gutter-backdrop"); 84 div->setAttribute(classAttr, "line-gutter-backdrop");
85 body->parserAppendChild(div); 85 body->parserAppendChild(div);
86 86
87 RefPtrWillBeRawPtr<HTMLTableElement> table = HTMLTableElement::create(*this) ; 87 RefPtrWillBeRawPtr<HTMLTableElement> table = HTMLTableElement::create(*this) ;
88 body->parserAppendChild(table); 88 body->parserAppendChild(table);
89 m_tbody = HTMLTableSectionElement::create(tbodyTag, *this); 89 m_tbody = HTMLTableSectionElement::create(tbodyTag, *this);
90 table->parserAppendChild(m_tbody); 90 table->parserAppendChild(m_tbody);
91 m_current = m_tbody; 91 m_current = m_tbody;
92 m_lineNumber = 0; 92 m_lineNumber = 0;
93 } 93 }
94 94
(...skipping 20 matching lines...) Expand all
115 processCommentToken(source, token); 115 processCommentToken(source, token);
116 break; 116 break;
117 case HTMLToken::Character: 117 case HTMLToken::Character:
118 processCharacterToken(source, token, annotation); 118 processCharacterToken(source, token, annotation);
119 break; 119 break;
120 } 120 }
121 } 121 }
122 122
123 void HTMLViewSourceDocument::processDoctypeToken(const String& source, HTMLToken &) 123 void HTMLViewSourceDocument::processDoctypeToken(const String& source, HTMLToken &)
124 { 124 {
125 m_current = addSpanWithClassName("webkit-html-doctype"); 125 m_current = addSpanWithClassName("html-doctype");
126 addText(source, "webkit-html-doctype"); 126 addText(source, "html-doctype");
127 m_current = m_td; 127 m_current = m_td;
128 } 128 }
129 129
130 void HTMLViewSourceDocument::processEndOfFileToken(const String& source, HTMLTok en&) 130 void HTMLViewSourceDocument::processEndOfFileToken(const String& source, HTMLTok en&)
131 { 131 {
132 m_current = addSpanWithClassName("webkit-html-end-of-file"); 132 m_current = addSpanWithClassName("html-end-of-file");
133 addText(source, "webkit-html-end-of-file"); 133 addText(source, "html-end-of-file");
134 m_current = m_td; 134 m_current = m_td;
135 } 135 }
136 136
137 void HTMLViewSourceDocument::processTagToken(const String& source, HTMLToken& to ken, SourceAnnotation annotation) 137 void HTMLViewSourceDocument::processTagToken(const String& source, HTMLToken& to ken, SourceAnnotation annotation)
138 { 138 {
139 maybeAddSpanForAnnotation(annotation); 139 maybeAddSpanForAnnotation(annotation);
140 m_current = addSpanWithClassName("webkit-html-tag"); 140 m_current = addSpanWithClassName("html-tag");
141 141
142 AtomicString tagName(token.name()); 142 AtomicString tagName(token.name());
143 143
144 unsigned index = 0; 144 unsigned index = 0;
145 HTMLToken::AttributeList::const_iterator iter = token.attributes().begin(); 145 HTMLToken::AttributeList::const_iterator iter = token.attributes().begin();
146 while (index < source.length()) { 146 while (index < source.length()) {
147 if (iter == token.attributes().end()) { 147 if (iter == token.attributes().end()) {
148 // We want to show the remaining characters in the token. 148 // We want to show the remaining characters in the token.
149 index = addRange(source, index, source.length(), emptyAtom); 149 index = addRange(source, index, source.length(), emptyAtom);
150 ASSERT(index == source.length()); 150 ASSERT(index == source.length());
151 break; 151 break;
152 } 152 }
153 153
154 AtomicString name(iter->name); 154 AtomicString name(iter->name);
155 AtomicString value(StringImpl::create8BitIfPossible(iter->value)); 155 AtomicString value(StringImpl::create8BitIfPossible(iter->value));
156 156
157 index = addRange(source, index, iter->nameRange.start - token.startIndex (), emptyAtom); 157 index = addRange(source, index, iter->nameRange.start - token.startIndex (), emptyAtom);
158 index = addRange(source, index, iter->nameRange.end - token.startIndex() , "webkit-html-attribute-name"); 158 index = addRange(source, index, iter->nameRange.end - token.startIndex() , "html-attribute-name");
159 159
160 if (tagName == baseTag && name == hrefAttr) 160 if (tagName == baseTag && name == hrefAttr)
161 addBase(value); 161 addBase(value);
162 162
163 index = addRange(source, index, iter->valueRange.start - token.startInde x(), emptyAtom); 163 index = addRange(source, index, iter->valueRange.start - token.startInde x(), emptyAtom);
164 164
165 bool isLink = name == srcAttr || name == hrefAttr; 165 bool isLink = name == srcAttr || name == hrefAttr;
166 index = addRange(source, index, iter->valueRange.end - token.startIndex( ), "webkit-html-attribute-value", isLink, tagName == aTag, value); 166 index = addRange(source, index, iter->valueRange.end - token.startIndex( ), "html-attribute-value", isLink, tagName == aTag, value);
167 167
168 ++iter; 168 ++iter;
169 } 169 }
170 m_current = m_td; 170 m_current = m_td;
171 } 171 }
172 172
173 void HTMLViewSourceDocument::processCommentToken(const String& source, HTMLToken &) 173 void HTMLViewSourceDocument::processCommentToken(const String& source, HTMLToken &)
174 { 174 {
175 m_current = addSpanWithClassName("webkit-html-comment"); 175 m_current = addSpanWithClassName("html-comment");
176 addText(source, "webkit-html-comment"); 176 addText(source, "html-comment");
177 m_current = m_td; 177 m_current = m_td;
178 } 178 }
179 179
180 void HTMLViewSourceDocument::processCharacterToken(const String& source, HTMLTok en&, SourceAnnotation annotation) 180 void HTMLViewSourceDocument::processCharacterToken(const String& source, HTMLTok en&, SourceAnnotation annotation)
181 { 181 {
182 addText(source, "", annotation); 182 addText(source, "", annotation);
183 } 183 }
184 184
185 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(con st AtomicString& className) 185 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(con st AtomicString& className)
186 { 186 {
187 if (m_current == m_tbody) { 187 if (m_current == m_tbody) {
188 addLine(className); 188 addLine(className);
189 return m_current; 189 return m_current;
190 } 190 }
191 191
192 RefPtrWillBeRawPtr<HTMLSpanElement> span = HTMLSpanElement::create(*this); 192 RefPtrWillBeRawPtr<HTMLSpanElement> span = HTMLSpanElement::create(*this);
193 span->setAttribute(classAttr, className); 193 span->setAttribute(classAttr, className);
194 m_current->parserAppendChild(span); 194 m_current->parserAppendChild(span);
195 return span.release(); 195 return span.release();
196 } 196 }
197 197
198 void HTMLViewSourceDocument::addLine(const AtomicString& className) 198 void HTMLViewSourceDocument::addLine(const AtomicString& className)
199 { 199 {
200 // Create a table row. 200 // Create a table row.
201 RefPtrWillBeRawPtr<HTMLTableRowElement> trow = HTMLTableRowElement::create(* this); 201 RefPtrWillBeRawPtr<HTMLTableRowElement> trow = HTMLTableRowElement::create(* this);
202 m_tbody->parserAppendChild(trow); 202 m_tbody->parserAppendChild(trow);
203 203
204 // Create a cell that will hold the line number (it is generated in the styl esheet using counters). 204 // Create a cell that will hold the line number (it is generated in the styl esheet using counters).
205 RefPtrWillBeRawPtr<HTMLTableCellElement> td = HTMLTableCellElement::create(t dTag, *this); 205 RefPtrWillBeRawPtr<HTMLTableCellElement> td = HTMLTableCellElement::create(t dTag, *this);
206 td->setAttribute(classAttr, "webkit-line-number"); 206 td->setAttribute(classAttr, "line-number");
207 td->setIntegralAttribute(valueAttr, ++m_lineNumber); 207 td->setIntegralAttribute(valueAttr, ++m_lineNumber);
208 trow->parserAppendChild(td); 208 trow->parserAppendChild(td);
209 209
210 // Create a second cell for the line contents 210 // Create a second cell for the line contents
211 td = HTMLTableCellElement::create(tdTag, *this); 211 td = HTMLTableCellElement::create(tdTag, *this);
212 td->setAttribute(classAttr, "webkit-line-content"); 212 td->setAttribute(classAttr, "line-content");
213 trow->parserAppendChild(td); 213 trow->parserAppendChild(td);
214 m_current = m_td = td; 214 m_current = m_td = td;
215 215
216 // Open up the needed spans. 216 // Open up the needed spans.
217 if (!className.isEmpty()) { 217 if (!className.isEmpty()) {
218 if (className == "webkit-html-attribute-name" || className == "webkit-ht ml-attribute-value") 218 if (className == "html-attribute-name" || className == "html-attribute-v alue")
219 m_current = addSpanWithClassName("webkit-html-tag"); 219 m_current = addSpanWithClassName("html-tag");
220 m_current = addSpanWithClassName(className); 220 m_current = addSpanWithClassName(className);
221 } 221 }
222 } 222 }
223 223
224 void HTMLViewSourceDocument::finishLine() 224 void HTMLViewSourceDocument::finishLine()
225 { 225 {
226 if (!m_current->hasChildren()) { 226 if (!m_current->hasChildren()) {
227 RefPtrWillBeRawPtr<HTMLBRElement> br = HTMLBRElement::create(*this); 227 RefPtrWillBeRawPtr<HTMLBRElement> br = HTMLBRElement::create(*this);
228 m_current->parserAppendChild(br); 228 m_current->parserAppendChild(br);
229 } 229 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 { 281 {
282 RefPtrWillBeRawPtr<HTMLBaseElement> base = HTMLBaseElement::create(*this); 282 RefPtrWillBeRawPtr<HTMLBaseElement> base = HTMLBaseElement::create(*this);
283 base->setAttribute(hrefAttr, href); 283 base->setAttribute(hrefAttr, href);
284 m_current->parserAppendChild(base); 284 m_current->parserAppendChild(base);
285 return base.release(); 285 return base.release();
286 } 286 }
287 287
288 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addLink(const AtomicStri ng& url, bool isAnchor) 288 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addLink(const AtomicStri ng& url, bool isAnchor)
289 { 289 {
290 if (m_current == m_tbody) 290 if (m_current == m_tbody)
291 addLine("webkit-html-tag"); 291 addLine("html-tag");
292 292
293 // Now create a link for the attribute value instead of a span. 293 // Now create a link for the attribute value instead of a span.
294 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(*th is); 294 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(*th is);
295 const char* classValue; 295 const char* classValue;
296 if (isAnchor) 296 if (isAnchor)
297 classValue = "webkit-html-attribute-value webkit-html-external-link"; 297 classValue = "html-attribute-value html-external-link";
298 else 298 else
299 classValue = "webkit-html-attribute-value webkit-html-resource-link"; 299 classValue = "html-attribute-value html-resource-link";
300 anchor->setAttribute(classAttr, classValue); 300 anchor->setAttribute(classAttr, classValue);
301 anchor->setAttribute(targetAttr, "_blank"); 301 anchor->setAttribute(targetAttr, "_blank");
302 anchor->setAttribute(hrefAttr, url); 302 anchor->setAttribute(hrefAttr, url);
303 m_current->parserAppendChild(anchor); 303 m_current->parserAppendChild(anchor);
304 return anchor.release(); 304 return anchor.release();
305 } 305 }
306 306
307 void HTMLViewSourceDocument::maybeAddSpanForAnnotation(SourceAnnotation annotati on) 307 void HTMLViewSourceDocument::maybeAddSpanForAnnotation(SourceAnnotation annotati on)
308 { 308 {
309 if (annotation == AnnotateSourceAsXSS) { 309 if (annotation == AnnotateSourceAsXSS) {
310 m_current = addSpanWithClassName("webkit-highlight"); 310 m_current = addSpanWithClassName("highlight");
311 m_current->setAttribute(titleAttr, kXSSDetected); 311 m_current->setAttribute(titleAttr, kXSSDetected);
312 } 312 }
313 } 313 }
314 314
315 void HTMLViewSourceDocument::trace(Visitor* visitor) 315 void HTMLViewSourceDocument::trace(Visitor* visitor)
316 { 316 {
317 visitor->trace(m_current); 317 visitor->trace(m_current);
318 visitor->trace(m_tbody); 318 visitor->trace(m_tbody);
319 visitor->trace(m_td); 319 visitor->trace(m_td);
320 HTMLDocument::trace(visitor); 320 HTMLDocument::trace(visitor);
321 } 321 }
322 322
323 } 323 }
OLDNEW
« no previous file with comments | « Source/core/css/view-source.css ('k') | Source/core/inspector/InspectorOverlayPage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698