diff options
Diffstat (limited to 'WebCore/dom')
49 files changed, 1272 insertions, 394 deletions
diff --git a/WebCore/dom/ActiveDOMObject.cpp b/WebCore/dom/ActiveDOMObject.cpp index 9d36065..31afe98 100644 --- a/WebCore/dom/ActiveDOMObject.cpp +++ b/WebCore/dom/ActiveDOMObject.cpp @@ -37,22 +37,14 @@ ActiveDOMObject::ActiveDOMObject(ScriptExecutionContext* scriptExecutionContext, : m_scriptExecutionContext(scriptExecutionContext) , m_pendingActivityCount(0) { -#if ENABLE(WORKERS) - ASSERT((m_scriptExecutionContext->isDocument() && isMainThread()) - || (m_scriptExecutionContext->isWorkerContext() && currentThread() == static_cast<WorkerContext*>(m_scriptExecutionContext)->thread()->threadID())); -#endif - + ASSERT(m_scriptExecutionContext->isContextThread()); m_scriptExecutionContext->createdActiveDOMObject(this, upcastPointer); } ActiveDOMObject::~ActiveDOMObject() { if (m_scriptExecutionContext) { -#if ENABLE(WORKERS) - ASSERT((m_scriptExecutionContext->isDocument() && isMainThread()) - || (m_scriptExecutionContext->isWorkerContext() && currentThread() == static_cast<WorkerContext*>(m_scriptExecutionContext)->thread()->threadID())); -#endif - + ASSERT(m_scriptExecutionContext->isContextThread()); m_scriptExecutionContext->destroyedActiveDOMObject(this); } } diff --git a/WebCore/dom/AsyncScriptRunner.cpp b/WebCore/dom/AsyncScriptRunner.cpp new file mode 100644 index 0000000..96036a1 --- /dev/null +++ b/WebCore/dom/AsyncScriptRunner.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2010 Google, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "AsyncScriptRunner.h" + +#include "CachedScript.h" +#include "Element.h" +#include "ScriptElement.h" + +namespace WebCore { + +AsyncScriptRunner::AsyncScriptRunner() + : m_timer(this, &AsyncScriptRunner::timerFired) +{ +} + +AsyncScriptRunner::~AsyncScriptRunner() +{ + for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i) + m_scriptsToExecuteSoon[i].first->element()->deref(); // Balances ref() in executeScriptSoon(). +} + +void AsyncScriptRunner::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<CachedScript> cachedScript) +{ + ASSERT_ARG(data, data); + + Element* element = data->element(); + ASSERT(element); + ASSERT(element->inDocument()); + + m_scriptsToExecuteSoon.append(make_pair(data, cachedScript)); + element->ref(); // Balanced by deref()s in timerFired() and dtor. + if (!m_timer.isActive()) + m_timer.startOneShot(0); +} + +void AsyncScriptRunner::suspend() +{ + m_timer.stop(); +} + +void AsyncScriptRunner::resume() +{ + if (hasPendingScripts()) + m_timer.startOneShot(0); +} + +void AsyncScriptRunner::timerFired(Timer<AsyncScriptRunner>* timer) +{ + ASSERT_UNUSED(timer, timer == &m_timer); + + Vector<pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > scripts; + scripts.swap(m_scriptsToExecuteSoon); + size_t size = scripts.size(); + for (size_t i = 0; i < size; ++i) { + scripts[i].first->execute(scripts[i].second.get()); + scripts[i].first->element()->deref(); // Balances ref() in executeScriptSoon(). + } +} + +} diff --git a/WebCore/dom/AsyncScriptRunner.h b/WebCore/dom/AsyncScriptRunner.h new file mode 100644 index 0000000..8b75e06 --- /dev/null +++ b/WebCore/dom/AsyncScriptRunner.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 Google, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef AsyncScriptRunner_h +#define AsyncScriptRunner_h + +#include "CachedResourceHandle.h" +#include "Timer.h" +#include <wtf/Noncopyable.h> +#include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class CachedScript; +class ScriptElementData; + +class AsyncScriptRunner : public Noncopyable { +public: + static PassOwnPtr<AsyncScriptRunner> create() { return new AsyncScriptRunner(); } + ~AsyncScriptRunner(); + + void executeScriptSoon(ScriptElementData*, CachedResourceHandle<CachedScript>); + bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty(); } + void suspend(); + void resume(); + +private: + AsyncScriptRunner(); + + void timerFired(Timer<AsyncScriptRunner>*); + + Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon; + Timer<AsyncScriptRunner> m_timer; +}; + +} + +#endif diff --git a/WebCore/dom/CheckedRadioButtons.h b/WebCore/dom/CheckedRadioButtons.h index 5a57955..de7b712 100644 --- a/WebCore/dom/CheckedRadioButtons.h +++ b/WebCore/dom/CheckedRadioButtons.h @@ -21,13 +21,12 @@ #ifndef CheckedRadioButtons_h #define CheckedRadioButtons_h +#include <wtf/Forward.h> #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> namespace WebCore { -class AtomicString; -class AtomicStringImpl; class HTMLInputElement; class HTMLFormControlElement; diff --git a/WebCore/dom/DOMImplementation.h b/WebCore/dom/DOMImplementation.h index c3d5658..a20f7d2 100644 --- a/WebCore/dom/DOMImplementation.h +++ b/WebCore/dom/DOMImplementation.h @@ -24,6 +24,7 @@ #ifndef DOMImplementation_h #define DOMImplementation_h +#include <wtf/Forward.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -35,7 +36,6 @@ class DocumentType; class Frame; class HTMLDocument; class KURL; -class String; typedef int ExceptionCode; diff --git a/WebCore/dom/DeviceMotionClient.h b/WebCore/dom/DeviceMotionClient.h new file mode 100644 index 0000000..d19f92f --- /dev/null +++ b/WebCore/dom/DeviceMotionClient.h @@ -0,0 +1,45 @@ +/* + * Copyright 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DeviceMotionClient_h +#define DeviceMotionClient_h + +namespace WebCore { + +class DeviceMotionController; +class DeviceMotionData; + +class DeviceMotionClient { +public: + virtual ~DeviceMotionClient() {} + virtual void setController(DeviceMotionController*) = 0; + virtual void startUpdating() = 0; + virtual void stopUpdating() = 0; + virtual DeviceMotionData* currentDeviceMotion() const = 0; +}; + +} // namespace WebCore + +#endif // DeviceMotionClient_h diff --git a/WebCore/dom/DeviceMotionController.cpp b/WebCore/dom/DeviceMotionController.cpp new file mode 100644 index 0000000..73b948e --- /dev/null +++ b/WebCore/dom/DeviceMotionController.cpp @@ -0,0 +1,104 @@ +/* + * Copyright 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DeviceMotionController.h" + +#include "DeviceMotionClient.h" +#include "DeviceMotionData.h" +#include "DeviceMotionEvent.h" + +namespace WebCore { + +DeviceMotionController::DeviceMotionController(DeviceMotionClient* client) + : m_client(client) + , m_timer(this, &DeviceMotionController::timerFired) +{ + ASSERT(m_client); + m_client->setController(this); +} + +void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer) +{ + ASSERT_UNUSED(timer, timer == &m_timer); + ASSERT(!m_client || m_client->currentDeviceMotion()); + m_timer.stop(); + + RefPtr<DeviceMotionData> deviceMotionData = m_client ? m_client->currentDeviceMotion() : DeviceMotionData::create(); + RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, deviceMotionData.get()); + + Vector<DOMWindow*> listenersVector; + copyToVector(m_newListeners, listenersVector); + m_newListeners.clear(); + for (size_t i = 0; i < listenersVector.size(); ++i) + listenersVector[i]->dispatchEvent(event); +} + +void DeviceMotionController::addListener(DOMWindow* window) +{ + // If no client is present or the client already has motion data, + // immediately trigger an asynchronous response. + if (!m_client || m_client->currentDeviceMotion()) { + m_newListeners.add(window); + if (!m_timer.isActive()) + m_timer.startOneShot(0); + } + + bool wasEmpty = m_listeners.isEmpty(); + m_listeners.add(window); + if (wasEmpty && m_client) + m_client->startUpdating(); +} + +void DeviceMotionController::removeListener(DOMWindow* window) +{ + m_listeners.remove(window); + m_newListeners.remove(window); + if (m_listeners.isEmpty() && m_client) + m_client->stopUpdating(); +} + +void DeviceMotionController::removeAllListeners(DOMWindow* window) +{ + // May be called with a DOMWindow that's not a listener. + if (!m_listeners.contains(window)) + return; + + m_listeners.removeAll(window); + m_newListeners.remove(window); + if (m_listeners.isEmpty() && m_client) + m_client->stopUpdating(); +} + +void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotionData) +{ + RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().devicemotionEvent, deviceMotionData); + Vector<DOMWindow*> listenersVector; + copyToVector(m_listeners, listenersVector); + for (size_t i = 0; i < listenersVector.size(); ++i) + listenersVector[i]->dispatchEvent(event); +} + +} // namespace WebCore diff --git a/WebCore/dom/DeviceMotionController.h b/WebCore/dom/DeviceMotionController.h new file mode 100644 index 0000000..2670e04 --- /dev/null +++ b/WebCore/dom/DeviceMotionController.h @@ -0,0 +1,61 @@ +/* + * Copyright 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DeviceMotionController_h +#define DeviceMotionController_h + +#include "DOMWindow.h" +#include "Timer.h" +#include <wtf/HashCountedSet.h> + +namespace WebCore { + +class DeviceMotionData; +class DeviceMotionClient; + +class DeviceMotionController { +public: + DeviceMotionController(DeviceMotionClient*); + + void addListener(DOMWindow*); + void removeListener(DOMWindow*); + void removeAllListeners(DOMWindow*); + + void didChangeDeviceMotion(DeviceMotionData*); + +private: + void timerFired(Timer<DeviceMotionController>*); + + DeviceMotionClient* m_client; + typedef HashCountedSet<DOMWindow*> ListenersCountedSet; + ListenersCountedSet m_listeners; + typedef HashSet<DOMWindow*> ListenersSet; + ListenersSet m_newListeners; + Timer<DeviceMotionController> m_timer; +}; + +} // namespace WebCore + +#endif // DeviceMotionController_h diff --git a/WebCore/dom/DeviceMotionData.cpp b/WebCore/dom/DeviceMotionData.cpp new file mode 100644 index 0000000..cf4b466 --- /dev/null +++ b/WebCore/dom/DeviceMotionData.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DeviceMotionData.h" + +namespace WebCore { + +PassRefPtr<DeviceMotionData> DeviceMotionData::create() +{ + return adoptRef(new DeviceMotionData); +} + +PassRefPtr<DeviceMotionData> DeviceMotionData::create(bool canProvideXAcceleration, double xAcceleration, + bool canProvideYAcceleration, double yAcceleration, + bool canProvideZAcceleration, double zAcceleration, + bool canProvideXRotationRate, double xRotationRate, + bool canProvideYRotationRate, double yRotationRate, + bool canProvideZRotationRate, double zRotationRate, + bool canProvideInterval, double interval) +{ + return adoptRef(new DeviceMotionData(canProvideXAcceleration, xAcceleration, + canProvideYAcceleration, yAcceleration, + canProvideZAcceleration, zAcceleration, + canProvideXRotationRate, xRotationRate, + canProvideYRotationRate, yRotationRate, + canProvideZRotationRate, zRotationRate, + canProvideInterval, interval)); +} + +DeviceMotionData::DeviceMotionData() + : m_canProvideXAcceleration(false) + , m_canProvideYAcceleration(false) + , m_canProvideZAcceleration(false) + , m_canProvideXRotationRate(false) + , m_canProvideYRotationRate(false) + , m_canProvideZRotationRate(false) + , m_canProvideInterval(false) +{ +} + +DeviceMotionData::DeviceMotionData(bool canProvideXAcceleration, double xAcceleration, + bool canProvideYAcceleration, double yAcceleration, + bool canProvideZAcceleration, double zAcceleration, + bool canProvideXRotationRate, double xRotationRate, + bool canProvideYRotationRate, double yRotationRate, + bool canProvideZRotationRate, double zRotationRate, + bool canProvideInterval, double interval) + : m_canProvideXAcceleration(canProvideXAcceleration) + , m_canProvideYAcceleration(canProvideYAcceleration) + , m_canProvideZAcceleration(canProvideZAcceleration) + , m_canProvideXRotationRate(canProvideXRotationRate) + , m_canProvideYRotationRate(canProvideYRotationRate) + , m_canProvideZRotationRate(canProvideZRotationRate) + , m_canProvideInterval(canProvideInterval) + , m_xAcceleration(xAcceleration) + , m_yAcceleration(yAcceleration) + , m_zAcceleration(zAcceleration) + , m_xRotationRate(xRotationRate) + , m_yRotationRate(yRotationRate) + , m_zRotationRate(zRotationRate) + , m_interval(interval) +{ +} + +} // namespace WebCore diff --git a/WebCore/dom/DeviceMotionData.h b/WebCore/dom/DeviceMotionData.h new file mode 100644 index 0000000..cd90246 --- /dev/null +++ b/WebCore/dom/DeviceMotionData.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DeviceMotionData_h +#define DeviceMotionData_h + +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class DeviceMotionData : public RefCounted<DeviceMotionData> { +public: + static PassRefPtr<DeviceMotionData> create(); + static PassRefPtr<DeviceMotionData> create(bool canProvideXAcceleration, double xAcceleration, + bool canProvideYAcceleration, double yAcceleration, + bool canProvideZAcceleration, double zAcceleration, + bool canProvideXRotationRate, double xRotationRate, + bool canProvideYRotationRate, double yRotationRate, + bool canProvideZRotationRate, double zRotationRate, + bool canProvideInterval, double interval); + + double xAcceleration() const { return m_xAcceleration; } + double yAcceleration() const { return m_yAcceleration; } + double zAcceleration() const { return m_zAcceleration; } + double xRotationRate() const { return m_xRotationRate; } + double yRotationRate() const { return m_yRotationRate; } + double zRotationRate() const { return m_zRotationRate; } + double interval() const { return m_interval; } + + bool canProvideXAcceleration() const { return m_canProvideXAcceleration; } + bool canProvideYAcceleration() const { return m_canProvideYAcceleration; } + bool canProvideZAcceleration() const { return m_canProvideZAcceleration; } + bool canProvideXRotationRate() const { return m_canProvideXRotationRate; } + bool canProvideYRotationRate() const { return m_canProvideYRotationRate; } + bool canProvideZRotationRate() const { return m_canProvideZRotationRate; } + bool canProvideInterval() const { return m_canProvideInterval; } + +private: + DeviceMotionData(); + DeviceMotionData(bool canProvideXAcceleration, double xAcceleration, + bool canProvideYAcceleration, double yAcceleration, + bool canProvideZAcceleration, double zAcceleration, + bool canProvideXRotationRate, double xRotationRate, + bool canProvideYRotationRate, double yRotationRate, + bool canProvideZRotationRate, double zRotationRate, + bool canProvideInterval, double interval); + + bool m_canProvideXAcceleration; + bool m_canProvideYAcceleration; + bool m_canProvideZAcceleration; + bool m_canProvideXRotationRate; + bool m_canProvideYRotationRate; + bool m_canProvideZRotationRate; + bool m_canProvideInterval; + + double m_xAcceleration; + double m_yAcceleration; + double m_zAcceleration; + double m_xRotationRate; + double m_yRotationRate; + double m_zRotationRate; + double m_interval; +}; + +} // namespace WebCore + +#endif // DeviceMotionData_h diff --git a/WebCore/dom/DeviceMotionEvent.cpp b/WebCore/dom/DeviceMotionEvent.cpp new file mode 100644 index 0000000..860cca2 --- /dev/null +++ b/WebCore/dom/DeviceMotionEvent.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DeviceMotionEvent.h" + +#include "DeviceMotionData.h" + +namespace WebCore { + +DeviceMotionEvent::~DeviceMotionEvent() +{ +} + +DeviceMotionEvent::DeviceMotionEvent() + : m_deviceMotionData(DeviceMotionData::create()) +{ +} + +DeviceMotionEvent::DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData* deviceMotionData) + : Event(eventType, false, false) // Can't bubble, not cancelable + , m_deviceMotionData(deviceMotionData) +{ +} + +void DeviceMotionEvent::initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData* deviceMotionData) +{ + if (dispatched()) + return; + + initEvent(type, bubbles, cancelable); + m_deviceMotionData = deviceMotionData; +} + +} // namespace WebCore diff --git a/WebCore/dom/DeviceMotionEvent.h b/WebCore/dom/DeviceMotionEvent.h new file mode 100644 index 0000000..f32c93b --- /dev/null +++ b/WebCore/dom/DeviceMotionEvent.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DeviceMotionEvent_h +#define DeviceMotionEvent_h + +#include "Event.h" + +namespace WebCore { + +class DeviceMotionData; + +class DeviceMotionEvent : public Event { +public: + ~DeviceMotionEvent(); + static PassRefPtr<DeviceMotionEvent> create() + { + return adoptRef(new DeviceMotionEvent); + } + static PassRefPtr<DeviceMotionEvent> create(const AtomicString& eventType, DeviceMotionData* deviceMotionData) + { + return adoptRef(new DeviceMotionEvent(eventType, deviceMotionData)); + } + + void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData*); + + virtual bool isDeviceMotionEvent() const { return true; } + + DeviceMotionData* deviceMotionData() const { return m_deviceMotionData.get(); } + +private: + DeviceMotionEvent(); + DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*); + + RefPtr<DeviceMotionData> m_deviceMotionData; +}; + +} // namespace WebCore + +#endif // DeviceMotionEvent_h diff --git a/WebCore/dom/DeviceMotionEvent.idl b/WebCore/dom/DeviceMotionEvent.idl new file mode 100644 index 0000000..97e8e71 --- /dev/null +++ b/WebCore/dom/DeviceMotionEvent.idl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +module core { + + interface [ + Conditional=DEVICE_ORIENTATION + ] DeviceMotionEvent : Event { + readonly attribute [Custom] double xAcceleration; + readonly attribute [Custom] double yAcceleration; + readonly attribute [Custom] double zAcceleration; + readonly attribute [Custom] double xRotationRate; + readonly attribute [Custom] double yRotationRate; + readonly attribute [Custom] double zRotationRate; + readonly attribute [Custom] double interval; + [Custom] void initDeviceMotionEvent(in DOMString type, in boolean bubbles, in boolean cancelable, in double xAcceleration, in double yAcceleration, in double zAcceleration, in double xRotationRate, in double yRotationRate, in double zRotationRate, in double interval); + }; + +} diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 8447f22..539d43f 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -28,6 +28,7 @@ #include "AXObjectCache.h" #include "AnimationController.h" +#include "AsyncScriptRunner.h" #include "Attr.h" #include "Attribute.h" #include "CDATASection.h" @@ -44,6 +45,7 @@ #include "CustomEvent.h" #include "DOMImplementation.h" #include "DOMWindow.h" +#include "DeviceMotionEvent.h" #include "DeviceOrientationEvent.h" #include "DocLoader.h" #include "DocumentFragment.h" @@ -77,10 +79,8 @@ #include "HTMLMapElement.h" #include "HTMLNameCollection.h" #include "HTMLNames.h" -#include "LegacyHTMLTreeBuilder.h" #include "HTMLStyleElement.h" #include "HTMLTitleElement.h" -#include "LegacyHTMLDocumentParser.h" #include "HTTPParsers.h" #include "HistoryItem.h" #include "HitTestRequest.h" @@ -89,6 +89,8 @@ #include "InspectorController.h" #include "InspectorTimelineAgent.h" #include "KeyboardEvent.h" +#include "LegacyHTMLDocumentParser.h" +#include "LegacyHTMLTreeBuilder.h" #include "Logging.h" #include "MessageEvent.h" #include "MouseEvent.h" @@ -134,10 +136,10 @@ #include "WebKitAnimationEvent.h" #include "WebKitTransitionEvent.h" #include "WheelEvent.h" +#include "XMLDocumentParser.h" #include "XMLHttpRequest.h" #include "XMLNSNames.h" #include "XMLNames.h" -#include "XMLDocumentParser.h" #include "htmlediting.h" #include <wtf/CurrentTime.h> #include <wtf/HashFunctions.h> @@ -172,8 +174,8 @@ #include "SVGDocumentExtensions.h" #include "SVGElementFactory.h" #include "SVGNames.h" -#include "SVGZoomEvent.h" #include "SVGStyleElement.h" +#include "SVGZoomEvent.h" #endif #if PLATFORM(ANDROID) @@ -319,12 +321,12 @@ static Widget* widgetForNode(Node* focusedNode) return toRenderWidget(renderer)->widget(); } -static bool acceptsEditingFocus(Node *node) +static bool acceptsEditingFocus(Node* node) { ASSERT(node); ASSERT(node->isContentEditable()); - Node *root = node->rootEditableElement(); + Node* root = node->rootEditableElement(); Frame* frame = node->document()->frame(); if (!frame || !root) return false; @@ -376,7 +378,7 @@ private: Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) : ContainerNode(0) - , m_domtree_version(0) + , m_domTreeVersion(0) , m_styleSheets(StyleSheetList::create(this)) , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired) , m_frameElementsShouldIgnoreScrolling(false) @@ -390,7 +392,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) , m_startTime(currentTime()) , m_overMinimumLayoutThreshold(false) , m_extraLayoutDelay(0) - , m_executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired) + , m_asyncScriptRunner(AsyncScriptRunner::create()) , m_xmlVersion("1.0") , m_xmlStandalone(false) #if ENABLE(XBL) @@ -485,7 +487,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) static int docID = 0; m_docID = docID++; #if ENABLE(XHTMLMP) - m_shouldProcessNoScriptElement = m_frame && m_frame->script()->canExecuteScripts(NotAboutToExecuteScript); + m_shouldProcessNoScriptElement = !(m_frame && m_frame->script()->canExecuteScripts(NotAboutToExecuteScript)); #endif } @@ -541,8 +543,7 @@ Document::~Document() ASSERT(m_ranges.isEmpty()); ASSERT(!m_styleRecalcTimer.isActive()); - for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i) - m_scriptsToExecuteSoon[i].first->element()->deref(); // Balances ref() in executeScriptSoon(). + m_asyncScriptRunner.clear(); removeAllEventListeners(); @@ -754,75 +755,75 @@ PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionCo } switch (importedNode->nodeType()) { - case TEXT_NODE: - return createTextNode(importedNode->nodeValue()); - case CDATA_SECTION_NODE: - return createCDATASection(importedNode->nodeValue(), ec); - case ENTITY_REFERENCE_NODE: - return createEntityReference(importedNode->nodeName(), ec); - case PROCESSING_INSTRUCTION_NODE: - return createProcessingInstruction(importedNode->nodeName(), importedNode->nodeValue(), ec); - case COMMENT_NODE: - return createComment(importedNode->nodeValue()); - case ELEMENT_NODE: { - Element* oldElement = static_cast<Element*>(importedNode); - RefPtr<Element> newElement = createElementNS(oldElement->namespaceURI(), oldElement->tagQName().toString(), ec); - - if (ec) - return 0; - - NamedNodeMap* attrs = oldElement->attributes(true); - if (attrs) { - unsigned length = attrs->length(); - for (unsigned i = 0; i < length; i++) { - Attribute* attr = attrs->attributeItem(i); - newElement->setAttribute(attr->name(), attr->value().impl(), ec); - if (ec) - return 0; - } + case TEXT_NODE: + return createTextNode(importedNode->nodeValue()); + case CDATA_SECTION_NODE: + return createCDATASection(importedNode->nodeValue(), ec); + case ENTITY_REFERENCE_NODE: + return createEntityReference(importedNode->nodeName(), ec); + case PROCESSING_INSTRUCTION_NODE: + return createProcessingInstruction(importedNode->nodeName(), importedNode->nodeValue(), ec); + case COMMENT_NODE: + return createComment(importedNode->nodeValue()); + case ELEMENT_NODE: { + Element* oldElement = static_cast<Element*>(importedNode); + RefPtr<Element> newElement = createElementNS(oldElement->namespaceURI(), oldElement->tagQName().toString(), ec); + + if (ec) + return 0; + + NamedNodeMap* attrs = oldElement->attributes(true); + if (attrs) { + unsigned length = attrs->length(); + for (unsigned i = 0; i < length; i++) { + Attribute* attr = attrs->attributeItem(i); + newElement->setAttribute(attr->name(), attr->value().impl(), ec); + if (ec) + return 0; } + } - newElement->copyNonAttributeProperties(oldElement); + newElement->copyNonAttributeProperties(oldElement); - if (deep) { - for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { - RefPtr<Node> newChild = importNode(oldChild, true, ec); - if (ec) - return 0; - newElement->appendChild(newChild.release(), ec); - if (ec) - return 0; - } + if (deep) { + for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { + RefPtr<Node> newChild = importNode(oldChild, true, ec); + if (ec) + return 0; + newElement->appendChild(newChild.release(), ec); + if (ec) + return 0; } - - return newElement.release(); } - case ATTRIBUTE_NODE: - return Attr::create(0, this, static_cast<Attr*>(importedNode)->attr()->clone()); - case DOCUMENT_FRAGMENT_NODE: { - DocumentFragment* oldFragment = static_cast<DocumentFragment*>(importedNode); - RefPtr<DocumentFragment> newFragment = createDocumentFragment(); - if (deep) { - for (Node* oldChild = oldFragment->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { - RefPtr<Node> newChild = importNode(oldChild, true, ec); - if (ec) - return 0; - newFragment->appendChild(newChild.release(), ec); - if (ec) - return 0; - } + + return newElement.release(); + } + case ATTRIBUTE_NODE: + return Attr::create(0, this, static_cast<Attr*>(importedNode)->attr()->clone()); + case DOCUMENT_FRAGMENT_NODE: { + DocumentFragment* oldFragment = static_cast<DocumentFragment*>(importedNode); + RefPtr<DocumentFragment> newFragment = createDocumentFragment(); + if (deep) { + for (Node* oldChild = oldFragment->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { + RefPtr<Node> newChild = importNode(oldChild, true, ec); + if (ec) + return 0; + newFragment->appendChild(newChild.release(), ec); + if (ec) + return 0; } - - return newFragment.release(); } - case ENTITY_NODE: - case NOTATION_NODE: - // FIXME: It should be possible to import these node types, however in DOM3 the DocumentType is readonly, so there isn't much sense in doing that. - // Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM. - case DOCUMENT_NODE: - case DOCUMENT_TYPE_NODE: - case XPATH_NAMESPACE_NODE: - break; + + return newFragment.release(); + } + case ENTITY_NODE: + case NOTATION_NODE: + // FIXME: It should be possible to import these node types, however in DOM3 the DocumentType is readonly, so there isn't much sense in doing that. + // Ability to add these imported nodes to a DocumentType will be considered for addition to a future release of the DOM. + case DOCUMENT_NODE: + case DOCUMENT_TYPE_NODE: + case XPATH_NAMESPACE_NODE: + break; } ec = NOT_SUPPORTED_ERR; @@ -843,26 +844,26 @@ PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionCode& ec) } switch (source->nodeType()) { - case ENTITY_NODE: - case NOTATION_NODE: - case DOCUMENT_NODE: - case DOCUMENT_TYPE_NODE: - case XPATH_NAMESPACE_NODE: - ec = NOT_SUPPORTED_ERR; - return 0; - case ATTRIBUTE_NODE: { - Attr* attr = static_cast<Attr*>(source.get()); - if (attr->ownerElement()) - attr->ownerElement()->removeAttributeNode(attr, ec); - attr->setSpecified(true); - break; - } - default: - if (source->hasTagName(iframeTag)) - static_cast<HTMLIFrameElement*>(source.get())->setRemainsAliveOnRemovalFromTree(attached()); + case ENTITY_NODE: + case NOTATION_NODE: + case DOCUMENT_NODE: + case DOCUMENT_TYPE_NODE: + case XPATH_NAMESPACE_NODE: + ec = NOT_SUPPORTED_ERR; + return 0; + case ATTRIBUTE_NODE: { + Attr* attr = static_cast<Attr*>(source.get()); + if (attr->ownerElement()) + attr->ownerElement()->removeAttributeNode(attr, ec); + attr->setSpecified(true); + break; + } + default: + if (source->hasTagName(iframeTag)) + static_cast<HTMLIFrameElement*>(source.get())->setRemainsAliveOnRemovalFromTree(attached()); - if (source->parentNode()) - source->parentNode()->removeChild(source.get(), ec); + if (source->parentNode()) + source->parentNode()->removeChild(source.get(), ec); } for (Node* node = source.get(); node; node = node->traverseNextNode(source.get())) @@ -952,7 +953,7 @@ Element* Document::getElementById(const AtomicString& elementId) const if (m_duplicateIds.contains(elementId.impl())) { // We know there's at least one node with this id, but we don't know what the first one is. - for (Node *n = traverseNextNode(); n != 0; n = n->traverseNextNode()) { + for (Node* n = traverseNextNode(); n; n = n->traverseNextNode()) { if (n->isElementNode()) { element = static_cast<Element*>(n); if (element->hasID() && element->getIdAttribute() == elementId) { @@ -974,9 +975,9 @@ String Document::readyState() const return "complete"; if (parsing()) return "loading"; - return "loaded"; - // FIXME: What does "interactive" mean? - // FIXME: Missing support for "uninitialized". + return "loaded"; + // FIXME: What does "interactive" mean? + // FIXME: Missing support for "uninitialized". } return String(); } @@ -1381,7 +1382,7 @@ PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT return NodeIterator::create(root, whatToShow, filter, expandEntityReferences); } -PassRefPtr<TreeWalker> Document::createTreeWalker(Node *root, unsigned whatToShow, +PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionCode& ec) { if (!root) { @@ -2093,8 +2094,8 @@ bool Document::shouldScheduleLayout() // (a) Only schedule a layout once the stylesheets are loaded. // (b) Only schedule layout once we have a body element. - return (haveStylesheetsLoaded() && body()) || - (documentElement() && !documentElement()->hasTagName(htmlTag)); + return (haveStylesheetsLoaded() && body()) + || (documentElement() && !documentElement()->hasTagName(htmlTag)); } int Document::minimumLayoutDelay() @@ -2364,7 +2365,7 @@ Node* Document::nextFocusableNode(Node* start, KeyboardEvent* event) if (Node* winner = nextNodeWithExactTabIndex(start->traverseNextNode(), start->tabIndex(), event)) return winner; - if (start->tabIndex() == 0) + if (!start->tabIndex()) // We've reached the last node in the document with a tabindex of 0. This is the end of the tabbing order. return 0; } @@ -2383,8 +2384,7 @@ Node* Document::nextFocusableNode(Node* start, KeyboardEvent* event) Node* Document::previousFocusableNode(Node* start, KeyboardEvent* event) { Node* last; - for (last = this; last->lastChild(); last = last->lastChild()) - ; // Empty loop. + for (last = this; last->lastChild(); last = last->lastChild()) { } // First try to find the last node in the document that comes before start and has the same tabindex as start. // If start is null, find the last node in the document with a tabindex of 0. @@ -2420,17 +2420,16 @@ int Document::nodeAbsIndex(Node *node) ASSERT(node->document() == this); int absIndex = 0; - for (Node *n = node; n && n != this; n = n->traversePreviousNode()) + for (Node* n = node; n && n != this; n = n->traversePreviousNode()) absIndex++; return absIndex; } -Node *Document::nodeWithAbsIndex(int absIndex) +Node* Document::nodeWithAbsIndex(int absIndex) { - Node *n = this; - for (int i = 0; n && (i < absIndex); i++) { + Node* n = this; + for (int i = 0; n && (i < absIndex); i++) n = n->traverseNextNode(); - } return n; } @@ -2588,27 +2587,27 @@ MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& r bool Document::childTypeAllowed(NodeType type) { switch (type) { - case ATTRIBUTE_NODE: - case CDATA_SECTION_NODE: - case DOCUMENT_FRAGMENT_NODE: - case DOCUMENT_NODE: - case ENTITY_NODE: - case ENTITY_REFERENCE_NODE: - case NOTATION_NODE: - case TEXT_NODE: - case XPATH_NAMESPACE_NODE: - return false; - case COMMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - return true; - case DOCUMENT_TYPE_NODE: - case ELEMENT_NODE: - // Documents may contain no more than one of each of these. - // (One Element and one DocumentType.) - for (Node* c = firstChild(); c; c = c->nextSibling()) - if (c->nodeType() == type) - return false; - return true; + case ATTRIBUTE_NODE: + case CDATA_SECTION_NODE: + case DOCUMENT_FRAGMENT_NODE: + case DOCUMENT_NODE: + case ENTITY_NODE: + case ENTITY_REFERENCE_NODE: + case NOTATION_NODE: + case TEXT_NODE: + case XPATH_NAMESPACE_NODE: + return false; + case COMMENT_NODE: + case PROCESSING_INSTRUCTION_NODE: + return true; + case DOCUMENT_TYPE_NODE: + case ELEMENT_NODE: + // Documents may contain no more than one of each of these. + // (One Element and one DocumentType.) + for (Node* c = firstChild(); c; c = c->nextSibling()) + if (c->nodeType() == type) + return false; + return true; } return false; } @@ -2632,14 +2631,14 @@ bool Document::canReplaceChild(Node* newChild, Node* oldChild) continue; switch (c->nodeType()) { - case DOCUMENT_TYPE_NODE: - numDoctypes++; - break; - case ELEMENT_NODE: - numElements++; - break; - default: - break; + case DOCUMENT_TYPE_NODE: + numDoctypes++; + break; + case ELEMENT_NODE: + numElements++; + break; + default: + break; } } @@ -2647,29 +2646,6 @@ bool Document::canReplaceChild(Node* newChild, Node* oldChild) if (newChild->nodeType() == DOCUMENT_FRAGMENT_NODE) { for (Node* c = firstChild(); c; c = c->nextSibling()) { switch (c->nodeType()) { - case ATTRIBUTE_NODE: - case CDATA_SECTION_NODE: - case DOCUMENT_FRAGMENT_NODE: - case DOCUMENT_NODE: - case ENTITY_NODE: - case ENTITY_REFERENCE_NODE: - case NOTATION_NODE: - case TEXT_NODE: - case XPATH_NAMESPACE_NODE: - return false; - case COMMENT_NODE: - case PROCESSING_INSTRUCTION_NODE: - break; - case DOCUMENT_TYPE_NODE: - numDoctypes++; - break; - case ELEMENT_NODE: - numElements++; - break; - } - } - } else { - switch (newChild->nodeType()) { case ATTRIBUTE_NODE: case CDATA_SECTION_NODE: case DOCUMENT_FRAGMENT_NODE: @@ -2682,13 +2658,36 @@ bool Document::canReplaceChild(Node* newChild, Node* oldChild) return false; case COMMENT_NODE: case PROCESSING_INSTRUCTION_NODE: - return true; + break; case DOCUMENT_TYPE_NODE: numDoctypes++; break; case ELEMENT_NODE: numElements++; break; + } + } + } else { + switch (newChild->nodeType()) { + case ATTRIBUTE_NODE: + case CDATA_SECTION_NODE: + case DOCUMENT_FRAGMENT_NODE: + case DOCUMENT_NODE: + case ENTITY_NODE: + case ENTITY_REFERENCE_NODE: + case NOTATION_NODE: + case TEXT_NODE: + case XPATH_NAMESPACE_NODE: + return false; + case COMMENT_NODE: + case PROCESSING_INSTRUCTION_NODE: + return true; + case DOCUMENT_TYPE_NODE: + numDoctypes++; + break; + case ELEMENT_NODE: + numElements++; + break; } } @@ -2887,11 +2886,11 @@ void Document::recalcStyleSelector() bool enabledViaScript = false; if (e->hasLocalName(linkTag)) { // <LINK> element - HTMLLinkElement* l = static_cast<HTMLLinkElement*>(n); - if (l->isDisabled()) + HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(n); + if (linkElement->isDisabled()) continue; - enabledViaScript = l->isEnabledViaScript(); - if (l->isLoading()) { + enabledViaScript = linkElement->isEnabledViaScript(); + if (linkElement->isLoading()) { // it is loading but we should still decide which style sheet set to use if (!enabledViaScript && !title.isEmpty() && m_preferredStylesheetSet.isEmpty()) { const AtomicString& rel = e->getAttribute(relAttr); @@ -2902,7 +2901,7 @@ void Document::recalcStyleSelector() } continue; } - if (!l->sheet()) + if (!linkElement->sheet()) title = nullAtom; } @@ -3110,7 +3109,7 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) // eww, I suck. set the qt focus correctly // ### find a better place in the code for this if (view()) { - Widget *focusWidget = widgetForNode(m_focusedNode.get()); + Widget* focusWidget = widgetForNode(m_focusedNode.get()); if (focusWidget) { // Make sure a widget has the right size before giving it focus. // Otherwise, we are testing edge cases of the Widget code. @@ -3166,12 +3165,12 @@ void Document::setCSSTarget(Element* n) n->setNeedsStyleRecalc(); } -void Document::attachNodeIterator(NodeIterator *ni) +void Document::attachNodeIterator(NodeIterator* ni) { m_nodeIterators.add(ni); } -void Document::detachNodeIterator(NodeIterator *ni) +void Document::detachNodeIterator(NodeIterator* ni) { m_nodeIterators.remove(ni); } @@ -3390,6 +3389,8 @@ PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& event = TouchEvent::create(); #endif #if ENABLE(DEVICE_ORIENTATION) + else if (eventType == "DeviceMotionEvent") + event = DeviceMotionEvent::create(); else if (eventType == "DeviceOrientationEvent") event = DeviceOrientationEvent::create(); #endif @@ -3619,7 +3620,7 @@ bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S { unsigned length = qualifiedName.length(); - if (length == 0) { + if (!length) { ec = INVALID_CHARACTER_ERR; return false; } @@ -3702,7 +3703,7 @@ void Document::removeImageMap(HTMLMapElement* imageMap) m_imageMapsByName.remove(it); } -HTMLMapElement *Document::getImageMap(const String& url) const +HTMLMapElement* Document::getImageMap(const String& url) const { if (url.isNull()) return 0; @@ -3738,13 +3739,13 @@ void Document::setInPageCache(bool flag) m_inPageCache = flag; if (flag) { - ASSERT(m_savedRenderer == 0); + ASSERT(!m_savedRenderer); m_savedRenderer = renderer(); if (FrameView* v = view()) v->resetScrollbars(); unscheduleStyleRecalc(); } else { - ASSERT(renderer() == 0 || renderer() == m_savedRenderer); + ASSERT(!renderer() || renderer() == m_savedRenderer); ASSERT(m_renderArena); setRenderer(m_savedRenderer); m_savedRenderer = 0; @@ -3860,7 +3861,7 @@ static IntRect placeholderRectForMarker() return IntRect(-1, -1, -1, -1); } -void Document::addMarker(Range *range, DocumentMarker::MarkerType type, String description) +void Document::addMarker(Range* range, DocumentMarker::MarkerType type, String description) { // Use a TextIterator to visit the potentially multiple nodes the range covers. for (TextIterator markedText(range); !markedText.atEnd(); markedText.advance()) { @@ -3957,7 +3958,7 @@ void Document::addMarker(Node* node, DocumentMarker newMarker) // copies markers from srcNode to dstNode, applying the specified shift delta to the copies. The shift is // useful if, e.g., the caller has created the dstNode from a non-prefix substring of the srcNode. -void Document::copyMarkers(Node *srcNode, unsigned startOffset, int length, Node *dstNode, int delta, DocumentMarker::MarkerType markerType) +void Document::copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta, DocumentMarker::MarkerType markerType) { if (length <= 0) return; @@ -4262,7 +4263,7 @@ void Document::invalidateRenderedRectsForMarkersInRect(const IntRect& r) } } -void Document::shiftMarkers(Node *node, unsigned startOffset, int delta, DocumentMarker::MarkerType markerType) +void Document::shiftMarkers(Node* node, unsigned startOffset, int delta, DocumentMarker::MarkerType markerType) { MarkerMapVectorPair* vectorPair = m_markers.get(node); if (!vectorPair) @@ -4274,7 +4275,7 @@ void Document::shiftMarkers(Node *node, unsigned startOffset, int delta, Documen bool docDirty = false; for (size_t i = 0; i != markers.size(); ++i) { - DocumentMarker &marker = markers[i]; + DocumentMarker& marker = markers[i]; if (marker.startOffset >= startOffset && (markerType == DocumentMarker::AllMarkers || marker.type == markerType)) { ASSERT((int)marker.startOffset + delta >= 0); marker.startOffset += delta; @@ -4319,7 +4320,7 @@ void Document::setMarkersActive(Node* node, unsigned startOffset, unsigned endOf bool docDirty = false; for (size_t i = 0; i != markers.size(); ++i) { - DocumentMarker &marker = markers[i]; + DocumentMarker& marker = markers[i]; // Markers are returned in order, so stop if we are now past the specified range. if (marker.startOffset >= endOffset) @@ -4381,21 +4382,21 @@ bool Document::inDesignMode() const return false; } -Document *Document::parentDocument() const +Document* Document::parentDocument() const { - Frame *childPart = frame(); + Frame* childPart = frame(); if (!childPart) return 0; - Frame *parent = childPart->tree()->parent(); + Frame* parent = childPart->tree()->parent(); if (!parent) return 0; return parent->document(); } -Document *Document::topDocument() const +Document* Document::topDocument() const { - Document *doc = const_cast<Document *>(this); - Element *element; + Document* doc = const_cast<Document *>(this); + Element* element; while ((element = doc->ownerElement())) doc = element->document(); @@ -4710,7 +4711,7 @@ unsigned FormElementKeyHash::hash(const FormElementKey& k) // this avoids ever returning a hash code of 0, since that is used to // signal "hash not computed yet", using a value that is likely to be // effectively the same as 0 when the low bits are masked - if (hash == 0) + if (!hash) hash = 0x80000000; return hash; @@ -4744,7 +4745,7 @@ bool Document::useSecureKeyboardEntryWhenActive() const void Document::initSecurityContext() { if (securityOrigin() && !securityOrigin()->isEmpty()) - return; // m_securityOrigin has already been initialized. + return; // m_securityOrigin has already been initialized. if (!m_frame) { // No source for a security context. @@ -4887,45 +4888,6 @@ void Document::updateFocusAppearanceTimerFired(Timer<Document>*) element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection); } -void Document::executeScriptSoonTimerFired(Timer<Document>* timer) -{ - ASSERT_UNUSED(timer, timer == &m_executeScriptSoonTimer); - - Vector<pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > scripts; - scripts.swap(m_scriptsToExecuteSoon); - size_t size = scripts.size(); - for (size_t i = 0; i < size; ++i) { - scripts[i].first->execute(scripts[i].second.get()); - scripts[i].first->element()->deref(); // Balances ref() in executeScriptSoon(). - } -} - -void Document::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<CachedScript> cachedScript) -{ - ASSERT_ARG(data, data); - - Element* element = data->element(); - ASSERT(element); - ASSERT(element->document() == this); - ASSERT(element->inDocument()); - - m_scriptsToExecuteSoon.append(make_pair(data, cachedScript)); - element->ref(); // Balanced by deref()s in executeScriptSoonTimerFired() and ~Document(). - if (!m_executeScriptSoonTimer.isActive()) - m_executeScriptSoonTimer.startOneShot(0); -} - -void Document::suspendExecuteScriptSoonTimer() -{ - m_executeScriptSoonTimer.stop(); -} - -void Document::resumeExecuteScriptSoonTimer() -{ - if (!m_scriptsToExecuteSoon.isEmpty()) - m_executeScriptSoonTimer.startOneShot(0); -} - // FF method for accessing the selection added for compatibility. DOMSelection* Document::getSelection() const { diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index 36379ee..ebe22cb 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -28,10 +28,10 @@ #include "CachedResourceHandle.h" #include "CheckedRadioButtons.h" -#include "ContainerNode.h" #include "CollectionCache.h" #include "CollectionType.h" #include "Color.h" +#include "ContainerNode.h" #include "Document.h" #include "DocumentMarker.h" #include "QualifiedName.h" @@ -48,99 +48,100 @@ namespace WebCore { - class Attr; - class AXObjectCache; - class CDATASection; - class CachedCSSStyleSheet; - class CachedScript; - class CanvasRenderingContext; - class CharacterData; - class CSSStyleDeclaration; - class CSSStyleSelector; - class CSSStyleSheet; - class Comment; - class Database; - class DOMImplementation; - class DOMSelection; - class DOMWindow; - class DatabaseThread; - class DocLoader; - class DocumentFragment; - class DocumentType; - class DocumentWeakReference; - class EditingText; - class Element; - class EntityReference; - class Event; - class EventListener; - class Frame; - class FrameView; - class HTMLCanvasElement; - class HTMLCollection; - class HTMLAllCollection; - class HTMLDocument; - class HTMLElement; - class HTMLFormElement; - class HTMLFrameOwnerElement; - class HTMLHeadElement; - class HTMLInputElement; - class HTMLMapElement; - class HistoryItem; - class HitTestRequest; - class HitTestResult; - class InspectorTimelineAgent; - class IntPoint; - class DOMWrapperWorld; - class JSNode; - class MediaCanStartListener; - class MouseEventWithHitTestResults; - class NodeFilter; - class NodeIterator; - class Page; - class PlatformMouseEvent; - class ProcessingInstruction; - class Range; - class RegisteredEventListener; - class RenderArena; - class RenderView; - class ScriptableDocumentParser; - class ScriptElementData; - class SecurityOrigin; - class SerializedScriptValue; - class SegmentedString; - class Settings; - class StyleSheet; - class StyleSheetList; - class Text; - class TextResourceDecoder; - class DocumentParser; - class TreeWalker; - class XMLHttpRequest; +class AsyncScriptRunner; +class Attr; +class AXObjectCache; +class CDATASection; +class CachedCSSStyleSheet; +class CachedScript; +class CanvasRenderingContext; +class CharacterData; +class CSSStyleDeclaration; +class CSSStyleSelector; +class CSSStyleSheet; +class Comment; +class Database; +class DOMImplementation; +class DOMSelection; +class DOMWindow; +class DatabaseThread; +class DocLoader; +class DocumentFragment; +class DocumentType; +class DocumentWeakReference; +class EditingText; +class Element; +class EntityReference; +class Event; +class EventListener; +class Frame; +class FrameView; +class HTMLCanvasElement; +class HTMLCollection; +class HTMLAllCollection; +class HTMLDocument; +class HTMLElement; +class HTMLFormElement; +class HTMLFrameOwnerElement; +class HTMLHeadElement; +class HTMLInputElement; +class HTMLMapElement; +class HistoryItem; +class HitTestRequest; +class HitTestResult; +class InspectorTimelineAgent; +class IntPoint; +class DOMWrapperWorld; +class JSNode; +class MediaCanStartListener; +class MouseEventWithHitTestResults; +class NodeFilter; +class NodeIterator; +class Page; +class PlatformMouseEvent; +class ProcessingInstruction; +class Range; +class RegisteredEventListener; +class RenderArena; +class RenderView; +class ScriptableDocumentParser; +class ScriptElementData; +class SecurityOrigin; +class SerializedScriptValue; +class SegmentedString; +class Settings; +class StyleSheet; +class StyleSheetList; +class Text; +class TextResourceDecoder; +class DocumentParser; +class TreeWalker; +class XMLHttpRequest; #if ENABLE(SVG) - class SVGDocumentExtensions; +class SVGDocumentExtensions; #endif - + #if ENABLE(XSLT) - class TransformSource; +class TransformSource; #endif #if ENABLE(XBL) - class XBLBindingManager; +class XBLBindingManager; #endif #if ENABLE(XPATH) - class XPathEvaluator; - class XPathExpression; - class XPathNSResolver; - class XPathResult; +class XPathEvaluator; +class XPathExpression; +class XPathNSResolver; +class XPathResult; #endif #if ENABLE(DASHBOARD_SUPPORT) - struct DashboardRegionValue; +struct DashboardRegionValue; #endif - typedef int ExceptionCode; +typedef int ExceptionCode; class FormElementKey { public: @@ -849,11 +850,8 @@ public: Document* topDocument() const; int docID() const { return m_docID; } - - void executeScriptSoon(ScriptElementData*, CachedResourceHandle<CachedScript>); - - void suspendExecuteScriptSoonTimer(); - void resumeExecuteScriptSoonTimer(); + + AsyncScriptRunner* asyncScriptRunner() { return m_asyncScriptRunner.get(); } #if ENABLE(XSLT) void applyXSLTransform(ProcessingInstruction* pi); @@ -869,8 +867,8 @@ public: XBLBindingManager* bindingManager() const { return m_bindingManager.get(); } #endif - void incDOMTreeVersion() { ++m_domtree_version; } - unsigned domTreeVersion() const { return m_domtree_version; } + void incDOMTreeVersion() { ++m_domTreeVersion; } + unsigned domTreeVersion() const { return m_domTreeVersion; } void setDocType(PassRefPtr<DocumentType>); @@ -1059,8 +1057,6 @@ private: String encoding() const; - void executeScriptSoonTimerFired(Timer<Document>*); - void updateTitle(); void updateFocusAppearanceTimerFired(Timer<Document>*); void updateBaseURL(); @@ -1083,10 +1079,10 @@ private: bool m_wellFormed; // Document URLs. - KURL m_url; // Document.URL: The URL from which this document was retrieved. - KURL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs. - KURL m_baseElementURL; // The URL set by the <base> element. - KURL m_cookieURL; // The URL to use for cookie access. + KURL m_url; // Document.URL: The URL from which this document was retrieved. + KURL m_baseURL; // Node.baseURI: The URL to use when resolving relative URLs. + KURL m_baseElementURL; // The URL set by the <base> element. + KURL m_cookieURL; // The URL to use for cookie access. KURL m_firstPartyForCookies; // The policy URL for third-party cookie blocking. // Document.documentURI: @@ -1137,7 +1133,7 @@ private: RefPtr<Node> m_activeNode; mutable RefPtr<Element> m_documentElement; - unsigned m_domtree_version; + unsigned m_domTreeVersion; HashSet<NodeIterator*> m_nodeIterators; HashSet<Range*> m_ranges; @@ -1212,10 +1208,9 @@ private: // using setExtraLayoutDelay to modify the minimum delay used at different // points during the lifetime of the Document. int m_extraLayoutDelay; - - Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon; - Timer<Document> m_executeScriptSoonTimer; + OwnPtr<AsyncScriptRunner> m_asyncScriptRunner; + #if ENABLE(XSLT) OwnPtr<TransformSource> m_transformSource; RefPtr<Document> m_transformSourceDocument; diff --git a/WebCore/dom/DocumentFragment.cpp b/WebCore/dom/DocumentFragment.cpp index ecc5725..47485b7 100644 --- a/WebCore/dom/DocumentFragment.cpp +++ b/WebCore/dom/DocumentFragment.cpp @@ -82,16 +82,16 @@ bool DocumentFragment::shouldUseLegacyHTMLParser() const && !document()->page()->settings()->html5ParserEnabled(); } -void DocumentFragment::parseHTML(const String& source, FragmentScriptingPermission scriptingPermission) +void DocumentFragment::parseHTML(const String& source, Element* contextElement, FragmentScriptingPermission scriptingPermission) { if (shouldUseLegacyHTMLParser()) return LegacyHTMLDocumentParser::parseDocumentFragment(source, this, scriptingPermission); - HTMLDocumentParser::parseDocumentFragment(source, this, scriptingPermission); + HTMLDocumentParser::parseDocumentFragment(source, this, contextElement, scriptingPermission); } -bool DocumentFragment::parseXML(const String& source, Element* parent, FragmentScriptingPermission scriptingPermission) +bool DocumentFragment::parseXML(const String& source, Element* contextElement, FragmentScriptingPermission scriptingPermission) { - return XMLDocumentParser::parseDocumentFragment(source, this, parent, scriptingPermission); + return XMLDocumentParser::parseDocumentFragment(source, this, contextElement, scriptingPermission); } } diff --git a/WebCore/dom/DocumentFragment.h b/WebCore/dom/DocumentFragment.h index 5eff17f..d3dadb8 100644 --- a/WebCore/dom/DocumentFragment.h +++ b/WebCore/dom/DocumentFragment.h @@ -33,8 +33,8 @@ class DocumentFragment : public ContainerNode { public: static PassRefPtr<DocumentFragment> create(Document*); - void parseHTML(const String&, FragmentScriptingPermission = FragmentScriptingAllowed); - bool parseXML(const String&, Element* parent, FragmentScriptingPermission = FragmentScriptingAllowed); + void parseHTML(const String&, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed); + bool parseXML(const String&, Element* contextElement, FragmentScriptingPermission = FragmentScriptingAllowed); private: DocumentFragment(Document*); diff --git a/WebCore/dom/DocumentMarker.h b/WebCore/dom/DocumentMarker.h index 8945eb0..55d2e33 100644 --- a/WebCore/dom/DocumentMarker.h +++ b/WebCore/dom/DocumentMarker.h @@ -24,9 +24,9 @@ #define DocumentMarker_h #include "PlatformString.h" +#include <wtf/Forward.h> namespace WebCore { - class String; // A range of a node within a document that is "marked", such as the range of a misspelled word. // It optionally includes a description that could be displayed in the user interface. diff --git a/WebCore/dom/DynamicNodeList.h b/WebCore/dom/DynamicNodeList.h index f97c38f..db133b7 100644 --- a/WebCore/dom/DynamicNodeList.h +++ b/WebCore/dom/DynamicNodeList.h @@ -31,7 +31,6 @@ namespace WebCore { - class AtomicString; class Element; class Node; diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index 2fa75ce..0e89e93 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -95,7 +95,7 @@ PassRefPtr<DocumentFragment> Element::createContextualFragment(const String& mar RefPtr<DocumentFragment> fragment = document()->createDocumentFragment(); if (document()->isHTMLDocument()) - fragment->parseHTML(markup, scriptingPermission); + fragment->parseHTML(markup, this, scriptingPermission); else { if (!fragment->parseXML(markup, this, scriptingPermission)) // FIXME: We should propagate a syntax error exception out here. diff --git a/WebCore/dom/Event.cpp b/WebCore/dom/Event.cpp index 4ea3e0c..1aab5c7 100644 --- a/WebCore/dom/Event.cpp +++ b/WebCore/dom/Event.cpp @@ -213,6 +213,11 @@ bool Event::isTouchEvent() const #endif #if ENABLE(DEVICE_ORIENTATION) +bool Event::isDeviceMotionEvent() const +{ + return false; +} + bool Event::isDeviceOrientationEvent() const { return false; diff --git a/WebCore/dom/Event.h b/WebCore/dom/Event.h index 2b570d5..e18258c 100644 --- a/WebCore/dom/Event.h +++ b/WebCore/dom/Event.h @@ -140,6 +140,7 @@ namespace WebCore { virtual bool isTouchEvent() const; #endif #if ENABLE(DEVICE_ORIENTATION) + virtual bool isDeviceMotionEvent() const; virtual bool isDeviceOrientationEvent() const; #endif bool fromUserGesture(); diff --git a/WebCore/dom/EventNames.h b/WebCore/dom/EventNames.h index 65abfbf..6c67b9f 100644 --- a/WebCore/dom/EventNames.h +++ b/WebCore/dom/EventNames.h @@ -42,6 +42,7 @@ namespace WebCore { macro(checking) \ macro(click) \ macro(close) \ + macro(complete) \ macro(compositionend) \ macro(compositionstart) \ macro(compositionupdate) \ @@ -50,6 +51,7 @@ namespace WebCore { macro(copy) \ macro(cut) \ macro(dblclick) \ + macro(devicemotion) \ macro(deviceorientation) \ macro(display) \ macro(downloading) \ @@ -150,6 +152,8 @@ namespace WebCore { \ macro(orientationchange) \ \ + macro(timeout) \ + \ macro(touchstart) \ macro(touchmove) \ macro(touchend) \ diff --git a/WebCore/dom/EventTarget.cpp b/WebCore/dom/EventTarget.cpp index cb6be7a..42a153a 100644 --- a/WebCore/dom/EventTarget.cpp +++ b/WebCore/dom/EventTarget.cpp @@ -156,7 +156,7 @@ Notification* EventTarget::toNotification() } #endif -#if ENABLE(FILE_READER) +#if ENABLE(BLOB) FileReader* EventTarget::toFileReader() { return 0; diff --git a/WebCore/dom/EventTarget.h b/WebCore/dom/EventTarget.h index 0e8c343..406c2fd 100644 --- a/WebCore/dom/EventTarget.h +++ b/WebCore/dom/EventTarget.h @@ -41,7 +41,6 @@ namespace WebCore { class AbstractWorker; - class AtomicString; class DedicatedWorkerContext; class DOMApplicationCache; class DOMWindow; @@ -120,7 +119,7 @@ namespace WebCore { #if ENABLE(NOTIFICATIONS) virtual Notification* toNotification(); #endif -#if ENABLE(FILE_READER) +#if ENABLE(BLOB) virtual FileReader* toFileReader(); #endif diff --git a/WebCore/dom/ExceptionCode.h b/WebCore/dom/ExceptionCode.h index ef73052..ed15a2e 100644 --- a/WebCore/dom/ExceptionCode.h +++ b/WebCore/dom/ExceptionCode.h @@ -61,7 +61,7 @@ namespace WebCore { // Introduced in File API: // http://www.w3.org/TR/file-upload/#dfn-fileerror -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) NOT_READABLE_ERR = 24, ENCODING_ERR = 26, #endif diff --git a/WebCore/dom/MessagePort.h b/WebCore/dom/MessagePort.h index 65332b8..10426e5 100644 --- a/WebCore/dom/MessagePort.h +++ b/WebCore/dom/MessagePort.h @@ -31,6 +31,7 @@ #include "EventListener.h" #include "EventTarget.h" #include "MessagePortChannel.h" +#include <wtf/Forward.h> #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> @@ -39,12 +40,10 @@ namespace WebCore { - class AtomicStringImpl; class Event; class Frame; class MessagePort; class ScriptExecutionContext; - class String; // The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1. typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; diff --git a/WebCore/dom/MessagePortChannel.h b/WebCore/dom/MessagePortChannel.h index 192cb92..f308a29 100644 --- a/WebCore/dom/MessagePortChannel.h +++ b/WebCore/dom/MessagePortChannel.h @@ -36,6 +36,7 @@ #include "SerializedScriptValue.h" #include <wtf/OwnPtr.h> +#include <wtf/Forward.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -48,7 +49,6 @@ namespace WebCore { class PlatformMessagePortChannel; class ScriptExecutionContext; class SerializedScriptValue; - class String; // The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1. typedef Vector<OwnPtr<MessagePortChannel>, 1> MessagePortChannelArray; diff --git a/WebCore/dom/NameNodeList.h b/WebCore/dom/NameNodeList.h index 4f109b4..b7f5bfc 100644 --- a/WebCore/dom/NameNodeList.h +++ b/WebCore/dom/NameNodeList.h @@ -26,11 +26,10 @@ #include "AtomicString.h" #include "DynamicNodeList.h" +#include <wtf/Forward.h> namespace WebCore { - class String; - // NodeList which lists all Nodes in a Element with a given "name" attribute class NameNodeList : public DynamicNodeList { public: diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h index 8a76084..b407ac4 100644 --- a/WebCore/dom/Node.h +++ b/WebCore/dom/Node.h @@ -30,20 +30,18 @@ #include "RenderStyleConstants.h" #include "ScriptWrappable.h" #include "TreeShared.h" +#include <wtf/Forward.h> #include <wtf/ListHashSet.h> #if USE(JSC) namespace JSC { - - class JSGlobalData; - class MarkStack; - +class JSGlobalData; +class MarkStack; } #endif namespace WebCore { -class AtomicString; class Attribute; class ClassNodeList; class ContainerNode; diff --git a/WebCore/dom/NodeList.h b/WebCore/dom/NodeList.h index 99a0662..d4e18aa 100644 --- a/WebCore/dom/NodeList.h +++ b/WebCore/dom/NodeList.h @@ -24,11 +24,11 @@ #ifndef NodeList_h #define NodeList_h +#include <wtf/Forward.h> #include <wtf/RefCounted.h> namespace WebCore { - class AtomicString; class Node; class NodeList : public RefCounted<NodeList> { diff --git a/WebCore/dom/OptionGroupElement.h b/WebCore/dom/OptionGroupElement.h index e4b1566..b98a3f2 100644 --- a/WebCore/dom/OptionGroupElement.h +++ b/WebCore/dom/OptionGroupElement.h @@ -21,10 +21,11 @@ #ifndef OptionGroupElement_h #define OptionGroupElement_h +#include <wtf/Forward.h> + namespace WebCore { class Element; -class String; class OptionGroupElement { public: diff --git a/WebCore/dom/PendingScript.cpp b/WebCore/dom/PendingScript.cpp new file mode 100644 index 0000000..42e225a --- /dev/null +++ b/WebCore/dom/PendingScript.cpp @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2010 Google, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "PendingScript.h" + +#include "CachedScript.h" +#include "Element.h" + +namespace WebCore { + +PendingScript::~PendingScript() +{ + if (m_cachedScript) + m_cachedScript->removeClient(this); +} + +PassRefPtr<Element> PendingScript::releaseElementAndClear() +{ + setCachedScript(0); + m_startingLineNumber = 0; + m_watchingForLoad = false; + return m_element.release(); +} + +void PendingScript::setCachedScript(CachedScript* cachedScript) +{ + if (m_cachedScript == cachedScript) + return; + if (m_cachedScript) + m_cachedScript->removeClient(this); + m_cachedScript = cachedScript; + if (m_cachedScript) + m_cachedScript->addClient(this); +} + +CachedScript* PendingScript::cachedScript() const +{ + return m_cachedScript.get(); +} + +void PendingScript::notifyFinished(CachedResource*) +{ +} + +} diff --git a/WebCore/dom/PendingScript.h b/WebCore/dom/PendingScript.h new file mode 100644 index 0000000..805f7ff --- /dev/null +++ b/WebCore/dom/PendingScript.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 Google, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PendingScript_h +#define PendingScript_h + +#include "CachedResourceClient.h" +#include "CachedResourceHandle.h" +#include <wtf/Noncopyable.h> +#include <wtf/PassRefPtr.h> + +namespace WebCore { + +class CachedScript; +class Element; + +// A container for an external script which may be loaded and executed. +// +// A CachedResourceHandle alone does not prevent the underlying CachedResource +// from purging its data buffer. This class holds a dummy client open for its +// lifetime in order to guarantee that the data buffer will not be purged. +class PendingScript : public Noncopyable, CachedResourceClient { +public: + PendingScript() + : m_startingLineNumber(0) + , m_watchingForLoad(false) + { + } + + ~PendingScript(); + + // FIXME: No setter means this is never set to anything other than 0. + // This is either unnecessary or incorrect. + int startingLineNumber() const { return m_startingLineNumber; } + + bool watchingForLoad() const { return m_watchingForLoad; } + void setWatchingForLoad(bool b) { m_watchingForLoad = b; } + + Element* element() const { return m_element.get(); } + void adoptElement(Element* element) { m_element = element; } + PassRefPtr<Element> releaseElementAndClear(); + + CachedScript* cachedScript() const; + void setCachedScript(CachedScript*); + + virtual void notifyFinished(CachedResource*); + +private: + int m_startingLineNumber; // Only used for inline script tags. + bool m_watchingForLoad; + RefPtr<Element> m_element; + CachedResourceHandle<CachedScript> m_cachedScript; +}; + +} + +#endif diff --git a/WebCore/dom/Position.cpp b/WebCore/dom/Position.cpp index 65b7261..4758bd9 100644 --- a/WebCore/dom/Position.cpp +++ b/WebCore/dom/Position.cpp @@ -328,6 +328,23 @@ bool Position::atEditingBoundary() const && prevPosition.isNotNull() && !prevPosition.node()->isContentEditable(); } +Node* Position::parentEditingBoundary() const +{ + if (!m_anchorNode || !m_anchorNode->document()) + return 0; + + Node* documentElement = m_anchorNode->document()->documentElement(); + if (!documentElement) + return 0; + + Node* boundary = m_anchorNode.get(); + while (boundary != documentElement && boundary->parentNode() && m_anchorNode->isContentEditable() == boundary->parentNode()->isContentEditable()) + boundary = boundary->parentNode(); + + return boundary; +} + + bool Position::atStartOfTree() const { if (isNull()) diff --git a/WebCore/dom/Position.h b/WebCore/dom/Position.h index f606c29..9f2ee24 100644 --- a/WebCore/dom/Position.h +++ b/WebCore/dom/Position.h @@ -138,6 +138,7 @@ public: // Returns true if the visually equivalent positions around have different editability bool atEditingBoundary() const; + Node* parentEditingBoundary() const; bool atStartOfTree() const; bool atEndOfTree() const; diff --git a/WebCore/dom/QualifiedName.cpp b/WebCore/dom/QualifiedName.cpp index 7cc809f..7c29ce0 100644 --- a/WebCore/dom/QualifiedName.cpp +++ b/WebCore/dom/QualifiedName.cpp @@ -88,8 +88,12 @@ void QualifiedName::deref() String QualifiedName::toString() const { String local = localName(); - if (hasPrefix()) - return prefix() + ":" + local; + if (hasPrefix()) { + String result = prefix().string(); + result.append(":"); + result.append(local); + return result; + } return local; } diff --git a/WebCore/dom/QualifiedName.h b/WebCore/dom/QualifiedName.h index 672a302..4391570 100644 --- a/WebCore/dom/QualifiedName.h +++ b/WebCore/dom/QualifiedName.h @@ -170,7 +170,7 @@ namespace WTF { template<> struct HashTraits<WebCore::QualifiedName> : GenericHashTraits<WebCore::QualifiedName> { static const bool emptyValueIsZero = false; - static WebCore::QualifiedName emptyValue() { return WebCore::QualifiedName(WebCore::nullAtom, WebCore::nullAtom, WebCore::nullAtom); } + static WebCore::QualifiedName emptyValue() { return WebCore::QualifiedName(nullAtom, nullAtom, nullAtom); } static void constructDeletedValue(WebCore::QualifiedName& slot) { new (&slot) WebCore::QualifiedName(WTF::HashTableDeletedValue); } static bool isDeletedValue(const WebCore::QualifiedName& slot) { return slot.isHashTableDeletedValue(); } }; diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp index dab8f8c..0262e48 100644 --- a/WebCore/dom/ScriptElement.cpp +++ b/WebCore/dom/ScriptElement.cpp @@ -24,6 +24,7 @@ #include "config.h" #include "ScriptElement.h" +#include "AsyncScriptRunner.h" #include "CachedScript.h" #include "DocLoader.h" #include "Document.h" @@ -246,7 +247,7 @@ void ScriptElementData::execute(CachedScript* cachedScript) void ScriptElementData::notifyFinished(CachedResource* o) { ASSERT_UNUSED(o, o == m_cachedScript); - m_element->document()->executeScriptSoon(this, m_cachedScript); + m_element->document()->asyncScriptRunner()->executeScriptSoon(this, m_cachedScript); m_cachedScript = 0; } diff --git a/WebCore/dom/ScriptExecutionContext.cpp b/WebCore/dom/ScriptExecutionContext.cpp index 291243d..f7ac603 100644 --- a/WebCore/dom/ScriptExecutionContext.cpp +++ b/WebCore/dom/ScriptExecutionContext.cpp @@ -31,7 +31,7 @@ #include "Database.h" #include "DatabaseTask.h" #include "DatabaseThread.h" -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) #include "FileThread.h" #endif #include "MessagePort.h" @@ -86,7 +86,7 @@ ScriptExecutionContext::~ScriptExecutionContext() m_databaseThread = 0; } #endif -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) if (m_fileThread) { m_fileThread->stop(); m_fileThread = 0; @@ -241,7 +241,7 @@ DOMTimer* ScriptExecutionContext::findTimeout(int timeoutId) return m_timeouts.get(timeoutId); } -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) FileThread* ScriptExecutionContext::fileThread() { if (!m_fileThread) { diff --git a/WebCore/dom/ScriptExecutionContext.h b/WebCore/dom/ScriptExecutionContext.h index 4cd483a..d2da307 100644 --- a/WebCore/dom/ScriptExecutionContext.h +++ b/WebCore/dom/ScriptExecutionContext.h @@ -29,6 +29,7 @@ #include "Console.h" #include "KURL.h" +#include <wtf/Forward.h> #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/PassOwnPtr.h> @@ -45,13 +46,12 @@ namespace WebCore { class DatabaseThread; #endif class DOMTimer; -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) class FileThread; #endif class MessagePort; class SecurityOrigin; class ScriptString; - class String; #if ENABLE(INSPECTOR) class InspectorController; #endif @@ -129,7 +129,7 @@ namespace WebCore { JSC::JSGlobalData* globalData(); #endif -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) FileThread* fileThread(); void stopFileThread(); #endif @@ -160,7 +160,7 @@ namespace WebCore { bool m_hasOpenDatabases; // This never changes back to false, even after the database thread is closed. #endif -#if ENABLE(FILE_READER) || ENABLE(FILE_WRITER) +#if ENABLE(BLOB) || ENABLE(FILE_WRITER) RefPtr<FileThread> m_fileThread; #endif }; diff --git a/WebCore/dom/SelectElement.h b/WebCore/dom/SelectElement.h index 3831ac4..f00bb67 100644 --- a/WebCore/dom/SelectElement.h +++ b/WebCore/dom/SelectElement.h @@ -23,6 +23,7 @@ #define SelectElement_h #include "Event.h" +#include <wtf/Forward.h> #include <wtf/Vector.h> namespace WebCore { @@ -34,7 +35,6 @@ class FormDataList; class HTMLFormElement; class KeyboardEvent; class SelectElementData; -class String; class SelectElement { public: diff --git a/WebCore/dom/TextEvent.cpp b/WebCore/dom/TextEvent.cpp index d282c13..5dc39e3 100644 --- a/WebCore/dom/TextEvent.cpp +++ b/WebCore/dom/TextEvent.cpp @@ -31,17 +31,45 @@ namespace WebCore { +PassRefPtr<TextEvent> TextEvent::create() +{ + return adoptRef(new TextEvent); +} + +PassRefPtr<TextEvent> TextEvent::create(PassRefPtr<AbstractView> view, const String& data) +{ + return adoptRef(new TextEvent(view, data)); +} + +PassRefPtr<TextEvent> TextEvent::createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace) +{ + return adoptRef(new TextEvent(view, data, 0, true, shouldSmartReplace)); +} + +PassRefPtr<TextEvent> TextEvent::createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle) +{ + return adoptRef(new TextEvent(view, "", data, true, shouldSmartReplace, shouldMatchStyle)); +} + TextEvent::TextEvent() : m_isLineBreak(false) , m_isBackTab(false) + , m_isPaste(false) + , m_shouldSmartReplace(false) + , m_shouldMatchStyle(false) { } -TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data) +TextEvent::TextEvent(PassRefPtr<AbstractView> view, const String& data, PassRefPtr<DocumentFragment> pastingFragment, + bool isPaste, bool shouldSmartReplace, bool shouldMatchStyle) : UIEvent(eventNames().textInputEvent, true, true, view, 0) , m_data(data) , m_isLineBreak(false) , m_isBackTab(false) + , m_pastingFragment(pastingFragment) + , m_isPaste(isPaste) + , m_shouldSmartReplace(shouldSmartReplace) + , m_shouldMatchStyle(shouldMatchStyle) { } diff --git a/WebCore/dom/TextEvent.h b/WebCore/dom/TextEvent.h index 9f93fdb..2e2eb95 100644 --- a/WebCore/dom/TextEvent.h +++ b/WebCore/dom/TextEvent.h @@ -27,20 +27,18 @@ #ifndef TextEvent_h #define TextEvent_h +#include "DocumentFragment.h" #include "UIEvent.h" namespace WebCore { class TextEvent : public UIEvent { public: - static PassRefPtr<TextEvent> create() - { - return adoptRef(new TextEvent); - } - static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView> view, const String& data) - { - return adoptRef(new TextEvent(view, data)); - } + static PassRefPtr<TextEvent> create(); + static PassRefPtr<TextEvent> create(PassRefPtr<AbstractView> view, const String& data); + static PassRefPtr<TextEvent> createForPlainTextPaste(PassRefPtr<AbstractView> view, const String& data, bool shouldSmartReplace); + static PassRefPtr<TextEvent> createForFragmentPaste(PassRefPtr<AbstractView> view, PassRefPtr<DocumentFragment> data, bool shouldSmartReplace, bool shouldMatchStyle); + virtual ~TextEvent(); void initTextEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, const String& data); @@ -57,13 +55,24 @@ namespace WebCore { bool isBackTab() const { return m_isBackTab; } void setIsBackTab(bool isBackTab) { m_isBackTab = isBackTab; } + bool isPaste() const { return m_isPaste; } + bool shouldSmartReplace() const { return m_shouldSmartReplace; } + bool shouldMatchStyle() const { return m_shouldMatchStyle; } + DocumentFragment* pastingFragment() const { return m_pastingFragment.get(); } + private: TextEvent(); - TextEvent(PassRefPtr<AbstractView>, const String& data); + TextEvent(PassRefPtr<AbstractView>, const String& data, PassRefPtr<DocumentFragment> = 0, + bool isPaste = false, bool shouldSmartReplace = false, bool shouldMatchStyle = false); String m_data; bool m_isLineBreak; bool m_isBackTab; + + RefPtr<DocumentFragment> m_pastingFragment; + bool m_isPaste; // FIXME: Should use inputMode after it be available: http://webkit.org/b/42805 + bool m_shouldSmartReplace; + bool m_shouldMatchStyle; }; } // namespace WebCore diff --git a/WebCore/dom/ViewportArguments.cpp b/WebCore/dom/ViewportArguments.cpp index c507032..9f831dd 100644 --- a/WebCore/dom/ViewportArguments.cpp +++ b/WebCore/dom/ViewportArguments.cpp @@ -53,6 +53,20 @@ void setViewportFeature(const String& keyString, const String& valueString, Docu didUseConstants = true; if (document->page()) value = document->page()->chrome()->windowRect().height(); + } else if (equalIgnoringCase(valueString, "device-dpi")) { + didUseConstants = true; + // Default of today is 160dpi, resulting in a scaleFactor of 1.0. + if (document->page()) + value = 160 * document->page()->chrome()->scaleFactor(); + } else if (equalIgnoringCase(valueString, "low-dpi")) { + didUseConstants = true; + value = 120; + } else if (equalIgnoringCase(valueString, "medium-dpi")) { + didUseConstants = true; + value = 160; + } else if (equalIgnoringCase(valueString, "high-dpi")) { + didUseConstants = true; + value = 240; } else if (equalIgnoringCase(valueString, "default")) // This allows us to distinguish the omission of a key from asking for the default value. value = -2; else if (valueString.length()) // listing a key with no value is shorthand for key=default @@ -80,19 +94,23 @@ void setViewportFeature(const String& keyString, const String& valueString, Docu reportViewportWarning(document, DeviceWidthShouldBeUsedWarning, keyString); else if (document->page() && value == document->page()->chrome()->windowRect().height() && !didUseConstants) reportViewportWarning(document, DeviceHeightShouldBeUsedWarning, keyString); - arguments->height = value; + } else if (keyString == "target-densitydpi" || keyString == "target-densityDpi") { + if (!didUseConstants && (value < 70 || value > 400)) + reportViewportWarning(document, TargetDensityDpiTooSmallOrLargeError, keyString); + arguments->targetDensityDpi = value; } else reportViewportWarning(document, UnrecognizedViewportArgumentError, keyString); } static const char* viewportErrorMessageTemplate(ViewportErrorCode errorCode) { - static const char* const errors[] = { + static const char* const errors[] = { "Viewport width or height set to physical device width, try using \"device-width\" constant instead for future compatibility.", "Viewport height or height set to physical device height, try using \"device-height\" constant instead for future compatibility.", "Viewport argument \"%replacement\" not recognized. Content ignored.", - "Viewport maximum-scale cannot be larger than 10.0. The maximum-scale will be set to 10.0." + "Viewport maximum-scale cannot be larger than 10.0. The maximum-scale will be set to 10.0.", + "Viewport target-densitydpi has to take a number between 70 and 400 as a valid target dpi, try using \"device-dpi\", \"low-dpi\", \"medium-dpi\" or \"high-dpi\" instead for future compatibility." }; return errors[errorCode]; diff --git a/WebCore/dom/ViewportArguments.h b/WebCore/dom/ViewportArguments.h index 29eec8e..1fac0df 100644 --- a/WebCore/dom/ViewportArguments.h +++ b/WebCore/dom/ViewportArguments.h @@ -26,16 +26,18 @@ #ifndef ViewportArguments_h #define ViewportArguments_h +#include <wtf/Forward.h> + namespace WebCore { class Document; -class String; enum ViewportErrorCode { DeviceWidthShouldBeUsedWarning, DeviceHeightShouldBeUsedWarning, UnrecognizedViewportArgumentError, - MaximumScaleTooLargeError + MaximumScaleTooLargeError, + TargetDensityDpiTooSmallOrLargeError }; struct ViewportArguments { @@ -48,6 +50,7 @@ struct ViewportArguments { , maximumScale(ValueUndefined) , width(ValueUndefined) , height(ValueUndefined) + , targetDensityDpi(ValueUndefined) , userScalable(ValueUndefined) { } @@ -57,12 +60,13 @@ struct ViewportArguments { float maximumScale; float width; float height; + float targetDensityDpi; float userScalable; bool hasCustomArgument() const { - return initialScale != ValueUndefined || minimumScale != ValueUndefined || maximumScale != ValueUndefined || width != ValueUndefined || height != ValueUndefined || userScalable != ValueUndefined; + return initialScale != ValueUndefined || minimumScale != ValueUndefined || maximumScale != ValueUndefined || width != ValueUndefined || height != ValueUndefined || userScalable != ValueUndefined || targetDensityDpi != ValueUndefined; } }; diff --git a/WebCore/dom/XMLDocumentParser.h b/WebCore/dom/XMLDocumentParser.h index a6cc9a0..e7e209a 100644 --- a/WebCore/dom/XMLDocumentParser.h +++ b/WebCore/dom/XMLDocumentParser.h @@ -201,6 +201,11 @@ namespace WebCore { static bool parseDocumentFragment(const String&, DocumentFragment*, Element* parent = 0, FragmentScriptingPermission = FragmentScriptingAllowed); + // WMLErrorHandling uses these functions. + virtual bool wellFormed() const { return !m_sawError; } + virtual int lineNumber() const; + virtual int columnNumber() const; + private: // From DocumentParser virtual void insert(const SegmentedString&); @@ -209,9 +214,6 @@ namespace WebCore { virtual bool finishWasCalled(); virtual bool isWaitingForScripts() const; virtual void stopParsing(); - virtual bool wellFormed() const { return !m_sawError; } - virtual int lineNumber() const; - virtual int columnNumber() const; // from CachedResourceClient virtual void notifyFinished(CachedResource*); diff --git a/WebCore/dom/XMLDocumentParserQt.cpp b/WebCore/dom/XMLDocumentParserQt.cpp index c702c09..678d141 100644 --- a/WebCore/dom/XMLDocumentParserQt.cpp +++ b/WebCore/dom/XMLDocumentParserQt.cpp @@ -325,7 +325,8 @@ static inline void handleElementNamespaces(Element* newElement, const QXmlStream for (int i = 0; i < ns.count(); ++i) { const QXmlStreamNamespaceDeclaration &decl = ns[i]; String namespaceURI = decl.namespaceUri(); - String namespaceQName = decl.prefix().isEmpty() ? String("xmlns") : String("xmlns:") + String(decl.prefix()); + String namespaceQName = decl.prefix().isEmpty() ? String("xmlns") : String("xmlns:"); + namespaceQName.append(decl.prefix()); newElement->setAttributeNS("http://www.w3.org/2000/xmlns/", namespaceQName, namespaceURI, ec, scriptingPermission); if (ec) // exception setting attributes return; diff --git a/WebCore/dom/make_names.pl b/WebCore/dom/make_names.pl index 9e0784a..4b4c7e3 100755 --- a/WebCore/dom/make_names.pl +++ b/WebCore/dom/make_names.pl @@ -470,7 +470,7 @@ sub printNamesHeaderFile my $lowerNamespace = lc($parameters{namespacePrefix}); print F "#ifndef DOM_$parameters{namespace}NAMES_HIDE_GLOBALS\n"; print F "// Namespace\n"; - print F "extern const WebCore::AtomicString ${lowerNamespace}NamespaceURI;\n\n"; + print F "extern const WTF::AtomicString ${lowerNamespace}NamespaceURI;\n\n"; if (keys %allTags) { print F "// Tags\n"; @@ -770,13 +770,13 @@ sub printFactoryHeaderFile #ifndef $parameters{namespace}ElementFactory_h #define $parameters{namespace}ElementFactory_h +#include <wtf/Forward.h> #include <wtf/PassRefPtr.h> namespace WebCore { class Element; class Document; class QualifiedName; - class AtomicString; } namespace WebCore { @@ -970,7 +970,7 @@ END print F <<END JSNode* createJS$parameters{namespace}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element) { - typedef HashMap<WebCore::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap; + typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap; DEFINE_STATIC_LOCAL(FunctionMap, map, ()); if (map.isEmpty()) { END @@ -979,7 +979,7 @@ END print F <<END v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element* element, bool forceNewObject) { - typedef HashMap<WebCore::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap; + typedef HashMap<WTF::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap; DEFINE_STATIC_LOCAL(FunctionMap, map, ()); if (map.isEmpty()) { END |