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 drawCSSPath(commands, fillColor) | |
343 { | |
344 context.save(); | |
345 context.beginPath(); | |
346 | |
347 var commandsIndex = 0; | |
348 var commandsLength = commands.length; | |
349 while(commandsIndex < commandsLength) { | |
apavlov
2014/04/17 16:11:32
Whitespace between "while" and parenthesis
Habib Virji
2014/04/17 16:27:02
Done.
| |
350 switch(commands[commandsIndex]) { | |
apavlov
2014/04/17 16:11:32
Whitespace between "switch" and parenthesis
Habib Virji
2014/04/17 16:27:02
Done.
| |
351 case "M": | |
352 context.moveTo(commands[commandsIndex+1], commands[commandsIndex+2]) ; | |
353 commandsIndex += 2 + 1; | |
354 break; | |
355 case "L": | |
356 context.lineTo(commands[commandsIndex+1], commands[commandsIndex+2]) ; | |
357 commandsIndex += 2 + 1; | |
358 break; | |
359 case "C": | |
360 context.bezierCurveTo(commands[commandsIndex+1], commands[commandsIn dex+2], commands[commandsIndex+3], | |
361 commands[commandsIndex+4], commands[commandsIn dex+5], commands[commandsIndex+6]); | |
362 commandsIndex += 6 + 1; | |
363 break; | |
364 case "Q": | |
365 context.quadraticCurveTo(commands[commandsIndex+1], commands[command sIndex+2], commands[commandsIndex+3], | |
366 commands[commandsIndex+4]); | |
367 commandsIndex += 4 + 1; | |
368 break; | |
369 case "Z": | |
370 context.closePath(); | |
371 commandsIndex++; | |
372 break; | |
373 default: | |
374 commandsIndex++; | |
375 } | |
376 } | |
377 context.closePath(); | |
378 context.fillStyle = fillColor; | |
379 context.fill(); | |
380 | |
381 context.restore(); | |
382 } | |
383 | |
384 function _drawShapeHighlight(shapeInfo) | |
385 { | |
386 if (shapeInfo.marginShape) | |
387 drawCSSPath(shapeInfo.marginShape, shapeMarginHighlightColor); | |
388 | |
389 if (shapeInfo.shape) | |
390 drawCSSPath(shapeInfo.shape, shapeHighlightColor); | |
391 | |
392 if (!(shapeInfo.shape || shapeInfo.marginShape)) | |
apavlov
2014/04/17 16:11:32
optional:
if (!shapeInfo.shape && !shapeInfo.marg
Habib Virji
2014/04/17 16:27:02
Done.
Habib Virji
2014/04/17 16:27:02
Done.
| |
393 drawOutlinedQuad(shapeInfo.bounds, shapeHighlightColor, shapeHighlightCo lor); | |
394 } | |
395 | |
396 | |
339 function drawUnderlyingQuad(quad, fillColor) | 397 function drawUnderlyingQuad(quad, fillColor) |
340 { | 398 { |
341 context.save(); | 399 context.save(); |
342 context.lineWidth = 2; | 400 context.lineWidth = 2; |
343 context.globalCompositeOperation = "destination-over"; | 401 context.globalCompositeOperation = "destination-over"; |
344 context.fillStyle = fillColor; | 402 context.fillStyle = fillColor; |
345 quadToPath(quad).fill(); | 403 quadToPath(quad).fill(); |
346 context.restore(); | 404 context.restore(); |
347 } | 405 } |
348 | 406 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
570 var paddingQuad = quads.pop(); | 628 var paddingQuad = quads.pop(); |
571 var borderQuad = quads.pop(); | 629 var borderQuad = quads.pop(); |
572 var marginQuad = quads.pop(); | 630 var marginQuad = quads.pop(); |
573 | 631 |
574 var hasContent = contentQuad && highlight.contentColor !== transparentColor || highlight.contentOutlineColor !== transparentColor; | 632 var hasContent = contentQuad && highlight.contentColor !== transparentColor || highlight.contentOutlineColor !== transparentColor; |
575 var hasPadding = paddingQuad && highlight.paddingColor !== transparentColor; | 633 var hasPadding = paddingQuad && highlight.paddingColor !== transparentColor; |
576 var hasBorder = borderQuad && highlight.borderColor !== transparentColor; | 634 var hasBorder = borderQuad && highlight.borderColor !== transparentColor; |
577 var hasMargin = marginQuad && highlight.marginColor !== transparentColor; | 635 var hasMargin = marginQuad && highlight.marginColor !== transparentColor; |
578 var hasEventTarget = eventTargetQuad && highlight.eventTargetColor !== trans parentColor; | 636 var hasEventTarget = eventTargetQuad && highlight.eventTargetColor !== trans parentColor; |
579 | 637 |
580 var clipQuad; | 638 if (highlight.elementInfo && highlight.elementInfo.shapeOutsideInfo) { |
581 if (hasMargin && (!hasBorder || !quadEquals(marginQuad, borderQuad))) { | 639 _drawShapeHighlight(highlight.elementInfo.shapeOutsideInfo); |
582 drawOutlinedQuadWithClip(marginQuad, borderQuad, highlight.marginColor); | 640 } else { |
583 clipQuad = borderQuad; | 641 var clipQuad; |
642 if (hasMargin && (!hasBorder || !quadEquals(marginQuad, borderQuad))) { | |
643 drawOutlinedQuadWithClip(marginQuad, borderQuad, highlight.marginCol or); | |
644 clipQuad = borderQuad; | |
645 } | |
646 if (hasBorder && (!hasPadding || !quadEquals(borderQuad, paddingQuad))) { | |
647 drawOutlinedQuadWithClip(borderQuad, paddingQuad, highlight.borderCo lor); | |
648 clipQuad = paddingQuad; | |
649 } | |
650 if (hasPadding && (!hasContent || !quadEquals(paddingQuad, contentQuad)) ) { | |
651 drawOutlinedQuadWithClip(paddingQuad, contentQuad, highlight.padding Color); | |
652 clipQuad = contentQuad; | |
653 } | |
654 if (hasContent) | |
655 drawOutlinedQuad(contentQuad, highlight.contentColor, highlight.cont entOutlineColor); | |
656 if (hasEventTarget) | |
657 drawUnderlyingQuad(eventTargetQuad, highlight.eventTargetColor); | |
584 } | 658 } |
585 if (hasBorder && (!hasPadding || !quadEquals(borderQuad, paddingQuad))) { | |
586 drawOutlinedQuadWithClip(borderQuad, paddingQuad, highlight.borderColor) ; | |
587 clipQuad = paddingQuad; | |
588 } | |
589 if (hasPadding && (!hasContent || !quadEquals(paddingQuad, contentQuad))) { | |
590 drawOutlinedQuadWithClip(paddingQuad, contentQuad, highlight.paddingColo r); | |
591 clipQuad = contentQuad; | |
592 } | |
593 if (hasContent) | |
594 drawOutlinedQuad(contentQuad, highlight.contentColor, highlight.contentO utlineColor); | |
595 if (hasEventTarget) | |
596 drawUnderlyingQuad(eventTargetQuad, highlight.eventTargetColor); | |
597 | |
598 var width = canvasWidth; | 659 var width = canvasWidth; |
599 var height = canvasHeight; | 660 var height = canvasHeight; |
600 var minX = Number.MAX_VALUE, minY = Number.MAX_VALUE, maxX = Number.MIN_VALU E; maxY = Number.MIN_VALUE; | 661 var minX = Number.MAX_VALUE, minY = Number.MAX_VALUE, maxX = Number.MIN_VALU E; maxY = Number.MIN_VALUE; |
601 for (var i = 0; i < highlight.quads.length; ++i) { | 662 for (var i = 0; i < highlight.quads.length; ++i) { |
602 var quad = highlight.quads[i]; | 663 var quad = highlight.quads[i]; |
603 for (var j = 0; j < quad.length; ++j) { | 664 for (var j = 0; j < quad.length; ++j) { |
604 minX = Math.min(minX, quad[j].x); | 665 minX = Math.min(minX, quad[j].x); |
605 maxX = Math.max(maxX, quad[j].x); | 666 maxX = Math.max(maxX, quad[j].x); |
606 minY = Math.min(minY, quad[j].y); | 667 minY = Math.min(minY, quad[j].y); |
607 maxY = Math.max(maxY, quad[j].y); | 668 maxY = Math.max(maxY, quad[j].y); |
608 } | 669 } |
609 } | 670 } |
610 | 671 |
611 var rulerAtRight = minX < 20 && maxX + 20 < width; | 672 var rulerAtRight = minX < 20 && maxX + 20 < width; |
612 var rulerAtBottom = minY < 20 && maxY + 20 < height; | 673 var rulerAtBottom = minY < 20 && maxY + 20 < height; |
613 | 674 |
614 if (highlight.showRulers) { | 675 if (highlight.showRulers) { |
615 _drawGrid(rulerAtRight, rulerAtBottom); | 676 _drawGrid(rulerAtRight, rulerAtBottom); |
616 _drawRulers(highlight, rulerAtRight, rulerAtBottom); | 677 _drawRulers(highlight, rulerAtRight, rulerAtBottom); |
617 } | 678 } |
679 | |
618 _drawElementTitle(highlight); | 680 _drawElementTitle(highlight); |
619 | 681 |
620 context.restore(); | 682 context.restore(); |
621 } | 683 } |
622 | 684 |
623 function drawQuadHighlight(highlight) | 685 function drawQuadHighlight(highlight) |
624 { | 686 { |
625 context.save(); | 687 context.save(); |
626 drawOutlinedQuad(highlight.quads[0], highlight.contentColor, highlight.conte ntOutlineColor); | 688 drawOutlinedQuad(highlight.quads[0], highlight.contentColor, highlight.conte ntOutlineColor); |
627 context.restore(); | 689 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> | 751 <div class="button" id="step-over-button" title="Step over next function cal l (F10)."><div class="glyph"></div></div> |
690 </div> | 752 </div> |
691 </body> | 753 </body> |
692 <canvas id="canvas" class="fill"></canvas> | 754 <canvas id="canvas" class="fill"></canvas> |
693 <div id="element-title"> | 755 <div id="element-title"> |
694 <span id="tag-name"></span><span id="node-id"></span><span id="class-name"></s pan> | 756 <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> | 757 <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> | 758 </div> |
697 <div id="log"></div> | 759 <div id="log"></div> |
698 </html> | 760 </html> |
OLD | NEW |