patch for "double get" problem with changing src of iframes
Darin Adler
darin at apple.com
Sun Dec 14 18:09:24 CET 2003
This fixes a problem where we would get the same web page twice when
changing the src of an iframe. I don't have a simple easy to reproduce
test case for this, but the problem ended up being pretty clear.
I imagine this is a part of the code that's gotten very different
between the tip of tree of WebCore and khtml in the kde repository, so
this probably won't be applicable for you guys, but please take a look
anyway.
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/ChangeLog,v
retrieving revision 1.2392
diff -p -u -u -p -r1.2392 ChangeLog
--- ChangeLog 2003/12/14 00:43:13 1.2392
+++ ChangeLog 2003/12/14 17:01:58
@@ -1,3 +1,23 @@
+2003-12-14 Darin Adler <darin at apple.com>
+
+ Reviewed by Maciej.
+
+ - fixed 3332280: REGRESSION (74-85): setting src of iframe results in two GETs
+
+ * khtml/html/html_baseimpl.h: Added openURL virtual function.
+ * khtml/html/html_baseimpl.cpp:
+ (HTMLFrameElementImpl::updateForNewURL): Call openURL to do the meat of the work,
+ since it's different for frames and iframes.
+ (HTMLFrameElementImpl::openURL): Move the part that's different for frames in here.
+ (HTMLFrameElementImpl::parseAttribute): Call setLocation to share code.
+ (HTMLFrameElementImpl::setLocation): Do nothing if the location is not changing.
+ Not needed to fix this bug, but could eliminate other cases of extra GETs.
+ (HTMLIFrameElementImpl::parseAttribute): Remove special handling of SRC, because now
+ we will end up calling openURL, which will do the right thing for iframes.
+ (HTMLIFrameElementImpl::openURL): Instead of doing the change to the frame directly,
+ use updateWidget, since that's what we do for other changes to iframes. To trigger a
+ call to updateWidget(), set needWidgetUpdate and mark the node changed.
+
2003-12-13 Darin Adler <darin at apple.com>
Reviewed by Maciej.
Index: khtml/html/html_baseimpl.cpp
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/html/html_baseimpl.cpp,v
retrieving revision 1.47
diff -p -u -u -p -r1.47 khtml/html/html_baseimpl.cpp
--- khtml/html/html_baseimpl.cpp 2003/12/05 22:03:07 1.47
+++ khtml/html/html_baseimpl.cpp 2003/12/14 17:01:59
@@ -266,27 +266,30 @@ void HTMLFrameElementImpl::updateForNewU
return;
}
- DOMString relativeURL = url;
- if (relativeURL.isEmpty()) {
- relativeURL = "about:blank";
- }
-
- if (!isURLAllowed(relativeURL)) {
+ if (!isURLAllowed(url)) {
return;
}
+ openURL();
+}
+
+void HTMLFrameElementImpl::openURL()
+{
KHTMLView *w = getDocument()->view();
if (!w) {
return;
}
+ DOMString relativeURL = url;
+ if (relativeURL.isEmpty()) {
+ relativeURL = "about:blank";
+ }
+
// Load the frame contents.
KHTMLPart *part = w->part();
KHTMLPart *framePart = part->findFrame(name.string());
- KURL kurl = getDocument()->completeURL(relativeURL.string());
-
if (framePart) {
- framePart->openURL(kurl);
+ framePart->openURL(getDocument()->completeURL(relativeURL.string()));
} else {
part->requestFrame(static_cast<RenderFrame *>(m_render), relativeURL.string(), name.string());
}
@@ -298,8 +301,7 @@ void HTMLFrameElementImpl::parseAttribut
switch(attr->id())
{
case ATTR_SRC:
- url = khtml::parseURL(attr->val());
- updateForNewURL();
+ setLocation(khtml::parseURL(attr->val()));
break;
case ATTR_ID:
case ATTR_NAME:
@@ -425,6 +427,7 @@ void HTMLFrameElementImpl::detach()
void HTMLFrameElementImpl::setLocation( const DOMString& str )
{
+ if (url == str) return;
url = str;
updateForNewURL();
}
@@ -658,10 +661,6 @@ void HTMLIFrameElementImpl::parseAttribu
case ATTR_HEIGHT:
addCSSLength( CSS_PROP_HEIGHT, attr->value() );
break;
- case ATTR_SRC:
- needWidgetUpdate = true; // ### do this for scrolling, margins etc?
- HTMLFrameElementImpl::parseAttribute( attr );
- break;
case ATTR_ALIGN:
addHTMLAlignment( attr->value() );
break;
@@ -706,3 +705,8 @@ void HTMLIFrameElementImpl::recalcStyle(
HTMLElementImpl::recalcStyle( ch );
}
+void HTMLIFrameElementImpl::openURL()
+{
+ needWidgetUpdate = true;
+ setChanged();
+}
Index: khtml/html/html_baseimpl.h
===================================================================
RCS file: /local/home/cvs/Labyrinth/WebCore/khtml/html/html_baseimpl.h,v
retrieving revision 1.16
diff -p -u -u -p -r1.16 khtml/html/html_baseimpl.h
--- khtml/html/html_baseimpl.h 2003/10/31 23:40:37 1.16
+++ khtml/html/html_baseimpl.h 2003/12/14 17:01:59
@@ -103,6 +103,7 @@ public:
protected:
bool isURLAllowed(const DOMString &) const;
+ virtual void openURL();
DOMString url;
DOMString name;
@@ -115,7 +116,7 @@ protected:
bool frameBorderSet : 1;
bool noresize : 1;
- private:
+private:
void updateForNewURL();
};
@@ -204,11 +205,12 @@ public:
virtual void recalcStyle( StyleChange ch );
protected:
+ virtual void openURL();
+
bool needWidgetUpdate;
};
-}; //namespace
+} //namespace
#endif
-
-------------- next part --------------
-- Darin
More information about the Khtml-devel
mailing list