当前位置: 首页 > news >正文

Chromium 前端window对象c++实现定义

前端中window.document window.alert()等一些列方法和对象在c++对应定义如下:

1、window对象接口定义文件window.idl

third_party\blink\renderer\core\frame\window.idl


// https://html.spec.whatwg.org/C/#the-window-object// FIXME: explain all uses of [CrossOrigin]
// NOTE: In the spec, Window inherits from EventTarget. We inject an additional
// layer to implement window's named properties object.
[ImplementedAs=DOMWindow,Global=Window,Exposed=Window
] interface Window : WindowProperties {// the current browsing context// FIXME: The spec uses the WindowProxy type for this and many other attributes.[LegacyUnforgeable, CrossOrigin, CachedAccessor=kWindowProxy] readonly attribute Window window;[Replaceable, CrossOrigin, CachedAccessor=kWindowProxy] readonly attribute Window self;[LegacyUnforgeable, CachedAccessor=kWindowDocument] readonly attribute Document document;attribute DOMString name;[PutForwards=href, LegacyUnforgeable, CrossOrigin=(Getter,Setter)] readonly attribute Location location;[CallWith=ScriptState] readonly attribute CustomElementRegistry customElements;readonly attribute History history;[Replaceable] readonly attribute Navigation navigation;[Replaceable, MeasureAs=BarPropLocationbar] readonly attribute BarProp locationbar;[Replaceable, MeasureAs=BarPropMenubar] readonly attribute BarProp menubar;[Replaceable, MeasureAs=BarPropPersonalbar] readonly attribute BarProp personalbar;[Replaceable, MeasureAs=BarPropScrollbars] readonly attribute BarProp scrollbars;[Replaceable, MeasureAs=BarPropStatusbar] readonly attribute BarProp statusbar;[Replaceable, MeasureAs=BarPropToolbar] readonly attribute BarProp toolbar;attribute DOMString status;[CrossOrigin, CallWith=Isolate] void close();[MeasureAs=WindowClosed, CrossOrigin] readonly attribute boolean closed;void stop();[CrossOrigin, CallWith=Isolate] void focus();[CrossOrigin] void blur();// other browsing contexts[Replaceable, CrossOrigin, CachedAccessor=kWindowProxy] readonly attribute Window frames;[Replaceable, CrossOrigin] readonly attribute unsigned long length;[LegacyUnforgeable, CrossOrigin] readonly attribute Window? top;// FIXME: opener should be of type any.[CrossOrigin, ImplementedAs=openerForBindings, CallWith=Isolate, RaisesException=Setter] attribute any opener;[Replaceable, CrossOrigin] readonly attribute Window? parent;[CheckSecurity=ReturnValue] readonly attribute Element? frameElement;[CallWith=Isolate, RaisesException] Window? open(optional USVString url="", optional DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = "");// indexed properties// https://html.spec.whatwg.org/C/browsers.html#windowproxy-getownproperty[NotEnumerable, CrossOrigin] getter Window (unsigned long index);// named properties// The spec defines the named getter on the Window interface, but we inject// the named properties object as its own interface that Window inherits// from.// getter object (DOMString name);// the user agent[LogActivity=GetterOnly] readonly attribute Navigator navigator;[RuntimeEnabled=OriginIsolationHeader] readonly attribute boolean originAgentCluster;// user prompts[Measure, CallWith=ScriptState] void alert();[Measure, CallWith=ScriptState] void alert(DOMString message);[Measure, CallWith=ScriptState] boolean confirm(optional DOMString message = "");[Measure, CallWith=ScriptState] DOMString? prompt(optional DOMString message = "", optional DOMString defaultValue = "");[Measure, CallWith=ScriptState] void print();[CrossOrigin, CallWith=Isolate, RaisesException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);[CrossOrigin, CallWith=Isolate, RaisesException] void postMessage(any message, optional WindowPostMessageOptions options = {});// WindowOrWorkerGlobalScope mixin// https://html.spec.whatwg.org/C/#windoworworkerglobalscope-mixin// https://wicg.github.io/origin-policy/#monkeypatch-html-windoworworkerglobalscope[Replaceable] readonly attribute DOMString origin;void queueMicrotask(VoidFunction callback);// AnimationFrameProvider mixin// https://html.spec.whatwg.org/C/#animation-frames[MeasureAs=UnprefixedRequestAnimationFrame] long requestAnimationFrame(FrameRequestCallback callback);void cancelAnimationFrame(long handle);// HTML obsolete features// https://html.spec.whatwg.org/C/#Window-partial[MeasureAs=WindowCaptureEvents] void captureEvents();[MeasureAs=WindowReleaseEvents] void releaseEvents();[Replaceable, SameObject] readonly attribute External external;// CSS Object Model (CSSOM)// https://drafts.csswg.org/cssom/#extensions-to-the-window-interface[Affects=Nothing, NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString? pseudoElt);// CSSOM View Module// https://drafts.csswg.org/cssom-view/#extensions-to-the-window-interface[HighEntropy, Measure, NewObject] MediaQueryList matchMedia(DOMString query);[SameObject, Replaceable] readonly attribute Screen screen;// browsing context[MeasureAs=WindowMove] void moveTo(long x, long y);[MeasureAs=WindowMove] void moveBy(long x, long y);[MeasureAs=WindowResize, RaisesException] void resizeTo(long x, long y);[MeasureAs=WindowResize, RaisesException] void resizeBy(long x, long y);// viewport[HighEntropy=Direct, MeasureAs=WindowInnerWidth, Replaceable] readonly attribute long innerWidth;[HighEntropy=Direct, MeasureAs=WindowInnerHeight, Replaceable] readonly attribute long innerHeight;// viewport scrolling[HighEntropy=Direct, MeasureAs=WindowScrollX, Replaceable] readonly attribute double scrollX;[HighEntropy=Direct, MeasureAs=WindowPageXOffset, Replaceable] readonly attribute double pageXOffset;[HighEntropy=Direct, MeasureAs=WindowScrollY, Replaceable] readonly attribute double scrollY;[HighEntropy=Direct, MeasureAs=WindowPageYOffset, Replaceable] readonly attribute double pageYOffset;void scroll(optional ScrollToOptions options = {});void scroll(unrestricted double x, unrestricted double y);void scrollTo(optional ScrollToOptions options = {});void scrollTo(unrestricted double x, unrestricted double y);void scrollBy(optional ScrollToOptions options = {});void scrollBy(unrestricted double x, unrestricted double y);// Visual Viewport API// https://github.com/WICG/ViewportAPI[Replaceable, SameObject] readonly attribute VisualViewport visualViewport;// client[HighEntropy=Direct, MeasureAs=WindowScreenX, Replaceable] readonly attribute long screenX;[HighEntropy=Direct, MeasureAs=WindowScreenY, Replaceable] readonly attribute long screenY;[HighEntropy=Direct, MeasureAs=WindowOuterWidth, Replaceable] readonly attribute long outerWidth;[HighEntropy=Direct, MeasureAs=WindowOuterHeight, Replaceable] readonly attribute long outerHeight;[HighEntropy=Direct, MeasureAs=WindowDevicePixelRatio, Replaceable] readonly attribute double devicePixelRatio;// Selection API// https://w3c.github.io/selection-api/#extensions-to-window-interface[Affects=Nothing] Selection? getSelection();// Console API// https://console.spec.whatwg.org/#console-interface// [Replaceable] readonly attribute Console console;// Console is installed by v8 inspector when context is created// and is left commented here just for documentation.// Compatibility// https://compat.spec.whatwg.org/#windoworientation-interface[RuntimeEnabled=OrientationEvent] attribute EventHandler onorientationchange;// This is the interface orientation in degrees. Some examples are://  0 is straight up; -90 is when the device is rotated 90 clockwise;//  90 is when rotated counter clockwise.[HighEntropy=Direct, MeasureAs=WindowOrientation, RuntimeEnabled=OrientationEvent] readonly attribute long orientation;// Event handler attribute for the pagereveal event.// https://drafts.csswg.org/css-view-transitions-2/#reveal-event[RuntimeEnabled=PageRevealEvent] attribute EventHandler onpagereveal;// Accessibility Object Model// https://github.com/WICG/aom/blob/HEAD/explainer.md[RuntimeEnabled=AccessibilityObjectModel, CallWith=ScriptState] Promise<ComputedAccessibleNode> getComputedAccessibleNode(Element element);// https://dom.spec.whatwg.org/#interface-window-extensions[Replaceable, GetterCallWith=ScriptState, MeasureAs=WindowEvent, NotEnumerable] readonly attribute any event;// Non-standard APIs[MeasureAs=WindowClientInformation, Replaceable] readonly attribute Navigator clientInformation;[MeasureAs=WindowFind] boolean find(optional DOMString string = "",optional boolean caseSensitive = false,optional boolean backwards = false,optional boolean wrap = false,optional boolean wholeWord = false,optional boolean searchInFrames = false,optional boolean showDialog = false);[MeasureAs=WindowOffscreenBuffering, Replaceable, NotEnumerable] readonly attribute boolean offscreenBuffering;[HighEntropy=Direct, MeasureAs=WindowScreenLeft, Replaceable] readonly attribute long screenLeft;[HighEntropy=Direct, MeasureAs=WindowScreenTop, Replaceable] readonly attribute long screenTop;[RuntimeEnabled=WindowDefaultStatus,MeasureAs=WindowDefaultStatus] attribute DOMString defaultStatus;[RuntimeEnabled=WindowDefaultStatus,MeasureAs=WindowDefaultstatus, ImplementedAs=defaultStatus] attribute DOMString defaultstatus;[MeasureAs=StyleMedia] readonly attribute StyleMedia styleMedia;[DeprecateAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(FrameRequestCallback callback);[DeprecateAs=PrefixedCancelAnimationFrame, ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(long id);// Event handler attributesattribute EventHandler onsearch;// https://w3c.github.io/webappsec-secure-contexts/#monkey-patching-global-objectreadonly attribute boolean isSecureContext;// TrustedTypes API: http://github.com/w3c/trusted-types[CallWith=ScriptState] readonly attribute TrustedTypePolicyFactory trustedTypes;// Anonymous iframe:// https://github.com/WICG/anonymous-iframe[RuntimeEnabled=AnonymousIframe] readonly attribute boolean credentialless;// Collection of fenced frame APIs// https://github.com/shivanigithub/fenced-frame/issues/14[RuntimeEnabled=FencedFrames] readonly attribute Fence? fence;
};Window includes GlobalEventHandlers;
Window includes WindowEventHandlers;
Window includes WindowOrWorkerGlobalScope;

