Changeset 41404 in webkit
- Timestamp:
- Mar 3, 2009 2:24:14 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r41403 r41404 1 2009-03-03 Timothy Hatcher <timothy@apple.com> 2 3 Fix a regression that broke dirxml and caused an ASSERT in debug builds. Also simplified 4 the console code and refactored things to have fewer code paths and duplication. 5 6 Reviewed by Kevin McCullough. 7 8 Test: manual-tests/inspector/console-dir.html 9 10 * bindings/js/JSInspectedObjectWrapper.cpp: 11 (WebCore::JSInspectedObjectWrapper::wrap): Use the lexicalGlobalObject instead of dynamicGlobalObject 12 to fix an ASSERT about using a wrapper from the wrong ExecState. 13 * bindings/js/JSQuarantinedObjectWrapper.cpp: 14 (WebCore::JSQuarantinedObjectWrapper::JSQuarantinedObjectWrapper): Ditto. 15 (WebCore::JSQuarantinedObjectWrapper::allowsUnwrappedAccessFrom): Ditto. 16 * inspector/front-end/Console.js: 17 (WebInspector.Console.prototype._format): Remove the inline argument and add forceObjectFormat. 18 When forceObjectFormat is true, the only formatter used is _formatobject. 19 (WebInspector.Console.prototype._formatvalue): Remove the inline argument. 20 (WebInspector.Console.prototype._formatstring): Ditto. 21 (WebInspector.Console.prototype._formatregexp): Ditto. 22 (WebInspector.Console.prototype._formatarray): Ditto. 23 (WebInspector.Console.prototype._formatnode): Remove the inline argument and make a DOM tree instead of an anchor. 24 (WebInspector.Console.prototype._formatobject): Remove the inline argument and always make a property graph. 25 (WebInspector.Console.prototype._formaterror): Remove the inline argument. 26 (WebInspector.ConsoleMessage): Remove the case for MessageLevel.Node and 27 simplify the case for MessageLevel.Object to use the normal _format code path with the %O formatter. 28 (WebInspector.ConsoleMessage.prototype._format.formatForConsole): Don't pass an additional true argument for inline. 29 (WebInspector.ConsoleMessage.prototype._format.formatAsObjectForConsole): Added. Pass a true argument for forceObjectFormat. 30 (WebInspector.ConsoleMessage.prototype._format): Added support for the %O formatter. Use formatForConsole for all arguments. 31 (WebInspector.ConsoleMessage.prototype.toString): Add the other message levels. 32 * inspector/front-end/inspector.css: Tweak styles to look and work correctly. 33 * inspector/front-end/utilities.js: 34 (Object.type): Return "node" for Node objects. 35 (Object.describe): Handle the "node" type. 36 * page/Console.cpp: 37 (WebCore::printMessageSourceAndLevelPrefix): Fix an assert by adding the other message level types. 38 (WebCore::Console::dirxml): Use the standard log fuction since it prints a DOM tree for nodes by default. 39 * page/Console.h: 40 (WebCore::enum MessageLevel): Removed NodeMessageLevel. Added a FIXME. 41 1 42 2009-03-03 Scott Violet <sky@google.com> 2 43 -
trunk/WebCore/bindings/js/JSInspectedObjectWrapper.cpp
r40046 r41404 58 58 return unwrappedObject; 59 59 60 if (WrapperMap* wrapperMap = wrappers().get(unwrappedExec-> dynamicGlobalObject()))60 if (WrapperMap* wrapperMap = wrappers().get(unwrappedExec->lexicalGlobalObject())) 61 61 if (JSInspectedObjectWrapper* wrapper = wrapperMap->get(unwrappedObject)) 62 62 return wrapper; -
trunk/WebCore/bindings/js/JSQuarantinedObjectWrapper.cpp
r41353 r41404 59 59 JSQuarantinedObjectWrapper::JSQuarantinedObjectWrapper(ExecState* unwrappedExec, JSObject* unwrappedObject, PassRefPtr<Structure> structure) 60 60 : JSObject(structure) 61 , m_unwrappedGlobalObject(unwrappedExec-> dynamicGlobalObject())61 , m_unwrappedGlobalObject(unwrappedExec->lexicalGlobalObject()) 62 62 , m_unwrappedObject(unwrappedObject) 63 63 { … … 73 73 bool JSQuarantinedObjectWrapper::allowsUnwrappedAccessFrom(ExecState* exec) const 74 74 { 75 return m_unwrappedGlobalObject->profileGroup() == exec-> dynamicGlobalObject()->profileGroup();75 return m_unwrappedGlobalObject->profileGroup() == exec->lexicalGlobalObject()->profileGroup(); 76 76 } 77 77 -
trunk/WebCore/inspector/front-end/Console.js
r41365 r41404 466 466 }, 467 467 468 _mouseOverNode: function(event) 469 { 470 var anchorElement = event.target.enclosingNodeOrSelfWithNodeName("a"); 471 WebInspector.hoveredDOMNode = (anchorElement ? anchorElement.representedNode : null); 472 }, 473 474 _mouseOutOfNode: function(event) 475 { 476 var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY); 477 var anchorElement = nodeUnderMouse.enclosingNodeOrSelfWithNodeName("a"); 478 if (!anchorElement || !anchorElement.representedNode) 479 WebInspector.hoveredDOMNode = null; 480 }, 481 482 _format: function(output, inline) 483 { 484 var type = Object.type(output, InspectorController.inspectedWindow()); 485 if (type === "object") { 486 if (output instanceof InspectorController.inspectedWindow().Node) 487 type = "node"; 488 } 468 _format: function(output, forceObjectFormat) 469 { 470 var type = (forceObjectFormat ? "object" : Object.type(output, InspectorController.inspectedWindow())); 489 471 490 472 // We don't perform any special formatting on these types, so we just … … 500 482 501 483 var formatter; 502 if (type in undecoratedTypes) 484 if (forceObjectFormat) 485 formatter = "_formatobject"; 486 else if (type in undecoratedTypes) 503 487 formatter = "_formatvalue"; 504 488 else { … … 512 496 var span = document.createElement("span"); 513 497 span.addStyleClass("console-formatted-" + type); 514 this[formatter](output, span , inline);498 this[formatter](output, span); 515 499 return span; 516 500 }, 517 501 518 _formatvalue: function(val, elem , inline)502 _formatvalue: function(val, elem) 519 503 { 520 504 elem.appendChild(document.createTextNode(val)); 521 505 }, 522 506 523 _formatstring: function(str, elem , inline)507 _formatstring: function(str, elem) 524 508 { 525 509 elem.appendChild(document.createTextNode("\"" + str + "\"")); 526 510 }, 527 511 528 _formatregexp: function(re, elem , inline)512 _formatregexp: function(re, elem) 529 513 { 530 514 var formatted = String(re).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1); … … 532 516 }, 533 517 534 _formatarray: function(arr, elem , inline)518 _formatarray: function(arr, elem) 535 519 { 536 520 elem.appendChild(document.createTextNode("[")); 537 521 for (var i = 0; i < arr.length; ++i) { 538 elem.appendChild(this._format(arr[i] , true));522 elem.appendChild(this._format(arr[i])); 539 523 if (i < arr.length - 1) 540 524 elem.appendChild(document.createTextNode(", ")); … … 543 527 }, 544 528 545 _formatnode: function(node, elem, inline) 546 { 547 var anchor = document.createElement("a"); 548 anchor.className = "inspectable-node"; 549 anchor.innerHTML = nodeTitleInfo.call(node).title; 550 anchor.representedNode = node; 551 anchor.addEventListener("mouseover", this._mouseOverNode.bind(this), false); 552 anchor.addEventListener("mouseout", this._mouseOutOfNode.bind(this), false); 553 554 if (inline) 555 elem.appendChild(anchor); 556 else 557 elem.appendChild(new WebInspector.ObjectPropertiesSection(node, anchor, null, null, true).element); 558 }, 559 560 _formatobject: function(obj, elem, inline) 561 { 562 if (inline) 563 elem.appendChild(document.createTextNode(Object.describe(obj))); 564 else 565 elem.appendChild(new WebInspector.ObjectPropertiesSection(obj, null, null, null, true).element); 566 }, 567 568 _formaterror: function(obj, elem, inline) 529 _formatnode: function(node, elem) 530 { 531 var treeOutline = new WebInspector.ElementsTreeOutline(); 532 treeOutline.rootDOMNode = node; 533 treeOutline.element.addStyleClass("outline-disclosure"); 534 if (!treeOutline.children[0].hasChildren) 535 treeOutline.element.addStyleClass("single-node"); 536 elem.appendChild(treeOutline.element); 537 }, 538 539 _formatobject: function(obj, elem) 540 { 541 elem.appendChild(new WebInspector.ObjectPropertiesSection(obj, null, null, null, true).element); 542 }, 543 544 _formaterror: function(obj, elem) 569 545 { 570 546 var messageElement = document.createElement("span"); … … 604 580 605 581 switch (this.level) { 606 case WebInspector.ConsoleMessage.MessageLevel.Object:607 var propertiesSection = new WebInspector.ObjectPropertiesSection(arguments[6], null, null, null, true);608 propertiesSection.element.addStyleClass("console-message");609 this.propertiesSection = propertiesSection;610 break;611 case WebInspector.ConsoleMessage.MessageLevel.Node:612 var node = arguments[6];613 if (!(node instanceof InspectorController.inspectedWindow().Node))614 return;615 this.elementsTreeOutline = new WebInspector.ElementsTreeOutline();616 this.elementsTreeOutline.rootDOMNode = node;617 break;618 582 case WebInspector.ConsoleMessage.MessageLevel.Trace: 619 583 var span = document.createElement("span"); … … 626 590 this.formattedMessage = span; 627 591 break; 592 case WebInspector.ConsoleMessage.MessageLevel.Object: 593 this.formattedMessage = this._format(["%O", arguments[6]]); 594 break; 628 595 default: 629 // The formatedMessage property is used for the rich and interactive console.630 596 this.formattedMessage = this._format(Array.prototype.slice.call(arguments, 6)); 631 632 // This is used for inline message bubbles in SourceFrames, or other plain-text representations.633 this.message = this.formattedMessage.textContent;634 597 break; 635 598 } 599 600 // This is used for inline message bubbles in SourceFrames, or other plain-text representations. 601 this.message = this.formattedMessage.textContent; 636 602 } 637 603 … … 650 616 651 617 function formatForConsole(obj) 618 { 619 return WebInspector.console._format(obj); 620 } 621 622 function formatAsObjectForConsole(obj) 652 623 { 653 624 return WebInspector.console._format(obj, true); … … 663 634 // Firebug allows both %i and %d for formatting integers. 664 635 formatters.i = formatters.d; 636 // Support %O to force object formating, instead of the type-based %o formatting. 637 formatters.O = formatAsObjectForConsole; 665 638 666 639 function append(a, b) … … 683 656 if (typeof parameters[i] === "string") 684 657 formattedResult.appendChild(WebInspector.linkifyStringAsFragment(parameters[i])); 685 else if (parameters.length === 1)686 formattedResult.appendChild(WebInspector.console._format(parameters[0]));687 658 else 688 659 formattedResult.appendChild(formatForConsole(parameters[i])); 660 689 661 if (i < parameters.length - 1) 690 662 formattedResult.appendChild(document.createTextNode(" ")); … … 822 794 levelString = "Object"; 823 795 break; 824 case WebInspector.ConsoleMessage.MessageLevel.GroupTitle: 825 levelString = "GroupTitle"; 796 case WebInspector.ConsoleMessage.MessageLevel.Trace: 797 levelString = "Trace"; 798 break; 799 case WebInspector.ConsoleMessage.MessageLevel.StartGroup: 800 levelString = "Start Group"; 801 break; 802 case WebInspector.ConsoleMessage.MessageLevel.EndGroup: 803 levelString = "End Group"; 826 804 break; 827 805 } … … 829 807 return sourceString + " " + levelString + ": " + this.formattedMessage.textContent + "\n" + this.url + " line " + this.line; 830 808 }, 831 809 832 810 isEqual: function(msg, disreguardGroup) 833 811 { … … 861 839 Error: 3, 862 840 Object: 4, 863 Node: 5, 864 Trace: 6, 865 StartGroup: 7, 866 EndGroup: 8 841 Trace: 5, 842 StartGroup: 6, 843 EndGroup: 7 867 844 } 868 845 -
trunk/WebCore/inspector/front-end/inspector.css
r41364 r41404 416 416 display: none; 417 417 position: absolute; 418 z-index: 1; 418 419 bottom: 0; 419 420 left: 0; … … 613 614 .console-group-messages .section .header .title { 614 615 color: black; 616 font-weight: normal; 617 } 618 619 .console-group-messages .section .properties li .info { 620 padding-top: 0; 621 padding-bottom: 0; 622 color: rgb(60%, 60%, 60%); 623 } 624 625 .console-group-messages .outline-disclosure { 626 padding-left: 0; 627 } 628 629 .console-group-messages .outline-disclosure > ol { 630 padding: 0 0 0 12px !important; 615 631 } 616 632 … … 620 636 } 621 637 622 .console-group-messages .outline-disclosure li { 623 padding-top: 2px; 624 padding-bottom: 2px; 638 .console-group-messages .outline-disclosure.single-node li { 639 padding-left: 2px; 625 640 } 626 641 627 642 .console-group-messages .outline-disclosure li .selection { 628 z-index: 0;629 margin- top: -1px;643 margin-left: -6px; 644 margin-right: -6px; 630 645 } 631 646 632 647 .console-formatted-object, .console-formatted-node { 633 648 position: relative; 634 display: block; 649 display: inline-block; 650 vertical-align: top; 635 651 } 636 652 … … 651 667 -webkit-user-select: none; 652 668 -webkit-user-modify: read-only; 653 }654 655 .inspectable-node {656 color: black !important;657 }658 659 .inspectable-node:hover {660 background-color: rgba(56, 121, 217, 0.1);661 -webkit-border-radius: 5px;662 padding: 0 5px 1px;663 margin: 0 -5px -1px;664 669 } 665 670 -
trunk/WebCore/inspector/front-end/utilities.js
r41335 r41404 38 38 win = win || window; 39 39 40 if (obj instanceof win.Node) 41 return "node"; 40 42 if (obj instanceof win.String) 41 43 return "string"; … … 71 73 switch (type1) { 72 74 case "object": 75 case "node": 73 76 return type2; 74 77 case "array": -
trunk/WebCore/page/Console.cpp
r39177 r41404 100 100 sourceString = "CSS"; 101 101 break; 102 case OtherMessageSource: 103 sourceString = "OTHER"; 104 break; 102 105 default: 103 106 ASSERT_NOT_REACHED(); 104 // Fall thru. 105 case OtherMessageSource: 106 sourceString = "OTHER"; 107 sourceString = "UNKNOWN"; 107 108 break; 108 109 } … … 113 114 levelString = "TIP"; 114 115 break; 116 case LogMessageLevel: 117 levelString = "LOG"; 118 break; 119 case WarningMessageLevel: 120 levelString = "WARN"; 121 break; 122 case ErrorMessageLevel: 123 levelString = "ERROR"; 124 break; 125 case ObjectMessageLevel: 126 levelString = "OBJECT"; 127 break; 128 case TraceMessageLevel: 129 levelString = "TRACE"; 130 break; 131 case StartGroupMessageLevel: 132 levelString = "START GROUP"; 133 break; 134 case EndGroupMessageLevel: 135 levelString = "END GROUP"; 136 break; 115 137 default: 116 138 ASSERT_NOT_REACHED(); 117 // Fall thru. 118 case LogMessageLevel: 119 levelString = "LOG"; 120 break; 121 case WarningMessageLevel: 122 levelString = "WARN"; 123 break; 124 case ErrorMessageLevel: 125 levelString = "ERROR"; 139 levelString = "UNKNOWN"; 126 140 break; 127 141 } … … 208 222 void Console::dirxml(ScriptCallStack* callStack) 209 223 { 210 addMessage(NodeMessageLevel, callStack); 224 // The standard behavior of our console.log will print the DOM tree for nodes. 225 log(callStack); 211 226 } 212 227 -
trunk/WebCore/page/Console.h
r39142 r41404 65 65 WarningMessageLevel, 66 66 ErrorMessageLevel, 67 // FIXME: the remaining levels should become a new MessageType enum. 67 68 ObjectMessageLevel, 68 NodeMessageLevel,69 69 TraceMessageLevel, 70 70 StartGroupMessageLevel,
Note: See TracChangeset
for help on using the changeset viewer.