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

Side by Side Diff: Source/core/inspector/InspectorFrontendHost.cpp

Issue 665763002: Oilpan: move context menu providers to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated GC_PLUGIN_IGNORE() Created 6 years, 2 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
« no previous file with comments | « Source/core/inspector/InspectorFrontendHost.h ('k') | Source/core/page/ContextMenuController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "platform/SharedBuffer.h" 52 #include "platform/SharedBuffer.h"
53 #include "platform/UserGestureIndicator.h" 53 #include "platform/UserGestureIndicator.h"
54 #include "platform/network/ResourceError.h" 54 #include "platform/network/ResourceError.h"
55 #include "platform/network/ResourceRequest.h" 55 #include "platform/network/ResourceRequest.h"
56 #include "platform/network/ResourceResponse.h" 56 #include "platform/network/ResourceResponse.h"
57 57
58 namespace blink { 58 namespace blink {
59 59
60 class FrontendMenuProvider final : public ContextMenuProvider { 60 class FrontendMenuProvider final : public ContextMenuProvider {
61 public: 61 public:
62 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* fronte ndHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem>& items) 62 static PassRefPtrWillBeRawPtr<FrontendMenuProvider> create(InspectorFrontend Host* frontendHost, ScriptValue frontendApiObject, const Vector<ContextMenuItem> & items)
63 { 63 {
64 return adoptRef(new FrontendMenuProvider(frontendHost, frontendApiObject , items)); 64 return adoptRefWillBeNoop(new FrontendMenuProvider(frontendHost, fronten dApiObject, items));
65 }
66
67 virtual ~FrontendMenuProvider()
68 {
69 // Verify that this menu provider has been detached.
70 ASSERT(!m_frontendHost);
71 }
72
73 virtual void trace(Visitor* visitor) override
74 {
75 visitor->trace(m_frontendHost);
76 ContextMenuProvider::trace(visitor);
65 } 77 }
66 78
67 void disconnect() 79 void disconnect()
68 { 80 {
69 m_frontendApiObject = ScriptValue(); 81 m_frontendApiObject = ScriptValue();
70 m_frontendHost = 0; 82 m_frontendHost = nullptr;
71 } 83 }
72 84
73 private: 85 virtual void contextMenuCleared() override
74 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue fronte ndApiObject, const Vector<ContextMenuItem>& items)
75 : m_frontendHost(frontendHost)
76 , m_frontendApiObject(frontendApiObject)
77 , m_items(items)
78 { 86 {
79 } 87 if (m_frontendHost) {
88 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared ");
89 function.call();
80 90
81 virtual ~FrontendMenuProvider() 91 m_frontendHost->clearMenuProvider();
82 { 92 m_frontendHost = nullptr;
83 contextMenuCleared(); 93 }
94 m_items.clear();
84 } 95 }
85 96
86 virtual void populateContextMenu(ContextMenu* menu) override 97 virtual void populateContextMenu(ContextMenu* menu) override
87 { 98 {
88 for (size_t i = 0; i < m_items.size(); ++i) 99 for (size_t i = 0; i < m_items.size(); ++i)
89 menu->appendItem(m_items[i]); 100 menu->appendItem(m_items[i]);
90 } 101 }
91 102
92 virtual void contextMenuItemSelected(const ContextMenuItem* item) override 103 virtual void contextMenuItemSelected(const ContextMenuItem* item) override
93 { 104 {
94 if (m_frontendHost) { 105 if (!m_frontendHost)
95 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGes ture); 106 return;
96 int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
97 107
98 ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSel ected"); 108 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture );
99 function.appendArgument(itemNumber); 109 int itemNumber = item->action() - ContextMenuItemBaseCustomTag;
100 function.call(); 110
101 } 111 ScriptFunctionCall function(m_frontendApiObject, "contextMenuItemSelecte d");
112 function.appendArgument(itemNumber);
113 function.call();
102 } 114 }
103 115
104 virtual void contextMenuCleared() override 116 private:
117 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptValue fronte ndApiObject, const Vector<ContextMenuItem>& items)
118 : m_frontendHost(frontendHost)
119 , m_frontendApiObject(frontendApiObject)
120 , m_items(items)
105 { 121 {
106 if (m_frontendHost) {
107 ScriptFunctionCall function(m_frontendApiObject, "contextMenuCleared ");
108 function.call();
109
110 m_frontendHost->m_menuProvider = 0;
111 }
112 m_items.clear();
113 m_frontendHost = 0;
114 } 122 }
115 123
116 InspectorFrontendHost* m_frontendHost; 124 RawPtrWillBeMember<InspectorFrontendHost> m_frontendHost;
117 ScriptValue m_frontendApiObject; 125 ScriptValue m_frontendApiObject;
126
127 // FIXME: Oilpan: remove when http://crbug.com/424962 Blink GC plugin
128 // changes have been deployed. ContextMenuItem triggers looping behavior.
129 GC_PLUGIN_IGNORE("crbug.com/424962")
118 Vector<ContextMenuItem> m_items; 130 Vector<ContextMenuItem> m_items;
119 }; 131 };
120 132
121 InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Pa ge* frontendPage) 133 InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Pa ge* frontendPage)
122 : m_client(client) 134 : m_client(client)
123 , m_frontendPage(frontendPage) 135 , m_frontendPage(frontendPage)
124 , m_menuProvider(0) 136 , m_menuProvider(nullptr)
125 { 137 {
126 } 138 }
127 139
128 InspectorFrontendHost::~InspectorFrontendHost() 140 InspectorFrontendHost::~InspectorFrontendHost()
129 { 141 {
130 ASSERT(!m_client); 142 ASSERT(!m_client);
131 } 143 }
132 144
133 void InspectorFrontendHost::trace(Visitor* visitor) 145 void InspectorFrontendHost::trace(Visitor* visitor)
134 { 146 {
135 visitor->trace(m_frontendPage); 147 visitor->trace(m_frontendPage);
148 visitor->trace(m_menuProvider);
136 } 149 }
137 150
138 void InspectorFrontendHost::disconnectClient() 151 void InspectorFrontendHost::disconnectClient()
139 { 152 {
140 m_client = 0; 153 m_client = 0;
141 if (m_menuProvider) 154 if (m_menuProvider) {
142 m_menuProvider->disconnect(); 155 m_menuProvider->disconnect();
156 m_menuProvider = nullptr;
157 }
143 m_frontendPage = nullptr; 158 m_frontendPage = nullptr;
144 } 159 }
145 160
146 void InspectorFrontendHost::setZoomFactor(float zoom) 161 void InspectorFrontendHost::setZoomFactor(float zoom)
147 { 162 {
148 if (!m_frontendPage) 163 if (!m_frontendPage)
149 return; 164 return;
150 if (LocalFrame* frame = m_frontendPage->deprecatedLocalMainFrame()) 165 if (LocalFrame* frame = m_frontendPage->deprecatedLocalMainFrame())
151 frame->setPageAndTextZoomFactors(zoom, 1); 166 frame->setPageAndTextZoomFactors(zoom, 1);
152 } 167 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message)); 224 m_client->sendMessageToEmbedder(escapeUnicodeNonCharacters(message));
210 } 225 }
211 226
212 void InspectorFrontendHost::showContextMenu(Page* page, float x, float y, const Vector<ContextMenuItem>& items) 227 void InspectorFrontendHost::showContextMenu(Page* page, float x, float y, const Vector<ContextMenuItem>& items)
213 { 228 {
214 ASSERT(m_frontendPage); 229 ASSERT(m_frontendPage);
215 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage- >deprecatedLocalMainFrame()); 230 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage- >deprecatedLocalMainFrame());
216 ScriptValue frontendApiObject = frontendScriptState->getFromGlobalObject("In spectorFrontendAPI"); 231 ScriptValue frontendApiObject = frontendScriptState->getFromGlobalObject("In spectorFrontendAPI");
217 ASSERT(frontendApiObject.isObject()); 232 ASSERT(frontendApiObject.isObject());
218 233
219 RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(thi s, frontendApiObject, items); 234 RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider ::create(this, frontendApiObject, items);
220 m_menuProvider = menuProvider.get(); 235 m_menuProvider = menuProvider.get();
221 float zoom = page->deprecatedLocalMainFrame()->pageZoomFactor(); 236 float zoom = page->deprecatedLocalMainFrame()->pageZoomFactor();
222 page->inspectorController().showContextMenu(x * zoom, y * zoom, menuProvider ); 237 page->inspectorController().showContextMenu(x * zoom, y * zoom, menuProvider );
223 } 238 }
224 239
225 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items) 240 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe nuItem>& items)
226 { 241 {
227 if (!event) 242 if (!event)
228 return; 243 return;
229 244
230 ASSERT(m_frontendPage); 245 ASSERT(m_frontendPage);
231 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage- >deprecatedLocalMainFrame()); 246 ScriptState* frontendScriptState = ScriptState::forMainWorld(m_frontendPage- >deprecatedLocalMainFrame());
232 ScriptValue frontendApiObject = frontendScriptState->getFromGlobalObject("In spectorFrontendAPI"); 247 ScriptValue frontendApiObject = frontendScriptState->getFromGlobalObject("In spectorFrontendAPI");
233 ASSERT(frontendApiObject.isObject()); 248 ASSERT(frontendApiObject.isObject());
234 249
235 Page* targetPage = m_frontendPage; 250 Page* targetPage = m_frontendPage;
236 if (event->target() && event->target()->executionContext() && event->target( )->executionContext()->executingWindow()) { 251 if (event->target() && event->target()->executionContext() && event->target( )->executionContext()->executingWindow()) {
237 LocalDOMWindow* window = event->target()->executionContext()->executingW indow(); 252 LocalDOMWindow* window = event->target()->executionContext()->executingW indow();
238 if (window->document() && window->document()->page()) 253 if (window->document() && window->document()->page())
239 targetPage = window->document()->page(); 254 targetPage = window->document()->page();
240 } 255 }
241 256
242 RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(thi s, frontendApiObject, items); 257 RefPtrWillBeRawPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider ::create(this, frontendApiObject, items);
243 targetPage->contextMenuController().showContextMenu(event, menuProvider); 258 targetPage->contextMenuController().showContextMenu(event, menuProvider);
244 m_menuProvider = menuProvider.get(); 259 m_menuProvider = menuProvider.get();
245 } 260 }
246 261
247 String InspectorFrontendHost::getSelectionBackgroundColor() 262 String InspectorFrontendHost::getSelectionBackgroundColor()
248 { 263 {
249 return RenderTheme::theme().activeSelectionBackgroundColor().serialized(); 264 return RenderTheme::theme().activeSelectionBackgroundColor().serialized();
250 } 265 }
251 266
252 String InspectorFrontendHost::getSelectionForegroundColor() 267 String InspectorFrontendHost::getSelectionForegroundColor()
253 { 268 {
254 return RenderTheme::theme().activeSelectionForegroundColor().serialized(); 269 return RenderTheme::theme().activeSelectionForegroundColor().serialized();
255 } 270 }
256 271
257 bool InspectorFrontendHost::isUnderTest() 272 bool InspectorFrontendHost::isUnderTest()
258 { 273 {
259 return m_client && m_client->isUnderTest(); 274 return m_client && m_client->isUnderTest();
260 } 275 }
261 276
262 bool InspectorFrontendHost::isHostedMode() 277 bool InspectorFrontendHost::isHostedMode()
263 { 278 {
264 return false; 279 return false;
265 } 280 }
266 281
267 } // namespace blink 282 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorFrontendHost.h ('k') | Source/core/page/ContextMenuController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698