Chromium html<script>对应c++接口定义

server/2024/10/17 17:29:57/
htmledit_views">

<script>:脚本元素


 <script> 元素用于嵌入可执行代码或数据,这通常用作嵌入或者引用 JavaScript 代码。<script> 元素也能在其他语言中使用,比如 WebGL 的 GLSL 着色器语言和 JSON。

更多参考:<script>:脚本元素 - HTML(超文本标记语言) | MDN (mozilla.org)

1、<script> 在html_tag_names.json5中接口定义:

   (third_party\blink\renderer\core\html\html_tag_names.json5)

    {name: "script",constructorNeedsCreateElementFlags: true,},

2、<script> html_script_element.idl接口定义:

// https://html.spec.whatwg.org/C/#the-script-element
[Exposed=Window,HTMLConstructor
] interface HTMLScriptElement : HTMLElement {[CEReactions, Reflect, URL, RaisesException=Setter] attribute ScriptURLString src;[CEReactions, Reflect] attribute DOMString type;[CEReactions, Reflect] attribute boolean noModule;[CEReactions, Reflect] attribute DOMString charset;[CEReactions] attribute boolean async;[CEReactions, Reflect] attribute boolean defer;[CEReactions, Reflect, ReflectOnly=("anonymous","use-credentials"), ReflectEmpty="anonymous", ReflectInvalid="anonymous"] attribute DOMString? crossOrigin;[CEReactions] attribute ScriptString text;[CEReactions, Reflect, ReflectOnly=("", "no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url"), ReflectMissing="", ReflectInvalid=""] attribute DOMString? referrerPolicy;[CEReactions, MeasureAs=PriorityHints, Reflect, ReflectOnly=("low", "auto", "high"), ReflectMissing="auto", ReflectInvalid="auto"] attribute DOMString fetchPriority;// obsolete members// https://html.spec.whatwg.org/C/#HTMLScriptElement-partial// TODO(foolip): The event and htmlFor attributes should return the empty// string on getting, and do nothing on setting.[CEReactions, Reflect] attribute DOMString event;[CEReactions, Reflect=for] attribute DOMString htmlFor;// Subresource Integrity// https://w3c.github.io/webappsec-subresource-integrity/#HTMLScriptElement[Reflect] attribute DOMString integrity;// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-supports[Measure] static boolean supports(DOMString type);// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-blocking[SameObject, PutForwards=value] readonly attribute DOMTokenList blocking;
};// https://wicg.github.io/attribution-reporting-api
HTMLScriptElement includes HTMLAttributionSrcElementUtils;

3、html_script_element.idl接口实现blink:

third_party\blink\renderer\core\html\html_script_element.h

third_party\blink\renderer\core\html\html_script_element.cc


