KHtml

kjs_mozilla.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2003 George Staikos ([email protected])
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #include "kjs_mozilla.h"
21 #include "kjs_mozilla.lut.h"
22 
23 
24 #include <klocalizedstring.h>
25 #include "khtml_debug.h"
26 
27 #include <kjs/lookup.h>
28 #include <khtml_part.h>
29 
30 using namespace KJS;
31 
32 namespace KJS
33 {
34 
35 const ClassInfo MozillaSidebarExtension::info = { "sidebar", nullptr, &MozillaSidebarExtensionTable, nullptr };
36 /*
37 @begin MozillaSidebarExtensionTable 1
38  addPanel MozillaSidebarExtension::addPanel DontDelete|Function 0
39 @end
40 */
41 }
42 KJS_IMPLEMENT_PROTOFUNC(MozillaSidebarExtensionFunc)
43 
44 MozillaSidebarExtension::MozillaSidebarExtension(ExecState *exec, KHTMLPart *p)
45  : m_part(p)
46 {
47  setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
48 }
49 
50 bool MozillaSidebarExtension::getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot &slot)
51 {
52 #ifdef KJS_VERBOSE
53  qCDebug(KHTML_LOG) << "MozillaSidebarExtension::get " << propertyName.ascii();
54 #endif
55  return getStaticPropertySlot<MozillaSidebarExtensionFunc, MozillaSidebarExtension, JSObject>
56  (exec, &MozillaSidebarExtensionTable, this, propertyName, slot);
57 }
58 
59 JSValue *MozillaSidebarExtension::getValueProperty(ExecState *exec, int token) const
60 {
61  Q_UNUSED(exec);
62  switch (token) {
63  default:
64  // qCDebug(KHTML_LOG) << "WARNING: Unhandled token in MozillaSidebarExtension::getValueProperty : " << token;
65  return jsNull();
66  }
67 }
68 
69 JSValue *MozillaSidebarExtensionFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
70 {
71  KJS_CHECK_THIS(KJS::MozillaSidebarExtension, thisObj);
72  MozillaSidebarExtension *mse = static_cast<MozillaSidebarExtension *>(thisObj);
73 
74  KHTMLPart *part = mse->part();
75  if (!part) {
76  return jsUndefined();
77  }
78 
79  // addPanel() id == 0
81  if (ext) {
82  QString url, name;
83  if (args.size() == 1) { // I've seen this, don't know if it's legal.
84  name.clear();
85  url = args[0]->toString(exec).qstring();
86  } else if (args.size() == 2 || args.size() == 3) {
87  name = args[0]->toString(exec).qstring();
88  url = args[1]->toString(exec).qstring();
89  // 2 is the "CURL" which I don't understand and don't think we need.
90  } else {
91  return jsBoolean(false);
92  }
93  emit ext->addWebSideBar(QUrl(url), name);
94  return jsBoolean(true);
95  }
96 
97  return jsUndefined();
98 }
99 
QString name(const QVariant &location)
This class is khtml&#39;s main class.
Definition: khtml_part.h:208
void addWebSideBar(const QUrl &url, const QString &name)
void clear()
KParts::BrowserExtension * browserExtension() const
Returns a pointer to the KParts::BrowserExtension.
const char * ascii() const
int size() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:48:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.