diff options
Diffstat (limited to 'WebCore/dom')
30 files changed, 286 insertions, 202 deletions
diff --git a/WebCore/dom/Attr.cpp b/WebCore/dom/Attr.cpp index 59daa59..f497394 100644 --- a/WebCore/dom/Attr.cpp +++ b/WebCore/dom/Attr.cpp @@ -117,13 +117,21 @@ String Attr::nodeValue() const return value(); } -void Attr::setValue(const AtomicString& value, ExceptionCode&) +void Attr::setValue(const AtomicString& value) { m_ignoreChildrenChanged++; removeChildren(); m_attribute->setValue(value); createTextChild(); m_ignoreChildrenChanged--; +} + +void Attr::setValue(const AtomicString& value, ExceptionCode&) +{ + if (m_element && m_element->isIdAttributeName(m_attribute->name())) + m_element->updateId(m_element->getIdAttribute(), value); + + setValue(value); if (m_element) m_element->attributeChanged(m_attribute.get()); @@ -167,7 +175,10 @@ void Attr::childrenChanged(bool changedByParser, Node* beforeChange, Node* after if (n->isTextNode()) val += static_cast<Text *>(n)->data(); } - + + if (m_element && m_element->isIdAttributeName(m_attribute->name())) + m_element->updateId(m_attribute->value(), val); + m_attribute->setValue(val.impl()); if (m_element) m_element->attributeChanged(m_attribute.get()); diff --git a/WebCore/dom/Attr.h b/WebCore/dom/Attr.h index 2e02a02..e76d2fa 100644 --- a/WebCore/dom/Attr.h +++ b/WebCore/dom/Attr.h @@ -48,6 +48,7 @@ public: const AtomicString& value() const { return m_attribute->value(); } void setValue(const AtomicString&, ExceptionCode&); + void setValue(const AtomicString&); Attribute* attr() const { return m_attribute.get(); } const QualifiedName& qualifiedName() const { return m_attribute->name(); } diff --git a/WebCore/dom/CharacterData.cpp b/WebCore/dom/CharacterData.cpp index 7accbfb..bc9ec56 100644 --- a/WebCore/dom/CharacterData.cpp +++ b/WebCore/dom/CharacterData.cpp @@ -24,6 +24,7 @@ #include "EventNames.h" #include "ExceptionCode.h" +#include "InspectorController.h" #include "MutationEvent.h" #include "RenderText.h" @@ -197,6 +198,9 @@ void CharacterData::dispatchModifiedEvent(StringImpl* prevValue) if (document()->hasListenerType(Document::DOMCHARACTERDATAMODIFIED_LISTENER)) dispatchEvent(MutationEvent::create(eventNames().DOMCharacterDataModifiedEvent, true, 0, prevValue, m_data)); dispatchSubtreeModifiedEvent(); +#if ENABLE(INSPECTOR) + InspectorController::characterDataModified(this); +#endif } void CharacterData::checkCharDataOperation(unsigned offset, ExceptionCode& ec) diff --git a/WebCore/dom/Clipboard.cpp b/WebCore/dom/Clipboard.cpp index d644bcc..6956257 100644 --- a/WebCore/dom/Clipboard.cpp +++ b/WebCore/dom/Clipboard.cpp @@ -33,12 +33,12 @@ namespace WebCore { -Clipboard::Clipboard(ClipboardAccessPolicy policy, bool isForDragging) +Clipboard::Clipboard(ClipboardAccessPolicy policy, ClipboardType clipboardType) : m_policy(policy) , m_dropEffect("uninitialized") , m_effectAllowed("uninitialized") , m_dragStarted(false) - , m_forDragging(isForDragging) + , m_clipboardType(clipboardType) , m_dragImage(0) { } @@ -127,7 +127,7 @@ void Clipboard::setDestinationOperation(DragOperation op) void Clipboard::setDropEffect(const String &effect) { - if (!m_forDragging) + if (!isForDragAndDrop()) return; // The attribute must ignore any attempts to set it to a value other than none, copy, link, and move. @@ -140,7 +140,7 @@ void Clipboard::setDropEffect(const String &effect) void Clipboard::setEffectAllowed(const String &effect) { - if (!m_forDragging) + if (!isForDragAndDrop()) return; if (dragOpFromIEOp(effect) == DragOperationPrivate) { diff --git a/WebCore/dom/Clipboard.h b/WebCore/dom/Clipboard.h index 0562280..b8eadfb 100644 --- a/WebCore/dom/Clipboard.h +++ b/WebCore/dom/Clipboard.h @@ -40,12 +40,17 @@ namespace WebCore { // State available during IE's events for drag and drop and copy/paste class Clipboard : public RefCounted<Clipboard> { public: + // Whether this clipboard is serving a drag-drop or copy-paste request. + enum ClipboardType { + CopyAndPaste, + DragAndDrop, + }; static PassRefPtr<Clipboard> create(ClipboardAccessPolicy, DragData*, Frame*); virtual ~Clipboard() { } - // Is this operation a drag-drop or a copy-paste? - bool isForDragging() const { return m_forDragging; } + bool isForCopyAndPaste() const { return m_clipboardType == CopyAndPaste; } + bool isForDragAndDrop() const { return m_clipboardType == DragAndDrop; } String dropEffect() const { return dropEffectIsUninitialized() ? "none" : m_dropEffect; } void setDropEffect(const String&); @@ -88,7 +93,7 @@ namespace WebCore { void setDragHasStarted() { m_dragStarted = true; } protected: - Clipboard(ClipboardAccessPolicy, bool isForDragging); + Clipboard(ClipboardAccessPolicy, ClipboardType); ClipboardAccessPolicy policy() const { return m_policy; } bool dragStarted() const { return m_dragStarted; } @@ -98,9 +103,9 @@ namespace WebCore { String m_dropEffect; String m_effectAllowed; bool m_dragStarted; + ClipboardType m_clipboardType; protected: - bool m_forDragging; IntPoint m_dragLoc; CachedResourceHandle<CachedImage> m_dragImage; RefPtr<Node> m_dragImageElement; diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp index 2dd50bb..e18f6fe 100644 --- a/WebCore/dom/ContainerNode.cpp +++ b/WebCore/dom/ContainerNode.cpp @@ -154,7 +154,9 @@ bool ContainerNode::insertBefore(PassRefPtr<Node> newChild, Node* refChild, Exce if (child->parentNode()) break; +#if ENABLE(INSPECTOR) InspectorController::willInsertDOMNode(child, this); +#endif insertBeforeCommon(next.get(), child); @@ -223,7 +225,9 @@ void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChil for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); ++it) { Node* child = it->get(); +#if ENABLE(INSPECTOR) InspectorController::willInsertDOMNode(child, this); +#endif insertBeforeCommon(next.get(), child); @@ -298,7 +302,9 @@ bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce ASSERT(!child->nextSibling()); ASSERT(!child->previousSibling()); +#if ENABLE(INSPECTOR) InspectorController::willInsertDOMNode(child.get(), this); +#endif // Add child after "prev". forbidEventDispatch(); @@ -577,7 +583,9 @@ bool ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionCode& ec, bo break; } +#if ENABLE(INSPECTOR) InspectorController::willInsertDOMNode(child, this); +#endif // Append child to the end of the list forbidEventDispatch(); @@ -617,7 +625,9 @@ void ContainerNode::parserAddChild(PassRefPtr<Node> newChild) ASSERT(newChild); ASSERT(!newChild->parent()); // Use appendChild if you need to handle reparenting (and want DOM mutation events). +#if ENABLE(INSPECTOR) InspectorController::willInsertDOMNode(newChild.get(), this); +#endif forbidEventDispatch(); Node* last = m_lastChild; @@ -990,7 +1000,9 @@ static void notifyChildInserted(Node* child) { ASSERT(!eventDispatchForbidden()); +#if ENABLE(INSPECTOR) InspectorController::didInsertDOMNode(child); +#endif RefPtr<Node> c = child; RefPtr<Document> document = child->document(); @@ -1024,7 +1036,9 @@ static void dispatchChildRemovalEvents(Node* child) { ASSERT(!eventDispatchForbidden()); +#if ENABLE(INSPECTOR) InspectorController::willRemoveDOMNode(child); +#endif RefPtr<Node> c = child; RefPtr<Document> document = child->document(); diff --git a/WebCore/dom/DeviceMotionClient.h b/WebCore/dom/DeviceMotionClient.h index d19f92f..45bf11a 100644 --- a/WebCore/dom/DeviceMotionClient.h +++ b/WebCore/dom/DeviceMotionClient.h @@ -38,6 +38,7 @@ public: virtual void startUpdating() = 0; virtual void stopUpdating() = 0; virtual DeviceMotionData* currentDeviceMotion() const = 0; + virtual void deviceMotionControllerDestroyed() = 0; }; } // namespace WebCore diff --git a/WebCore/dom/DeviceMotionController.cpp b/WebCore/dom/DeviceMotionController.cpp index 73b948e..3385167 100644 --- a/WebCore/dom/DeviceMotionController.cpp +++ b/WebCore/dom/DeviceMotionController.cpp @@ -40,6 +40,11 @@ DeviceMotionController::DeviceMotionController(DeviceMotionClient* client) m_client->setController(this); } +DeviceMotionController::~DeviceMotionController() +{ + m_client->deviceMotionControllerDestroyed(); +} + void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer) { ASSERT_UNUSED(timer, timer == &m_timer); diff --git a/WebCore/dom/DeviceMotionController.h b/WebCore/dom/DeviceMotionController.h index 2670e04..422be73 100644 --- a/WebCore/dom/DeviceMotionController.h +++ b/WebCore/dom/DeviceMotionController.h @@ -38,6 +38,7 @@ class DeviceMotionClient; class DeviceMotionController { public: DeviceMotionController(DeviceMotionClient*); + ~DeviceMotionController(); void addListener(DOMWindow*); void removeListener(DOMWindow*); diff --git a/WebCore/dom/DeviceMotionData.cpp b/WebCore/dom/DeviceMotionData.cpp index cf4b466..7344c1c 100644 --- a/WebCore/dom/DeviceMotionData.cpp +++ b/WebCore/dom/DeviceMotionData.cpp @@ -28,59 +28,63 @@ namespace WebCore { +PassRefPtr<DeviceMotionData::Acceleration> DeviceMotionData::Acceleration::create(bool canProvideX, double x, + bool canProvideY, double y, + bool canProvideZ, double z) +{ + return adoptRef(new DeviceMotionData::Acceleration(canProvideX, x, canProvideY, y, canProvideZ, z)); +} + +DeviceMotionData::Acceleration::Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z) + : m_x(x) + , m_y(y) + , m_z(z) + , m_canProvideX(canProvideX) + , m_canProvideY(canProvideY) + , m_canProvideZ(canProvideZ) + +{ +} + +PassRefPtr<DeviceMotionData::RotationRate> DeviceMotionData::RotationRate::create(bool canProvideAlpha, double alpha, + bool canProvideBeta, double beta, + bool canProvideGamma, double gamma) +{ + return adoptRef(new DeviceMotionData::RotationRate(canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma)); +} + +DeviceMotionData::RotationRate::RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma) + : m_alpha(alpha) + , m_beta(beta) + , m_gamma(gamma) + , m_canProvideAlpha(canProvideAlpha) + , m_canProvideBeta(canProvideBeta) + , m_canProvideGamma(canProvideGamma) +{ +} + 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) +PassRefPtr<DeviceMotionData> DeviceMotionData::create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, + PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval) { - return adoptRef(new DeviceMotionData(canProvideXAcceleration, xAcceleration, - canProvideYAcceleration, yAcceleration, - canProvideZAcceleration, zAcceleration, - canProvideXRotationRate, xRotationRate, - canProvideYRotationRate, yRotationRate, - canProvideZRotationRate, zRotationRate, - canProvideInterval, interval)); + return adoptRef(new DeviceMotionData(acceleration, accelerationIncludingGravity, rotationRate, 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) + : 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) +DeviceMotionData::DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, + PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval) + : m_acceleration(acceleration) + , m_accelerationIncludingGravity(accelerationIncludingGravity) + , m_rotationRate(rotationRate) , m_canProvideInterval(canProvideInterval) - , m_xAcceleration(xAcceleration) - , m_yAcceleration(yAcceleration) - , m_zAcceleration(zAcceleration) - , m_xRotationRate(xRotationRate) - , m_yRotationRate(yRotationRate) - , m_zRotationRate(zRotationRate) , m_interval(interval) { } diff --git a/WebCore/dom/DeviceMotionData.h b/WebCore/dom/DeviceMotionData.h index cd90246..1d53b53 100644 --- a/WebCore/dom/DeviceMotionData.h +++ b/WebCore/dom/DeviceMotionData.h @@ -28,60 +28,79 @@ #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> namespace WebCore { class DeviceMotionData : public RefCounted<DeviceMotionData> { public: + class Acceleration : public RefCounted<DeviceMotionData::Acceleration> { + public: + static PassRefPtr<Acceleration> create(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z); + + bool canProvideX() const { return m_canProvideX; } + bool canProvideY() const { return m_canProvideY; } + bool canProvideZ() const { return m_canProvideZ; } + + double x() const { return m_x; } + double y() const { return m_y; } + double z() const { return m_z; } + + private: + Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z); + + double m_x; + double m_y; + double m_z; + + bool m_canProvideX; + bool m_canProvideY; + bool m_canProvideZ; + }; + + class RotationRate : public RefCounted<DeviceMotionData::RotationRate> { + public: + static PassRefPtr<RotationRate> create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); + + bool canProvideAlpha() const { return m_canProvideAlpha; } + bool canProvideBeta() const { return m_canProvideBeta; } + bool canProvideGamma() const { return m_canProvideGamma; } + + double alpha() const { return m_alpha; } + double beta() const { return m_beta; } + double gamma() const { return m_gamma; } + + private: + RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); + + double m_alpha; + double m_beta; + double m_gamma; + + bool m_canProvideAlpha; + bool m_canProvideBeta; + bool m_canProvideGamma; + }; + 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; } + static PassRefPtr<DeviceMotionData> create(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, + PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double 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; } + const Acceleration* acceleration() const { return m_acceleration.get(); } + const Acceleration* accelerationIncludingGravity() const { return m_accelerationIncludingGravity.get(); } + const RotationRate* rotationRate() const { return m_rotationRate.get(); } + double interval() const { return m_interval; } 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; + DeviceMotionData(PassRefPtr<Acceleration> acceleration, PassRefPtr<Acceleration> accelerationIncludingGravity, + PassRefPtr<RotationRate> rotationRate, bool canProvideInterval, double interval); - double m_xAcceleration; - double m_yAcceleration; - double m_zAcceleration; - double m_xRotationRate; - double m_yRotationRate; - double m_zRotationRate; + RefPtr<Acceleration> m_acceleration; + RefPtr<Acceleration> m_accelerationIncludingGravity; + RefPtr<RotationRate> m_rotationRate; + bool m_canProvideInterval; double m_interval; }; diff --git a/WebCore/dom/DeviceMotionEvent.idl b/WebCore/dom/DeviceMotionEvent.idl index 97e8e71..437ba4c 100644 --- a/WebCore/dom/DeviceMotionEvent.idl +++ b/WebCore/dom/DeviceMotionEvent.idl @@ -28,14 +28,11 @@ 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] Acceleration acceleration; + readonly attribute [Custom] Acceleration accelerationIncludingGravity; + readonly attribute [Custom] RotationRate rotationRate; 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); + [Custom] void initDeviceMotionEvent(in DOMString type, in boolean bubbles, in boolean cancelable, in Acceleration acceleration, in Acceleration accelerationIncludingGravity, in RotationRate rotationRate, in double interval); }; } diff --git a/WebCore/dom/DeviceOrientationClient.h b/WebCore/dom/DeviceOrientationClient.h index c969c95..347c3b3 100644 --- a/WebCore/dom/DeviceOrientationClient.h +++ b/WebCore/dom/DeviceOrientationClient.h @@ -39,6 +39,7 @@ public: virtual void startUpdating() = 0; virtual void stopUpdating() = 0; virtual DeviceOrientation* lastOrientation() const = 0; + virtual void deviceOrientationControllerDestroyed() = 0; }; } // namespace WebCore diff --git a/WebCore/dom/DeviceOrientationController.cpp b/WebCore/dom/DeviceOrientationController.cpp index a744366..60fcf13 100644 --- a/WebCore/dom/DeviceOrientationController.cpp +++ b/WebCore/dom/DeviceOrientationController.cpp @@ -41,6 +41,11 @@ DeviceOrientationController::DeviceOrientationController(Page* page, DeviceOrien m_client->setController(this); } +DeviceOrientationController::~DeviceOrientationController() +{ + m_client->deviceOrientationControllerDestroyed(); +} + void DeviceOrientationController::timerFired(Timer<DeviceOrientationController>* timer) { ASSERT_UNUSED(timer, timer == &m_timer); diff --git a/WebCore/dom/DeviceOrientationController.h b/WebCore/dom/DeviceOrientationController.h index 9517791..53b80f8 100644 --- a/WebCore/dom/DeviceOrientationController.h +++ b/WebCore/dom/DeviceOrientationController.h @@ -40,6 +40,7 @@ class Page; class DeviceOrientationController { public: DeviceOrientationController(Page*, DeviceOrientationClient*); + ~DeviceOrientationController(); void addListener(DOMWindow*); void removeListener(DOMWindow*); diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index 180b943..359a3d3 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -129,7 +129,6 @@ #include "TreeWalker.h" #include "UIEvent.h" #include "UserContentURLPattern.h" -#include "ViewportArguments.h" #include "WebKitAnimationEvent.h" #include "WebKitTransitionEvent.h" #include "WheelEvent.h" @@ -1079,7 +1078,7 @@ KURL Document::baseURI() const // * making it receive a rect as parameter, i.e. nodesFromRect(x, y, w, h); // * making it receive the expading size of each direction separately, // i.e. nodesFromRect(x, y, topSize, rightSize, bottomSize, leftSize); -PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned hPadding, unsigned vPadding, bool ignoreClipping) const +PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping) const { // FIXME: Share code between this, elementFromPoint and caretRangeFromPoint. if (!renderer()) @@ -1093,26 +1092,25 @@ PassRefPtr<NodeList> Document::nodesFromRect(int centerX, int centerY, unsigned float zoomFactor = frame->pageZoomFactor(); IntPoint point = roundedIntPoint(FloatPoint(centerX * zoomFactor + view()->scrollX(), centerY * zoomFactor + view()->scrollY())); - IntSize padding(hPadding, vPadding); int type = HitTestRequest::ReadOnly | HitTestRequest::Active; // When ignoreClipping is false, this method returns null for coordinates outside of the viewport. if (ignoreClipping) type |= HitTestRequest::IgnoreClipping; - else if (!frameView->visibleContentRect().intersects(IntRect(point, padding))) + else if (!frameView->visibleContentRect().intersects(HitTestResult::rectFromPoint(point, topPadding, rightPadding, bottomPadding, leftPadding))) return 0; HitTestRequest request(type); // Passing a zero padding will trigger a rect hit test, however for the purposes of nodesFromRect, // we special handle this case in order to return a valid NodeList. - if (padding.isZero()) { + if (!topPadding && !rightPadding && !bottomPadding && !leftPadding) { HitTestResult result(point); return handleZeroPadding(request, result); } - HitTestResult result(point, padding); + HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding); renderView()->layer()->hitTest(request, result); return StaticHashSetNodeList::adopt(result.rectBasedTestResult()); @@ -1238,8 +1236,10 @@ void Document::removeElementById(const AtomicString& elementId, Element* element if (m_elementsById.get(elementId.impl()) == element) m_elementsById.remove(elementId.impl()); - else + else { + ASSERT(m_inRemovedLastRefFunction || m_duplicateIds.contains(elementId.impl())); m_duplicateIds.remove(elementId.impl()); + } } Element* Document::getElementByAccessKey(const String& key) const @@ -1824,6 +1824,18 @@ void Document::clearAXObjectCache() #endif } +bool Document::axObjectCacheExists() const +{ + if (m_axObjectCache) + return true; + + Document* doc = topDocument(); + if (doc != this) + return doc->axObjectCacheExists(); + + return false; +} + AXObjectCache* Document::axObjectCache() const { #if PLATFORM(ANDROID) @@ -2097,7 +2109,7 @@ void Document::implicitClose() view()->layout(); } -#if PLATFORM(MAC) +#if PLATFORM(MAC) || PLATFORM(CHROMIUM) if (f && renderObject && this == topDocument() && AXObjectCache::accessibilityEnabled()) { // The AX cache may have been cleared at this point, but we need to make sure it contains an // AX object to send the notification to. getOrCreate will make sure that an valid AX object @@ -2352,7 +2364,7 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist())) continue; RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url()); - parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleSheet::UserLevel); + parsedSheet->setIsUserStyleSheet(sheet->level() == UserStyleUserLevel); parsedSheet->parseString(sheet->source(), !inQuirksMode()); if (!m_pageGroupUserSheets) m_pageGroupUserSheets.set(new Vector<RefPtr<CSSStyleSheet> >); @@ -2647,16 +2659,14 @@ void Document::processViewport(const String& features) { ASSERT(!features.isNull()); + m_viewportArguments = ViewportArguments(); + processArguments(features, (void*)&m_viewportArguments, &setViewportFeature); + Frame* frame = this->frame(); - if (!frame) + if (!frame || !frame->page()) return; - if (frame->page()) { - ViewportArguments arguments; - processArguments(features, (void*)&arguments, &setViewportFeature); - - frame->page()->chrome()->client()->didReceiveViewportArguments(frame, arguments); - } + frame->page()->chrome()->client()->didReceiveViewportArguments(frame, m_viewportArguments); } MouseEventWithHitTestResults Document::prepareMouseEvent(const HitTestRequest& request, const IntPoint& documentPoint, const PlatformMouseEvent& event) @@ -3224,7 +3234,7 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode) } } -#if ((PLATFORM(MAC) || PLATFORM(WIN)) && !PLATFORM(CHROMIUM)) || PLATFORM(GTK) +#if PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(CHROMIUM) if (!focusChangeBlocked && m_focusedNode && AXObjectCache::accessibilityEnabled()) { RenderObject* oldFocusedRenderer = 0; RenderObject* newFocusedRenderer = 0; @@ -3271,6 +3281,8 @@ void Document::attachNodeIterator(NodeIterator* ni) void Document::detachNodeIterator(NodeIterator* ni) { + // The node iterator can be detached without having been attached if its root node didn't have a document + // when the iterator was created, but has it now. m_nodeIterators.remove(ni); } @@ -3870,6 +3882,10 @@ void Document::setInPageCache(bool flag) ASSERT(m_renderArena); setRenderer(m_savedRenderer); m_savedRenderer = 0; + + if (frame() && frame()->page()) + frame()->page()->chrome()->client()->didReceiveViewportArguments(frame(), m_viewportArguments); + if (childNeedsStyleRecalc()) scheduleStyleRecalc(); } @@ -3967,7 +3983,7 @@ bool Document::queryCommandIndeterm(const String& commandName) bool Document::queryCommandState(const String& commandName) { - return command(this, commandName).state() != FalseTriState; + return command(this, commandName).state() == TrueTriState; } bool Document::queryCommandSupported(const String& commandName) @@ -4083,6 +4099,11 @@ SVGDocumentExtensions* Document::accessSVGExtensions() m_svgExtensions = adoptPtr(new SVGDocumentExtensions(this)); return m_svgExtensions.get(); } + +bool Document::hasSVGRootNode() const +{ + return documentElement() && documentElement()->hasTagName(SVGNames::svgTag); +} #endif PassRefPtr<HTMLCollection> Document::images() @@ -4326,37 +4347,9 @@ void FormElementKey::deref() const type()->deref(); } -unsigned FormElementKeyHash::hash(const FormElementKey& k) +unsigned FormElementKeyHash::hash(const FormElementKey& key) { - ASSERT(sizeof(k) % (sizeof(uint16_t) * 2) == 0); - - unsigned l = sizeof(k) / (sizeof(uint16_t) * 2); - const uint16_t* s = reinterpret_cast<const uint16_t*>(&k); - uint32_t hash = WTF::stringHashingStartValue; - - // Main loop - for (; l > 0; l--) { - hash += s[0]; - uint32_t tmp = (s[1] << 11) ^ hash; - hash = (hash << 16) ^ tmp; - s += 2; - hash += hash >> 11; - } - - // Force "avalanching" of final 127 bits - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 2; - hash += hash >> 15; - hash ^= hash << 10; - - // 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) - hash = 0x80000000; - - return hash; + return WTF::StringHasher::createBlobHash<sizeof(FormElementKey)>(&key); } void Document::setIconURL(const String& iconURL, const String& type) diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index c1065fb..fa3d9fb 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -36,6 +36,7 @@ #include "QualifiedName.h" #include "ScriptExecutionContext.h" #include "Timer.h" +#include "ViewportArguments.h" #include <wtf/FixedArray.h> #include <wtf/HashCountedSet.h> #include <wtf/OwnPtr.h> @@ -276,6 +277,8 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange); #endif + ViewportArguments viewportArguments() const { return m_viewportArguments; } + DocumentType* doctype() const { return m_docType.get(); } DOMImplementation* implementation() const; @@ -305,7 +308,7 @@ public: /** * Retrieve all nodes that intersect a rect in the window's document, until it is fully enclosed by - * the boundaries of node. + * the boundaries of a node. * * @param centerX x reference for the rectangle in CSS pixels * @param centerY y reference for the rectangle in CSS pixels @@ -314,7 +317,8 @@ public: * @param ignoreClipping whether or not to ignore the root scroll frame when retrieving the element. * If false, this method returns null for coordinates outside of the viewport. */ - PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned hPadding, unsigned vPadding, bool ignoreClipping) const; + PassRefPtr<NodeList> nodesFromRect(int centerX, int centerY, unsigned topPadding, unsigned rightPadding, + unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping) const; Element* elementFromPoint(int x, int y) const; PassRefPtr<Range> caretRangeFromPoint(int x, int y); @@ -385,8 +389,10 @@ public: virtual bool isImageDocument() const { return false; } #if ENABLE(SVG) virtual bool isSVGDocument() const { return false; } + bool hasSVGRootNode() const; #else static bool isSVGDocument() { return false; } + static bool hasSVGRootNode() { return false; } #endif virtual bool isPluginDocument() const { return false; } virtual bool isMediaDocument() const { return false; } @@ -520,6 +526,7 @@ public: void clearAXObjectCache(); AXObjectCache* axObjectCache() const; + bool axObjectCacheExists() const; // to get visually ordered hebrew and arabic pages right void setVisuallyOrdered(); @@ -1323,6 +1330,8 @@ private: #endif int m_loadEventDelayCount; + + ViewportArguments m_viewportArguments; }; inline bool Document::hasElementWithId(AtomicStringImpl* id) const diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl index 296bd44..e551f88 100644 --- a/WebCore/dom/Document.idl +++ b/WebCore/dom/Document.idl @@ -186,11 +186,6 @@ module core { readonly attribute [ConvertNullStringTo=Undefined] DOMString defaultCharset; readonly attribute [ConvertNullStringTo=Undefined] DOMString readyState; - - NodeList nodesFromRect(in long x, in long y, - in unsigned long hPadding, - in unsigned long vPadding, - in boolean ignoreClipping); Element elementFromPoint(in long x, in long y); Range caretRangeFromPoint(in long x, in long y); diff --git a/WebCore/dom/DocumentMarker.h b/WebCore/dom/DocumentMarker.h index e6160ae..dd5e981 100644 --- a/WebCore/dom/DocumentMarker.h +++ b/WebCore/dom/DocumentMarker.h @@ -40,6 +40,7 @@ struct DocumentMarker { Grammar, TextMatch, Replacement, + CorrectionIndicator, RejectedCorrection }; diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index 5f53c2d..c408790 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -33,6 +33,7 @@ #include "CSSStyleSelector.h" #include "ClientRect.h" #include "ClientRectList.h" +#include "DOMTokenList.h" #include "DatasetDOMStringMap.h" #include "Document.h" #include "DocumentFragment.h" @@ -578,7 +579,10 @@ void Element::setAttribute(const AtomicString& name, const AtomicString& value, else if (!old && !value.isNull()) m_attributeMap->addAttribute(createAttribute(QualifiedName(nullAtom, localName, nullAtom), value)); else if (old && !value.isNull()) { - old->setValue(value); + if (Attr* attrNode = old->attr()) + attrNode->setValue(value); + else + old->setValue(value); attributeChanged(old); } @@ -608,7 +612,10 @@ void Element::setAttribute(const QualifiedName& name, const AtomicString& value, else if (!old && !value.isNull()) m_attributeMap->addAttribute(createAttribute(name, value)); else if (old) { - old->setValue(value); + if (Attr* attrNode = old->attr()) + attrNode->setValue(value); + else + old->setValue(value); attributeChanged(old); } @@ -651,6 +658,8 @@ void Element::updateAfterAttributeChanged(Attribute* attr) document()->axObjectCache()->selectedChildrenChanged(renderer()); else if (attrName == aria_expandedAttr) document()->axObjectCache()->handleAriaExpandedChange(renderer()); + else if (attrName == aria_hiddenAttr) + document()->axObjectCache()->childrenChanged(renderer()); } void Element::recalcStyleIfNeededAfterAttributeChanged(Attribute* attr) @@ -1565,6 +1574,21 @@ bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec) return false; } +DOMTokenList* Element::classList() +{ + ElementRareData* data = ensureRareData(); + if (!data->m_classList) + data->m_classList = DOMTokenList::create(this); + return data->m_classList.get(); +} + +DOMTokenList* Element::optionalClassList() const +{ + if (!hasRareData()) + return 0; + return rareData()->m_classList.get(); +} + DOMStringMap* Element::dataset() { ElementRareData* data = ensureRareData(); diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h index d9a5085..b51e750 100644 --- a/WebCore/dom/Element.h +++ b/WebCore/dom/Element.h @@ -36,6 +36,7 @@ class Attribute; class ClientRect; class ClientRectList; class DOMStringMap; +class DOMTokenList; class ElementRareData; class IntSize; @@ -269,6 +270,9 @@ public: bool webkitMatchesSelector(const String& selectors, ExceptionCode&); + DOMTokenList* classList(); + DOMTokenList* optionalClassList() const; + DOMStringMap* dataset(); DOMStringMap* optionalDataset() const; diff --git a/WebCore/dom/ElementRareData.h b/WebCore/dom/ElementRareData.h index 8e338ab..f1e6334 100644 --- a/WebCore/dom/ElementRareData.h +++ b/WebCore/dom/ElementRareData.h @@ -22,6 +22,7 @@ #ifndef ElementRareData_h #define ElementRareData_h +#include "DOMTokenList.h" #include "DatasetDOMStringMap.h" #include "Element.h" #include "NodeRareData.h" @@ -42,6 +43,7 @@ public: RefPtr<RenderStyle> m_computedStyle; OwnPtr<DatasetDOMStringMap> m_datasetDOMStringMap; + OwnPtr<DOMTokenList> m_classList; }; inline IntSize defaultMinimumSizeForResizing() diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp index 92b42fe..5694dfe 100644 --- a/WebCore/dom/Node.cpp +++ b/WebCore/dom/Node.cpp @@ -25,11 +25,15 @@ #include "config.h" #include "Node.h" +<<<<<<< HEAD #ifdef ANDROID_DOM_LOGGING #define LOG_TAG "webcore" #include "AndroidLog.h" #endif +======= +#include "AXObjectCache.h" +>>>>>>> webkit.org at r68651 #include "Attr.h" #include "Attribute.h" #include "CSSParser.h" @@ -386,6 +390,9 @@ Node::~Node() if (renderer()) detach(); + if (AXObjectCache::accessibilityEnabled() && m_document && m_document->axObjectCacheExists()) + m_document->axObjectCache()->removeNodeForUse(this); + if (m_previous) m_previous->setNextSibling(0); if (m_next) diff --git a/WebCore/dom/NodeIterator.cpp b/WebCore/dom/NodeIterator.cpp index af07f42..ce3103c 100644 --- a/WebCore/dom/NodeIterator.cpp +++ b/WebCore/dom/NodeIterator.cpp @@ -76,12 +76,16 @@ NodeIterator::NodeIterator(PassRefPtr<Node> rootNode, unsigned whatToShow, PassR , m_referenceNode(root(), true) , m_detached(false) { - root()->document()->attachNodeIterator(this); + // Document type nodes may have a null document. But since they can't have children, there is no need to listen for modifications to these. + ASSERT(root()->document() || root()->nodeType() == Node::DOCUMENT_TYPE_NODE); + if (Document* ownerDocument = root()->document()) + ownerDocument->attachNodeIterator(this); } NodeIterator::~NodeIterator() { - root()->document()->detachNodeIterator(this); + if (Document* ownerDocument = root()->document()) + ownerDocument->detachNodeIterator(this); } PassRefPtr<Node> NodeIterator::nextNode(ScriptState* state, ExceptionCode& ec) @@ -144,7 +148,8 @@ PassRefPtr<Node> NodeIterator::previousNode(ScriptState* state, ExceptionCode& e void NodeIterator::detach() { - root()->document()->detachNodeIterator(this); + if (Document* ownerDocument = root()->document()) + ownerDocument->detachNodeIterator(this); m_detached = true; m_referenceNode.node.clear(); } @@ -159,6 +164,7 @@ void NodeIterator::updateForNodeRemoval(Node* removedNode, NodePointer& referenc { ASSERT(!m_detached); ASSERT(removedNode); + ASSERT(root()->document()); ASSERT(root()->document() == removedNode->document()); // Iterator is not affected if the removed node is the reference node and is the root. diff --git a/WebCore/dom/QualifiedName.h b/WebCore/dom/QualifiedName.h index ee90408..2da8f0c 100644 --- a/WebCore/dom/QualifiedName.h +++ b/WebCore/dom/QualifiedName.h @@ -112,52 +112,24 @@ inline bool operator!=(const QualifiedName& q, const AtomicString& a) { return a inline unsigned hashComponents(const QualifiedNameComponents& buf) { - ASSERT(sizeof(QualifiedNameComponents) % (sizeof(uint16_t) * 2) == 0); - - unsigned l = sizeof(QualifiedNameComponents) / (sizeof(uint16_t) * 2); - const uint16_t* s = reinterpret_cast<const uint16_t*>(&buf); - uint32_t hash = WTF::stringHashingStartValue; - - // Main loop - for (; l > 0; l--) { - hash += s[0]; - uint32_t tmp = (s[1] << 11) ^ hash; - hash = (hash << 16) ^ tmp; - s += 2; - hash += hash >> 11; - } - - // Force "avalanching" of final 127 bits - hash ^= hash << 3; - hash += hash >> 5; - hash ^= hash << 2; - hash += hash >> 15; - hash ^= hash << 10; - - // 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) - hash = 0x80000000; - - return hash; + return WTF::StringHasher::createBlobHash<sizeof(QualifiedNameComponents)>(&buf); } - + struct QualifiedNameHash { static unsigned hash(const QualifiedName& name) { return hash(name.impl()); } - + static unsigned hash(const QualifiedName::QualifiedNameImpl* name) - { + { QualifiedNameComponents c = { name->m_prefix.impl(), name->m_localName.impl(), name->m_namespace.impl() }; return hashComponents(c); } - + static bool equal(const QualifiedName& a, const QualifiedName& b) { return a == b; } static bool equal(const QualifiedName::QualifiedNameImpl* a, const QualifiedName::QualifiedNameImpl* b) { return a == b; } - + static const bool safeToCompareToEmptyOrDeleted = false; }; - + } namespace WTF { diff --git a/WebCore/dom/Range.h b/WebCore/dom/Range.h index 9834aec..aea76e1 100644 --- a/WebCore/dom/Range.h +++ b/WebCore/dom/Range.h @@ -109,6 +109,7 @@ public: void textRects(Vector<IntRect>&, bool useSelectionHeight = false); // Transform-friendly void textQuads(Vector<FloatQuad>&, bool useSelectionHeight = false); + void getBorderAndTextQuads(Vector<FloatQuad>&) const; void nodeChildrenChanged(ContainerNode*); void nodeChildrenWillBeRemoved(ContainerNode*); @@ -147,8 +148,6 @@ private: enum ActionType { DELETE_CONTENTS, EXTRACT_CONTENTS, CLONE_CONTENTS }; PassRefPtr<DocumentFragment> processContents(ActionType, ExceptionCode&); - void getBorderAndTextQuads(Vector<FloatQuad>&) const; - RefPtr<Document> m_ownerDocument; RangeBoundaryPoint m_start; RangeBoundaryPoint m_end; diff --git a/WebCore/dom/SelectElement.cpp b/WebCore/dom/SelectElement.cpp index 0ca6cb3..bcab08c 100644 --- a/WebCore/dom/SelectElement.cpp +++ b/WebCore/dom/SelectElement.cpp @@ -53,7 +53,7 @@ #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) #define ARROW_KEYS_POP_MENU 1 #define SPACE_OR_RETURN_POP_MENU 0 -#elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && OS(LINUX)) +#elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (OS(LINUX) || OS(FREEBSD))) #define ARROW_KEYS_POP_MENU 0 #define SPACE_OR_RETURN_POP_MENU 1 #else diff --git a/WebCore/dom/SpaceSplitString.h b/WebCore/dom/SpaceSplitString.h index f49670b..0d3650e 100644 --- a/WebCore/dom/SpaceSplitString.h +++ b/WebCore/dom/SpaceSplitString.h @@ -74,6 +74,7 @@ namespace WebCore { bool containsAll(const SpaceSplitString& names) const { return !names.m_data || (m_data && m_data->containsAll(*names.m_data)); } size_t size() const { return m_data ? m_data->size() : 0; } + bool isNull() const { return !m_data; } const AtomicString& operator[](size_t i) const { ASSERT(i < size()); return (*m_data)[i]; } private: diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp index a158e2e..f07fda9 100644 --- a/WebCore/dom/StyledElement.cpp +++ b/WebCore/dom/StyledElement.cpp @@ -28,6 +28,7 @@ #include "CSSStyleSelector.h" #include "CSSStyleSheet.h" #include "CSSValueKeywords.h" +#include "DOMTokenList.h" #include "Document.h" #include "HTMLNames.h" #include <wtf/HashFunctions.h> @@ -217,12 +218,12 @@ void StyledElement::classAttributeChanged(const AtomicString& newClassString) } bool hasClass = i < length; setHasClass(hasClass); - if (hasClass) + if (hasClass) { attributes()->setClass(newClassString); - else { - if (attributeMap()) - attributeMap()->clearClass(); - } + if (DOMTokenList* classList = optionalClassList()) + classList->reset(newClassString); + } else if (attributeMap()) + attributeMap()->clearClass(); setNeedsStyleRecalc(); dispatchSubtreeModifiedEvent(); } diff --git a/WebCore/dom/StyledElement.h b/WebCore/dom/StyledElement.h index 8040dbf..4b62388 100644 --- a/WebCore/dom/StyledElement.h +++ b/WebCore/dom/StyledElement.h @@ -32,6 +32,7 @@ namespace WebCore { class Attribute; +class ClassList; class CSSMappedAttributeDeclaration; class StyledElement : public Element { |