#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_HTML_HTML_SCRIPT_ELEMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_HTML_SCRIPT_ELEMENT_H_#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/create_element_flags.h"
#include "third_party/blink/renderer/core/html/blocking_attribute.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/script/script_element_base.h"
#include "third_party/blink/renderer/core/script/script_loader.h"
#include "third_party/blink/renderer/platform/bindings/parkable_string.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"namespace blink {class ExceptionState;class CORE_EXPORT HTMLScriptElement final : public HTMLElement,public ScriptElementBase {DEFINE_WRAPPERTYPEINFO();public:static bool supports(const AtomicString&);HTMLScriptElement(Document&, const CreateElementFlags);// Returns attributes that should be checked against Trusted Typesconst AttrNameToTrustedType& GetCheckedAttributeTypes() const override;String text() { return TextFromChildren(); }void setText(const String&);void setInnerTextForBinding(const V8UnionStringLegacyNullToEmptyStringOrTrustedScript*string_or_trusted_script,ExceptionState& exception_state) override;void setTextContentForBinding(const V8UnionStringOrTrustedScript* value,ExceptionState& exception_state) override;void setTextContent(const String&) override;void setAsync(bool);bool async() const;BlockingAttribute& blocking() const { return *blocking_attribute_; }ScriptLoader* Loader() const final { return loader_.Get(); }bool IsScriptElement() const override { return true; }Document& GetDocument() const override;ExecutionContext* GetExecutionContext() const override;V8HTMLOrSVGScriptElement* AsV8HTMLOrSVGScriptElement() override;DOMNodeId GetDOMNodeId() override;void Trace(Visitor*) const override;void FinishParsingChildren() override;bool IsPotentiallyRenderBlocking() const override;private:void ParseAttribute(const AttributeModificationParams&) override;InsertionNotificationRequest InsertedInto(ContainerNode&) override;void RemovedFrom(ContainerNode& insertion_point) override;void DidNotifySubtreeInsertionsToDocument() override;void ChildrenChanged(const ChildrenChange&) override;bool IsURLAttribute(const Attribute&) const override;bool HasLegalLinkAttribute(const QualifiedName&) const override;// ScriptElementBase overrides:String SourceAttributeValue() const override;String CharsetAttributeValue() const override;String TypeAttributeValue() const override;String LanguageAttributeValue() const override;bool NomoduleAttributeValue() const override;String ForAttributeValue() const override;String EventAttributeValue() const override;String CrossOriginAttributeValue() const override;String IntegrityAttributeValue() const override;String ReferrerPolicyAttributeValue() const override;String FetchPriorityAttributeValue() const override;String ChildTextContent() override;String ScriptTextInternalSlot() const override;bool AsyncAttributeValue() const override;bool DeferAttributeValue() const override;bool HasSourceAttribute() const override;bool HasAttributionsrcAttribute() const override;bool IsConnected() const override;bool HasChildren() const override;const AtomicString& GetNonceForElement() const override;bool ElementHasDuplicateAttributes() const override {return HasDuplicateAttribute();}bool AllowInlineScriptForCSP(const AtomicString& nonce,const WTF::OrdinalNumber&,const String& script_content) override;void DispatchLoadEvent() override;void DispatchErrorEvent() override;Type GetScriptElementType() override;Element& CloneWithoutAttributesAndChildren(Document&) const override;// https://w3c.github.io/trusted-types/dist/spec/#script-scripttextParkableString script_text_internal_slot_;bool children_changed_by_api_;Member<BlockingAttribute> blocking_attribute_;Member<ScriptLoader> loader_;
};}  // namespace blink#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_HTML_SCRIPT_ELEMENT_H_

4、html_script_element.idl接口实现v8:

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.// DO NOT EDIT: This file is auto-generated by
// //third_party/blink/renderer/bindings/scripts/generate_bindings.py
//
// Use the GN flag `blink_enable_generated_code_formatting=true` to enable
// formatting of the generated files.#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_HTML_SCRIPT_ELEMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_HTML_SCRIPT_ELEMENT_H_#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/v8_interface_bridge.h"namespace blink {class ExecutionContext;
class HTMLScriptElement;
struct WrapperTypeInfo;class CORE_EXPORT V8HTMLScriptElement final : public bindings::V8InterfaceBridge<V8HTMLScriptElement, HTMLScriptElement> {public:
static bool IsExposed(ExecutionContext* execution_context);static constexpr const WrapperTypeInfo* GetWrapperTypeInfo() {return &wrapper_type_info_;
}static void InstallInterfaceTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Template> interface_template);
static void InstallUnconditionalProperties(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Template> instance_template, v8::Local<v8::Template> prototype_template, v8::Local<v8::Template> interface_template);
static void InstallContextDependentProperties(v8::Local<v8::Context> context, const DOMWrapperWorld& world, v8::Local<v8::Object> instance_object, v8::Local<v8::Object> prototype_object, v8::Local<v8::Object> interface_object, v8::Local<v8::Template> interface_template, FeatureSelector feature_selector);private:
static const WrapperTypeInfo wrapper_type_info_;friend class HTMLScriptElement;
};}  // namespace blink#endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_HTML_SCRIPT_ELEMENT_H_

out\Debug\gen\third_party\blink\renderer\bindings\core\v8\v8_html_script_element.h

out\Debug\gen\third_party\blink\renderer\bindings\core\v8\v8_html_script_element.cc

截取部分实现:

void V8HTMLScriptElement::InstallUnconditionalProperties(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Template> instance_template, v8::Local<v8::Template> prototype_template, v8::Local<v8::Template> interface_template) {using bindings::IDLMemberInstaller;v8::Local<v8::FunctionTemplate> interface_function_template = interface_template.As<v8::FunctionTemplate>();
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_function_template);
{static const IDLMemberInstaller::AttributeConfig kAttributeTable[] = {
{"src", SrcAttributeGetCallback, SrcAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"type", TypeAttributeGetCallback, TypeAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"noModule", NoModuleAttributeGetCallback, NoModuleAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"charset", CharsetAttributeGetCallback, CharsetAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"async", AsyncAttributeGetCallback, AsyncAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"defer", DeferAttributeGetCallback, DeferAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"crossOrigin", CrossOriginAttributeGetCallback, CrossOriginAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"text", TextAttributeGetCallback, TextAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"referrerPolicy", ReferrerPolicyAttributeGetCallback, ReferrerPolicyAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"fetchPriority", FetchPriorityAttributeGetCallback, FetchPriorityAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"event", EventAttributeGetCallback, EventAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"htmlFor", HTMLForAttributeGetCallback, HTMLForAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"integrity", IntegrityAttributeGetCallback, IntegrityAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
{"blocking", BlockingAttributeGetCallback, BlockingAttributeSetCallback, unsigned(v8::None), unsigned(IDLMemberInstaller::FlagLocation::kPrototype), unsigned(IDLMemberInstaller::FlagWorld::kAllWorlds), unsigned(IDLMemberInstaller::FlagReceiverCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(IDLMemberInstaller::FlagCrossOriginCheck::kCheck), unsigned(v8::SideEffectType::kHasNoSideEffect), unsigned(V8PrivateProperty::CachedAccessor::kNone)},
};
IDLMemberInstaller::InstallAttributes(isolate, world, instance_template, prototype_template, interface_template, signature, kAttributeTable);
}


http://www.ppmy.cn/server/132542.html

相关文章

01数组算法/代码随想录

一、数组 好久没写算法题&#xff0c;之前喜欢按着习惯选择刷题&#xff0c;很早以前就听说代码随想录&#xff0c;今天跟着代码随想录再过一遍算法 1.1二分查找 常见疑问 middle一定是在[left, right]这个范围内标准代码不会越界&#xff0c;因为在else if中出现越界后&…

自由学习记录(6)

单例为何存在 静态类不能继承其他类&#xff0c;也不能被继承&#xff0c;这是静态类的一个限制。静态类的设计初衷是为了提供一组与对象无关的工具或功能&#xff0c;因此它没有对象实例的概念&#xff0c;这也意味着不能利用面向对象中的继承和多态特性。 为什么不能继承静…

2024-10-16 问AI: [AI面试题] 描述遗传算法的概念

文心一言 遗传算法&#xff08;Genetic Algorithm&#xff0c;GA&#xff09;是一种模拟生物进化过程的全局优化搜索算法&#xff0c;其概念可以从以下几个方面进行描述&#xff1a; 一、基本原理 遗传算法借鉴了达尔文的进化论和孟德尔的遗传学说&#xff0c;其本质是一种并…

使用Hugging Face中的BERT进行标题分类

使用Hugging Face中的BERT进行标题分类 前言相关介绍出处基本原理优点缺点 前提条件实验环境BERT进行标题分类准备数据集读取数据集划分数据集设置相关参数创建自己DataSet对象计算准确率定义预训练模型定义优化器训练模型保存模型测试模型 参考文献 前言 由于本人水平有限&…

springboot系列--web相关知识探索五

一、前言 web相关知识探索四中研究了请求中所带的参数是如何映射到接口参数中的&#xff0c;也即请求参数如何与接口参数绑定。主要有四种、分别是注解方式、Servlet API方式、复杂参数、以及自定义对象参数。web相关知识探索四中主要研究了复杂参数底层绑定原理。本次主要是研…

PCB厚铜板究竟厚在哪,猎板PCB告诉您

在PCB厚铜板领域&#xff0c;厚铜板通常指的是在PCB制造过程中&#xff0c;使用比标准PCB厚度更大的铜箔。标准PCB铜箔厚度一般在35微米&#xff08;1盎司/平方英尺&#xff09;左右&#xff0c;而厚铜PCB的铜厚度通常在105微米&#xff08;3盎司/平方英尺&#xff09;及以上&a…

在uniapp中实现长按聊天对话框可以弹出对话框然后可以删除该条对话,单击可以进入该条对话框的对话页面

效果展示 效果描述 长按【大于1s】某一条对话框会弹出一个对话框&#xff0c;点击确定按钮就可以将当前对话框从列表中进行删除&#xff0c;如果点击取消则不做额外操作。 如果只是点击了一下&#xff0c;时间【小于1s】的情况下会直接引入到与该用户的对话框详情页面。 代码…

【Docker】Elasticsearch Docker 容器数据迁移

背景 之前的 es 数据是容器化部署的&#xff0c;由于最近云服务器到期&#xff0c;需要进行更换&#xff0c;于是需要进行es 容器和es 数据的迁移。这里记录一下。 版本信息&#xff1a; es&#xff1a;7.10.0kibana:7.10.0 操作步骤 1. 新环境下载docker 镜像 版本与旧环…