[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
hyatt
hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:47:54 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 314db79486b34e7b35e41fda36ae8b4a1f29f374
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jul 21 01:36:50 2003 +0000
Enable domain() and setDomain() to work for all documents (XML
as well as HTML).
Implement onload for frames.
Reviewed by mjs
* khtml/ecma/kjs_window.cpp:
(Window::isSafeScript):
(WindowFunc::tryCall):
* khtml/html/html_baseimpl.cpp:
(HTMLFrameElementImpl::parseAttribute):
(HTMLIFrameElementImpl::parseAttribute):
* khtml/html/html_documentimpl.cpp:
* khtml/html/html_documentimpl.h:
* khtml/khtml_part.cpp:
(KHTMLPart::checkEmitLoadEvent):
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::domain):
(DocumentImpl::setDomain):
* khtml/xml/dom_docimpl.h:
* khtml/xml/dom_nodeimpl.cpp:
(NodeImpl::dispatchWindowEvent):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4677 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 22442fd..6454f2c 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,31 @@
2003-07-18 Dave Hyatt <hyatt at apple.com>
+ Enable domain() and setDomain() to work for all documents (XML
+ as well as HTML).
+
+ Implement onload for frames.
+
+ Reviewed by mjs
+
+ * khtml/ecma/kjs_window.cpp:
+ (Window::isSafeScript):
+ (WindowFunc::tryCall):
+ * khtml/html/html_baseimpl.cpp:
+ (HTMLFrameElementImpl::parseAttribute):
+ (HTMLIFrameElementImpl::parseAttribute):
+ * khtml/html/html_documentimpl.cpp:
+ * khtml/html/html_documentimpl.h:
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::checkEmitLoadEvent):
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::domain):
+ (DocumentImpl::setDomain):
+ * khtml/xml/dom_docimpl.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeImpl::dispatchWindowEvent):
+
+2003-07-18 Dave Hyatt <hyatt at apple.com>
+
Fix for 3334082, XML documents can access HTML/XML docs in other
domains. The basic bug is that we made a change right before
1.0 to allow a parent document to access a child frame's document
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 22442fd..6454f2c 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,31 @@
2003-07-18 Dave Hyatt <hyatt at apple.com>
+ Enable domain() and setDomain() to work for all documents (XML
+ as well as HTML).
+
+ Implement onload for frames.
+
+ Reviewed by mjs
+
+ * khtml/ecma/kjs_window.cpp:
+ (Window::isSafeScript):
+ (WindowFunc::tryCall):
+ * khtml/html/html_baseimpl.cpp:
+ (HTMLFrameElementImpl::parseAttribute):
+ (HTMLIFrameElementImpl::parseAttribute):
+ * khtml/html/html_documentimpl.cpp:
+ * khtml/html/html_documentimpl.h:
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::checkEmitLoadEvent):
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::domain):
+ (DocumentImpl::setDomain):
+ * khtml/xml/dom_docimpl.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeImpl::dispatchWindowEvent):
+
+2003-07-18 Dave Hyatt <hyatt at apple.com>
+
Fix for 3334082, XML documents can access HTML/XML docs in other
domains. The basic bug is that we made a change right before
1.0 to allow a parent document to access a child frame's document
diff --git a/WebCore/khtml/ecma/kjs_window.cpp b/WebCore/khtml/ecma/kjs_window.cpp
index b0ca7b8..39c94b0 100644
--- a/WebCore/khtml/ecma/kjs_window.cpp
+++ b/WebCore/khtml/ecma/kjs_window.cpp
@@ -958,27 +958,22 @@ bool Window::isSafeScript(ExecState *exec) const
// exist yet allow JS to access the window object.
if (!m_part->xmlDocImpl())
return true;
-
- DOM::HTMLDocument thisDocument = m_part->htmlDocument();
- if ( thisDocument.isNull() ) {
- kdDebug(6070) << "Window::isSafeScript: trying to access an XML document !?" << endl;
- return false;
- }
- DOM::HTMLDocument actDocument = activePart->htmlDocument();
+ DOM::DocumentImpl* thisDocument = m_part->xmlDocImpl();
+ DOM::DocumentImpl* actDocument = activePart->xmlDocImpl();
- if ( actDocument.isNull() ) {
+ if (!actDocument) {
kdDebug(6070) << "Window::isSafeScript: active part has no document!" << endl;
return false;
}
- DOM::DOMString actDomain = actDocument.domain();
+ DOM::DOMString actDomain = actDocument->domain();
// Always allow local pages to execute any JS.
if (actDomain.isNull())
return true;
- DOM::DOMString thisDomain = thisDocument.domain();
+ DOM::DOMString thisDomain = thisDocument->domain();
//kdDebug(6070) << "current domain:" << actDomain.string() << ", frame domain:" << thisDomain.string() << endl;
if ( actDomain == thisDomain )
return true;
@@ -1289,11 +1284,14 @@ Value WindowFunc::tryCall(ExecState *exec, Object &thisObj, const List &args)
khtmlpart->begin();
khtmlpart->write("<HTML><BODY>");
khtmlpart->end();
- if ( part->docImpl() ) {
- kdDebug(6070) << "Setting domain to " << part->docImpl()->domain().string() << endl;
- khtmlpart->docImpl()->setDomain( part->docImpl()->domain(), true );
- khtmlpart->docImpl()->setBaseURL( part->docImpl()->baseURL() );
+
+ if (part->xmlDocImpl()) {
+ kdDebug(6070) << "Setting domain to " << part->xmlDocImpl()->domain().string() << endl;
+ khtmlpart->xmlDocImpl()->setDomain( part->docImpl()->domain(), true );
}
+
+ if ( part->docImpl() )
+ khtmlpart->docImpl()->setBaseURL( part->docImpl()->baseURL() );
}
#if APPLE_CHANGES
if (!url.isEmpty()) {
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 8173f2a..4ec8484 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -350,7 +350,14 @@ void HTMLFrameElementImpl::parseAttribute(AttributeImpl *attr)
scrolling = QScrollView::AlwaysOff;
// FIXME: If we are already attached, this has no effect.
// FIXME: Is this falling through on purpose, or do we want a break here?
-
+ case ATTR_ONLOAD:
+ setHTMLEventListener(EventImpl::LOAD_EVENT,
+ getDocument()->createHTMLEventListener(attr->value().string()));
+ break;
+ case ATTR_ONUNLOAD:
+ setHTMLEventListener(EventImpl::UNLOAD_EVENT,
+ getDocument()->createHTMLEventListener(attr->value().string()));
+ break;
default:
HTMLElementImpl::parseAttribute(attr);
}
@@ -670,6 +677,9 @@ void HTMLIFrameElementImpl::parseAttribute(AttributeImpl *attr )
needWidgetUpdate = true; // ### do this for scrolling, margins etc?
HTMLFrameElementImpl::parseAttribute( attr );
break;
+ case ATTR_ALIGN:
+ addHTMLAlignment( attr->value() );
+ break;
default:
HTMLFrameElementImpl::parseAttribute( attr );
}
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index ce3e67e..4886f7e 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -143,38 +143,6 @@ DOMString HTMLDocumentImpl::referrer() const
return DOMString();
}
-DOMString HTMLDocumentImpl::domain() const
-{
- if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
- m_domain = KURL(URL()).host(); // Initially set to the host
- return m_domain;
-}
-
-void HTMLDocumentImpl::setDomain(const DOMString &newDomain, bool force /*=false*/)
-{
- if ( force ) {
- m_domain = newDomain;
- return;
- }
- if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
- m_domain = KURL(URL()).host(); // Initially set to the host
-
- // Both NS and IE specify that changing the domain is only allowed when
- // the new domain is a suffix of the old domain.
- int oldLength = m_domain.length();
- int newLength = newDomain.length();
- if ( newLength < oldLength ) // e.g. newDomain=kde.org (7) and m_domain=www.kde.org (11)
- {
- DOMString test = m_domain.copy();
- if ( test[oldLength - newLength - 1] == '.' ) // Check that it's a subdomain, not e.g. "de.org"
- {
- test.remove( 0, oldLength - newLength ); // now test is "kde.org" from m_domain
- if ( test == newDomain ) // and we check that it's the same thing as newDomain
- m_domain = newDomain;
- }
- }
-}
-
DOMString HTMLDocumentImpl::lastModified() const
{
if ( view() )
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index 2c57aba..18b9840 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -57,8 +57,6 @@ public:
virtual bool isHTMLDocument() const { return true; }
DOMString referrer() const;
- DOMString domain() const;
- void setDomain( const DOMString &newDomain, bool force = false ); // not part of the DOM
DOMString lastModified() const;
DOMString cookie() const;
void setCookie( const DOMString &);
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 1eddc7b..90eb700 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -1785,9 +1785,9 @@ void KHTMLPart::checkEmitLoadEvent()
// All frames completed -> set their domain to the frameset's domain
// This must only be done when loading the frameset initially (#22039),
// not when following a link in a frame (#44162).
- if ( d->m_doc && d->m_doc->isHTMLDocument() )
+ if ( d->m_doc )
{
- DOMString domain = static_cast<HTMLDocumentImpl*>(d->m_doc)->domain();
+ DOMString domain = d->m_doc->domain();
ConstFrameIt it = d->m_frames.begin();
ConstFrameIt end = d->m_frames.end();
for (; it != end; ++it )
@@ -1796,10 +1796,10 @@ void KHTMLPart::checkEmitLoadEvent()
if ( p && p->inherits( "KHTMLPart" ))
{
KHTMLPart* htmlFrame = static_cast<KHTMLPart *>(p);
- if (htmlFrame->d->m_doc && htmlFrame->d->m_doc->isHTMLDocument() )
+ if (htmlFrame->d->m_doc)
{
kdDebug() << "KHTMLPart::checkCompleted setting frame domain to " << domain.string() << endl;
- static_cast<HTMLDocumentImpl*>(htmlFrame->d->m_doc)->setDomain( domain );
+ htmlFrame->d->m_doc->setDomain( domain );
}
}
}
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 72ecbd2..03a1817 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -2306,6 +2306,38 @@ ElementImpl *DocumentImpl::ownerElement()
return static_cast<ElementImpl *>(renderPart->element());
}
+DOMString DocumentImpl::domain() const
+{
+ if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
+ m_domain = KURL(URL()).host(); // Initially set to the host
+ return m_domain;
+}
+
+void DocumentImpl::setDomain(const DOMString &newDomain, bool force /*=false*/)
+{
+ if ( force ) {
+ m_domain = newDomain;
+ return;
+ }
+ if ( m_domain.isEmpty() ) // not set yet (we set it on demand to save time and space)
+ m_domain = KURL(URL()).host(); // Initially set to the host
+
+ // Both NS and IE specify that changing the domain is only allowed when
+ // the new domain is a suffix of the old domain.
+ int oldLength = m_domain.length();
+ int newLength = newDomain.length();
+ if ( newLength < oldLength ) // e.g. newDomain=kde.org (7) and m_domain=www.kde.org (11)
+ {
+ DOMString test = m_domain.copy();
+ if ( test[oldLength - newLength - 1] == '.' ) // Check that it's a subdomain, not e.g. "de.org"
+ {
+ test.remove( 0, oldLength - newLength ); // now test is "kde.org" from m_domain
+ if ( test == newDomain ) // and we check that it's the same thing as newDomain
+ m_domain = newDomain;
+ }
+ }
+}
+
#if APPLE_CHANGES
void DocumentImpl::setDecoder(Decoder *decoder)
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 85ef49f..a0cbd56 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -443,6 +443,9 @@ public:
// Returns 0 if this is the top level document.
ElementImpl *ownerElement();
+ DOMString domain() const;
+ void setDomain( const DOMString &newDomain, bool force = false ); // not part of the DOM
+
signals:
void finishedParsing();
@@ -551,6 +554,7 @@ public:
khtml::Decoder *decoder() const { return m_decoder; }
private:
+ mutable DOMString m_domain;
bool m_inPageCache;
int m_passwordFields;
int m_secureForms;
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index fc6ed8f..1430e91 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -600,8 +600,32 @@ bool NodeImpl::dispatchWindowEvent(int _id, bool canBubbleArg, bool cancelableAr
bool r = dispatchGenericEvent( evt, exceptioncode );
if (!evt->defaultPrevented() && doc->document())
doc->document()->defaultEventHandler(evt);
+
+ if (_id == EventImpl::LOAD_EVENT && !evt->propagationStopped()) {
+ // For onload events, send them to the enclosing frame only.
+ // This is a DOM extension and is independent of bubbling/capturing rules of
+ // the DOM. You send the event only to the enclosing frame. It does not
+ // bubble through the parent document.
+ DOM::ElementImpl* elt = doc->document()->ownerElement();
+ if (elt && (elt->getDocument()->domain().isNull() ||
+ elt->getDocument()->domain() == doc->document()->domain())) {
+ // We also do a security check, since we don't want to allow the enclosing
+ // iframe to see loads of child documents in other domains.
+ evt->setCurrentTarget(elt);
+
+ // Capturing first.
+ elt->handleLocalEvents(evt,true);
+
+ // Bubbling second.
+ if (!evt->propagationStopped())
+ elt->handleLocalEvents(evt,false);
+ r = !evt->defaultPrevented();
+ }
+ }
+
doc->deref();
evt->deref();
+
return r;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list