Chromium html<lable>c++接口定义

news2024/10/20 23:55:34

HTML <label> 元素(标签)表示用户界面中某个元素的说明。

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

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

    {
      name: "label",
      interfaceHeaderDir: "third_party/blink/renderer/core/html/forms",
    },

2、html_label_element.idl接口定义:

// https://html.spec.whatwg.org/C/#the-label-element
[
    Exposed=Window,
    HTMLConstructor
] interface HTMLLabelElement : HTMLElement {
    readonly attribute HTMLFormElement? form;
    [CEReactions, Reflect=for] attribute DOMString htmlFor;
    readonly attribute HTMLElement? control;
};

2、html_label_element.idl接口blink实现:

third_party\blink\renderer\core\html\forms\html_label_element.h

third_party\blink\renderer\core\html\forms\html_label_element.cc

namespace blink {

class CORE_EXPORT HTMLLabelElement final : public HTMLElement {
  DEFINE_WRAPPERTYPEINFO();

 public:
  explicit HTMLLabelElement(Document&);

  HTMLElement* control() const;
  HTMLFormElement* form() const;

  bool WillRespondToMouseClickEvents() override;

 private:
  bool IsInInteractiveContent(Node*) const;

  bool IsInteractiveContent() const override;
  void AccessKeyAction(SimulatedClickCreationScope creation_scope) override;

  // Overridden to update the hover/active state of the corresponding control.
  void SetActive(bool active) override;
  void SetHovered(bool hovered) override;

  // Overridden to either click() or focus() the corresponding control.
  void DefaultEventHandler(Event&) override;
  bool HasActivationBehavior() const override;

  void Focus(const FocusParams&) override;

  bool processing_click_;
};

}  // namespace blink

3、html_label_element.idl接口v8实现:

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

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

namespace blink {



bool V8HTMLLabelElement::IsExposed(ExecutionContext* execution_context) {
  
return execution_context->IsWindow();
}

// Construction of WrapperTypeInfo may require non-trivial initialization due
// to cross-component address resolution in order to load the pointer to the
// parent interface's WrapperTypeInfo.  We ignore this issue because the issue
// happens only on component builds and the official release builds
// (statically-linked builds) are never affected by this issue.
#if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif

const WrapperTypeInfo V8HTMLLabelElement::wrapper_type_info_{
    gin::kEmbedderBlink,
    V8HTMLLabelElement::InstallInterfaceTemplate,
    nullptr,
    "HTMLLabelElement",
    V8HTMLElement::GetWrapperTypeInfo(),
    WrapperTypeInfo::kWrapperTypeObjectPrototype,
    WrapperTypeInfo::kNodeClassId,
    WrapperTypeInfo::kNotInheritFromActiveScriptWrappable,
    WrapperTypeInfo::kIdlInterface,
    false,
};

#if defined(COMPONENT_BUILD) && defined(WIN32) && defined(__clang__)
#pragma clang diagnostic pop
#endif

const WrapperTypeInfo& HTMLLabelElement::wrapper_type_info_ =
    V8HTMLLabelElement::wrapper_type_info_;

// non-[ActiveScriptWrappable]
static_assert(
    !std::is_base_of<ActiveScriptWrappableBase, HTMLLabelElement>::value,
    "HTMLLabelElement inherits from ActiveScriptWrappable<> without "
    "[ActiveScriptWrappable] extended attribute.");

namespace  {

namespace v8_html_label_element {

void FormAttributeGetCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
  
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_HTMLLabelElement_form_Getter");
BLINK_BINDINGS_TRACE_EVENT("HTMLLabelElement.form.get");



v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> v8_receiver = info.This();
HTMLLabelElement* blink_receiver = V8HTMLLabelElement::ToWrappableUnsafe(isolate, v8_receiver);
auto&& return_value = blink_receiver->form();
bindings::V8SetReturnValue(info, return_value, blink_receiver);
}


void HTMLForAttributeGetCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
  
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_HTMLLabelElement_htmlFor_Getter");
BLINK_BINDINGS_TRACE_EVENT("HTMLLabelElement.htmlFor.get");



v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> v8_receiver = info.This();
HTMLLabelElement* blink_receiver = V8HTMLLabelElement::ToWrappableUnsafe(isolate, v8_receiver);
auto&& return_value = blink_receiver->FastGetAttribute(html_names::kForAttr);
bindings::V8SetReturnValue(info, return_value, isolate, bindings::V8ReturnValue::kNonNullable);
}

void HTMLForAttributeSetCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
  
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_HTMLLabelElement_htmlFor_Setter");
BLINK_BINDINGS_TRACE_EVENT("HTMLLabelElement.htmlFor.set");

const char* const class_like_name = "HTMLLabelElement";
const char* const property_name = "htmlFor";
bindings::PerformAttributeSetCEReactionsReflectTypeString(info, html_names::kForAttr, class_like_name, property_name);
}

void ControlAttributeGetCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
  
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_HTMLLabelElement_control_Getter");
BLINK_BINDINGS_TRACE_EVENT("HTMLLabelElement.control.get");



v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> v8_receiver = info.This();
HTMLLabelElement* blink_receiver = V8HTMLLabelElement::ToWrappableUnsafe(isolate, v8_receiver);
auto&& return_value = blink_receiver->control();
bindings::V8SetReturnValue(info, return_value, blink_receiver);
}


void ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
  RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_HTMLLabelElement_constructor");
BLINK_BINDINGS_TRACE_EVENT("HTMLLabelElement.constructor");

v8::Isolate* isolate = info.GetIsolate();
if (!info.IsConstructCall()) {
  const ExceptionContextType exception_context_type = ExceptionContextType::kConstructorOperationInvoke;
const char* const class_like_name = "HTMLLabelElement";
ExceptionState exception_state(isolate, exception_context_type, class_like_name);
exception_state.ThrowTypeError(ExceptionMessages::ConstructorCalledAsFunction());
return;
}
if (ConstructorMode::Current(isolate) == ConstructorMode::kWrapExistingObject) {
  v8::Local<v8::Object> v8_receiver = info.This();
bindings::V8SetReturnValue(info, v8_receiver);
return;
}



// [HTMLConstructor]
V8HTMLConstructor::HtmlConstructor(info, *V8HTMLLabelElement::GetWrapperTypeInfo(), HTMLElementType::kHTMLLabelElement);
}


}  // namespace v8_html_label_element

using namespace v8_html_label_element;

}  // namespace 

void V8HTMLLabelElement::InstallInterfaceTemplate(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::Template> interface_template) {
  const WrapperTypeInfo* const wrapper_type_info = V8HTMLLabelElement::GetWrapperTypeInfo();
v8::Local<v8::FunctionTemplate> interface_function_template = interface_template.As<v8::FunctionTemplate>();
v8::Local<v8::ObjectTemplate> instance_object_template = interface_function_template->InstanceTemplate();
v8::Local<v8::ObjectTemplate> prototype_object_template = interface_function_template->PrototypeTemplate();
v8::Local<v8::FunctionTemplate> parent_interface_template = wrapper_type_info->parent_class->GetV8ClassTemplate(isolate, world).As<v8::FunctionTemplate>();
bindings::SetupIDLInterfaceTemplate(isolate, wrapper_type_info, instance_object_template, prototype_object_template, interface_function_template, parent_interface_template);

interface_function_template->SetCallHandler(ConstructorCallback);
interface_function_template->SetLength(0);






v8::Local<v8::Template> instance_template = instance_object_template;
v8::Local<v8::Template> prototype_template = prototype_object_template;
InstallUnconditionalProperties(isolate, world, instance_template, prototype_template, interface_template);
}

void V8HTMLLabelElement::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;

{
  static const IDLMemberInstaller::AttributeConfig kAttributeTable[] = {
{"form", FormAttributeGetCallback, nullptr, 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)},
{"control", ControlAttributeGetCallback, nullptr, 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)},
};
v8::Local<v8::FunctionTemplate> interface_function_template = interface_template.As<v8::FunctionTemplate>();
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_function_template);
IDLMemberInstaller::InstallAttributes(isolate, world, instance_template, prototype_template, interface_template, signature, kAttributeTable);
}







}




}  // namespace blink

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2219649.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于curl和wget命令编写的多文件或大文件批量上传下载

