Commit 0df8b7e8 authored by eric@webkit.org's avatar eric@webkit.org

2010-05-27 Anton Muhin <antonm@chromium.org>

        Reviewed by Adam Barth.

        Add callbacks to ScriptController to allow notifications on named items additions and removals
        https://bugs.webkit.org/show_bug.cgi?id=39679

        * bindings/js/ScriptController.h: Callbacks with empty implementation added.
        (WebCore::ScriptController::namedItemAdded):
        (WebCore::ScriptController::namedItemRemoved):
        * bindings/v8/ScriptController.cpp: Empty implementation of callbacks.
        (WebCore::ScriptController::namedItemAdded):
        (WebCore::ScriptController::namedItemRemoved):
        * bindings/v8/ScriptController.h: Callbacks added.
        * html/HTMLDocument.cpp: Hooking in callbacks.
        (WebCore::HTMLDocument::addItemToMap):
        (WebCore::HTMLDocument::removeItemFromMap):
        * html/HTMLDocument.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@60291 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent fcfb2c88
2010-05-27 Anton Muhin <antonm@chromium.org>
Reviewed by Adam Barth.
Add callbacks to ScriptController to allow notifications on named items additions and removals
https://bugs.webkit.org/show_bug.cgi?id=39679
* bindings/js/ScriptController.h: Callbacks with empty implementation added.
(WebCore::ScriptController::namedItemAdded):
(WebCore::ScriptController::namedItemRemoved):
* bindings/v8/ScriptController.cpp: Empty implementation of callbacks.
(WebCore::ScriptController::namedItemAdded):
(WebCore::ScriptController::namedItemRemoved):
* bindings/v8/ScriptController.h: Callbacks added.
* html/HTMLDocument.cpp: Hooking in callbacks.
(WebCore::HTMLDocument::addItemToMap):
(WebCore::HTMLDocument::removeItemFromMap):
* html/HTMLDocument.h:
2010-05-27 Zhenyao Mo <zmo@google.com>
Reviewed by Dimitri Glazkov.
......
......@@ -142,6 +142,9 @@ public:
void clearWindowShell(bool goingIntoPageCache = false);
void updateDocument();
void namedItemAdded(HTMLDocument*, const AtomicString&) { }
void namedItemRemoved(HTMLDocument*, const AtomicString&) { }
// Notifies the ScriptController that the securityOrigin of the current
// document was modified. For example, this method is called when
// document.domain is set. This method is *not* called when a new document
......
......@@ -454,4 +454,12 @@ void ScriptController::updateDocument()
m_proxy->windowShell()->updateDocument();
}
void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
{
}
void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& name)
{
}
} // namespace WebCore
......@@ -169,6 +169,9 @@ public:
void clearWindowShell(bool = false);
void updateDocument();
void namedItemAdded(HTMLDocument*, const AtomicString&);
void namedItemRemoved(HTMLDocument*, const AtomicString&);
void updateSecurityOrigin();
void clearScriptObjects();
void updatePlatformScriptObjects();
......
......@@ -315,17 +315,21 @@ PassRefPtr<Element> HTMLDocument::createElement(const AtomicString& name, Except
return HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, name.lower(), xhtmlNamespaceURI), this, 0, false);
}
static void addItemToMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name)
void HTMLDocument::addItemToMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name)
{
if (name.isEmpty())
return;
map.add(name.impl());
if (Frame* f = frame())
f->script()->namedItemAdded(this, name);
}
static void removeItemFromMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name)
void HTMLDocument::removeItemFromMap(HashCountedSet<AtomicStringImpl*>& map, const AtomicString& name)
{
if (name.isEmpty())
return;
if (Frame* f = frame())
f->script()->namedItemRemoved(this, name);
map.remove(name.impl());
}
......
......@@ -91,6 +91,9 @@ private:
virtual Tokenizer* createTokenizer();
virtual void determineParseMode();
void addItemToMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
void removeItemFromMap(HashCountedSet<AtomicStringImpl*>&, const AtomicString&);
HashCountedSet<AtomicStringImpl*> m_namedItemCounts;
HashCountedSet<AtomicStringImpl*> m_extraNamedItemCounts;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment