| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "web/agent/sample/sample_agent.h" |
| 6 |
| 7 #include "web/api/document.h" |
| 8 #include "web/api/element.h" |
| 9 |
| 10 namespace web { |
| 11 |
| 12 SampleAgent::SampleAgent(Frame* frame) : Agent(frame) { |
| 13 Element* element = frame->GetFunkyElement(); |
| 14 if (!element) |
| 15 return; |
| 16 element->AddEventListener( |
| 17 "load", WTF::bind(&SampleAgent::Load, wrapPersistent(this))); |
| 18 element->SetId("FUNKY!"); |
| 19 element->Before("YESS", "AWESOME!"); |
| 20 Document* document = frame->GetDocument(); |
| 21 if (!document) |
| 22 return; |
| 23 document->Write("THIS", "IS", "VARIADIC"); |
| 24 |
| 25 // Example of what you can do with the Variant. |
| 26 auto current_script = document->GetCurrentScript(); |
| 27 if (!current_script) |
| 28 return; |
| 29 |
| 30 if (WTF::holds_alternative<blink::Member<SVGScriptElement>>( |
| 31 current_script.value())) |
| 32 return; |
| 33 |
| 34 HTMLScriptElement* script = |
| 35 WTF::get<blink::Member<HTMLScriptElement>>(current_script.value()); |
| 36 script->DoDummyThing(); |
| 37 } |
| 38 |
| 39 void SampleAgent::Load(Event*) {} |
| 40 |
| 41 } // namespace web |
| OLD | NEW |