最近需要在windows和服务器linux系统之间传递大量的文件&#xff0c;部分文件非常大&#xff08;TB以上&#xff09;&#xff0c;并且文件夹中包含文件或文件夹&#xff0c;需要先进行上传再进行组织&#xff0c;因此就想办法结合curl和wget命令编写了命令或脚本工具&#xff0…

三菱PLC伺服-停止位置不正确故障排查

停止位置不正确时&#xff0c;请确认以下项目。 1)请确认伺服放大器(驱动单元)的电子齿轮的设定是否正确。 2&#xff09;请确认原点位置是否偏移。 1、设计近点信号(DOG)时&#xff0c;请考虑有足够为0N的时间能充分减速到爬行速度。该指令在DOG的前端开始减速到爬行速度&…

【云从】六、云存储

文章目录 1、应用架构2、存储设备3、存储方案3.1 直连式存储DAS3.2 网络连接存储NAS3.3 存储区域网络SAN3.4 分布式存储ServerSAN3.5 软件定义存储SDS 4、云存储4.1 云硬盘CBS4.2 文件存储CFS4.3 对象存储COS 1、应用架构 2、存储设备 硬盘性能对比&#xff1a; 硬盘接口对比&…

C语言(函数)—函数栈帧的创建和销毁

目录 前言 补充知识 一、函数线帧是什么&#xff1f; 二、函数线帧的实现&#xff08;举例说明&#xff09; 两数之和代码 ​编辑两数之和 汇编代码分析 执行第一条语句 执行第二条语句 执行第三条语句 执行第四、五、六条语句 执行第七条语句 执行第八、九、十条语句 执行第十…

Scroll 生态首个 meme 项目 $Baggor,我们可以有哪些期待?

在最近几个月里&#xff0c;加密市场整体表现平稳&#xff0c;无论是比特币还是山寨币板块&#xff0c;都处于震荡状态&#xff0c;并未显示出突破前高的迹象。然而&#xff0c;在这样的市场背景下&#xff0c;meme币却持续扛起了大旗&#xff0c;令这个看似不太熊的熊市不断引…

递归算法笔记

根据b站视频整理的 **视频地址&#xff1a;**https://www.bilibili.com/video/BV1S24y1p7iH/?spm_id_from333.788.videopod.sections&vd_source6335ddc7b30e1f4510569db5f2506f20 最常见的一个递归例子&#xff1a; 斐波那契数列&#xff1a;1&#xff0c;2&#xff0c;3…

Linux 使用xtrabackup备份MySQL数据

目录 一&#xff1a;xtrabackup 介绍二&#xff1a;实现数据备份1. 实现全备份2. 实现增量备份3. 实现差异备份4. 全备份时压缩数据5. 全备份时排除指定表不备份6. 全备份时排除指定库不备份 三&#xff1a;实现数据还原1. 全备份数据恢复流程2. 全备份压缩后的数据恢复流程3. …

神仙公司名单(长沙)

神仙公司&#xff08;长沙&#xff09; 小周末&#xff0c;继续 神仙公司系列。 长沙&#xff0c;湖南省的省会城市&#xff0c;不仅以其深厚的历史文化底蕴著称&#xff0c;同时也是一个充满活力的现代都市。 长沙的经济活力、教育资源、医疗资源、就业机会、居住环境、生活成…

python中堆的用法

Python 堆&#xff08;Headp&#xff09; Python中堆是一种基于二叉树存储的数据结构。 主要应用场景&#xff1a; 对一个序列数据的操作基于排序的操作场景&#xff0c;例如序列数据基于最大值最小值进行的操作。 堆的数据结构&#xff1a; Python 中堆是一颗平衡二叉树&am…

15分钟学Go 第2天:安装Go环境

第2天&#xff1a;安装Go环境 1. 引言 在学习Go语言之前&#xff0c;首先需要配置好本地开发环境。本节将详细介绍如何在Windows 11上安装和配置Go语言环境&#xff0c;包括安装步骤、环境变量设置、VS Code配置与测试、以及常见问题解决方案。完成这些步骤后&#xff0c;你将…

