From 333db7f4989c00a9fc6217c365c1fd81ff544359 Mon Sep 17 00:00:00 2001 From: ggaren Date: Mon, 2 Oct 2006 01:02:49 +0000 Subject: [PATCH] LayoutTests: Added test for the viewource attribute, which applies to and + + + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index fa734792ab08..0c86a8bb447c 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,26 @@ +2006-10-01 Geoffrey Garen + + Reviewed by Maciej. + + More frame/iframe merging. + + - Removed needWidgetUpdate and related code. needWidgetUpdate is always + false, so this was dead code. + - Removed FIXME about setInViewSourceMode inside openURL(). openURL(), rather + than attach(), is the correct place for setInViewSourceMode, because + openURL() is the function that creates our frame. + - Moved IFRAME insertedIntoDocument() code into FRAME, and removed FRAME + code that did the same thing in other places. + - Made FRAME's attach() method suffuciently generic so that IFRAME could + call up to it, rather than skipping its superclass and calling up directly + to ELEMENT. + - Changed a few IFRAME up-calls to ELEMENT into up-calls to FRAME. + - Replaced ad hoc frame loading code in FRAME::attach() with call to + openURL(), the designated frame loading function. + + Layout tests pass. I added a layout test for viewsource mode, since I + broke it in the course of writing this patch. + 2006-10-01 Anders Carlsson Reviewed by Geoff. diff --git a/WebCore/html/HTMLFrameElement.cpp b/WebCore/html/HTMLFrameElement.cpp index 210feed1d9f7..d43d3b74a63e 100644 --- a/WebCore/html/HTMLFrameElement.cpp +++ b/WebCore/html/HTMLFrameElement.cpp @@ -117,9 +117,6 @@ void HTMLFrameElement::openURL() document()->frame()->requestFrame(this, m_URL, m_name); - // FIXME: This is a relic from how HTMLIFrameElement used to do things. - // It's probably unnecessary, since viewsource mode doesn't really work, - // and both parseMappedAttribute and attach include the same check. if (contentFrame()) contentFrame()->setInViewSourceMode(viewSourceMode()); } @@ -183,44 +180,33 @@ RenderObject *HTMLFrameElement::createRenderer(RenderArena *arena, RenderStyle * return new (arena) RenderFrame(this); } -void HTMLFrameElement::attach() +void HTMLFrameElement::insertedIntoDocument() { + HTMLElement::insertedIntoDocument(); + m_name = getAttribute(nameAttr); if (m_name.isNull()) m_name = getAttribute(idAttr); - // inherit default settings from parent frameset - for (Node *node = parentNode(); node; node = node->parentNode()) - if (node->hasTagName(framesetTag)) { - HTMLFrameSetElement* frameset = static_cast(node); - if (!m_frameBorderSet) - m_frameBorder = frameset->frameBorder(); - if (!m_noResize) - m_noResize = frameset->noResize(); - break; - } + if (Frame* parentFrame = document()->frame()) + m_name = parentFrame->tree()->uniqueChildName(m_name); +} +void HTMLFrameElement::attach() +{ HTMLElement::attach(); - - if (!renderer()) - return; - - Frame* frame = document()->frame(); - - if (!frame) - return; - - AtomicString relativeURL = m_URL; - if (relativeURL.isEmpty()) - relativeURL = "about:blank"; - - m_name = frame->tree()->uniqueChildName(m_name); - - // load the frame contents - frame->requestFrame(this, relativeURL, m_name); - if (contentFrame()) - contentFrame()->setInViewSourceMode(viewSourceMode()); + if (hasTagName(frameTag)) { + if (HTMLFrameSetElement* frameSetElement = containingFrameSetElement()) { + if (!m_frameBorderSet) + m_frameBorder = frameSetElement->frameBorder(); + if (!m_noResize) + m_noResize = frameSetElement->noResize(); + } + } + + if (!contentFrame()) + openURL(); } void HTMLFrameElement::close() @@ -307,6 +293,15 @@ Document* HTMLFrameElement::contentDocument() const return frame->document(); } +HTMLFrameSetElement* HTMLFrameElement::containingFrameSetElement() const +{ + for (Node* node = parentNode(); node; node = node->parentNode()) + if (node->hasTagName(framesetTag)) + return static_cast(node); + + return 0; +} + bool HTMLFrameElement::isURLAttribute(Attribute *attr) const { return attr->name() == srcAttr; diff --git a/WebCore/html/HTMLFrameElement.h b/WebCore/html/HTMLFrameElement.h index 3b59993f03f6..22072cb96760 100644 --- a/WebCore/html/HTMLFrameElement.h +++ b/WebCore/html/HTMLFrameElement.h @@ -32,6 +32,7 @@ namespace WebCore { class Frame; +class HTMLFrameSetElement; class HTMLFrameElement : public HTMLElement { @@ -49,12 +50,17 @@ public: virtual int tagPriority() const { return 0; } virtual void parseMappedAttribute(MappedAttribute*); + virtual void attach(); - void close(); - virtual void willRemove(); virtual void detach(); + virtual bool rendererIsNeeded(RenderStyle*); virtual RenderObject *createRenderer(RenderArena*, RenderStyle*); + + void insertedIntoDocument(); + virtual void willRemove(); + + void close(); bool noResize() { return m_noResize; } @@ -65,6 +71,7 @@ public: Frame* contentFrame() const; Document* contentDocument() const; + HTMLFrameSetElement* containingFrameSetElement() const; virtual bool isURLAttribute(Attribute*) const; diff --git a/WebCore/html/HTMLIFrameElement.cpp b/WebCore/html/HTMLIFrameElement.cpp index a929f0b8697f..ec19dce77fed 100644 --- a/WebCore/html/HTMLIFrameElement.cpp +++ b/WebCore/html/HTMLIFrameElement.cpp @@ -39,7 +39,6 @@ using namespace HTMLNames; HTMLIFrameElement::HTMLIFrameElement(Document* doc) : HTMLFrameElement(iframeTag, doc) - , needWidgetUpdate(false) { m_frameBorder = false; } @@ -60,7 +59,7 @@ bool HTMLIFrameElement::mapToEntry(const QualifiedName& attrName, MappedAttribut return false; } - return HTMLElement::mapToEntry(attrName, result); + return HTMLFrameElement::mapToEntry(attrName, result); } void HTMLIFrameElement::parseMappedAttribute(MappedAttribute *attr) @@ -85,23 +84,14 @@ void HTMLIFrameElement::parseMappedAttribute(MappedAttribute *attr) void HTMLIFrameElement::insertedIntoDocument() { + HTMLFrameElement::insertedIntoDocument(); + if (document()->isHTMLDocument()) { HTMLDocument *doc = static_cast(document()); doc->addDocExtraNamedItem(oldNameAttr); } - HTMLElement::insertedIntoDocument(); - - // Load the frame - m_name = getAttribute(nameAttr); - if (m_name.isNull()) - m_name = getAttribute(idAttr); - - if (Frame* parentFrame = document()->frame()) { - m_name = parentFrame->tree()->uniqueChildName(m_name); - - openURL(); - } + openURL(); } void HTMLIFrameElement::willRemove() @@ -122,7 +112,7 @@ void HTMLIFrameElement::removedFromDocument() doc->removeDocExtraNamedItem(oldNameAttr); } - HTMLElement::removedFromDocument(); + HTMLFrameElement::removedFromDocument(); } bool HTMLIFrameElement::rendererIsNeeded(RenderStyle *style) @@ -138,18 +128,12 @@ RenderObject *HTMLIFrameElement::createRenderer(RenderArena *arena, RenderStyle void HTMLIFrameElement::attach() { - HTMLElement::attach(); - - RenderPartObject* renderPart = static_cast(renderer()); - - if (renderPart) { - if (!contentFrame()) - openURL(); + HTMLFrameElement::attach(); + if (RenderPartObject* renderPart = static_cast(renderer())) { if (contentFrame()) { renderPart->setWidget(contentFrame()->view()); renderPart->updateWidget(); - needWidgetUpdate = false; } } } @@ -159,16 +143,6 @@ void HTMLIFrameElement::detach() HTMLElement::detach(); } -void HTMLIFrameElement::recalcStyle( StyleChange ch ) -{ - if (needWidgetUpdate) { - if (renderer()) - static_cast(renderer())->updateWidget(); - needWidgetUpdate = false; - } - HTMLElement::recalcStyle( ch ); -} - bool HTMLIFrameElement::isURLAttribute(Attribute *attr) const { return attr->name() == srcAttr; diff --git a/WebCore/html/HTMLIFrameElement.h b/WebCore/html/HTMLIFrameElement.h index 1b4c3d66fd8d..dcc93fa504ed 100644 --- a/WebCore/html/HTMLIFrameElement.h +++ b/WebCore/html/HTMLIFrameElement.h @@ -50,7 +50,6 @@ public: virtual void detach(); virtual bool rendererIsNeeded(RenderStyle*); virtual RenderObject *createRenderer(RenderArena*, RenderStyle*); - virtual void recalcStyle(StyleChange); virtual bool isURLAttribute(Attribute*) const; @@ -63,10 +62,7 @@ public: String width() const; void setWidth(const String&); -protected: - bool needWidgetUpdate; - - private: +private: String oldNameAttr; }; -- 2.36.0