2、window对象接口定义实现文件(blink):

third_party\blink\renderer\core\frame\dom_window.h

third_party\blink\renderer\core\frame\dom_window.cc

third_party\blink\renderer\core\frame\local_dom_window.h

third_party\blink\renderer\core\frame\local_dom_window.cc

继承关系:

// Note: if you're thinking of returning something DOM-related by reference,
// please ping dcheng@chromium.org first. You probably don't want to do that.
class CORE_EXPORT LocalDOMWindow final : public DOMWindow,public ExecutionContext,public WindowOrWorkerGlobalScope,public WindowEventHandlers,public Supplementable<LocalDOMWindow>

在local_dom_window.h  LocalDOMWindow类中对应这前端window所有方法和对象实现


#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_LOCAL_DOM_WINDOW_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_LOCAL_DOM_WINDOW_H_#include <memory>#include "base/task/single_thread_task_runner.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "services/network/public/mojom/content_security_policy.mojom-blink.h"
#include "third_party/blink/public/common/frame/delegated_capability_request_token.h"
#include "third_party/blink/public/common/frame/history_user_activation_state.h"
#include "third_party/blink/public/common/metrics/post_message_counter.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/editing/spellcheck/spell_checker.h"
#include "third_party/blink/renderer/core/editing/suggestion/text_suggestion_controller.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/use_counter_impl.h"
#include "third_party/blink/renderer/core/frame/window_event_handlers.h"
#include "third_party/blink/renderer/core/frame/window_or_worker_global_scope.h"
#include "third_party/blink/renderer/core/html/closewatcher/close_watcher.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h"
#include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/prefinalizer.h"
#include "third_party/blink/renderer/platform/storage/blink_storage_key.h"
#include "third_party/blink/renderer/platform/supplementable.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/blink/renderer/platform/wtf/uuid.h"namespace blink {class BarProp;
class CSSStyleDeclaration;
class CustomElementRegistry;
class Document;
class DocumentInit;
class DOMSelection;
class DOMVisualViewport;
class Element;
class ExceptionState;
class External;
class Fence;
class FrameConsole;
class History;
class InputMethodController;
class LocalFrame;
class MediaQueryList;
class MessageEvent;
class Modulator;
class NavigationApi;
class Navigator;
class Screen;
class ScriptController;
class ScriptPromise;
class ScriptState;
class ScrollToOptions;
class SecurityOrigin;
class SerializedScriptValue;
class SourceLocation;
class StyleMedia;
class TrustedTypePolicyFactory;
class V8FrameRequestCallback;
class V8VoidFunction;
struct WebPictureInPictureWindowOptions;
class WindowAgent;namespace scheduler {
class TaskAttributionInfo;
}enum PageTransitionEventPersistence {kPageTransitionEventNotPersisted = 0,kPageTransitionEventPersisted = 1
};// Note: if you're thinking of returning something DOM-related by reference,
// please ping dcheng@chromium.org first. You probably don't want to do that.
class CORE_EXPORT LocalDOMWindow final : public DOMWindow,public ExecutionContext,public WindowOrWorkerGlobalScope,public WindowEventHandlers,public Supplementable<LocalDOMWindow> {USING_PRE_FINALIZER(LocalDOMWindow, Dispose);public:class CORE_EXPORT EventListenerObserver : public GarbageCollectedMixin {public:virtual void DidAddEventListener(LocalDOMWindow*, const AtomicString&) = 0;virtual void DidRemoveEventListener(LocalDOMWindow*,const AtomicString&) = 0;virtual void DidRemoveAllEventListeners(LocalDOMWindow*) = 0;};static LocalDOMWindow* From(const ScriptState*);LocalDOMWindow(LocalFrame&, WindowAgent*);~LocalDOMWindow() override;// Returns the token identifying the frame that this ExecutionContext was// associated with at the moment of its creation. This remains valid even// after the frame has been destroyed and the ExecutionContext is detached.// This is used as a stable and persistent identifier for attributing detached// context memory usage.const LocalFrameToken& GetLocalFrameToken() const { return token_; }ExecutionContextToken GetExecutionContextToken() const final {return token_;}LocalFrame* GetFrame() const {// UnsafeTo<> is safe here because DOMWindow's frame can only change to// nullptr, and it was constructed with a LocalFrame in the constructor.return UnsafeTo<LocalFrame>(DOMWindow::GetFrame());}ScriptController& GetScriptController() const { return *script_controller_; }void Initialize();void ClearForReuse() { document_ = nullptr; }void ResetWindowAgent(WindowAgent*);mojom::blink::V8CacheOptions GetV8CacheOptions() const override;// Bind Content Security Policy to this window. This will cause the// CSP to resolve the 'self' attribute and all policies will then be// applied to this document.void BindContentSecurityPolicy();void Trace(Visitor*) const override;// ExecutionContext overrides:bool IsWindow() const final { return true; }bool IsContextThread() const final;bool ShouldInstallV8Extensions() const final;ContentSecurityPolicy* GetContentSecurityPolicyForWorld(const DOMWrapperWorld* world) final;const KURL& Url() const final;const KURL& BaseURL() const final;KURL CompleteURL(const String&) const final;void DisableEval(const String& error_message) final;void SetWasmEvalErrorMessage(const String& error_message) final;String UserAgent() const final;UserAgentMetadata GetUserAgentMetadata() const final;HttpsState GetHttpsState() const final;ResourceFetcher* Fetcher() final;bool CanExecuteScripts(ReasonForCallingCanExecuteScripts) final;void ExceptionThrown(ErrorEvent*) final;void AddInspectorIssue(AuditsIssue) final;EventTarget* ErrorEventTarget() final { return this; }String OutgoingReferrer() const final;CoreProbeSink* GetProbeSink() final;const BrowserInterfaceBrokerProxy& GetBrowserInterfaceBroker() const final;FrameOrWorkerScheduler* GetScheduler() final;scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(TaskType) final;TrustedTypePolicyFactory* GetTrustedTypes() const final {return GetTrustedTypesForWorld(*GetCurrentWorld());}ScriptWrappable* ToScriptWrappable() final { return this; }void ReportPermissionsPolicyViolation(mojom::blink::PermissionsPolicyFeature,mojom::blink::PolicyDisposition,const absl::optional<String>& reporting_endpoint,const String& message = g_empty_string) const final;void ReportDocumentPolicyViolation(mojom::blink::DocumentPolicyFeature,mojom::blink::PolicyDisposition,const String& message = g_empty_string,// If source_file is set to empty string,// current JS file would be used as source_file instead.const String& source_file = g_empty_string) const final;void SetIsInBackForwardCache(bool) final;bool HasStorageAccess() const final;void AddConsoleMessageImpl(ConsoleMessage*, bool discard_duplicates) final;scoped_refptr<base::SingleThreadTaskRunner>GetAgentGroupSchedulerCompositorTaskRunner() final;// UseCounter orverrides:void CountUse(mojom::WebFeature feature) final;// Count |feature| only when this window is associated with a cross-origin// iframe.void CountUseOnlyInCrossOriginIframe(mojom::blink::WebFeature feature);// Count |feature| only when this window is associated with a same-origin// iframe with the outermost main frame.void CountUseOnlyInSameOriginIframe(mojom::blink::WebFeature feature);// Count |feature| only when this window is associated with a cross-site// iframe. A "site" is a scheme and registrable domain.void CountUseOnlyInCrossSiteIframe(mojom::blink::WebFeature feature) override;// Count permissions policy feature usage through use counter.void CountPermissionsPolicyUsage(mojom::blink::PermissionsPolicyFeature feature,UseCounterImpl::PermissionsPolicyUsageType type);// Checks if navigation to Javascript URL is allowed. This check should run// before any action is taken (e.g. creating new window) for all// same-origin navigations.String CheckAndGetJavascriptUrl(const DOMWrapperWorld* world,const KURL& url,Element* element,network::mojom::CSPDisposition csp_disposition =network::mojom::CSPDisposition::CHECK);Document* InstallNewDocument(const DocumentInit&);// EventTarget overrides:ExecutionContext* GetExecutionContext() const override;const LocalDOMWindow* ToLocalDOMWindow() const override;LocalDOMWindow* ToLocalDOMWindow() override;// Same-origin DOM Level 0Screen* screen();History* history();BarProp* locationbar();BarProp* menubar();BarProp* personalbar();BarProp* scrollbars();BarProp* statusbar();BarProp* toolbar();Navigator* navigator();Navigator* clientInformation() { return navigator(); }bool offscreenBuffering() const;int outerHeight() const;int outerWidth() const;int innerHeight() const;int innerWidth() const;int screenX() const;int screenY() const;int screenLeft() const { return screenX(); }int screenTop() const { return screenY(); }double scrollX() const;double scrollY() const;double pageXOffset() const { return scrollX(); }double pageYOffset() const { return scrollY(); }DOMVisualViewport* visualViewport();const AtomicString& name() const;void setName(const AtomicString&);String status() const;void setStatus(const String&);String defaultStatus() const;void setDefaultStatus(const String&);String origin() const;// DOM Level 2 AbstractView InterfaceDocument* document() const;// CSSOM View ModuleStyleMedia* styleMedia();// WebKit extensionsdouble devicePixelRatio() const;// This is the interface orientation in degrees. Some examples are://  0 is straight up; -90 is when the device is rotated 90 clockwise;//  90 is when rotated counter clockwise.int orientation() const;DOMSelection* getSelection();void print(ScriptState*);void stop();void alert(ScriptState*, const String& message = String());bool confirm(ScriptState*, const String& message);String prompt(ScriptState*,const String& message,const String& default_value);bool find(const String&,bool case_sensitive,bool backwards,bool wrap,bool whole_word,bool search_in_frames,bool show_dialog) const;// FIXME: ScrollBehaviorSmooth is currently unsupported in VisualViewport.// crbug.com/434497void scrollBy(double x, double y) const;void scrollBy(const ScrollToOptions*) const;void scrollTo(double x, double y) const;void scrollTo(const ScrollToOptions*) const;void scroll(double x, double y) const { scrollTo(x, y); }void scroll(const ScrollToOptions* scroll_to_options) const {scrollTo(scroll_to_options);}void moveBy(int x, int y) const;void moveTo(int x, int y) const;void resizeBy(int x, int y, ExceptionState&) const;void resizeTo(int width, int height, ExceptionState&) const;MediaQueryList* matchMedia(const String&);// DOM Level 2 Style InterfaceCSSStyleDeclaration* getComputedStyle(Element*,const String& pseudo_elt = String()) const;// Acessibility Object ModelScriptPromise getComputedAccessibleNode(ScriptState*, Element*);// WebKit animation extensionsint requestAnimationFrame(V8FrameRequestCallback*);int webkitRequestAnimationFrame(V8FrameRequestCallback*);void cancelAnimationFrame(int id);// https://html.spec.whatwg.org/C/#windoworworkerglobalscope-mixinvoid queueMicrotask(V8VoidFunction*);// https://html.spec.whatwg.org/C/#dom-originagentclusterbool originAgentCluster() const;// Custom elementsCustomElementRegistry* customElements(ScriptState*) const;CustomElementRegistry* customElements() const;CustomElementRegistry* MaybeCustomElements() const;void SetModulator(Modulator*);// Obsolete APIsvoid captureEvents() {}void releaseEvents() {}External* external();bool isSecureContext() const;DEFINE_ATTRIBUTE_EVENT_LISTENER(search, kSearch)DEFINE_ATTRIBUTE_EVENT_LISTENER(orientationchange, kOrientationchange)DEFINE_ATTRIBUTE_EVENT_LISTENER(pagereveal, kPagereveal)void RegisterEventListenerObserver(EventListenerObserver*);void FrameDestroyed();void Reset();Element* frameElement() const;DOMWindow* open(v8::Isolate*,const String& url_string,const AtomicString& target,const String& features,ExceptionState&);DOMWindow* openPictureInPictureWindow(v8::Isolate*,const WebPictureInPictureWindowOptions&,ExceptionState&);FrameConsole* GetFrameConsole() const;void PrintErrorMessage(const String&) const;void DispatchPostMessage(MessageEvent* event,scoped_refptr<const SecurityOrigin> intended_target_origin,std::unique_ptr<SourceLocation> location,const base::UnguessableToken& source_agent_cluster_id);void DispatchMessageEventWithOriginCheck(const SecurityOrigin* intended_target_origin,MessageEvent*,std::unique_ptr<SourceLocation>,const base::UnguessableToken& source_agent_cluster_id);// Events// EventTarget APIvoid RemoveAllEventListeners() override;using EventTarget::DispatchEvent;DispatchEventResult DispatchEvent(Event&, EventTarget*);void FinishedLoading(FrameLoader::NavigationFinishState);// Dispatch the (deprecated) orientationchange event to this DOMWindow and// recurse on its child frames.void SendOrientationChangeEvent();void EnqueueWindowEvent(Event&, TaskType);void EnqueueDocumentEvent(Event&, TaskType);void EnqueueNonPersistedPageshowEvent();void EnqueueHashchangeEvent(const String& old_url, const String& new_url);void DispatchPopstateEvent(scoped_refptr<SerializedScriptValue>,scheduler::TaskAttributionInfo* parent_task);void DispatchWindowLoadEvent();void DocumentWasClosed();void AcceptLanguagesChanged();// https://dom.spec.whatwg.org/#dom-window-eventScriptValue event(ScriptState*);Event* CurrentEvent() const;void SetCurrentEvent(Event*);TrustedTypePolicyFactory* trustedTypes(ScriptState*) const;TrustedTypePolicyFactory* GetTrustedTypesForWorld(const DOMWrapperWorld&) const;// Returns true if this window is cross-site to the outermost main frame.// Defaults to false in a detached window. Note: This uses an outdated// definition of "site" which only includes the registrable domain and not the// scheme. IsCrossSiteSubframeIncludingScheme() uses HTML's definition of// "site" as a registrable domain and scheme.bool IsCrossSiteSubframe() const;bool IsCrossSiteSubframeIncludingScheme() const;void DispatchPersistedPageshowEvent(base::TimeTicks navigation_start);void DispatchPagehideEvent(PageTransitionEventPersistence persistence);InputMethodController& GetInputMethodController() const {return *input_method_controller_;}TextSuggestionController& GetTextSuggestionController() const {return *text_suggestion_controller_;}SpellChecker& GetSpellChecker() const { return *spell_checker_; }void ClearIsolatedWorldCSPForTesting(int32_t world_id);bool CrossOriginIsolatedCapability() const override;bool IsIsolatedContext() const override;// These delegate to the document_.ukm::UkmRecorder* UkmRecorder() override;ukm::SourceId UkmSourceID() const override;const BlinkStorageKey& GetStorageKey() const { return storage_key_; }void SetStorageKey(const BlinkStorageKey& storage_key);// This storage key must only be used when binding session storage.//// TODO(crbug.com/1407150): Remove this when deprecation trial is complete.const BlinkStorageKey& GetSessionStorageKey() const {return session_storage_key_;}void SetSessionStorageKey(const BlinkStorageKey& session_storage_key);void DidReceiveUserActivation();// Returns the state of the |payment_request_token_| in this document.bool IsPaymentRequestTokenActive() const;// Consumes the |payment_request_token_| if it was active in this document.bool ConsumePaymentRequestToken();// Returns the state of the |fullscreen_request_token_| in this document.bool IsFullscreenRequestTokenActive() const;// Consumes the |fullscreen_request_token_| if it was active in this document.bool ConsumeFullscreenRequestToken();// Returns the state of the |display_capture_request_token_| in this document.bool IsDisplayCaptureRequestTokenActive() const;// Consumes the |display_capture_request_token_| if it was active in this// document.bool ConsumeDisplayCaptureRequestToken();// Called when a network request buffered an additional `num_bytes` while this// frame is in back-forward cache.void DidBufferLoadWhileInBackForwardCache(bool update_process_wide_count,size_t num_bytes);// Whether the window is credentialless or not.bool credentialless() const;bool IsInFencedFrame() const override;Fence* fence();CloseWatcher::WatcherStack* closewatcher_stack() {return closewatcher_stack_.Get();}void GenerateNewNavigationId();String GetNavigationId() const { return navigation_id_; }NavigationApi* navigation();// Is this a Document Picture in Picture window?bool IsPictureInPictureWindow() const;void set_is_picture_in_picture_window_for_testing(bool is_picture_in_picture) {is_picture_in_picture_window_ = is_picture_in_picture;}// Sets the HasStorageAccess member. Note that it can only be granted for a// given window, it cannot be taken away.void SetHasStorageAccess();protected:// EventTarget overrides.void AddedEventListener(const AtomicString& event_type,RegisteredEventListener&) override;void RemovedEventListener(const AtomicString& event_type,const RegisteredEventListener&) override;// Protected DOMWindow overrides.void SchedulePostMessage(PostedMessage*) override;private:class NetworkStateObserver;// Intentionally private to prevent redundant checks.bool IsLocalDOMWindow() const override { return true; }bool HasInsecureContextInAncestors() const override;Document& GetDocumentForWindowEventHandler() const override {return *document();}void Dispose();void DispatchLoadEvent();void SetIsPictureInPictureWindow();// Return the viewport size including scrollbars.gfx::Size GetViewportSize() const;Member<ScriptController> script_controller_;Member<Document> document_;Member<DOMVisualViewport> visualViewport_;bool should_print_when_finished_loading_;mutable Member<Screen> screen_;mutable Member<History> history_;mutable Member<BarProp> locationbar_;mutable Member<BarProp> menubar_;mutable Member<BarProp> personalbar_;mutable Member<BarProp> scrollbars_;mutable Member<BarProp> statusbar_;mutable Member<BarProp> toolbar_;mutable Member<Navigator> navigator_;mutable Member<StyleMedia> media_;mutable Member<CustomElementRegistry> custom_elements_;Member<External> external_;Member<NavigationApi> navigation_;String status_;String default_status_;HeapHashSet<WeakMember<EventListenerObserver>> event_listener_observers_;// Trackers for delegated payment, fullscreen, and display-capture requests.// These are related to |Frame::user_activation_state_|.DelegatedCapabilityRequestToken payment_request_token_;DelegatedCapabilityRequestToken fullscreen_request_token_;DelegatedCapabilityRequestToken display_capture_request_token_;// https://dom.spec.whatwg.org/#window-current-event// We represent the "undefined" value as nullptr.Member<Event> current_event_;// Store TrustedTypesPolicyFactory, per DOMWrapperWorld.mutable HeapHashMap<scoped_refptr<const DOMWrapperWorld>,Member<TrustedTypePolicyFactory>>trusted_types_map_;// A dummy scheduler to return when the window is detached.// All operations on it result in no-op, but due to this it's safe to// use the returned value of GetScheduler() without additional checks.// A task posted to a task runner obtained from one of its task runners// will be forwarded to the default task runner.// TODO(altimin): We should be able to remove it after we complete// frame:document lifetime refactoring.std::unique_ptr<FrameOrWorkerScheduler> detached_scheduler_;Member<InputMethodController> input_method_controller_;Member<SpellChecker> spell_checker_;Member<TextSuggestionController> text_suggestion_controller_;// Map from isolated world IDs to their ContentSecurityPolicy instances.Member<HeapHashMap<int, Member<ContentSecurityPolicy>>>isolated_world_csp_map_;// Tracks which features have already been potentially violated in this// document. This helps to count them only once per page load.// We don't use std::bitset to avoid to include// permissions_policy.mojom-blink.h.mutable Vector<bool> potentially_violated_features_;// Token identifying the LocalFrame that this window was associated with at// creation. Remains valid even after the frame is destroyed and the context// is detached.const LocalFrameToken token_;// Tracks which document policy violation reports have already been sent in// this document, to avoid reporting duplicates. The value stored comes// from |DocumentPolicyViolationReport::MatchId()|.mutable HashSet<unsigned> document_policy_violation_reports_sent_;// Tracks metrics related to postMessage usage.// TODO(crbug.com/1159586): Remove when no longer needed.PostMessageCounter post_message_counter_;// The storage key for this LocalDomWindow.BlinkStorageKey storage_key_;// The storage key here is the one to use when binding session storage. This// may differ from `storage_key_` as a deprecation trial can prevent the// partitioning of session storage.//// TODO(crbug.com/1407150): Remove this when deprecation trial is complete.BlinkStorageKey session_storage_key_;// Fire "online" and "offline" events.Member<NetworkStateObserver> network_state_observer_;// The total bytes buffered by all network requests in this frame while frozen// due to back-forward cache. This number gets reset when the frame gets out// of the back-forward cache.size_t total_bytes_buffered_while_in_back_forward_cache_ = 0;// Collection of fenced frame APIs.// https://github.com/shivanigithub/fenced-frame/issues/14Member<Fence> fence_;Member<CloseWatcher::WatcherStack> closewatcher_stack_;// If set, this window is a Document Picture in Picture window.// https://wicg.github.io/document-picture-in-picture/bool is_picture_in_picture_window_ = false;// The navigation id of a document is to identify navigation of special types// like bfcache navigation or soft navigation. It changes when navigations// of these types occur.String navigation_id_;// Records whether this window has obtained storage access. It cannot be// revoked once set to true.bool has_storage_access_ = false;// Tracks whether this window has shown a payment request without a user// activation. It cannot be revoked once set to true.// TODO(crbug.com/1439565): Move this bit to a new payments-specific// per-LocalDOMWindow class in the payments module.bool had_activationless_payment_request_ = false;
};template <>
struct DowncastTraits<LocalDOMWindow> {static bool AllowFrom(const ExecutionContext& context) {return context.IsWindow();}static bool AllowFrom(const DOMWindow& window) {return window.IsLocalDOMWindow();}
};inline String LocalDOMWindow::status() const {return status_;
}inline String LocalDOMWindow::defaultStatus() const {DCHECK(RuntimeEnabledFeatures::WindowDefaultStatusEnabled());return default_status_;
}}  // namespace blink#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_LOCAL_DOM_WINDOW_H_

