LayoutTests/ChangeLog

 12011-02-03 Adam Bergkvist <adam.bergkvist@ericsson.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Introduce the device element as an experimental feature
 6 https://bugs.webkit.org/show_bug.cgi?id=47264
 7
 8 Test that device is a void element.
 9
 10 * html5lib/resources/webkit02.dat:
 11
1122011-02-03 Csaba Osztrogonác <ossy@webkit.org>
213
314 Unreviewed, rebaseline Qt svg tests after r77485.

LayoutTests/html5lib/resources/webkit02.dat

9292| <tr>
9393| <td>
9494| "A"
 95
 96#data
 97<device><div></div>
 98#errors
 99#document
 100| <html>
 101| <head>
 102| <body>
 103| <device>
 104| <div>

Source/WebCore/ChangeLog

 12011-02-03 Adam Bergkvist <adam.bergkvist@ericsson.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Introduce the device element as an experimental feature
 6 https://bugs.webkit.org/show_bug.cgi?id=47264
 7
 8 Added implementation of the device element
 9 http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#devices
 10
 11 Functionality currently not testable (parser test added)
 12
 13 * bindings/js/JSHTMLDeviceElementCustom.cpp: Added.
 14 (WebCore::JSHTMLDeviceElement::data):
 15 * css/html.css:
 16 (button, device):
 17 (input, textarea, keygen, select, button, isindex, meter, progress, device):
 18 (input, textarea, keygen, select, button, isindex, datagrid, device):
 19 (input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button, device):
 20 (input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active, input[type="file"]:active::-webkit-file-upload-button, button:active, device:active):
 21 * device/DeviceData.h: Added.
 22 * device/DeviceDialogClient.h: Added.
 23 * device/DeviceList.cpp: Added.
 24 (WebCore::DeviceList::updateSelections):
 25 (WebCore::DeviceList::selectedEntries):
 26 (WebCore::DeviceList::selectionsMatch):
 27 (WebCore::DeviceList::types):
 28 (WebCore::DeviceList::get):
 29 (WebCore::DeviceList::length):
 30 * device/DeviceList.h: Added.
 31 (WebCore::DeviceListEntry::create):
 32 (WebCore::DeviceListEntry::id):
 33 (WebCore::DeviceListEntry::type):
 34 (WebCore::DeviceListEntry::displayName):
 35 (WebCore::DeviceListEntry::selected):
 36 (WebCore::DeviceListEntry::setSelected):
 37 (WebCore::DeviceListEntry::sameEntry):
 38 (WebCore::DeviceListEntry::DeviceListEntry):
 39 (WebCore::DeviceList::create):
 40 (WebCore::DeviceList::DeviceList):
 41 * device/DeviceManagerProxy.cpp: Added.
 42 (WebCore::deviceManagerProxy):
 43 (WebCore::DeviceManagerProxy::DeviceManagerProxy):
 44 (WebCore::DeviceManagerProxy::streamDeviceManager):
 45 (WebCore::DeviceManagerProxy::createDeviceList):
 46 (WebCore::DeviceManagerProxy::createDeviceData):
 47 * device/DeviceManagerProxy.h: Added.
 48 * device/DeviceTypeInfo.cpp: Added.
 49 (WebCore::deviceTypeInfo):
 50 * device/DeviceTypeInfo.h: Added.
 51 (WebCore::DeviceTypeInfo::DeviceTypeInfo):
 52 (WebCore::DeviceTypeInfo::deviceTypeLabel):
 53 (WebCore::DeviceTypeInfo::supportsMultipleSelections):
 54 * html/HTMLDeviceElement.cpp: Added.
 55 (WebCore::createDeviceTypeMap):
 56 (WebCore::HTMLDeviceElement::HTMLDeviceElement):
 57 (WebCore::HTMLDeviceElement::~HTMLDeviceElement):
 58 (WebCore::HTMLDeviceElement::create):
 59 (WebCore::HTMLDeviceElement::type):
 60 (WebCore::HTMLDeviceElement::setType):
 61 (WebCore::HTMLDeviceElement::createRenderer):
 62 (WebCore::HTMLDeviceElement::attach):
 63 (WebCore::HTMLDeviceElement::parseMappedAttribute):
 64 (WebCore::HTMLDeviceElement::updateDeviceType):
 65 (WebCore::HTMLDeviceElement::defaultEventHandler):
 66 (WebCore::HTMLDeviceElement::runDialog):
 67 (WebCore::HTMLDeviceElement::selectionsMade):
 68 (WebCore::HTMLDeviceElement::supportsFocus):
 69 (WebCore::HTMLDeviceElement::isFocusable):
 70 (WebCore::HTMLDeviceElement::isKeyboardFocusable):
 71 (WebCore::HTMLDeviceElement::isMouseFocusable):
 72 (WebCore::DeviceTypeNames::media):
 73 (WebCore::DeviceTypeNames::audio):
 74 (WebCore::DeviceTypeNames::video):
 75 * html/HTMLDeviceElement.h: Added.
 76 (WebCore::HTMLDeviceElement::data):
 77 (WebCore::HTMLDeviceElement::deviceType):
 78 (WebCore::HTMLDeviceElement::canStartSelection):
 79 * html/HTMLDeviceElement.idl: Added.
 80 * html/HTMLElement.cpp:
 81 (WebCore::HTMLElement::ieForbidsInsertHTML):
 82 * html/HTMLTagNames.in:
 83 * html/parser/HTMLTreeBuilder.cpp:
 84 (WebCore::HTMLTreeBuilder::processStartTagForInBody):
 85 * loader/EmptyClients.h:
 86 (WebCore::EmptyChromeClient::runDeviceDialog):
 87 * page/Chrome.cpp:
 88 (WebCore::Chrome::runDeviceDialog):
 89 * page/Chrome.h:
 90 * page/ChromeClient.h:
 91 * page/DOMWindow.idl:
 92 * platform/LocalizedStrings.h:
 93 * platform/device/StreamDeviceManager.cpp: Added.
 94 (WebCore::NullStreamDeviceManagerPrivate::create):
 95 (WebCore::NullStreamDeviceManagerPrivate::createDeviceList):
 96 (WebCore::StreamDeviceManager::StreamDeviceManager):
 97 (WebCore::StreamDeviceManager::createDeviceList):
 98 * platform/device/StreamDeviceManager.h: Added.
 99 (WebCore::StreamDeviceManager::create):
 100 * platform/device/StreamDeviceManagerPrivate.h: Added.
 101
