]> granicus.if.org Git - clang/commitdiff
Moved generation of html header/footer with builtin CSS to the rewriter library.
authorTed Kremenek <kremenek@apple.com>
Wed, 19 Mar 2008 06:14:37 +0000 (06:14 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 19 Mar 2008 06:14:37 +0000 (06:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48537 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/HTMLPrint.cpp
include/clang/Rewrite/HTMLRewrite.h
lib/Rewrite/HTMLRewrite.cpp

index 93e544fc9662d24cc79783ff3018f4308304215f..a513bf975ddacc1775f345be97c90506d8bf9ad0 100644 (file)
@@ -50,39 +50,7 @@ HTMLPrinter::~HTMLPrinter() {
   
   html::EscapeText(R, FileID);
   html::AddLineNumbers(R, FileID);
-  
-  // Generate header
-
-  {
-    std::ostringstream os;
-  
-    os << "<html>\n<head>\n"
-       << " <style type=\"text/css\">\n"    
-       << "  .codeblock { width:100% }\n"
-       << "  .codeline { font-family: \"Monaco\", fixed; font-size:11pt }\n"
-       << "  .codeline { height:1.5em; line-height:1.5em }\n"
-       << "  .nums, .lines { float:left; height:100% }\n"
-       << "  .nums { background-color: #eeeeee }\n"
-       << "  .nums { font-family: \"Andale Mono\", fixed; font-size:smaller }\n"
-       << "  .nums { width:2.5em; padding-right:2ex; text-align:right }\n"
-       << "  .lines { padding-left: 1ex; border-left: 3px solid #ccc }\n"
-       << "  .lines { white-space: pre }\n"
-       << " </style>\n"
-       << "</head>\n"
-       << "<body>";
-
-    R.InsertStrBefore(StartLoc, os.str());
-  }
-  
-  // Generate footer
-  
-  {
-    std::ostringstream os;
-    
-    os << "</body></html>\n";
-    R.InsertStrAfter(EndLoc, os.str());
-  }
-    
+  html::AddHeaderFooterInternalBuiltinCSS(R, FileID);
   
   // Emit the HTML.
   
index 01116026125eac28ef943c47eab088462b342012..1b0aa28a9d80a87456ecb2b28ed31c2fcd414b20 100644 (file)
@@ -26,6 +26,9 @@ namespace html {
   void EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces = false);
   
   void AddLineNumbers(Rewriter& R, unsigned FileID);  
+  
+  void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID);
+  
 
 } // end html namespace
 } // end clang namespace
index 9bd18109bbb4d50475eb7a0fc56919691f5894b1..9690ecb74acd2f25073829fa834fc6de55c144c0 100644 (file)
@@ -118,3 +118,47 @@ void html::AddLineNumbers(Rewriter& R, unsigned FileID) {
   R.InsertCStrAfter(SourceLocation::getFileLoc(FileID, FileEnd - FileBeg),
                     "</div>");
 }
+
+void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
+
+  const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
+  const char* FileStart = Buf->getBufferStart();
+  const char* FileEnd = Buf->getBufferEnd();
+
+  SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0);
+  SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd-FileStart);
+
+  // Generate header
+
+  {
+    std::ostringstream os;
+    
+    os << "<html>\n<head>\n"
+    << " <style type=\"text/css\">\n"    
+    << "  .codeblock { width:100% }\n"
+    << "  .codeline { font-family: \"Andale Mono\", fixed; font-size:10pt }\n"
+    << "  .codeline { height:1.5em; line-height:1.5em }\n"
+    << "  .nums, .lines { float:left; height:100% }\n"
+    << "  .nums { background-color: #eeeeee }\n"
+    << "  .nums { font-size:smaller }\n"
+    << "  .nums { width:2.5em; padding-right:2ex; text-align:right }\n"
+    << "  .lines { padding-left: 1ex; border-left: 3px solid #ccc }\n"
+    << "  .lines { white-space: pre }\n"
+    << " </style>\n"
+    << "</head>\n"
+    << "<body>";
+    
+    R.InsertStrBefore(StartLoc, os.str());
+  }
+  
+  // Generate footer
+  
+  {
+    std::ostringstream os;
+    
+    os << "</body></html>\n";
+    R.InsertStrAfter(EndLoc, os.str());
+  }
+}
+  
+