@@ -308,22 +308,70 @@ class Element : public lepus::RefCounted,
308308 virtual void SetEventHandler (const base::String& name, EventHandler* handler);
309309 virtual void ResetEventHandlers ();
310310
311- // For js/lepus/worklet event handlers
311+ /* *
312+ * Element API for adding js event
313+ * @param name the binding event's name
314+ * @param type the binding event's type
315+ * @param callback the binding event's corresponding js function name
316+ */
312317 void SetJSEventHandler (const base::String& name, const base::String& type,
313318 const base::String& callback);
319+
320+ /* *
321+ * Element API for adding lepus event
322+ * @param name the binding event's name
323+ * @param type the binding event's type
324+ * @param script the binding event's corresponding lepus script
325+ * @param callback the binding event's corresponding lepus function
326+ */
314327 void SetLepusEventHandler (const base::String& name, const base::String& type,
315328 const lepus::Value& script,
316329 const lepus::Value& callback);
330+
331+ /* *
332+ * Element API for adding worklet event
333+ * @param name the binding worklet event's name
334+ * @param type the binding worklet event's type
335+ * @param worklet_info the binding worklet info, passed to the front-end
336+ * @param ctx the context of Lepus / LepusNg
337+ * framework
338+ */
317339 void SetWorkletEventHandler (const base::String& name,
318340 const base::String& type,
319341 const lepus::Value& worklet_info,
320342 lepus::Context* ctx);
343+
344+ /* *
345+ * Element API for removing specific event
346+ * @param name the removed event's name
347+ * @param type the removed event's type
348+ */
321349 void RemoveEvent (const base::String& name, const base::String& type);
350+
351+ /* *
352+ * Element API for removing all events
353+ */
322354 void RemoveAllEvents ();
323355
324- // For config op
356+ /* *
357+ * Element API for adding config.
358+ * @param key the config key,
359+ * @param value the config value.
360+ */
325361 void AddConfig (const base::String& key, const lepus::Value& value);
362+
363+ /* *
364+ * Element API for setting config.
365+ * @param config the config will be setted,
366+ */
326367 void SetConfig (const lepus::Value& config);
368+
369+ /* *
370+ * A key function to get element's config.
371+ * The returned value is constant. You should not get Table() from
372+ * the value and change configs. Use AddConfig() instead which will
373+ * guarantee this element creates a writable config table.
374+ */
327375 const lepus::Value config () const ;
328376
329377 // For gesture handler
@@ -414,6 +462,115 @@ class Element : public lepus::RefCounted,
414462 bool IsRadonArch () const { return arch_type_ == RadonArch; }
415463 bool IsFiberArch () const { return arch_type_ == FiberArch; }
416464
465+ // Element type checking methods
466+ virtual bool is_none () const { return false ; }
467+ virtual bool is_block () const { return false ; }
468+ virtual bool is_if () const { return false ; }
469+ virtual bool is_for () const { return false ; }
470+ bool is_inline_element () const { return is_inline_element_; }
471+
472+ // Virtual parent node access methods (for AirModeFiber)
473+ void set_virtual_parent (Element* virtual_parent) {
474+ virtual_parent_ = virtual_parent;
475+ }
476+ Element* virtual_parent () { return virtual_parent_; }
477+ Element* root_virtual_parent ();
478+
479+ // Parent component unique ID access methods
480+ int64_t GetParentComponentUniqueIdForFiber () {
481+ return parent_component_unique_id_;
482+ }
483+
484+ void SetParentComponentUniqueIdForFiber (int64_t id) {
485+ if (id != parent_component_unique_id_) {
486+ parent_component_element_ = nullptr ;
487+ }
488+ parent_component_unique_id_ = id;
489+ }
490+
491+ bool IsInSameCSSScope (Element* element) {
492+ return css_id_ == element->css_id_ ;
493+ }
494+
495+ // This interface is currently only used by the inspector. The inspector
496+ // determines whether an element is created by the itself by checking whether
497+ // element has a data model. Since the data model of a fiber element is not
498+ // empty by default, this interface is provided to the inspector to reset the
499+ // data model and mark the element as created by the inspector.
500+ void ResetDataModel () { data_model_ = nullptr ; }
501+
502+ void MarkCanBeLayoutOnly (bool flag) { can_be_layout_only_ = flag; }
503+
504+ // Async resolve status query methods
505+ void UpdateResolveStatus (AsyncResolveStatus value) {
506+ resolve_status_ = value;
507+ }
508+
509+ bool IsAsyncResolveInvoked () {
510+ return resolve_status_ != AsyncResolveStatus::kCreated &&
511+ resolve_status_ != AsyncResolveStatus::kUpdated ;
512+ }
513+
514+ bool IsAsyncResolveResolving () {
515+ return resolve_status_ == AsyncResolveStatus::kResolving ||
516+ resolve_status_ == AsyncResolveStatus::kResolved ||
517+ resolve_status_ == AsyncResolveStatus::kPreparing ||
518+ resolve_status_ == AsyncResolveStatus::kSyncResolving ;
519+ }
520+
521+ bool flush_required () { return flush_required_; }
522+
523+ inline bool ShouldProcessParallelTasks () {
524+ return is_parallel_flush () ||
525+ resolve_status_ == AsyncResolveStatus::kSyncResolving ;
526+ }
527+
528+ inline bool ShouldResolveStyle () {
529+ return !IsAsyncResolveResolving () && ((dirty_ & ~kDirtyTree ) != 0 );
530+ }
531+
532+ inline void EnqueueReduceTask (base::MoveOnlyClosure<void > operation) {
533+ parallel_reduce_tasks_->emplace_back (std::move (operation));
534+ }
535+
536+ inline bool IsAsyncFlushRoot () const { return is_async_flush_root_; }
537+ inline void MarkAsyncFlushRoot (bool value) { is_async_flush_root_ = value; }
538+
539+ // Data model accessor methods
540+ const ClassList& classes () { return data_model_->classes (); }
541+
542+ ClassList ReleaseClasses () { return data_model_->ReleaseClasses (); }
543+
544+ const base::String& GetIdSelector () { return data_model_->idSelector (); }
545+
546+ const DataMap& dataset () { return data_model_->dataset (); }
547+
548+ // Check has_value() before usage to avoid unintentional construction.
549+ const auto & builtin_attr_map () const { return builtin_attr_map_; }
550+
551+ // Check has_value() before usage to avoid unintentional construction.
552+ const auto & updated_attr_map () const { return updated_attr_map_; }
553+
554+ void set_style_sheet_manager (
555+ const std::shared_ptr<CSSStyleSheetManager>& manager) {
556+ css_style_sheet_manager_ = manager;
557+ }
558+
559+ const std::shared_ptr<CSSStyleSheetManager>& style_sheet_manager () {
560+ return css_style_sheet_manager_;
561+ }
562+
563+ void set_attached_to_layout_parent (bool has) {
564+ attached_to_layout_parent_ = has;
565+ }
566+ bool attached_to_layout_parent () const { return attached_to_layout_parent_; }
567+
568+ void UpdateAttrMap (const base::String& key, const lepus::Value& value) {
569+ updated_attr_map_[key] = value;
570+ }
571+
572+ void MarkAttrDirtyForPseudoElement () { dirty_ |= kDirtyAttr ; }
573+
417574 void UpdateLayout (float left, float top, float width, float height,
418575 const std::array<float , 4 >& paddings,
419576 const std::array<float , 4 >& margins,
0 commit comments