KHtml

kjs_audio.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2006 Germain Garand <[email protected]>
4  * Copyright (C) 2007 Matthias Kretz <[email protected]>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "ecma/kjs_audio.h"
22 
23 #include <html/HTMLAudioElement.h>
24 
25 namespace KJS
26 {
27 
28 AudioConstructorImp::AudioConstructorImp(ExecState *exec, DOM::DocumentImpl *d)
29  : JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()), doc(d)
30 {
31 }
32 
33 bool AudioConstructorImp::implementsConstruct() const
34 {
35  return true;
36 }
37 
38 JSObject *AudioConstructorImp::construct(ExecState *exec, const List &list)
39 {
40  khtml::HTMLAudioElement *audio = static_cast<khtml::HTMLAudioElement *>(doc->createElement("audio"));
41 
42  QString url;
43  if (list.size() > 0) {
44  url = list.at(0)->toString(exec).qstring();
45  if (!url.isEmpty()) {
46  audio->setSrc(url);
47  }
48  }
49  return getDOMNode(exec, audio)->getObject();
50 }
51 
52 } // namespace KJS
53 
bool isEmpty() const const
const QChar at(int position) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.