| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 updateSubtreeBreakpoints(child, rootBit, false); | 402 updateSubtreeBreakpoints(child, rootBit, false); |
| 403 } | 403 } |
| 404 didRemoveBreakpoint(); | 404 didRemoveBreakpoint(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void InspectorDOMDebuggerAgent::getEventListeners(ErrorString* errorString, cons
t String& objectId, std::unique_ptr<protocol::Array<protocol::DOMDebugger::Event
Listener>>* listenersArray) | 407 void InspectorDOMDebuggerAgent::getEventListeners(ErrorString* errorString, cons
t String& objectId, std::unique_ptr<protocol::Array<protocol::DOMDebugger::Event
Listener>>* listenersArray) |
| 408 { | 408 { |
| 409 v8::HandleScope handles(m_isolate); | 409 v8::HandleScope handles(m_isolate); |
| 410 v8::Local<v8::Value> object; | 410 v8::Local<v8::Value> object; |
| 411 v8::Local<v8::Context> context; | 411 v8::Local<v8::Context> context; |
| 412 std::unique_ptr<v8_inspector::StringBuffer> error; |
| 412 std::unique_ptr<v8_inspector::StringBuffer> objectGroup; | 413 std::unique_ptr<v8_inspector::StringBuffer> objectGroup; |
| 413 if (!m_v8Session->unwrapObject(errorString, toV8InspectorStringView(objectId
), &object, &context, &objectGroup)) | 414 if (!m_v8Session->unwrapObject(&error, toV8InspectorStringView(objectId), &o
bject, &context, &objectGroup)) { |
| 415 *errorString = toCoreString(std::move(error)); |
| 414 return; | 416 return; |
| 417 } |
| 415 v8::Context::Scope scope(context); | 418 v8::Context::Scope scope(context); |
| 416 *listenersArray = protocol::Array<protocol::DOMDebugger::EventListener>::cre
ate(); | 419 *listenersArray = protocol::Array<protocol::DOMDebugger::EventListener>::cre
ate(); |
| 417 V8EventListenerInfoList eventInformation; | 420 V8EventListenerInfoList eventInformation; |
| 418 InspectorDOMDebuggerAgent::eventListenersInfoForTarget(context->GetIsolate()
, object, eventInformation); | 421 InspectorDOMDebuggerAgent::eventListenersInfoForTarget(context->GetIsolate()
, object, eventInformation); |
| 419 for (const auto& info : eventInformation) { | 422 for (const auto& info : eventInformation) { |
| 420 if (!info.useCapture) | 423 if (!info.useCapture) |
| 421 continue; | 424 continue; |
| 422 std::unique_ptr<protocol::DOMDebugger::EventListener> listenerObject = b
uildObjectForEventListener(context, info, objectGroup->string()); | 425 std::unique_ptr<protocol::DOMDebugger::EventListener> listenerObject = b
uildObjectForEventListener(context, info, objectGroup->string()); |
| 423 if (listenerObject) | 426 if (listenerObject) |
| 424 (*listenersArray)->addItem(std::move(listenerObject)); | 427 (*listenersArray)->addItem(std::move(listenerObject)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 518 |
| 516 if (breakpointType == SubtreeModified) | 519 if (breakpointType == SubtreeModified) |
| 517 description->setBoolean("insertion", insertion); | 520 description->setBoolean("insertion", insertion); |
| 518 } | 521 } |
| 519 | 522 |
| 520 int breakpointOwnerNodeId = m_domAgent->boundNodeId(breakpointOwner); | 523 int breakpointOwnerNodeId = m_domAgent->boundNodeId(breakpointOwner); |
| 521 ASSERT(breakpointOwnerNodeId); | 524 ASSERT(breakpointOwnerNodeId); |
| 522 description->setInteger("nodeId", breakpointOwnerNodeId); | 525 description->setInteger("nodeId", breakpointOwnerNodeId); |
| 523 description->setString("type", domTypeName(breakpointType)); | 526 description->setString("type", domTypeName(breakpointType)); |
| 524 String json = description->toJSONString(); | 527 String json = description->toJSONString(); |
| 525 m_v8Session->breakProgram(toV8InspectorStringView(protocol::Debugger::API::P
aused::ReasonEnum::DOM), toV8InspectorStringView(json)); | 528 m_v8Session->breakProgram(toV8InspectorStringView(v8_inspector::protocol::De
bugger::API::Paused::ReasonEnum::DOM), toV8InspectorStringView(json)); |
| 526 } | 529 } |
| 527 | 530 |
| 528 bool InspectorDOMDebuggerAgent::hasBreakpoint(Node* node, int type) | 531 bool InspectorDOMDebuggerAgent::hasBreakpoint(Node* node, int type) |
| 529 { | 532 { |
| 530 if (!m_domAgent->enabled()) | 533 if (!m_domAgent->enabled()) |
| 531 return false; | 534 return false; |
| 532 uint32_t rootBit = 1 << type; | 535 uint32_t rootBit = 1 << type; |
| 533 uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift; | 536 uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift; |
| 534 return m_domBreakpoints.get(node) & (rootBit | derivedBit); | 537 return m_domBreakpoints.get(node) & (rootBit | derivedBit); |
| 535 } | 538 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 551 for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child =
InspectorDOMAgent::innerNextSibling(child)) | 554 for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child =
InspectorDOMAgent::innerNextSibling(child)) |
| 552 updateSubtreeBreakpoints(child, newRootMask, set); | 555 updateSubtreeBreakpoints(child, newRootMask, set); |
| 553 } | 556 } |
| 554 | 557 |
| 555 void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(std::unique_ptr<proto
col::DictionaryValue> eventData, bool synchronous) | 558 void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(std::unique_ptr<proto
col::DictionaryValue> eventData, bool synchronous) |
| 556 { | 559 { |
| 557 if (!eventData) | 560 if (!eventData) |
| 558 return; | 561 return; |
| 559 String json = eventData->toJSONString(); | 562 String json = eventData->toJSONString(); |
| 560 if (synchronous) | 563 if (synchronous) |
| 561 m_v8Session->breakProgram(toV8InspectorStringView(protocol::Debugger::AP
I::Paused::ReasonEnum::EventListener), toV8InspectorStringView(json)); | 564 m_v8Session->breakProgram(toV8InspectorStringView(v8_inspector::protocol
::Debugger::API::Paused::ReasonEnum::EventListener), toV8InspectorStringView(jso
n)); |
| 562 else | 565 else |
| 563 m_v8Session->schedulePauseOnNextStatement(toV8InspectorStringView(protoc
ol::Debugger::API::Paused::ReasonEnum::EventListener), toV8InspectorStringView(j
son)); | 566 m_v8Session->schedulePauseOnNextStatement(toV8InspectorStringView(v8_ins
pector::protocol::Debugger::API::Paused::ReasonEnum::EventListener), toV8Inspect
orStringView(json)); |
| 564 } | 567 } |
| 565 | 568 |
| 566 std::unique_ptr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePau
seOnNativeEventData(const String& eventName, const String* targetName) | 569 std::unique_ptr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePau
seOnNativeEventData(const String& eventName, const String* targetName) |
| 567 { | 570 { |
| 568 String fullEventName = (targetName ? listenerEventCategoryType : instrumenta
tionEventCategoryType) + eventName; | 571 String fullEventName = (targetName ? listenerEventCategoryType : instrumenta
tionEventCategoryType) + eventName; |
| 569 protocol::DictionaryValue* breakpoints = eventListenerBreakpoints(); | 572 protocol::DictionaryValue* breakpoints = eventListenerBreakpoints(); |
| 570 protocol::Value* value = breakpoints->get(fullEventName); | 573 protocol::Value* value = breakpoints->get(fullEventName); |
| 571 if (!value) | 574 if (!value) |
| 572 return nullptr; | 575 return nullptr; |
| 573 bool match = false; | 576 bool match = false; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 645 |
| 643 void InspectorDOMDebuggerAgent::willSendXMLHttpOrFetchNetworkRequest(const Strin
g& url) | 646 void InspectorDOMDebuggerAgent::willSendXMLHttpOrFetchNetworkRequest(const Strin
g& url) |
| 644 { | 647 { |
| 645 String breakpointURL; | 648 String breakpointURL; |
| 646 if (m_state->booleanProperty(DOMDebuggerAgentState::pauseOnAllXHRs, false)) | 649 if (m_state->booleanProperty(DOMDebuggerAgentState::pauseOnAllXHRs, false)) |
| 647 breakpointURL = ""; | 650 breakpointURL = ""; |
| 648 else { | 651 else { |
| 649 protocol::DictionaryValue* breakpoints = xhrBreakpoints(); | 652 protocol::DictionaryValue* breakpoints = xhrBreakpoints(); |
| 650 for (size_t i = 0; i < breakpoints->size(); ++i) { | 653 for (size_t i = 0; i < breakpoints->size(); ++i) { |
| 651 auto breakpoint = breakpoints->at(i); | 654 auto breakpoint = breakpoints->at(i); |
| 652 // TODO(dgozman): remove extra String cast after migrating away from
String16. | 655 if (url.contains(breakpoint.first)) { |
| 653 if (url.contains(String(breakpoint.first))) { | |
| 654 breakpointURL = breakpoint.first; | 656 breakpointURL = breakpoint.first; |
| 655 break; | 657 break; |
| 656 } | 658 } |
| 657 } | 659 } |
| 658 } | 660 } |
| 659 | 661 |
| 660 if (breakpointURL.isNull()) | 662 if (breakpointURL.isNull()) |
| 661 return; | 663 return; |
| 662 | 664 |
| 663 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryV
alue::create(); | 665 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryV
alue::create(); |
| 664 eventData->setString("breakpointURL", breakpointURL); | 666 eventData->setString("breakpointURL", breakpointURL); |
| 665 eventData->setString("url", url); | 667 eventData->setString("url", url); |
| 666 String json = eventData->toJSONString(); | 668 String json = eventData->toJSONString(); |
| 667 m_v8Session->breakProgram(toV8InspectorStringView(protocol::Debugger::API::P
aused::ReasonEnum::XHR), toV8InspectorStringView(json)); | 669 m_v8Session->breakProgram(toV8InspectorStringView(v8_inspector::protocol::De
bugger::API::Paused::ReasonEnum::XHR), toV8InspectorStringView(json)); |
| 668 } | 670 } |
| 669 | 671 |
| 670 void InspectorDOMDebuggerAgent::didAddBreakpoint() | 672 void InspectorDOMDebuggerAgent::didAddBreakpoint() |
| 671 { | 673 { |
| 672 if (m_state->booleanProperty(DOMDebuggerAgentState::enabled, false)) | 674 if (m_state->booleanProperty(DOMDebuggerAgentState::enabled, false)) |
| 673 return; | 675 return; |
| 674 setEnabled(true); | 676 setEnabled(true); |
| 675 } | 677 } |
| 676 | 678 |
| 677 void InspectorDOMDebuggerAgent::didRemoveBreakpoint() | 679 void InspectorDOMDebuggerAgent::didRemoveBreakpoint() |
| (...skipping 19 matching lines...) Expand all Loading... |
| 697 m_instrumentingAgents->removeInspectorDOMDebuggerAgent(this); | 699 m_instrumentingAgents->removeInspectorDOMDebuggerAgent(this); |
| 698 } | 700 } |
| 699 } | 701 } |
| 700 | 702 |
| 701 void InspectorDOMDebuggerAgent::didCommitLoadForLocalFrame(LocalFrame*) | 703 void InspectorDOMDebuggerAgent::didCommitLoadForLocalFrame(LocalFrame*) |
| 702 { | 704 { |
| 703 m_domBreakpoints.clear(); | 705 m_domBreakpoints.clear(); |
| 704 } | 706 } |
| 705 | 707 |
| 706 } // namespace blink | 708 } // namespace blink |
| OLD | NEW |