3、window对象接口定义实现文件(v8):

out\Debug\gen\third_party\blink\renderer\bindings\modules\v8\v8_window.cc

out\Debug\gen\third_party\blink\renderer\bindings\modules\v8\v8_window.h

部分定义:

void SelfAttributeSetCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_DOMWindow_self_Setter");
BLINK_BINDINGS_TRACE_EVENT("Window.self.set");v8::Isolate* isolate = info.GetIsolate();
const char* const property_name = "self";
if (UNLIKELY(info.Length() < 1)) {const ExceptionContextType exception_context_type = ExceptionContextType::kAttributeSet;
const char* const class_like_name = "Window";
ExceptionState exception_state(isolate, exception_context_type, class_like_name, property_name);
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}// [Replaceable]
bool did_create;
v8::Local<v8::Object> v8_receiver = info.This();
v8::Local<v8::Context> current_context = isolate->GetCurrentContext();
v8::Local<v8::Value> v8_property_value = info[0];
if (!v8_receiver->CreateDataProperty(current_context, V8AtomicString(isolate, property_name), v8_property_value).To(&did_create)) {return;
}
}void DocumentAttributeGetCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_DOMWindow_document_Getter");
BLINK_BINDINGS_TRACE_EVENT("Window.document.get");v8::Local<v8::Object> v8_receiver = info.This();
LocalDOMWindow* blink_receiver = &UnsafeTo<LocalDOMWindow>(*V8Window::ToWrappableUnsafe(v8_receiver));
auto&& return_value = blink_receiver->document();
bindings::V8SetReturnValue(info, return_value, blink_receiver);
}

