OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2011 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
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 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 /** | 27 /** |
28 * @constructor | 28 * @constructor |
29 * @extends {WebInspector.Object} | 29 * @extends {WebInspector.Object} |
30 */ | 30 */ |
31 WebInspector.View = function() | 31 WebInspector.View = function() |
32 { | 32 { |
33 this.element = document.createElementWithClass("div", "view"); | 33 this.element = createElementWithClass("div", "view"); |
34 this.element.__view = this; | 34 this.element.__view = this; |
35 this._visible = true; | 35 this._visible = true; |
36 this._isRoot = false; | 36 this._isRoot = false; |
37 this._isShowing = false; | 37 this._isShowing = false; |
38 this._children = []; | 38 this._children = []; |
39 this._hideOnDetach = false; | 39 this._hideOnDetach = false; |
40 this._cssFiles = []; | 40 this._cssFiles = []; |
41 this._notificationDepth = 0; | 41 this._notificationDepth = 0; |
42 } | 42 } |
43 | 43 |
44 WebInspector.View._cssFileToContent = {}; | 44 WebInspector.View._cssFileToContent = {}; |
45 | 45 |
46 WebInspector.View._buildSourceURL = function(cssFile) | 46 WebInspector.View._buildSourceURL = function(cssFile) |
47 { | 47 { |
48 return "\n/*# sourceURL=" + WebInspector.ParsedURL.completeURL(window.locati
on.href, cssFile) + " */"; | 48 return "\n/*# sourceURL=" + WebInspector.ParsedURL.completeURL(window.locati
on.href, cssFile) + " */"; |
49 } | 49 } |
50 | 50 |
51 /** | 51 /** |
52 * @param {string} cssFile | 52 * @param {string} cssFile |
53 * @return {!Element} | 53 * @return {!Element} |
54 */ | 54 */ |
55 WebInspector.View.createStyleElement = function(cssFile) | 55 WebInspector.View.createStyleElement = function(cssFile) |
56 { | 56 { |
57 var content = WebInspector.View._cssFileToContent[cssFile]; | 57 var content = WebInspector.View._cssFileToContent[cssFile]; |
58 if (!content) { | 58 if (!content) { |
59 content = loadResource(cssFile) + WebInspector.View._buildSourceURL(cssF
ile) | 59 content = loadResource(cssFile) + WebInspector.View._buildSourceURL(cssF
ile) |
60 WebInspector.View._cssFileToContent[cssFile] = content; | 60 WebInspector.View._cssFileToContent[cssFile] = content; |
61 } | 61 } |
62 var styleElement = document.createElement("style"); | 62 var styleElement = createElement("style"); |
63 styleElement.type = "text/css"; | 63 styleElement.type = "text/css"; |
64 styleElement.textContent = content; | 64 styleElement.textContent = content; |
65 return styleElement; | 65 return styleElement; |
66 } | 66 } |
67 | 67 |
68 WebInspector.View.prototype = { | 68 WebInspector.View.prototype = { |
69 markAsRoot: function() | 69 markAsRoot: function() |
70 { | 70 { |
71 this.element.classList.add("component-root"); | 71 this.element.classList.add("component-root"); |
72 WebInspector.View.__assert(!this.element.parentElement, "Attempt to mark
as root attached node"); | 72 WebInspector.View.__assert(!this.element.parentElement, "Attempt to mark
as root attached node"); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 { | 644 { |
645 WebInspector.View.__assert(!child.__viewCounter && !child.__view, "Attempt t
o remove element containing view via regular DOM operation"); | 645 WebInspector.View.__assert(!child.__viewCounter && !child.__view, "Attempt t
o remove element containing view via regular DOM operation"); |
646 return WebInspector.View._originalRemoveChild.call(this, child); | 646 return WebInspector.View._originalRemoveChild.call(this, child); |
647 } | 647 } |
648 | 648 |
649 Element.prototype.removeChildren = function() | 649 Element.prototype.removeChildren = function() |
650 { | 650 { |
651 WebInspector.View.__assert(!this.__viewCounter, "Attempt to remove element c
ontaining view via regular DOM operation"); | 651 WebInspector.View.__assert(!this.__viewCounter, "Attempt to remove element c
ontaining view via regular DOM operation"); |
652 WebInspector.View._originalRemoveChildren.call(this); | 652 WebInspector.View._originalRemoveChildren.call(this); |
653 } | 653 } |
OLD | NEW |