| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library debugger_page_element; | 5 library debugger_page_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'dart:math'; | 9 import 'dart:math'; |
| 10 import 'observatory_element.dart'; | 10 import 'observatory_element.dart'; |
| (...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 // Has this frame been pinned open? | 2135 // Has this frame been pinned open? |
| 2136 bool _pinned = false; | 2136 bool _pinned = false; |
| 2137 | 2137 |
| 2138 void setCurrent(bool value) { | 2138 void setCurrent(bool value) { |
| 2139 busy = true; | 2139 busy = true; |
| 2140 frame.function.load().then((func) { | 2140 frame.function.load().then((func) { |
| 2141 _current = value; | 2141 _current = value; |
| 2142 var frameOuter = $['frameOuter']; | 2142 var frameOuter = $['frameOuter']; |
| 2143 if (_current) { | 2143 if (_current) { |
| 2144 frameOuter.classes.add('current'); | 2144 frameOuter.classes.add('current'); |
| 2145 expanded = true; | 2145 _expand(); |
| 2146 frameOuter.classes.add('shadow'); | |
| 2147 scrollIntoView(); | 2146 scrollIntoView(); |
| 2148 } else { | 2147 } else { |
| 2149 frameOuter.classes.remove('current'); | 2148 frameOuter.classes.remove('current'); |
| 2150 if (_pinned) { | 2149 if (_pinned) { |
| 2151 expanded = true; | 2150 _expand(); |
| 2152 frameOuter.classes.add('shadow'); | |
| 2153 } else { | 2151 } else { |
| 2154 expanded = false; | 2152 _unexpand(); |
| 2155 frameOuter.classes.remove('shadow'); | |
| 2156 } | 2153 } |
| 2157 } | 2154 } |
| 2158 busy = false; | 2155 busy = false; |
| 2159 }); | 2156 }); |
| 2160 } | 2157 } |
| 2161 | 2158 |
| 2162 @observable String scriptHeight; | 2159 @observable String scriptHeight; |
| 2163 @observable bool expanded = false; | 2160 @observable bool expanded = false; |
| 2164 @observable bool busy = false; | 2161 @observable bool busy = false; |
| 2165 | 2162 |
| 2166 DebuggerFrameElement.created() : super.created(); | 2163 DebuggerFrameElement.created() : super.created(); |
| 2167 | 2164 |
| 2168 | |
| 2169 String makeExpandKey(String key) { | 2165 String makeExpandKey(String key) { |
| 2170 return '${frame.function.qualifiedName}/${key}'; | 2166 return '${frame.function.qualifiedName}/${key}'; |
| 2171 } | 2167 } |
| 2172 | 2168 |
| 2173 bool matchFrame(Frame newFrame) { | 2169 bool matchFrame(Frame newFrame) { |
| 2174 return newFrame.function.id == frame.function.id; | 2170 return newFrame.function.id == frame.function.id; |
| 2175 } | 2171 } |
| 2176 | 2172 |
| 2177 void updateFrame(Frame newFrame) { | 2173 void updateFrame(Frame newFrame) { |
| 2178 assert(matchFrame(newFrame)); | 2174 assert(matchFrame(newFrame)); |
| 2179 frame = newFrame; | 2175 frame = newFrame; |
| 2180 } | 2176 } |
| 2181 | 2177 |
| 2182 Script get script => frame.location.script; | 2178 Script get script => frame.location.script; |
| 2183 | 2179 |
| 2180 int _varsTop(varsDiv) { |
| 2181 const minTop = 5; |
| 2182 if (varsDiv == null) { |
| 2183 return minTop; |
| 2184 } |
| 2185 const navbarHeight = NavBarElement.height; |
| 2186 const bottomPad = 6; |
| 2187 var parent = varsDiv.parent.getBoundingClientRect(); |
| 2188 var varsHeight = varsDiv.clientHeight; |
| 2189 var maxTop = parent.height - (varsHeight + bottomPad); |
| 2190 var adjustedTop = navbarHeight - parent.top; |
| 2191 return (max(minTop, min(maxTop, adjustedTop))); |
| 2192 } |
| 2193 |
| 2194 void _onScroll(event) { |
| 2195 if (!expanded) { |
| 2196 return; |
| 2197 } |
| 2198 var varsDiv = shadowRoot.querySelector('#vars'); |
| 2199 if (varsDiv == null) { |
| 2200 return; |
| 2201 } |
| 2202 var currentTop = varsDiv.style.top; |
| 2203 var newTop = _varsTop(varsDiv); |
| 2204 if (currentTop != newTop) { |
| 2205 varsDiv.style.top = '${newTop}px'; |
| 2206 } |
| 2207 } |
| 2208 |
| 2209 void _expand() { |
| 2210 var frameOuter = $['frameOuter']; |
| 2211 expanded = true; |
| 2212 frameOuter.classes.add('shadow'); |
| 2213 _subscribeToScroll(); |
| 2214 } |
| 2215 |
| 2216 void _unexpand() { |
| 2217 var frameOuter = $['frameOuter']; |
| 2218 expanded = false; |
| 2219 _unsubscribeToScroll(); |
| 2220 frameOuter.classes.remove('shadow'); |
| 2221 } |
| 2222 |
| 2223 StreamSubscription _scrollSubscription; |
| 2224 StreamSubscription _resizeSubscription; |
| 2225 |
| 2226 void _subscribeToScroll() { |
| 2227 if (scroller != null) { |
| 2228 if (_scrollSubscription == null) { |
| 2229 _scrollSubscription = scroller.onScroll.listen(_onScroll); |
| 2230 } |
| 2231 if (_resizeSubscription == null) { |
| 2232 _resizeSubscription = window.onResize.listen(_onScroll); |
| 2233 } |
| 2234 } |
| 2235 } |
| 2236 |
| 2237 void _unsubscribeToScroll() { |
| 2238 if (_scrollSubscription != null) { |
| 2239 _scrollSubscription.cancel(); |
| 2240 _scrollSubscription = null; |
| 2241 } |
| 2242 if (_resizeSubscription != null) { |
| 2243 _resizeSubscription.cancel(); |
| 2244 _resizeSubscription = null; |
| 2245 } |
| 2246 } |
| 2247 |
| 2184 @override | 2248 @override |
| 2185 void attached() { | 2249 void attached() { |
| 2186 super.attached(); | 2250 super.attached(); |
| 2187 int windowHeight = window.innerHeight; | 2251 int windowHeight = window.innerHeight; |
| 2188 scriptHeight = '${windowHeight ~/ 1.6}px'; | 2252 scriptHeight = '${windowHeight ~/ 1.6}px'; |
| 2253 if (expanded) { |
| 2254 _subscribeToScroll(); |
| 2255 } |
| 2256 } |
| 2257 |
| 2258 void detached() { |
| 2259 _unsubscribeToScroll(); |
| 2260 super.detached(); |
| 2189 } | 2261 } |
| 2190 | 2262 |
| 2191 void toggleExpand(var a, var b, var c) { | 2263 void toggleExpand(var a, var b, var c) { |
| 2192 if (busy) { | 2264 if (busy) { |
| 2193 return; | 2265 return; |
| 2194 } | 2266 } |
| 2195 busy = true; | 2267 busy = true; |
| 2196 frame.function.load().then((func) { | 2268 frame.function.load().then((func) { |
| 2197 _pinned = !_pinned; | 2269 _pinned = !_pinned; |
| 2198 var frameOuter = $['frameOuter']; | |
| 2199 if (_pinned) { | 2270 if (_pinned) { |
| 2200 expanded = true; | 2271 _expand(); |
| 2201 frameOuter.classes.add('shadow'); | |
| 2202 } else { | 2272 } else { |
| 2203 expanded = false; | 2273 _unexpand(); |
| 2204 frameOuter.classes.remove('shadow'); | |
| 2205 } | 2274 } |
| 2206 busy = false; | 2275 busy = false; |
| 2207 }); | 2276 }); |
| 2208 } | 2277 } |
| 2209 | 2278 |
| 2210 @observable | 2279 @observable |
| 2211 get properLocals { | 2280 get properLocals { |
| 2212 var locals = new List(); | 2281 var locals = new List(); |
| 2213 var homeMethod = frame.function.homeMethod; | 2282 var homeMethod = frame.function.homeMethod; |
| 2214 if (homeMethod.dartOwner is Class && homeMethod.isStatic) { | 2283 if (homeMethod.dartOwner is Class && homeMethod.isStatic) { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 } | 2631 } |
| 2563 }); | 2632 }); |
| 2564 } | 2633 } |
| 2565 | 2634 |
| 2566 void focus() { | 2635 void focus() { |
| 2567 $['textBox'].focus(); | 2636 $['textBox'].focus(); |
| 2568 } | 2637 } |
| 2569 | 2638 |
| 2570 DebuggerInputElement.created() : super.created(); | 2639 DebuggerInputElement.created() : super.created(); |
| 2571 } | 2640 } |
| OLD | NEW |