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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 : HTMLDocument(initializer) 53 : HTMLDocument(initializer)
54 , m_type(mimeType) 54 , m_type(mimeType)
55 { 55 {
56 setIsViewSource(true); 56 setIsViewSource(true);
57 57
58 // FIXME: Why do view-source pages need to load in quirks mode? 58 // FIXME: Why do view-source pages need to load in quirks mode?
59 setCompatibilityMode(QuirksMode); 59 setCompatibilityMode(QuirksMode);
60 lockCompatibilityMode(); 60 lockCompatibilityMode();
61 } 61 }
62 62
63 PassRefPtrWillBeRawPtr<DocumentParser> HTMLViewSourceDocument::createParser() 63 RawPtr<DocumentParser> HTMLViewSourceDocument::createParser()
64 { 64 {
65 return HTMLViewSourceParser::create(*this, m_type); 65 return HTMLViewSourceParser::create(*this, m_type);
66 } 66 }
67 67
68 void HTMLViewSourceDocument::createContainingTable() 68 void HTMLViewSourceDocument::createContainingTable()
69 { 69 {
70 RefPtrWillBeRawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*this); 70 RawPtr<HTMLHtmlElement> html = HTMLHtmlElement::create(*this);
71 parserAppendChild(html); 71 parserAppendChild(html);
72 RefPtrWillBeRawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this); 72 RawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*this);
73 html->parserAppendChild(head); 73 html->parserAppendChild(head);
74 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this); 74 RawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*this);
75 html->parserAppendChild(body); 75 html->parserAppendChild(body);
76 76
77 // Create a line gutter div that can be used to make sure the gutter extends down the height of the whole 77 // Create a line gutter div that can be used to make sure the gutter extends down the height of the whole
78 // document. 78 // document.
79 RefPtrWillBeRawPtr<HTMLDivElement> div = HTMLDivElement::create(*this); 79 RawPtr<HTMLDivElement> div = HTMLDivElement::create(*this);
80 div->setAttribute(classAttr, "line-gutter-backdrop"); 80 div->setAttribute(classAttr, "line-gutter-backdrop");
81 body->parserAppendChild(div); 81 body->parserAppendChild(div);
82 82
83 RefPtrWillBeRawPtr<HTMLTableElement> table = HTMLTableElement::create(*this) ; 83 RawPtr<HTMLTableElement> table = HTMLTableElement::create(*this);
84 body->parserAppendChild(table); 84 body->parserAppendChild(table);
85 m_tbody = HTMLTableSectionElement::create(tbodyTag, *this); 85 m_tbody = HTMLTableSectionElement::create(tbodyTag, *this);
86 table->parserAppendChild(m_tbody); 86 table->parserAppendChild(m_tbody);
87 m_current = m_tbody; 87 m_current = m_tbody;
88 m_lineNumber = 0; 88 m_lineNumber = 0;
89 } 89 }
90 90
91 void HTMLViewSourceDocument::addSource(const String& source, HTMLToken& token, S ourceAnnotation annotation) 91 void HTMLViewSourceDocument::addSource(const String& source, HTMLToken& token, S ourceAnnotation annotation)
92 { 92 {
93 if (!m_current) 93 if (!m_current)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 m_current = addSpanWithClassName("html-comment"); 171 m_current = addSpanWithClassName("html-comment");
172 addText(source, "html-comment"); 172 addText(source, "html-comment");
173 m_current = m_td; 173 m_current = m_td;
174 } 174 }
175 175
176 void HTMLViewSourceDocument::processCharacterToken(const String& source, HTMLTok en&, SourceAnnotation annotation) 176 void HTMLViewSourceDocument::processCharacterToken(const String& source, HTMLTok en&, SourceAnnotation annotation)
177 { 177 {
178 addText(source, "", annotation); 178 addText(source, "", annotation);
179 } 179 }
180 180
181 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(con st AtomicString& className) 181 RawPtr<Element> HTMLViewSourceDocument::addSpanWithClassName(const AtomicString& className)
182 { 182 {
183 if (m_current == m_tbody) { 183 if (m_current == m_tbody) {
184 addLine(className); 184 addLine(className);
185 return m_current; 185 return m_current;
186 } 186 }
187 187
188 RefPtrWillBeRawPtr<HTMLSpanElement> span = HTMLSpanElement::create(*this); 188 RawPtr<HTMLSpanElement> span = HTMLSpanElement::create(*this);
189 span->setAttribute(classAttr, className); 189 span->setAttribute(classAttr, className);
190 m_current->parserAppendChild(span); 190 m_current->parserAppendChild(span);
191 return span.release(); 191 return span.release();
192 } 192 }
193 193
194 void HTMLViewSourceDocument::addLine(const AtomicString& className) 194 void HTMLViewSourceDocument::addLine(const AtomicString& className)
195 { 195 {
196 // Create a table row. 196 // Create a table row.
197 RefPtrWillBeRawPtr<HTMLTableRowElement> trow = HTMLTableRowElement::create(* this); 197 RawPtr<HTMLTableRowElement> trow = HTMLTableRowElement::create(*this);
198 m_tbody->parserAppendChild(trow); 198 m_tbody->parserAppendChild(trow);
199 199
200 // Create a cell that will hold the line number (it is generated in the styl esheet using counters). 200 // Create a cell that will hold the line number (it is generated in the styl esheet using counters).
201 RefPtrWillBeRawPtr<HTMLTableCellElement> td = HTMLTableCellElement::create(t dTag, *this); 201 RawPtr<HTMLTableCellElement> td = HTMLTableCellElement::create(tdTag, *this) ;
202 td->setAttribute(classAttr, "line-number"); 202 td->setAttribute(classAttr, "line-number");
203 td->setIntegralAttribute(valueAttr, ++m_lineNumber); 203 td->setIntegralAttribute(valueAttr, ++m_lineNumber);
204 trow->parserAppendChild(td); 204 trow->parserAppendChild(td);
205 205
206 // Create a second cell for the line contents 206 // Create a second cell for the line contents
207 td = HTMLTableCellElement::create(tdTag, *this); 207 td = HTMLTableCellElement::create(tdTag, *this);
208 td->setAttribute(classAttr, "line-content"); 208 td->setAttribute(classAttr, "line-content");
209 trow->parserAppendChild(td); 209 trow->parserAppendChild(td);
210 m_current = m_td = td; 210 m_current = m_td = td;
211 211
212 // Open up the needed spans. 212 // Open up the needed spans.
213 if (!className.isEmpty()) { 213 if (!className.isEmpty()) {
214 if (className == "html-attribute-name" || className == "html-attribute-v alue") 214 if (className == "html-attribute-name" || className == "html-attribute-v alue")
215 m_current = addSpanWithClassName("html-tag"); 215 m_current = addSpanWithClassName("html-tag");
216 m_current = addSpanWithClassName(className); 216 m_current = addSpanWithClassName(className);
217 } 217 }
218 } 218 }
219 219
220 void HTMLViewSourceDocument::finishLine() 220 void HTMLViewSourceDocument::finishLine()
221 { 221 {
222 if (!m_current->hasChildren()) { 222 if (!m_current->hasChildren()) {
223 RefPtrWillBeRawPtr<HTMLBRElement> br = HTMLBRElement::create(*this); 223 RawPtr<HTMLBRElement> br = HTMLBRElement::create(*this);
224 m_current->parserAppendChild(br); 224 m_current->parserAppendChild(br);
225 } 225 }
226 m_current = m_tbody; 226 m_current = m_tbody;
227 } 227 }
228 228
229 void HTMLViewSourceDocument::addText(const String& text, const AtomicString& cla ssName, SourceAnnotation annotation) 229 void HTMLViewSourceDocument::addText(const String& text, const AtomicString& cla ssName, SourceAnnotation annotation)
230 { 230 {
231 if (text.isEmpty()) 231 if (text.isEmpty())
232 return; 232 return;
233 233
234 // Add in the content, splitting on newlines. 234 // Add in the content, splitting on newlines.
235 Vector<String> lines; 235 Vector<String> lines;
236 text.split('\n', true, lines); 236 text.split('\n', true, lines);
237 unsigned size = lines.size(); 237 unsigned size = lines.size();
238 for (unsigned i = 0; i < size; i++) { 238 for (unsigned i = 0; i < size; i++) {
239 String substring = lines[i]; 239 String substring = lines[i];
240 if (m_current == m_tbody) 240 if (m_current == m_tbody)
241 addLine(className); 241 addLine(className);
242 if (substring.isEmpty()) { 242 if (substring.isEmpty()) {
243 if (i == size - 1) 243 if (i == size - 1)
244 break; 244 break;
245 finishLine(); 245 finishLine();
246 continue; 246 continue;
247 } 247 }
248 RefPtrWillBeRawPtr<Element> oldElement = m_current; 248 RawPtr<Element> oldElement = m_current;
249 maybeAddSpanForAnnotation(annotation); 249 maybeAddSpanForAnnotation(annotation);
250 m_current->parserAppendChild(Text::create(*this, substring)); 250 m_current->parserAppendChild(Text::create(*this, substring));
251 m_current = oldElement; 251 m_current = oldElement;
252 if (i < size - 1) 252 if (i < size - 1)
253 finishLine(); 253 finishLine();
254 } 254 }
255 } 255 }
256 256
257 int HTMLViewSourceDocument::addRange(const String& source, int start, int end, c onst AtomicString& className, bool isLink, bool isAnchor, const AtomicString& li nk) 257 int HTMLViewSourceDocument::addRange(const String& source, int start, int end, c onst AtomicString& className, bool isLink, bool isAnchor, const AtomicString& li nk)
258 { 258 {
259 ASSERT(start <= end); 259 ASSERT(start <= end);
260 if (start == end) 260 if (start == end)
261 return start; 261 return start;
262 262
263 String text = source.substring(start, end - start); 263 String text = source.substring(start, end - start);
264 if (!className.isEmpty()) { 264 if (!className.isEmpty()) {
265 if (isLink) 265 if (isLink)
266 m_current = addLink(link, isAnchor); 266 m_current = addLink(link, isAnchor);
267 else 267 else
268 m_current = addSpanWithClassName(className); 268 m_current = addSpanWithClassName(className);
269 } 269 }
270 addText(text, className); 270 addText(text, className);
271 if (!className.isEmpty() && m_current != m_tbody) 271 if (!className.isEmpty() && m_current != m_tbody)
272 m_current = toElement(m_current->parentNode()); 272 m_current = toElement(m_current->parentNode());
273 return end; 273 return end;
274 } 274 }
275 275
276 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addBase(const AtomicStri ng& href) 276 RawPtr<Element> HTMLViewSourceDocument::addBase(const AtomicString& href)
277 { 277 {
278 RefPtrWillBeRawPtr<HTMLBaseElement> base = HTMLBaseElement::create(*this); 278 RawPtr<HTMLBaseElement> base = HTMLBaseElement::create(*this);
279 base->setAttribute(hrefAttr, href); 279 base->setAttribute(hrefAttr, href);
280 m_current->parserAppendChild(base); 280 m_current->parserAppendChild(base);
281 return base.release(); 281 return base.release();
282 } 282 }
283 283
284 PassRefPtrWillBeRawPtr<Element> HTMLViewSourceDocument::addLink(const AtomicStri ng& url, bool isAnchor) 284 RawPtr<Element> HTMLViewSourceDocument::addLink(const AtomicString& url, bool is Anchor)
285 { 285 {
286 if (m_current == m_tbody) 286 if (m_current == m_tbody)
287 addLine("html-tag"); 287 addLine("html-tag");
288 288
289 // Now create a link for the attribute value instead of a span. 289 // Now create a link for the attribute value instead of a span.
290 RefPtrWillBeRawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(*th is); 290 RawPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(*this);
291 const char* classValue; 291 const char* classValue;
292 if (isAnchor) 292 if (isAnchor)
293 classValue = "html-attribute-value html-external-link"; 293 classValue = "html-attribute-value html-external-link";
294 else 294 else
295 classValue = "html-attribute-value html-resource-link"; 295 classValue = "html-attribute-value html-resource-link";
296 anchor->setAttribute(classAttr, classValue); 296 anchor->setAttribute(classAttr, classValue);
297 anchor->setAttribute(targetAttr, "_blank"); 297 anchor->setAttribute(targetAttr, "_blank");
298 anchor->setAttribute(hrefAttr, url); 298 anchor->setAttribute(hrefAttr, url);
299 m_current->parserAppendChild(anchor); 299 m_current->parserAppendChild(anchor);
300 return anchor.release(); 300 return anchor.release();
(...skipping 19 matching lines...) Expand all
320 320
321 DEFINE_TRACE(HTMLViewSourceDocument) 321 DEFINE_TRACE(HTMLViewSourceDocument)
322 { 322 {
323 visitor->trace(m_current); 323 visitor->trace(m_current);
324 visitor->trace(m_tbody); 324 visitor->trace(m_tbody);
325 visitor->trace(m_td); 325 visitor->trace(m_td);
326 HTMLDocument::trace(visitor); 326 HTMLDocument::trace(visitor);
327 } 327 }
328 328
329 } // namespace blink 329 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLViewSourceDocument.h ('k') | third_party/WebKit/Source/core/html/ImageDocument.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698