| 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->SetId("FUNKY!"); |
| 17 element->Before("YESS", "AWESOME!"); |
| 18 Document* document = frame->GetDocument(); |
| 19 if (!document) |
| 20 return; |
| 21 document->Write("THIS", "IS", "VARIADIC"); |
| 22 |
| 23 // Example of what you can do with the Variant. |
| 24 auto current_script = document->GetCurrentScript(); |
| 25 if (!current_script) |
| 26 return; |
| 27 |
| 28 if (WTF::holds_alternative<blink::Member<SVGScriptElement>>( |
| 29 current_script.value())) |
| 30 return; |
| 31 |
| 32 HTMLScriptElement* script = |
| 33 WTF::get<blink::Member<HTMLScriptElement>>(current_script.value()); |
| 34 script->DoDummyThing(); |
| 35 } |
| 36 |
| 37 } // namespace web |
| OLD | NEW |