2012-04-27 23:19:06 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
2024-04-30 17:45:07 +02:00
|
|
|
|
|
|
|
#include "cef/include/cef_dom.h"
|
2012-04-27 23:19:06 +02:00
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
namespace blink {
|
2017-07-27 01:19:27 +02:00
|
|
|
class WebLocalFrame;
|
2012-04-27 23:19:06 +02:00
|
|
|
class WebNode;
|
2019-03-13 22:27:37 +01:00
|
|
|
} // namespace blink
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
class CefBrowserImpl;
|
|
|
|
|
|
|
|
class CefDOMDocumentImpl : public CefDOMDocument {
|
|
|
|
public:
|
2017-07-27 01:19:27 +02:00
|
|
|
CefDOMDocumentImpl(CefBrowserImpl* browser, blink::WebLocalFrame* frame);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefDOMDocumentImpl() override;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
// CefDOMDocument methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
Type GetType() override;
|
|
|
|
CefRefPtr<CefDOMNode> GetDocument() override;
|
|
|
|
CefRefPtr<CefDOMNode> GetBody() override;
|
|
|
|
CefRefPtr<CefDOMNode> GetHead() override;
|
|
|
|
CefString GetTitle() override;
|
|
|
|
CefRefPtr<CefDOMNode> GetElementById(const CefString& id) override;
|
|
|
|
CefRefPtr<CefDOMNode> GetFocusedNode() override;
|
|
|
|
bool HasSelection() override;
|
|
|
|
int GetSelectionStartOffset() override;
|
|
|
|
int GetSelectionEndOffset() override;
|
|
|
|
CefString GetSelectionAsMarkup() override;
|
|
|
|
CefString GetSelectionAsText() override;
|
|
|
|
CefString GetBaseURL() override;
|
|
|
|
CefString GetCompleteURL(const CefString& partialURL) override;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
CefBrowserImpl* GetBrowser() { return browser_; }
|
2017-07-27 01:19:27 +02:00
|
|
|
blink::WebLocalFrame* GetFrame() { return frame_; }
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
// The document maintains a map of all existing node objects.
|
2013-11-08 22:28:56 +01:00
|
|
|
CefRefPtr<CefDOMNode> GetOrCreateNode(const blink::WebNode& node);
|
|
|
|
void RemoveNode(const blink::WebNode& node);
|
2012-04-27 23:19:06 +02:00
|
|
|
|
|
|
|
// Must be called before the object is destroyed.
|
|
|
|
void Detach();
|
|
|
|
|
|
|
|
// Verify that the object exists and is being accessed on the UI thread.
|
|
|
|
bool VerifyContext();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
CefBrowserImpl* browser_;
|
2017-07-27 01:19:27 +02:00
|
|
|
blink::WebLocalFrame* frame_;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
using NodeMap = std::map<blink::WebNode, CefDOMNode*>;
|
2012-04-27 23:19:06 +02:00
|
|
|
NodeMap node_map_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefDOMDocumentImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|