Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Side by Side Diff: Source/web/InspectorOverlayImpl.cpp

Issue 1206833003: Devtools[LayoutEditor]: Pass data about property change from InspectorOverlayPage (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix empty line Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void setPausedInDebuggerMessage(const String*) override { } 102 void setPausedInDebuggerMessage(const String*) override { }
103 void setInspectModeEnabled(bool) override { } 103 void setInspectModeEnabled(bool) override { }
104 void hideHighlight() override { } 104 void hideHighlight() override { }
105 void highlightNode(Node*, Node* eventTarget, const InspectorHighlightConfig& , bool omitTooltip) override { } 105 void highlightNode(Node*, Node* eventTarget, const InspectorHighlightConfig& , bool omitTooltip) override { }
106 void highlightQuad(PassOwnPtr<FloatQuad>, const InspectorHighlightConfig&) o verride { } 106 void highlightQuad(PassOwnPtr<FloatQuad>, const InspectorHighlightConfig&) o verride { }
107 void showAndHideViewSize(bool showGrid) override { } 107 void showAndHideViewSize(bool showGrid) override { }
108 void setListener(InspectorOverlay::Listener* listener) override { } 108 void setListener(InspectorOverlay::Listener* listener) override { }
109 void suspendUpdates() override { } 109 void suspendUpdates() override { }
110 void resumeUpdates() override { } 110 void resumeUpdates() override { }
111 void clear() override { } 111 void clear() override { }
112 void setCSSAgent(InspectorCSSAgent*) override { }
112 }; 113 };
113 114
114 DEFINE_TRACE(InspectorOverlayStub) 115 DEFINE_TRACE(InspectorOverlayStub)
115 { 116 {
116 InspectorOverlay::trace(visitor); 117 InspectorOverlay::trace(visitor);
117 } 118 }
118 119
119 } // anonymous namespace 120 } // anonymous namespace
120 121
121 // static 122 // static
122 PassOwnPtrWillBeRawPtr<InspectorOverlay> InspectorOverlayImpl::createEmpty() 123 PassOwnPtrWillBeRawPtr<InspectorOverlay> InspectorOverlayImpl::createEmpty()
123 { 124 {
124 return adoptPtrWillBeNoop(new InspectorOverlayStub()); 125 return adoptPtrWillBeNoop(new InspectorOverlayStub());
125 } 126 }
126 127
127 InspectorOverlayImpl::InspectorOverlayImpl(WebViewImpl* webViewImpl) 128 InspectorOverlayImpl::InspectorOverlayImpl(WebViewImpl* webViewImpl)
128 : m_webViewImpl(webViewImpl) 129 : m_webViewImpl(webViewImpl)
129 , m_inspectModeEnabled(false) 130 , m_inspectModeEnabled(false)
130 , m_overlayHost(InspectorOverlayHost::create()) 131 , m_overlayHost(InspectorOverlayHost::create())
131 , m_drawViewSize(false) 132 , m_drawViewSize(false)
132 , m_drawViewSizeWithGrid(false) 133 , m_drawViewSizeWithGrid(false)
133 , m_omitTooltip(false) 134 , m_omitTooltip(false)
134 , m_timer(this, &InspectorOverlayImpl::onTimer) 135 , m_timer(this, &InspectorOverlayImpl::onTimer)
135 , m_suspendCount(0) 136 , m_suspendCount(0)
136 , m_updating(false) 137 , m_updating(false)
138 , m_layoutEditor(nullptr)
dgozman 2015/06/25 12:31:00 Not needed.
sergeyv 2015/06/25 12:54:31 Done.
137 { 139 {
138 m_overlayHost->setListener(this); 140 m_overlayHost->setDebuggerListener(this);
139 } 141 }
140 142
141 InspectorOverlayImpl::~InspectorOverlayImpl() 143 InspectorOverlayImpl::~InspectorOverlayImpl()
142 { 144 {
143 ASSERT(!m_overlayPage); 145 ASSERT(!m_overlayPage);
144 } 146 }
145 147
146 DEFINE_TRACE(InspectorOverlayImpl) 148 DEFINE_TRACE(InspectorOverlayImpl)
147 { 149 {
148 visitor->trace(m_highlightNode); 150 visitor->trace(m_highlightNode);
(...skipping 21 matching lines...) Expand all
170 // Don't invalidate during an update, because that will lead to Document::sc heduleLayoutTreeUpdate 172 // Don't invalidate during an update, because that will lead to Document::sc heduleLayoutTreeUpdate
171 // being called within Document::updateLayoutTree which violates document li fecycle expectations. 173 // being called within Document::updateLayoutTree which violates document li fecycle expectations.
172 if (m_updating) 174 if (m_updating)
173 return; 175 return;
174 176
175 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); 177 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight);
176 } 178 }
177 179
178 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent) 180 bool InspectorOverlayImpl::handleInputEvent(const WebInputEvent& inputEvent)
179 { 181 {
182 bool handled = false;
180 if (isEmpty()) 183 if (isEmpty())
181 return false; 184 return handled;
182 185
183 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) { 186 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) {
184 // Only let GestureTab in (we only need it and we know PlatformGestureEv entBuilder supports it). 187 // Only let GestureTab in (we only need it and we know PlatformGestureEv entBuilder supports it).
185 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv ent)); 188 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webVie wImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEv ent));
186 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); 189 overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent);
187 } 190 }
188 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W ebInputEvent::MouseEnter) { 191 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W ebInputEvent::MouseEnter) {
189 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f ilter it out manually. 192 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f ilter it out manually.
190 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); 193 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent));
191 if (mouseEvent.type() == PlatformEvent::MouseMoved) 194 if (mouseEvent.type() == PlatformEvent::MouseMoved)
192 overlayMainFrame()->eventHandler().handleMouseMoveEvent(mouseEvent); 195 handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mo useEvent);
193 if (mouseEvent.type() == PlatformEvent::MousePressed) 196 if (mouseEvent.type() == PlatformEvent::MousePressed)
194 overlayMainFrame()->eventHandler().handleMousePressEvent(mouseEvent) ; 197 handled = overlayMainFrame()->eventHandler().handleMousePressEvent(m ouseEvent);
195 if (mouseEvent.type() == PlatformEvent::MouseReleased) 198 if (mouseEvent.type() == PlatformEvent::MouseReleased)
196 overlayMainFrame()->eventHandler().handleMouseReleaseEvent(mouseEven t); 199 handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent (mouseEvent);
197 } 200 }
198 if (WebInputEvent::isTouchEventType(inputEvent.type)) { 201 if (WebInputEvent::isTouchEventType(inputEvent.type)) {
199 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); 202 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl- >mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent));
200 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); 203 overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent);
201 } 204 }
202 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { 205 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) {
203 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati c_cast<const WebKeyboardEvent&>(inputEvent)); 206 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(stati c_cast<const WebKeyboardEvent&>(inputEvent));
204 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); 207 overlayMainFrame()->eventHandler().keyEvent(keyboardEvent);
205 } 208 }
206 209
207 // Overlay should not consume events. 210 return handled;
208 return false;
209 } 211 }
210 212
211 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message) 213 void InspectorOverlayImpl::setPausedInDebuggerMessage(const String* message)
212 { 214 {
213 m_pausedInDebuggerMessage = message ? *message : String(); 215 m_pausedInDebuggerMessage = message ? *message : String();
214 update(); 216 update();
215 } 217 }
216 218
217 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled) 219 void InspectorOverlayImpl::setInspectModeEnabled(bool enabled)
218 { 220 {
219 m_inspectModeEnabled = enabled; 221 m_inspectModeEnabled = enabled;
220 update(); 222 update();
221 } 223 }
222 224
223 void InspectorOverlayImpl::hideHighlight() 225 void InspectorOverlayImpl::hideHighlight()
224 { 226 {
227 if (m_layoutEditor)
228 m_layoutEditor->setNode(nullptr);
225 m_highlightNode.clear(); 229 m_highlightNode.clear();
226 m_eventTargetNode.clear(); 230 m_eventTargetNode.clear();
227 m_highlightQuad.clear(); 231 m_highlightQuad.clear();
228 m_layoutEditor.clear();
229 update(); 232 update();
230 } 233 }
231 234
232 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In spectorHighlightConfig& highlightConfig, bool omitTooltip) 235 void InspectorOverlayImpl::highlightNode(Node* node, Node* eventTarget, const In spectorHighlightConfig& highlightConfig, bool omitTooltip)
233 { 236 {
234 m_nodeHighlightConfig = highlightConfig; 237 m_nodeHighlightConfig = highlightConfig;
235 m_highlightNode = node; 238 m_highlightNode = node;
236 if (highlightConfig.showLayoutEditor) 239 if (highlightConfig.showLayoutEditor)
dgozman 2015/06/25 12:31:00 && m_layoutEditor
sergeyv 2015/06/25 12:54:31 Done.
237 m_layoutEditor = LayoutEditor::create(node); 240 m_layoutEditor->setNode(node);
238 m_eventTargetNode = eventTarget; 241 m_eventTargetNode = eventTarget;
239 m_omitTooltip = omitTooltip; 242 m_omitTooltip = omitTooltip;
240 update(); 243 update();
241 } 244 }
242 245
243 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe ctorHighlightConfig& highlightConfig) 246 void InspectorOverlayImpl::highlightQuad(PassOwnPtr<FloatQuad> quad, const Inspe ctorHighlightConfig& highlightConfig)
244 { 247 {
245 m_quadHighlightConfig = highlightConfig; 248 m_quadHighlightConfig = highlightConfig;
246 m_highlightQuad = quad; 249 m_highlightQuad = quad;
247 m_omitTooltip = false; 250 m_omitTooltip = false;
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 { 480 {
478 if (!m_suspendCount++) 481 if (!m_suspendCount++)
479 clear(); 482 clear();
480 } 483 }
481 484
482 void InspectorOverlayImpl::resumeUpdates() 485 void InspectorOverlayImpl::resumeUpdates()
483 { 486 {
484 --m_suspendCount; 487 --m_suspendCount;
485 } 488 }
486 489
490 void InspectorOverlayImpl::setCSSAgent(InspectorCSSAgent* cssAgent)
491 {
492 if (cssAgent)
493 m_layoutEditor = LayoutEditor::create(cssAgent);
494 else
495 m_layoutEditor.clear();
496
497 m_overlayHost->setLayoutEditorListener(m_layoutEditor.get());
498 }
499
500
487 } // namespace blink 501 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698