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

Side by Side Diff: Source/devtools/front_end/source_frame/SourceFrame.js

Issue 362273002: DevTools: Reduce code via using document.createElementWithClass and document.createChild. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 return; 653 return;
654 } 654 }
655 } 655 }
656 656
657 var rowMessage = { consoleMessage: msg }; 657 var rowMessage = { consoleMessage: msg };
658 rowMessages.push(rowMessage); 658 rowMessages.push(rowMessage);
659 659
660 this._textEditor.beginUpdates(); 660 this._textEditor.beginUpdates();
661 var messageBubbleElement = this._messageBubbles[lineNumber]; 661 var messageBubbleElement = this._messageBubbles[lineNumber];
662 if (!messageBubbleElement) { 662 if (!messageBubbleElement) {
663 messageBubbleElement = document.createElement("div"); 663 messageBubbleElement = document.createElementWithClass("div", "webki t-html-message-bubble");
664 messageBubbleElement.className = "webkit-html-message-bubble";
665 this._messageBubbles[lineNumber] = messageBubbleElement; 664 this._messageBubbles[lineNumber] = messageBubbleElement;
666 this._textEditor.addDecoration(lineNumber, messageBubbleElement); 665 this._textEditor.addDecoration(lineNumber, messageBubbleElement);
667 } 666 }
668 667
669 var imageElement = document.createElement("div"); 668 var imageElement = document.createElement("div");
670 switch (msg.level) { 669 switch (msg.level) {
671 case WebInspector.ConsoleMessage.MessageLevel.Error: 670 case WebInspector.ConsoleMessage.MessageLevel.Error:
672 messageBubbleElement.classList.add("webkit-html-error-message"); 671 messageBubbleElement.classList.add("webkit-html-error-message");
673 imageElement.className = "error-icon-small"; 672 imageElement.className = "error-icon-small";
674 break; 673 break;
675 case WebInspector.ConsoleMessage.MessageLevel.Warning: 674 case WebInspector.ConsoleMessage.MessageLevel.Warning:
676 messageBubbleElement.classList.add("webkit-html-warning-message" ); 675 messageBubbleElement.classList.add("webkit-html-warning-message" );
677 imageElement.className = "warning-icon-small"; 676 imageElement.className = "warning-icon-small";
678 break; 677 break;
679 } 678 }
680 679
681 var messageLineElement = document.createElement("div");
682 messageLineElement.className = "webkit-html-message-line";
683 messageBubbleElement.appendChild(messageLineElement);
684
685 // Create the image element in the Inspector's document so we can use re lative image URLs. 680 // Create the image element in the Inspector's document so we can use re lative image URLs.
681 var messageLineElement = messageBubbleElement.createChild("div", "webkit -html-message-line");
686 messageLineElement.appendChild(imageElement); 682 messageLineElement.appendChild(imageElement);
687 messageLineElement.appendChild(document.createTextNode(msg.messageText)) ; 683 messageLineElement.createTextChild(msg.messageText);
688 684
689 rowMessage.element = messageLineElement; 685 rowMessage.element = messageLineElement;
690 rowMessage.repeatCount = 1; 686 rowMessage.repeatCount = 1;
691 this._updateMessageRepeatCount(rowMessage); 687 this._updateMessageRepeatCount(rowMessage);
692 this._textEditor.endUpdates(); 688 this._textEditor.endUpdates();
693 }, 689 },
694 690
695 _updateMessageRepeatCount: function(rowMessage) 691 _updateMessageRepeatCount: function(rowMessage)
696 { 692 {
697 if (rowMessage.repeatCount < 2) 693 if (rowMessage.repeatCount < 2)
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 onJumpToPosition: function(from, to) 883 onJumpToPosition: function(from, to)
888 { 884 {
889 this._sourceFrame.onJumpToPosition(from, to); 885 this._sourceFrame.onJumpToPosition(from, to);
890 } 886 }
891 } 887 }
892 888
893 importScript("GoToLineDialog.js"); 889 importScript("GoToLineDialog.js");
894 importScript("ResourceView.js"); 890 importScript("ResourceView.js");
895 importScript("FontView.js"); 891 importScript("FontView.js");
896 importScript("ImageView.js"); 892 importScript("ImageView.js");
OLDNEW
« no previous file with comments | « Source/devtools/front_end/source_frame/ImageView.js ('k') | Source/devtools/front_end/sources/JavaScriptSourceFrame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698