[webkit-changes] cvs commit: WebCore/khtml/xml xml_tokenizer.cpp
Adele
adele at opensource.apple.com
Fri Jul 1 15:46:58 PDT 2005
adele 05/07/01 15:46:58
Modified: . Tag: Safari-2-0-branch ChangeLog
khtml/html Tag: Safari-2-0-branch html_headimpl.cpp
html_headimpl.h htmlparser.cpp
khtml/xml Tag: Safari-2-0-branch xml_tokenizer.cpp
Log:
Merged fix from TOT to Safari-2-0-branch
<rdar://problem/4164985> Not able to load additional script blocks dynamically
2005-05-04 Vicki Murley <vicki at apple.com>
Reviewed by darin.
- fixed <rdar://problem/3986228> Not able to load additional script blocks dynamically
Run scripts when they're inserted into the document. Use createdByParser bit to make sure
that scripts aren't run twice, once while parsing and again when inserting.
* khtml/html/html_headimpl.cpp:
(HTMLScriptElementImpl::HTMLScriptElementImpl):
(HTMLScriptElementImpl::~HTMLScriptElementImpl):
(HTMLScriptElementImpl::insertedIntoDocument):
(HTMLScriptElementImpl::removedFromDocument):
(HTMLScriptElementImpl::notifyFinished):
* khtml/html/html_headimpl.h:
(DOM::HTMLScriptElementImpl::setCreatedByParser):
* khtml/html/htmlparser.cpp:
(KHTMLParser::getElement):
* khtml/xml/xml_tokenizer.cpp:
(khtml::XMLTokenizer::startElement):
Revision Changes Path
No revision
No revision
1.4104.2.39 +27 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4104.2.38
retrieving revision 1.4104.2.39
diff -u -r1.4104.2.38 -r1.4104.2.39
--- ChangeLog 1 Jul 2005 22:35:56 -0000 1.4104.2.38
+++ ChangeLog 1 Jul 2005 22:46:51 -0000 1.4104.2.39
@@ -1,5 +1,32 @@
2005-07-01 Adele Peterson <adele at apple.com>
+ Merged fix from TOT to Safari-2-0-branch
+ <rdar://problem/4164985> Not able to load additional script blocks dynamically
+
+ 2005-05-04 Vicki Murley <vicki at apple.com>
+
+ Reviewed by darin.
+
+ - fixed <rdar://problem/3986228> Not able to load additional script blocks dynamically
+
+ Run scripts when they're inserted into the document. Use createdByParser bit to make sure
+ that scripts aren't run twice, once while parsing and again when inserting.
+
+ * khtml/html/html_headimpl.cpp:
+ (HTMLScriptElementImpl::HTMLScriptElementImpl):
+ (HTMLScriptElementImpl::~HTMLScriptElementImpl):
+ (HTMLScriptElementImpl::insertedIntoDocument):
+ (HTMLScriptElementImpl::removedFromDocument):
+ (HTMLScriptElementImpl::notifyFinished):
+ * khtml/html/html_headimpl.h:
+ (DOM::HTMLScriptElementImpl::setCreatedByParser):
+ * khtml/html/htmlparser.cpp:
+ (KHTMLParser::getElement):
+ * khtml/xml/xml_tokenizer.cpp:
+ (khtml::XMLTokenizer::startElement):
+
+2005-07-01 Adele Peterson <adele at apple.com>
+
Merged fix from TOT to Safari-2-0-branch.
<rdar://problem/4164922> Request for including an implementation of the elementFromPoint function
No revision
No revision
1.43.16.1 +69 -2 WebCore/khtml/html/html_headimpl.cpp
Index: html_headimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_headimpl.cpp,v
retrieving revision 1.43
retrieving revision 1.43.16.1
diff -u -r1.43 -r1.43.16.1
--- html_headimpl.cpp 16 Apr 2004 19:51:32 -0000 1.43
+++ html_headimpl.cpp 1 Jul 2005 22:46:56 -0000 1.43.16.1
@@ -29,6 +29,7 @@
#include "khtmlview.h"
#include "khtml_part.h"
+#include "kjs_proxy.h"
#include "misc/htmlhashes.h"
#include "misc/loader.h"
@@ -354,12 +355,78 @@
// -------------------------------------------------------------------------
-HTMLScriptElementImpl::HTMLScriptElementImpl(DocumentPtr *doc) : HTMLElementImpl(doc)
+HTMLScriptElementImpl::HTMLScriptElementImpl(DocumentPtr *doc)
+ : HTMLElementImpl(doc), m_cachedScript(0), m_createdByParser(false)
{
}
HTMLScriptElementImpl::~HTMLScriptElementImpl()
{
+ if (m_cachedScript)
+ m_cachedScript->deref(this);
+}
+
+void HTMLScriptElementImpl::insertedIntoDocument()
+{
+ HTMLElementImpl::insertedIntoDocument();
+
+ assert(!m_cachedScript);
+
+ if (m_createdByParser)
+ return;
+
+ QString url = getAttribute(ATTR_SRC).string();
+ if (!url.isEmpty()) {
+ QString charset = getAttribute(ATTR_CHARSET).string();
+ m_cachedScript = getDocument()->docLoader()->requestScript(DOMString(url), charset);
+ m_cachedScript->ref(this);
+ return;
+ }
+
+ DOMString scriptString = "";
+ for (NodeImpl *n = firstChild(); n; n = n->nextSibling())
+ if (n->isTextNode())
+ scriptString += static_cast<TextImpl*>(n)->data();
+
+ DocumentImpl *doc = getDocument();
+ KHTMLPart *part = doc->part();
+ if (!part)
+ return;
+ KJSProxy *proxy = KJSProxy::proxy(part);
+ if (!proxy)
+ return;
+
+ proxy->evaluate(doc->URL(), 0, scriptString.string(), Node());
+ DocumentImpl::updateDocumentsRendering();
+}
+
+void HTMLScriptElementImpl::removedFromDocument()
+{
+ HTMLElementImpl::removedFromDocument();
+
+ if (m_cachedScript) {
+ m_cachedScript->deref(this);
+ m_cachedScript = 0;
+ }
+}
+
+void HTMLScriptElementImpl::notifyFinished(CachedObject* o)
+{
+ CachedScript *cs = static_cast<CachedScript *>(o);
+
+ assert(cs == m_cachedScript);
+
+ KHTMLPart *part = getDocument()->part();
+ if (part) {
+ KJSProxy *proxy = KJSProxy::proxy(part);
+ if (proxy) {
+ proxy->evaluate(cs->url().string(), 0, cs->script().string(), Node());
+ DocumentImpl::updateDocumentsRendering();
+ }
+ }
+
+ cs->deref(this);
+ m_cachedScript = 0;
}
NodeImpl::Id HTMLScriptElementImpl::id() const
@@ -516,7 +583,7 @@
// Only allow title to be set by first <title> encountered.
if (inDocument() && getDocument()->title().isEmpty())
#else
- if (inDocument()))
+ if (inDocument())
#endif
getDocument()->setTitle(m_title);
}
1.15.16.1 +13 -5 WebCore/khtml/html/html_headimpl.h
Index: html_headimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_headimpl.h,v
retrieving revision 1.15
retrieving revision 1.15.16.1
diff -u -r1.15 -r1.15.16.1
--- html_headimpl.h 16 Apr 2004 19:51:32 -0000 1.15
+++ html_headimpl.h 1 Jul 2005 22:46:56 -0000 1.15.16.1
@@ -32,7 +32,8 @@
namespace khtml {
class CachedCSSStyleSheet;
-};
+ class CachedScript;
+}
namespace DOM {
@@ -134,17 +135,24 @@
// -------------------------------------------------------------------------
-class HTMLScriptElementImpl : public HTMLElementImpl
+class HTMLScriptElementImpl : public HTMLElementImpl, public khtml::CachedObjectClient
{
public:
HTMLScriptElementImpl(DocumentPtr *doc);
-
~HTMLScriptElementImpl();
+
+ virtual void insertedIntoDocument();
+ virtual void removedFromDocument();
+ virtual void notifyFinished(khtml::CachedObject *finishedObj);
virtual Id id() const;
-
virtual bool isURLAttribute(AttributeImpl *attr) const;
-
+
+ void setCreatedByParser(bool createdByParser) { m_createdByParser = createdByParser; }
+
+private:
+ khtml::CachedScript *m_cachedScript;
+ bool m_createdByParser;
};
// -------------------------------------------------------------------------
1.92.6.1 +7 -0 WebCore/khtml/html/htmlparser.cpp
Index: htmlparser.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/htmlparser.cpp,v
retrieving revision 1.92
retrieving revision 1.92.6.1
diff -u -r1.92 -r1.92.6.1
--- htmlparser.cpp 10 Mar 2005 21:09:24 -0000 1.92
+++ htmlparser.cpp 1 Jul 2005 22:46:57 -0000 1.92.6.1
@@ -943,6 +943,13 @@
if (!includesCommentsInDOM)
return 0;
break;
+
+ case ID_SCRIPT:
+ {
+ HTMLScriptElementImpl *scriptElement = new HTMLScriptElementImpl(document);
+ scriptElement->setCreatedByParser(true);
+ return scriptElement;
+ }
}
return document->document()->createHTMLElement(t->id);
No revision
No revision
1.30.8.1 +3 -0 WebCore/khtml/xml/xml_tokenizer.cpp
Index: xml_tokenizer.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/xml_tokenizer.cpp,v
retrieving revision 1.30
retrieving revision 1.30.8.1
diff -u -r1.30 -r1.30.8.1
--- xml_tokenizer.cpp 15 Mar 2005 21:44:32 -0000 1.30
+++ xml_tokenizer.cpp 1 Jul 2005 22:46:57 -0000 1.30.8.1
@@ -333,6 +333,9 @@
m_currentNode = implicitTBody;
}
+ if (newElement->id() == ID_SCRIPT)
+ static_cast<HTMLScriptElementImpl *>(newElement)->setCreatedByParser(true);
+
if (m_currentNode->addChild(newElement)) {
if (m_view && !newElement->attached())
newElement->attach();
More information about the webkit-changes
mailing list