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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorDOMDebuggerAgent.cpp

Issue 2159633002: [DevTools] Generate public versions of protocol classes to be exposed in v8_inspector/public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra files Created 4 years, 5 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
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 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 else 303 else
304 breakpointsByTarget->remove(targetName.lower()); 304 breakpointsByTarget->remove(targetName.lower());
305 didRemoveBreakpoint(); 305 didRemoveBreakpoint();
306 } 306 }
307 307
308 void InspectorDOMDebuggerAgent::didInvalidateStyleAttr(Node* node) 308 void InspectorDOMDebuggerAgent::didInvalidateStyleAttr(Node* node)
309 { 309 {
310 if (hasBreakpoint(node, AttributeModified)) { 310 if (hasBreakpoint(node, AttributeModified)) {
311 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create(); 311 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create();
312 descriptionForDOMEvent(node, AttributeModified, false, eventData.get()); 312 descriptionForDOMEvent(node, AttributeModified, false, eventData.get());
313 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, s td::move(eventData)); 313 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::D OM, std::move(eventData));
314 } 314 }
315 } 315 }
316 316
317 void InspectorDOMDebuggerAgent::didInsertDOMNode(Node* node) 317 void InspectorDOMDebuggerAgent::didInsertDOMNode(Node* node)
318 { 318 {
319 if (m_domBreakpoints.size()) { 319 if (m_domBreakpoints.size()) {
320 uint32_t mask = m_domBreakpoints.get(InspectorDOMAgent::innerParentNode( node)); 320 uint32_t mask = m_domBreakpoints.get(InspectorDOMAgent::innerParentNode( node));
321 uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTyp eShift)) & inheritableDOMBreakpointTypesMask; 321 uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTyp eShift)) & inheritableDOMBreakpointTypesMask;
322 if (inheritableTypesMask) 322 if (inheritableTypesMask)
323 updateSubtreeBreakpoints(node, inheritableTypesMask, true); 323 updateSubtreeBreakpoints(node, inheritableTypesMask, true);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 v8::Isolate* isolate = context->GetIsolate(); 449 v8::Isolate* isolate = context->GetIsolate();
450 v8::Local<v8::Function> function = eventListenerEffectiveFunction(isolate, i nfo.handler); 450 v8::Local<v8::Function> function = eventListenerEffectiveFunction(isolate, i nfo.handler);
451 if (function.IsEmpty()) 451 if (function.IsEmpty())
452 return nullptr; 452 return nullptr;
453 453
454 String scriptId; 454 String scriptId;
455 int lineNumber; 455 int lineNumber;
456 int columnNumber; 456 int columnNumber;
457 getFunctionLocation(function, scriptId, lineNumber, columnNumber); 457 getFunctionLocation(function, scriptId, lineNumber, columnNumber);
458 458
459 std::unique_ptr<protocol::Debugger::Location> location = protocol::Debugger: :Location::create()
460 .setScriptId(scriptId)
461 .setLineNumber(lineNumber).build();
462 location->setColumnNumber(columnNumber);
463 std::unique_ptr<protocol::DOMDebugger::EventListener> value = protocol::DOMD ebugger::EventListener::create() 459 std::unique_ptr<protocol::DOMDebugger::EventListener> value = protocol::DOMD ebugger::EventListener::create()
464 .setType(info.eventType) 460 .setType(info.eventType)
465 .setUseCapture(info.useCapture) 461 .setUseCapture(info.useCapture)
466 .setPassive(info.passive) 462 .setPassive(info.passive)
467 .setLocation(std::move(location)).build(); 463 .setScriptId(scriptId)
464 .setLineNumber(lineNumber)
465 .setColumnNumber(columnNumber).build();
468 if (!objectGroupId.isEmpty()) { 466 if (!objectGroupId.isEmpty()) {
469 value->setHandler(m_v8Session->wrapObject(context, function, objectGroup Id, false)); 467 value->setHandler(m_v8Session->wrapObject(context, function, objectGroup Id));
470 value->setOriginalHandler(m_v8Session->wrapObject(context, info.handler, objectGroupId, false)); 468 value->setOriginalHandler(m_v8Session->wrapObject(context, info.handler, objectGroupId));
471 v8::Local<v8::Function> removeFunction; 469 v8::Local<v8::Function> removeFunction;
472 if (info.removeFunction.ToLocal(&removeFunction)) 470 if (info.removeFunction.ToLocal(&removeFunction))
473 value->setRemoveFunction(m_v8Session->wrapObject(context, removeFunc tion, objectGroupId, false)); 471 value->setRemoveFunction(m_v8Session->wrapObject(context, removeFunc tion, objectGroupId));
474 } 472 }
475 return value; 473 return value;
476 } 474 }
477 475
478 void InspectorDOMDebuggerAgent::allowNativeBreakpoint(const String& breakpointNa me, const String* targetName, bool sync) 476 void InspectorDOMDebuggerAgent::allowNativeBreakpoint(const String& breakpointNa me, const String* targetName, bool sync)
479 { 477 {
480 pauseOnNativeEventIfNeeded(preparePauseOnNativeEventData(breakpointName, tar getName), sync); 478 pauseOnNativeEventIfNeeded(preparePauseOnNativeEventData(breakpointName, tar getName), sync);
481 } 479 }
482 480
483 void InspectorDOMDebuggerAgent::willInsertDOMNode(Node* parent) 481 void InspectorDOMDebuggerAgent::willInsertDOMNode(Node* parent)
484 { 482 {
485 if (hasBreakpoint(parent, SubtreeModified)) { 483 if (hasBreakpoint(parent, SubtreeModified)) {
486 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create(); 484 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create();
487 descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get()); 485 descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get());
488 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, s td::move(eventData)); 486 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::D OM, std::move(eventData));
489 } 487 }
490 } 488 }
491 489
492 void InspectorDOMDebuggerAgent::willRemoveDOMNode(Node* node) 490 void InspectorDOMDebuggerAgent::willRemoveDOMNode(Node* node)
493 { 491 {
494 Node* parentNode = InspectorDOMAgent::innerParentNode(node); 492 Node* parentNode = InspectorDOMAgent::innerParentNode(node);
495 if (hasBreakpoint(node, NodeRemoved)) { 493 if (hasBreakpoint(node, NodeRemoved)) {
496 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create(); 494 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create();
497 descriptionForDOMEvent(node, NodeRemoved, false, eventData.get()); 495 descriptionForDOMEvent(node, NodeRemoved, false, eventData.get());
498 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, s td::move(eventData)); 496 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::D OM, std::move(eventData));
499 } else if (parentNode && hasBreakpoint(parentNode, SubtreeModified)) { 497 } else if (parentNode && hasBreakpoint(parentNode, SubtreeModified)) {
500 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create(); 498 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create();
501 descriptionForDOMEvent(node, SubtreeModified, false, eventData.get()); 499 descriptionForDOMEvent(node, SubtreeModified, false, eventData.get());
502 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, s td::move(eventData)); 500 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::D OM, std::move(eventData));
503 } 501 }
504 didRemoveDOMNode(node); 502 didRemoveDOMNode(node);
505 } 503 }
506 504
507 void InspectorDOMDebuggerAgent::willModifyDOMAttr(Element* element, const Atomic String&, const AtomicString&) 505 void InspectorDOMDebuggerAgent::willModifyDOMAttr(Element* element, const Atomic String&, const AtomicString&)
508 { 506 {
509 if (hasBreakpoint(element, AttributeModified)) { 507 if (hasBreakpoint(element, AttributeModified)) {
510 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create(); 508 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::Diction aryValue::create();
511 descriptionForDOMEvent(element, AttributeModified, false, eventData.get( )); 509 descriptionForDOMEvent(element, AttributeModified, false, eventData.get( ));
512 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::DOM, s td::move(eventData)); 510 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::D OM, std::move(eventData));
513 } 511 }
514 } 512 }
515 513
516 void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpo intType, bool insertion, protocol::DictionaryValue* description) 514 void InspectorDOMDebuggerAgent::descriptionForDOMEvent(Node* target, int breakpo intType, bool insertion, protocol::DictionaryValue* description)
517 { 515 {
518 ASSERT(hasBreakpoint(target, breakpointType)); 516 ASSERT(hasBreakpoint(target, breakpointType));
519 517
520 Node* breakpointOwner = target; 518 Node* breakpointOwner = target;
521 if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) { 519 if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) {
522 // For inheritable breakpoint types, target node isn't always the same a s the node that owns a breakpoint. 520 // For inheritable breakpoint types, target node isn't always the same a s the node that owns a breakpoint.
523 // Target node may be unknown to frontend, so we need to push it first. 521 // Target node may be unknown to frontend, so we need to push it first.
524 std::unique_ptr<protocol::Runtime::RemoteObject> targetNodeObject = m_do mAgent->resolveNode(target, V8InspectorSession::backtraceObjectGroup); 522 std::unique_ptr<protocol::Runtime::API::RemoteObject> targetNodeObject = m_domAgent->resolveNode(target, V8InspectorSession::backtraceObjectGroup);
525 description->setValue("targetNode", targetNodeObject->serialize()); 523 description->setValue("targetNode", protocol::SerializedValue::create(ta rgetNodeObject->toJSONString()));
526 524
527 // Find breakpoint owner node. 525 // Find breakpoint owner node.
528 if (!insertion) 526 if (!insertion)
529 breakpointOwner = InspectorDOMAgent::innerParentNode(target); 527 breakpointOwner = InspectorDOMAgent::innerParentNode(target);
530 ASSERT(breakpointOwner); 528 ASSERT(breakpointOwner);
531 while (!(m_domBreakpoints.get(breakpointOwner) & (1 << breakpointType))) { 529 while (!(m_domBreakpoints.get(breakpointOwner) & (1 << breakpointType))) {
532 Node* parentNode = InspectorDOMAgent::innerParentNode(breakpointOwne r); 530 Node* parentNode = InspectorDOMAgent::innerParentNode(breakpointOwne r);
533 if (!parentNode) 531 if (!parentNode)
534 break; 532 break;
535 breakpointOwner = parentNode; 533 breakpointOwner = parentNode;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 568
571 for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child)) 569 for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child))
572 updateSubtreeBreakpoints(child, newRootMask, set); 570 updateSubtreeBreakpoints(child, newRootMask, set);
573 } 571 }
574 572
575 void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(std::unique_ptr<proto col::DictionaryValue> eventData, bool synchronous) 573 void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(std::unique_ptr<proto col::DictionaryValue> eventData, bool synchronous)
576 { 574 {
577 if (!eventData) 575 if (!eventData)
578 return; 576 return;
579 if (synchronous) 577 if (synchronous)
580 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::EventL istener, std::move(eventData)); 578 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::E ventListener, std::move(eventData));
581 else 579 else
582 m_v8Session->schedulePauseOnNextStatement(protocol::Debugger::Paused::Re asonEnum::EventListener, std::move(eventData)); 580 m_v8Session->schedulePauseOnNextStatement(protocol::Debugger::API::Pause d::ReasonEnum::EventListener, std::move(eventData));
583 } 581 }
584 582
585 std::unique_ptr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePau seOnNativeEventData(const String& eventName, const String* targetName) 583 std::unique_ptr<protocol::DictionaryValue> InspectorDOMDebuggerAgent::preparePau seOnNativeEventData(const String& eventName, const String* targetName)
586 { 584 {
587 String fullEventName = (targetName ? listenerEventCategoryType : instrumenta tionEventCategoryType) + eventName; 585 String fullEventName = (targetName ? listenerEventCategoryType : instrumenta tionEventCategoryType) + eventName;
588 protocol::DictionaryValue* breakpoints = eventListenerBreakpoints(); 586 protocol::DictionaryValue* breakpoints = eventListenerBreakpoints();
589 protocol::Value* value = breakpoints->get(fullEventName); 587 protocol::Value* value = breakpoints->get(fullEventName);
590 if (!value) 588 if (!value)
591 return nullptr; 589 return nullptr;
592 bool match = false; 590 bool match = false;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 672 }
675 } 673 }
676 } 674 }
677 675
678 if (breakpointURL.isNull()) 676 if (breakpointURL.isNull())
679 return; 677 return;
680 678
681 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryV alue::create(); 679 std::unique_ptr<protocol::DictionaryValue> eventData = protocol::DictionaryV alue::create();
682 eventData->setString("breakpointURL", breakpointURL); 680 eventData->setString("breakpointURL", breakpointURL);
683 eventData->setString("url", url); 681 eventData->setString("url", url);
684 m_v8Session->breakProgram(protocol::Debugger::Paused::ReasonEnum::XHR, std:: move(eventData)); 682 m_v8Session->breakProgram(protocol::Debugger::API::Paused::ReasonEnum::XHR, std::move(eventData));
685 } 683 }
686 684
687 void InspectorDOMDebuggerAgent::didAddBreakpoint() 685 void InspectorDOMDebuggerAgent::didAddBreakpoint()
688 { 686 {
689 if (m_state->booleanProperty(DOMDebuggerAgentState::enabled, false)) 687 if (m_state->booleanProperty(DOMDebuggerAgentState::enabled, false))
690 return; 688 return;
691 setEnabled(true); 689 setEnabled(true);
692 } 690 }
693 691
694 void InspectorDOMDebuggerAgent::didRemoveBreakpoint() 692 void InspectorDOMDebuggerAgent::didRemoveBreakpoint()
(...skipping 19 matching lines...) Expand all
714 m_instrumentingAgents->removeInspectorDOMDebuggerAgent(this); 712 m_instrumentingAgents->removeInspectorDOMDebuggerAgent(this);
715 } 713 }
716 } 714 }
717 715
718 void InspectorDOMDebuggerAgent::didCommitLoadForLocalFrame(LocalFrame*) 716 void InspectorDOMDebuggerAgent::didCommitLoadForLocalFrame(LocalFrame*)
719 { 717 {
720 m_domBreakpoints.clear(); 718 m_domBreakpoints.clear();
721 } 719 }
722 720
723 } // namespace blink 721 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698