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

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

Issue 2386893002: Reformat comments in core/html/parser (Closed)
Patch Set: self review Created 4 years, 2 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 29 matching lines...) Expand all
40 TextDocumentParser::~TextDocumentParser() {} 40 TextDocumentParser::~TextDocumentParser() {}
41 41
42 void TextDocumentParser::appendBytes(const char* data, size_t length) { 42 void TextDocumentParser::appendBytes(const char* data, size_t length) {
43 if (!m_haveInsertedFakePreElement) 43 if (!m_haveInsertedFakePreElement)
44 insertFakePreElement(); 44 insertFakePreElement();
45 HTMLDocumentParser::appendBytes(data, length); 45 HTMLDocumentParser::appendBytes(data, length);
46 } 46 }
47 47
48 void TextDocumentParser::insertFakePreElement() { 48 void TextDocumentParser::insertFakePreElement() {
49 // In principle, we should create a specialized tree builder for 49 // In principle, we should create a specialized tree builder for
50 // TextDocuments, but instead we re-use the existing HTMLTreeBuilder. 50 // TextDocuments, but instead we re-use the existing HTMLTreeBuilder. We
51 // We create a fake token and give it to the tree builder rather than 51 // create a fake token and give it to the tree builder rather than sending
52 // sending fake bytes through the front-end of the parser to avoid 52 // fake bytes through the front-end of the parser to avoid distrubing the
53 // distrubing the line/column number calculations. 53 // line/column number calculations.
54 Vector<Attribute> attributes; 54 Vector<Attribute> attributes;
55 attributes.append( 55 attributes.append(
56 Attribute(styleAttr, "word-wrap: break-word; white-space: pre-wrap;")); 56 Attribute(styleAttr, "word-wrap: break-word; white-space: pre-wrap;"));
57 AtomicHTMLToken fakePre(HTMLToken::StartTag, preTag.localName(), attributes); 57 AtomicHTMLToken fakePre(HTMLToken::StartTag, preTag.localName(), attributes);
58 treeBuilder()->constructTree(&fakePre); 58 treeBuilder()->constructTree(&fakePre);
59
60 // The document could have been detached by an extension while the
61 // tree was being constructed.
59 if (isStopped()) 62 if (isStopped())
60 return; // The document could have been detached by an extension while the tree was being constructed. 63 return;
61 64
62 // Normally we would skip the first \n after a <pre> element, but we don't 65 // Normally we would skip the first \n after a <pre> element, but we don't
63 // want to skip the first \n for text documents! 66 // want to skip the first \n for text documents!
64 treeBuilder()->setShouldSkipLeadingNewline(false); 67 treeBuilder()->setShouldSkipLeadingNewline(false);
65 68
66 // Although Text Documents expose a "pre" element in their DOM, they 69 // Although Text Documents expose a "pre" element in their DOM, they
67 // act like a <plaintext> tag, so we have to force plaintext mode. 70 // act like a <plaintext> tag, so we have to force plaintext mode.
68 forcePlaintextForTextDocument(); 71 forcePlaintextForTextDocument();
69 72
70 m_haveInsertedFakePreElement = true; 73 m_haveInsertedFakePreElement = true;
71 } 74 }
72 75
73 } // namespace blink 76 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698