From 39ec1cfd2725841118b331229e6e67a74df63137 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Fri, 16 Mar 2012 13:25:13 -0700 Subject: [PATCH 1/3] Put the view's class in the DOM for easier debugging --- AppKit/CPView.j | 1 + 1 file changed, 1 insertion(+) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 28c947d59..007dadce5 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -291,6 +291,7 @@ var CPViewFlags = { }, CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(aFrame), _CGRectGetMinY(aFrame)); CPDOMDisplayServerSetStyleSize(_DOMElement, width, height); + _DOMElement.className = [self className]; _DOMImageParts = []; _DOMImageSizes = []; From 97b77e9b7b033c0d7410a6361ed981fc258f90d2 Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Sun, 18 Mar 2012 15:33:19 -0700 Subject: [PATCH 2/3] Changed to using data-cappuccino-view attribute --- AppKit/CPView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 007dadce5..3805fbeff 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -291,7 +291,7 @@ var CPViewFlags = { }, CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(aFrame), _CGRectGetMinY(aFrame)); CPDOMDisplayServerSetStyleSize(_DOMElement, width, height); - _DOMElement.className = [self className]; + _DOMElement.setAttribute("data-cappuccino-view", [self className]); _DOMImageParts = []; _DOMImageSizes = []; From 706129bcbdeccaab1c4c2a55c24b869d9cc8accc Mon Sep 17 00:00:00 2001 From: Aparajita Fishman Date: Sun, 18 Mar 2012 16:19:01 -0700 Subject: [PATCH 3/3] Implement a mechanism to display a DOM element's CPView class --- AppKit/CPView.j | 4 +++- Tools/capp/Resources/Templates/Application/index-debug.html | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 3805fbeff..52a948aef 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -291,7 +291,9 @@ var CPViewFlags = { }, CPDOMDisplayServerSetStyleLeftTop(_DOMElement, NULL, _CGRectGetMinX(aFrame), _CGRectGetMinY(aFrame)); CPDOMDisplayServerSetStyleSize(_DOMElement, width, height); - _DOMElement.setAttribute("data-cappuccino-view", [self className]); + + if (typeof(appkit_tag_dom_elements) !== "undefined" && !!appkit_tag_dom_elements) + _DOMElement.setAttribute("data-cappuccino-view", [self className]); _DOMImageParts = []; _DOMImageSizes = []; diff --git a/Tools/capp/Resources/Templates/Application/index-debug.html b/Tools/capp/Resources/Templates/Application/index-debug.html index 871c9f72d..a2da7fe2d 100644 --- a/Tools/capp/Resources/Templates/Application/index-debug.html +++ b/Tools/capp/Resources/Templates/Application/index-debug.html @@ -52,6 +52,10 @@ // Uncomment to enable a specific logger: //CPLogRegister(CPLogConsole); //CPLogRegister(CPLogPopup); + + // Tag view DOM elements with a "data-cappuccino-view" attribute that contains + // the class name of the view that created them. Comment this or set to false to disable. + appkit_tag_dom_elements = true;