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>
|
|
|
|
#include "include/cef_dom.h"
|
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
namespace blink {
|
2012-04-27 23:19:06 +02:00
|
|
|
class WebFrame;
|
|
|
|
class WebNode;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CefBrowserImpl;
|
|
|
|
|
|
|
|
class CefDOMDocumentImpl : public CefDOMDocument {
|
|
|
|
public:
|
|
|
|
CefDOMDocumentImpl(CefBrowserImpl* browser,
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebFrame* 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_; }
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebFrame* 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_;
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebFrame* frame_;
|
2012-04-27 23:19:06 +02:00
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
typedef std::map<blink::WebNode, CefDOMNode*> NodeMap;
|
2012-04-27 23:19:06 +02:00
|
|
|
NodeMap node_map_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefDOMDocumentImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_DOM_DOCUMENT_IMPL_H_
|