Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 30 matching lines...) Expand all Loading... | |
| 41 #include "core/inspector/LayoutEditor.h" | 41 #include "core/inspector/LayoutEditor.h" |
| 42 #include "core/loader/EmptyClients.h" | 42 #include "core/loader/EmptyClients.h" |
| 43 #include "core/loader/FrameLoadRequest.h" | 43 #include "core/loader/FrameLoadRequest.h" |
| 44 #include "core/page/ChromeClient.h" | 44 #include "core/page/ChromeClient.h" |
| 45 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
| 46 #include "platform/JSONValues.h" | 46 #include "platform/JSONValues.h" |
| 47 #include "platform/ScriptForbiddenScope.h" | 47 #include "platform/ScriptForbiddenScope.h" |
| 48 #include "platform/graphics/GraphicsContext.h" | 48 #include "platform/graphics/GraphicsContext.h" |
| 49 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
| 50 #include "public/platform/WebData.h" | 50 #include "public/platform/WebData.h" |
| 51 #include "web/PageOverlay.h" | |
| 51 #include "web/WebGraphicsContextImpl.h" | 52 #include "web/WebGraphicsContextImpl.h" |
| 52 #include "web/WebInputEventConversion.h" | 53 #include "web/WebInputEventConversion.h" |
| 53 #include "web/WebLocalFrameImpl.h" | 54 #include "web/WebLocalFrameImpl.h" |
| 54 #include "web/WebViewImpl.h" | 55 #include "web/WebViewImpl.h" |
| 55 #include <v8.h> | 56 #include <v8.h> |
| 56 | 57 |
| 57 namespace OverlayZOrders { | |
| 58 // Use 99 as a big z-order number so that highlight is above other overlays. | |
| 59 static const int highlight = 99; | |
| 60 } | |
| 61 | |
| 62 namespace blink { | 58 namespace blink { |
| 63 | 59 |
| 64 namespace { | 60 namespace { |
| 65 | 61 |
| 66 class InspectorOverlayStub : public NoBaseWillBeGarbageCollectedFinalized<Inspec torOverlayStub>, public InspectorOverlay { | 62 class InspectorOverlayStub : public NoBaseWillBeGarbageCollectedFinalized<Inspec torOverlayStub>, public InspectorOverlay { |
| 67 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(InspectorOverlayStub); | 63 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(InspectorOverlayStub); |
| 68 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(InspectorOverlayStub); | 64 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(InspectorOverlayStub); |
| 69 public: | 65 public: |
| 70 InspectorOverlayStub() { } | 66 InspectorOverlayStub() { } |
| 71 DECLARE_TRACE(); | 67 DECLARE_TRACE(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 85 void setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor>) override { } | 81 void setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor>) override { } |
| 86 }; | 82 }; |
| 87 | 83 |
| 88 DEFINE_TRACE(InspectorOverlayStub) | 84 DEFINE_TRACE(InspectorOverlayStub) |
| 89 { | 85 { |
| 90 InspectorOverlay::trace(visitor); | 86 InspectorOverlay::trace(visitor); |
| 91 } | 87 } |
| 92 | 88 |
| 93 } // anonymous namespace | 89 } // anonymous namespace |
| 94 | 90 |
| 91 class InspectorOverlayImpl::InspectorPageOverlayDelegate : public PageOverlay::D elegate { | |
| 92 public: | |
| 93 InspectorPageOverlayDelegate(InspectorOverlayImpl& overlay) | |
| 94 : m_overlay(overlay) | |
| 95 { } | |
| 96 | |
| 97 void paintPageOverlay(WebGraphicsContext* context, const WebSize& webViewSiz e) | |
| 98 { | |
| 99 if (m_overlay.isEmpty()) | |
| 100 return; | |
| 101 | |
| 102 GraphicsContext& graphicsContext = toWebGraphicsContextImpl(context)->gr aphicsContext(); | |
| 103 FrameView* view = m_overlay.overlayMainFrame()->view(); | |
| 104 ASSERT(!view->needsLayout()); | |
| 105 view->paint(&graphicsContext, IntRect(0, 0, view->width(), view->height( ))); | |
| 106 } | |
| 107 | |
| 108 private: | |
| 109 InspectorOverlayImpl& m_overlay; | |
| 110 }; | |
| 111 | |
| 112 | |
| 95 class InspectorOverlayImpl::InspectorOverlayChromeClient final: public EmptyChro meClient { | 113 class InspectorOverlayImpl::InspectorOverlayChromeClient final: public EmptyChro meClient { |
| 96 public: | 114 public: |
| 97 InspectorOverlayChromeClient(ChromeClient& client, InspectorOverlayImpl& ove rlay) | 115 InspectorOverlayChromeClient(ChromeClient& client, InspectorOverlayImpl& ove rlay) |
| 98 : m_client(client) | 116 : m_client(client) |
| 99 , m_overlay(overlay) | 117 , m_overlay(overlay) |
| 100 { } | 118 { } |
| 101 | 119 |
| 102 void setCursor(const Cursor& cursor) override | 120 void setCursor(const Cursor& cursor) override |
| 103 { | 121 { |
| 104 m_client.setCursor(cursor); | 122 m_client.setCursor(cursor); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 { | 176 { |
| 159 visitor->trace(m_highlightNode); | 177 visitor->trace(m_highlightNode); |
| 160 visitor->trace(m_eventTargetNode); | 178 visitor->trace(m_eventTargetNode); |
| 161 visitor->trace(m_overlayPage); | 179 visitor->trace(m_overlayPage); |
| 162 visitor->trace(m_overlayHost); | 180 visitor->trace(m_overlayHost); |
| 163 visitor->trace(m_listener); | 181 visitor->trace(m_listener); |
| 164 visitor->trace(m_layoutEditor); | 182 visitor->trace(m_layoutEditor); |
| 165 InspectorOverlay::trace(visitor); | 183 InspectorOverlay::trace(visitor); |
| 166 } | 184 } |
| 167 | 185 |
| 168 void InspectorOverlayImpl::paintPageOverlay(WebGraphicsContext* context, const W ebSize& webViewSize) | |
| 169 { | |
| 170 if (isEmpty()) | |
| 171 return; | |
| 172 | |
| 173 GraphicsContext& graphicsContext = toWebGraphicsContextImpl(context)->graphi csContext(); | |
| 174 FrameView* view = overlayMainFrame()->view(); | |
| 175 ASSERT(!view->needsLayout()); | |
| 176 view->paint(&graphicsContext, IntRect(0, 0, view->width(), view->height())); | |
| 177 } | |
| 178 | |
| 179 void InspectorOverlayImpl::invalidate() | 186 void InspectorOverlayImpl::invalidate() |
| 180 { | 187 { |
| 181 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); | 188 if (!m_pageOverlay) |
| 189 m_pageOverlay = PageOverlay::create(m_webViewImpl, adoptPtr(new Inspecto rPageOverlayDelegate(*this))); | |
| 190 | |
| 191 m_pageOverlay->update(); | |
| 182 } | 192 } |
| 183 | 193 |
| 184 void InspectorOverlayImpl::layout() | 194 void InspectorOverlayImpl::layout() |
| 185 { | 195 { |
| 186 if (isEmpty()) | 196 if (isEmpty()) |
| 187 return; | 197 return; |
| 188 | 198 |
| 189 TemporaryChange<bool> scoped(m_inLayout, true); | 199 TemporaryChange<bool> scoped(m_inLayout, true); |
| 190 if (m_needsUpdate) { | 200 if (m_needsUpdate) { |
| 191 m_needsUpdate = false; | 201 m_needsUpdate = false; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (m_suspendCount) | 291 if (m_suspendCount) |
| 282 return true; | 292 return true; |
| 283 bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_hi ghlightQuad || m_drawViewSize; | 293 bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_hi ghlightQuad || m_drawViewSize; |
| 284 bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull() ; | 294 bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull() ; |
| 285 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && ! m_inspectModeEnabled)); | 295 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && ! m_inspectModeEnabled)); |
| 286 } | 296 } |
| 287 | 297 |
| 288 void InspectorOverlayImpl::update() | 298 void InspectorOverlayImpl::update() |
| 289 { | 299 { |
| 290 if (isEmpty()) { | 300 if (isEmpty()) { |
| 291 m_webViewImpl->removePageOverlay(this); | 301 if (m_pageOverlay) |
| 302 m_pageOverlay.clear(); | |
| 292 return; | 303 return; |
| 293 } | 304 } |
| 294 m_needsUpdate = true; | 305 m_needsUpdate = true; |
| 295 m_webViewImpl->page()->chromeClient().scheduleAnimation(); | 306 m_webViewImpl->page()->chromeClient().scheduleAnimation(); |
| 296 } | 307 } |
| 297 | 308 |
| 298 void InspectorOverlayImpl::rebuildOverlayPage() | 309 void InspectorOverlayImpl::rebuildOverlayPage() |
| 299 { | 310 { |
| 300 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); | 311 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); |
| 301 if (!view) | 312 if (!view) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 { | 513 { |
| 503 --m_suspendCount; | 514 --m_suspendCount; |
| 504 } | 515 } |
| 505 | 516 |
| 506 void InspectorOverlayImpl::setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor> layoutEditor) | 517 void InspectorOverlayImpl::setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor> layoutEditor) |
| 507 { | 518 { |
| 508 m_layoutEditor = layoutEditor; | 519 m_layoutEditor = layoutEditor; |
| 509 m_overlayHost->setLayoutEditorListener(m_layoutEditor.get()); | 520 m_overlayHost->setLayoutEditorListener(m_layoutEditor.get()); |
| 510 } | 521 } |
| 511 | 522 |
| 523 GraphicsLayer* InspectorOverlayImpl::graphicsLayer() | |
| 524 { | |
| 525 if (!m_pageOverlay) | |
| 526 return nullptr; | |
| 527 | |
| 528 return m_pageOverlay->graphicsLayer(); | |
| 529 } | |
| 530 | |
| 531 void InspectorOverlayImpl::updatePageOverlay() | |
|
dgozman
2015/07/30 10:17:31
updateGraphicsLayer? Or even better replace two me
sergeyv
2015/07/30 11:42:37
Done.
| |
| 532 { | |
| 533 if (m_pageOverlay) | |
| 534 m_pageOverlay->update(); | |
| 535 } | |
| 512 | 536 |
| 513 } // namespace blink | 537 } // namespace blink |
| OLD | NEW |