4、控制台输入window看下和c++代码对比效果:

相关文章:

Chromium 前端window对象c++实现定义

前端中window.document window.alert()等一些列方法和对象在c对应定义如下&#xff1a; 1、window对象接口定义文件window.idl third_party\blink\renderer\core\frame\window.idl // https://html.spec.whatwg.org/C/#the-window-object// FIXME: explain all uses of [Cros…...

【力扣算法题】每天一道,健康生活

2024年10月8日 参考github网站&#xff1a;代码随想录 1.二分查找 leetcode 视频 class Solution { public:int search(vector<int>& nums, int target) {int left 0;int right nums.size()-1;while(left<right){int middle (leftright)/2;if(nums[middle] …...

Android Camera系列(四):TextureView+OpenGL ES+Camera

别人贪婪时我恐惧&#xff0c;别人恐惧时我贪婪 Android Camera系列&#xff08;一&#xff09;&#xff1a;SurfaceViewCamera Android Camera系列&#xff08;二&#xff09;&#xff1a;TextureViewCamera Android Camera系列&#xff08;三&#xff09;&#xff1a;GLSur…...

03 django管理系统 - 部门管理 - 部门列表

部门管理 首先我们需要在models里定义Dept类 # 创建部门表 class Dept(models.Model):name models.CharField(max_length100)head models.CharField(max_length100)phone models.CharField(max_length15)email models.EmailField()address models.CharField(max_length2…...

