[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
mjs
mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:16:33 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 1ef0533bdb37d7c9308f6018d0659223da820b72
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 5 22:03:07 2003 +0000
Reviewed by John.
<rdar://problem/3487222>: Add ability to create working fully standalone document object
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::CSSStyleSelector):
(khtml::CSSStyleSelector::addSheet):
(khtml::CSSStyleSelector::initForStyleResolve):
(khtml::CSSStyleSelector::applyRule):
* khtml/dom/dom_doc.cpp:
(DOM::Document::part):
* khtml/dom/dom_doc.h:
* khtml/ecma/kjs_dom.cpp:
(DOMDocument::getValueProperty):
(KJS::checkNodeSecurity):
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLDocFunction::tryCall):
(KJS::HTMLDocument::tryGet):
(KJS::HTMLDocument::putValue):
(KJS::HTMLElement::tryGet):
(Image::notifyFinished):
* khtml/ecma/kjs_traversal.cpp:
(JSNodeFilter::acceptNode):
* khtml/ecma/xmlhttprequest.cpp:
(KJS::XMLHttpRequest::changeState):
* khtml/html/html_baseimpl.cpp:
(HTMLBodyElementImpl::insertedIntoDocument):
(HTMLFrameElementImpl::isURLAllowed):
(HTMLFrameElementImpl::attach):
(HTMLFrameElementImpl::detach):
(HTMLFrameElementImpl::contentDocument):
(HTMLIFrameElementImpl::attach):
* khtml/html/html_documentimpl.cpp:
(HTMLDocumentImpl::referrer):
(HTMLDocumentImpl::lastModified):
* khtml/html/html_formimpl.cpp:
(HTMLFormElementImpl::formData):
(HTMLFormElementImpl::prepareSubmit):
(HTMLFormElementImpl::submit):
(HTMLFormElementImpl::reset):
(HTMLGenericFormElementImpl::isKeyboardFocusable):
(HTMLGenericFormElementImpl::defaultEventHandler):
* khtml/html/html_headimpl.cpp:
(HTMLBaseElementImpl::process):
(HTMLLinkElementImpl::process):
* khtml/html/html_inlineimpl.cpp:
(HTMLAnchorElementImpl::isKeyboardFocusable):
(HTMLAnchorElementImpl::defaultEventHandler):
* khtml/html/html_objectimpl.cpp:
(HTMLAppletElementImpl::createRenderer):
(HTMLAppletElementImpl::getAppletInstance):
(HTMLEmbedElementImpl::rendererIsNeeded):
(HTMLObjectElementImpl::rendererIsNeeded):
* khtml/html/htmltokenizer.cpp:
(HTMLTokenizer::scriptExecution):
(HTMLTokenizer::parseTag):
* khtml/rendering/render_applet.cpp:
(RenderApplet::RenderApplet):
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::setTitle):
(DocumentImpl::part):
(DocumentImpl::close):
(DocumentImpl::processHttpEquiv):
* khtml/xml/dom_docimpl.h:
* khtml/xml/dom_nodeimpl.cpp:
(NodeImpl::dispatchEvent):
* kwq/KWQAccObject.mm:
(-[KWQAccObject textUnderElement]):
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::partForNode):
(KWQKHTMLPart::attributedString):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5709 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 5cd7bce..7d280d6 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,77 @@
+2003-12-05 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by John.
+
+ <rdar://problem/3487222>: Add ability to create working fully standalone document object
+
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::CSSStyleSelector):
+ (khtml::CSSStyleSelector::addSheet):
+ (khtml::CSSStyleSelector::initForStyleResolve):
+ (khtml::CSSStyleSelector::applyRule):
+ * khtml/dom/dom_doc.cpp:
+ (DOM::Document::part):
+ * khtml/dom/dom_doc.h:
+ * khtml/ecma/kjs_dom.cpp:
+ (DOMDocument::getValueProperty):
+ (KJS::checkNodeSecurity):
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLDocFunction::tryCall):
+ (KJS::HTMLDocument::tryGet):
+ (KJS::HTMLDocument::putValue):
+ (KJS::HTMLElement::tryGet):
+ (Image::notifyFinished):
+ * khtml/ecma/kjs_traversal.cpp:
+ (JSNodeFilter::acceptNode):
+ * khtml/ecma/xmlhttprequest.cpp:
+ (KJS::XMLHttpRequest::changeState):
+ * khtml/html/html_baseimpl.cpp:
+ (HTMLBodyElementImpl::insertedIntoDocument):
+ (HTMLFrameElementImpl::isURLAllowed):
+ (HTMLFrameElementImpl::attach):
+ (HTMLFrameElementImpl::detach):
+ (HTMLFrameElementImpl::contentDocument):
+ (HTMLIFrameElementImpl::attach):
+ * khtml/html/html_documentimpl.cpp:
+ (HTMLDocumentImpl::referrer):
+ (HTMLDocumentImpl::lastModified):
+ * khtml/html/html_formimpl.cpp:
+ (HTMLFormElementImpl::formData):
+ (HTMLFormElementImpl::prepareSubmit):
+ (HTMLFormElementImpl::submit):
+ (HTMLFormElementImpl::reset):
+ (HTMLGenericFormElementImpl::isKeyboardFocusable):
+ (HTMLGenericFormElementImpl::defaultEventHandler):
+ * khtml/html/html_headimpl.cpp:
+ (HTMLBaseElementImpl::process):
+ (HTMLLinkElementImpl::process):
+ * khtml/html/html_inlineimpl.cpp:
+ (HTMLAnchorElementImpl::isKeyboardFocusable):
+ (HTMLAnchorElementImpl::defaultEventHandler):
+ * khtml/html/html_objectimpl.cpp:
+ (HTMLAppletElementImpl::createRenderer):
+ (HTMLAppletElementImpl::getAppletInstance):
+ (HTMLEmbedElementImpl::rendererIsNeeded):
+ (HTMLObjectElementImpl::rendererIsNeeded):
+ * khtml/html/htmltokenizer.cpp:
+ (HTMLTokenizer::scriptExecution):
+ (HTMLTokenizer::parseTag):
+ * khtml/rendering/render_applet.cpp:
+ (RenderApplet::RenderApplet):
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::setTitle):
+ (DocumentImpl::part):
+ (DocumentImpl::close):
+ (DocumentImpl::processHttpEquiv):
+ * khtml/xml/dom_docimpl.h:
+ * khtml/xml/dom_nodeimpl.cpp:
+ (NodeImpl::dispatchEvent):
+ * kwq/KWQAccObject.mm:
+ (-[KWQAccObject textUnderElement]):
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::partForNode):
+ (KWQKHTMLPart::attributedString):
+
2003-12-05 Richard Williamson <rjw at apple.com>
Fixed 3501885. Added null test to returned node from collection.
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 9ae0a7b..2b8b569 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -184,7 +184,8 @@ CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
init();
if(!defaultStyle) loadDefaultStyle();
- m_medium = sheet->doc()->view()->mediaType();
+ KHTMLView *view = sheet->doc()->view();
+ m_medium = view ? view->mediaType() : QString("all");
authorStyle = new CSSStyleSelectorList();
authorStyle->append( sheet, m_medium );
@@ -213,7 +214,8 @@ CSSStyleSelector::~CSSStyleSelector()
void CSSStyleSelector::addSheet( CSSStyleSheetImpl *sheet )
{
- m_medium = sheet->doc()->view()->mediaType();
+ KHTMLView *view = sheet->doc()->view();
+ m_medium = view ? view->mediaType() : QString("all");
authorStyle->append( sheet, m_medium );
}
@@ -319,8 +321,8 @@ void CSSStyleSelector::initForStyleResolve(ElementImpl* e, RenderStyle* defaultP
parentStyle = (parentNode && parentNode->renderer()) ? parentNode->renderer()->style() : 0;
view = element->getDocument()->view();
isXMLDoc = !element->getDocument()->isHTMLDocument();
- part = view->part();
- settings = part->settings();
+ part = element->getDocument()->part();
+ settings = part ? part->settings() : 0;
paintDeviceMetrics = element->getDocument()->paintDeviceMetrics();
style = 0;
@@ -1628,7 +1630,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
{
style->setBackgroundAttachment(false);
// only use slow repaints if we actually have a background pixmap
- if( style->backgroundImage() )
+ if( style->backgroundImage() && view )
view->useSlowRepaints();
break;
}
@@ -2016,7 +2018,8 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
p = ABSOLUTE; break;
case CSS_VAL_FIXED:
{
- view->useSlowRepaints();
+ if ( view )
+ view->useSlowRepaints();
p = FIXED;
break;
}
diff --git a/WebCore/khtml/dom/dom_doc.cpp b/WebCore/khtml/dom/dom_doc.cpp
index 356c2cc..a4cfaa4 100644
--- a/WebCore/khtml/dom/dom_doc.cpp
+++ b/WebCore/khtml/dom/dom_doc.cpp
@@ -447,6 +447,14 @@ KHTMLView *Document::view() const
return static_cast<DocumentImpl*>(impl)->view();
}
+KHTMLPart *Document::part() const
+{
+ if (!impl) return 0;
+
+ return static_cast<DocumentImpl*>(impl)->part();
+}
+
+
DOMString Document::completeURL(const DOMString& url)
{
if ( !impl ) return url;
diff --git a/WebCore/khtml/dom/dom_doc.h b/WebCore/khtml/dom/dom_doc.h
index f812a55..e1dbc22 100644
--- a/WebCore/khtml/dom/dom_doc.h
+++ b/WebCore/khtml/dom/dom_doc.h
@@ -763,6 +763,8 @@ public:
*/
KHTMLView *view() const;
+ KHTMLPart *part() const;
+
/**
* Introduced in DOM Level 2
* This method is from the DocumentCSS interface
diff --git a/WebCore/khtml/ecma/kjs_dom.cpp b/WebCore/khtml/ecma/kjs_dom.cpp
index 6612c2f..3ef22fd 100644
--- a/WebCore/khtml/ecma/kjs_dom.cpp
+++ b/WebCore/khtml/ecma/kjs_dom.cpp
@@ -755,9 +755,9 @@ Value DOMDocument::getValueProperty(ExecState *exec, int token) const
case ReadyState:
{
DOM::DocumentImpl* docimpl = node.handle()->getDocument();
- if ( docimpl && docimpl->view() )
+ if ( docimpl )
{
- KHTMLPart* part = docimpl->view()->part();
+ KHTMLPart* part = docimpl->part();
if ( part ) {
if (part->d->m_bComplete) return String("complete");
if (docimpl->parsing()) return String("loading");
@@ -1317,8 +1317,8 @@ bool KJS::checkNodeSecurity(ExecState *exec, const DOM::Node& n)
return false;
// Check to see if the currently executing interpreter is allowed to access the specified node
- KHTMLView *view = n.handle()->getDocument()->view();
- Window* win = view && view->part() ? Window::retrieveWindow(view->part()) : 0L;
+ KHTMLPart *part = n.handle()->getDocument()->part();
+ Window* win = part ? Window::retrieveWindow(part) : 0L;
if ( !win || !win->isSafeScript(exec) )
return false;
return true;
diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp
index b6b2740..3d0b8fa 100644
--- a/WebCore/khtml/ecma/kjs_html.cpp
+++ b/WebCore/khtml/ecma/kjs_html.cpp
@@ -71,22 +71,19 @@ Value KJS::HTMLDocFunction::tryCall(ExecState *exec, Object &thisObj, const List
case HTMLDocument::Open:
// For compatibility with other browsers, pass open calls with parameters to the window.
if (args.size() > 1) {
- KHTMLView *view = static_cast<DOM::DocumentImpl *>(doc.handle())->view();
- if (view) {
- KHTMLPart *part = view->part();
- if (part) {
- Window *window = Window::retrieveWindow(part);
- if (window) {
- Object functionObject = Object::dynamicCast(window->get(exec, "open"));
- if (functionObject.isNull() || !functionObject.implementsCall()) {
- Object exception = Error::create(exec, TypeError);
- exec->setException(exception);
- return exception;
- }
- Object windowObject(window);
- return functionObject.call(exec, windowObject, args);
- }
- }
+ KHTMLPart *part = static_cast<DOM::DocumentImpl *>(doc.handle())->part();
+ if (part) {
+ Window *window = Window::retrieveWindow(part);
+ if (window) {
+ Object functionObject = Object::dynamicCast(window->get(exec, "open"));
+ if (functionObject.isNull() || !functionObject.implementsCall()) {
+ Object exception = Error::create(exec, TypeError);
+ exec->setException(exception);
+ return exception;
+ }
+ Object windowObject(window);
+ return functionObject.call(exec, windowObject, args);
+ }
}
return Undefined();
}
@@ -201,8 +198,6 @@ Value KJS::HTMLDocument::tryGet(ExecState *exec, const Identifier &propertyName)
case Body:
return getDOMNode(exec,doc.body());
case Location:
- Q_ASSERT(view);
- Q_ASSERT(view->part());
if ( view && view->part() )
{
Window* win = Window::retrieveWindow(view->part());
@@ -362,11 +357,9 @@ void KJS::HTMLDocument::putValue(ExecState *exec, int token, const Value& value,
doc.setCookie(value.toString(exec).string());
break;
case Location: {
- KHTMLView *view = static_cast<DOM::DocumentImpl *>( doc.handle() )->view();
- Q_ASSERT(view);
- if (view)
+ KHTMLPart *part = static_cast<DOM::DocumentImpl *>( doc.handle() )->part();
+ if (part)
{
- KHTMLPart *part = view->part();
QString str = value.toString(exec).qstring();
// When assinging location, IE and Mozilla both resolve the URL
@@ -1108,13 +1101,13 @@ Value KJS::HTMLElement::tryGet(ExecState *exec, const Identifier &propertyName)
case ID_FRAME:
case ID_IFRAME: {
DOM::DocumentImpl* doc = static_cast<DOM::HTMLFrameElementImpl *>(element.handle())->contentDocument();
- if ( doc && doc->view() ) {
- KHTMLPart* part = doc->view()->part();
+ if ( doc ) {
+ KHTMLPart* part = doc->part();
if ( part ) {
- Object globalObject = Object::dynamicCast( Window::retrieve( part ) );
- // Calling hasProperty on a Window object doesn't work, it always says true.
- // Hence we need to use getDirect instead.
- if ( !globalObject.isNull() && static_cast<ObjectImp *>(globalObject.imp())->getDirect( propertyName ) )
+ Object globalObject = Object::dynamicCast( Window::retrieve( part ) );
+ // Calling hasProperty on a Window object doesn't work, it always says true.
+ // Hence we need to use getDirect instead.
+ if ( !globalObject.isNull() && static_cast<ObjectImp *>(globalObject.imp())->getDirect( propertyName ) )
return globalObject.get( exec, propertyName );
}
}
@@ -3256,8 +3249,8 @@ void Image::putValue(ExecState *exec, int token, const Value& value, int /*attr*
void Image::notifyFinished(khtml::CachedObject *)
{
- if (onLoadListener) {
- DOM::Event ev = doc->view()->part()->document().createEvent("HTMLEvents");
+ if (onLoadListener && doc->part()) {
+ DOM::Event ev = doc->part()->document().createEvent("HTMLEvents");
ev.initEvent("load", true, true);
onLoadListener->handleEvent(ev, true);
}
diff --git a/WebCore/khtml/ecma/kjs_traversal.cpp b/WebCore/khtml/ecma/kjs_traversal.cpp
index 408d9cd..8a18069 100644
--- a/WebCore/khtml/ecma/kjs_traversal.cpp
+++ b/WebCore/khtml/ecma/kjs_traversal.cpp
@@ -307,7 +307,7 @@ JSNodeFilter::~JSNodeFilter()
short JSNodeFilter::acceptNode(const DOM::Node &n)
{
- KHTMLPart *part = static_cast<DOM::DocumentImpl *>( n.handle()->docPtr()->document() )->view()->part();
+ KHTMLPart *part = static_cast<DOM::DocumentImpl *>( n.handle()->docPtr()->document() )->part();
KJSProxy *proxy = KJSProxy::proxy( part );
if (proxy) {
ExecState *exec = proxy->interpreter()->globalExec();
diff --git a/WebCore/khtml/ecma/xmlhttprequest.cpp b/WebCore/khtml/ecma/xmlhttprequest.cpp
index 3552144..7434326 100644
--- a/WebCore/khtml/ecma/xmlhttprequest.cpp
+++ b/WebCore/khtml/ecma/xmlhttprequest.cpp
@@ -187,8 +187,8 @@ void XMLHttpRequest::changeState(XMLHttpRequestState newState)
if (state != newState) {
state = newState;
- if (onReadyStateChangeListener != 0) {
- DOM::Event ev = doc->view()->part()->document().createEvent("HTMLEvents");
+ if (onReadyStateChangeListener != 0 && doc->part()) {
+ DOM::Event ev = doc->part()->document().createEvent("HTMLEvents");
ev.initEvent("readystatechange", true, true);
onReadyStateChangeListener->handleEvent(ev, true);
}
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index c8a509c..ec8f913 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -159,14 +159,16 @@ void HTMLBodyElementImpl::insertedIntoDocument()
{
HTMLElementImpl::insertedIntoDocument();
+ // FIXME: perhaps all this stuff should be in attach() instead of here...
+
KHTMLView* w = getDocument()->view();
- if(w->marginWidth() != -1) {
+ if(w && w->marginWidth() != -1) {
QString s;
s.sprintf( "%d", w->marginWidth() );
addCSSLength(CSS_PROP_MARGIN_LEFT, s);
addCSSLength(CSS_PROP_MARGIN_RIGHT, s);
}
- if(w->marginHeight() != -1) {
+ if(w && w->marginHeight() != -1) {
QString s;
s.sprintf( "%d", w->marginHeight() );
addCSSLength(CSS_PROP_MARGIN_TOP, s);
@@ -209,6 +211,10 @@ bool HTMLFrameElementImpl::isURLAllowed(const DOMString &URLString) const
KHTMLView *w = getDocument()->view();
+ if (!w) {
+ return false;
+ }
+
KURL newURL(getDocument()->completeURL(URLString.string()));
newURL.setRef(QString::null);
@@ -383,9 +389,12 @@ void HTMLFrameElementImpl::attach()
if (!m_render)
return;
- KHTMLView* w = getDocument()->view();
+ KHTMLPart *part = getDocument()->part();
+
+ if (!part)
+ return;
- w->part()->incrementFrameCount();
+ part->incrementFrameCount();
DOMString relativeURL = url;
if (relativeURL.isEmpty()) {
@@ -393,19 +402,20 @@ void HTMLFrameElementImpl::attach()
}
// we need a unique name for every frame in the frameset. Hope that's unique enough.
- if(name.isEmpty() || w->part()->frameExists( name.string() ) )
- name = DOMString(w->part()->requestFrameName());
+ if(name.isEmpty() || part->frameExists( name.string() ) )
+ name = DOMString(part->requestFrameName());
// load the frame contents
- w->part()->requestFrame( static_cast<RenderFrame*>(m_render), relativeURL.string(), name.string() );
+ part->requestFrame( static_cast<RenderFrame*>(m_render), relativeURL.string(), name.string() );
}
void HTMLFrameElementImpl::detach()
{
- if (m_render) {
- KHTMLView* w = getDocument()->view();
- w->part()->decrementFrameCount();
- KHTMLPart *framePart = w->part()->findFrame( name.string() );
+ KHTMLPart *part = getDocument()->part();
+
+ if (m_render && part) {
+ part->decrementFrameCount();
+ KHTMLPart *framePart = part->findFrame( name.string() );
if (framePart)
framePart->frameDetached();
}
@@ -438,10 +448,10 @@ void HTMLFrameElementImpl::setFocus(bool received)
DocumentImpl* HTMLFrameElementImpl::contentDocument() const
{
- KHTMLView* w = getDocument()->view();
+ KHTMLPart* p = getDocument()->part();
- if (w) {
- KHTMLPart *part = w->part()->findFrame( name.string() );
+ if (p) {
+ KHTMLPart *part = p->findFrame( name.string() );
if (part) {
return part->xmlDocImpl();
}
@@ -675,12 +685,12 @@ void HTMLIFrameElementImpl::attach()
{
HTMLElementImpl::attach();
- if (m_render) {
+ KHTMLPart *part = getDocument()->part();
+ if (m_render && part) {
// we need a unique name for every frame in the frameset. Hope that's unique enough.
- KHTMLView* w = getDocument()->view();
- w->part()->incrementFrameCount();
- if(name.isEmpty() || w->part()->frameExists( name.string() ))
- name = DOMString(w->part()->requestFrameName());
+ part->incrementFrameCount();
+ if(name.isEmpty() || part->frameExists( name.string() ))
+ name = DOMString(part->requestFrameName());
static_cast<RenderPartObject*>(m_render)->updateWidget();
needWidgetUpdate = false;
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index 7347a93..31e7a4c 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -130,21 +130,21 @@ HTMLDocumentImpl::~HTMLDocumentImpl()
DOMString HTMLDocumentImpl::referrer() const
{
- if ( view() )
+ if ( part() )
#if APPLE_CHANGES
- return KWQ(view()->part())->incomingReferrer();
+ return KWQ(part())->incomingReferrer();
#else
// This is broken; returns the referrer used for links within this page (basically
// the same as the URL), not the referrer used for loading this page itself.
- return view()->part()->referrer();
+ return part()->referrer();
#endif
return DOMString();
}
DOMString HTMLDocumentImpl::lastModified() const
{
- if ( view() )
- return view()->part()->lastModified();
+ if ( part() )
+ return part()->lastModified();
return DOMString();
}
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 8182251..30137fe 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -304,7 +304,7 @@ QByteArray HTMLFormElementImpl::formData(bool& ok)
str.replace(',', ' ');
QStringList charsets = QStringList::split(' ', str);
QTextCodec* codec = 0;
- KHTMLView *view = getDocument()->view();
+ KHTMLPart *part = getDocument()->part();
for ( QStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it )
{
QString enc = (*it);
@@ -312,8 +312,8 @@ QByteArray HTMLFormElementImpl::formData(bool& ok)
{
// use standard document encoding
enc = "ISO-8859-1";
- if(view && view->part())
- enc = view->part()->encoding();
+ if (part)
+ enc = part->encoding();
}
if((codec = KGlobal::charsets()->codecForName(enc.latin1())))
break;
@@ -390,8 +390,7 @@ QByteArray HTMLFormElementImpl::formData(bool& ok)
if(!static_cast<HTMLInputElementImpl*>(current)->value().isEmpty())
{
#if APPLE_CHANGES
- KWQKHTMLPart *part = KWQ(current->getDocument()->view()->part());
- QString mimeType = part->mimeTypeForFileName(onlyfilename);
+ QString mimeType = part ? KWQ(part)->mimeTypeForFileName(onlyfilename) : QString();
#else
KMimeType::Ptr ptr = KMimeType::findByURL(KURL(path));
QString mimeType = ptr->name();
@@ -471,8 +470,8 @@ void HTMLFormElementImpl::setBoundary( const DOMString& bound )
bool HTMLFormElementImpl::prepareSubmit()
{
- KHTMLView *view = getDocument()->view();
- if(m_insubmit || !view || !view->part() || view->part()->onlyLocalReferences())
+ KHTMLPart *part = getDocument()->part();
+ if(m_insubmit || !part || part->onlyLocalReferences())
return m_insubmit;
m_insubmit = true;
@@ -492,7 +491,8 @@ bool HTMLFormElementImpl::prepareSubmit()
void HTMLFormElementImpl::submit( bool activateSubmitButton )
{
KHTMLView *view = getDocument()->view();
- if (!view || !view->part()) {
+ KHTMLPart *part = getDocument()->part();
+ if (!view || !part) {
return;
}
@@ -511,7 +511,7 @@ void HTMLFormElementImpl::submit( bool activateSubmitButton )
bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
#if APPLE_CHANGES
- KWQ(view->part())->clearRecordedFormValues();
+ KWQ(part)->clearRecordedFormValues();
#endif
for (QPtrListIterator<HTMLGenericFormElementImpl> it(formElements); it.current(); ++it) {
HTMLGenericFormElementImpl* current = it.current();
@@ -523,7 +523,7 @@ void HTMLFormElementImpl::submit( bool activateSubmitButton )
if (input->inputType() == HTMLInputElementImpl::TEXT
|| input->inputType() == HTMLInputElementImpl::PASSWORD)
{
- KWQ(view->part())->recordFormValue(input->name().string(), input->value().string(), this);
+ KWQ(part)->recordFormValue(input->name().string(), input->value().string(), this);
}
}
#else
@@ -553,13 +553,13 @@ void HTMLFormElementImpl::submit( bool activateSubmitButton )
QByteArray form_data = formData(ok);
if (ok) {
if(m_post) {
- view->part()->submitForm( "post", m_url.string(), form_data,
+ part->submitForm( "post", m_url.string(), form_data,
m_target.string(),
enctype().string(),
boundary().string() );
}
else {
- view->part()->submitForm( "get", m_url.string(), form_data,
+ part->submitForm( "get", m_url.string(), form_data,
m_target.string() );
}
}
@@ -573,8 +573,8 @@ void HTMLFormElementImpl::submit( bool activateSubmitButton )
void HTMLFormElementImpl::reset( )
{
- KHTMLView *view = getDocument()->view();
- if(m_inreset || !view || !view->part()) return;
+ KHTMLPart *part = getDocument()->part();
+ if(m_inreset || !part) return;
m_inreset = true;
@@ -859,7 +859,8 @@ bool HTMLGenericFormElementImpl::isKeyboardFocusable() const
((static_cast<RenderWidget*>(m_render)->widget()->focusPolicy() == QWidget::TabFocus) ||
(static_cast<RenderWidget*>(m_render)->widget()->focusPolicy() == QWidget::StrongFocus));
}
- return getDocument()->view()->part()->tabsToAllControls();
+ if (getDocument()->part())
+ return getDocument()->part()->tabsToAllControls();
}
return false;
}
@@ -888,9 +889,9 @@ void HTMLGenericFormElementImpl::defaultEventHandler(EventImpl *evt)
if (evt->target()==this)
{
// Report focus in/out changes to the browser extension (editable widgets only)
- KHTMLView *view = getDocument()->view();
- if (evt->id()==EventImpl::DOMFOCUSIN_EVENT && isEditable() && view && m_render && m_render->isWidget()) {
- KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>(view->part()->browserExtension());
+ KHTMLPart *part = getDocument()->part();
+ if (evt->id()==EventImpl::DOMFOCUSIN_EVENT && isEditable() && part && m_render && m_render->isWidget()) {
+ KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>(part->browserExtension());
QWidget *widget = static_cast<RenderWidget*>(m_render)->widget();
if (ext)
ext->editableWidgetFocused(widget);
@@ -924,8 +925,8 @@ void HTMLGenericFormElementImpl::defaultEventHandler(EventImpl *evt)
}
#endif
- if (evt->id()==EventImpl::DOMFOCUSOUT_EVENT && isEditable() && view && m_render && m_render->isWidget()) {
- KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>(view->part()->browserExtension());
+ if (evt->id()==EventImpl::DOMFOCUSOUT_EVENT && isEditable() && part && m_render && m_render->isWidget()) {
+ KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>(part->browserExtension());
QWidget *widget = static_cast<RenderWidget*>(m_render)->widget();
if (ext)
ext->editableWidgetBlurred(widget);
diff --git a/WebCore/khtml/html/html_headimpl.cpp b/WebCore/khtml/html/html_headimpl.cpp
index 96c07f4..e87d107 100644
--- a/WebCore/khtml/html/html_headimpl.cpp
+++ b/WebCore/khtml/html/html_headimpl.cpp
@@ -95,8 +95,8 @@ void HTMLBaseElementImpl::process()
if (!inDocument())
return;
- if(!m_href.isEmpty())
- getDocument()->setBaseURL( KURL( getDocument()->view()->part()->url(), m_href.string() ).url() );
+ if(!m_href.isEmpty() && getDocument()->part())
+ getDocument()->setBaseURL( KURL( getDocument()->part()->url(), m_href.string() ).url() );
if(!m_target.isEmpty())
getDocument()->setBaseTarget( m_target.string() );
@@ -201,7 +201,7 @@ void HTMLLinkElementImpl::process()
QString type = m_type.string().lower();
QString rel = m_rel.string().lower();
- KHTMLPart* part = getDocument()->view() ? getDocument()->view()->part() : 0;
+ KHTMLPart* part = getDocument()->part();
// IE extension: location of small icon for locationbar / bookmarks
#if APPLE_CHANGES
diff --git a/WebCore/khtml/html/html_inlineimpl.cpp b/WebCore/khtml/html/html_inlineimpl.cpp
index 9695575..fc174f3 100644
--- a/WebCore/khtml/html/html_inlineimpl.cpp
+++ b/WebCore/khtml/html/html_inlineimpl.cpp
@@ -79,7 +79,10 @@ bool HTMLAnchorElementImpl::isKeyboardFocusable() const
if (!isFocusable())
return false;
- return getDocument()->view()->part()->tabsToLinks();
+ if (!getDocument()->part())
+ return false;
+
+ return getDocument()->part()->tabsToLinks();
}
NodeImpl::Id HTMLAnchorElementImpl::id() const
@@ -180,9 +183,9 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt)
state |= Qt::ControlButton;
}
- if (getDocument() && getDocument()->view()) {
+ if (getDocument() && getDocument()->view() && getDocument()->part()) {
getDocument()->view()->resetCursor();
- getDocument()->view()->part()->
+ getDocument()->part()->
urlSelected( url, button, state, utarget );
}
}
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index f767a83..2a15a6f 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -105,9 +105,9 @@ bool HTMLAppletElementImpl::rendererIsNeeded(RenderStyle *style)
RenderObject *HTMLAppletElementImpl::createRenderer(RenderArena *arena, RenderStyle *style)
{
#ifndef Q_WS_QWS // FIXME(E)? I don't think this is possible with Qt Embedded...
- KHTMLView *view = getDocument()->view();
+ KHTMLPart *part = getDocument()->part();
- if( view->part()->javaEnabled() )
+ if( part && part->javaEnabled() )
{
QMap<QString, QString> args;
@@ -180,8 +180,8 @@ Bindings::Instance *HTMLAppletElementImpl::getAppletInstance() const
// Call into the part (and over the bridge) to pull the Bindings::Instance
// from the guts of the Java VM.
void *_view = r->widget()->getView();
- KHTMLView* v = getDocument()->view();
- appletInstance = KWQ(v->part())->getAppletInstanceForView((NSView *)_view);
+ KHTMLPart* part = getDocument()->part();
+ appletInstance = part ? KWQ(part)->getAppletInstanceForView((NSView *)_view) : 0;
}
return appletInstance;
}
@@ -267,8 +267,10 @@ void HTMLEmbedElementImpl::parseAttribute(AttributeImpl *attr)
bool HTMLEmbedElementImpl::rendererIsNeeded(RenderStyle *style)
{
- KHTMLView* w = getDocument()->view();
- return w->part()->pluginsEnabled() && parentNode()->id() != ID_OBJECT;
+ KHTMLPart *part = getDocument()->part();
+ if (!part)
+ return false;
+ return part->pluginsEnabled() && parentNode()->id() != ID_OBJECT;
}
RenderObject *HTMLEmbedElementImpl::createRenderer(RenderArena *arena, RenderStyle *style)
@@ -365,8 +367,8 @@ bool HTMLObjectElementImpl::rendererIsNeeded(RenderStyle *style)
return HTMLElementImpl::rendererIsNeeded(style);
}
- KHTMLView* w = getDocument()->view();
- if (!w->part()->pluginsEnabled()) {
+ KHTMLPart* part = getDocument()->part();
+ if (!part || !part->pluginsEnabled()) {
return false;
}
#if APPLE_CHANGES
diff --git a/WebCore/khtml/html/htmltokenizer.cpp b/WebCore/khtml/html/htmltokenizer.cpp
index 02c3380..7c4c058 100644
--- a/WebCore/khtml/html/htmltokenizer.cpp
+++ b/WebCore/khtml/html/htmltokenizer.cpp
@@ -550,7 +550,7 @@ void HTMLTokenizer::scriptExecution( const QString& str, QString scriptURL,
int baseLine)
{
#if APPLE_CHANGES
- if (!view->part())
+ if (!view || !view->part())
return;
#endif
bool oldscript = script;
@@ -1247,7 +1247,8 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
scriptSrc = QString::null;
scriptSrcCharset = QString::null;
if ( currToken.attrs && /* potentially have a ATTR_SRC ? */
- parser->doc()->view()->part()->jScriptEnabled() && /* jscript allowed at all? */
+ parser->doc()->part() &&
+ parser->doc()->part()->jScriptEnabled() && /* jscript allowed at all? */
view /* are we a regular tokenizer or just for innerHTML ? */
) {
if ( ( a = currToken.attrs->getAttributeItem( ATTR_SRC ) ) )
@@ -1255,7 +1256,7 @@ void HTMLTokenizer::parseTag(DOMStringIt &src)
if ( ( a = currToken.attrs->getAttributeItem( ATTR_CHARSET ) ) )
scriptSrcCharset = a->value().string().stripWhiteSpace();
if ( scriptSrcCharset.isEmpty() )
- scriptSrcCharset = parser->doc()->view()->part()->encoding();
+ scriptSrcCharset = parser->doc()->part()->encoding();
if (!(a = currToken.attrs->getAttributeItem( ATTR_LANGUAGE )))
a = currToken.attrs->getAttributeItem(ATTR_TYPE);
}
diff --git a/WebCore/khtml/rendering/render_applet.cpp b/WebCore/khtml/rendering/render_applet.cpp
index 256b5e1..06094cf 100644
--- a/WebCore/khtml/rendering/render_applet.cpp
+++ b/WebCore/khtml/rendering/render_applet.cpp
@@ -49,9 +49,8 @@ RenderApplet::RenderApplet(HTMLElementImpl *applet, const QMap<QString, QString>
setInline(true);
KJavaAppletContext *context = 0;
- KHTMLView *_view = applet->getDocument()->view();
- if ( _view ) {
- KHTMLPart *part = _view->part();
+ KHTMLPart *part = applet->getDocument()->part();
+ if ( part ) {
context = part->createJavaContext();
}
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index e4f2fa4..9c6a65e 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -594,11 +594,11 @@ void DocumentImpl::setTitle(DOMString _title)
{
m_title = _title;
- if (!view() || !view()->part())
+ if (!part())
return;
#if APPLE_CHANGES
- KWQ(view()->part())->setTitle(_title);
+ KWQ(part())->setTitle(_title);
#else
QString titleStr = m_title.string();
for (int i = 0; i < titleStr.length(); ++i)
@@ -606,7 +606,7 @@ void DocumentImpl::setTitle(DOMString _title)
titleStr[i] = ' ';
titleStr = titleStr.stripWhiteSpace();
titleStr.compose();
- if ( !view()->part()->parentPart() ) {
+ if ( !part()->parentPart() ) {
if (titleStr.isNull() || titleStr.isEmpty()) {
// empty title... set window caption as the URL
KURL url = m_url;
@@ -615,7 +615,7 @@ void DocumentImpl::setTitle(DOMString _title)
titleStr = url.url();
}
- emit view()->part()->setWindowCaption( KStringHandler::csqueeze( titleStr, 128 ) );
+ emit part()->setWindowCaption( KStringHandler::csqueeze( titleStr, 128 ) );
}
#endif
}
@@ -921,6 +921,11 @@ QStringList DocumentImpl::docState()
return s;
}
+KHTMLPart *DocumentImpl::part() const
+{
+ return m_view ? m_view->part() : 0;
+}
+
RangeImpl *DocumentImpl::createRange()
{
return new RangeImpl( docPtr() );
@@ -1232,7 +1237,7 @@ void DocumentImpl::close()
// First fire the onload.
bool doload = !parsing() && m_tokenizer && !m_processingLoadEvent;
- bool wasNotRedirecting = !view() || view()->part()->d->m_scheduledRedirection == noRedirectionScheduled || view()->part()->d->m_scheduledRedirection == historyNavigationScheduled;
+ bool wasNotRedirecting = !part() || part()->d->m_scheduledRedirection == noRedirectionScheduled || part()->d->m_scheduledRedirection == historyNavigationScheduled;
m_processingLoadEvent = true;
if (body() && doload) {
@@ -1628,7 +1633,7 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
{
assert(!equiv.isNull() && !content.isNull());
- KHTMLView *v = getDocument()->view();
+ KHTMLPart *part = getDocument()->part();
if (strcasecmp(equiv, "default-style") == 0) {
// The preferred style set has been overridden as per section
@@ -1637,11 +1642,11 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
// For more info, see the test at:
// http://www.hixie.ch/tests/evil/css/import/main/preferred.html
// -dwh
- v->part()->d->m_sheetUsed = content.string();
+ part->d->m_sheetUsed = content.string();
m_preferredStylesheetSet = content;
updateStyleSelector();
}
- else if(strcasecmp(equiv, "refresh") == 0 && v->part()->metaRefreshEnabled())
+ else if(strcasecmp(equiv, "refresh") == 0 && part->metaRefreshEnabled())
{
// get delay and url
QString str = content.string().stripWhiteSpace();
@@ -1655,10 +1660,10 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
int delay = 0;
delay = str.toInt(&ok);
#if APPLE_CHANGES
- // We want a new history item if the refresh timeout > 1 second
- if(ok) v->part()->scheduleRedirection(delay, v->part()->url().url(), delay <= 1);
+ // We want a new history item if the refresh timeout > 1 second
+ if(ok && part) part->scheduleRedirection(delay, part->url().url(), delay <= 1);
#else
- if(ok) v->part()->scheduleRedirection(delay, v->part()->url().url() );
+ if(ok && part) part->scheduleRedirection(delay, part->url().url() );
#endif
} else {
double delay = 0;
@@ -1672,12 +1677,12 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
str = str.stripWhiteSpace();
if ( str.length() && str[0] == '=' ) str = str.mid( 1 ).stripWhiteSpace();
str = parseURL( DOMString(str) ).string();
- if ( ok )
+ if ( ok && part )
#if APPLE_CHANGES
// We want a new history item if the refresh timeout > 1 second
- v->part()->scheduleRedirection(delay, getDocument()->completeURL( str ), delay <= 1);
+ part->scheduleRedirection(delay, getDocument()->completeURL( str ), delay <= 1);
#else
- v->part()->scheduleRedirection(delay, getDocument()->completeURL( str ));
+ part->scheduleRedirection(delay, getDocument()->completeURL( str ));
#endif
}
}
@@ -1685,14 +1690,13 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
{
QString str = content.string().stripWhiteSpace();
time_t expire_date = str.toLong();
- KURL url = v->part()->url();
if (m_docLoader)
m_docLoader->setExpireDate(expire_date);
}
- else if(strcasecmp(equiv, "pragma") == 0 || strcasecmp(equiv, "cache-control") == 0)
+ else if(strcasecmp(equiv, "pragma") == 0 || strcasecmp(equiv, "cache-control") == 0 && part)
{
QString str = content.string().lower().stripWhiteSpace();
- KURL url = v->part()->url();
+ KURL url = part->url();
if ((str == "no-cache") && url.protocol().startsWith("http"))
{
KIO::http_update_cache(url, true, 0);
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index d270f2c..63f39ca 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -46,6 +46,7 @@
class QPaintDevice;
class QPaintDeviceMetrics;
class KHTMLView;
+class KHTMLPart;
class Tokenizer;
class RenderArena;
@@ -223,6 +224,7 @@ public:
QStringList &restoreState( ) { return m_state; }
KHTMLView *view() const { return m_view; }
+ KHTMLPart *part() const;
RangeImpl *createRange();
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 50320a7..a5c082f 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -487,6 +487,8 @@ bool NodeImpl::dispatchEvent(EventImpl *evt, int &exceptioncode, bool tempEvent)
{
evt->setTarget(this);
+ KHTMLPart *part = document->document()->part();
+
// Since event handling code could cause this object to be deleted, grab a reference to the view now
KHTMLView *view = document->document()->view();
if (view)
@@ -497,13 +499,8 @@ bool NodeImpl::dispatchEvent(EventImpl *evt, int &exceptioncode, bool tempEvent)
// If tempEvent is true, this means that the DOM implementation will not be storing a reference to the event, i.e.
// there is no way to retrieve it from javascript if a script does not already have a reference to it in a variable.
// So there is no need for the interpreter to keep the event in it's cache
-#if APPLE_CHANGES
- if (tempEvent && view && view->part() && view->part()->jScript())
- view->part()->jScript()->finishedWithEvent(evt);
-#else
- if (tempEvent && view && view->part()->jScript())
- view->part()->jScript()->finishedWithEvent(evt);
-#endif
+ if (tempEvent && part && part->jScript())
+ part->jScript()->finishedWithEvent(evt);
if (view)
view->deref();
diff --git a/WebCore/kwq/KWQAccObject.mm b/WebCore/kwq/KWQAccObject.mm
index fc7502a..773177f 100644
--- a/WebCore/kwq/KWQAccObject.mm
+++ b/WebCore/kwq/KWQAccObject.mm
@@ -239,22 +239,19 @@ using khtml::RenderWidget;
NodeImpl* e = m_renderer->element();
DocumentImpl* d = m_renderer->document();
if (e && d) {
- KHTMLView* v = d->view();
- if (v) {
- KHTMLPart* p = v->part();
- if (p) {
- Range r(p->document());
- if (m_renderer->isText()) {
- r.setStartBefore(e);
- r.setEndAfter(e);
- return p->text(r).getNSString();
- }
- if (e->firstChild()) {
- r.setStartBefore(e->firstChild());
- r.setEndAfter(e->lastChild());
- return p->text(r).getNSString();
- }
- }
+ KHTMLPart* p = d->part();
+ if (p) {
+ Range r(p->document());
+ if (m_renderer->isText()) {
+ r.setStartBefore(e);
+ r.setEndAfter(e);
+ return p->text(r).getNSString();
+ }
+ if (e->firstChild()) {
+ r.setStartBefore(e->firstChild());
+ r.setEndAfter(e->lastChild());
+ return p->text(r).getNSString();
+ }
}
}
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index ef3267e..5ee86c6 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -1277,7 +1277,7 @@ WebCoreBridge *KWQKHTMLPart::bridgeForWidget(const QWidget *widget)
KWQKHTMLPart *KWQKHTMLPart::partForNode(NodeImpl *node)
{
ASSERT_ARG(node, node);
- return KWQ(node->getDocument()->view()->part());
+ return KWQ(node->getDocument()->part());
}
NSView *KWQKHTMLPart::documentViewForNode(DOM::NodeImpl *node)
@@ -2464,7 +2464,7 @@ NSAttributedString *KWQKHTMLPart::attributedString(NodeImpl *_start, int startOf
// will have corrected any illegally nested <a> elements.
if (linkStartNode && n.handle() == linkStartNode){
DOMString href = parseURL(linkStartNode->getAttribute(ATTR_HREF));
- KURL kURL = KWQ(linkStartNode->getDocument()->view()->part())->completeURL(href.string());
+ KURL kURL = KWQ(linkStartNode->getDocument()->part())->completeURL(href.string());
NSURL *URL = kURL.getNSURL();
[result addAttribute:NSLinkAttributeName value:URL range:NSMakeRange(linkStartLocation, [result length]-linkStartLocation)];
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list