1/*
2 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef WebHitTestResult_h
21#define WebHitTestResult_h
22
23#include "APIObject.h"
24#include <WebCore/IntRect.h>
25#include <wtf/Forward.h>
26#include <wtf/PassRefPtr.h>
27#include <wtf/RefPtr.h>
28#include <wtf/text/WTFString.h>
29
30namespace IPC {
31class ArgumentDecoder;
32class ArgumentEncoder;
33}
34
35namespace WebCore {
36class HitTestResult;
37}
38
39namespace WebKit {
40
41class WebFrame;
42
43class WebHitTestResult : public API::ObjectImpl<API::Object::Type::HitTestResult> {
44public:
45    struct Data {
46        String absoluteImageURL;
47        String absolutePDFURL;
48        String absoluteLinkURL;
49        String absoluteMediaURL;
50        String linkLabel;
51        String linkTitle;
52        bool isContentEditable;
53        WebCore::IntRect elementBoundingBox;
54        bool isScrollbar;
55
56        Data();
57        explicit Data(const WebCore::HitTestResult&);
58        ~Data();
59
60        void encode(IPC::ArgumentEncoder&) const;
61        static bool decode(IPC::ArgumentDecoder&, WebHitTestResult::Data&);
62
63        WebCore::IntRect elementBoundingBoxInWindowCoordinates(const WebCore::HitTestResult&);
64    };
65
66    static PassRefPtr<WebHitTestResult> create(const WebHitTestResult::Data&);
67
68    String absoluteImageURL() const { return m_data.absoluteImageURL; }
69    String absolutePDFURL() const { return m_data.absolutePDFURL; }
70    String absoluteLinkURL() const { return m_data.absoluteLinkURL; }
71    String absoluteMediaURL() const { return m_data.absoluteMediaURL; }
72
73    String linkLabel() const { return m_data.linkLabel; }
74    String linkTitle() const { return m_data.linkTitle; }
75
76    bool isContentEditable() const { return m_data.isContentEditable; }
77
78    WebCore::IntRect elementBoundingBox() const { return m_data.elementBoundingBox; }
79
80    bool isScrollbar() const { return m_data.isScrollbar; }
81
82private:
83    explicit WebHitTestResult(const WebHitTestResult::Data& hitTestResultData)
84        : m_data(hitTestResultData)
85    {
86    }
87
88    Data m_data;
89};
90
91} // namespace WebKit
92
93#endif // WebHitTestResult_h
94