2008-05-26 Maciej Stachowiak <mjs@apple.com>
Reviewed by Anders.
- make addStaticGlobals protected instead of private so subclasses can use it
* JavaScriptCore.exp:
* kjs/JSGlobalObject.h:
WebCore:
2008-05-25 Maciej Stachowiak <mjs@apple.com>
Reviewed by Anders.
- bind the window's "document" and "window" properties to static slots
1.7% speedup on Acid3 test 26
Only the "document" part matters for Acid3, but since I was doing
this anyway, "window" also seemed like a good one to optimize.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::JSDOMWindowBase): Allocate variable
slots for document and window; but just put null in the document
slot for now.
(WebCore::JSDOMWindowBase::updateDocument): Fill in the document
slot.
(WebCore::JSDOMWindowBase::~JSDOMWindowBase): Make our shell stop
tracking us.
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::JSDOMWindowShell): Allocate HashSet
for our still-not-dead inner windows.
(WebCore::JSDOMWindowShell::updateDocument): Update all our
inner windows ever (to make sure the update to the document
property shows up everywhere).
* bindings/js/JSDOMWindowShell.h:
(WebCore::JSDOMWindowShell::setWindow): Update our hash.
(WebCore::JSDOMWindowShell::clearFormerWindow): Ditto.
* bindings/js/JSDocumentCustom.cpp:
(WebCore::toJS): Don't set self as a property map property of
the window, this is no longer necessary.
* bindings/js/kjs_proxy.cpp:
(WebCore::KJSProxy::initScript): Update document for the
newly created window.
* bindings/js/kjs_proxy.h:
* page/Frame.cpp:
(WebCore::Frame::setDocument): If the document is not null,
update our window.
LayoutTests:
2008-05-26 Maciej Stachowiak <mjs@apple.com>
Reviewed by Anders.
- update test result for document/window being allocated to var slots
* http/tests/security/cross-frame-access-put-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34143
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-05-26 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Anders.
+
+ - make addStaticGlobals protected instead of private so subclasses can use it
+
+ * JavaScriptCore.exp:
+ * kjs/JSGlobalObject.h:
+
2008-05-26 Geoffrey Garen <ggaren@apple.com>
Reviewed by Darin Adler.
__ZN3KJS11PropertyMapD1Ev
__ZN3KJS12DateInstance4infoE
__ZN3KJS12PropertySlot15undefinedGetterEPNS_9ExecStateEPNS_8JSObjectERKNS_10IdentifierERKS0_
+__ZN3KJS12RegisterFile14addGlobalSlotsEm
__ZN3KJS13ArrayInstance4infoE
__ZN3KJS13CodeGenerator21setDumpsGeneratedCodeEb
__ZN3KJS13StatementNode6setLocEii
// Initialize and/or retrieve per-thread hash tables - use perThreadData() for faster access instead.
static ThreadClassInfoHashTables* threadClassInfoHashTables();
- private:
void init(JSObject* thisValue);
JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
+ protected:
struct GlobalPropertyInfo {
GlobalPropertyInfo(const Identifier& i, JSValue* v, unsigned a)
: identifier(i)
};
void addStaticGlobals(GlobalPropertyInfo*, int count);
+ private:
bool checkTimeout();
void resetTimeoutCheck();
+2008-05-26 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Anders.
+
+ - update test result for document/window being allocated to var slots
+
+ * http/tests/security/cross-frame-access-put-expected.txt:
+
2008-05-26 James Ren <jamesjren@gmail.com>
Reviewed by Sam Weinig, landed by Collin Jackson.
CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-put.html. Domains, protocols and ports must match.
+CONSOLE MESSAGE: line 1: Unsafe JavaScript attempt to access frame with URL http://localhost:8000/security/resources/cross-frame-iframe-for-put-test.html from frame with URL http://127.0.0.1:8000/security/cross-frame-access-put.html. Domains, protocols and ports must match.
+
ALERT: PASS: window.Attr should be '[object AttrConstructor]' and is.
ALERT: PASS: window.CDATASection should be '[object CDATASectionConstructor]' and is.
ALERT: PASS: window.CharacterData should be '[object CharacterDataConstructor]' and is.
+2008-05-25 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Anders.
+
+ - bind the window's "document" and "window" properties to static slots
+ 1.7% speedup on Acid3 test 26
+
+ Only the "document" part matters for Acid3, but since I was doing
+ this anyway, "window" also seemed like a good one to optimize.
+
+ * bindings/js/JSDOMWindowBase.cpp:
+ (WebCore::JSDOMWindowBase::JSDOMWindowBase): Allocate variable
+ slots for document and window; but just put null in the document
+ slot for now.
+ (WebCore::JSDOMWindowBase::updateDocument): Fill in the document
+ slot.
+ (WebCore::JSDOMWindowBase::~JSDOMWindowBase): Make our shell stop
+ tracking us.
+ * bindings/js/JSDOMWindowBase.h:
+ * bindings/js/JSDOMWindowShell.cpp:
+ (WebCore::JSDOMWindowShell::JSDOMWindowShell): Allocate HashSet
+ for our still-not-dead inner windows.
+ (WebCore::JSDOMWindowShell::updateDocument): Update all our
+ inner windows ever (to make sure the update to the document
+ property shows up everywhere).
+ * bindings/js/JSDOMWindowShell.h:
+ (WebCore::JSDOMWindowShell::setWindow): Update our hash.
+ (WebCore::JSDOMWindowShell::clearFormerWindow): Ditto.
+ * bindings/js/JSDocumentCustom.cpp:
+ (WebCore::toJS): Don't set self as a property map property of
+ the window, this is no longer necessary.
+ * bindings/js/kjs_proxy.cpp:
+ (WebCore::KJSProxy::initScript): Update document for the
+ newly created window.
+ * bindings/js/kjs_proxy.h:
+ * page/Frame.cpp:
+ (WebCore::Frame::setDocument): If the document is not null,
+ update our window.
+
2008-05-26 Anders Carlsson <andersca@apple.com>
Reviewed by Sam.
// Time in milliseconds before the script timeout handler kicks in.
setTimeoutTime(10000);
+
+ GlobalPropertyInfo staticGlobals[] = {
+ GlobalPropertyInfo("document", jsNull(), DontDelete | ReadOnly),
+ GlobalPropertyInfo("window", d->m_shell, DontDelete | ReadOnly)
+ };
+
+ addStaticGlobals(staticGlobals, sizeof(staticGlobals) / sizeof(GlobalPropertyInfo));
+}
+
+void JSDOMWindowBase::updateDocument()
+{
+ ASSERT(m_impl->document());
+ ExecState* exec = globalExec();
+ symbolTablePutWithAttributes("document", toJS(exec, m_impl->document()), DontDelete | ReadOnly);
}
JSDOMWindowBase::~JSDOMWindowBase()
{
+ d->m_shell->clearFormerWindow(asJSDOMWindow(this));
+
clearAllTimeouts();
// Clear any backpointers to the window
public:
virtual ~JSDOMWindowBase();
+ void updateDocument();
+
DOMWindow* impl() const { return m_impl.get(); }
void disconnectFrame();
JSDOMWindowShell::JSDOMWindowShell(DOMWindow* domWindow)
: Base(jsNull())
, m_window(0)
+ , m_liveFormerWindows(new HashSet<JSDOMWindow*>)
{
m_window = new JSDOMWindow(domWindow, this);
setPrototype(m_window->prototype());
m_window->clear();
}
+
+void JSDOMWindowShell::updateDocument()
+{
+ m_window->updateDocument();
+ HashSet<JSDOMWindow*>::iterator end = m_liveFormerWindows->end();
+ for (HashSet<JSDOMWindow*>::iterator it = m_liveFormerWindows->begin(); it != end; ++it)
+ (*it)->updateDocument();
+}
+
// ----
// Conversion methods
// ----
void setWindow(JSDOMWindow* window)
{
ASSERT_ARG(window, window);
+ m_liveFormerWindows->add(m_window);
m_window = window;
setPrototype(window->prototype());
}
DOMWindow* impl() const;
void disconnectFrame();
void clear();
+ void updateDocument();
+
+ void clearFormerWindow(JSDOMWindow* window) { m_liveFormerWindows->remove(window); }
private:
JSDOMWindow* m_window;
+ HashSet<JSDOMWindow*>* m_liveFormerWindows;
};
KJS::JSValue* toJS(KJS::ExecState*, Frame*);
// Make sure the document is kept around by the window object, and works right with the
// back/forward cache.
- if (doc->frame())
- toJSDOMWindowShell(doc->frame())->window()->putDirect("document", ret, DontDelete|ReadOnly);
- else {
+ if (!doc->frame()) {
size_t nodeCount = 0;
for (Node* n = doc; n; n = n->traverseNextNode())
nodeCount++;
JSLock lock;
m_windowShell = new JSDOMWindowShell(m_frame->domWindow());
+ m_windowShell->updateDocument();
if (Page* page = m_frame->page()) {
attachDebugger(page->debugger());
m_frame->loader()->dispatchWindowObjectAvailable();
}
-void KJSProxy::clearDocumentWrapper()
-{
- if (!m_windowShell)
- return;
-
- JSLock lock;
- m_windowShell->window()->removeDirect("document");
-}
-
bool KJSProxy::processingUserGesture() const
{
if (!m_windowShell)
void finishedWithEvent(Event*);
void setEventHandlerLineno(int lineno) { m_handlerLineno = lineno; }
- void clearDocumentWrapper();
-
void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
bool processingUserGesture() const;
if (d->m_doc && !d->m_doc->attached())
d->m_doc->attach();
- // Remove the cached 'document' property, which is now stale.
- d->m_jscript.clearDocumentWrapper();
+ // Update the cached 'document' property, which is now stale.
+ if (d->m_doc && d->m_jscript.haveWindowShell()) {
+ JSLock lock;
+ d->m_jscript.windowShell()->updateDocument();
+ }
}
Settings* Frame::settings() const