Changeset 56999 in webkit
- Timestamp:
- Apr 2, 2010 5:55:40 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56997 r56999 1 2010-04-02 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Implement InspectorFrontendHost::showContextMenu for Chromium. 6 7 Move inspector frontend context menu code from InspectorFrontendClient to InspectorFrontendHost as it's platform independent. 8 9 https://bugs.webkit.org/show_bug.cgi?id=36817 10 11 * WebCore.Inspector.exp: 12 * bindings/v8/custom/V8InspectorFrontendHostCustom.cpp: 13 (WebCore::V8InspectorFrontendHost::showContextMenuCallback): 14 * inspector/InspectorFrontendClient.h: 15 * inspector/InspectorFrontendClientLocal.cpp: 16 (WebCore::InspectorFrontendClientLocal::InspectorFrontendClientLocal): 17 (WebCore::InspectorFrontendClientLocal::~InspectorFrontendClientLocal): 18 (WebCore::InspectorFrontendClientLocal::windowObjectCleared): 19 * inspector/InspectorFrontendClientLocal.h: 20 * inspector/InspectorFrontendHost.cpp: 21 (WebCore::FrontendMenuProvider::create): 22 (WebCore::FrontendMenuProvider::disconnect): 23 (WebCore::FrontendMenuProvider::FrontendMenuProvider): 24 (WebCore::FrontendMenuProvider::~FrontendMenuProvider): 25 (WebCore::FrontendMenuProvider::populateContextMenu): 26 (WebCore::FrontendMenuProvider::contextMenuItemSelected): 27 (WebCore::FrontendMenuProvider::contextMenuCleared): 28 (WebCore::InspectorFrontendHost::InspectorFrontendHost): 29 (WebCore::InspectorFrontendHost::disconnectClient): 30 (WebCore::InspectorFrontendHost::showContextMenu): 31 * inspector/InspectorFrontendHost.h: 32 (WebCore::InspectorFrontendHost::create): 33 1 34 2010-04-02 Ilya Tikhonovsky <loislo@chromium.org> 2 35 -
trunk/WebCore/WebCore.Inspector.exp
r56051 r56999 25 25 __ZN7WebCore28InspectorFrontendClientLocal12moveWindowByEff 26 26 __ZN7WebCore28InspectorFrontendClientLocal15canAttachWindowEv 27 __ZN7WebCore28InspectorFrontendClientLocal15showContextMenuEPNS_5EventERKN3WTF6VectorIPNS_15ContextMenuItemELm0EEE28 27 __ZN7WebCore28InspectorFrontendClientLocal17setAttachedWindowEb 29 28 __ZN7WebCore28InspectorFrontendClientLocal26changeAttachedWindowHeightEj -
trunk/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
r54349 r56999 36 36 37 37 #include "V8Binding.h" 38 #include "V8MouseEvent.h" 38 39 #include "V8Proxy.h" 39 40 … … 42 43 v8::Handle<v8::Value> V8InspectorFrontendHost::showContextMenuCallback(const v8::Arguments& args) 43 44 { 45 if (args.Length() < 2) 46 return v8::Undefined(); 47 48 v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(args[0]); 49 if (!V8MouseEvent::info.equals(V8DOMWrapper::domWrapperType(eventWrapper))) 50 return v8::Undefined(); 51 52 Event* event = V8Event::toNative(eventWrapper); 53 if (!args[1]->IsArray()) 54 return v8::Undefined(); 55 56 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]); 57 Vector<ContextMenuItem*> items; 58 59 for (size_t i = 0; i < array->Length(); ++i) { 60 v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(array->Get(v8::Integer::New(i))); 61 v8::Local<v8::Value> label = item->Get(v8::String::New("label")); 62 v8::Local<v8::Value> id = item->Get(v8::String::New("id")); 63 if (label->IsUndefined() || id->IsUndefined()) { 64 items.append(new ContextMenuItem(SeparatorType, 65 ContextMenuItemTagNoAction, 66 String())); 67 } else { 68 ContextMenuAction typedId = static_cast<ContextMenuAction>( 69 ContextMenuItemBaseCustomTag + id->ToInt32()->Value()); 70 items.append(new ContextMenuItem(ActionType, 71 typedId, 72 toWebCoreStringWithNullCheck(label))); 73 } 74 } 75 76 InspectorFrontendHost* frontendHost = V8InspectorFrontendHost::toNative(args.Holder()); 77 frontendHost->showContextMenu(event, items); 78 44 79 return v8::Undefined(); 45 80 } -
trunk/WebCore/inspector/InspectorFrontendClient.h
r56051 r56999 61 61 62 62 virtual void inspectedURLChanged(const String&) = 0; 63 64 virtual void showContextMenu(Event*, const Vector<ContextMenuItem*>&) = 0;65 63 }; 66 64 -
trunk/WebCore/inspector/InspectorFrontendClientLocal.cpp
r56051 r56999 35 35 36 36 #include "Chrome.h" 37 #include "ContextMenu.h"38 #include "ContextMenuController.h"39 #include "ContextMenuItem.h"40 #include "ContextMenuProvider.h"41 37 #include "FloatRect.h" 42 38 #include "Frame.h" … … 52 48 namespace WebCore { 53 49 54 class FrontendMenuProvider : public ContextMenuProvider {55 public:56 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendClientLocal* frontendClient, ScriptObject webInspector, const Vector<ContextMenuItem*>& items)57 {58 return adoptRef(new FrontendMenuProvider(frontendClient, webInspector, items));59 }60 61 void disconnect()62 {63 m_webInspector = ScriptObject();64 m_frontendClient = 0;65 }66 67 private:68 FrontendMenuProvider(InspectorFrontendClientLocal* frontendClient, ScriptObject webInspector, const Vector<ContextMenuItem*>& items)69 : m_frontendClient(frontendClient)70 , m_webInspector(webInspector)71 , m_items(items)72 {73 }74 75 virtual ~FrontendMenuProvider()76 {77 contextMenuCleared();78 }79 80 virtual void populateContextMenu(ContextMenu* menu)81 {82 for (size_t i = 0; i < m_items.size(); ++i)83 menu->appendItem(*m_items[i]);84 }85 86 virtual void contextMenuItemSelected(ContextMenuItem* item)87 {88 int itemNumber = item->action() - ContextMenuItemBaseCustomTag;89 90 ScriptFunctionCall function(m_webInspector, "dispatch");91 function.appendArgument("contextMenuItemSelected");92 function.appendArgument(itemNumber);93 function.call();94 }95 96 virtual void contextMenuCleared()97 {98 99 if (m_frontendClient) {100 ScriptFunctionCall function(m_webInspector, "dispatch");101 function.appendArgument("contextMenuCleared");102 function.call();103 104 m_frontendClient->m_menuProvider = 0;105 }106 deleteAllValues(m_items);107 m_items.clear();108 }109 110 InspectorFrontendClientLocal* m_frontendClient;111 ScriptObject m_webInspector;112 Vector<ContextMenuItem*> m_items;113 };114 115 50 static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight"; 116 51 static const unsigned defaultAttachedHeight = 300; … … 122 57 , m_frontendPage(frontendPage) 123 58 , m_frontendScriptState(0) 124 , m_menuProvider(0)125 59 { 126 60 } … … 130 64 if (m_frontendHost) 131 65 m_frontendHost->disconnectClient(); 132 if (m_menuProvider)133 m_menuProvider->disconnect();134 66 m_frontendScriptState = 0; 135 67 m_frontendPage = 0; … … 144 76 m_frontendScriptState = scriptStateFromPage(debuggerWorld(), m_frontendPage); 145 77 ScriptGlobalObject::set(m_frontendScriptState, "InspectorBackend", m_inspectorController->inspectorBackend()); 146 m_frontendHost = InspectorFrontendHost::create(this );78 m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage); 147 79 ScriptGlobalObject::set(m_frontendScriptState, "InspectorFrontendHost", m_frontendHost.get()); 148 80 } … … 184 116 } 185 117 186 void InspectorFrontendClientLocal::showContextMenu(Event* event, const Vector<ContextMenuItem*>& items)187 {188 ScriptObject webInspectorObj;189 if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) {190 ASSERT_NOT_REACHED();191 return;192 }193 194 RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, webInspectorObj, items);195 ContextMenuController* menuController = m_frontendPage->contextMenuController();196 menuController->showContextMenu(event, menuProvider);197 m_menuProvider = menuProvider.get();198 }199 200 118 void InspectorFrontendClientLocal::setAttachedWindow(bool attached) 201 119 { -
trunk/WebCore/inspector/InspectorFrontendClientLocal.h
r56051 r56999 38 38 namespace WebCore { 39 39 40 class FrontendMenuProvider;41 40 class InspectorController; 42 41 class InspectorFrontendHost; … … 56 55 virtual void changeAttachedWindowHeight(unsigned); 57 56 58 virtual void showContextMenu(Event*, const Vector<ContextMenuItem*>&);59 60 57 protected: 61 58 virtual void setAttachedWindowHeight(unsigned) = 0; … … 73 70 // TODO(yurys): this ref shouldn't be needed. 74 71 RefPtr<InspectorFrontendHost> m_frontendHost; 75 FrontendMenuProvider* m_menuProvider;76 72 }; 77 73 -
trunk/WebCore/inspector/InspectorFrontendHost.cpp
r56051 r56999 46 46 #include "Page.h" 47 47 #include "Pasteboard.h" 48 #include "ScriptFunctionCall.h" 48 49 49 50 #include <wtf/RefPtr.h> … … 54 55 namespace WebCore { 55 56 56 InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client) 57 class FrontendMenuProvider : public ContextMenuProvider { 58 public: 59 static PassRefPtr<FrontendMenuProvider> create(InspectorFrontendHost* frontendHost, ScriptObject webInspector, const Vector<ContextMenuItem*>& items) 60 { 61 return adoptRef(new FrontendMenuProvider(frontendHost, webInspector, items)); 62 } 63 64 void disconnect() 65 { 66 m_webInspector = ScriptObject(); 67 m_frontendHost = 0; 68 } 69 70 private: 71 FrontendMenuProvider(InspectorFrontendHost* frontendHost, ScriptObject webInspector, const Vector<ContextMenuItem*>& items) 72 : m_frontendHost(frontendHost) 73 , m_webInspector(webInspector) 74 , m_items(items) 75 { 76 } 77 78 virtual ~FrontendMenuProvider() 79 { 80 contextMenuCleared(); 81 } 82 83 virtual void populateContextMenu(ContextMenu* menu) 84 { 85 for (size_t i = 0; i < m_items.size(); ++i) 86 menu->appendItem(*m_items[i]); 87 } 88 89 virtual void contextMenuItemSelected(ContextMenuItem* item) 90 { 91 if (m_frontendHost) { 92 int itemNumber = item->action() - ContextMenuItemBaseCustomTag; 93 94 ScriptFunctionCall function(m_webInspector, "dispatch"); 95 function.appendArgument("contextMenuItemSelected"); 96 function.appendArgument(itemNumber); 97 function.call(); 98 } 99 } 100 101 virtual void contextMenuCleared() 102 { 103 if (m_frontendHost) { 104 ScriptFunctionCall function(m_webInspector, "dispatch"); 105 function.appendArgument("contextMenuCleared"); 106 function.call(); 107 108 m_frontendHost->m_menuProvider = 0; 109 } 110 deleteAllValues(m_items); 111 m_items.clear(); 112 } 113 114 InspectorFrontendHost* m_frontendHost; 115 ScriptObject m_webInspector; 116 Vector<ContextMenuItem*> m_items; 117 }; 118 119 InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client, Page* frontendPage) 57 120 : m_client(client) 121 , m_frontendPage(frontendPage) 122 , m_menuProvider(0) 58 123 { 59 124 } … … 67 132 { 68 133 m_client = 0; 134 if (m_menuProvider) 135 m_menuProvider->disconnect(); 136 m_frontendPage = 0; 69 137 } 70 138 … … 170 238 void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMenuItem*>& items) 171 239 { 172 if (m_client) 173 m_client->showContextMenu(event, items); 240 ASSERT(m_frontendPage); 241 ScriptState* frontendScriptState = scriptStateFromPage(debuggerWorld(), m_frontendPage); 242 ScriptObject webInspectorObj; 243 if (!ScriptGlobalObject::get(frontendScriptState, "WebInspector", webInspectorObj)) { 244 ASSERT_NOT_REACHED(); 245 return; 246 } 247 RefPtr<FrontendMenuProvider> menuProvider = FrontendMenuProvider::create(this, webInspectorObj, items); 248 ContextMenuController* menuController = m_frontendPage->contextMenuController(); 249 menuController->showContextMenu(event, menuProvider); 250 m_menuProvider = menuProvider.get(); 174 251 } 175 252 -
trunk/WebCore/inspector/InspectorFrontendHost.h
r56051 r56999 43 43 class ContextMenuItem; 44 44 class Event; 45 class FrontendMenuProvider; 45 46 class InspectorClient; 46 47 class InspectorFrontendClient; … … 50 51 { 51 52 public: 52 static PassRefPtr<InspectorFrontendHost> create(InspectorFrontendClient* client )53 static PassRefPtr<InspectorFrontendHost> create(InspectorFrontendClient* client, Page* frontendPage) 53 54 { 54 return adoptRef(new InspectorFrontendHost(client ));55 return adoptRef(new InspectorFrontendHost(client, frontendPage)); 55 56 } 56 57 … … 80 81 81 82 private: 82 InspectorFrontendHost(InspectorFrontendClient* client); 83 friend class FrontendMenuProvider; 84 InspectorFrontendHost(InspectorFrontendClient* client, Page* frontendPage); 83 85 84 86 InspectorFrontendClient* m_client; 87 Page* m_frontendPage; 88 FrontendMenuProvider* m_menuProvider; 85 89 }; 86 90 -
trunk/WebKit/chromium/ChangeLog
r56972 r56999 1 2010-04-02 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Implement InspectorFrontendClient in Chromium and remove all custom bindings for the host methods from WebDevToolsFrontendImpl. 6 7 https://bugs.webkit.org/show_bug.cgi?id=36817 8 9 * WebKit.gyp: 10 * src/InspectorFrontendClientImpl.cpp: Added. 11 (WebKit::InspectorFrontendClientImpl::InspectorFrontendClientImpl): 12 (WebKit::InspectorFrontendClientImpl::~InspectorFrontendClientImpl): 13 (WebKit::InspectorFrontendClientImpl::windowObjectCleared): 14 (WebKit::InspectorFrontendClientImpl::frontendLoaded): 15 (WebKit::InspectorFrontendClientImpl::moveWindowBy): 16 (WebKit::InspectorFrontendClientImpl::localizedStringsURL): 17 (WebKit::InspectorFrontendClientImpl::hiddenPanels): 18 (WebKit::InspectorFrontendClientImpl::bringToFront): 19 (WebKit::InspectorFrontendClientImpl::closeWindow): 20 (WebKit::InspectorFrontendClientImpl::canAttachWindow): 21 (WebKit::InspectorFrontendClientImpl::attachWindow): 22 (WebKit::InspectorFrontendClientImpl::detachWindow): 23 (WebKit::InspectorFrontendClientImpl::changeAttachedWindowHeight): 24 (WebKit::InspectorFrontendClientImpl::inspectedURLChanged): 25 * src/InspectorFrontendClientImpl.h: Added. 26 * src/WebDevToolsFrontendImpl.cpp: 27 (WebKit::WebDevToolsFrontendImpl::WebDevToolsFrontendImpl): 28 (WebKit::WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl): 29 (WebKit::WebDevToolsFrontendImpl::frontendLoaded): 30 * src/WebDevToolsFrontendImpl.h: 31 * src/js/DebuggerAgent.js: 32 (devtools.DebuggerAgent.prototype.doHandleBacktraceResponse_): 33 * src/js/DevTools.js: 34 (): 35 1 36 2010-04-01 Jay Civelli <jcivelli@google.com> 2 37 -
trunk/WebKit/chromium/WebKit.gyp
r56908 r56999 264 264 'src/InspectorClientImpl.cpp', 265 265 'src/InspectorClientImpl.h', 266 'src/InspectorFrontendClientImpl.cpp', 267 'src/InspectorFrontendClientImpl.h', 266 268 'src/linux/WebFontRendering.cpp', 267 269 'src/linux/WebFontRenderStyle.cpp', -
trunk/WebKit/chromium/src/InspectorFrontendClientImpl.h
r56998 r56999 29 29 */ 30 30 31 #ifndef InspectorFrontendClient Local_h32 #define InspectorFrontendClient Local_h31 #ifndef InspectorFrontendClientImpl_h 32 #define InspectorFrontendClientImpl_h 33 33 34 34 #include "InspectorFrontendClient.h" 35 #include "ScriptState.h"36 35 #include <wtf/Noncopyable.h> 37 36 38 37 namespace WebCore { 39 40 class FrontendMenuProvider;41 class InspectorController;42 38 class InspectorFrontendHost; 43 39 class Page; 40 } 44 41 45 class InspectorFrontendClientLocal : public InspectorFrontendClient, public Noncopyable { 42 namespace WebKit { 43 44 class WebDevToolsFrontendClient; 45 class WebDevToolsFrontendImpl; 46 47 class InspectorFrontendClientImpl : public WebCore::InspectorFrontendClient 48 , public Noncopyable { 46 49 public: 47 InspectorFrontendClientLocal(InspectorController*, Page*); 48 virtual ~InspectorFrontendClientLocal(); 49 50 InspectorFrontendClientImpl(WebCore::Page*, WebDevToolsFrontendClient*, WebDevToolsFrontendImpl*); 51 virtual ~InspectorFrontendClientImpl(); 52 53 // InspectorFrontendClient methods: 50 54 virtual void windowObjectCleared(); 51 55 virtual void frontendLoaded(); … … 53 57 virtual void moveWindowBy(float x, float y); 54 58 59 virtual WebCore::String localizedStringsURL(); 60 virtual WebCore::String hiddenPanels(); 61 62 virtual void bringToFront(); 63 virtual void closeWindow(); 64 55 65 virtual bool canAttachWindow(); 66 virtual void attachWindow(); 67 virtual void detachWindow(); 56 68 virtual void changeAttachedWindowHeight(unsigned); 57 58 virtual void showContextMenu(Event*, const Vector<ContextMenuItem*>&);59 69 60 protected: 61 virtual void setAttachedWindowHeight(unsigned) = 0; 62 63 void setAttachedWindow(bool); 64 void restoreAttachedWindowHeight(); 70 virtual void inspectedURLChanged(const WebCore::String&); 65 71 66 72 private: 67 static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight); 68 69 friend class FrontendMenuProvider; 70 InspectorController* m_inspectorController; 71 Page* m_frontendPage; 72 ScriptState* m_frontendScriptState; 73 // TODO(yurys): this ref shouldn't be needed. 74 RefPtr<InspectorFrontendHost> m_frontendHost; 75 FrontendMenuProvider* m_menuProvider; 73 WebCore::Page* m_frontendPage; 74 WebDevToolsFrontendClient* m_client; 75 WebDevToolsFrontendImpl* m_frontend; 76 RefPtr<WebCore::InspectorFrontendHost> m_frontendHost; 76 77 }; 77 78 78 } // namespace Web Core79 } // namespace WebKit 79 80 80 81 #endif -
trunk/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp
r56836 r56999 43 43 #include "InspectorBackend.h" 44 44 #include "InspectorController.h" 45 #include "InspectorFrontendClientImpl.h" 45 46 #include "InspectorFrontendHost.h" 46 47 #include "Node.h" … … 102 103 , m_loaded(false) 103 104 { 105 InspectorController* ic = m_webViewImpl->page()->inspectorController(); 106 ic->setInspectorFrontendClient(new InspectorFrontendClientImpl(m_webViewImpl->page(), m_client, this)); 107 104 108 WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); 105 109 v8::HandleScope scope; … … 119 123 WebDevToolsFrontendImpl::jsDebuggerPauseScript); 120 124 debuggerCommandExecutorObj.build(); 121 122 BoundObject devToolsHost(frameContext, this, "InspectorFrontendHost");123 devToolsHost.addProtoFunction(124 "loaded",125 WebDevToolsFrontendImpl::jsLoaded);126 devToolsHost.addProtoFunction(127 "platform",128 WebDevToolsFrontendImpl::jsPlatform);129 devToolsHost.addProtoFunction(130 "port",131 WebDevToolsFrontendImpl::jsPort);132 devToolsHost.addProtoFunction(133 "copyText",134 WebDevToolsFrontendImpl::jsCopyText);135 devToolsHost.addProtoFunction(136 "activateWindow",137 WebDevToolsFrontendImpl::jsActivateWindow);138 devToolsHost.addProtoFunction(139 "closeWindow",140 WebDevToolsFrontendImpl::jsCloseWindow);141 devToolsHost.addProtoFunction(142 "attach",143 WebDevToolsFrontendImpl::jsDockWindow);144 devToolsHost.addProtoFunction(145 "detach",146 WebDevToolsFrontendImpl::jsUndockWindow);147 devToolsHost.addProtoFunction(148 "localizedStringsURL",149 WebDevToolsFrontendImpl::jsLocalizedStringsURL);150 devToolsHost.addProtoFunction(151 "hiddenPanels",152 WebDevToolsFrontendImpl::jsHiddenPanels);153 devToolsHost.addProtoFunction(154 "setting",155 WebDevToolsFrontendImpl::jsSetting);156 devToolsHost.addProtoFunction(157 "setSetting",158 WebDevToolsFrontendImpl::jsSetSetting);159 devToolsHost.addProtoFunction(160 "bringToFront",161 WebDevToolsFrontendImpl::jsBringToFront);162 devToolsHost.addProtoFunction(163 "inspectedURLChanged",164 WebDevToolsFrontendImpl::jsInspectedURLChanged);165 devToolsHost.addProtoFunction(166 "showContextMenu",167 WebDevToolsFrontendImpl::jsShowContextMenu);168 devToolsHost.addProtoFunction(169 "canAttachWindow",170 WebDevToolsFrontendImpl::jsCanAttachWindow);171 devToolsHost.addProtoFunction(172 "setAttachedWindowHeight",173 WebDevToolsFrontendImpl::jsSetAttachedWindowHeight);174 devToolsHost.addProtoFunction(175 "moveWindowBy",176 WebDevToolsFrontendImpl::jsMoveWindowBy);177 devToolsHost.build();178 125 } 179 126 180 127 WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl() 181 128 { 182 if (m_menuProvider)183 m_menuProvider->disconnect();184 129 } 185 130 … … 196 141 } 197 142 executeScript(v); 143 } 144 145 void WebDevToolsFrontendImpl::frontendLoaded() 146 { 147 m_loaded = true; 148 149 // Grant the devtools page the ability to have source view iframes. 150 SecurityOrigin* origin = m_webViewImpl->page()->mainFrame()->domWindow()->securityOrigin(); 151 origin->grantUniversalAccess(); 152 153 for (Vector<Vector<String> >::iterator it = m_pendingIncomingMessages.begin(); 154 it != m_pendingIncomingMessages.end(); 155 ++it) { 156 executeScript(*it); 157 } 158 m_pendingIncomingMessages.clear(); 198 159 } 199 160 … … 213 174 } 214 175 215 void WebDevToolsFrontendImpl::dispatchOnWebInspector(const String& methodName, const String& param)216 {217 WebFrameImpl* frame = m_webViewImpl->mainFrameImpl();218 v8::HandleScope scope;219 v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame());220 v8::Context::Scope contextScope(frameContext);221 222 v8::Handle<v8::Value> webInspector = frameContext->Global()->Get(v8::String::New("WebInspector"));223 ASSERT(webInspector->IsObject());224 v8::Handle<v8::Object> webInspectorObj = v8::Handle<v8::Object>::Cast(webInspector);225 226 v8::Handle<v8::Value> method = webInspectorObj->Get(ToV8String(methodName));227 ASSERT(method->IsFunction());228 v8::Handle<v8::Function> methodFunc = v8::Handle<v8::Function>::Cast(method);229 v8::Handle<v8::Value> args[] = {230 ToV8String(param)231 };232 methodFunc->Call(frameContext->Global(), 1, args);233 }234 235 176 void WebDevToolsFrontendImpl::sendRpcMessage(const WebDevToolsMessageData& data) 236 177 { 237 178 m_client->sendMessageToAgent(data); 238 }239 240 void WebDevToolsFrontendImpl::contextMenuItemSelected(ContextMenuItem* item)241 {242 int itemNumber = item->action() - ContextMenuItemBaseCustomTag;243 dispatchOnWebInspector("contextMenuItemSelected", String::number(itemNumber));244 }245 246 void WebDevToolsFrontendImpl::contextMenuCleared()247 {248 dispatchOnWebInspector("contextMenuCleared", "");249 }250 251 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsLoaded(const v8::Arguments& args)252 {253 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value());254 frontend->m_loaded = true;255 256 // Grant the devtools page the ability to have source view iframes.257 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page();258 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin();259 origin->grantUniversalAccess();260 261 for (Vector<Vector<String> >::iterator it = frontend->m_pendingIncomingMessages.begin();262 it != frontend->m_pendingIncomingMessages.end();263 ++it) {264 frontend->executeScript(*it);265 }266 frontend->m_pendingIncomingMessages.clear();267 return v8::Undefined();268 }269 270 // static271 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsPlatform(const v8::Arguments& args)272 {273 #if defined(OS_MACOSX)274 return v8String("mac");275 #elif defined(OS_LINUX)276 return v8String("linux");277 #elif defined(OS_WIN)278 return v8String("windows");279 #else280 return v8String("unknown");281 #endif282 }283 284 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsPort(const v8::Arguments& args)285 {286 return v8::Undefined();287 }288 289 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsCopyText(const v8::Arguments& args)290 {291 String text = WebCore::toWebCoreStringWithNullCheck(args[0]);292 Pasteboard::generalPasteboard()->writePlainText(text);293 return v8::Undefined();294 }295 296 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsActivateWindow(const v8::Arguments& args)297 {298 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value());299 frontend->m_client->activateWindow();300 return v8::Undefined();301 }302 303 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsCloseWindow(const v8::Arguments& args)304 {305 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value());306 frontend->m_client->closeWindow();307 return v8::Undefined();308 }309 310 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsDockWindow(const v8::Arguments& args)311 {312 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value());313 frontend->m_client->dockWindow();314 return v8::Undefined();315 }316 317 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsUndockWindow(const v8::Arguments& args)318 {319 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value());320 frontend->m_client->undockWindow();321 return v8::Undefined();322 }323 324 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsLocalizedStringsURL(const v8::Arguments& args)325 {326 return v8::Undefined();327 }328 329 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsHiddenPanels(const v8::Arguments& args)330 {331 return v8String("");332 179 } 333 180 … … 340 187 } 341 188 342 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsSetting(const v8::Arguments& args)343 {344 return v8::Undefined();345 }346 347 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsSetSetting(const v8::Arguments& args)348 {349 return v8::Undefined();350 }351 352 189 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsDebuggerPauseScript(const v8::Arguments& args) 353 190 { … … 357 194 } 358 195 359 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsBringToFront(const v8::Arguments& args)360 {361 return v8::Undefined();362 }363 364 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsInspectedURLChanged(const v8::Arguments& args)365 {366 return v8::Undefined();367 }368 369 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsShowContextMenu(const v8::Arguments& args)370 {371 if (args.Length() < 2)372 return v8::Undefined();373 374 v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(args[0]);375 if (!V8MouseEvent::info.equals(V8DOMWrapper::domWrapperType(eventWrapper)))376 return v8::Undefined();377 378 Event* event = V8Event::toNative(eventWrapper);379 if (!args[1]->IsArray())380 return v8::Undefined();381 382 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);383 Vector<ContextMenuItem*> items;384 385 for (size_t i = 0; i < array->Length(); ++i) {386 v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(array->Get(v8::Integer::New(i)));387 v8::Local<v8::Value> label = item->Get(v8::String::New("label"));388 v8::Local<v8::Value> id = item->Get(v8::String::New("id"));389 if (label->IsUndefined() || id->IsUndefined()) {390 items.append(new ContextMenuItem(SeparatorType,391 ContextMenuItemTagNoAction,392 String()));393 } else {394 ContextMenuAction typedId = static_cast<ContextMenuAction>(395 ContextMenuItemBaseCustomTag + id->ToInt32()->Value());396 items.append(new ContextMenuItem(ActionType,397 typedId,398 toWebCoreStringWithNullCheck(label)));399 }400 }401 402 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value());403 404 frontend->m_menuProvider = MenuProvider::create(frontend, items);405 406 ContextMenuController* menuController = frontend->m_webViewImpl->page()->contextMenuController();407 menuController->showContextMenu(event, frontend->m_menuProvider);408 409 return v8::Undefined();410 }411 412 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsCanAttachWindow(const v8::Arguments& args)413 {414 return v8Boolean(true);415 }416 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsSetAttachedWindowHeight(const v8::Arguments& args)417 {418 return v8::Undefined();419 }420 421 v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsMoveWindowBy(const v8::Arguments& args)422 {423 return v8::Undefined();424 }425 426 196 } // namespace WebKit -
trunk/WebKit/chromium/src/WebDevToolsFrontendImpl.h
r56836 r56999 32 32 #define WebDevToolsFrontendImpl_h 33 33 34 #include "ContextMenu.h"35 #include "ContextMenuProvider.h"36 34 #include "DevToolsRPC.h" 37 35 #include "WebDevToolsFrontend.h" … … 75 73 virtual void dispatchMessageFromAgent(const WebKit::WebDevToolsMessageData& data); 76 74 75 void frontendLoaded(); 76 77 77 private: 78 class MenuProvider : public WebCore::ContextMenuProvider { 79 public: 80 static PassRefPtr<MenuProvider> create(WebDevToolsFrontendImpl* frontendHost, const Vector<WebCore::ContextMenuItem*>& items) 81 { 82 return adoptRef(new MenuProvider(frontendHost, items)); 83 } 78 void executeScript(const Vector<String>& v); 84 79 85 virtual ~MenuProvider()86 {87 contextMenuCleared();88 }89 90 void disconnect()91 {92 m_frontendHost = 0;93 }94 95 virtual void populateContextMenu(WebCore::ContextMenu* menu)96 {97 for (size_t i = 0; i < m_items.size(); ++i)98 menu->appendItem(*m_items[i]);99 }100 101 virtual void contextMenuItemSelected(WebCore::ContextMenuItem* item)102 {103 if (m_frontendHost)104 m_frontendHost->contextMenuItemSelected(item);105 }106 107 virtual void contextMenuCleared()108 {109 if (m_frontendHost)110 m_frontendHost->contextMenuCleared();111 deleteAllValues(m_items);112 m_items.clear();113 }114 115 private:116 MenuProvider(WebDevToolsFrontendImpl* frontendHost, const Vector<WebCore::ContextMenuItem*>& items)117 : m_frontendHost(frontendHost)118 , m_items(items) { }119 WebDevToolsFrontendImpl* m_frontendHost;120 Vector<WebCore::ContextMenuItem*> m_items;121 };122 123 void executeScript(const Vector<String>& v);124 void dispatchOnWebInspector(const String& method, const String& param);125 126 // friend class MenuSelectionHandler;127 void contextMenuItemSelected(WebCore::ContextMenuItem* menuItem);128 void contextMenuCleared();129 130 static v8::Handle<v8::Value> jsLoaded(const v8::Arguments& args);131 static v8::Handle<v8::Value> jsPlatform(const v8::Arguments& args);132 static v8::Handle<v8::Value> jsPort(const v8::Arguments& args);133 static v8::Handle<v8::Value> jsCopyText(const v8::Arguments& args);134 135 static v8::Handle<v8::Value> jsActivateWindow(const v8::Arguments& args);136 static v8::Handle<v8::Value> jsCloseWindow(const v8::Arguments& args);137 static v8::Handle<v8::Value> jsDockWindow(const v8::Arguments& args);138 static v8::Handle<v8::Value> jsUndockWindow(const v8::Arguments& args);139 static v8::Handle<v8::Value> jsLocalizedStringsURL(const v8::Arguments& args);140 static v8::Handle<v8::Value> jsHiddenPanels(const v8::Arguments& args);141 80 static v8::Handle<v8::Value> jsDebuggerCommand(const v8::Arguments& args); 142 static v8::Handle<v8::Value> jsSetting(const v8::Arguments& args);143 static v8::Handle<v8::Value> jsSetSetting(const v8::Arguments& args);144 81 static v8::Handle<v8::Value> jsDebuggerPauseScript(const v8::Arguments& args); 145 static v8::Handle<v8::Value> jsBringToFront(const v8::Arguments& args);146 static v8::Handle<v8::Value> jsInspectedURLChanged(const v8::Arguments& args);147 static v8::Handle<v8::Value> jsShowContextMenu(const v8::Arguments& args);148 static v8::Handle<v8::Value> jsCanAttachWindow(const v8::Arguments& args);149 static v8::Handle<v8::Value> jsSetAttachedWindowHeight(const v8::Arguments& args);150 static v8::Handle<v8::Value> jsMoveWindowBy(const v8::Arguments& args);151 82 152 83 WebKit::WebViewImpl* m_webViewImpl; … … 158 89 bool m_loaded; 159 90 Vector<Vector<String> > m_pendingIncomingMessages; 160 RefPtr<MenuProvider> m_menuProvider;161 91 }; 162 92 -
trunk/WebKit/chromium/src/js/DebuggerAgent.js
r56410 r56999 965 965 WebInspector.pausedScript(this.callFrames_); 966 966 this.showPendingExceptionMessage_(); 967 InspectorFrontendHost. activateWindow();967 InspectorFrontendHost.bringToFront(); 968 968 }; 969 969 -
trunk/WebKit/chromium/src/js/DevTools.js
r55629 r56999 280 280 { 281 281 if (this.panels.elements._nodeSearchButton.toggled) 282 InspectorFrontendHost. activateWindow();282 InspectorFrontendHost.bringToFront(); 283 283 original.apply(this, arguments); 284 284 }
Note: See TracChangeset
for help on using the changeset viewer.