L1 Sklearn 衍生概念辨析 - 回归/分类/聚类/降维

背景 前文中我们提到&#xff1a; Scikit-Learn 库的算法主要有四类&#xff1a;分类、回归、聚类、降维&#xff1a; 回归&#xff1a;线性回归、决策树回归、SVM回归、KNN 回归&#xff1b;集成回归&#xff1a;随机森林、Adaboost、GradientBoosting、Bagging、ExtraTrees。…...

【畅捷通-注册安全分析报告】

前言 由于网站注册入口容易被黑客攻击&#xff0c;存在如下安全问题&#xff1a; 暴力破解密码&#xff0c;造成用户信息泄露短信盗刷的安全问题&#xff0c;影响业务及导致用户投诉带来经济损失&#xff0c;尤其是后付费客户&#xff0c;风险巨大&#xff0c;造成亏损无底洞…...

TCP IP网络编程

文章目录 TCP IP网络编程一、基础知识&#xff08;TCP&#xff09;1&#xff09;Linux1. socket()2.bind()2.1前提2.2字节序与网络字节序2.3 字节序转换2.4 字符串信息转化成网络字节序的整数型2.5 INADDR_ANY 3.listen()4.accept()5.connect()6.案例小结6.1服务器端6.2 客户端…...

libssh2编译部署详解

