diff options
Diffstat (limited to 'WebCore/dom')
97 files changed, 1089 insertions, 677 deletions
diff --git a/WebCore/dom/Attr.cpp b/WebCore/dom/Attr.cpp index aa5916b..2ef5f9b 100644 --- a/WebCore/dom/Attr.cpp +++ b/WebCore/dom/Attr.cpp @@ -27,9 +27,12 @@ #include "Element.h" #include "ExceptionCode.h" #include "Text.h" +#include "XMLNSNames.h" namespace WebCore { +using namespace HTMLNames; + inline Attr::Attr(Element* element, Document* document, PassRefPtr<Attribute> attribute) : ContainerNode(document) , m_element(element) @@ -100,7 +103,13 @@ void Attr::setPrefix(const AtomicString& prefix, ExceptionCode& ec) if (ec) return; - m_attribute->setPrefix(prefix); + if ((prefix == xmlnsAtom && namespaceURI() != XMLNSNames::xmlnsNamespaceURI) + || static_cast<Attr*>(this)->qualifiedName() == xmlnsAtom) { + ec = NAMESPACE_ERR; + return; + } + + m_attribute->setPrefix(prefix.isEmpty() ? AtomicString() : prefix); } String Attr::nodeValue() const @@ -164,4 +173,9 @@ void Attr::childrenChanged(bool changedByParser, Node* beforeChange, Node* after m_element->attributeChanged(m_attribute.get()); } +bool Attr::isId() const +{ + return qualifiedName().matches(m_element ? m_element->idAttributeName() : idAttr); +} + } diff --git a/WebCore/dom/Attr.h b/WebCore/dom/Attr.h index e927a6e..2e02a02 100644 --- a/WebCore/dom/Attr.h +++ b/WebCore/dom/Attr.h @@ -52,6 +52,8 @@ public: Attribute* attr() const { return m_attribute.get(); } const QualifiedName& qualifiedName() const { return m_attribute->name(); } + bool isId() const; + // An extension to get presentational information for attributes. CSSStyleDeclaration* style() { return m_attribute->style(); } diff --git a/WebCore/dom/Attr.idl b/WebCore/dom/Attr.idl index c01f34a..af84478 100644 --- a/WebCore/dom/Attr.idl +++ b/WebCore/dom/Attr.idl @@ -22,10 +22,7 @@ module core { interface [ CustomMarkFunction, - GenerateConstructor, - GenerateNativeConverter, - InterfaceUUID=EEE8E22B-22C3-4e50-95F4-5E0B8AAD8231, - ImplementationUUID=41B16348-D8E7-4d21-BFDB-125705B7E91F + GenerateNativeConverter ] Attr : Node { // DOM Level 1 @@ -38,11 +35,13 @@ module core { // DOM Level 2 readonly attribute Element ownerElement; - + + // DOM Level 3 + + readonly attribute boolean isId; + // extensions -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM readonly attribute CSSStyleDeclaration style; -#endif }; } diff --git a/WebCore/dom/BeforeLoadEvent.idl b/WebCore/dom/BeforeLoadEvent.idl index d06a39d..9c8b7e5 100644 --- a/WebCore/dom/BeforeLoadEvent.idl +++ b/WebCore/dom/BeforeLoadEvent.idl @@ -26,9 +26,7 @@ module events { - interface [ - GenerateConstructor - ] BeforeLoadEvent : Event { + interface BeforeLoadEvent : Event { void initBeforeLoadEvent(in DOMString type, in boolean canBubble, in boolean cancelable, diff --git a/WebCore/dom/CDATASection.idl b/WebCore/dom/CDATASection.idl index 7c6c1e6..70a4f55 100644 --- a/WebCore/dom/CDATASection.idl +++ b/WebCore/dom/CDATASection.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=DC8E30FD-42DD-4a12-9B74-78D634321B41, - ImplementationUUID=10A5D70C-D93E-409c-A6BA-9D7CB4E3D06A - ] CDATASection : Text { + interface CDATASection : Text { }; } diff --git a/WebCore/dom/CharacterData.idl b/WebCore/dom/CharacterData.idl index 7c8c7ac..4ddd782 100644 --- a/WebCore/dom/CharacterData.idl +++ b/WebCore/dom/CharacterData.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=149159F4-D2BA-4040-8137-6BF6424C972A, - ImplementationUUID=E2095280-B9BD-446a-8C03-79F78417CDFF - ] CharacterData : Node { + interface CharacterData : Node { attribute [ConvertNullToNullString] DOMString data setter raises(DOMException); diff --git a/WebCore/dom/CheckedRadioButtons.cpp b/WebCore/dom/CheckedRadioButtons.cpp index 9883f58..3cf8848 100644 --- a/WebCore/dom/CheckedRadioButtons.cpp +++ b/WebCore/dom/CheckedRadioButtons.cpp @@ -60,6 +60,8 @@ HTMLInputElement* CheckedRadioButtons::checkedButtonForGroup(const AtomicString& { if (!m_nameToCheckedRadioButtonMap) return 0; + + m_nameToCheckedRadioButtonMap->checkConsistency(); return m_nameToCheckedRadioButtonMap->get(name.impl()); } @@ -69,6 +71,8 @@ void CheckedRadioButtons::removeButton(HTMLFormControlElement* element) if (element->name().isEmpty() || !m_nameToCheckedRadioButtonMap) return; + m_nameToCheckedRadioButtonMap->checkConsistency(); + NameToInputMap::iterator it = m_nameToCheckedRadioButtonMap->find(element->name().impl()); if (it == m_nameToCheckedRadioButtonMap->end() || it->second != element) return; diff --git a/WebCore/dom/ClientRect.idl b/WebCore/dom/ClientRect.idl index 6f0598f..7dbdd68 100644 --- a/WebCore/dom/ClientRect.idl +++ b/WebCore/dom/ClientRect.idl @@ -26,9 +26,7 @@ module view { - interface [ - GenerateConstructor - ] ClientRect { + interface ClientRect { readonly attribute float top; readonly attribute float right; readonly attribute float bottom; diff --git a/WebCore/dom/ClientRectList.idl b/WebCore/dom/ClientRectList.idl index 8230f6c..6372418 100644 --- a/WebCore/dom/ClientRectList.idl +++ b/WebCore/dom/ClientRectList.idl @@ -27,7 +27,6 @@ module view { interface [ - GenerateConstructor, HasIndexGetter ] ClientRectList { readonly attribute unsigned long length; diff --git a/WebCore/dom/Clipboard.cpp b/WebCore/dom/Clipboard.cpp index 2aea90a..7f33aac 100644 --- a/WebCore/dom/Clipboard.cpp +++ b/WebCore/dom/Clipboard.cpp @@ -35,7 +35,9 @@ namespace WebCore { Clipboard::Clipboard(ClipboardAccessPolicy policy, bool isForDragging) - : m_policy(policy) + : m_policy(policy) + , m_dropEffect("none") + , m_effectAllowed("uninitialized") , m_dragStarted(false) , m_forDragging(isForDragging) , m_dragImage(0) @@ -64,7 +66,7 @@ static DragOperation dragOpFromIEOp(const String& op) if (op == "link") return DragOperationLink; if (op == "move") - return DragOperationGeneric; + return DragOperationGeneric; // FIXME: Why is this DragOperationGeneric? <http://webkit.org/b/33697> if (op == "copyLink") return (DragOperation)(DragOperationCopy | DragOperationLink); if (op == "copyMove") @@ -98,29 +100,29 @@ static String IEOpFromDragOp(DragOperation op) return "none"; } -bool Clipboard::sourceOperation(DragOperation& op) const +DragOperation Clipboard::sourceOperation() const { - if (m_effectAllowed.isNull()) - return false; - op = dragOpFromIEOp(m_effectAllowed); - return true; + DragOperation op = dragOpFromIEOp(m_effectAllowed); + ASSERT(op != DragOperationPrivate); + return op; } -bool Clipboard::destinationOperation(DragOperation& op) const +DragOperation Clipboard::destinationOperation() const { - if (m_dropEffect.isNull()) - return false; - op = dragOpFromIEOp(m_dropEffect); - return true; + DragOperation op = dragOpFromIEOp(m_dropEffect); + ASSERT(op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationGeneric || op == DragOperationMove); + return op; } void Clipboard::setSourceOperation(DragOperation op) { + ASSERT_ARG(op, op != DragOperationPrivate); m_effectAllowed = IEOpFromDragOp(op); } void Clipboard::setDestinationOperation(DragOperation op) { + ASSERT_ARG(op, op == DragOperationCopy || op == DragOperationNone || op == DragOperationLink || op == DragOperationGeneric || op == DragOperationMove); m_dropEffect = IEOpFromDragOp(op); } @@ -129,6 +131,10 @@ void Clipboard::setDropEffect(const String &effect) if (!m_forDragging) return; + // The attribute must ignore any attempts to set it to a value other than none, copy, link, and move. + if (effect != "none" && effect != "copy" && effect != "link" && effect != "move") + return; + if (m_policy == ClipboardReadable || m_policy == ClipboardTypesReadable) m_dropEffect = effect; } @@ -138,6 +144,17 @@ void Clipboard::setEffectAllowed(const String &effect) if (!m_forDragging) return; + if (dragOpFromIEOp(effect) == DragOperationPrivate) { + // This means that there was no conversion, and the effectAllowed that + // we are passed isn't a valid effectAllowed, so we should ignore it, + // and not set m_effectAllowed. + + // The attribute must ignore any attempts to set it to a value other than + // none, copy, copyLink, copyMove, link, linkMove, move, all, and uninitialized. + return; + } + + if (m_policy == ClipboardWritable) m_effectAllowed = effect; } diff --git a/WebCore/dom/Clipboard.h b/WebCore/dom/Clipboard.h index f6c09b2..042cd82 100644 --- a/WebCore/dom/Clipboard.h +++ b/WebCore/dom/Clipboard.h @@ -74,8 +74,8 @@ namespace WebCore { void setAccessPolicy(ClipboardAccessPolicy); - bool sourceOperation(DragOperation&) const; - bool destinationOperation(DragOperation&) const; + DragOperation sourceOperation() const; + DragOperation destinationOperation() const; void setSourceOperation(DragOperation); void setDestinationOperation(DragOperation); diff --git a/WebCore/dom/Clipboard.idl b/WebCore/dom/Clipboard.idl index dc8677e..6509677 100644 --- a/WebCore/dom/Clipboard.idl +++ b/WebCore/dom/Clipboard.idl @@ -28,9 +28,7 @@ module core { - interface [ - GenerateConstructor - ] Clipboard { + interface Clipboard { attribute [ConvertNullStringTo=Undefined] DOMString dropEffect; attribute [ConvertNullStringTo=Undefined] DOMString effectAllowed; readonly attribute [CustomGetter] Array types; diff --git a/WebCore/dom/Comment.idl b/WebCore/dom/Comment.idl index a89f0e7..b9f4e31 100644 --- a/WebCore/dom/Comment.idl +++ b/WebCore/dom/Comment.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=5D16069F-7E6B-4b28-8647-C36B2ED81ED1, - ImplementationUUID=CB55DB55-411F-451f-97C6-284B99E77F8E - ] Comment : CharacterData { + interface Comment : CharacterData { }; } diff --git a/WebCore/dom/CompositionEvent.idl b/WebCore/dom/CompositionEvent.idl index 3752091..28d6625 100644 --- a/WebCore/dom/CompositionEvent.idl +++ b/WebCore/dom/CompositionEvent.idl @@ -26,9 +26,7 @@ module events { // Introduced in DOM Level 3: - interface [ - GenerateConstructor - ] CompositionEvent : UIEvent { + interface CompositionEvent : UIEvent { readonly attribute DOMString data; diff --git a/WebCore/dom/ContainerNode.cpp b/WebCore/dom/ContainerNode.cpp index 5cd0781..39cd3b4 100644 --- a/WebCore/dom/ContainerNode.cpp +++ b/WebCore/dom/ContainerNode.cpp @@ -33,6 +33,7 @@ #include "Frame.h" #include "FrameView.h" #include "InlineTextBox.h" +#include "InspectorController.h" #include "MutationEvent.h" #include "Page.h" #include "RenderTheme.h" @@ -869,6 +870,13 @@ static void dispatchChildInsertionEvents(Node* child) { ASSERT(!eventDispatchForbidden()); +#if ENABLE(INSPECTOR) + if (Page* page = child->document()->page()) { + if (InspectorController* inspectorController = page->inspectorController()) + inspectorController->didInsertDOMNode(child); + } +#endif + RefPtr<Node> c = child; RefPtr<Document> document = child->document(); @@ -891,6 +899,13 @@ static void dispatchChildInsertionEvents(Node* child) static void dispatchChildRemovalEvents(Node* child) { +#if ENABLE(INSPECTOR) + if (Page* page = child->document()->page()) { + if (InspectorController* inspectorController = page->inspectorController()) + inspectorController->didRemoveDOMNode(child); + } +#endif + RefPtr<Node> c = child; RefPtr<Document> document = child->document(); diff --git a/WebCore/dom/DOMCoreException.idl b/WebCore/dom/DOMCoreException.idl index 3001995..9baea1b 100644 --- a/WebCore/dom/DOMCoreException.idl +++ b/WebCore/dom/DOMCoreException.idl @@ -28,9 +28,7 @@ module core { - interface [ - GenerateConstructor - ] DOMCoreException { + interface DOMCoreException { readonly attribute unsigned short code; readonly attribute DOMString name; diff --git a/WebCore/dom/DOMImplementation.idl b/WebCore/dom/DOMImplementation.idl index 6f4df80..81df6c8 100644 --- a/WebCore/dom/DOMImplementation.idl +++ b/WebCore/dom/DOMImplementation.idl @@ -20,11 +20,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=B0CC344F-963C-4acc-9FC6-EB22649345E5, - ImplementationUUID=9E835092-2CA3-426b-826B-8272A8105E49 - ] DOMImplementation { + interface DOMImplementation { // DOM Level 1 @@ -44,7 +40,6 @@ module core { // DOMImplementationCSS interface from DOM Level 2 CSS -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM [OldStyleObjC] CSSStyleSheet createCSSStyleSheet(in DOMString title, in DOMString media) raises(DOMException); @@ -52,7 +47,6 @@ module core { // HTMLDOMImplementation interface from DOM Level 2 HTML HTMLDocument createHTMLDocument(in DOMString title); -#endif }; } diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp index c8d21ba..73beef6 100644 --- a/WebCore/dom/Document.cpp +++ b/WebCore/dom/Document.cpp @@ -36,6 +36,8 @@ #include "CSSValueKeywords.h" #include "CString.h" #include "CachedCSSStyleSheet.h" +#include "Chrome.h" +#include "ChromeClient.h" #include "Comment.h" #include "Console.h" #include "CookieJar.h" @@ -67,6 +69,7 @@ #include "HTMLElementFactory.h" #include "HTMLFrameOwnerElement.h" #include "HTMLHeadElement.h" +#include "HTMLIFrameElement.h" #include "HTMLInputElement.h" #include "HTMLLinkElement.h" #include "HTMLMapElement.h" @@ -113,6 +116,7 @@ #include "SegmentedString.h" #include "SelectionController.h" #include "Settings.h" +#include "StringBuffer.h" #include "StyleSheetList.h" #include "TextEvent.h" #include "TextIterator.h" @@ -126,6 +130,7 @@ #include "WebKitTransitionEvent.h" #include "WheelEvent.h" #include "XMLHttpRequest.h" +#include "XMLNSNames.h" #include "XMLNames.h" #include "XMLTokenizer.h" #include "htmlediting.h" @@ -135,11 +140,6 @@ #include <wtf/PassRefPtr.h> #include <wtf/StdLibExtras.h> -#if ENABLE(DATABASE) -#include "Database.h" -#include "DatabaseThread.h" -#endif - #if ENABLE(SHARED_WORKERS) #include "SharedWorkerRepository.h" #endif @@ -171,6 +171,7 @@ #include "SVGStyleElement.h" #endif +<<<<<<< HEAD #if PLATFORM(ANDROID) // FIXME: We shouldn't be including this from WebCore! #include "WebViewCore.h" @@ -191,6 +192,9 @@ #if ENABLE(TOUCH_EVENTS) #include "ChromeClient.h" +======= +#if ENABLE(TOUCH_EVENTS) +>>>>>>> webkit.org at r54127 #include "TouchEvent.h" #endif @@ -338,15 +342,49 @@ static bool disableRangeMutation(Page* page) static HashSet<Document*>* documentsThatNeedStyleRecalc = 0; -Document::Document(Frame* frame, bool isXHTML) +class DocumentWeakReference : public ThreadSafeShared<DocumentWeakReference> { +public: + static PassRefPtr<DocumentWeakReference> create(Document* document) + { + return adoptRef(new DocumentWeakReference(document)); + } + + Document* document() + { + ASSERT(isMainThread()); + return m_document; + } + + void clear() + { + ASSERT(isMainThread()); + m_document = 0; + } + +private: + DocumentWeakReference(Document* document) + : m_document(document) + { + ASSERT(isMainThread()); + } + + Document* m_document; +}; + +Document::Document(Frame* frame, bool isXHTML, bool isHTML) : ContainerNode(0) , m_domtree_version(0) , m_styleSheets(StyleSheetList::create(this)) , m_styleRecalcTimer(this, &Document::styleRecalcTimerFired) , m_frameElementsShouldIgnoreScrolling(false) + , m_containsValidityStyleRules(false) , m_title("") + , m_rawTitle("") , m_titleSetExplicitly(false) , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired) + , m_startTime(currentTime()) + , m_overMinimumLayoutThreshold(false) + , m_extraLayoutDelay(0) , m_executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired) , m_xmlVersion("1.0") , m_xmlStandalone(false) @@ -369,14 +407,17 @@ Document::Document(Frame* frame, bool isXHTML) , m_inPageCache(false) , m_useSecureKeyboardEntryWhenActive(false) , m_isXHTML(isXHTML) + , m_isHTML(isHTML) , m_numNodeListCaches(0) -#if ENABLE(DATABASE) - , m_hasOpenDatabases(false) +#if USE(JSC) + , m_normalWorldWrapperCache(0) #endif , m_usingGeolocation(false) + , m_storageEventTimer(this, &Document::storageEventTimerFired) #if ENABLE(WML) , m_containsWMLContent(false) #endif + , m_weakReference(DocumentWeakReference::create(this)) { m_document = this; @@ -394,7 +435,7 @@ Document::Document(Frame* frame, bool isXHTML) m_docLoader = new DocLoader(this); - visuallyOrdered = false; + m_visuallyOrdered = false; m_bParsing = false; m_wellFormed = false; @@ -415,7 +456,6 @@ Document::Document(Frame* frame, bool isXHTML) m_gotoAnchorNeededAfterStylesheetsLoad = false; - m_styleSelector = 0; m_didCalculateStyleSelector = false; m_pendingStylesheets = 0; m_ignorePendingStylesheets = false; @@ -429,9 +469,12 @@ Document::Document(Frame* frame, bool isXHTML) resetActiveLinkColor(); m_processingLoadEvent = false; +<<<<<<< HEAD m_startTime = currentTime(); m_overMinimumLayoutThreshold = false; m_extraLayoutDelay = 0; +======= +>>>>>>> webkit.org at r54127 initSecurityContext(); initDNSPrefetch(); @@ -462,6 +505,9 @@ void Document::removedLastRef() m_titleElement = 0; m_documentElement = 0; + // removeAllChildren() doesn't always unregister IDs, do it upfront to avoid having stale references in the map. + m_elementsById.clear(); + removeAllChildren(); deleteAllValues(m_markers); @@ -503,7 +549,6 @@ Document::~Document() m_tokenizer.clear(); m_document = 0; - delete m_styleSelector; m_docLoader.clear(); m_renderArena.clear(); @@ -522,26 +567,25 @@ Document::~Document() for (unsigned i = 0; i < count; i++) deleteAllValues(m_nameCollectionInfo[i]); -#if ENABLE(DATABASE) - if (m_databaseThread) { - ASSERT(m_databaseThread->terminationRequested()); - m_databaseThread = 0; - } -#endif - if (m_styleSheets) m_styleSheets->documentDestroyed(); + + m_weakReference->clear(); } +#if USE(JSC) Document::JSWrapperCache* Document::createWrapperCache(DOMWrapperWorld* world) { JSWrapperCache* wrapperCache = new JSWrapperCache(); m_wrapperCacheMap.set(world, wrapperCache); -#if USE(JSC) + if (world->isNormal()) { + ASSERT(!m_normalWorldWrapperCache); + m_normalWorldWrapperCache = wrapperCache; + } world->rememberDocument(this); -#endif return wrapperCache; } +#endif void Document::resetLinkColor() { @@ -796,6 +840,9 @@ PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionCode& ec) break; } default: + if (source->hasTagName(iframeTag)) + static_cast<HTMLIFrameElement*>(source.get())->setRemainsAliveOnRemovalFromTree(attached()); + if (source->parentNode()) source->parentNode()->removeChild(source.get(), ec); } @@ -808,21 +855,17 @@ PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionCode& ec) bool Document::hasPrefixNamespaceMismatch(const QualifiedName& qName) { - DEFINE_STATIC_LOCAL(const AtomicString, xmlnsNamespaceURI, ("http://www.w3.org/2000/xmlns/")); - DEFINE_STATIC_LOCAL(const AtomicString, xmlns, ("xmlns")); - DEFINE_STATIC_LOCAL(const AtomicString, xml, ("xml")); - // These checks are from DOM Core Level 2, createElementNS // http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-DocCrElNS if (!qName.prefix().isEmpty() && qName.namespaceURI().isNull()) // createElementNS(null, "html:div") return true; - if (qName.prefix() == xml && qName.namespaceURI() != XMLNames::xmlNamespaceURI) // createElementNS("http://www.example.com", "xml:lang") + if (qName.prefix() == xmlAtom && qName.namespaceURI() != XMLNames::xmlNamespaceURI) // createElementNS("http://www.example.com", "xml:lang") return true; // Required by DOM Level 3 Core and unspecified by DOM Level 2 Core: // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-DocCrElNS // createElementNS("http://www.w3.org/2000/xmlns/", "foo:bar"), createElementNS(null, "xmlns:bar") - if ((qName.prefix() == xmlns && qName.namespaceURI() != xmlnsNamespaceURI) || (qName.prefix() != xmlns && qName.namespaceURI() == xmlnsNamespaceURI)) + if ((qName.prefix() == xmlnsAtom && qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI) || (qName.prefix() != xmlnsAtom && qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI)) return true; return false; @@ -883,6 +926,8 @@ Element* Document::getElementById(const AtomicString& elementId) const if (elementId.isEmpty()) return 0; + m_elementsById.checkConsistency(); + Element* element = m_elementsById.get(elementId.impl()); if (element) return element; @@ -892,7 +937,7 @@ Element* Document::getElementById(const AtomicString& elementId) const for (Node *n = traverseNextNode(); n != 0; n = n->traverseNextNode()) { if (n->isElementNode()) { element = static_cast<Element*>(n); - if (element->hasID() && element->getAttribute(idAttr) == elementId) { + if (element->hasID() && element->getAttribute(element->idAttributeName()) == elementId) { m_duplicateIds.remove(elementId.impl()); m_elementsById.set(elementId.impl(), element); return element; @@ -1074,6 +1119,8 @@ void Document::addElementById(const AtomicString& elementId, Element* element) void Document::removeElementById(const AtomicString& elementId, Element* element) { + m_elementsById.checkConsistency(); + if (m_elementsById.get(elementId.impl()) == element) m_elementsById.remove(elementId.impl()); else @@ -1098,8 +1145,67 @@ Element* Document::getElementByAccessKey(const String& key) const return m_elementsByAccessKey.get(key.impl()); } +/* + * Performs three operations: + * 1. Convert control characters to spaces + * 2. Trim leading and trailing spaces + * 3. Collapse internal whitespace. + */ +static inline String canonicalizedTitle(Document* document, const String& title) +{ + const UChar* characters = title.characters(); + unsigned length = title.length(); + unsigned i; + + StringBuffer buffer(length); + unsigned builderIndex = 0; + + // Skip leading spaces and leading characters that would convert to spaces + for (i = 0; i < length; ++i) { + UChar c = characters[i]; + if (!(c <= 0x20 || c == 0x7F)) + break; + } + + if (i == length) + return ""; + + // Replace control characters with spaces, and backslashes with currency symbols, and collapse whitespace. + bool previousCharWasWS = false; + for (; i < length; ++i) { + UChar c = characters[i]; + if (c <= 0x20 || c == 0x7F || (WTF::Unicode::category(c) & (WTF::Unicode::Separator_Line | WTF::Unicode::Separator_Paragraph))) { + if (previousCharWasWS) + continue; + buffer[builderIndex++] = ' '; + previousCharWasWS = true; + } else { + buffer[builderIndex++] = c; + previousCharWasWS = false; + } + } + + // Strip trailing spaces + while (builderIndex > 0) { + --builderIndex; + if (buffer[builderIndex] != ' ') + break; + } + + if (!builderIndex && buffer[builderIndex] == ' ') + return ""; + + buffer.shrink(builderIndex + 1); + + // Replace the backslashes with currency symbols if the encoding requires it. + document->displayBufferModifiedByEncoding(buffer.characters(), buffer.length()); + + return String::adopt(buffer); +} + void Document::updateTitle() { + m_title = canonicalizedTitle(this, m_rawTitle); if (Frame* f = frame()) f->loader()->setTitle(m_title); } @@ -1126,10 +1232,10 @@ void Document::setTitle(const String& title, Element* titleElement) m_titleElement = titleElement; } - if (m_title == title) + if (m_rawTitle == title) return; - m_title = title; + m_rawTitle = title; updateTitle(); if (m_titleSetExplicitly && m_titleElement && m_titleElement->hasTagName(titleTag)) @@ -1154,8 +1260,8 @@ void Document::removeTitle(Element* titleElement) } } - if (!m_titleElement && !m_title.isEmpty()) { - m_title = ""; + if (!m_titleElement && !m_rawTitle.isEmpty()) { + m_rawTitle = ""; updateTitle(); } } @@ -1284,32 +1390,7 @@ void Document::recalcStyle(StyleChange change) // style selector may set this again during recalc m_hasNodesWithPlaceholderStyle = false; - RefPtr<RenderStyle> documentStyle = RenderStyle::create(); - documentStyle->setDisplay(BLOCK); - documentStyle->setVisuallyOrdered(visuallyOrdered); - documentStyle->setZoom(frame()->pageZoomFactor()); - m_styleSelector->setStyle(documentStyle); - - FontDescription fontDescription; - fontDescription.setUsePrinterFont(printing()); - if (Settings* settings = this->settings()) { - fontDescription.setRenderingMode(settings->fontRenderingMode()); - if (printing() && !settings->shouldPrintBackgrounds()) - documentStyle->setForceBackgroundsToWhite(true); - const AtomicString& stdfont = settings->standardFontFamily(); - if (!stdfont.isEmpty()) { - fontDescription.firstFamily().setFamily(stdfont); - fontDescription.firstFamily().appendFamily(0); - } - fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1); - m_styleSelector->setFontSize(fontDescription, m_styleSelector->fontSizeForKeyword(CSSValueMedium, inCompatMode(), false)); - } - - documentStyle->setFontDescription(fontDescription); - documentStyle->font().update(m_styleSelector->fontSelector()); - if (inCompatMode()) - documentStyle->setHtmlHacks(true); // enable html specific rendering tricks - + RefPtr<RenderStyle> documentStyle = CSSStyleSelector::styleForDocument(this); StyleChange ch = diff(documentStyle.get(), renderer()->style()); if (renderer() && ch != NoChange) renderer()->setStyle(documentStyle.release()); @@ -1421,7 +1502,7 @@ void Document::updateLayoutIgnorePendingStylesheets() } else if (m_hasNodesWithPlaceholderStyle) // If new nodes have been added or style recalc has been done with style sheets still pending, some nodes // may not have had their real style calculated yet. Normally this gets cleaned when style sheets arrive - // but here we need up-to-date style immediatly. + // but here we need up-to-date style immediately. recalcStyle(Force); } @@ -1430,6 +1511,15 @@ void Document::updateLayoutIgnorePendingStylesheets() m_ignorePendingStylesheets = oldIgnore; } +void Document::createStyleSelector() +{ + bool matchAuthorAndUserStyles = true; + if (Settings* docSettings = settings()) + matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled(); + m_styleSelector.set(new CSSStyleSelector(this, m_styleSheets.get(), m_mappedElementSheet.get(), pageUserSheet(), pageGroupUserSheets(), + !inCompatMode(), matchAuthorAndUserStyles)); +} + void Document::attach() { ASSERT(!attached()); @@ -1447,14 +1537,6 @@ void Document::attach() renderView()->didMoveOnscreen(); #endif - if (!m_styleSelector) { - bool matchAuthorAndUserStyles = true; - if (Settings* docSettings = settings()) - matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled(); - m_styleSelector = new CSSStyleSelector(this, m_styleSheets.get(), m_mappedElementSheet.get(), pageUserSheet(), pageGroupUserSheets(), - !inCompatMode(), matchAuthorAndUserStyles); - } - recalcStyle(Force); RenderObject* render = renderer(); @@ -1514,14 +1596,8 @@ void Document::detach() if (render) render->destroy(); - HashSet<RefPtr<HistoryItem> > associatedHistoryItems; - associatedHistoryItems.swap(m_associatedHistoryItems); - HashSet<RefPtr<HistoryItem> >::iterator end = associatedHistoryItems.end(); - for (HashSet<RefPtr<HistoryItem> >::iterator i = associatedHistoryItems.begin(); i != end; ++i) - (*i)->documentDetached(this); - // This is required, as our Frame might delete itself as soon as it detaches - // us. However, this violates Node::detach() symantics, as it's never + // us. However, this violates Node::detach() semantics, as it's never // possible to re-attach. Eventually Document::detach() should be renamed, // or this setting of the frame to 0 could be made explicit in each of the // callers of Document::detach(). @@ -1606,7 +1682,7 @@ AXObjectCache* Document::axObjectCache() const void Document::setVisuallyOrdered() { - visuallyOrdered = true; + m_visuallyOrdered = true; if (renderer()) renderer()->style()->setVisuallyOrdered(true); } @@ -1789,7 +1865,8 @@ void Document::implicitClose() if (f) f->animation()->resumeAnimations(this); - ImageLoader::dispatchPendingEvents(); + ImageLoader::dispatchPendingBeforeLoadEvents(); + ImageLoader::dispatchPendingLoadEvents(); dispatchWindowLoadEvent(); dispatchWindowEvent(PageTransitionEvent::create(eventNames().pageshowEvent, false), this); if (m_pendingStateObject) @@ -1983,9 +2060,9 @@ void Document::updateBaseURL() m_baseURL = KURL(); if (m_elemSheet) - m_elemSheet->setHref(m_baseURL.string()); + m_elemSheet->setBaseURL(m_baseURL); if (m_mappedElementSheet) - m_mappedElementSheet->setHref(m_baseURL.string()); + m_mappedElementSheet->setBaseURL(m_baseURL); } String Document::userAgent(const KURL& url) const @@ -2007,7 +2084,7 @@ CSSStyleSheet* Document::pageUserSheet() return 0; // Parse the sheet and cache it. - m_pageUserSheet = CSSStyleSheet::create(this, settings()->userStyleSheetLocation()); + m_pageUserSheet = CSSStyleSheet::createInline(this, settings()->userStyleSheetLocation()); m_pageUserSheet->setIsUserStyleSheet(true); m_pageUserSheet->parseString(userSheetText, !inCompatMode()); return m_pageUserSheet.get(); @@ -2042,7 +2119,7 @@ const Vector<RefPtr<CSSStyleSheet> >* Document::pageGroupUserSheets() const const UserStyleSheet* sheet = sheets->at(i).get(); if (!UserContentURLPattern::matchesPatterns(url(), sheet->whitelist(), sheet->blacklist())) continue; - RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::create(const_cast<Document*>(this), sheet->url()); + RefPtr<CSSStyleSheet> parsedSheet = CSSStyleSheet::createInline(const_cast<Document*>(this), sheet->url()); parsedSheet->setIsUserStyleSheet(true); parsedSheet->parseString(sheet->source(), !inCompatMode()); if (!m_pageGroupUserSheets) @@ -2064,14 +2141,14 @@ void Document::clearPageGroupUserSheets() CSSStyleSheet* Document::elementSheet() { if (!m_elemSheet) - m_elemSheet = CSSStyleSheet::create(this, m_baseURL.string()); + m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); return m_elemSheet.get(); } CSSStyleSheet* Document::mappedElementSheet() { if (!m_mappedElementSheet) - m_mappedElementSheet = CSSStyleSheet::create(this, m_baseURL.string()); + m_mappedElementSheet = CSSStyleSheet::createInline(this, m_baseURL); return m_mappedElementSheet.get(); } @@ -2681,10 +2758,7 @@ void Document::recalcStyleSelector() m_styleSheets->swap(sheets); - // Create a new style selector - delete m_styleSelector; - m_styleSelector = new CSSStyleSelector(this, m_styleSheets.get(), m_mappedElementSheet.get(), - pageUserSheet(), pageGroupUserSheets(), !inCompatMode(), matchAuthorAndUserStyles); + m_styleSelector.clear(); m_didCalculateStyleSelector = true; } @@ -3026,6 +3100,25 @@ void Document::dispatchWindowLoadEvent() domWindow->dispatchLoadEvent(); } +void Document::enqueueStorageEvent(PassRefPtr<Event> storageEvent) +{ + m_storageEventQueue.append(storageEvent); + if (!m_storageEventTimer.isActive()) + m_storageEventTimer.startOneShot(0); +} + +void Document::storageEventTimerFired(Timer<Document>*) +{ + ASSERT(!m_storageEventTimer.isActive()); + Vector<RefPtr<Event> > storageEventQueue; + storageEventQueue.swap(m_storageEventQueue); + + typedef Vector<RefPtr<Event> >::const_iterator Iterator; + Iterator end = storageEventQueue.end(); + for (Iterator it = storageEventQueue.begin(); it != end; ++it) + dispatchWindowEvent(*it); +} + PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionCode& ec) { RefPtr<Event> event; @@ -3138,7 +3231,7 @@ String Document::cookie(ExceptionCode& ec) const // INVALID_STATE_ERR exception on getting if the Document has no // browsing context. - if (securityOrigin()->isSandboxed(SandboxOrigin)) { + if (!securityOrigin()->canAccessCookies()) { ec = SECURITY_ERR; return String(); } @@ -3159,7 +3252,7 @@ void Document::setCookie(const String& value, ExceptionCode& ec) // INVALID_STATE_ERR exception on setting if the Document has no // browsing context. - if (securityOrigin()->isSandboxed(SandboxOrigin)) { + if (!securityOrigin()->canAccessCookies()) { ec = SECURITY_ERR; return; } @@ -3185,6 +3278,11 @@ String Document::domain() const void Document::setDomain(const String& newDomain, ExceptionCode& ec) { + if (SecurityOrigin::isDomainRelaxationForbiddenForURLScheme(securityOrigin()->protocol())) { + ec = SECURITY_ERR; + return; + } + // Both NS and IE specify that changing the domain is only allowed when // the new domain is a suffix of the old domain. @@ -3365,6 +3463,8 @@ void Document::removeImageMap(HTMLMapElement* imageMap) if (!name.impl()) return; + m_imageMapsByName.checkConsistency(); + ImageMapsByName::iterator it = m_imageMapsByName.find(name.impl()); if (it != m_imageMapsByName.end() && it->second == imageMap) m_imageMapsByName.remove(it); @@ -3377,6 +3477,7 @@ HTMLMapElement *Document::getImageMap(const String& url) const int hashPos = url.find('#'); String name = (hashPos < 0 ? url : url.substring(hashPos + 1)).impl(); AtomicString mapName = isHTMLDocument() ? name.lower() : name; + m_imageMapsByName.checkConsistency(); return m_imageMapsByName.get(mapName.impl()); } @@ -4087,7 +4188,7 @@ PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const S } // Spec: DOM Level 2 Core: http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-DocCrAttrNS - if (!shouldIgnoreNamespaceChecks && qName.localName() == "xmlns" && qName.namespaceURI() != "http://www.w3.org/2000/xmlns/") { + if (!shouldIgnoreNamespaceChecks && qName.localName() == xmlnsAtom && qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI) { ec = NAMESPACE_ERR; return 0; } @@ -4182,6 +4283,7 @@ CollectionCache* Document::nameCollectionInfo(CollectionType type, const AtomicS NamedCollectionMap::iterator iter = map.find(name.impl()); if (iter == map.end()) iter = map.add(name.impl(), new CollectionCache).first; + iter->second->checkConsistency(); return iter->second; } @@ -4410,10 +4512,8 @@ void Document::initSecurityContext() // loading URL. const KURL& url = m_frame->loader()->url(); m_cookieURL = url; - ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(url)); + ScriptExecutionContext::setSecurityOrigin(SecurityOrigin::create(url, m_frame->loader()->sandboxFlags())); - updateSandboxFlags(); - if (SecurityOrigin::allowSubstituteDataAccessToLocal()) { // If this document was loaded with substituteData, then the document can // load local resources. See https://bugs.webkit.org/show_bug.cgi?id=16756 @@ -4464,6 +4564,29 @@ void Document::setSecurityOrigin(SecurityOrigin* securityOrigin) initDNSPrefetch(); } +#if ENABLE(DATABASE) + +bool Document::isDatabaseReadOnly() const +{ + if (!page() || page()->settings()->privateBrowsingEnabled()) + return true; + return false; +} + +void Document::databaseExceededQuota(const String& name) +{ + Page* currentPage = page(); + if (currentPage) + currentPage->chrome()->client()->exceededDatabaseQuota(document()->frame(), name); +} + +#endif + +bool Document::isContextThread() const +{ + return isMainThread(); +} + void Document::updateURLForPushOrReplaceState(const KURL& url) { Frame* f = frame(); @@ -4486,18 +4609,6 @@ void Document::statePopped(SerializedScriptValue* stateObject) m_pendingStateObject = stateObject; } -void Document::registerHistoryItem(HistoryItem* item) -{ - ASSERT(!m_associatedHistoryItems.contains(item)); - m_associatedHistoryItems.add(item); -} - -void Document::unregisterHistoryItem(HistoryItem* item) -{ - ASSERT(m_associatedHistoryItems.contains(item) || m_associatedHistoryItems.isEmpty()); - m_associatedHistoryItems.remove(item); -} - void Document::updateSandboxFlags() { if (m_frame && securityOrigin()) @@ -4558,63 +4669,12 @@ void Document::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<C m_executeScriptSoonTimer.startOneShot(0); } -// FF method for accessing the selection added for compatability. +// FF method for accessing the selection added for compatibility. DOMSelection* Document::getSelection() const { return frame() ? frame()->domWindow()->getSelection() : 0; } -#if ENABLE(DATABASE) - -void Document::addOpenDatabase(Database* database) -{ - if (!m_openDatabaseSet) - m_openDatabaseSet.set(new DatabaseSet); - - ASSERT(!m_openDatabaseSet->contains(database)); - m_openDatabaseSet->add(database); -} - -void Document::removeOpenDatabase(Database* database) -{ - ASSERT(m_openDatabaseSet && m_openDatabaseSet->contains(database)); - if (!m_openDatabaseSet) - return; - - m_openDatabaseSet->remove(database); -} - -DatabaseThread* Document::databaseThread() -{ - if (!m_databaseThread && !m_hasOpenDatabases) { - // Create the database thread on first request - but not if at least one database was already opened, - // because in that case we already had a database thread and terminated it and should not create another. - m_databaseThread = DatabaseThread::create(); - if (!m_databaseThread->start()) - m_databaseThread = 0; - } - - return m_databaseThread.get(); -} - -void Document::stopDatabases() -{ - if (m_openDatabaseSet) { - DatabaseSet::iterator i = m_openDatabaseSet->begin(); - DatabaseSet::iterator end = m_openDatabaseSet->end(); - for (; i != end; ++i) { - (*i)->stop(); - if (m_databaseThread) - m_databaseThread->unscheduleDatabaseTasks(*i); - } - } - - if (m_databaseThread) - m_databaseThread->requestTermination(); -} - -#endif - #if ENABLE(WML) void Document::resetWMLPageState() { @@ -4753,21 +4813,27 @@ private: }; struct PerformTaskContext : Noncopyable { - PerformTaskContext(ScriptExecutionContext* scriptExecutionContext, PassOwnPtr<ScriptExecutionContext::Task> task) - : scriptExecutionContext(scriptExecutionContext) + PerformTaskContext(PassRefPtr<DocumentWeakReference> documentReference, PassOwnPtr<ScriptExecutionContext::Task> task) + : documentReference(documentReference) , task(task) { } - ScriptExecutionContext* scriptExecutionContext; // The context should exist until task execution. + RefPtr<DocumentWeakReference> documentReference; OwnPtr<ScriptExecutionContext::Task> task; }; static void performTask(void* ctx) { - PerformTaskContext* ptctx = reinterpret_cast<PerformTaskContext*>(ctx); - ptctx->task->performTask(ptctx->scriptExecutionContext); - delete ptctx; + ASSERT(isMainThread()); + + PerformTaskContext* context = reinterpret_cast<PerformTaskContext*>(ctx); + ASSERT(context); + + if (Document* document = context->documentReference->document()) + context->task->performTask(document); + + delete context; } void Document::postTask(PassOwnPtr<Task> task) @@ -4776,7 +4842,7 @@ void Document::postTask(PassOwnPtr<Task> task) ScriptExecutionContextTaskTimer* timer = new ScriptExecutionContextTaskTimer(static_cast<Document*>(this), task); timer->startOneShot(0); } else { - callOnMainThread(performTask, new PerformTaskContext(this, task)); + callOnMainThread(performTask, new PerformTaskContext(m_weakReference, task)); } } diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h index b24063a..f909ba1 100644 --- a/WebCore/dom/Document.h +++ b/WebCore/dom/Document.h @@ -32,9 +32,13 @@ #include "CollectionCache.h" #include "CollectionType.h" #include "Color.h" +#include "Document.h" #include "DocumentMarker.h" #include "ScriptExecutionContext.h" #include "Timer.h" +#if USE(JSC) +#include <runtime/WeakGCMap.h> +#endif #include <wtf/HashCountedSet.h> #include <wtf/OwnPtr.h> #include <wtf/PassOwnPtr.h> @@ -60,6 +64,7 @@ namespace WebCore { class DocLoader; class DocumentFragment; class DocumentType; + class DocumentWeakReference; class EditingText; class Element; class EntityReference; @@ -174,11 +179,11 @@ class Document : public ContainerNode, public ScriptExecutionContext { public: static PassRefPtr<Document> create(Frame* frame) { - return adoptRef(new Document(frame, false)); + return adoptRef(new Document(frame, false, false)); } static PassRefPtr<Document> createXHTML(Frame* frame) { - return adoptRef(new Document(frame, true)); + return adoptRef(new Document(frame, true, false)); } virtual ~Document(); @@ -344,13 +349,14 @@ public: ASSERT(type >= FirstUnnamedDocumentCachedType); unsigned index = type - FirstUnnamedDocumentCachedType; ASSERT(index < NumUnnamedDocumentCachedTypes); + m_collectionInfo[index].checkConsistency(); return &m_collectionInfo[index]; } CollectionCache* nameCollectionInfo(CollectionType, const AtomicString& name); // Other methods (not part of DOM) - virtual bool isHTMLDocument() const { return false; } + bool isHTMLDocument() const { return m_isHTML; } virtual bool isImageDocument() const { return false; } #if ENABLE(SVG) virtual bool isSVGDocument() const { return false; } @@ -369,7 +375,12 @@ public: #endif virtual bool isFrameSet() const { return false; } - CSSStyleSelector* styleSelector() const { return m_styleSelector; } + CSSStyleSelector* styleSelector() + { + if (!m_styleSelector) + createStyleSelector(); + return m_styleSelector.get(); + } Element* getElementByAccessKey(const String& key) const; @@ -473,6 +484,7 @@ public: // to get visually ordered hebrew and arabic pages right void setVisuallyOrdered(); + bool visuallyOrdered() const { return m_visuallyOrdered; } void open(Document* ownerDocument = 0); void implicitOpen(); @@ -613,6 +625,9 @@ public: void dispatchWindowEvent(PassRefPtr<Event>, PassRefPtr<EventTarget> = 0); void dispatchWindowLoadEvent(); + void enqueueStorageEvent(PassRefPtr<Event>); + void storageEventTimerFired(Timer<Document>*); + PassRefPtr<Event> createEvent(const String& eventType, ExceptionCode&); // keep track of what types of event listeners are registered, so we don't @@ -826,7 +841,7 @@ public: void updateFocusAppearanceSoon(); void cancelFocusAppearanceUpdate(); - // FF method for accessing the selection added for compatability. + // FF method for accessing the selection added for compatibility. DOMSelection* getSelection() const; // Extension for manipulating canvas drawing contexts for use in CSS @@ -842,16 +857,13 @@ public: virtual void scriptImported(unsigned long, const String&); virtual void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously. - typedef HashMap<WebCore::Node*, JSNode*> JSWrapperCache; +#if USE(JSC) + typedef JSC::WeakGCMap<WebCore::Node*, JSNode*> JSWrapperCache; typedef HashMap<DOMWrapperWorld*, JSWrapperCache*> JSWrapperCacheMap; JSWrapperCacheMap& wrapperCacheMap() { return m_wrapperCacheMap; } - JSWrapperCache* getWrapperCache(DOMWrapperWorld* world) - { - if (JSWrapperCache* wrapperCache = m_wrapperCacheMap.get(world)) - return wrapperCache; - return createWrapperCache(world); - } + JSWrapperCache* getWrapperCache(DOMWrapperWorld* world); JSWrapperCache* createWrapperCache(DOMWrapperWorld*); +#endif virtual void finishedParsing(); @@ -910,22 +922,18 @@ public: void updateURLForPushOrReplaceState(const KURL&); void statePopped(SerializedScriptValue*); - void registerHistoryItem(HistoryItem* item); - void unregisterHistoryItem(HistoryItem* item); void updateSandboxFlags(); // Set sandbox flags as determined by the frame. bool processingLoadEvent() const { return m_processingLoadEvent; } #if ENABLE(DATABASE) - void addOpenDatabase(Database*); - void removeOpenDatabase(Database*); - DatabaseThread* databaseThread(); // Creates the thread as needed, but not if it has been already terminated. - void setHasOpenDatabases() { m_hasOpenDatabases = true; } - bool hasOpenDatabases() { return m_hasOpenDatabases; } - void stopDatabases(); + virtual bool isDatabaseReadOnly() const; + virtual void databaseExceededQuota(const String& name); #endif + virtual bool isContextThread() const; + void setUsingGeolocation(bool f) { m_usingGeolocation = f; } bool usingGeolocation() const { return m_usingGeolocation; }; @@ -936,11 +944,12 @@ public: void resetWMLPageState(); void initializeWMLPageState(); #endif + + bool containsValidityStyleRules() const { return m_containsValidityStyleRules; } + void setContainsValidityStyleRules() { m_containsValidityStyleRules = true; } protected: - Document(Frame*, bool isXHTML); - - void setStyleSelector(CSSStyleSelector* styleSelector) { m_styleSelector = styleSelector; } + Document(Frame*, bool isXHTML, bool isHTML); void clearXMLVersion() { m_xmlVersion = String(); } @@ -976,7 +985,9 @@ private: void cacheDocumentElement() const; - CSSStyleSelector* m_styleSelector; + void createStyleSelector(); + + OwnPtr<CSSStyleSelector> m_styleSelector; bool m_didCalculateStyleSelector; Frame* m_frame; @@ -1061,7 +1072,7 @@ private: String m_selectedStylesheetSet; bool m_loadingSheet; - bool visuallyOrdered; + bool m_visuallyOrdered; bool m_bParsing; Timer<Document> m_styleRecalcTimer; bool m_inStyleRecalc; @@ -1076,8 +1087,10 @@ private: bool m_isDNSPrefetchEnabled; bool m_haveExplicitlyDisabledDNSPrefetch; bool m_frameElementsShouldIgnoreScrolling; + bool m_containsValidityStyleRules; String m_title; + String m_rawTitle; bool m_titleSetExplicitly; RefPtr<Element> m_titleElement; @@ -1182,23 +1195,25 @@ private: bool m_useSecureKeyboardEntryWhenActive; bool m_isXHTML; + bool m_isHTML; unsigned m_numNodeListCaches; +#if USE(JSC) JSWrapperCacheMap m_wrapperCacheMap; - -#if ENABLE(DATABASE) - RefPtr<DatabaseThread> m_databaseThread; - bool m_hasOpenDatabases; // This never changes back to false, even as the database thread is closed. - typedef HashSet<Database*> DatabaseSet; - OwnPtr<DatabaseSet> m_openDatabaseSet; + JSWrapperCache* m_normalWorldWrapperCache; #endif - + bool m_usingGeolocation; + Timer<Document> m_storageEventTimer; + Vector<RefPtr<Event> > m_storageEventQueue; + #if ENABLE(WML) bool m_containsWMLContent; #endif + + RefPtr<DocumentWeakReference> m_weakReference; }; inline bool Document::hasElementWithId(AtomicStringImpl* id) const diff --git a/WebCore/dom/Document.idl b/WebCore/dom/Document.idl index 69417c8..2b17a13 100644 --- a/WebCore/dom/Document.idl +++ b/WebCore/dom/Document.idl @@ -22,12 +22,9 @@ module core { interface [ CustomToJS, - GenerateConstructor, GenerateNativeConverter, CustomMarkFunction, - InlineGetOwnPropertySlot, - InterfaceUUID=48BB95FC-2D08-4c54-BE65-7558736A4CAE, - ImplementationUUID=FF5CBE81-F817-429c-A6C2-0CCCD2328062 + InlineGetOwnPropertySlot ] Document : Node { // DOM Level 1 Core @@ -81,7 +78,6 @@ module core { attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString documentURI; -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM // DOM Level 2 Events (DocumentEvents interface) Event createEvent(in DOMString eventType) @@ -129,7 +125,6 @@ module core { in XPathResult inResult) raises(DOMException); #endif // ENABLE_XPATH -#endif // !defined(LANGUAGE_COM) // Common extensions @@ -171,9 +166,7 @@ module core { attribute HTMLElement body setter raises (DOMException); -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM readonly attribute HTMLHeadElement head; -#endif readonly attribute HTMLCollection images; readonly attribute HTMLCollection applets; readonly attribute HTMLCollection links; @@ -194,9 +187,7 @@ module core { readonly attribute [ConvertNullStringTo=Undefined] DOMString readyState; Element elementFromPoint(in long x, in long y); -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM Range caretRangeFromPoint(in long x, in long y); -#endif // Mozilla extensions #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT @@ -209,11 +200,9 @@ module core { readonly attribute [ConvertNullStringTo=Null] DOMString preferredStylesheetSet; attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString selectedStylesheetSet; -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM #if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT CSSStyleDeclaration createCSSStyleDeclaration(); #endif -#endif #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C // DOM Level 2 Style Interface @@ -230,11 +219,9 @@ module core { #endif -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C [V8Custom] DOMObject getCSSCanvasContext(in DOMString contextId, in DOMString name, in long width, in long height); #endif -#endif // HTML 5 NodeList getElementsByClassName(in DOMString tagname); @@ -252,7 +239,6 @@ module core { #endif #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM // Event handler DOM attributes attribute [DontEnum] EventListener onabort; attribute [DontEnum] EventListener onblur; @@ -325,7 +311,10 @@ module core { attribute [DontEnum] EventListener ontouchmove; attribute [DontEnum] EventListener ontouchend; attribute [DontEnum] EventListener ontouchcancel; +<<<<<<< HEAD #endif +======= +>>>>>>> webkit.org at r54127 #endif #endif }; diff --git a/WebCore/dom/DocumentFragment.idl b/WebCore/dom/DocumentFragment.idl index ff6232f..882b62d 100644 --- a/WebCore/dom/DocumentFragment.idl +++ b/WebCore/dom/DocumentFragment.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=F5C8DAF0-D728-4b2b-9D9C-630621B07D35, - ImplementationUUID=E57BF71F-3FAA-495c-A307-E288F8E5B2EC - ] DocumentFragment : Node { + interface DocumentFragment : Node { // NodeSelector - Selector API Element querySelector(in DOMString selectors) raises(DOMException); diff --git a/WebCore/dom/DocumentType.idl b/WebCore/dom/DocumentType.idl index ef7b5b6..7992dc5 100644 --- a/WebCore/dom/DocumentType.idl +++ b/WebCore/dom/DocumentType.idl @@ -20,10 +20,7 @@ module core { interface [ - GenerateConstructor, - GenerateNativeConverter, - InterfaceUUID=20F04535-A423-4273-8CFE-3AD996100D29, - ImplementationUUID=736D952F-DBAF-458b-834B-F1638700BD88 + GenerateNativeConverter ] DocumentType : Node { // DOM Level 1 diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index d7f1b11..ac4fdb3 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -42,6 +42,7 @@ #include "FrameView.h" #include "HTMLElement.h" #include "HTMLNames.h" +#include "InspectorController.h" #include "NamedNodeMap.h" #include "NodeList.h" #include "NodeRenderStyle.h" @@ -159,21 +160,6 @@ NamedNodeMap* Element::attributes() const return attributes(false); } -NamedNodeMap* Element::attributes(bool readonly) const -{ - if (!m_isStyleAttributeValid) - updateStyleAttribute(); - -#if ENABLE(SVG) - if (!m_areSVGAttributesValid) - updateAnimatedSVGAttribute(String()); -#endif - - if (!readonly && !namedAttrMap) - createAttributeMap(); - return namedAttrMap.get(); -} - Node::NodeType Element::nodeType() const { return ELEMENT_NODE; @@ -196,7 +182,7 @@ const AtomicString& Element::getAttribute(const QualifiedName& name) const #if ENABLE(SVG) if (!m_areSVGAttributesValid) - updateAnimatedSVGAttribute(name.localName()); + updateAnimatedSVGAttribute(name); #endif if (namedAttrMap) @@ -502,8 +488,10 @@ const AtomicString& Element::getAttribute(const String& name) const updateStyleAttribute(); #if ENABLE(SVG) - if (!m_areSVGAttributesValid) - updateAnimatedSVGAttribute(name); + if (!m_areSVGAttributesValid) { + // We're not passing a namespace argument on purpose. SVGNames::*Attr are defined w/o namespaces as well. + updateAnimatedSVGAttribute(QualifiedName(nullAtom, name, nullAtom)); + } #endif if (namedAttrMap) @@ -532,9 +520,9 @@ void Element::setAttribute(const AtomicString& name, const AtomicString& value, document()->incDOMTreeVersion(); - if (localName == idAttr.localName()) + if (localName == idAttributeName().localName()) updateId(old ? old->value() : nullAtom, value); - + if (old && value.isNull()) namedAttrMap->removeAttribute(old->name()); else if (!old && !value.isNull()) @@ -543,6 +531,15 @@ void Element::setAttribute(const AtomicString& name, const AtomicString& value, old->setValue(value); attributeChanged(old); } + +#if ENABLE(INSPECTOR) + if (Page* page = document()->page()) { + if (InspectorController* inspectorController = page->inspectorController()) { + if (!m_synchronizingStyleAttribute) + inspectorController->didModifyDOMAttr(this); + } + } +#endif } void Element::setAttribute(const QualifiedName& name, const AtomicString& value, ExceptionCode&) @@ -552,9 +549,9 @@ void Element::setAttribute(const QualifiedName& name, const AtomicString& value, // allocate attributemap if necessary Attribute* old = attributes(false)->getAttributeItem(name); - if (name == idAttr) + if (name == idAttributeName()) updateId(old ? old->value() : nullAtom, value); - + if (old && value.isNull()) namedAttrMap->removeAttribute(name); else if (!old && !value.isNull()) @@ -563,6 +560,15 @@ void Element::setAttribute(const QualifiedName& name, const AtomicString& value, old->setValue(value); attributeChanged(old); } + +#if ENABLE(INSPECTOR) + if (Page* page = document()->page()) { + if (InspectorController* inspectorController = page->inspectorController()) { + if (!m_synchronizingStyleAttribute) + inspectorController->didModifyDOMAttr(this); + } + } +#endif } PassRefPtr<Attribute> Element::createAttribute(const QualifiedName& name, const AtomicString& value) @@ -578,20 +584,22 @@ void Element::attributeChanged(Attribute* attr, bool) void Element::updateAfterAttributeChanged(Attribute* attr) { - AXObjectCache* axObjectCache = document()->axObjectCache(); - if (!axObjectCache->accessibilityEnabled()) + if (!AXObjectCache::accessibilityEnabled()) return; const QualifiedName& attrName = attr->name(); if (attrName == aria_activedescendantAttr) { // any change to aria-activedescendant attribute triggers accessibility focus change, but document focus remains intact - axObjectCache->handleActiveDescendantChanged(renderer()); + document()->axObjectCache()->handleActiveDescendantChanged(renderer()); } else if (attrName == roleAttr) { // the role attribute can change at any time, and the AccessibilityObject must pick up these changes - axObjectCache->handleAriaRoleChanged(renderer()); + document()->axObjectCache()->handleAriaRoleChanged(renderer()); } else if (attrName == aria_valuenowAttr) { // If the valuenow attribute changes, AX clients need to be notified. - axObjectCache->postNotification(renderer(), AXObjectCache::AXValueChanged, true); + document()->axObjectCache()->postNotification(renderer(), AXObjectCache::AXValueChanged, true); + } else if (attrName == aria_labelAttr || attrName == aria_labeledbyAttr || attrName == altAttr || attrName == titleAttr) { + // If the content of an element changes due to an attribute change, notify accessibility. + document()->axObjectCache()->contentChanged(renderer()); } } @@ -600,15 +608,31 @@ void Element::recalcStyleIfNeededAfterAttributeChanged(Attribute* attr) if (document()->attached() && document()->styleSelector()->hasSelectorForAttribute(attr->name().localName())) setNeedsStyleRecalc(); } - -void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list) + +// Returns true is the given attribute is an event handler. +// We consider an event handler any attribute that begins with "on". +// It is a simple solution that has the advantage of not requiring any +// code or configuration change if a new event handler is defined. + +static bool isEventHandlerAttribute(const QualifiedName& name) +{ + return name.namespaceURI().isNull() && name.localName().startsWith("on"); +} + +static bool isAttributeToRemove(const QualifiedName& name, const AtomicString& value) +{ + return (name.localName().endsWith(hrefAttr.localName()) || name == srcAttr || name == actionAttr) && protocolIsJavaScript(deprecatedParseURL(value)); +} + +void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list, FragmentScriptingPermission scriptingPermission) { document()->incDOMTreeVersion(); // If setting the whole map changes the id attribute, we need to call updateId. - Attribute* oldId = namedAttrMap ? namedAttrMap->getAttributeItem(idAttr) : 0; - Attribute* newId = list ? list->getAttributeItem(idAttr) : 0; + const QualifiedName& idName = idAttributeName(); + Attribute* oldId = namedAttrMap ? namedAttrMap->getAttributeItem(idName) : 0; + Attribute* newId = list ? list->getAttributeItem(idName) : 0; if (oldId || newId) updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom); @@ -620,6 +644,22 @@ void Element::setAttributeMap(PassRefPtr<NamedNodeMap> list) if (namedAttrMap) { namedAttrMap->m_element = this; + // If the element is created as result of a paste or drag-n-drop operation + // we want to remove all the script and event handlers. + if (scriptingPermission == FragmentScriptingNotAllowed) { + unsigned i = 0; + while (i < namedAttrMap->length()) { + const QualifiedName& attributeName = namedAttrMap->m_attributes[i]->name(); + if (isEventHandlerAttribute(attributeName)) { + namedAttrMap->m_attributes.remove(i); + continue; + } + + if (isAttributeToRemove(attributeName, namedAttrMap->m_attributes[i]->value())) + namedAttrMap->m_attributes[i]->setValue(nullAtom); + i++; + } + } unsigned len = namedAttrMap->length(); for (unsigned i = 0; i < len; i++) attributeChanged(namedAttrMap->m_attributes[i].get()); @@ -634,7 +674,7 @@ bool Element::hasAttributes() const #if ENABLE(SVG) if (!m_areSVGAttributesValid) - updateAnimatedSVGAttribute(String()); + updateAnimatedSVGAttribute(anyQName()); #endif return namedAttrMap && namedAttrMap->length() > 0; @@ -650,14 +690,14 @@ String Element::nodeNamePreservingCase() const return m_tagName.toString(); } -void Element::setPrefix(const AtomicString &_prefix, ExceptionCode& ec) +void Element::setPrefix(const AtomicString& prefix, ExceptionCode& ec) { ec = 0; - checkSetPrefix(_prefix, ec); + checkSetPrefix(prefix, ec); if (ec) return; - m_tagName.setPrefix(_prefix); + m_tagName.setPrefix(prefix.isEmpty() ? AtomicString() : prefix); } KURL Element::baseURI() const @@ -713,7 +753,7 @@ void Element::insertedIntoDocument() if (hasID()) { if (NamedNodeMap* attrs = namedAttrMap.get()) { - Attribute* idItem = attrs->getAttributeItem(idAttr); + Attribute* idItem = attrs->getAttributeItem(idAttributeName()); if (idItem && !idItem->isNull()) updateId(nullAtom, idItem->value()); } @@ -724,7 +764,7 @@ void Element::removedFromDocument() { if (hasID()) { if (NamedNodeMap* attrs = namedAttrMap.get()) { - Attribute* idItem = attrs->getAttributeItem(idAttr); + Attribute* idItem = attrs->getAttributeItem(idAttributeName()); if (idItem && !idItem->isNull()) updateId(idItem->value(), nullAtom); } @@ -1001,6 +1041,7 @@ void Element::finishParsingChildren() void Element::dispatchAttrRemovalEvent(Attribute*) { ASSERT(!eventDispatchForbidden()); + #if 0 if (!document()->hasListenerType(Document::DOMATTRMODIFIED_LISTENER)) return; @@ -1013,6 +1054,7 @@ void Element::dispatchAttrRemovalEvent(Attribute*) void Element::dispatchAttrAdditionEvent(Attribute*) { ASSERT(!eventDispatchForbidden()); + #if 0 if (!document()->hasListenerType(Document::DOMATTRMODIFIED_LISTENER)) return; @@ -1047,21 +1089,6 @@ String Element::openTagStartToString() const return result; } -void Element::updateId(const AtomicString& oldId, const AtomicString& newId) -{ - if (!inDocument()) - return; - - if (oldId == newId) - return; - - Document* doc = document(); - if (!oldId.isEmpty()) - doc->removeElementById(oldId, this); - if (!newId.isEmpty()) - doc->addElementById(newId, this); -} - #ifndef NDEBUG void Element::formatForDebugger(char* buffer, unsigned length) const { @@ -1073,7 +1100,7 @@ void Element::formatForDebugger(char* buffer, unsigned length) const result += s; } - s = getAttribute(idAttr); + s = getAttribute(idAttributeName()); if (s.length() > 0) { if (result.length() > 0) result += "; "; @@ -1133,13 +1160,17 @@ PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionCode& ec) return static_pointer_cast<Attr>(attrs->removeNamedItem(attr->qualifiedName(), ec)); } -void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode& ec) +void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode& ec, FragmentScriptingPermission scriptingPermission) { String prefix, localName; if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec)) return; QualifiedName qName(prefix, localName, namespaceURI); + + if (scriptingPermission == FragmentScriptingNotAllowed && (isEventHandlerAttribute(qName) || isAttributeToRemove(qName, value))) + return; + setAttribute(qName, value, ec); } @@ -1152,6 +1183,14 @@ void Element::removeAttribute(const String& name, ExceptionCode& ec) if (ec == NOT_FOUND_ERR) ec = 0; } + +#if ENABLE(INSPECTOR) + if (Page* page = document()->page()) { + if (InspectorController* inspectorController = page->inspectorController()) + inspectorController->didModifyDOMAttr(this); + } +#endif + } void Element::removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode& ec) @@ -1250,7 +1289,7 @@ void Element::updateFocusAppearance(bool /*restorePreviousSelection*/) } } // FIXME: I'm not sure all devices will want this off, but this is - // currently turned off for Andriod. + // currently turned off for Android. #if !ENABLE(DIRECTIONAL_PAD_NAVIGATION) else if (renderer() && !renderer()->isWidget()) renderer()->enclosingLayer()->scrollRectToVisible(getRect()); @@ -1423,7 +1462,7 @@ bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec) KURL Element::getURLAttribute(const QualifiedName& name) const { -#ifndef NDEBUG +#if !ASSERT_DISABLED if (namedAttrMap) { if (Attribute* attribute = namedAttrMap->getAttributeItem(name)) ASSERT(isURLAttribute(attribute)); @@ -1432,4 +1471,9 @@ KURL Element::getURLAttribute(const QualifiedName& name) const return document()->completeURL(deprecatedParseURL(getAttribute(name))); } +const QualifiedName& Element::rareIDAttributeName() const +{ + return rareData()->m_idAttributeName; +} + } // namespace WebCore diff --git a/WebCore/dom/Element.h b/WebCore/dom/Element.h index bc9a7d7..15032d7 100644 --- a/WebCore/dom/Element.h +++ b/WebCore/dom/Element.h @@ -26,6 +26,9 @@ #define Element_h #include "ContainerNode.h" +#include "Document.h" +#include "HTMLNames.h" +#include "MappedAttributeEntry.h" #include "QualifiedName.h" #include "ScrollTypes.h" @@ -71,7 +74,7 @@ public: DEFINE_ATTRIBUTE_EVENT_LISTENER(select); DEFINE_ATTRIBUTE_EVENT_LISTENER(submit); - // These 4 attribute event handler attributes are overrided by HTMLBodyElement + // These four attribute event handler attributes are overridden by HTMLBodyElement // and HTMLFrameSetElement to forward to the DOMWindow. DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(blur); DEFINE_VIRTUAL_ATTRIBUTE_EVENT_LISTENER(error); @@ -110,7 +113,9 @@ public: const AtomicString& getAttributeNS(const String& namespaceURI, const String& localName) const; void setAttribute(const AtomicString& name, const AtomicString& value, ExceptionCode&); - void setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode&); + void setAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& value, ExceptionCode&, FragmentScriptingPermission = FragmentScriptingAllowed); + + const QualifiedName& idAttributeName() const; void scrollIntoView(bool alignToTop = true); void scrollIntoViewIfNeeded(bool centerIfNeeded = true); @@ -184,7 +189,7 @@ public: virtual void attributeChanged(Attribute*, bool preserveDecls = false); // not part of the DOM - void setAttributeMap(PassRefPtr<NamedNodeMap>); + void setAttributeMap(PassRefPtr<NamedNodeMap>, FragmentScriptingPermission = FragmentScriptingAllowed); NamedNodeMap* attributeMap() const { return namedAttrMap.get(); } virtual void copyNonAttributeProperties(const Element* /*source*/) { } @@ -283,6 +288,7 @@ private: virtual bool childTypeAllowed(NodeType); virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value); + const QualifiedName& rareIDAttributeName() const; #ifndef NDEBUG virtual void formatForDebugger(char* buffer, unsigned length) const; @@ -295,7 +301,7 @@ private: virtual void updateStyleAttribute() const { } #if ENABLE(SVG) - virtual void updateAnimatedSVGAttribute(const String&) const { } + virtual void updateAnimatedSVGAttribute(const QualifiedName&) const { } #endif void updateFocusAppearanceSoonAfterAttach(); @@ -340,6 +346,41 @@ inline Element* Node::parentElement() const return parent && parent->isElementNode() ? static_cast<Element*>(parent) : 0; } +inline const QualifiedName& Element::idAttributeName() const +{ + return hasRareData() ? rareIDAttributeName() : HTMLNames::idAttr; +} + +inline NamedNodeMap* Element::attributes(bool readonly) const +{ + if (!m_isStyleAttributeValid) + updateStyleAttribute(); + +#if ENABLE(SVG) + if (!m_areSVGAttributesValid) + updateAnimatedSVGAttribute(anyQName()); +#endif + + if (!readonly && !namedAttrMap) + createAttributeMap(); + return namedAttrMap.get(); +} + +inline void Element::updateId(const AtomicString& oldId, const AtomicString& newId) +{ + if (!inDocument()) + return; + + if (oldId == newId) + return; + + Document* doc = document(); + if (!oldId.isEmpty()) + doc->removeElementById(oldId, this); + if (!newId.isEmpty()) + doc->addElementById(newId, this); +} + } //namespace #endif diff --git a/WebCore/dom/Element.idl b/WebCore/dom/Element.idl index 4a223bb..c9b6260 100644 --- a/WebCore/dom/Element.idl +++ b/WebCore/dom/Element.idl @@ -22,11 +22,8 @@ module core { interface [ CustomMarkFunction, - GenerateConstructor, GenerateNativeConverter, - InlineGetOwnPropertySlot, - InterfaceUUID=FEFE9C21-E58C-4b5b-821A-61A514613763, - ImplementationUUID=12E5B08E-A680-4baf-9D1E-108AEF7ABBFB + InlineGetOwnPropertySlot ] Element : Node { // DOM Level 1 Core @@ -67,9 +64,7 @@ module core { [OldStyleObjC] boolean hasAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI, in DOMString localName); -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM readonly attribute CSSStyleDeclaration style; -#endif // Common extensions @@ -110,7 +105,6 @@ module core { NodeList querySelectorAll(in DOMString selectors) raises(DOMException); -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM // WebKit extension, pending specification. boolean webkitMatchesSelector(in DOMString selectors) raises(DOMException); @@ -121,7 +115,6 @@ module core { readonly attribute Element previousElementSibling; readonly attribute Element nextElementSibling; readonly attribute unsigned long childElementCount; -#endif #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT // CSSOM View Module API @@ -135,7 +128,6 @@ module core { #endif #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM // Event handler DOM attributes attribute [DontEnum] EventListener onabort; attribute [DontEnum] EventListener onblur; @@ -208,7 +200,10 @@ module core { attribute [DontEnum] EventListener ontouchmove; attribute [DontEnum] EventListener ontouchend; attribute [DontEnum] EventListener ontouchcancel; +<<<<<<< HEAD #endif +======= +>>>>>>> webkit.org at r54127 #endif #endif }; diff --git a/WebCore/dom/ElementRareData.h b/WebCore/dom/ElementRareData.h index 94e0499..f23ad8e 100644 --- a/WebCore/dom/ElementRareData.h +++ b/WebCore/dom/ElementRareData.h @@ -27,6 +27,8 @@ namespace WebCore { +using namespace HTMLNames; + class ElementRareData : public NodeRareData { public: ElementRareData(); @@ -38,6 +40,7 @@ public: IntSize m_minimumSizeForResizing; RefPtr<RenderStyle> m_computedStyle; + QualifiedName m_idAttributeName; }; inline IntSize defaultMinimumSizeForResizing() @@ -47,6 +50,7 @@ inline IntSize defaultMinimumSizeForResizing() inline ElementRareData::ElementRareData() : m_minimumSizeForResizing(defaultMinimumSizeForResizing()) + , m_idAttributeName(idAttr) { } diff --git a/WebCore/dom/Entity.idl b/WebCore/dom/Entity.idl index b154797..8dacbe9 100644 --- a/WebCore/dom/Entity.idl +++ b/WebCore/dom/Entity.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=5CDB5ACA-F3A7-47ea-B89C-F335E4342C55, - ImplementationUUID=DDD2A621-59FD-4bb2-9F95-7061C3FB9F06 - ] Entity : Node { + interface Entity : Node { readonly attribute [ConvertNullStringTo=Null] DOMString publicId; readonly attribute [ConvertNullStringTo=Null] DOMString systemId; readonly attribute [ConvertNullStringTo=Null] DOMString notationName; diff --git a/WebCore/dom/EntityReference.idl b/WebCore/dom/EntityReference.idl index 8a206e9..f652d9a 100644 --- a/WebCore/dom/EntityReference.idl +++ b/WebCore/dom/EntityReference.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=61BF4A03-19FB-4ac4-A624-5BF0893FDA65, - ImplementationUUID=486E1182-CF4F-450b-B411-A584CA42BBD0 - ] EntityReference : Node { + interface EntityReference : Node { }; } diff --git a/WebCore/dom/ErrorEvent.idl b/WebCore/dom/ErrorEvent.idl index 6125e1e..ad13193 100644 --- a/WebCore/dom/ErrorEvent.idl +++ b/WebCore/dom/ErrorEvent.idl @@ -32,7 +32,6 @@ module events { interface [ Conditional=WORKERS, - GenerateConstructor, NoStaticTables ] ErrorEvent : Event { diff --git a/WebCore/dom/Event.idl b/WebCore/dom/Event.idl index 75b6b5f..d64d122 100644 --- a/WebCore/dom/Event.idl +++ b/WebCore/dom/Event.idl @@ -23,11 +23,8 @@ module events { // Introduced in DOM Level 2: interface [ CustomToJS, - GenerateConstructor, NoStaticTables, - Polymorphic, - InterfaceUUID=D17495FA-ACAD-4d27-9362-E19E057B189D, - ImplementationUUID=CFDCDDB2-5B3F-412d-BDA4-80B23C721549 + Polymorphic ] Event { // DOM PhaseType @@ -61,9 +58,8 @@ module events { readonly attribute unsigned short eventPhase; readonly attribute boolean bubbles; readonly attribute boolean cancelable; -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM readonly attribute DOMTimeStamp timeStamp; -#endif + void stopPropagation(); void preventDefault(); [OldStyleObjC] void initEvent(in DOMString eventTypeArg, diff --git a/WebCore/dom/EventException.idl b/WebCore/dom/EventException.idl index 3d82f85..1c8fac6 100644 --- a/WebCore/dom/EventException.idl +++ b/WebCore/dom/EventException.idl @@ -30,7 +30,6 @@ module events { // Introduced in DOM Level 2: interface [ - GenerateConstructor, NoStaticTables ] EventException { diff --git a/WebCore/dom/EventListener.idl b/WebCore/dom/EventListener.idl index 1edf52f..023777b 100644 --- a/WebCore/dom/EventListener.idl +++ b/WebCore/dom/EventListener.idl @@ -25,7 +25,7 @@ module events { NoStaticTables, ObjCProtocol, PureInterface, - InterfaceUUID=B04F2AE3-71E2-4ebe-ABFE-EF4938354082, + OmitConstructor ] EventListener { void handleEvent(in Event evt); }; diff --git a/WebCore/dom/EventNames.h b/WebCore/dom/EventNames.h index c8c3291..4a0a042 100644 --- a/WebCore/dom/EventNames.h +++ b/WebCore/dom/EventNames.h @@ -150,10 +150,15 @@ namespace WebCore { macro(touchmove) \ macro(touchend) \ macro(touchcancel) \ +<<<<<<< HEAD /* #if PLATFORM(ANDROID) */ \ macro(touchlongpress) \ macro(touchdoubletap) \ /* #endif */ \ +======= + \ + macro(success) \ +>>>>>>> webkit.org at r54127 \ // end of DOM_EVENT_NAMES_FOR_EACH diff --git a/WebCore/dom/EventTarget.h b/WebCore/dom/EventTarget.h index 2d77c87..fa5ca09 100644 --- a/WebCore/dom/EventTarget.h +++ b/WebCore/dom/EventTarget.h @@ -36,6 +36,7 @@ #include "EventNames.h" #include "RegisteredEventListener.h" #include <wtf/Forward.h> +#include <wtf/HashMap.h> namespace WebCore { diff --git a/WebCore/dom/EventTarget.idl b/WebCore/dom/EventTarget.idl index 844dc32..0cdb6b3 100644 --- a/WebCore/dom/EventTarget.idl +++ b/WebCore/dom/EventTarget.idl @@ -24,7 +24,7 @@ module events { interface [ ObjCProtocol, PureInterface, - InterfaceUUID=1D71C7EC-0BA0-4044-BDFD-56B3E8F5F9D4 + OmitConstructor ] EventTarget { [OldStyleObjC] void addEventListener(in DOMString type, in EventListener listener, diff --git a/WebCore/dom/InputElement.cpp b/WebCore/dom/InputElement.cpp index c29cb1c..13bb0b2 100644 --- a/WebCore/dom/InputElement.cpp +++ b/WebCore/dom/InputElement.cpp @@ -22,6 +22,7 @@ #include "InputElement.h" #include "BeforeTextInsertedEvent.h" +#include "Chrome.h" #include "ChromeClient.h" #include "Document.h" #include "Event.h" diff --git a/WebCore/dom/InputElement.h b/WebCore/dom/InputElement.h index 2ae0312..a24b438 100644 --- a/WebCore/dom/InputElement.h +++ b/WebCore/dom/InputElement.h @@ -47,6 +47,7 @@ public: virtual bool searchEventsShouldBeDispatched() const = 0; virtual int size() const = 0; + virtual const String& suggestedValue() const = 0; virtual String value() const = 0; virtual void setValue(const String&, bool sendChangeEvent = false) = 0; virtual void setValueForUser(const String&) = 0; @@ -92,6 +93,9 @@ public: String value() const { return m_value; } void setValue(const String& value) { m_value = value; } + const String& suggestedValue() const { return m_suggestedValue; } + void setSuggestedValue(const String& value) { m_suggestedValue = value; } + int size() const { return m_size; } void setSize(int value) { m_size = value; } @@ -107,6 +111,7 @@ public: private: AtomicString m_name; String m_value; + String m_suggestedValue; int m_size; int m_maxLength; int m_cachedSelectionStart; diff --git a/WebCore/dom/KeyboardEvent.idl b/WebCore/dom/KeyboardEvent.idl index 58e5da7..1af3d02 100644 --- a/WebCore/dom/KeyboardEvent.idl +++ b/WebCore/dom/KeyboardEvent.idl @@ -21,9 +21,7 @@ module events { // Introduced in DOM Level 3: - interface [ - GenerateConstructor - ] KeyboardEvent : UIEvent { + interface KeyboardEvent : UIEvent { #if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT // KeyLocationCode diff --git a/WebCore/dom/MappedAttributeEntry.h b/WebCore/dom/MappedAttributeEntry.h index 842e7a8..ce2464e 100644 --- a/WebCore/dom/MappedAttributeEntry.h +++ b/WebCore/dom/MappedAttributeEntry.h @@ -47,7 +47,9 @@ enum MappedAttributeEntry { // When adding new entries, make sure to keep eLastEntry at the end of the list. , eLastEntry }; - + +enum FragmentScriptingPermission { FragmentScriptingAllowed, FragmentScriptingNotAllowed }; + } #endif diff --git a/WebCore/dom/MessageChannel.idl b/WebCore/dom/MessageChannel.idl index 4e0892b..bae5b18 100644 --- a/WebCore/dom/MessageChannel.idl +++ b/WebCore/dom/MessageChannel.idl @@ -26,7 +26,7 @@ module events { - interface [CustomMarkFunction, NoStaticTables] MessageChannel { + interface [CustomConstructor, CustomMarkFunction, NoStaticTables] MessageChannel { readonly attribute MessagePort port1; readonly attribute MessagePort port2; diff --git a/WebCore/dom/MessageEvent.idl b/WebCore/dom/MessageEvent.idl index 7e497fc..2b47374 100644 --- a/WebCore/dom/MessageEvent.idl +++ b/WebCore/dom/MessageEvent.idl @@ -27,10 +27,9 @@ module events { interface [ - GenerateConstructor, NoStaticTables ] MessageEvent : Event { - readonly attribute SerializedScriptValue data; + readonly attribute [CachedAttribute] SerializedScriptValue data; readonly attribute DOMString origin; readonly attribute DOMString lastEventId; diff --git a/WebCore/dom/MessagePort.idl b/WebCore/dom/MessagePort.idl index a9149ec..62cf63a 100644 --- a/WebCore/dom/MessagePort.idl +++ b/WebCore/dom/MessagePort.idl @@ -29,7 +29,6 @@ module events { interface [ CustomMarkFunction, EventTarget, - GenerateConstructor, NoStaticTables ] MessagePort { // We need to have something as an ObjC binding, because MessagePort is used in MessageEvent, which already has one, diff --git a/WebCore/dom/MessagePortChannel.h b/WebCore/dom/MessagePortChannel.h index 90cb0d9..192cb92 100644 --- a/WebCore/dom/MessagePortChannel.h +++ b/WebCore/dom/MessagePortChannel.h @@ -62,7 +62,7 @@ namespace WebCore { // Creates a new wrapper for the passed channel. static PassOwnPtr<MessagePortChannel> create(PassRefPtr<PlatformMessagePortChannel>); - // Entangles the channel with a port (called when a port has been cloned, after the clone has been marshalled to its new owning thread and is ready to receive messages). + // Entangles the channel with a port (called when a port has been cloned, after the clone has been marshaled to its new owning thread and is ready to receive messages). // Returns false if the entanglement failed because the port was closed. bool entangleIfOpen(MessagePort*); diff --git a/WebCore/dom/MouseEvent.idl b/WebCore/dom/MouseEvent.idl index c509459..49385f1 100644 --- a/WebCore/dom/MouseEvent.idl +++ b/WebCore/dom/MouseEvent.idl @@ -20,9 +20,7 @@ module events { // Introduced in DOM Level 2: - interface [ - GenerateConstructor - ] MouseEvent : UIEvent { + interface MouseEvent : UIEvent { readonly attribute long screenX; readonly attribute long screenY; readonly attribute long clientX; diff --git a/WebCore/dom/MouseRelatedEvent.cpp b/WebCore/dom/MouseRelatedEvent.cpp index 87815b1..15d4e43 100644 --- a/WebCore/dom/MouseRelatedEvent.cpp +++ b/WebCore/dom/MouseRelatedEvent.cpp @@ -151,7 +151,7 @@ void MouseRelatedEvent::receivedTarget() } // Adjust layerX/Y to be relative to the layer. - // FIXME: We're pretty sure this is the wrong defintion of "layer." + // FIXME: We're pretty sure this is the wrong definition of "layer." // Our RenderLayer is a more modern concept, and layerX/Y is some // other notion about groups of elements (left over from the Netscape 4 days?); // we should test and fix this. diff --git a/WebCore/dom/MutationEvent.idl b/WebCore/dom/MutationEvent.idl index ea7a4dd..99a6aaa 100644 --- a/WebCore/dom/MutationEvent.idl +++ b/WebCore/dom/MutationEvent.idl @@ -20,9 +20,7 @@ module events { // Introduced in DOM Level 2: - interface [ - GenerateConstructor - ] MutationEvent : Event { + interface MutationEvent : Event { // attrChangeType const unsigned short MODIFICATION = 1; diff --git a/WebCore/dom/NamedAttrMap.cpp b/WebCore/dom/NamedAttrMap.cpp index 56b40b9..d8a6ba8 100644 --- a/WebCore/dom/NamedAttrMap.cpp +++ b/WebCore/dom/NamedAttrMap.cpp @@ -130,7 +130,7 @@ PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec) return 0; } - if (a->name() == idAttr) + if (attr->isId()) m_element->updateId(old ? old->value() : nullAtom, a->value()); // ### slightly inefficient - resizes attribute array twice. @@ -155,9 +155,9 @@ PassRefPtr<Node> NamedNodeMap::removeNamedItem(const QualifiedName& name, Except return 0; } - RefPtr<Node> r = a->createAttrIfNeeded(m_element); + RefPtr<Attr> r = a->createAttrIfNeeded(m_element); - if (name == idAttr) + if (r->isId()) m_element->updateId(a->value(), nullAtom); removeAttribute(name); @@ -172,52 +172,27 @@ PassRefPtr<Node> NamedNodeMap::item(unsigned index) const return m_attributes[index]->createAttrIfNeeded(m_element); } -// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller -// can tune the behaviour (hasAttribute is case sensitive whereas getAttribute is not). -Attribute* NamedNodeMap::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const +Attribute* NamedNodeMap::getAttributeItemSlowCase(const String& name, bool shouldIgnoreAttributeCase) const { unsigned len = length(); - bool doSlowCheck = shouldIgnoreAttributeCase; - - // Optimize for the case where the attribute exists and its name exactly matches. + + // Continue to checking case-insensitively and/or full namespaced names if necessary: for (unsigned i = 0; i < len; ++i) { const QualifiedName& attrName = m_attributes[i]->name(); if (!attrName.hasPrefix()) { - if (name == attrName.localName()) + if (shouldIgnoreAttributeCase && equalIgnoringCase(name, attrName.localName())) + return m_attributes[i].get(); + } else { + // FIXME: Would be faster to do this comparison without calling toString, which + // generates a temporary string by concatenation. But this branch is only reached + // if the attribute name has a prefix, which is rare in HTML. + if (equalPossiblyIgnoringCase(name, attrName.toString(), shouldIgnoreAttributeCase)) return m_attributes[i].get(); - } else - doSlowCheck = true; - } - - // Continue to checking case-insensitively and/or full namespaced names if necessary: - if (doSlowCheck) { - for (unsigned i = 0; i < len; ++i) { - const QualifiedName& attrName = m_attributes[i]->name(); - if (!attrName.hasPrefix()) { - if (shouldIgnoreAttributeCase && equalIgnoringCase(name, attrName.localName())) - return m_attributes[i].get(); - } else { - // FIXME: Would be faster to do this comparison without calling toString, which - // generates a temporary string by concatenation. But this branch is only reached - // if the attribute name has a prefix, which is rare in HTML. - if (equalPossiblyIgnoringCase(name, attrName.toString(), shouldIgnoreAttributeCase)) - return m_attributes[i].get(); - } } } return 0; } -Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) const -{ - unsigned len = length(); - for (unsigned i = 0; i < len; ++i) { - if (m_attributes[i]->name().matches(name)) - return m_attributes[i].get(); - } - return 0; -} - void NamedNodeMap::clearAttributes() { detachAttributesFromElement(); @@ -242,8 +217,8 @@ void NamedNodeMap::setAttributes(const NamedNodeMap& other) // If assigning the map changes the id attribute, we need to call // updateId. - Attribute *oldId = getAttributeItem(idAttr); - Attribute *newId = other.getAttributeItem(idAttr); + Attribute* oldId = getAttributeItem(m_element->idAttributeName()); + Attribute* newId = other.getAttributeItem(m_element->idAttributeName()); if (oldId || newId) m_element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom); diff --git a/WebCore/dom/NamedAttrMap.h b/WebCore/dom/NamedAttrMap.h index 759900b..d5136b5 100644 --- a/WebCore/dom/NamedAttrMap.h +++ b/WebCore/dom/NamedAttrMap.h @@ -103,12 +103,45 @@ private: void detachAttributesFromElement(); void detachFromElement(); Attribute* getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const; + Attribute* getAttributeItemSlowCase(const String& name, bool shouldIgnoreAttributeCase) const; Element* m_element; Vector<RefPtr<Attribute> > m_attributes; AtomicString m_id; }; +inline Attribute* NamedNodeMap::getAttributeItem(const QualifiedName& name) const +{ + unsigned len = length(); + for (unsigned i = 0; i < len; ++i) { + if (m_attributes[i]->name().matches(name)) + return m_attributes[i].get(); + } + return 0; +} + +// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller +// can tune the behaviour (hasAttribute is case sensitive whereas getAttribute is not). +inline Attribute* NamedNodeMap::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const +{ + unsigned len = length(); + bool doSlowCheck = shouldIgnoreAttributeCase; + + // Optimize for the case where the attribute exists and its name exactly matches. + for (unsigned i = 0; i < len; ++i) { + const QualifiedName& attrName = m_attributes[i]->name(); + if (!attrName.hasPrefix()) { + if (name == attrName.localName()) + return m_attributes[i].get(); + } else + doSlowCheck = true; + } + + if (doSlowCheck) + return getAttributeItemSlowCase(name, shouldIgnoreAttributeCase); + return 0; +} + } //namespace #undef id diff --git a/WebCore/dom/NamedNodeMap.idl b/WebCore/dom/NamedNodeMap.idl index 8166853..4d36577 100644 --- a/WebCore/dom/NamedNodeMap.idl +++ b/WebCore/dom/NamedNodeMap.idl @@ -22,11 +22,8 @@ module core { interface [ CustomMarkFunction, - GenerateConstructor, HasIndexGetter, - HasNameGetter, - InterfaceUUID=08DAF7A4-4C32-4709-B72F-622721FF0FB8, - ImplementationUUID=A1CC9F5B-092D-4a04-96D9-D7718A8D6242 + HasNameGetter ] NamedNodeMap { Node getNamedItem(in DOMString name); diff --git a/WebCore/dom/Node.cpp b/WebCore/dom/Node.cpp index b48819a..2f0de43 100644 --- a/WebCore/dom/Node.cpp +++ b/WebCore/dom/Node.cpp @@ -42,6 +42,7 @@ #include "CString.h" #include "ChildNodeList.h" #include "ClassNodeList.h" +#include "ContextMenuController.h" #include "DOMImplementation.h" #include "Document.h" #include "DynamicNodeList.h" @@ -58,6 +59,7 @@ #include "InspectorTimelineAgent.h" #include "KeyboardEvent.h" #include "Logging.h" +#include "MappedAttribute.h" #include "MouseEvent.h" #include "MutationEvent.h" #include "NameNodeList.h" @@ -152,7 +154,7 @@ void Node::dumpStatistics() size_t attrMaps = 0; size_t mappedAttrMaps = 0; - for (HashSet<Node*>::const_iterator it = liveNodeSet.begin(); it != liveNodeSet.end(); ++it) { + for (HashSet<Node*>::iterator it = liveNodeSet.begin(); it != liveNodeSet.end(); ++it) { Node* node = *it; if (node->hasRareData()) @@ -258,7 +260,7 @@ void Node::dumpStatistics() printf(" Number of XPathNS nodes: %zu\n", xpathNSNodes); printf("Element tag name distibution:\n"); - for (HashMap<String, size_t>::const_iterator it = perTagCount.begin(); it != perTagCount.end(); ++it) + for (HashMap<String, size_t>::iterator it = perTagCount.begin(); it != perTagCount.end(); ++it) printf(" Number of <%s> tags: %zu\n", it->first.utf8().data(), it->second); printf("Attribute Maps:\n"); @@ -429,6 +431,7 @@ Node::Node(Document* document, ConstructionType type) #if ENABLE(SVG) , m_areSVGAttributesValid(true) , m_synchronizingSVGAttributes(false) + , m_hasRareSVGData(false) #endif { if (m_document) @@ -527,6 +530,12 @@ void Node::setDocument(Document* document) updateDOMNodeDocument(this, m_document, document); #endif + if (hasRareData() && rareData()->nodeLists()) { + if (m_document) + m_document->removeNodeListCache(); + document->addNodeListCache(); + } + if (m_document) m_document->selfOnlyDeref(); @@ -682,7 +691,7 @@ void Node::normalize() // Merge text nodes. while (Node* nextSibling = node->nextSibling()) { - if (!nextSibling->isTextNode()) + if (nextSibling->nodeType() != TEXT_NODE) break; RefPtr<Text> nextText = static_cast<Text*>(nextSibling); @@ -850,7 +859,7 @@ bool Node::isFocusable() const ASSERT(!renderer()->needsLayout()); else // If the node is in a display:none tree it might say it needs style recalc but - // the whole document is atually up to date. + // the whole document is actually up to date. ASSERT(!document()->childNeedsStyleRecalc()); // FIXME: Even if we are not visible, we might have a child that is visible. @@ -918,7 +927,10 @@ void Node::notifyLocalNodeListsAttributeChanged() if (!data->nodeLists()) return; - data->nodeLists()->invalidateCachesThatDependOnAttributes(); + if (!isAttributeNode()) + data->nodeLists()->invalidateCachesThatDependOnAttributes(); + else + data->nodeLists()->invalidateCaches(); if (data->nodeLists()->isEmpty()) { data->clearNodeLists(); @@ -1041,34 +1053,27 @@ Node* Node::traversePreviousSiblingPostOrder(const Node* stayWithin) const return 0; } -void Node::checkSetPrefix(const AtomicString&, ExceptionCode& ec) +void Node::checkSetPrefix(const AtomicString& prefix, ExceptionCode& ec) { // Perform error checking as required by spec for setting Node.prefix. Used by // Element::setPrefix() and Attr::setPrefix() // FIXME: Implement support for INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character. - // NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. if (isReadOnlyNode()) { ec = NO_MODIFICATION_ALLOWED_ERR; return; } - // FIXME: Implement NAMESPACE_ERR: - Raised if the specified prefix is malformed - // We have to comment this out, since it's used for attributes and tag names, and we've only - // switched one over. - /* - // - if the namespaceURI of this node is null, - // - if the specified prefix is "xml" and the namespaceURI of this node is different from - // "http://www.w3.org/XML/1998/namespace", - // - if this node is an attribute and the specified prefix is "xmlns" and - // the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/", - // - or if this node is an attribute and the qualifiedName of this node is "xmlns" [Namespaces]. - if ((namespacePart(id()) == noNamespace && id() > ID_LAST_TAG) || - (_prefix == "xml" && String(document()->namespaceURI(id())) != "http://www.w3.org/XML/1998/namespace")) { + // FIXME: Raise NAMESPACE_ERR if prefix is malformed per the Namespaces in XML specification. + + const AtomicString& nodeNamespaceURI = namespaceURI(); + if ((nodeNamespaceURI.isEmpty() && !prefix.isEmpty()) + || (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI)) { ec = NAMESPACE_ERR; return; - }*/ + } + // Attribute-specific checks are in Attr::setPrefix(). } bool Node::canReplaceChild(Node* newChild, Node*) @@ -1472,7 +1477,7 @@ bool Node::canStartSelection() const Node* Node::shadowAncestorNode() { #if ENABLE(SVG) - // SVG elements living in a shadow tree only occour when <use> created them. + // SVG elements living in a shadow tree only occur when <use> created them. // For these cases we do NOT want to return the shadowParentNode() here // but the actual shadow tree element - as main difference to the HTML forms // shadow tree concept. (This function _could_ be made virtual - opinions?) @@ -1661,7 +1666,6 @@ PassRefPtr<Element> Node::querySelector(const String& selectors, ExceptionCode& // FIXME: we could also optimize for the the [id="foo"] case if (strictParsing && inDocument() && querySelectorList.hasOneSelector() && querySelectorList.first()->m_match == CSSSelector::Id) { - ASSERT(querySelectorList.first()->attribute() == idAttr); Element* element = document()->getElementById(querySelectorList.first()->m_value); if (element && (isDocumentNode() || element->isDescendantOf(this)) && selectorChecker.checkSelector(querySelectorList.first(), element)) return element; @@ -1788,7 +1792,7 @@ bool Node::isDefaultNamespace(const AtomicString& namespaceURIMaybeEmpty) const for (unsigned i = 0; i < attrs->length(); i++) { Attribute* attr = attrs->attributeItem(i); - if (attr->localName() == "xmlns") + if (attr->localName() == xmlnsAtom) return attr->value() == namespaceURI; } } @@ -1874,12 +1878,12 @@ String Node::lookupNamespaceURI(const String &prefix) const for (unsigned i = 0; i < attrs->length(); i++) { Attribute *attr = attrs->attributeItem(i); - if (attr->prefix() == "xmlns" && attr->localName() == prefix) { + if (attr->prefix() == xmlnsAtom && attr->localName() == prefix) { if (!attr->value().isEmpty()) return attr->value(); return String(); - } else if (attr->localName() == "xmlns" && prefix.isNull()) { + } else if (attr->localName() == xmlnsAtom && prefix.isNull()) { if (!attr->value().isEmpty()) return attr->value(); @@ -1929,7 +1933,7 @@ String Node::lookupNamespacePrefix(const AtomicString &_namespaceURI, const Elem for (unsigned i = 0; i < attrs->length(); i++) { Attribute *attr = attrs->attributeItem(i); - if (attr->prefix() == "xmlns" && + if (attr->prefix() == xmlnsAtom && attr->value() == _namespaceURI && originalElement->lookupNamespaceURI(attr->localName()) == _namespaceURI) return attr->localName(); @@ -2332,6 +2336,7 @@ ContainerNode* Node::eventParentNode() return static_cast<ContainerNode*>(parent); } +<<<<<<< HEAD #ifdef ANDROID_INSTRUMENT static size_t nodeSize = 0; @@ -2364,6 +2369,20 @@ size_t Node::reportDOMNodesSize() return nodeSize; } #endif +======= +Node* Node::enclosingLinkEventParentOrSelf() +{ + for (Node* node = this; node; node = node->eventParentNode()) { + // For imagemaps, the enclosing link node is the associated area element not the image itself. + // So we don't let images be the enclosingLinkNode, even though isLink sometimes returns true + // for them. + if (node->isLink() && !node->hasTagName(imgTag)) + return node; + } + + return 0; +} +>>>>>>> webkit.org at r54127 // -------- @@ -2394,51 +2413,170 @@ void Node::didMoveToNewOwnerDocument() setDidMoveToNewOwnerDocumentWasCalled(true); } -static inline void updateSVGElementInstancesAfterEventListenerChange(Node* referenceNode) +#if ENABLE(SVG) +static inline HashSet<SVGElementInstance*> instancesForSVGElement(Node* node) +{ + HashSet<SVGElementInstance*> instances; + + ASSERT(node); + if (!node->isSVGElement() || node->shadowTreeRootNode()) + return HashSet<SVGElementInstance*>(); + + SVGElement* element = static_cast<SVGElement*>(node); + if (!element->isStyled()) + return HashSet<SVGElementInstance*>(); + + SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(element); + ASSERT(!styledElement->instanceUpdatesBlocked()); + + return styledElement->instancesForElement(); +} +#endif + +static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) +{ + if (!targetNode->EventTarget::addEventListener(eventType, listener, useCapture)) + return false; + + if (Document* document = targetNode->document()) + document->addListenerTypeIfNeeded(eventType); + + return true; +} + +bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) { #if !ENABLE(SVG) - UNUSED_PARAM(referenceNode); + return tryAddEventListener(this, eventType, listener, useCapture); #else - ASSERT(referenceNode); - if (!referenceNode->isSVGElement()) - return; + if (!isSVGElement()) + return tryAddEventListener(this, eventType, listener, useCapture); - // Elements living inside a <use> shadow tree, never cause any updates! - if (referenceNode->shadowTreeRootNode()) - return; + HashSet<SVGElementInstance*> instances = instancesForSVGElement(this); + if (instances.isEmpty()) + return tryAddEventListener(this, eventType, listener, useCapture); - // We're possibly (a child of) an element that is referenced by a <use> client - // If an event listeners changes on a referenced element, update all instances. - for (Node* node = referenceNode; node; node = node->parentNode()) { - if (!node->hasID() || !node->isSVGElement()) - continue; + RefPtr<EventListener> listenerForRegularTree = listener; + RefPtr<EventListener> listenerForShadowTree = listenerForRegularTree; - SVGElementInstance::invalidateAllInstancesOfElement(static_cast<SVGElement*>(node)); - break; + // Add event listener to regular DOM element + if (!tryAddEventListener(this, eventType, listenerForRegularTree.release(), useCapture)) + return false; + + // Add event listener to all shadow tree DOM element instances + const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); + for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { + ASSERT((*it)->shadowTreeElement()); + ASSERT((*it)->correspondingElement() == this); + + RefPtr<EventListener> listenerForCurrentShadowTreeElement = listenerForShadowTree; + bool result = tryAddEventListener((*it)->shadowTreeElement(), eventType, listenerForCurrentShadowTreeElement.release(), useCapture); + ASSERT_UNUSED(result, result); } + + return true; #endif } -bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture) +static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture) { - if (!EventTarget::addEventListener(eventType, listener, useCapture)) + if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCapture)) return false; +<<<<<<< HEAD if (Document* document = this->document()) document->addListenerTypeIfNeeded(eventType); updateSVGElementInstancesAfterEventListenerChange(this); +======= + // FIXME: Notify Document that the listener has vanished. We need to keep track of a number of + // listeners for each type, not just a bool - see https://bugs.webkit.org/show_bug.cgi?id=33861 + +>>>>>>> webkit.org at r54127 return true; } bool Node::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) { - if (!EventTarget::removeEventListener(eventType, listener, useCapture)) +#if !ENABLE(SVG) + return tryRemoveEventListener(this, eventType, listener, useCapture); +#else + if (!isSVGElement()) + return tryRemoveEventListener(this, eventType, listener, useCapture); + + HashSet<SVGElementInstance*> instances = instancesForSVGElement(this); + if (instances.isEmpty()) + return tryRemoveEventListener(this, eventType, listener, useCapture); + + // EventTarget::removeEventListener creates a PassRefPtr around the given EventListener + // object when creating a temporary RegisteredEventListener object used to look up the + // event listener in a cache. If we want to be able to call removeEventListener() multiple + // times on different nodes, we have to delay its immediate destruction, which would happen + // after the first call below. + RefPtr<EventListener> protector(listener); + + // Remove event listener from regular DOM element + if (!tryRemoveEventListener(this, eventType, listener, useCapture)) return false; +<<<<<<< HEAD updateSVGElementInstancesAfterEventListenerChange(this); +======= + // Remove event listener from all shadow tree DOM element instances + const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); + for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { + ASSERT((*it)->correspondingElement() == this); + + SVGElement* shadowTreeElement = (*it)->shadowTreeElement(); + ASSERT(shadowTreeElement); + + if (tryRemoveEventListener(shadowTreeElement, eventType, listener, useCapture)) + continue; + + // This case can only be hit for event listeners created from markup + ASSERT(listener->wasCreatedFromMarkup()); + + // If the event listener 'listener' has been created from markup and has been fired before + // then JSLazyEventListener::parseCode() has been called and m_jsFunction of that listener + // has been created (read: it's not 0 anymore). During shadow tree creation, the event + // listener DOM attribute has been cloned, and another event listener has been setup in + // the shadow tree. If that event listener has not been used yet, m_jsFunction is still 0, + // and tryRemoveEventListener() above will fail. Work around that very seldom problem. + EventTargetData* data = shadowTreeElement->eventTargetData(); + ASSERT(data); + + EventListenerMap::iterator result = data->eventListenerMap.find(eventType); + ASSERT(result != data->eventListenerMap.end()); + + EventListenerVector* entry = result->second; + ASSERT(entry); + + unsigned int index = 0; + bool foundListener = false; + + EventListenerVector::iterator end = entry->end(); + for (EventListenerVector::iterator it = entry->begin(); it != end; ++it) { + if (!(*it).listener->wasCreatedFromMarkup()) { + ++index; + continue; + } + + foundListener = true; + entry->remove(index); + break; + } + + ASSERT(foundListener); + + if (entry->isEmpty()) { + delete entry; + data->eventListenerMap.remove(result); + } + } +>>>>>>> webkit.org at r54127 return true; +#endif } EventTargetData* Node::eventTargetData() @@ -2907,6 +3045,23 @@ void Node::defaultEventHandler(Event* event) if (event->isTextEvent()) if (Frame* frame = document()->frame()) frame->eventHandler()->defaultTextInputEventHandler(static_cast<TextEvent*>(event)); +#if ENABLE(PAN_SCROLLING) + } else if (eventType == eventNames().mousedownEvent) { + MouseEvent* mouseEvent = static_cast<MouseEvent*>(event); + if (mouseEvent->button() == MiddleButton) { + if (enclosingLinkEventParentOrSelf()) + return; + + RenderObject* renderer = this->renderer(); + while (renderer && (!renderer->isBox() || !toRenderBox(renderer)->canBeScrolledAndHasScrollableArea())) + renderer = renderer->parent(); + + if (renderer) { + if (Frame* frame = document()->frame()) + frame->eventHandler()->startPanScrolling(renderer); + } + } +#endif } } diff --git a/WebCore/dom/Node.h b/WebCore/dom/Node.h index ebf275a..495bca9 100644 --- a/WebCore/dom/Node.h +++ b/WebCore/dom/Node.h @@ -27,14 +27,9 @@ #include "EventTarget.h" #include "KURLHash.h" -#include "PlatformString.h" -#include "RegisteredEventListener.h" +#include "ScriptWrappable.h" #include "TreeShared.h" -#include "FloatPoint.h" -#include <wtf/Assertions.h> #include <wtf/ListHashSet.h> -#include <wtf/OwnPtr.h> -#include <wtf/PassRefPtr.h> namespace WebCore { @@ -46,6 +41,7 @@ class DynamicNodeList; class Element; class Event; class EventListener; +class FloatPoint; class Frame; class IntRect; class KeyboardEvent; @@ -81,7 +77,7 @@ const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // this class implements nodes, which can have a parent but no children: -class Node : public EventTarget, public TreeShared<Node> { +class Node : public EventTarget, public TreeShared<Node>, public ScriptWrappable { friend class Document; public: enum NodeType { @@ -206,6 +202,9 @@ public: // The node's parent for the purpose of event capture and bubbling. virtual ContainerNode* eventParentNode(); + // Returns the enclosing event parent node (or self) that, when clicked, would trigger a navigation. + Node* enclosingLinkEventParentOrSelf(); + // Node ancestors when concerned about event flow void eventAncestors(Vector<RefPtr<ContainerNode> > &ancestors); @@ -252,7 +251,7 @@ public: virtual ContainerNode* addChild(PassRefPtr<Node>); // Called by the parser when this element's close tag is reached, - // signalling that all child tags have been parsed and added. + // signaling that all child tags have been parsed and added. // This is needed for <applet> and <object> elements, which can't lay themselves out // until they know all of their nested <param>s. [Radar 3603191, 4040848]. // Also used for script elements and some SVG elements for similar purposes, @@ -584,7 +583,10 @@ protected: void setTabIndexExplicitly(short); bool hasRareData() const { return m_hasRareData; } - +#if ENABLE(SVG) + bool hasRareSVGData() const { return m_hasRareSVGData; } +#endif + NodeRareData* rareData() const; NodeRareData* ensureRareData(); @@ -648,9 +650,10 @@ protected: #if ENABLE(SVG) mutable bool m_areSVGAttributesValid : 1; // Element mutable bool m_synchronizingSVGAttributes : 1; // SVGElement + bool m_hasRareSVGData : 1; // SVGElement #endif - // 11 bits remaining + // 10 bits remaining }; // Used in Node::addSubresourceAttributeURLs() and in addSubresourceStyleURLs() diff --git a/WebCore/dom/Node.idl b/WebCore/dom/Node.idl index 45ea132..c6cd4b9 100644 --- a/WebCore/dom/Node.idl +++ b/WebCore/dom/Node.idl @@ -25,12 +25,9 @@ module core { CustomPushEventHandlerScope, CustomToJS, EventTarget, - GenerateConstructor, GenerateNativeConverter, InlineGetOwnPropertySlot, - Polymorphic, - InterfaceUUID=84BA0D7A-7E3E-4a7b-B6FB-7653E8FB54ED, - ImplementationUUID=81B47FDB-94B0-40fd-8E0C-FB2A6E53CC04 + Polymorphic ] Node #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C : Object, EventTarget @@ -135,7 +132,6 @@ module core { #endif /* defined(LANGUAGE_OBJECTIVE_C) */ #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM [Custom] void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture); @@ -145,7 +141,6 @@ module core { boolean dispatchEvent(in Event event) raises(EventException); #endif -#endif }; } diff --git a/WebCore/dom/NodeFilter.idl b/WebCore/dom/NodeFilter.idl index 3cc5e86..d721f80 100644 --- a/WebCore/dom/NodeFilter.idl +++ b/WebCore/dom/NodeFilter.idl @@ -21,7 +21,7 @@ module traversal { // Introduced in DOM Level 2: - interface [GenerateConstructor, CustomMarkFunction, CustomNativeConverter, ObjCProtocol] NodeFilter { + interface [CustomMarkFunction, CustomNativeConverter, ObjCProtocol] NodeFilter { // Constants returned by acceptNode const short FILTER_ACCEPT = 1; diff --git a/WebCore/dom/NodeIterator.idl b/WebCore/dom/NodeIterator.idl index 8805d07..e1818a1 100644 --- a/WebCore/dom/NodeIterator.idl +++ b/WebCore/dom/NodeIterator.idl @@ -22,8 +22,7 @@ module traversal { // Introduced in DOM Level 2: interface [ - CustomMarkFunction, - GenerateConstructor + CustomMarkFunction ] NodeIterator { readonly attribute Node root; readonly attribute unsigned long whatToShow; diff --git a/WebCore/dom/NodeList.idl b/WebCore/dom/NodeList.idl index cf21cc7..edb2dc7 100644 --- a/WebCore/dom/NodeList.idl +++ b/WebCore/dom/NodeList.idl @@ -21,12 +21,9 @@ module core { interface [ - GenerateConstructor, HasIndexGetter, HasNameGetter, - CustomCall, - InterfaceUUID=F9A9F6A9-385C-414e-A6F6-E2E0CF574130, - ImplementationUUID=BBB49E8B-DB1D-4c4a-B970-D300FB4609FA + CustomCall ] NodeList { Node item(in [IsIndex] unsigned long index); diff --git a/WebCore/dom/Notation.idl b/WebCore/dom/Notation.idl index a16fde6..96351d2 100644 --- a/WebCore/dom/Notation.idl +++ b/WebCore/dom/Notation.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=6580C703-F5FF-40a7-ACF2-AB80EBC83CA1, - ImplementationUUID=A52869F7-A3CE-4f4c-8C27-E369C4ED9FF9 - ] Notation : Node { + interface Notation : Node { readonly attribute [ConvertNullStringTo=Null] DOMString publicId; readonly attribute [ConvertNullStringTo=Null] DOMString systemId; }; diff --git a/WebCore/dom/OverflowEvent.idl b/WebCore/dom/OverflowEvent.idl index 4a1bed5..0b4f5c6 100644 --- a/WebCore/dom/OverflowEvent.idl +++ b/WebCore/dom/OverflowEvent.idl @@ -24,9 +24,7 @@ */ module events { - interface [ - GenerateConstructor - ] OverflowEvent : Event { + interface OverflowEvent : Event { const unsigned short HORIZONTAL = 0; const unsigned short VERTICAL = 1; const unsigned short BOTH = 2; diff --git a/WebCore/dom/PageTransitionEvent.idl b/WebCore/dom/PageTransitionEvent.idl index a09f94b..8d70f67 100644 --- a/WebCore/dom/PageTransitionEvent.idl +++ b/WebCore/dom/PageTransitionEvent.idl @@ -25,9 +25,7 @@ module events { - interface [ - GenerateConstructor - ] PageTransitionEvent : Event { + interface PageTransitionEvent : Event { readonly attribute boolean persisted; diff --git a/WebCore/dom/PopStateEvent.idl b/WebCore/dom/PopStateEvent.idl index c6775ec..f9c9a71 100644 --- a/WebCore/dom/PopStateEvent.idl +++ b/WebCore/dom/PopStateEvent.idl @@ -26,15 +26,13 @@ module events { - interface [ - GenerateConstructor - ] PopStateEvent : Event { + interface PopStateEvent : Event { [Custom] void initPopStateEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in any stateArg); - readonly attribute [CustomGetter] any state; + readonly attribute [V8CustomGetter] any state; }; } diff --git a/WebCore/dom/Position.cpp b/WebCore/dom/Position.cpp index 0ff8262..0126835 100644 --- a/WebCore/dom/Position.cpp +++ b/WebCore/dom/Position.cpp @@ -498,7 +498,7 @@ Position Position::upstream(EditingBoundaryCrossingRule rule) const lastNode = currentNode; } - // If we've moved to a position that is visually disinct, return the last saved position. There + // If we've moved to a position that is visually distinct, return the last saved position. There // is code below that terminates early if we're *about* to move to a visually distinct position. if (endsOfNodeAreVisuallyDistinctPositions(currentNode) && currentNode != boundary) return lastVisible; @@ -744,13 +744,17 @@ bool Position::isCandidate() const if (isTableElement(node()) || editingIgnoresContent(node())) return (atFirstEditingPositionForNode() || atLastEditingPositionForNode()) && !nodeIsUserSelectNone(node()->parent()); - if (!m_anchorNode->hasTagName(htmlTag) && renderer->isBlockFlow()) { + if (m_anchorNode->hasTagName(htmlTag)) + return false; + + if (renderer->isBlockFlow()) { if (toRenderBlock(renderer)->height() || m_anchorNode->hasTagName(bodyTag)) { if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer)) return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(node()); return m_anchorNode->isContentEditable() && !Position::nodeIsUserSelectNone(node()) && atEditingBoundary(); } - } + } else + return m_anchorNode->isContentEditable() && !Position::nodeIsUserSelectNone(node()) && atEditingBoundary(); return false; } @@ -995,7 +999,7 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi RenderObject* renderer = node()->renderer(); if (!renderer->isText()) { - if (renderer->isBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { + if (!renderer->isRenderButton() && renderer->isBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) { bool lastPosition = caretOffset == lastOffsetInNode(node()); Node* startNode = lastPosition ? node()->childNode(caretOffset - 1) : node()->childNode(caretOffset); while (startNode && (!startNode->renderer() || (startNode->isTextNode() && toRenderText(startNode->renderer())->isAllCollapsibleWhitespace()))) @@ -1009,9 +1013,16 @@ void Position::getInlineBoxAndOffset(EAffinity affinity, TextDirection primaryDi return; } } - inlineBox = renderer->isBox() ? toRenderBox(renderer)->inlineBoxWrapper() : 0; - if (!inlineBox || (caretOffset > inlineBox->caretMinOffset() && caretOffset < inlineBox->caretMaxOffset())) + inlineBox = 0; + if (renderer->isBox()) { + inlineBox = toRenderBox(renderer)->inlineBoxWrapper(); + if (!inlineBox || (caretOffset > inlineBox->caretMinOffset() && caretOffset < inlineBox->caretMaxOffset())) + return; + } else if (node()->isContentEditable()) { + Position pos = positionInParentBeforeNode(node()).upstream(); + pos.getInlineBoxAndOffset(DOWNSTREAM, primaryDirection, inlineBox, caretOffset); return; + } } else { RenderText* textRenderer = toRenderText(renderer); @@ -1165,8 +1176,10 @@ void Position::formatForDebugger(char* buffer, unsigned length) const void Position::showTreeForThis() const { - if (node()) + if (node()) { node()->showTreeForThis(); + fprintf(stderr, "offset: %d\n", m_offset); + } } #endif diff --git a/WebCore/dom/Position.h b/WebCore/dom/Position.h index 1e0304e..fc5849f 100644 --- a/WebCore/dom/Position.h +++ b/WebCore/dom/Position.h @@ -135,7 +135,7 @@ public: bool atFirstEditingPositionForNode() const; bool atLastEditingPositionForNode() const; - // Retuns true if the visually equivalent positions around have different editability + // Returns true if the visually equivalent positions around have different editability bool atEditingBoundary() const; bool atStartOfTree() const; diff --git a/WebCore/dom/ProcessingInstruction.cpp b/WebCore/dom/ProcessingInstruction.cpp index 8adf9aa..d4636b4 100644 --- a/WebCore/dom/ProcessingInstruction.cpp +++ b/WebCore/dom/ProcessingInstruction.cpp @@ -139,7 +139,8 @@ void ProcessingInstruction::checkStyleSheet() // We need to make a synthetic XSLStyleSheet that is embedded. It needs to be able // to kick off import/include loads that can hang off some parent sheet. if (m_isXSL) { - m_sheet = XSLStyleSheet::createEmbedded(this, m_localHref); + KURL baseURL = KURL(ParsedURLString, m_localHref); + m_sheet = XSLStyleSheet::createEmbedded(this, m_localHref, baseURL); m_loading = false; } #endif @@ -197,24 +198,27 @@ bool ProcessingInstruction::sheetLoaded() return false; } -void ProcessingInstruction::setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet* sheet) +void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet) { #if ENABLE(XSLT) ASSERT(!m_isXSL); #endif - RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, url, charset); + RefPtr<CSSStyleSheet> newSheet = CSSStyleSheet::create(this, href, baseURL, charset); m_sheet = newSheet; - parseStyleSheet(sheet->sheetText()); + // We don't need the cross-origin security check here because we are + // getting the sheet text in "strict" mode. This enforces a valid CSS MIME + // type. + parseStyleSheet(sheet->sheetText(true)); newSheet->setTitle(m_title); newSheet->setMedia(MediaList::create(newSheet.get(), m_media)); newSheet->setDisabled(m_alternate); } #if ENABLE(XSLT) -void ProcessingInstruction::setXSLStyleSheet(const String& url, const String& sheet) +void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet) { ASSERT(m_isXSL); - m_sheet = XSLStyleSheet::create(this, url); + m_sheet = XSLStyleSheet::create(this, href, baseURL); parseStyleSheet(sheet); } #endif diff --git a/WebCore/dom/ProcessingInstruction.h b/WebCore/dom/ProcessingInstruction.h index 61af9cf..31f680d 100644 --- a/WebCore/dom/ProcessingInstruction.h +++ b/WebCore/dom/ProcessingInstruction.h @@ -76,9 +76,9 @@ private: virtual void removedFromDocument(); void checkStyleSheet(); - virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*); + virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*); #if ENABLE(XSLT) - virtual void setXSLStyleSheet(const String& url, const String& sheet); + virtual void setXSLStyleSheet(const String& href, const KURL& baseURL, const String& sheet); #endif bool isLoading() const; diff --git a/WebCore/dom/ProcessingInstruction.idl b/WebCore/dom/ProcessingInstruction.idl index 578b22e..efcc9c1 100644 --- a/WebCore/dom/ProcessingInstruction.idl +++ b/WebCore/dom/ProcessingInstruction.idl @@ -20,11 +20,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=5947E8F8-B5CB-4a51-B883-B91F344F1E13, - ImplementationUUID=7EEC0376-3D76-4643-A964-97B8AC1FB6D3 - ] ProcessingInstruction : Node { + interface ProcessingInstruction : Node { // DOM Level 1 @@ -32,11 +28,8 @@ module core { attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString data setter raises(DOMException); -#if !defined(LANGUAGE_COM) || !LANGUAGE_COM // interface LinkStyle from DOM Level 2 Style Sheets readonly attribute StyleSheet sheet; -#endif - }; } diff --git a/WebCore/dom/ProgressEvent.idl b/WebCore/dom/ProgressEvent.idl index 2db72af..afdf3a2 100644 --- a/WebCore/dom/ProgressEvent.idl +++ b/WebCore/dom/ProgressEvent.idl @@ -25,9 +25,7 @@ module events { - interface [ - GenerateConstructor - ] ProgressEvent : Event { + interface ProgressEvent : Event { readonly attribute boolean lengthComputable; readonly attribute unsigned long loaded; readonly attribute unsigned long total; diff --git a/WebCore/dom/QualifiedName.h b/WebCore/dom/QualifiedName.h index a7e1fcb..7581ba1 100644 --- a/WebCore/dom/QualifiedName.h +++ b/WebCore/dom/QualifiedName.h @@ -22,7 +22,7 @@ #define QualifiedName_h #include "AtomicString.h" -#include <wtf/HashFunctions.h> +#include <wtf/HashTraits.h> namespace WebCore { diff --git a/WebCore/dom/Range.cpp b/WebCore/dom/Range.cpp index 84a46c2..52d1785 100644 --- a/WebCore/dom/Range.cpp +++ b/WebCore/dom/Range.cpp @@ -666,7 +666,7 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception } // Complex case: Start and end containers are different. - // There are three possiblities here: + // There are three possibilities here: // 1. Start container == commonRoot (End container must be a descendant) // 2. End container == commonRoot (Start container must be a descendant) // 3. Neither is commonRoot, they are both descendants @@ -1417,7 +1417,7 @@ void Range::surroundContents(PassRefPtr<Node> passNewParent, ExceptionCode& ec) // although this will fail below for another reason). if (parentOfNewParent->isCharacterDataNode()) parentOfNewParent = parentOfNewParent->parentNode(); - if (!parentOfNewParent->childTypeAllowed(newParent->nodeType())) { + if (!parentOfNewParent || !parentOfNewParent->childTypeAllowed(newParent->nodeType())) { ec = HIERARCHY_REQUEST_ERR; return; } @@ -1930,3 +1930,17 @@ void Range::getBorderAndTextQuads(Vector<FloatQuad>& quads) const } } // namespace WebCore + +#ifndef NDEBUG + +void showTree(const WebCore::Range* range) +{ + if (range && range->boundaryPointsValid()) { + WebCore::Position start = range->startPosition(); + WebCore::Position end = range->endPosition(); + start.node()->showTreeAndMark(start.node(), "S", end.node(), "E"); + fprintf(stderr, "start offset: %d, end offset: %d\n", start.deprecatedEditingOffset(), end.deprecatedEditingOffset()); + } +} + +#endif diff --git a/WebCore/dom/Range.h b/WebCore/dom/Range.h index 583f9f0..fd0f66a 100644 --- a/WebCore/dom/Range.h +++ b/WebCore/dom/Range.h @@ -158,4 +158,9 @@ inline bool operator!=(const Range& a, const Range& b) { return !(a == b); } } // namespace +#ifndef NDEBUG +// Outside the WebCore namespace for ease of invocation from gdb. +void showTree(const WebCore::Range*); +#endif + #endif diff --git a/WebCore/dom/Range.idl b/WebCore/dom/Range.idl index 9024e09..cd01d61 100644 --- a/WebCore/dom/Range.idl +++ b/WebCore/dom/Range.idl @@ -21,7 +21,7 @@ module ranges { // Introduced in DOM Level 2: - interface [GenerateConstructor] Range { + interface Range { readonly attribute Node startContainer getter raises(DOMException); diff --git a/WebCore/dom/RangeException.idl b/WebCore/dom/RangeException.idl index d2cf385..100912d 100644 --- a/WebCore/dom/RangeException.idl +++ b/WebCore/dom/RangeException.idl @@ -19,9 +19,7 @@ module ranges { - interface [ - GenerateConstructor - ] RangeException { + interface RangeException { readonly attribute unsigned short code; readonly attribute DOMString name; diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp index 83ed2bb..9a80e16 100644 --- a/WebCore/dom/ScriptElement.cpp +++ b/WebCore/dom/ScriptElement.cpp @@ -177,7 +177,7 @@ void ScriptElementData::evaluateScript(const ScriptSourceCode& sourceCode) return; if (Frame* frame = m_element->document()->frame()) { - if (!frame->script()->isEnabled()) + if (!frame->script()->canExecuteScripts()) return; m_evaluated = true; diff --git a/WebCore/dom/ScriptExecutionContext.cpp b/WebCore/dom/ScriptExecutionContext.cpp index bc71084..c2fe120 100644 --- a/WebCore/dom/ScriptExecutionContext.cpp +++ b/WebCore/dom/ScriptExecutionContext.cpp @@ -28,7 +28,9 @@ #include "ScriptExecutionContext.h" #include "ActiveDOMObject.h" -#include "Document.h" +#include "Database.h" +#include "DatabaseTask.h" +#include "DatabaseThread.h" #include "MessagePort.h" #include "SecurityOrigin.h" #include "WorkerContext.h" @@ -56,6 +58,9 @@ public: }; ScriptExecutionContext::ScriptExecutionContext() +#if ENABLE(DATABASE) + : m_hasOpenDatabases(false) +#endif { } @@ -72,8 +77,69 @@ ScriptExecutionContext::~ScriptExecutionContext() ASSERT((*iter)->scriptExecutionContext() == this); (*iter)->contextDestroyed(); } +#if ENABLE(DATABASE) + if (m_databaseThread) { + ASSERT(m_databaseThread->terminationRequested()); + m_databaseThread = 0; + } +#endif +} + +#if ENABLE(DATABASE) + +DatabaseThread* ScriptExecutionContext::databaseThread() +{ + if (!m_databaseThread && !m_hasOpenDatabases) { + // Create the database thread on first request - but not if at least one database was already opened, + // because in that case we already had a database thread and terminated it and should not create another. + m_databaseThread = DatabaseThread::create(); + if (!m_databaseThread->start()) + m_databaseThread = 0; + } + + return m_databaseThread.get(); +} + +void ScriptExecutionContext::addOpenDatabase(Database* database) +{ + ASSERT(isContextThread()); + if (!m_openDatabaseSet) + m_openDatabaseSet.set(new DatabaseSet()); + + ASSERT(!m_openDatabaseSet->contains(database)); + m_openDatabaseSet->add(database); +} + +void ScriptExecutionContext::removeOpenDatabase(Database* database) +{ + ASSERT(isContextThread()); + ASSERT(m_openDatabaseSet && m_openDatabaseSet->contains(database)); + if (!m_openDatabaseSet) + return; + m_openDatabaseSet->remove(database); +} + +void ScriptExecutionContext::stopDatabases(DatabaseTaskSynchronizer* cleanupSync) +{ + ASSERT(isContextThread()); + if (m_openDatabaseSet) { + DatabaseSet::iterator i = m_openDatabaseSet->begin(); + DatabaseSet::iterator end = m_openDatabaseSet->end(); + for (; i != end; ++i) { + (*i)->stop(); + if (m_databaseThread) + m_databaseThread->unscheduleDatabaseTasks(*i); + } + } + + if (m_databaseThread) + m_databaseThread->requestTermination(cleanupSync); + else if (cleanupSync) + cleanupSync->taskCompleted(); } +#endif + void ScriptExecutionContext::processMessagePortMessagesSoon() { postTask(ProcessMessagesSoonTask::create()); diff --git a/WebCore/dom/ScriptExecutionContext.h b/WebCore/dom/ScriptExecutionContext.h index cf332c3..709bc69 100644 --- a/WebCore/dom/ScriptExecutionContext.h +++ b/WebCore/dom/ScriptExecutionContext.h @@ -33,11 +33,17 @@ #include <wtf/HashSet.h> #include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> #include <wtf/Threading.h> namespace WebCore { class ActiveDOMObject; +#if ENABLE(DATABASE) + class Database; + class DatabaseTaskSynchronizer; + class DatabaseThread; +#endif class DOMTimer; class MessagePort; class SecurityOrigin; @@ -59,6 +65,19 @@ namespace WebCore { virtual bool isDocument() const { return false; } virtual bool isWorkerContext() const { return false; } +#if ENABLE(DATABASE) + virtual bool isDatabaseReadOnly() const = 0; + virtual void databaseExceededQuota(const String& name) = 0; + DatabaseThread* databaseThread(); + void setHasOpenDatabases() { m_hasOpenDatabases = true; } + bool hasOpenDatabases() const { return m_hasOpenDatabases; } + void addOpenDatabase(Database*); + void removeOpenDatabase(Database*); + // When the database cleanup is done, cleanupSync will be signalled. + void stopDatabases(DatabaseTaskSynchronizer*); +#endif + virtual bool isContextThread() const = 0; + const KURL& url() const { return virtualURL(); } KURL completeURL(const String& url) const { return virtualCompleteURL(url); } @@ -97,6 +116,8 @@ namespace WebCore { public: virtual ~Task(); virtual void performTask(ScriptExecutionContext*) = 0; + // Certain tasks get marked specially so that they aren't discarded, and are executed, when the context is shutting down its message queue. + virtual bool isCleanupTask() const { return false; } }; virtual void postTask(PassOwnPtr<Task>) = 0; // Executes the task on context's thread asynchronously. @@ -129,6 +150,13 @@ namespace WebCore { virtual void refScriptExecutionContext() = 0; virtual void derefScriptExecutionContext() = 0; + +#if ENABLE(DATABASE) + RefPtr<DatabaseThread> m_databaseThread; + bool m_hasOpenDatabases; // This never changes back to false, even after the database thread is closed. + typedef HashSet<Database* > DatabaseSet; + OwnPtr<DatabaseSet> m_openDatabaseSet; +#endif }; } // namespace WebCore diff --git a/WebCore/dom/SelectElement.cpp b/WebCore/dom/SelectElement.cpp index 3d2a549..866b6ca 100644 --- a/WebCore/dom/SelectElement.cpp +++ b/WebCore/dom/SelectElement.cpp @@ -22,6 +22,7 @@ #include "SelectElement.h" #include "CharacterNames.h" +#include "Chrome.h" #include "ChromeClient.h" #include "Element.h" #include "EventHandler.h" @@ -49,10 +50,10 @@ // Configure platform-specific behavior when focused pop-up receives arrow/space/return keystroke. // (PLATFORM(MAC) and PLATFORM(GTK) are always false in Chromium, hence the extra tests.) -#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && PLATFORM(DARWIN)) +#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) && PLATFORM(LINUX)) +#elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && OS(LINUX)) #define ARROW_KEYS_POP_MENU 0 #define SPACE_OR_RETURN_POP_MENU 1 #else @@ -221,28 +222,21 @@ void SelectElement::scrollToSelection(SelectElementData& data, Element* element) toRenderListBox(renderer)->selectionChanged(); } -void SelectElement::recalcStyle(SelectElementData& data, Element* element) +void SelectElement::setOptionsChangedOnRenderer(SelectElementData& data, Element* element) { - RenderObject* renderer = element->renderer(); - if (element->childNeedsStyleRecalc() && renderer) { + if (RenderObject* renderer = element->renderer()) { if (data.usesMenuList()) toRenderMenuList(renderer)->setOptionsChanged(true); else toRenderListBox(renderer)->setOptionsChanged(true); - } else if (data.shouldRecalcListItems()) - recalcListItems(data, element); + } } void SelectElement::setRecalcListItems(SelectElementData& data, Element* element) { data.setShouldRecalcListItems(true); data.setActiveSelectionAnchorIndex(-1); // Manual selection anchor is reset when manipulating the select programmatically. - if (RenderObject* renderer = element->renderer()) { - if (data.usesMenuList()) - toRenderMenuList(renderer)->setOptionsChanged(true); - else - toRenderListBox(renderer)->setOptionsChanged(true); - } + setOptionsChangedOnRenderer(data, element); element->setNeedsStyleRecalc(); } @@ -251,6 +245,8 @@ void SelectElement::recalcListItems(SelectElementData& data, const Element* elem Vector<Element*>& listItems = data.rawListItems(); listItems.clear(); + data.setShouldRecalcListItems(false); + OptionElement* foundSelected = 0; for (Node* currentNode = element->firstChild(); currentNode;) { if (!currentNode->isElementNode()) { @@ -296,8 +292,6 @@ void SelectElement::recalcListItems(SelectElementData& data, const Element* elem // <select>'s subtree at this point. currentNode = currentNode->traverseNextSibling(element); } - - data.setShouldRecalcListItems(false); } int SelectElement::selectedIndex(const SelectElementData& data, const Element* element) @@ -348,6 +342,8 @@ void SelectElement::setSelectedIndex(SelectElementData& data, Element* element, data.setUserDrivenChange(userDrivenChange); if (fireOnChangeNow) menuListOnChange(data, element); + if (RenderMenuList* menuList = toRenderMenuList(element->renderer())) + menuList->didSetSelectedIndex(); } if (Frame* frame = element->document()->frame()) @@ -444,7 +440,7 @@ void SelectElement::restoreFormControlState(SelectElementData& data, Element* el optionElement->setSelectedState(state[i] == 'X'); } - element->setNeedsStyleRecalc(); + setOptionsChangedOnRenderer(data, element); } void SelectElement::parseMultipleAttribute(SelectElementData& data, Element* element, MappedAttribute* attribute) @@ -518,6 +514,7 @@ void SelectElement::reset(SelectElementData& data, Element* element) if (!selectedOption && firstOption && data.usesMenuList()) firstOption->setSelectedState(true); + setOptionsChangedOnRenderer(data, element); element->setNeedsStyleRecalc(); } @@ -680,7 +677,7 @@ void SelectElement::listBoxDefaultEventHandler(SelectElementData& data, Element* data.setActiveSelectionState(true); bool multiSelectKeyPressed = false; -#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && PLATFORM(DARWIN)) +#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN)) multiSelectKeyPressed = mouseEvent->metaKey(); #else multiSelectKeyPressed = mouseEvent->ctrlKey(); @@ -892,6 +889,8 @@ void SelectElement::typeAheadFind(SelectElementData& data, Element* element, Key setSelectedIndex(data, element, listToOptionIndex(data, element, index)); if (!data.usesMenuList()) listBoxOnChange(data, element); + + setOptionsChangedOnRenderer(data, element); element->setNeedsStyleRecalc(); return; } @@ -954,7 +953,7 @@ SelectElementData::SelectElementData() void SelectElementData::checkListItems(const Element* element) const { -#ifndef NDEBUG +#if !ASSERT_DISABLED const Vector<Element*>& items = m_listItems; SelectElement::recalcListItems(*const_cast<SelectElementData*>(this), element, false); ASSERT(items == m_listItems); diff --git a/WebCore/dom/SelectElement.h b/WebCore/dom/SelectElement.h index 4cc76a0..6891c22 100644 --- a/WebCore/dom/SelectElement.h +++ b/WebCore/dom/SelectElement.h @@ -75,7 +75,6 @@ protected: static void listBoxOnChange(SelectElementData&, Element*); static void menuListOnChange(SelectElementData&, Element*); static void scrollToSelection(SelectElementData&, Element*); - static void recalcStyle(SelectElementData&, Element*); static void setRecalcListItems(SelectElementData&, Element*); static void recalcListItems(SelectElementData&, const Element*, bool updateSelectedStates = true); static int selectedIndex(const SelectElementData&, const Element*); @@ -100,6 +99,7 @@ protected: private: static void menuListDefaultEventHandler(SelectElementData&, Element*, Event*, HTMLFormElement*); static void listBoxDefaultEventHandler(SelectElementData&, Element*, Event*, HTMLFormElement*); + static void setOptionsChangedOnRenderer(SelectElementData&, Element*); }; // HTML/WMLSelectElement hold this struct as member variable diff --git a/WebCore/dom/SelectorNodeList.cpp b/WebCore/dom/SelectorNodeList.cpp index 85b1238..bc97034 100644 --- a/WebCore/dom/SelectorNodeList.cpp +++ b/WebCore/dom/SelectorNodeList.cpp @@ -50,7 +50,6 @@ PassRefPtr<StaticNodeList> createSelectorNodeList(Node* rootNode, const CSSSelec CSSStyleSelector::SelectorChecker selectorChecker(document, strictParsing); if (strictParsing && rootNode->inDocument() && onlySelector && onlySelector->m_match == CSSSelector::Id && !document->containsMultipleElementsWithId(onlySelector->m_value)) { - ASSERT(querySelectorList.first()->attribute() == idAttr); Element* element = document->getElementById(onlySelector->m_value); if (element && (rootNode->isDocumentNode() || element->isDescendantOf(rootNode)) && selectorChecker.checkSelector(onlySelector, element)) nodes.append(element); diff --git a/WebCore/dom/StyleElement.cpp b/WebCore/dom/StyleElement.cpp index a21959d..f881179 100644 --- a/WebCore/dom/StyleElement.cpp +++ b/WebCore/dom/StyleElement.cpp @@ -103,7 +103,7 @@ void StyleElement::createSheet(Element* e, const String& text) if (screenEval.eval(mediaList.get()) || printEval.eval(mediaList.get())) { document->addPendingSheet(); setLoading(true); - m_sheet = CSSStyleSheet::create(e, String(), document->inputEncoding()); + m_sheet = CSSStyleSheet::create(e, String(), KURL(), document->inputEncoding()); m_sheet->parseString(text, !document->inCompatMode()); m_sheet->setMedia(mediaList.get()); m_sheet->setTitle(e->title()); diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp index 46ce137..3607963 100644 --- a/WebCore/dom/StyledElement.cpp +++ b/WebCore/dom/StyledElement.cpp @@ -234,7 +234,7 @@ void StyledElement::classAttributeChanged(const AtomicString& newClassString) void StyledElement::parseMappedAttribute(MappedAttribute *attr) { - if (attr->name() == idAttr) { + if (attr->name() == idAttributeName()) { // unique id setHasID(!attr->isNull()); if (namedAttrMap) { @@ -346,7 +346,7 @@ void StyledElement::addCSSColor(MappedAttribute* attr, int id, const String& c) // not something that fits the specs. // we're emulating IEs color parser here. It maps transparent to black, otherwise it tries to build a rgb value - // out of everyhting you put in. The algorithm is experimentally determined, but seems to work for all test cases I have. + // out of everything you put in. The algorithm is experimentally determined, but seems to work for all test cases I have. // the length of the color value is rounded up to the next // multiple of 3. each part of the rgb triple then gets one third diff --git a/WebCore/dom/Text.idl b/WebCore/dom/Text.idl index 1b0009d..116eab7 100644 --- a/WebCore/dom/Text.idl +++ b/WebCore/dom/Text.idl @@ -19,11 +19,7 @@ module core { - interface [ - GenerateConstructor, - InterfaceUUID=4EA6B89C-F8E5-462a-A807-519446123184, - ImplementationUUID=CB5D61CB-D30D-486e-9BD7-F42B7611C2E5 - ] Text : CharacterData { + interface Text : CharacterData { // DOM Level 1 diff --git a/WebCore/dom/TextEvent.idl b/WebCore/dom/TextEvent.idl index 779afd1..83b0e3b 100644 --- a/WebCore/dom/TextEvent.idl +++ b/WebCore/dom/TextEvent.idl @@ -26,9 +26,7 @@ module events { // Introduced in DOM Level 3: - interface [ - GenerateConstructor - ] TextEvent : UIEvent { + interface TextEvent : UIEvent { readonly attribute DOMString data; diff --git a/WebCore/dom/Touch.idl b/WebCore/dom/Touch.idl index 29bf18d..e684d1f 100644 --- a/WebCore/dom/Touch.idl +++ b/WebCore/dom/Touch.idl @@ -26,8 +26,12 @@ module events { interface [ +<<<<<<< HEAD Conditional=TOUCH_EVENTS, GenerateConstructor +======= + Conditional=TOUCH_EVENTS +>>>>>>> webkit.org at r54127 ] Touch { readonly attribute long clientX; readonly attribute long clientY; diff --git a/WebCore/dom/TouchEvent.cpp b/WebCore/dom/TouchEvent.cpp index 1fbba6c..f06efb6 100644 --- a/WebCore/dom/TouchEvent.cpp +++ b/WebCore/dom/TouchEvent.cpp @@ -40,10 +40,13 @@ TouchEvent::TouchEvent(TouchList* touches, TouchList* targetTouches, , m_touches(touches) , m_targetTouches(targetTouches) , m_changedTouches(changedTouches) +<<<<<<< HEAD #if PLATFORM(ANDROID) , m_longPressPrevented(false) , m_doubleTapPrevented(false) #endif +======= +>>>>>>> webkit.org at r54127 { } diff --git a/WebCore/dom/TouchEvent.h b/WebCore/dom/TouchEvent.h index abc1ee2..263dc36 100644 --- a/WebCore/dom/TouchEvent.h +++ b/WebCore/dom/TouchEvent.h @@ -60,6 +60,7 @@ public: TouchList* targetTouches() const { return m_targetTouches.get(); } TouchList* changedTouches() const { return m_changedTouches.get(); } +<<<<<<< HEAD #if PLATFORM(ANDROID) bool longPressPrevented() const { return m_longPressPrevented; } void preventLongPress() { m_longPressPrevented = true; } @@ -70,6 +71,8 @@ public: void setDoubleTapPrevented(bool prevented) { m_doubleTapPrevented = prevented; } #endif +======= +>>>>>>> webkit.org at r54127 private: TouchEvent() {} TouchEvent(TouchList* touches, TouchList* targetTouches, @@ -83,11 +86,14 @@ private: RefPtr<TouchList> m_touches; RefPtr<TouchList> m_targetTouches; RefPtr<TouchList> m_changedTouches; +<<<<<<< HEAD #if PLATFORM(ANDROID) bool m_longPressPrevented; bool m_doubleTapPrevented; #endif +======= +>>>>>>> webkit.org at r54127 }; } // namespace WebCore diff --git a/WebCore/dom/TouchEvent.idl b/WebCore/dom/TouchEvent.idl index 010c36f..b46d68f 100644 --- a/WebCore/dom/TouchEvent.idl +++ b/WebCore/dom/TouchEvent.idl @@ -26,8 +26,12 @@ module events { interface [ +<<<<<<< HEAD Conditional=TOUCH_EVENTS, GenerateConstructor +======= + Conditional=TOUCH_EVENTS +>>>>>>> webkit.org at r54127 ] TouchEvent : UIEvent { readonly attribute TouchList touches; readonly attribute TouchList targetTouches; diff --git a/WebCore/dom/TouchList.h b/WebCore/dom/TouchList.h index f5033c9..a578e4c 100644 --- a/WebCore/dom/TouchList.h +++ b/WebCore/dom/TouchList.h @@ -28,9 +28,15 @@ #if ENABLE(TOUCH_EVENTS) +<<<<<<< HEAD #include <wtf/RefCounted.h> #include <wtf/Vector.h> #include "Touch.h" +======= +#include "Touch.h" +#include <wtf/RefCounted.h> +#include <wtf/Vector.h> +>>>>>>> webkit.org at r54127 namespace WebCore { diff --git a/WebCore/dom/TouchList.idl b/WebCore/dom/TouchList.idl index c2aa58a..4bb9e81 100644 --- a/WebCore/dom/TouchList.idl +++ b/WebCore/dom/TouchList.idl @@ -27,7 +27,10 @@ module events { interface [ Conditional=TOUCH_EVENTS, +<<<<<<< HEAD GenerateConstructor, +======= +>>>>>>> webkit.org at r54127 HasIndexGetter ] TouchList { readonly attribute unsigned long length; diff --git a/WebCore/dom/TransformSourceLibxslt.cpp b/WebCore/dom/TransformSourceLibxslt.cpp index 33a85e8..e058438 100644 --- a/WebCore/dom/TransformSourceLibxslt.cpp +++ b/WebCore/dom/TransformSourceLibxslt.cpp @@ -24,6 +24,8 @@ */ #include "config.h" + +#if ENABLE(XSLT) #include "TransformSource.h" #include <libxml/tree.h> @@ -41,3 +43,5 @@ TransformSource::~TransformSource() } } + +#endif diff --git a/WebCore/dom/TreeWalker.idl b/WebCore/dom/TreeWalker.idl index 4ff969e..f591128 100644 --- a/WebCore/dom/TreeWalker.idl +++ b/WebCore/dom/TreeWalker.idl @@ -22,8 +22,7 @@ module traversal { // Introduced in DOM Level 2: interface [ - CustomMarkFunction, - GenerateConstructor + CustomMarkFunction ] TreeWalker { readonly attribute Node root; readonly attribute unsigned long whatToShow; diff --git a/WebCore/dom/UIEvent.idl b/WebCore/dom/UIEvent.idl index 36d0988..88dc108 100644 --- a/WebCore/dom/UIEvent.idl +++ b/WebCore/dom/UIEvent.idl @@ -20,9 +20,7 @@ module events { // Introduced in DOM Level 2: - interface [ - GenerateConstructor - ] UIEvent : Event { + interface UIEvent : Event { readonly attribute DOMWindow view; readonly attribute long detail; diff --git a/WebCore/dom/WebKitAnimationEvent.idl b/WebCore/dom/WebKitAnimationEvent.idl index f874995..86ffcc5 100644 --- a/WebCore/dom/WebKitAnimationEvent.idl +++ b/WebCore/dom/WebKitAnimationEvent.idl @@ -25,9 +25,7 @@ module events { - interface [ - GenerateConstructor - ] WebKitAnimationEvent : Event { + interface WebKitAnimationEvent : Event { readonly attribute DOMString animationName; readonly attribute double elapsedTime; void initWebKitAnimationEvent(in DOMString typeArg, diff --git a/WebCore/dom/WebKitTransitionEvent.idl b/WebCore/dom/WebKitTransitionEvent.idl index 8c645cb..fa619fa 100644 --- a/WebCore/dom/WebKitTransitionEvent.idl +++ b/WebCore/dom/WebKitTransitionEvent.idl @@ -25,9 +25,7 @@ module events { - interface [ - GenerateConstructor - ] WebKitTransitionEvent : Event { + interface WebKitTransitionEvent : Event { readonly attribute DOMString propertyName; readonly attribute double elapsedTime; void initWebKitTransitionEvent(in DOMString typeArg, diff --git a/WebCore/dom/WheelEvent.idl b/WebCore/dom/WheelEvent.idl index 4cba4ac..a8481a0 100644 --- a/WebCore/dom/WheelEvent.idl +++ b/WebCore/dom/WheelEvent.idl @@ -21,9 +21,7 @@ module events { // Based off of proposed IDL interface for WheelEvent: - interface [ - GenerateConstructor - ] WheelEvent : UIEvent { + interface WheelEvent : UIEvent { readonly attribute long screenX; readonly attribute long screenY; readonly attribute long clientX; diff --git a/WebCore/dom/XMLTokenizer.cpp b/WebCore/dom/XMLTokenizer.cpp index 56f8ff4..1c43322 100644 --- a/WebCore/dom/XMLTokenizer.cpp +++ b/WebCore/dom/XMLTokenizer.cpp @@ -134,8 +134,8 @@ void XMLTokenizer::write(const SegmentedString& s, bool /*appendData*/) doWrite(s.toString()); - // After parsing, go ahead and dispatch image beforeload/load events. - ImageLoader::dispatchPendingEvents(); + // After parsing, go ahead and dispatch image beforeload events. + ImageLoader::dispatchPendingBeforeLoadEvents(); } void XMLTokenizer::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber) diff --git a/WebCore/dom/XMLTokenizer.h b/WebCore/dom/XMLTokenizer.h index 2f9c113..92e2830 100644 --- a/WebCore/dom/XMLTokenizer.h +++ b/WebCore/dom/XMLTokenizer.h @@ -136,6 +136,7 @@ bool parseXMLDocumentFragment(const String&, DocumentFragment*, Element* parent #include "CachedResourceClient.h" #include "CachedResourceHandle.h" +#include "MappedAttributeEntry.h" #include "SegmentedString.h" #include "StringHash.h" #include "Tokenizer.h" @@ -143,7 +144,7 @@ bool parseXMLDocumentFragment(const String&, DocumentFragment*, Element* parent #include <wtf/OwnPtr.h> #if USE(QXMLSTREAM) -#include <QtXml/qxmlstream.h> +#include <qxmlstream.h> #else #include <libxml/tree.h> #include <libxml/xmlstring.h> @@ -181,7 +182,7 @@ namespace WebCore { class XMLTokenizer : public Tokenizer, public CachedResourceClient { public: XMLTokenizer(Document*, FrameView* = 0); - XMLTokenizer(DocumentFragment*, Element*); + XMLTokenizer(DocumentFragment*, Element*, FragmentScriptingPermission); ~XMLTokenizer(); enum ErrorType { warning, nonFatal, fatal }; @@ -247,7 +248,7 @@ public: void endDocument(); #endif private: - friend bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent); + friend bool parseXMLDocumentFragment(const String&, DocumentFragment*, Element*, FragmentScriptingPermission); void initializeParserContext(const char* chunk = 0); @@ -308,6 +309,7 @@ public: typedef HashMap<String, String> PrefixForNamespaceMap; PrefixForNamespaceMap m_prefixToNamespaceMap; SegmentedString m_pendingSrc; + FragmentScriptingPermission m_scriptingPermission; }; #if ENABLE(XSLT) @@ -315,7 +317,7 @@ void* xmlDocPtrForString(DocLoader*, const String& source, const String& url); #endif HashMap<String, String> parseAttributes(const String&, bool& attrsOK); -bool parseXMLDocumentFragment(const String&, DocumentFragment*, Element* parent = 0); +bool parseXMLDocumentFragment(const String&, DocumentFragment*, Element* parent = 0, FragmentScriptingPermission = FragmentScriptingAllowed); } // namespace WebCore diff --git a/WebCore/dom/XMLTokenizerLibxml2.cpp b/WebCore/dom/XMLTokenizerLibxml2.cpp index 42c8b9b..fcb3718 100644 --- a/WebCore/dom/XMLTokenizerLibxml2.cpp +++ b/WebCore/dom/XMLTokenizerLibxml2.cpp @@ -51,6 +51,7 @@ #include "ScriptValue.h" #include "TextResourceDecoder.h" #include "TransformSource.h" +#include "XMLNSNames.h" #include "XMLTokenizerScope.h" #include <libxml/parser.h> #include <libxml/parserInternals.h> @@ -168,11 +169,11 @@ public: m_callbacks.append(callback); } - void appendErrorCallback(XMLTokenizer::ErrorType type, const char* message, int lineNumber, int columnNumber) + void appendErrorCallback(XMLTokenizer::ErrorType type, const xmlChar* message, int lineNumber, int columnNumber) { PendingErrorCallback* callback = new PendingErrorCallback; - callback->message = strdup(message); + callback->message = xmlStrdup(message); callback->type = type; callback->lineNumber = lineNumber; callback->columnNumber = columnNumber; @@ -315,16 +316,16 @@ private: struct PendingErrorCallback: public PendingCallback { virtual ~PendingErrorCallback() { - free(message); + xmlFree(message); } virtual void call(XMLTokenizer* tokenizer) { - tokenizer->handleError(type, message, lineNumber, columnNumber); + tokenizer->handleError(type, reinterpret_cast<char*>(message), lineNumber, columnNumber); } XMLTokenizer::ErrorType type; - char* message; + xmlChar* message; int lineNumber; int columnNumber; }; @@ -547,10 +548,11 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view) , m_pendingScript(0) , m_scriptStartLine(0) , m_parsingFragment(false) + , m_scriptingPermission(FragmentScriptingAllowed) { } -XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) +XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission scriptingPermission) : m_doc(fragment->document()) , m_view(0) , m_context(0) @@ -573,6 +575,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_pendingScript(0) , m_scriptStartLine(0) , m_parsingFragment(true) + , m_scriptingPermission(scriptingPermission) { fragment->ref(); if (m_doc) @@ -596,9 +599,9 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) if (NamedNodeMap* attrs = element->attributes()) { for (unsigned i = 0; i < attrs->length(); i++) { Attribute* attr = attrs->attributeItem(i); - if (attr->localName() == "xmlns") + if (attr->localName() == xmlnsAtom) m_defaultNamespaceURI = attr->value(); - else if (attr->prefix() == "xmlns") + else if (attr->prefix() == xmlnsAtom) m_prefixToNamespaceMap.set(attr->localName(), attr->value()); } } @@ -674,15 +677,15 @@ struct _xmlSAX2Namespace { }; typedef struct _xmlSAX2Namespace xmlSAX2Namespace; -static inline void handleElementNamespaces(Element* newElement, const xmlChar** libxmlNamespaces, int nb_namespaces, ExceptionCode& ec) +static inline void handleElementNamespaces(Element* newElement, const xmlChar** libxmlNamespaces, int nb_namespaces, ExceptionCode& ec, FragmentScriptingPermission scriptingPermission) { xmlSAX2Namespace* namespaces = reinterpret_cast<xmlSAX2Namespace*>(libxmlNamespaces); for (int i = 0; i < nb_namespaces; i++) { - String namespaceQName = "xmlns"; + AtomicString namespaceQName = xmlnsAtom; String namespaceURI = toString(namespaces[i].uri); if (namespaces[i].prefix) namespaceQName = "xmlns:" + toString(namespaces[i].prefix); - newElement->setAttributeNS("http://www.w3.org/2000/xmlns/", namespaceQName, namespaceURI, ec); + newElement->setAttributeNS(XMLNSNames::xmlnsNamespaceURI, namespaceQName, namespaceURI, ec, scriptingPermission); if (ec) // exception setting attributes return; } @@ -697,7 +700,7 @@ struct _xmlSAX2Attributes { }; typedef struct _xmlSAX2Attributes xmlSAX2Attributes; -static inline void handleElementAttributes(Element* newElement, const xmlChar** libxmlAttributes, int nb_attributes, ExceptionCode& ec) +static inline void handleElementAttributes(Element* newElement, const xmlChar** libxmlAttributes, int nb_attributes, ExceptionCode& ec, FragmentScriptingPermission scriptingPermission) { xmlSAX2Attributes* attributes = reinterpret_cast<xmlSAX2Attributes*>(libxmlAttributes); for (int i = 0; i < nb_attributes; i++) { @@ -708,7 +711,7 @@ static inline void handleElementAttributes(Element* newElement, const xmlChar** String attrURI = attrPrefix.isEmpty() ? String() : toString(attributes[i].uri); String attrQName = attrPrefix.isEmpty() ? attrLocalName : attrPrefix + ":" + attrLocalName; - newElement->setAttributeNS(attrURI, attrQName, attrValue, ec); + newElement->setAttributeNS(attrURI, attrQName, attrValue, ec, scriptingPermission); if (ec) // exception setting attributes return; } @@ -776,17 +779,17 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm } ExceptionCode ec = 0; - handleElementNamespaces(newElement.get(), libxmlNamespaces, nb_namespaces, ec); + handleElementNamespaces(newElement.get(), libxmlNamespaces, nb_namespaces, ec, m_scriptingPermission); if (ec) { stopParsing(); return; } ScriptController* jsProxy = m_doc->frame() ? m_doc->frame()->script() : 0; - if (jsProxy && m_doc->frame()->script()->isEnabled()) + if (jsProxy && m_doc->frame()->script()->canExecuteScripts()) jsProxy->setEventHandlerLineNumber(lineNumber()); - handleElementAttributes(newElement.get(), libxmlAttributes, nb_attributes, ec); + handleElementAttributes(newElement.get(), libxmlAttributes, nb_attributes, ec, m_scriptingPermission); if (ec) { stopParsing(); return; @@ -810,7 +813,7 @@ void XMLTokenizer::startElementNs(const xmlChar* xmlLocalName, const xmlChar* xm if (m_view && !newElement->attached()) newElement->attach(); - if (isFirstElement && m_doc->frame()) + if (!m_parsingFragment && isFirstElement && m_doc->frame()) m_doc->frame()->loader()->dispatchDocumentElementAvailable(); } @@ -829,6 +832,13 @@ void XMLTokenizer::endElementNs() Node* n = m_currentNode; n->finishParsingChildren(); + if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n))) { + popCurrentNode(); + ExceptionCode ec; + n->remove(ec); + return; + } + if (!n->isElementNode() || !m_view) { popCurrentNode(); return; @@ -899,7 +909,7 @@ void XMLTokenizer::error(ErrorType type, const char* message, va_list args) if (m_parserStopped) return; -#if COMPILER(MSVC) +#if COMPILER(MSVC) || COMPILER(RVCT) char m[1024]; vsnprintf(m, sizeof(m) - 1, message, args); #else @@ -909,11 +919,11 @@ void XMLTokenizer::error(ErrorType type, const char* message, va_list args) #endif if (m_parserPaused) - m_pendingCallbacks->appendErrorCallback(type, m, lineNumber(), columnNumber()); + m_pendingCallbacks->appendErrorCallback(type, reinterpret_cast<const xmlChar*>(m), lineNumber(), columnNumber()); else handleError(type, m, lineNumber(), columnNumber()); -#if !COMPILER(MSVC) +#if !COMPILER(MSVC) && !COMPILER(RVCT) free(m); #endif } @@ -1380,12 +1390,12 @@ void XMLTokenizer::resumeParsing() end(); } -bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent) +bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent, FragmentScriptingPermission scriptingPermission) { if (!chunk.length()) return true; - XMLTokenizer tokenizer(fragment, parent); + XMLTokenizer tokenizer(fragment, parent, scriptingPermission); CString chunkAsUtf8 = chunk.utf8(); tokenizer.initializeParserContext(chunkAsUtf8.data()); diff --git a/WebCore/dom/XMLTokenizerQt.cpp b/WebCore/dom/XMLTokenizerQt.cpp index 4e61715..5335b07 100644 --- a/WebCore/dom/XMLTokenizerQt.cpp +++ b/WebCore/dom/XMLTokenizerQt.cpp @@ -100,11 +100,12 @@ XMLTokenizer::XMLTokenizer(Document* _doc, FrameView* _view) , m_pendingScript(0) , m_scriptStartLine(0) , m_parsingFragment(false) + , m_scriptingPermission(FragmentScriptingAllowed) { m_stream.setEntityResolver(new EntityResolver); } -XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) +XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement, FragmentScriptingPermission permission) : m_doc(fragment->document()) , m_view(0) , m_wroteText(false) @@ -126,6 +127,7 @@ XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement) , m_pendingScript(0) , m_scriptStartLine(0) , m_parsingFragment(true) + , m_scriptingPermission(permission) { fragment->ref(); if (m_doc) @@ -256,12 +258,12 @@ void XMLTokenizer::resumeParsing() end(); } -bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent) +bool parseXMLDocumentFragment(const String& chunk, DocumentFragment* fragment, Element* parent, FragmentScriptingPermission scriptingPermission) { if (!chunk.length()) return true; - XMLTokenizer tokenizer(fragment, parent); + XMLTokenizer tokenizer(fragment, parent, scriptingPermission); tokenizer.write(String("<qxmlstreamdummyelement>"), false); tokenizer.write(chunk, false); @@ -322,19 +324,20 @@ static inline String prefixFromQName(const QString& qName) } static inline void handleElementNamespaces(Element* newElement, const QXmlStreamNamespaceDeclarations &ns, - ExceptionCode& ec) + ExceptionCode& ec, FragmentScriptingPermission scriptingPermission) { 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:") + decl.prefix(); - newElement->setAttributeNS("http://www.w3.org/2000/xmlns/", namespaceQName, namespaceURI, ec); + newElement->setAttributeNS("http://www.w3.org/2000/xmlns/", namespaceQName, namespaceURI, ec, scriptingPermission); if (ec) // exception setting attributes return; } } -static inline void handleElementAttributes(Element* newElement, const QXmlStreamAttributes &attrs, ExceptionCode& ec) +static inline void handleElementAttributes(Element* newElement, const QXmlStreamAttributes &attrs, ExceptionCode& ec, + FragmentScriptingPermission scriptingPermission) { for (int i = 0; i < attrs.count(); ++i) { const QXmlStreamAttribute &attr = attrs[i]; @@ -342,7 +345,7 @@ static inline void handleElementAttributes(Element* newElement, const QXmlStream String attrValue = attr.value(); String attrURI = attr.namespaceUri().isEmpty() ? String() : String(attr.namespaceUri()); String attrQName = attr.qualifiedName(); - newElement->setAttributeNS(attrURI, attrQName, attrValue, ec); + newElement->setAttributeNS(attrURI, attrQName, attrValue, ec, scriptingPermission); if (ec) // exception setting attributes return; } @@ -502,13 +505,13 @@ void XMLTokenizer::parseStartElement() m_sawFirstElement = true; ExceptionCode ec = 0; - handleElementNamespaces(newElement.get(), m_stream.namespaceDeclarations(), ec); + handleElementNamespaces(newElement.get(), m_stream.namespaceDeclarations(), ec, m_scriptingPermission); if (ec) { stopParsing(); return; } - handleElementAttributes(newElement.get(), m_stream.attributes(), ec); + handleElementAttributes(newElement.get(), m_stream.attributes(), ec, m_scriptingPermission); if (ec) { stopParsing(); return; @@ -538,6 +541,13 @@ void XMLTokenizer::parseEndElement() Node* n = m_currentNode; n->finishParsingChildren(); + if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n))) { + popCurrentNode(); + ExceptionCode ec; + n->remove(ec); + return; + } + if (!n->isElementNode() || !m_view) { if (!m_currentNodeStack.isEmpty()) popCurrentNode(); diff --git a/WebCore/dom/make_names.pl b/WebCore/dom/make_names.pl index 6b5ddb4..daf45ef 100755 --- a/WebCore/dom/make_names.pl +++ b/WebCore/dom/make_names.pl @@ -94,7 +94,6 @@ sub defaultTagPropertyHash 'constructorNeedsCreatedByParser' => 0, 'constructorNeedsFormElement' => 0, 'createWithNew' => 0, - 'exportString' => 0, 'interfaceName' => defaultInterfaceName($_[0]), # By default, the JSInterfaceName is the same as the interfaceName. 'JSInterfaceName' => defaultInterfaceName($_[0]), @@ -104,11 +103,6 @@ sub defaultTagPropertyHash ); } -sub defaultAttrPropertyHash -{ - return ('exportString' => 0); -} - sub defaultParametersHash { return ( @@ -117,8 +111,7 @@ sub defaultParametersHash 'namespaceURI' => '', 'guardFactoryWith' => '', 'tagsNullNamespace' => 0, - 'attrsNullNamespace' => 0, - 'exportStrings' => 0 + 'attrsNullNamespace' => 0 ); } @@ -157,7 +150,7 @@ sub attrsHandler $attr =~ s/-/_/g; # Initialize default properties' values. - $attrs{$attr} = { defaultAttrPropertyHash($attr) } if !defined($attrs{$attr}); + $attrs{$attr} = {} if !defined($attrs{$attr}); if ($property) { die "Unknown property $property for attribute $attr\n" if !defined($attrs{$attr}{$property}); @@ -220,10 +213,6 @@ sub printMacros for my $name (sort keys %$namesRef) { print F "$macro $name","$suffix;\n"; - - if ($parameters{exportStrings} or $names{$name}{exportString}) { - print F "extern char $name", "${suffix}String[];\n"; - } } } @@ -534,14 +523,6 @@ DEFINE_GLOBAL(AtomicString, ${lowerNamespace}NamespaceURI, \"$parameters{namespa print F "}\n"; } - if (keys %tags) { - printDefinitionStrings($F, \%tags, "tags"); - } - - if (keys %attrs) { - printDefinitionStrings($F, \%attrs, "attributes"); - } - print F "\nvoid init() { static bool initialized = false; @@ -599,25 +580,6 @@ sub printElementIncludes } } -sub printDefinitionStrings -{ - my ($F, $namesRef, $type) = @_; - my $singularType = substr($type, 0, -1); - my $shortType = substr($singularType, 0, 4); - my $shortCamelType = ucfirst($shortType); - print F "\n// " . ucfirst($type) . " as strings\n"; - - my %names = %$namesRef; - for my $name (sort keys %$namesRef) { - next if (!$parameters{exportStrings} and !$names{$name}{exportString}); - - my $realName = $name; - $realName =~ s/_/-/g; - - print F "char $name","${shortCamelType}String[] = \"$realName\";\n"; - } -} - sub printDefinitions { my ($F, $namesRef, $type, $namespaceURI) = @_; @@ -628,19 +590,10 @@ sub printDefinitions print F " // " . ucfirst($type) . "\n"; - my %names = %$namesRef; for my $name (sort keys %$namesRef) { - next if ($parameters{exportStrings} or $names{$name}{exportString}); - my $realName = $name; $realName =~ s/_/-/g; - print F " const char *$name","${shortCamelType}String = \"$realName\";\n"; - } - - print "\n"; - - for my $name (sort keys %$namesRef) { - print F " new ((void*)&$name","${shortCamelType}) QualifiedName(nullAtom, $name","${shortCamelType}String, $namespaceURI);\n"; + print F " new ((void*)&$name","${shortCamelType}) QualifiedName(nullAtom, \"$realName\", $namespaceURI);\n"; } } |