...

Source file src/pkg/cmd/vendor/github.com/google/pprof/internal/report/source_html.go

     1	// Copyright 2014 Google Inc. All Rights Reserved.
     2	//
     3	// Licensed under the Apache License, Version 2.0 (the "License");
     4	// you may not use this file except in compliance with the License.
     5	// You may obtain a copy of the License at
     6	//
     7	//     http://www.apache.org/licenses/LICENSE-2.0
     8	//
     9	// Unless required by applicable law or agreed to in writing, software
    10	// distributed under the License is distributed on an "AS IS" BASIS,
    11	// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12	// See the License for the specific language governing permissions and
    13	// limitations under the License.
    14	
    15	package report
    16	
    17	import (
    18		"html/template"
    19	)
    20	
    21	// AddSourceTemplates adds templates used by PrintWebList to t.
    22	func AddSourceTemplates(t *template.Template) {
    23		template.Must(t.Parse(`{{define "weblistcss"}}` + weblistPageCSS + `{{end}}`))
    24		template.Must(t.Parse(`{{define "weblistjs"}}` + weblistPageScript + `{{end}}`))
    25	}
    26	
    27	const weblistPageCSS = `<style type="text/css">
    28	body {
    29	font-family: sans-serif;
    30	}
    31	h1 {
    32	  font-size: 1.5em;
    33	  margin-bottom: 4px;
    34	}
    35	.legend {
    36	  font-size: 1.25em;
    37	}
    38	.line, .nop, .unimportant {
    39	  color: #aaaaaa;
    40	}
    41	.inlinesrc {
    42	  color: #000066;
    43	}
    44	.deadsrc {
    45	cursor: pointer;
    46	}
    47	.deadsrc:hover {
    48	background-color: #eeeeee;
    49	}
    50	.livesrc {
    51	color: #0000ff;
    52	cursor: pointer;
    53	}
    54	.livesrc:hover {
    55	background-color: #eeeeee;
    56	}
    57	.asm {
    58	color: #008800;
    59	display: none;
    60	}
    61	</style>`
    62	
    63	const weblistPageScript = `<script type="text/javascript">
    64	function pprof_toggle_asm(e) {
    65	  var target;
    66	  if (!e) e = window.event;
    67	  if (e.target) target = e.target;
    68	  else if (e.srcElement) target = e.srcElement;
    69	
    70	  if (target) {
    71	    var asm = target.nextSibling;
    72	    if (asm && asm.className == "asm") {
    73	      asm.style.display = (asm.style.display == "block" ? "" : "block");
    74	      e.preventDefault();
    75	      return false;
    76	    }
    77	  }
    78	}
    79	</script>`
    80	
    81	const weblistPageClosing = `
    82	</body>
    83	</html>
    84	`
    85	

View as plain text