libssh2编译部署详解 一、准备工作二、编译libssh2方法一:使用Autotools构建方法二:使用CMake构建三、验证安装四、使用libssh2五、结论libssh2是一个用于实现SSH2协议的开源库,它支持建立安全的远程连接、传输文件等操作。本文将详细介绍如何在Linux系统下编译和部署libssh…...

IPv4数据报的首部格式 -计算机网络

IPv4数据报的首部格式 Day22. IPv4数据报的首部格式 -计算机网络_4字节的整数倍-CSDN博客 IP数据报首部是4字节的整数倍 &#x1f33f;版本&#xff1a; 占4比特&#xff0c;表示IP协议的版本通信双方使用的IP协议必须一致&#xff0c;目前广泛使用的IP协议版本号上4&#xf…...

小米电机与STM32——CAN通信

背景介绍&#xff1a;为了利用小米电机&#xff0c;搭建机械臂的关节&#xff0c;需要学习小米电机的使用方法。计划采用STM32驱动小米电机&#xff0c;实现指定运动&#xff0c;为此需要了解他们之间的通信方式&#xff0c;指令写入方法等。花了很多时间学习&#xff0c;但网络…...

2.2.ReactOS系统KSERVICE_TABLE_DESCRIPTOR结构体的声明

2.2.ReactOS系统KSERVICE_TABLE_DESCRIPTOR结构体的声明 2.2.ReactOS系统KSERVICE_TABLE_DESCRIPTOR结构体的声明 文章目录 2.2.ReactOS系统KSERVICE_TABLE_DESCRIPTOR结构体的声明KSERVICE_TABLE_DESCRIPTOR系统调用表结构体的声明 KSERVICE_TABLE_DESCRIPTOR系统调用表结构体…...

前端接口报500如何解决 | 发生的原因以及处理步骤

接口500&#xff0c;通常指的是服务器内部错误&#xff08;Internal Server Error&#xff09;&#xff0c;是HTTP协议中的一个标准状态码。当服务器遇到无法处理的错误时&#xff0c;会返回这个状态码。这种错误可能涉及到服务器配置、服务器上的应用程序、服务器资源、数据库…...

图书馆自习室座位预约管理微信小程序+ssm(lw+演示+源码+运行)

摘 要 随着电子商务快速发展世界各地区,各个高校对图书馆也起来越重视.图书馆代表着一间学校或者地区的文化标志&#xff0c;因为图书馆丰富的图书资源能够带给我们重要的信息资源&#xff0c;图书馆管理系统是学校管理机制重要的一环&#xff0c;,面对这一世界性的新动向和新…...

谷歌-BERT-第一步:模型下载

1 需求 需求1&#xff1a;基于transformers库实现自动从Hugging Face下载模型 需求2&#xff1a;基于huggingface-hub库实现自动从Hugging Face下载模型 需求3&#xff1a;手动从Hugging Face下载模型 2 接口 3.1 需求1 示例一&#xff1a;下载到默认目录 from transform…...

FPGA实现PCIE采集电脑端视频缩放后转千兆UDP网络输出,基于XDMA+PHY芯片架构,提供3套工程源码和技术支持

目录 1、前言工程概述免责声明 2、相关方案推荐我已有的PCIE方案我这里已有的以太网方案本博已有的FPGA图像缩放方案 3、PCIE基础知识扫描4、工程详细设计方案工程设计原理框图电脑端视频PCIE视频采集QT上位机XDMA配置及使用XDMA中断模块FDMA图像缓存纯Verilog图像缩放模块详解…...

Hi3061M开发板——系统时钟频率