11022011-02-02 Pavel Podivilov <podivilov@chromium.org>
2103
3104 Reviewed by Pavel Feldman.

Source/WebCore/bindings/js/JSHTMLDeviceElementCustom.cpp

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(DEVICE_ELEMENT)
 35
 36#include "JSHTMLDeviceElement.h"
 37
 38#include "DeviceData.h"
 39#include "HTMLDeviceElement.h"
 40
 41using namespace JSC;
 42
 43namespace WebCore {
 44
 45JSValue JSHTMLDeviceElement::data(ExecState* exec) const
 46{
 47 HTMLDeviceElement* device = static_cast<HTMLDeviceElement*>(impl());
 48 DeviceData* data = device->data();
 49 if (!data)
 50 return jsNull();
 51
 52 // FIXME - implement the Stream API (Bug 47265)
 53 // if (Stream* stream = data->toStream())
 54 // return toJS(exec, globalObject(), stream);
 55
 56 // ASSERT_NOT_REACHED();
 57 return jsNull();
 58}
 59
 60} // namespace WebCore
 61
 62#endif

Source/WebCore/css/html.css

@@fieldset {
348348 border: 2px groove ThreeDFace
349349}
350350
351 button {
 351button, device {
352352 -webkit-appearance: button;
353353}
354354
355355/* Form controls don't go vertical. */
356 input, textarea, keygen, select, button, isindex, meter, progress {
 356input, textarea, keygen, select, button, isindex, meter, progress, device {
357357 -webkit-block-flow: tb !important;
358358}
359359
360 input, textarea, keygen, select, button, isindex, datagrid {
 360input, textarea, keygen, select, button, isindex, datagrid, device {
361361 margin: 0__qem;
362362 font: -webkit-small-control;
363363 color: initial;

@@input[type="button"], input[type="submit"], input[type="reset"], input[type="fil
484484 white-space: pre
485485}
486486
487 input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button {
 487input[type="button"], input[type="submit"], input[type="reset"], input[type="file"]::-webkit-file-upload-button, button, device {
488488 -webkit-box-align: center;
489489 text-align: center;
490490 cursor: default;

@@select:disabled, keygen:disabled, optgroup:disabled, option:disabled, datagrid:d
513513 color: GrayText
514514}
515515
516 input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active, input[type="file"]:active::-webkit-file-upload-button, button:active {
 516input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active, input[type="file"]:active::-webkit-file-upload-button, button:active, device:active {
517517 border-style: inset
518518}
519519

Source/WebCore/device/DeviceData.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef DeviceData_h
 33#define DeviceData_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include <wtf/RefCounted.h>
 38#include <wtf/RefPtr.h>
 39
 40namespace WebCore {
 41
 42class Stream;
 43
 44class DeviceData : public RefCounted<DeviceData> {
 45public:
 46 // FIXME - implement the Stream API (Bug 47265)
 47 // virtual Stream* toStream() { return 0; }
 48};
 49
 50} // namespace WebCore
 51
 52#endif // ENABLE(DEVICE_ELEMENT)
 53
 54#endif // DeviceData_h

Source/WebCore/device/DeviceDialogClient.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef DeviceDialogClient_h
 33#define DeviceDialogClient_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "DeviceList.h"
 38#include <wtf/PassRefPtr.h>
 39
 40namespace WebCore {
 41
 42class DeviceDialogClient {
 43public:
 44 virtual DeviceType deviceType() const = 0;
 45 virtual void selectionsMade(PassRefPtr<DeviceList>) = 0;
 46};
 47
 48} // namespace WebCore
 49
 50#endif // ENABLE(DEVICE_ELEMENT)
 51
 52#endif // DeviceDialogClient_h

Source/WebCore/device/DeviceList.cpp

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(DEVICE_ELEMENT)
 35
 36#include "DeviceList.h"
 37
 38namespace WebCore {
 39
 40void DeviceList::updateSelections(DeviceList* referenceList)
 41{
 42 Vector<RefPtr<DeviceListEntry> > selectedEntries = referenceList->selectedEntries();
 43
 44 for (size_t i = 0; !selectedEntries.isEmpty() && i < m_listEntries.size(); i++) {
 45 for (size_t j = 0; j < selectedEntries.size(); j++) {
 46 if (selectedEntries[j]->sameEntry(m_listEntries[i].get())) {
 47 m_listEntries[i]->setSelected(true);
 48 selectedEntries.remove(j);
 49 break;
 50 }
 51 }
 52 }
 53}
 54
 55Vector<RefPtr<DeviceListEntry> > DeviceList::selectedEntries()
 56{
 57 Vector<RefPtr<DeviceListEntry> > selectedEntries;
 58
 59 for (size_t i = 0; i < m_listEntries.size(); i++)
 60 if (m_listEntries[i]->selected())
 61 selectedEntries.append(m_listEntries[i]);
 62
 63 return selectedEntries;
 64}
 65
 66bool DeviceList::selectionsMatch(DeviceList* other)
 67{
 68 Vector<RefPtr<DeviceListEntry> > otherSelectedEntries = other->selectedEntries();
 69
 70 for (int i = static_cast<int>(m_listEntries.size()) - 1; i >= 0; i--) {
 71 int j;
 72 for (j = static_cast<int>(otherSelectedEntries.size()) - 1; j >= 0; j--) {
 73 if (otherSelectedEntries[j]->sameEntry(m_listEntries[i].get())) {
 74 if (!m_listEntries[i]->selected())
 75 return false;
 76 otherSelectedEntries.remove(j);
 77 break;
 78 }
 79 }
 80 if (j < 0 && m_listEntries[i]->selected())
 81 return false;
 82 }
 83 return true;
 84}
 85
 86Vector<DeviceType> DeviceList::types()
 87{
 88 Vector<DeviceType> types;
 89
 90 for (size_t i = 0; i < m_listEntries.size(); i++)
 91 if (types.find(m_listEntries[i]->type()) == WTF::notFound)
 92 types.append(m_listEntries[i]->type());
 93
 94 return types;
 95}
 96
 97DeviceListEntry* DeviceList::get(int index)
 98{
 99 return m_listEntries[index].get();
 100}
 101
 102int DeviceList::length()
 103{
 104 return m_listEntries.size();
 105}
 106
 107} // namespace WebCore
 108
 109#endif // ENABLE(DEVICE_ELEMENT)

Source/WebCore/device/DeviceList.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef DeviceList_h
 33#define DeviceList_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "DeviceTypeInfo.h"
 38#include <wtf/RefCounted.h>
 39#include <wtf/RefPtr.h>
 40#include <wtf/Vector.h>
 41
 42namespace WebCore {
 43
 44class DeviceListEntry : public RefCounted<DeviceListEntry> {
 45public:
 46 static PassRefPtr<DeviceListEntry> create(const String& id, const DeviceType type, const String& displayName)
 47 {
 48 return adoptRef(new DeviceListEntry(id, type, displayName));
 49 }
 50
 51 String id() { return m_id; }
 52 DeviceType type() { return m_type; }
 53 String displayName() { return m_displayName; }
 54
 55 bool selected() { return m_selected; }
 56 void setSelected(bool selected) { m_selected = selected; }
 57
 58 bool sameEntry(DeviceListEntry* other)
 59 {
 60 return m_id == other->m_id && m_displayName == other->m_displayName && m_type == other->m_type;
 61 }
 62
 63private:
 64 DeviceListEntry(const String& id, DeviceType type, const String& displayName)
 65 : m_id(id)
 66 , m_type(type)
 67 , m_displayName(displayName)
 68 , m_selected(false) { }
 69
 70 String m_id;
 71 DeviceType m_type;
 72 String m_displayName;
 73 bool m_selected;
 74};
 75
 76class DeviceList : public RefCounted<DeviceList> {
 77public:
 78 static PassRefPtr<DeviceList> create(const Vector<RefPtr<DeviceListEntry> >& listEntries)
 79 {
 80 return adoptRef(new DeviceList(listEntries));
 81 }
 82
 83 void updateSelections(DeviceList* referenceList);
 84 Vector<RefPtr<DeviceListEntry> > selectedEntries();
 85 bool selectionsMatch(DeviceList* other);
 86 Vector<DeviceType> types();
 87
 88 DeviceListEntry* get(int index);
 89 int length();
 90
 91private:
 92 DeviceList(const Vector<RefPtr<DeviceListEntry> >& listEntries)
 93 : m_listEntries(listEntries) { }
 94
 95 Vector<RefPtr<DeviceListEntry> > m_listEntries;
 96};
 97
 98} // namespace WebCore
 99
 100#endif // ENABLE(DEVICE_ELEMENT)
 101
 102#endif // DeviceList_h

Source/WebCore/device/DeviceManagerProxy.cpp

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(DEVICE_ELEMENT)
 35
 36#include "DeviceManagerProxy.h"
 37
 38namespace WebCore {
 39
 40DeviceManagerProxy& deviceManagerProxy()
 41{
 42 DEFINE_STATIC_LOCAL(DeviceManagerProxy, instance, ());
 43 return instance;
 44}
 45
 46DeviceManagerProxy::DeviceManagerProxy()
 47 : m_streamDeviceManager(0)
 48{
 49}
 50
 51StreamDeviceManager* DeviceManagerProxy::streamDeviceManager()
 52{
 53 if (!m_streamDeviceManager)
 54 m_streamDeviceManager = StreamDeviceManager::create();
 55 return m_streamDeviceManager.get();
 56}
 57
 58PassRefPtr<DeviceList> DeviceManagerProxy::createDeviceList(const DeviceType type)
 59{
 60 switch (type) {
 61 case MediaDeviceType:
 62 case AudioDeviceType:
 63 case VideoDeviceType:
 64 return streamDeviceManager()->createDeviceList(type);
 65 default:
 66 return DeviceList::create(Vector<RefPtr<DeviceListEntry> >());
 67 }
 68}
 69
 70PassRefPtr<DeviceData> DeviceManagerProxy::createDeviceData(DeviceList* deviceList)
 71{
 72 ASSERT(deviceList->length());
 73 DeviceType type = deviceList->get(0)->type();
 74
 75 switch (type) {
 76 case MediaDeviceType:
 77 case AudioDeviceType:
 78 case VideoDeviceType:
 79 // FIXME - implement the Stream API (Bug 47265)
 80 return 0;
 81 default:
 82 ASSERT_NOT_REACHED();
 83 }
 84
 85 return 0;
 86}
 87
 88} // namespace WebCore
 89
 90#endif // ENABLE(DEVICE_ELEMENT)

Source/WebCore/device/DeviceManagerProxy.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef DeviceManagerProxy_h
 33#define DeviceManagerProxy_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "DeviceData.h"
 38#include "DeviceList.h"
 39#include "StreamDeviceManager.h"
 40
 41namespace WebCore {
 42
 43class DeviceManagerProxy {
 44public:
 45 DeviceManagerProxy();
 46
 47 StreamDeviceManager* streamDeviceManager();
 48
 49 PassRefPtr<DeviceList> createDeviceList(const DeviceType);
 50 PassRefPtr<DeviceData> createDeviceData(DeviceList*);
 51
 52private:
 53 RefPtr<StreamDeviceManager> m_streamDeviceManager;
 54};
 55
 56DeviceManagerProxy& deviceManagerProxy();
 57
 58} // namespace WebCore
 59
 60#endif // ENABLE(DEVICE_ELEMENT)
 61
 62#endif // DeviceManagerProxy_h

Source/WebCore/device/DeviceTypeInfo.cpp

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(DEVICE_ELEMENT)
 35
 36#include "DeviceTypeInfo.h"
 37
 38namespace WebCore {
 39
 40const DeviceTypeInfo& deviceTypeInfo(DeviceType type)
 41{
 42 static const DeviceTypeInfo deviceInfoList[] = {
 43 DeviceTypeInfo("Media", false),
 44 DeviceTypeInfo("Audio", false),
 45 DeviceTypeInfo("Video", false)
 46 };
 47
 48 ASSERT(type >= 0 && type < UnknownDeviceType);
 49 return deviceInfoList[type];
 50}
 51
 52} // namespace WebCore
 53
 54#endif // ENABLE(DEVICE_ELEMENT)

Source/WebCore/device/DeviceTypeInfo.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef DeviceTypeInfo_h
 33#define DeviceTypeInfo_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "PlatformString.h"
 38
 39namespace WebCore {
 40
 41enum DeviceType {
 42 MediaDeviceType,
 43 AudioDeviceType,
 44 VideoDeviceType,
 45 UnknownDeviceType
 46};
 47
 48class DeviceTypeInfo {
 49public:
 50 DeviceTypeInfo(String deviceTypeLabel, bool supportsMultipleSelections)
 51 : m_deviceTypeLabel(deviceTypeLabel)
 52 , m_supportsMultipleSelections(supportsMultipleSelections)
 53 { }
 54
 55 String deviceTypeLabel() const { return m_deviceTypeLabel; }
 56 bool supportsMultipleSelections() const { return m_supportsMultipleSelections; }
 57
 58private:
 59 String m_deviceTypeLabel;
 60 bool m_supportsMultipleSelections;
 61};
 62
 63const DeviceTypeInfo& deviceTypeInfo(DeviceType);
 64
 65} // namespace WebCore
 66
 67#endif // ENABLE(DEVICE_ELEMENT)
 68
 69#endif // DeviceTypeInfo_h

Source/WebCore/html/HTMLDeviceElement.cpp

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(DEVICE_ELEMENT)
 35
 36#include "HTMLDeviceElement.h"
 37
 38#include "Chrome.h"
 39#include "DeviceManagerProxy.h"
 40#include "Document.h"
 41#include "Frame.h"
 42#include "HTMLNames.h"
 43#include "KeyboardEvent.h"
 44#include "LocalizedStrings.h"
 45#include "Page.h"
 46#include "PlatformString.h"
 47#include "RenderButton.h"
 48#include <wtf/HashMap.h>
 49#include <wtf/text/AtomicStringHash.h>
 50
 51namespace WebCore {
 52
 53using namespace HTMLNames;
 54
 55typedef HashMap<String, DeviceType, CaseFoldingHash> DeviceTypeMap;
 56
 57static PassOwnPtr<DeviceTypeMap> createDeviceTypeMap()
 58{
 59 OwnPtr<DeviceTypeMap> map = adoptPtr(new DeviceTypeMap);
 60 map->add(DeviceTypeNames::media(), MediaDeviceType);
 61 map->add(DeviceTypeNames::audio(), AudioDeviceType);
 62 map->add(DeviceTypeNames::video(), VideoDeviceType);
 63 return map.release();
 64}
 65
 66HTMLDeviceElement::HTMLDeviceElement(const QualifiedName& tagName, Document* doc)
 67 : HTMLElement(tagName, doc)
 68 , m_data(0)
 69 , m_deviceList(0)
 70{
 71 ASSERT(hasTagName(deviceTag));
 72}
 73
 74HTMLDeviceElement::~HTMLDeviceElement()
 75{
 76}
 77
 78PassRefPtr<HTMLDeviceElement> HTMLDeviceElement::create(Document* document)
 79{
 80 return adoptRef(new HTMLDeviceElement(deviceTag, document));
 81}
 82
 83PassRefPtr<HTMLDeviceElement> HTMLDeviceElement::create(const QualifiedName& tagName, Document* document)
 84{
 85 return adoptRef(new HTMLDeviceElement(tagName, document));
 86}
 87
 88String HTMLDeviceElement::type() const
 89{
 90 return getAttribute(typeAttr);
 91}
 92
 93void HTMLDeviceElement::setType(const String& type)
 94{
 95 setAttribute(typeAttr, type);
 96}
 97
 98RenderObject* HTMLDeviceElement::createRenderer(RenderArena* arena, RenderStyle*)
 99{
 100 return new (arena) RenderButton(this);
 101}
 102
 103void HTMLDeviceElement::attach()
 104{
 105 ASSERT(!attached());
 106
 107 HTMLElement::attach();
 108
 109 if (renderer())
 110 static_cast<RenderButton*>(renderer())->setText(deviceElementButtonLabel());
 111}
 112
 113void HTMLDeviceElement::parseMappedAttribute(Attribute* attr)
 114{
 115 if (attr->name() == typeAttr)
 116 updateDeviceType();
 117 else
 118 HTMLElement::parseMappedAttribute(attr);
 119}
 120
 121void HTMLDeviceElement::updateDeviceType()
 122{
 123 static const DeviceTypeMap* deviceTypeMap = createDeviceTypeMap().leakPtr();
 124 const AtomicString& typeString = fastGetAttribute(typeAttr);
 125
 126 DeviceTypeMap::const_iterator result = deviceTypeMap->find(typeString);
 127 m_deviceType = result != deviceTypeMap->end() ? result->second : UnknownDeviceType;
 128}
 129
 130void HTMLDeviceElement::defaultEventHandler(Event* evt)
 131{
 132 if (evt->type() == eventNames().DOMActivateEvent) {
 133 runDialog();
 134 evt->setDefaultHandled();
 135 return;
 136 }
 137
 138 if (evt->isKeyboardEvent()) {
 139 KeyboardEvent* keyEvent = static_cast<KeyboardEvent*>(evt);
 140
 141 if (evt->type() == eventNames().keypressEvent) {
 142 switch (keyEvent->charCode()) {
 143 case '\r':
 144 dispatchSimulatedClick(evt);
 145 case ' ':
 146 evt->setDefaultHandled();
 147 return;
 148 }
 149 } else if (keyEvent->keyIdentifier() == "U+0020") {
 150 if (evt->type() == eventNames().keydownEvent)
 151 setActive(true, true);
 152 else { // keyupEvent
 153 if (active())
 154 dispatchSimulatedClick(evt);
 155 evt->setDefaultHandled();
 156 }
 157 return;
 158 }
 159 }
 160 HTMLElement::defaultEventHandler(evt);
 161}
 162
 163void HTMLDeviceElement::runDialog()
 164{
 165 Frame* frame = document()->frame();
 166 if (!frame || !frame->loader()->isProcessingUserGesture())
 167 return;
 168
 169 Page* page = frame->page();
 170 if (!page)
 171 return;
 172 if (Chrome* chrome = page->chrome())
 173 chrome->runDeviceDialog(m_deviceList.get(), this);
 174}
 175
 176void HTMLDeviceElement::selectionsMade(PassRefPtr<DeviceList> prpNewDeviceList)
 177{
 178 RefPtr<DeviceList> newDeviceList = prpNewDeviceList;
 179 bool hasSelections = newDeviceList->selectedEntries().size();
 180 bool hasChanged = m_deviceList ? !newDeviceList->selectionsMatch(m_deviceList.get()) : hasSelections;
 181 m_deviceList = newDeviceList;
 182
 183 if (hasChanged) {
 184 m_data = hasSelections ? deviceManagerProxy().createDeviceData(m_deviceList.get()) : 0;
 185 dispatchEvent(Event::create(eventNames().changeEvent, true, false));
 186 }
 187}
 188
 189bool HTMLDeviceElement::supportsFocus() const
 190{
 191 return true;
 192}
 193
 194bool HTMLDeviceElement::isFocusable() const
 195{
 196 return renderer() && renderer()->isBox() && !toRenderBox(renderer())->size().isEmpty()
 197 && HTMLElement::isFocusable();
 198}
 199
 200bool HTMLDeviceElement::isKeyboardFocusable(KeyboardEvent* event) const
 201{
 202 return isFocusable() && document()->frame()
 203 && document()->frame()->eventHandler()->tabsToAllControls(event);
 204}
 205
 206bool HTMLDeviceElement::isMouseFocusable() const
 207{
 208#if PLATFORM(GTK) || PLATFORM(QT)
 209 return HTMLElement::isMouseFocusable();
 210#else
 211 return false;
 212#endif
 213}
 214
 215namespace DeviceTypeNames {
 216
 217const AtomicString& media()
 218{
 219 DEFINE_STATIC_LOCAL(AtomicString, name, ("media"));
 220 return name;
 221}
 222
 223const AtomicString& audio()
 224{
 225 DEFINE_STATIC_LOCAL(AtomicString, name, ("audio"));
 226 return name;
 227}
 228
 229const AtomicString& video()
 230{
 231 DEFINE_STATIC_LOCAL(AtomicString, name, ("video"));
 232 return name;
 233}
 234
 235} // namespace WebCore::DeviceTypeNames
 236
 237} // namespace WebCore
 238
 239#endif

Source/WebCore/html/HTMLDeviceElement.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef HTMLDeviceElement_h
 33#define HTMLDeviceElement_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "DeviceData.h"
 38#include "DeviceDialogClient.h"
 39#include "HTMLElement.h"
 40
 41namespace WebCore {
 42
 43class HTMLDeviceElement : public HTMLElement, DeviceDialogClient {
 44public:
 45 static PassRefPtr<HTMLDeviceElement> create(Document*);
 46 static PassRefPtr<HTMLDeviceElement> create(const QualifiedName&, Document*);
 47 ~HTMLDeviceElement();
 48
 49 String type() const;
 50 void setType(const String&);
 51
 52 DeviceData* data() const { return m_data.get(); }
 53
 54 virtual bool isFocusable() const;
 55
 56 virtual DeviceType deviceType() const { return m_deviceType; }
 57 virtual void selectionsMade(PassRefPtr<DeviceList>);
 58
 59protected:
 60 virtual void attach();
 61
 62 virtual bool isKeyboardFocusable(KeyboardEvent*) const;
 63 virtual bool isMouseFocusable() const;
 64
 65private:
 66 HTMLDeviceElement(const QualifiedName&, Document*);
 67
 68 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 69
 70 virtual void parseMappedAttribute(Attribute*);
 71 void updateDeviceType();
 72 virtual void defaultEventHandler(Event*);
 73 void runDialog();
 74
 75 virtual bool supportsFocus() const;
 76 virtual bool canStartSelection() const { return false; }
 77
 78 RefPtr<DeviceData> m_data;
 79 DeviceType m_deviceType;
 80 RefPtr<DeviceList> m_deviceList;
 81};
 82
 83namespace DeviceTypeNames {
 84
 85const AtomicString& media();
 86const AtomicString& audio();
 87const AtomicString& video();
 88
 89} // namespace WebCore::DeviceTypeNames
 90
 91} // namespace WebCore
 92
 93#endif
 94#endif

Source/WebCore/html/HTMLDeviceElement.idl

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32module html {
 33
 34 interface [Conditional=DEVICE_ELEMENT] HTMLDeviceElement : HTMLElement {
 35 attribute [ConvertNullToNullString] DOMString type;
 36 readonly attribute [CustomGetter] any data;
 37 };
 38
 39}

Source/WebCore/html/HTMLElement.cpp

@@bool HTMLElement::ieForbidsInsertHTML() const
8989 || hasLocalName(dcellTag)
9090 || hasLocalName(dcolTag)
9191#endif
 92#if ENABLE(DEVICE_ELEMENT)
 93 || hasLocalName(deviceTag)
 94#endif
9295 || hasLocalName(embedTag)
9396 || hasLocalName(frameTag)
9497 || hasLocalName(hrTag)

Source/WebCore/html/HTMLTagNames.in

@@command interfaceName=HTMLElement
3232datagrid interfaceName=HTMLDataGridElement, conditional=DATAGRID
3333datalist interfaceName=HTMLDataListElement, conditional=DATALIST
3434dcell interfaceName=HTMLDataGridCellElement, conditional=DATAGRID
 35device conditional=DEVICE_ELEMENT
3536dcol interfaceName=HTMLDataGridColElement, conditional=DATAGRID
3637drow interfaceName=HTMLDataGridRowElement, conditional=DATAGRID
3738dd interfaceName=HTMLElement

Source/WebCore/html/parser/HTMLTreeBuilder.cpp

@@void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken& token)
892892 }
893893 if (token.name() == areaTag
894894 || token.name() == brTag
 895 || token.name() == deviceTag
895896 || token.name() == embedTag
896897 || token.name() == imgTag
897898 || token.name() == keygenTag

Source/WebCore/loader/EmptyClients.h

@@public:
190190 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) { }
191191 virtual void chooseIconForFiles(const Vector<String>&, FileChooser*) { }
192192
 193#if ENABLE(DEVICE_ELEMENT)
 194 virtual void runDeviceDialog(DeviceList*, DeviceDialogClient*) { }
 195#endif
 196
193197 virtual void formStateDidChange(const Node*) { }
194198
195199 virtual void formDidFocus(const Node*) { }

Source/WebCore/page/Chrome.cpp

@@void Chrome::chooseIconForFiles(const Vector<String>& filenames, FileChooser* fi
435435 m_client->chooseIconForFiles(filenames, fileChooser);
436436}
437437
 438#if ENABLE(DEVICE_ELEMENT)
 439void Chrome::runDeviceDialog(DeviceList* oldDeviceList, DeviceDialogClient* client)
 440{
 441 m_client->runDeviceDialog(oldDeviceList, client);
 442}
 443#endif
 444
438445void Chrome::dispatchViewportDataDidChange(const ViewportArguments& arguments) const
439446{
440447 m_client->dispatchViewportDataDidChange(arguments);

Source/WebCore/page/Chrome.h

@@namespace WebCore {
4949 class Node;
5050 class Page;
5151 class PopupMenuClient;
 52
 53#if ENABLE(DEVICE_ELEMENT)
 54 class DeviceDialogClient;
 55 class DeviceList;
 56#endif
 57
5258#if ENABLE(NOTIFICATIONS)
5359 class NotificationPresenter;
5460#endif

@@namespace WebCore {
150156 void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
151157 void chooseIconForFiles(const Vector<String>&, FileChooser*);
152158
 159#if ENABLE(DEVICE_ELEMENT)
 160 void runDeviceDialog(DeviceList*, DeviceDialogClient*);
 161#endif
 162
153163 void dispatchViewportDataDidChange(const ViewportArguments&) const;
154164
155165 bool requiresFullscreenForVideoPlayback();

Source/WebCore/page/ChromeClient.h

@@namespace WebCore {
7272 class GraphicsLayer;
7373#endif
7474
 75#if ENABLE(DEVICE_ELEMENT)
 76 class DeviceDialogClient;
 77 class DeviceList;
 78#endif
 79
7580#if ENABLE(NOTIFICATIONS)
7681 class NotificationPresenter;
7782#endif

@@namespace WebCore {
224229 // Asynchronous request to load an icon for specified filenames.
225230 virtual void chooseIconForFiles(const Vector<String>&, FileChooser*) = 0;
226231
 232#if ENABLE(DEVICE_ELEMENT)
 233 virtual void runDeviceDialog(DeviceList*, DeviceDialogClient*) = 0;
 234#endif
 235
227236 // Notification that the given form element has changed. This function
228237 // will be called frequently, so handling should be very fast.
229238 virtual void formStateDidChange(const Node*) = 0;

Source/WebCore/page/DOMWindow.idl

@@module window {
427427 attribute [Conditional=DATAGRID] HTMLDataGridElementConstructor HTMLDataGridElement;
428428 attribute [Conditional=DATAGRID] HTMLDataGridCellElementConstructor HTMLDataGridCellElement;
429429 attribute [Conditional=DATAGRID] HTMLDataGridColElementConstructor HTMLDataGridColElement;
 430#if defined(ENABLE_DEVICE_ELEMENT) && ENABLE_DEVICE_ELEMENT
 431 attribute HTMLDeviceElementConstructor HTMLDeviceElement;
 432#endif
430433 attribute HTMLDListElementConstructor HTMLDListElement;
431434 attribute HTMLDirectoryElementConstructor HTMLDirectoryElement;
432435 attribute HTMLDivElementConstructor HTMLDivElement;

Source/WebCore/platform/LocalizedStrings.h

@@namespace WebCore {
3939 String submitButtonDefaultLabel();
4040 String fileButtonChooseFileLabel();
4141 String fileButtonNoFileSelectedLabel();
 42#if ENABLE(DEVICE_ELEMENT)
 43 String deviceElementButtonLabel();
 44#endif
4245
4346#if PLATFORM(MAC)
4447 String copyImageUnknownFileLabel();

Source/WebCore/platform/device/StreamDeviceManager.cpp

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#include "config.h"
 33
 34#if ENABLE(DEVICE_ELEMENT)
 35
 36#include "StreamDeviceManager.h"
 37
 38// FIXME - Add platform specific definitions of StreamDeviceManagerPrivateClassName here
 39#define StreamDeviceManagerPrivateClassName NullStreamDeviceManagerPrivate
 40
 41namespace WebCore {
 42
 43class NullStreamDeviceManagerPrivate : public StreamDeviceManagerPrivateInterface {
 44public:
 45 static StreamDeviceManagerPrivateInterface* create()
 46 {
 47 return new NullStreamDeviceManagerPrivate();
 48 }
 49
 50 PassRefPtr<DeviceList> createDeviceList(const DeviceType)
 51 {
 52 return DeviceList::create(Vector<RefPtr<DeviceListEntry> >());
 53 }
 54};
 55
 56StreamDeviceManager::StreamDeviceManager()
 57 : m_private(StreamDeviceManagerPrivateClassName::create())
 58{
 59}
 60
 61PassRefPtr<DeviceList> StreamDeviceManager::createDeviceList(const DeviceType type)
 62{
 63 return m_private->createDeviceList(type);
 64}
 65
 66} // namespace WebCore
 67
 68#endif // ENABLE(DEVICE_ELEMENT)

Source/WebCore/platform/device/StreamDeviceManager.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef StreamDeviceManager_h
 33#define StreamDeviceManager_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "DeviceList.h"
 38#include "PlatformString.h"
 39#include "StreamDeviceManagerPrivate.h"
 40
 41namespace WebCore {
 42
 43class StreamDeviceManager : public RefCounted<StreamDeviceManager> {
 44public:
 45 static PassRefPtr<StreamDeviceManager> create()
 46 {
 47 return adoptRef(new StreamDeviceManager());
 48 }
 49
 50 PassRefPtr<DeviceList> createDeviceList(const DeviceType);
 51
 52private:
 53 StreamDeviceManager();
 54
 55 OwnPtr<StreamDeviceManagerPrivateInterface*> m_private;
 56};
 57
 58} // namespace WebCore
 59
 60#endif // ENABLE(DEVICE_ELEMENT)
 61
 62#endif // StreamDeviceManager_h

Source/WebCore/platform/device/StreamDeviceManagerPrivate.h

 1/*
 2 * Copyright (C) 2011 Ericsson AB
 3 * All rights reserved.
 4 *
 5 * Redistribution and use in source and binary forms, with or without
 6 * modification, are permitted provided that the following conditions
 7 * are met:
 8 *
 9 * 1. Redistributions of source code must retain the above copyright
 10 * notice, this list of conditions and the following disclaimer.
 11 * 2. Redistributions in binary form must reproduce the above copyright
 12 * notice, this list of conditions and the following disclaimer
 13 * in the documentation and/or other materials provided with the
 14 * distribution.
 15 * 3. Neither the name of Ericsson nor the names of its contributors
 16 * may be used to endorse or promote products derived from this
 17 * software without specific prior written permission.
 18 *
 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 */
 31
 32#ifndef StreamDeviceManagerPrivate_h
 33#define StreamDeviceManagerPrivate_h
 34
 35#if ENABLE(DEVICE_ELEMENT)
 36
 37#include "DeviceList.h"
 38#include "PlatformString.h"
 39
 40namespace WebCore {
 41
 42class StreamDeviceManagerPrivateInterface {
 43public:
 44 virtual PassRefPtr<DeviceList> createDeviceList(const DeviceType) = 0;
 45};
 46
 47} // namespace WebCore
 48
 49#endif // ENABLE(DEVICE_ELEMENT)
 50
 51#endif // StreamDeviceManagerPrivate_h

Tools/ChangeLog

 12011-02-03 Adam Bergkvist <adam.bergkvist@ericsson.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Introduce the device element as an experimental feature
 6 https://bugs.webkit.org/show_bug.cgi?id=47264
 7
 8 Added --device-element build option
 9
 10 * Scripts/build-webkit:
 11
1122011-02-03 Gabor Rapcsanyi <rgabor@webkit.org>
213
314 Unreviewed.

Tools/Scripts/build-webkit

@@my (
7070 $databaseSupport,
7171 $datagridSupport,
7272 $datalistSupport,
 73 $deviceElementSupport,
7374 $deviceOrientationSupport,
7475 $directoryUploadSupport,
7576 $domStorageSupport,

@@my @features = (
147148 { option => "datalist", desc => "Toggle HTML5 datalist support",
148149 define => "ENABLE_DATALIST", default => 1, value => \$datalistSupport },
149150
 151 { option => "device-element", desc => "Toggle device element support",
 152 define => "ENABLE_DEVICE_ELEMENT", default => 0, value => \$deviceElementSupport },
 153
150154 { option => "device-orientation", desc => "Toggle DeviceOrientation support",
151155 define => "ENABLE_DEVICE_ORIENTATION", default => 0, value => \$deviceOrientationSupport },
152156