OLD | NEW |
---|---|
1 <!-- | 1 <!-- |
2 Copyright (C) 2012 Google Inc. All rights reserved. | 2 Copyright (C) 2012 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 | 7 |
8 1. Redistributions of source code must retain the above copyright | 8 1. Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 2. Redistributions in binary form must reproduce the above copyright | 10 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ | 149 /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ |
150 color: rgb(153, 69, 0); | 150 color: rgb(153, 69, 0); |
151 } | 151 } |
152 | 152 |
153 </style> | 153 </style> |
154 <script> | 154 <script> |
155 const lightGridColor = "rgba(0,0,0,0.2)"; | 155 const lightGridColor = "rgba(0,0,0,0.2)"; |
156 const darkGridColor = "rgba(0,0,0,0.7)"; | 156 const darkGridColor = "rgba(0,0,0,0.7)"; |
157 const transparentColor = "rgba(0, 0, 0, 0)"; | 157 const transparentColor = "rgba(0, 0, 0, 0)"; |
158 const gridBackgroundColor = "rgba(255, 255, 255, 0.8)"; | 158 const gridBackgroundColor = "rgba(255, 255, 255, 0.8)"; |
159 //CSS shapes | |
160 const shapeHighlightColor = "rgba(96, 82, 127, 0.8)"; | |
161 const shapeMarginHighlightColor = "rgba(96, 82, 127, 0.6)"; | |
159 | 162 |
160 function drawPausedInDebuggerMessage(message) | 163 function drawPausedInDebuggerMessage(message) |
161 { | 164 { |
162 window._controlsVisible = true; | 165 window._controlsVisible = true; |
163 document.querySelector(".controls-line").style.visibility = "visible"; | 166 document.querySelector(".controls-line").style.visibility = "visible"; |
164 document.getElementById("paused-in-debugger").textContent = message; | 167 document.getElementById("paused-in-debugger").textContent = message; |
165 document.body.classList.add("dimmed"); | 168 document.body.classList.add("dimmed"); |
166 } | 169 } |
167 | 170 |
168 function _drawGrid(rulerAtRight, rulerAtBottom) | 171 function _drawGrid(rulerAtRight, rulerAtBottom) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 context.fillStyle = fillColor; | 332 context.fillStyle = fillColor; |
330 context.save(); | 333 context.save(); |
331 context.lineWidth = 0; | 334 context.lineWidth = 0; |
332 quadToPath(quad).fill(); | 335 quadToPath(quad).fill(); |
333 context.globalCompositeOperation = "destination-out"; | 336 context.globalCompositeOperation = "destination-out"; |
334 context.fillStyle = "red"; | 337 context.fillStyle = "red"; |
335 quadToPath(clipQuad).fill(); | 338 quadToPath(clipQuad).fill(); |
336 context.restore(); | 339 context.restore(); |
337 } | 340 } |
338 | 341 |
342 function pathCommand(context, commands, name, index, length) { | |
pfeldman
2014/04/15 11:59:09
{ on the next line
Habib Virji
2014/04/17 15:43:47
Done.
| |
343 context[name].apply(context, commands.slice(index + 1, index + length + 1)); | |
pfeldman
2014/04/15 11:59:09
We plan on annotating this code with JSDoc, reflec
| |
344 return index + length + 1; | |
345 } | |
346 | |
347 function drawPath(context, commands, fillColor, outlineColor) | |
348 { | |
349 context.save(); | |
350 context.beginPath(); | |
351 | |
352 var commandsIndex = 0; | |
353 var commandsLength = commands.length; | |
354 while(commandsIndex < commandsLength) { | |
355 switch(commands[commandsIndex]) { | |
356 // 1 point | |
357 case 'M': | |
pfeldman
2014/04/15 11:59:09
We use double quotes for strings.
| |
358 commandsIndex = pathCommand(context, commands, "moveTo", commandsInd ex, 2); | |
pfeldman
2014/04/15 11:59:09
Lets just call context.moveTo(...) and increment i
Habib Virji
2014/04/17 15:43:47
Done.
| |
359 break; | |
360 // 1 point | |
361 case 'L': | |
362 commandsIndex = pathCommand(context, commands, "lineTo", commandsInd ex, 2); | |
363 break; | |
364 // 3 points | |
365 case 'C': | |
366 commandsIndex = pathCommand(context, commands, "bezierCurveTo", comm andsIndex, 6); | |
367 break; | |
368 // 2 points | |
369 case 'Q': | |
370 commandsIndex = pathCommand(context, commands, "quadraticCurveTo", c ommandsIndex, 2); | |
371 break; | |
372 // 0 points | |
373 case 'Z': | |
374 commandsIndex = pathCommand(context, commands, "closePath", commands Index, 0); | |
375 break; | |
376 default: | |
377 commandsIndex++; | |
378 } | |
379 } | |
380 context.closePath(); | |
381 context.fillStyle = fillColor; | |
382 context.fill(); | |
383 | |
384 if (outlineColor) { | |
385 context.lineWidth = 2; | |
386 context.strokeStyle = outlineColor; | |
387 context.stroke(); | |
388 } | |
389 | |
390 context.restore(); | |
391 } | |
339 function drawUnderlyingQuad(quad, fillColor) | 392 function drawUnderlyingQuad(quad, fillColor) |
340 { | 393 { |
341 context.save(); | 394 context.save(); |
342 context.lineWidth = 2; | 395 context.lineWidth = 2; |
343 context.globalCompositeOperation = "destination-over"; | 396 context.globalCompositeOperation = "destination-over"; |
344 context.fillStyle = fillColor; | 397 context.fillStyle = fillColor; |
345 quadToPath(quad).fill(); | 398 quadToPath(quad).fill(); |
346 context.restore(); | 399 context.restore(); |
347 } | 400 } |
348 | 401 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 context.beginPath(); | 590 context.beginPath(); |
538 context.moveTo(x, 0); | 591 context.moveTo(x, 0); |
539 context.lineTo(x, topmostYForX[x]); | 592 context.lineTo(x, topmostYForX[x]); |
540 context.stroke(); | 593 context.stroke(); |
541 } | 594 } |
542 } | 595 } |
543 | 596 |
544 context.restore(); | 597 context.restore(); |
545 } | 598 } |
546 | 599 |
600 function _drawShapeHighlight(shapeInfo) { | |
pfeldman
2014/04/15 11:59:09
{ on the next line
Habib Virji
2014/04/17 15:43:47
Done.
| |
601 if (shapeInfo.marginShape) | |
602 drawPath(context, shapeInfo.marginShape, shapeMarginHighlightColor); | |
603 | |
604 if (shapeInfo.shape) | |
605 drawPath(context, shapeInfo.shape, shapeHighlightColor); | |
606 | |
607 if (!(shapeInfo.shape || shapeInfo.marginShape)) | |
608 drawOutlinedQuad(shapeInfo.bounds, shapeHighlightColor, shapeHighlightCo lor); | |
609 } | |
610 | |
547 function drawNodeHighlight(highlight) | 611 function drawNodeHighlight(highlight) |
548 { | 612 { |
549 { | 613 { |
550 for (var i = 0; i < highlight.quads.length; ++i) { | 614 for (var i = 0; i < highlight.quads.length; ++i) { |
551 var quad = highlight.quads[i]; | 615 var quad = highlight.quads[i]; |
552 for (var j = 0; j < quad.length; ++j) { | 616 for (var j = 0; j < quad.length; ++j) { |
553 quad[j].x = Math.round(quad[j].x * pageScaleFactor - scrollX); | 617 quad[j].x = Math.round(quad[j].x * pageScaleFactor - scrollX); |
554 quad[j].y = Math.round(quad[j].y * pageScaleFactor - scrollY); | 618 quad[j].y = Math.round(quad[j].y * pageScaleFactor - scrollY); |
555 } | 619 } |
556 } | 620 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 } | 672 } |
609 } | 673 } |
610 | 674 |
611 var rulerAtRight = minX < 20 && maxX + 20 < width; | 675 var rulerAtRight = minX < 20 && maxX + 20 < width; |
612 var rulerAtBottom = minY < 20 && maxY + 20 < height; | 676 var rulerAtBottom = minY < 20 && maxY + 20 < height; |
613 | 677 |
614 if (highlight.showRulers) { | 678 if (highlight.showRulers) { |
615 _drawGrid(rulerAtRight, rulerAtBottom); | 679 _drawGrid(rulerAtRight, rulerAtBottom); |
616 _drawRulers(highlight, rulerAtRight, rulerAtBottom); | 680 _drawRulers(highlight, rulerAtRight, rulerAtBottom); |
617 } | 681 } |
682 if (highlight.elementInfo && highlight.elementInfo.shapeOutsideInfo) | |
683 _drawShapeHighlight(highlight.elementInfo.shapeOutsideInfo); | |
684 | |
618 _drawElementTitle(highlight); | 685 _drawElementTitle(highlight); |
619 | 686 |
620 context.restore(); | 687 context.restore(); |
621 } | 688 } |
622 | 689 |
623 function drawQuadHighlight(highlight) | 690 function drawQuadHighlight(highlight) |
624 { | 691 { |
625 context.save(); | 692 context.save(); |
626 drawOutlinedQuad(highlight.quads[0], highlight.contentColor, highlight.conte ntOutlineColor); | 693 drawOutlinedQuad(highlight.quads[0], highlight.contentColor, highlight.conte ntOutlineColor); |
627 context.restore(); | 694 context.restore(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 <div class="button" id="step-over-button" title="Step over next function cal l (F10)."><div class="glyph"></div></div> | 756 <div class="button" id="step-over-button" title="Step over next function cal l (F10)."><div class="glyph"></div></div> |
690 </div> | 757 </div> |
691 </body> | 758 </body> |
692 <canvas id="canvas" class="fill"></canvas> | 759 <canvas id="canvas" class="fill"></canvas> |
693 <div id="element-title"> | 760 <div id="element-title"> |
694 <span id="tag-name"></span><span id="node-id"></span><span id="class-name"></s pan> | 761 <span id="tag-name"></span><span id="node-id"></span><span id="class-name"></s pan> |
695 <span id="node-width"></span><span class="px">px</span><span class="px"> × ; </span><span id="node-height"></span><span class="px">px</span> | 762 <span id="node-width"></span><span class="px">px</span><span class="px"> × ; </span><span id="node-height"></span><span class="px">px</span> |
696 </div> | 763 </div> |
697 <div id="log"></div> | 764 <div id="log"></div> |
698 </html> | 765 </html> |
OLD | NEW |