这里写目录标题 前言MCU时钟介绍PLLCRG_ConfigPLL时钟配置另附完整系统时钟结构图 前言 Hi3061M使用过程中&#xff0c;AD和APT输出&#xff0c;都需要考虑到时钟频率&#xff0c;特别是APT&#xff0c;关系到PWM的输出频率。于是就研究了下相关的时钟。 MCU时钟介绍 MCU共有…...

C++入门基础知识110—【关于C++ if...else 语句】

成长路上不孤单&#x1f60a;&#x1f60a;&#x1f60a;&#x1f60a;&#x1f60a;&#x1f60a; 【14后&#x1f60a;///C爱好者&#x1f60a;///持续分享所学&#x1f60a;///如有需要欢迎收藏转发///&#x1f60a;】 今日分享关于C if...else 语句的相关内容&#xff01…...

基于YOLO11深度学习的非机动车驾驶员头盔检测系统【python源码+Pyqt5界面+数据集+训练代码】深度学习实战、目标检测、卷积神经网络

《博主简介》 小伙伴们好&#xff0c;我是阿旭。专注于人工智能、AIGC、python、计算机视觉相关分享研究。 ✌更多学习资源&#xff0c;可关注公-仲-hao:【阿旭算法与机器学习】&#xff0c;共同学习交流~ &#x1f44d;感谢小伙伴们点赞、关注&#xff01; 《------往期经典推…...

图像分类-demo(Lenet),tensorflow和Alexnet

目录 demo(Lenet) 代码实现基本步骤&#xff1a; TensorFlow 一、核心概念 二、主要特点 三、简单实现 参数: 模型编译 模型训练 模型评估 Alexnet model.py train.py predict.py demo(Lenet) PyTorch提供了一个名为“torchvision”的附加库&#xff0c;其中包含…...

excel 单元格嵌入图片

1.图片右键,设置图片格式 2.属性 随单元格改为位置和大小 这样的话&#xff0c;图片就会嵌入到单元格&#xff0c;也会跟着单元格的大小而改变...

GitHub简介与安装使用入门教程

1、Git与GitHub的简介 Git是目前世界上最先进的分布式控制系统&#xff0c;它允许开发者跟踪和管理源代码的改动历史记录等&#xff0c;可以将你的代码恢复到某一个版本&#xff0c;支持多人协作开发。它的核心功能包括版本控制、分支管理、合并和冲突解决等&#xff0c;其操作…...

HTML(五)列表详解

在HTML中&#xff0c;列表可以分为两种&#xff0c;一种为有序列表。另一种为无序列表 今天就来详细讲解一下这两种列表如何实现&#xff0c;效果如何 1.有序列表 有序列表的标准格式如下&#xff1a; <ol><li>列表项一</li><li>列表项二</li>…...

SparkSQL介绍及使用

SparkSQL介绍及使用 一、什么是SparkSQL&#xff08;了解&#xff09; spark开发时可以使用rdd进行开发&#xff0c;spark还提供saprksql工具&#xff0c;将数据转为结构化数据进行操作 1-1 介绍 官网&#xff1a;https://spark.apache.org/sql/ Spark SQL是 Apache Spark 用于…...

【聚星文社】3.2版一键推文工具更新啦

【聚星文社】3.2版一键推文工具更新啦。调试了好几个通宵就是为了效果和质量。 旧版尽早更新新版&#xff0c;从此告别手搓&#xff01; 工具入口https://iimenvrieak.feishu.cn/docx/ZhRNdEWT6oGdCwxdhOPcdds7nof...

C++基础补充(03)C++20 的 std::format 函数

文章目录 1. 使用C20 std::format2. 基本用法3. 格式说明 1. 使用C20 std::format 需要将VisualStudio默认的标准修改为C20 菜单“项目”-“项目属性”&#xff0c;打开如下对话框 代码中加入头文件 2. 基本用法 通过占位符{}制定格式化的位置&#xff0c;后面传入变量 #…...

[论文笔记]DAPR: A Benchmark on Document-Aware Passage Retrieval

引言 今天带来论文DAPR: A Benchmark on Document-Aware Passage Retrieval的笔记。 本文提出了一个基准&#xff1a;文档感知段落检索(Document-Aware Passage Retrieval,DAPR)以及介绍了一些上下文段落表示的方法。 为了简单&#xff0c;下文中以翻译的口吻记录&#xff0c…...

Spring Boot知识管理:智能搜索与分析

3系统分析 3.1可行性分析 通过对本知识管理系统实行的目的初步调查和分析&#xff0c;提出可行性方案并对其一一进行论证。我们在这里主要从技术可行性、经济可行性、操作可行性等方面进行分析。 3.1.1技术可行性 本知识管理系统采用JAVA作为开发语言&#xff0c;Spring Boot框…...

操作系统(2) (进程调度/进程调度器类型/三种进程调度/调度算法)

目录 1. 介绍进程调度&#xff08;Introduction to Process Scheduling&#xff09; 2. 优先级调度&#xff08;Priority Scheduling&#xff09; 3. CPU 利用率&#xff08;CPU Utilization&#xff09; 4. 吞吐量&#xff08;Throughput&#xff09; 5. 周转时间&#xf…...

鸿蒙--知乎评论

这里我们将采用组件化的思想进行开发 在开发中默认展示的是首页也就是 pages/Index.ets页面 这里存放的是所有页面的配置文件,类似与uniapp中的pages.json 如果我们此时要更改默认显示Zh...

2024 - 两台CentOS服务器上的1000个Docker容器(每台500个)之间实现UDP通信(C语言版本)

两台CentOS服务器上的1000个Docker容器&#xff08;每台500个&#xff09;之间实现UDP通信(C语言版本) 给女朋友对象写得&#xff0c;她不会&#xff0c;我就写了一个 为了帮助您在两台CentOS服务器上的1000个Docker容器&#xff08;每台500个&#xff09;之间实现UDP通信&…...