Excel:vba实现筛选出有批注的单元格

实现的效果&#xff1a;代码&#xff1a; Sub test() Dim cell As RangeRange("F3:I10000").ClearlastRow Cells(Rows.Count, "f").End(xlUp).Row MsgBox lastrow For Each cell In Range("a1:a21")If Not cell.Comment Is Nothing ThenMsgBox…

【AIGC】2024-arXiv-InstantStyle:文本到图像生成中保持风格的免费午餐

2024-arXiv-InstantStyle: Free Lunch towards Style-Preserving in Text-to-Image Generation InstantStyle&#xff1a;文本到图像生成中保持风格的免费午餐摘要1. 引言2. 相关工作2.1 文本到图像的传播模型2.2 风格化图像生成2.3 扩散模型中的注意力控制 3. 方法3.1 动机3.2…

keil中编译遇到错误“error #94-D the size of an array must be greater than zero”解决方法

这一期&#xff0c;我们来看一个在keil中编译时候遇到定义数组元素个数为0时候遇到的一个错误。 错误&#xff1a; 先看错误&#xff1a;编译提示错误“error: #94-D: the size of an array must be greater than zero” &#xff0c;意思是这个数组内元素个数不能定义为0个&…

【AIGC】解锁高效GPTs:ChatGPT-Builder中系统提示词Prompt的设计与应用

博客主页&#xff1a; [小ᶻZ࿆] 本文专栏: AIGC | ChatGPT 文章目录 &#x1f4af;前言&#x1f4af;系统提示词系统提示词的作用与重要性系统提示词在构建GPTs中的作用结论 &#x1f4af;ChatGPT-Builder系统提示词的详细解读OpenAI为Builder编写的系统提示词系统提示词对…

R语言详解predict函数

R语言中predict函数在建立模型&#xff0c;研究关系时常用。但是不同type得到的结果常常被混为一谈&#xff0c;接下来&#xff0c;探讨predict得到的不同结果。 #数据 set.seed(123) n<-1000 age<-rnorm(n,mean50,sd10) gender<-rbinom(n,1,0.5) disease<-rbinom…

OpenCV高级图形用户界面(12)用于更改指定窗口的大小函数resizeWindow()的使用

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 cv::resizeWindow() 函数用于更改指定窗口的大小。这使得你可以根据需要调整窗口的宽度和高度。 注释 指定的窗口大小是指图像区域的大小。工具栏…

Maxwell 底层原理 详解

Maxwell 是一个 MySQL 数据库的增量数据捕获&#xff08;CDC, Change Data Capture&#xff09;工具&#xff0c;它通过读取 MySQL 的 binlog&#xff08;Binary Log&#xff09;来捕获数据变化&#xff0c;并将这些变化实时地发送到如 Kafka、Kinesis、RabbitMQ 或其他输出端。…

字节跳动青训营——入营考核解答(持续更新中~~~)

考核内容&#xff1a; 在指定的题库中自主选择不少于 15 道算法题并完成解题&#xff0c;其中题目难度分配如下&#xff1a; 简单题不少于 10 道中等题不少于 4 道困难题不少于 1 道 解答代码 20. 百分位数&#xff08;中等&#xff09; 代码实现&#xff1a; import jav…

Uiautomator2与weditor配置一直报错咋办

作者在配置这两个的时候绞尽脑汁了&#xff0c;u2的init总是报错并且无法自动在手机上安装atx&#xff0c;weditor可以打开但是只要对元素操作或者任意操作就会让你去重新init&#xff0c;搞得作者焦头烂额&#xff0c;而且网上各种各样的报错信息眼花缭乱&#xff0c;作者几乎…

【深入学习Redis丨第八篇】详解Redis数据持久化机制

前言 Redis支持两种数据持久化方式&#xff1a;RDB方式和AOF方式。前者会根据配置的规则定时将内存中的数据持久化到硬盘上&#xff0c;后者则是在每次执行写命令之后将命令记录下来。两种持久化方式可以单独使用&#xff0c;但是通常会将两者结合使用。 一、持久化 1.1、什么…