Diff
Modified: trunk/LayoutTests/ChangeLog (98226 => 98227)
--- trunk/LayoutTests/ChangeLog 2011-10-24 09:26:54 UTC (rev 98226)
+++ trunk/LayoutTests/ChangeLog 2011-10-24 09:40:47 UTC (rev 98227)
@@ -1,3 +1,15 @@
+2011-10-24 Pavel Feldman <pfeld...@chromium.org>
+
+ Web Inspector: make view load CSS files upon show.
+ https://bugs.webkit.org/show_bug.cgi?id=70696
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/view-css-expected.txt: Added.
+ * inspector/view-css.html: Added.
+ * inspector/view-events-expected.txt:
+ * inspector/view-events.html:
+
2011-10-24 Kosztyo Kristof <kkris...@inf.u-szeged.hu>
[Qt] Unreviewed gardening after r98199
Added: trunk/LayoutTests/inspector/view-css-expected.txt (0 => 98227)
--- trunk/LayoutTests/inspector/view-css-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/view-css-expected.txt 2011-10-24 09:40:47 UTC (rev 98227)
@@ -0,0 +1,22 @@
+This tests that CSS files are properly loaded / unloaded upon view show / detach.
+
+
+Running: testEvents
+Parent.show()
+ LOAD parent.css
+Child 1.show()
+ LOAD child.css
+ LOAD child1.css
+Child 2.show()
+ LOAD child2.css
+Child 2.detach()
+ UNLOAD child2.css
+Parent.detach()
+ UNLOAD parent.css
+ UNLOAD child.css
+ UNLOAD child1.css
+Parent.show()
+ LOAD parent.css
+ LOAD child.css
+ LOAD child1.css
+
Property changes on: trunk/LayoutTests/inspector/view-css-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/view-css.html (0 => 98227)
--- trunk/LayoutTests/inspector/view-css.html (rev 0)
+++ trunk/LayoutTests/inspector/view-css.html 2011-10-24 09:40:47 UTC (rev 98227)
@@ -0,0 +1,76 @@
+<html>
+<head>
+<script src=""
+<script>
+
+function test()
+{
+ function TestView(viewName, requiredCSS, requiredCSS2)
+ {
+ WebInspector.View.call(this);
+
+ this.registerRequiredCSS(requiredCSS);
+ if (requiredCSS2)
+ this.registerRequiredCSS(requiredCSS2);
+ this._viewName = viewName;
+ }
+
+ TestView.prototype = {
+ show: function(parentElement)
+ {
+ InspectorTest.addResult(this._viewName + ".show()");
+ WebInspector.View.prototype.show.call(this, parentElement);
+ },
+
+ detach: function()
+ {
+ InspectorTest.addResult(this._viewName + ".detach()");
+ WebInspector.View.prototype.detach.call(this);
+ },
+
+ _doLoadCSS: function(cssFile)
+ {
+ InspectorTest.addResult(" LOAD " + cssFile);
+ },
+
+ _doUnloadCSS: function(cssFile)
+ {
+ InspectorTest.addResult(" UNLOAD " + cssFile);
+ }
+ };
+
+ TestView.prototype.__proto__ = WebInspector.View.prototype;
+
+ InspectorTest.runTestSuite([
+ function testEvents(next)
+ {
+ var parentView = new TestView("Parent", "parent.css");
+ parentView.show(WebInspector.mainPanelsView.element);
+
+ var childView1 = new TestView("Child 1", "child.css", "child1.css");
+ var childView2 = new TestView("Child 2", "child.css", "child2.css");
+
+ childView1.show(parentView.element);
+ childView2.show(parentView.element);
+
+ childView2.detach(parentView.element);
+
+ parentView.detach();
+
+ parentView.show(WebInspector.mainPanelsView.element);
+
+ next();
+ }
+ ]);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+This tests that CSS files are properly loaded / unloaded upon view show / detach.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/view-css.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/inspector/view-events-expected.txt (98226 => 98227)
--- trunk/LayoutTests/inspector/view-events-expected.txt 2011-10-24 09:26:54 UTC (rev 98226)
+++ trunk/LayoutTests/inspector/view-events-expected.txt 2011-10-24 09:40:47 UTC (rev 98227)
@@ -36,9 +36,33 @@
Running: testEvents
Parent()
+Child()
Parent.show()
Parent.wasShown()
Parent.onResize()
+Parent.doResize()
+ Parent.onResize()
+Child.show()
+ Child.wasShown()
+ Child.onResize()
+Parent.doResize()
+ Parent.onResize()
+ Child.onResize()
+Parent.detach()
+ Child.willHide()
+ Parent.willHide()
+Parent.show()
+ Parent.wasShown()
+ Parent.onResize()
+ Child.wasShown()
+ Child.onResize()
+Child.detach()
+ Child.willHide()
+Parent.detach()
+ Parent.willHide()
+
+Running: testEventsHideOnDetach
+Parent()
Child()
Parent.show()
Parent.wasShown()
Modified: trunk/LayoutTests/inspector/view-events.html (98226 => 98227)
--- trunk/LayoutTests/inspector/view-events.html 2011-10-24 09:26:54 UTC (rev 98226)
+++ trunk/LayoutTests/inspector/view-events.html 2011-10-24 09:40:47 UTC (rev 98227)
@@ -124,10 +124,26 @@
{
var parentView = new TestView("Parent");
parentView.markAsRoot();
- parentView.show(document.body);
+ var childView = new TestView("Child");
+ parentView.show(WebInspector.mainPanelsView.element);
+ parentView.doResize();
+ childView.show(parentView.element);
+ parentView.doResize();
+ parentView.detach();
+ parentView.show(WebInspector.mainPanelsView.element);
+ childView.detach();
+ parentView.detach();
+ next();
+ },
+
+ function testEventsHideOnDetach(next)
+ {
+ var parentView = new TestView("Parent");
var childView = new TestView("Child");
+ childView.setHideOnDetach();
parentView.show(WebInspector.mainPanelsView.element);
+
parentView.doResize();
childView.show(parentView.element);
parentView.doResize();
@@ -141,8 +157,7 @@
function testViewCounter(next)
{
var parentView = new TestView("Parent");
- parentView.markAsRoot();
- parentView.show(document.body);
+ parentView.show(WebInspector.mainPanelsView.element);
var childView = new TestView("Child");
childView.show(parentView.element);
@@ -164,8 +179,7 @@
function testRemoveChild(next)
{
var parentView = new TestView("Parent");
- parentView.markAsRoot();
- parentView.show(document.body);
+ parentView.show(WebInspector.mainPanelsView.element);
var childView = new TestView("Child");
childView.show(parentView.element);
Modified: trunk/Source/WebCore/ChangeLog (98226 => 98227)
--- trunk/Source/WebCore/ChangeLog 2011-10-24 09:26:54 UTC (rev 98226)
+++ trunk/Source/WebCore/ChangeLog 2011-10-24 09:40:47 UTC (rev 98227)
@@ -1,5 +1,30 @@
2011-10-24 Pavel Feldman <pfeld...@chromium.org>
+ Web Inspector: make view load CSS files upon show.
+ https://bugs.webkit.org/show_bug.cgi?id=70696
+
+ Reviewed by Yury Semikhatsky.
+
+ Test: inspector/view-css.html
+
+ * inspector/front-end/View.js:
+ (WebInspector.View):
+ (WebInspector.View.prototype._callOnVisibleChildren):
+ (WebInspector.View.prototype._processWillShow):
+ (WebInspector.View.prototype._processWasShown):
+ (WebInspector.View.prototype._processWillHide):
+ (WebInspector.View.prototype._processWasHidden):
+ (WebInspector.View.prototype._processOnResize):
+ (WebInspector.View.prototype.show):
+ (WebInspector.View.prototype.detach):
+ (WebInspector.View.prototype.registerRequiredCSS):
+ (WebInspector.View.prototype._loadCSSIfNeeded):
+ (WebInspector.View.prototype._doLoadCSS):
+ (WebInspector.View.prototype._disableCSSIfNeeded):
+ (WebInspector.View.prototype._doUnloadCSS):
+
+2011-10-24 Pavel Feldman <pfeld...@chromium.org>
+
Web Inspector: make DataGrid a view
https://bugs.webkit.org/show_bug.cgi?id=70695
Modified: trunk/Source/WebCore/inspector/front-end/View.js (98226 => 98227)
--- trunk/Source/WebCore/inspector/front-end/View.js 2011-10-24 09:26:54 UTC (rev 98226)
+++ trunk/Source/WebCore/inspector/front-end/View.js 2011-10-24 09:40:47 UTC (rev 98227)
@@ -37,8 +37,12 @@
this._isShowing = false;
this._children = [];
this._hideOnDetach = false;
+ this._cssFiles = [];
}
+WebInspector.View._cssFileToVisibleViewCount = {};
+WebInspector.View._cssFileToStyleElement = {};
+
WebInspector.View.prototype = {
markAsRoot: function()
{
@@ -60,42 +64,53 @@
return this._isRoot || (this._parentView && this._parentView.isShowing());
},
+ _callOnVisibleChildren: function(method)
+ {
+ for (var i = 0; i < this._children.length; ++i)
+ if (this._children[i]._visible)
+ method.call(this._children[i]);
+ },
+
+ _processWillShow: function()
+ {
+ this._loadCSSIfNeeded();
+ this._callOnVisibleChildren(this._processWillShow);
+ },
+
_processWasShown: function()
{
- if (!this._parentIsShowing())
- return;
-
this._isShowing = true;
this.restoreScrollPositions();
this.wasShown();
this.onResize();
- for (var i = 0; i < this._children.length; ++i)
- this._children[i]._processWasShown();
+
+ this._callOnVisibleChildren(this._processWasShown);
},
_processWillHide: function()
{
- if (!this._parentIsShowing())
- return;
-
this.storeScrollPositions();
- for (var i = 0; i < this._children.length; ++i)
- this._children[i]._processWillHide();
+ this._callOnVisibleChildren(this._processWillHide);
this.willHide();
this._isShowing = false;
},
+ _processWasHidden: function()
+ {
+ this._disableCSSIfNeeded();
+ this._callOnVisibleChildren(this._processWasHidden);
+ },
+
_processOnResize: function()
{
if (!this.isShowing())
return;
this.onResize();
- for (var i = 0; i < this._children.length; ++i)
- this._children[i]._processOnResize();
+ this._callOnVisibleChildren(this._processOnResize);
},
wasShown: function()
@@ -118,34 +133,38 @@
{
WebInspector.View._assert(parentElement, "Attempt to attach view with no parent element");
- this._visible = true;
- this.element.addStyleClass("visible");
+ // Update view hierarchy
+ if (this.element.parentElement !== parentElement) {
+ var currentParent = parentElement;
+ while (currentParent && !currentParent.__view)
+ currentParent = currentParent.parentElement;
- if (this.element.parentElement === parentElement) {
- this._processWasShown();
+ if (currentParent) {
+ this._parentView = currentParent.__view;
+ this._parentView._children.push(this);
+ this._isRoot = false;
+ } else
+ WebInspector.View._assert(this._isRoot, "Attempt to attach view to orphan node");
+ } else if (this._visible)
return;
- }
- // Force legal append
- WebInspector.View._incrementViewCounter(parentElement, this.element);
- if (insertBefore)
- WebInspector.View._originalInsertBefore.call(parentElement, this.element, insertBefore);
- else
- WebInspector.View._originalAppendChild.call(parentElement, this.element);
+ this._visible = true;
+ if (this._parentIsShowing())
+ this._processWillShow();
- // Update view hierarchy
- var currentParent = parentElement;
- while (currentParent && !currentParent.__view)
- currentParent = currentParent.parentElement;
+ this.element.addStyleClass("visible");
- if (currentParent) {
- this._parentView = currentParent.__view;
- this._parentView._children.push(this);
- this._isRoot = false;
- } else
- WebInspector.View._assert(this._isRoot, "Attempt to attach view to orphan node");
+ // Reparent
+ if (this.element.parentElement !== parentElement) {
+ WebInspector.View._incrementViewCounter(parentElement, this.element);
+ if (insertBefore)
+ WebInspector.View._originalInsertBefore.call(parentElement, this.element, insertBefore);
+ else
+ WebInspector.View._originalAppendChild.call(parentElement, this.element);
+ }
- this._processWasShown();
+ if (this._parentIsShowing())
+ this._processWasShown();
},
detach: function()
@@ -154,10 +173,14 @@
if (!parentElement)
return;
- this._processWillHide();
+ if (this._parentIsShowing())
+ this._processWillHide();
if (this._hideOnDetach) {
this.element.removeStyleClass("visible");
+ this._visible = false;
+ if (this._parentIsShowing())
+ this._processWasHidden();
return;
}
@@ -165,15 +188,18 @@
WebInspector.View._decrementViewCounter(parentElement, this.element);
WebInspector.View._originalRemoveChild.call(parentElement, this.element);
+ this._visible = false;
+ if (this._parentIsShowing())
+ this._processWasHidden();
+
// Update view hierarchy
if (this._parentView) {
var childIndex = this._parentView._children.indexOf(this);
WebInspector.View._assert(childIndex >= 0, "Attempt to remove non-child view");
this._parentView._children.splice(childIndex, 1);
this._parentView = null;
- }
-
- this._visible = false;
+ } else
+ WebInspector.View._assert(this._isRoot, "Removing non-root view from DOM");
},
detachChildViews: function()
@@ -224,6 +250,63 @@
this._processOnResize();
},
+ registerRequiredCSS: function(cssFile)
+ {
+ this._cssFiles.push(cssFile);
+ },
+
+ _loadCSSIfNeeded: function()
+ {
+ for (var i = 0; i < this._cssFiles.length; ++i) {
+ var cssFile = this._cssFiles[i];
+
+ var viewsWithCSSFile = WebInspector.View._cssFileToVisibleViewCount[cssFile];
+ WebInspector.View._cssFileToVisibleViewCount[cssFile] = (viewsWithCSSFile || 0) + 1;
+ if (!viewsWithCSSFile)
+ this._doLoadCSS(cssFile);
+ }
+ },
+
+ _doLoadCSS: function(cssFile)
+ {
+ var styleElement = WebInspector.View._cssFileToStyleElement[cssFile];
+ if (styleElement) {
+ styleElement.disabled = false;
+ return;
+ }
+
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", cssFile, false);
+ xhr.send(null);
+
+ styleElement = document.createElement("style");
+ styleElement.type = "text/css";
+ styleElement.textContent = xhr.responseText;
+ document.head.insertBefore(styleElement, document.head.firstChild);
+
+ WebInspector.View._cssFileToStyleElement[cssFile] = styleElement;
+ },
+
+ _disableCSSIfNeeded: function()
+ {
+ for (var i = 0; i < this._cssFiles.length; ++i) {
+ var cssFile = this._cssFiles[i];
+
+ var viewsWithCSSFile = WebInspector.View._cssFileToVisibleViewCount[cssFile];
+ viewsWithCSSFile--;
+ WebInspector.View._cssFileToVisibleViewCount[cssFile] = viewsWithCSSFile;
+
+ if (!viewsWithCSSFile)
+ this._doUnloadCSS(cssFile);
+ }
+ },
+
+ _doUnloadCSS: function(cssFile)
+ {
+ var styleElement = WebInspector.View._cssFileToStyleElement[cssFile];
+ styleElement.disabled = true;
+ },
+
printViewHierarchy: function()
{
var lines = [];