[webkit-changes] cvs commit: WebCore/khtml/html html_objectimpl.cpp
html_objectimpl.h html_miscimpl.cpp
David
harrison at opensource.apple.com
Mon Oct 24 14:42:16 PDT 2005
harrison 05/10/24 14:42:15
Modified: . ChangeLog
khtml/html html_objectimpl.cpp html_objectimpl.h
html_miscimpl.cpp
Log:
Reviewed by Darin. Committed by David Harrison.
http://bugzilla.opendarwin.org/show_bug.cgi?id=5449
"OBJECT should be accessible by id/name as document property only if its only children are PARAMs"
Test added:
* fast/js/object-by-name-or-id-expected.txt: Added.
* fast/js/object-by-name-or-id.html: Added.
Files changed:
* khtml/html/html_miscimpl.cpp:
(DOM::HTMLNameCollectionImpl::traverseNextItem):
* khtml/html/html_objectimpl.cpp:
(DOM::HTMLObjectElementImpl::HTMLObjectElementImpl):
(DOM::HTMLObjectElementImpl::parseMappedAttribute):
(DOM::HTMLObjectElementImpl::insertedIntoDocument):
(DOM::HTMLObjectElementImpl::removedFromDocument):
(DOM::HTMLObjectElementImpl::childrenChanged):
(DOM::HTMLObjectElementImpl::updateDocNamedItem):
* khtml/html/html_objectimpl.h:
(DOM::HTMLObjectElementImpl::isDocNamedItem):
* manual-tests/drag_select_highlighting.html: Added.
Revision Changes Path
1.273 +25 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -r1.272 -r1.273
--- ChangeLog 24 Oct 2005 21:34:39 -0000 1.272
+++ ChangeLog 24 Oct 2005 21:42:09 -0000 1.273
@@ -2,6 +2,31 @@
Reviewed by Darin. Committed by David Harrison.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=5449
+ "OBJECT should be accessible by id/name as document property only if its only children are PARAMs"
+
+ Test added:
+ * fast/js/object-by-name-or-id-expected.txt: Added.
+ * fast/js/object-by-name-or-id.html: Added.
+
+ Files changed:
+ * khtml/html/html_miscimpl.cpp:
+ (DOM::HTMLNameCollectionImpl::traverseNextItem):
+ * khtml/html/html_objectimpl.cpp:
+ (DOM::HTMLObjectElementImpl::HTMLObjectElementImpl):
+ (DOM::HTMLObjectElementImpl::parseMappedAttribute):
+ (DOM::HTMLObjectElementImpl::insertedIntoDocument):
+ (DOM::HTMLObjectElementImpl::removedFromDocument):
+ (DOM::HTMLObjectElementImpl::childrenChanged):
+ (DOM::HTMLObjectElementImpl::updateDocNamedItem):
+ * khtml/html/html_objectimpl.h:
+ (DOM::HTMLObjectElementImpl::isDocNamedItem):
+ * manual-tests/drag_select_highlighting.html: Added.
+
+2005-10-24 Mitz Pettel <opendarwin.org at mitzpettel.com>
+
+ Reviewed by Darin. Committed by David Harrison.
+
http://bugzilla.opendarwin.org/show_bug.cgi?id=5415
"Left border of selection highlight leaves behind a trail"
1.84 +39 -4 WebCore/khtml/html/html_objectimpl.cpp
Index: html_objectimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_objectimpl.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- html_objectimpl.cpp 24 Oct 2005 19:36:36 -0000 1.83
+++ html_objectimpl.cpp 24 Oct 2005 21:42:14 -0000 1.84
@@ -42,6 +42,7 @@
#include "rendering/render_frames.h"
#include "rendering/render_image.h"
#include "xml/dom2_eventsimpl.h"
+#include "xml/dom_textimpl.h"
#include "xml/EventNames.h"
#ifndef Q_WS_QWS // We don't have Java in Qt Embedded
@@ -561,6 +562,7 @@
{
needWidgetUpdate = false;
m_useFallbackContent = false;
+ m_docNamedItem = true;
}
HTMLObjectElementImpl::~HTMLObjectElementImpl()
@@ -678,7 +680,7 @@
getDocument()->createHTMLEventListener(attr->value().qstring(), this));
} else if (attr->name() == nameAttr) {
DOMString newNameAttr = attr->value();
- if (inDocument() && getDocument()->isHTMLDocument()) {
+ if (isDocNamedItem() && inDocument() && getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
document->removeNamedItem(oldNameAttr);
document->addNamedItem(newNameAttr);
@@ -686,7 +688,7 @@
oldNameAttr = newNameAttr;
} else if (attr->name() == idAttr) {
DOMString newIdAttr = attr->value();
- if (inDocument() && getDocument()->isHTMLDocument()) {
+ if (isDocNamedItem() && inDocument() && getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
document->removeDocExtraNamedItem(oldIdAttr);
document->addDocExtraNamedItem(newIdAttr);
@@ -779,7 +781,7 @@
void HTMLObjectElementImpl::insertedIntoDocument()
{
- if (getDocument()->isHTMLDocument()) {
+ if (isDocNamedItem() && getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
document->addNamedItem(oldNameAttr);
document->addDocExtraNamedItem(oldIdAttr);
@@ -790,7 +792,7 @@
void HTMLObjectElementImpl::removedFromDocument()
{
- if (getDocument()->isHTMLDocument()) {
+ if (isDocNamedItem() && getDocument()->isHTMLDocument()) {
HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
document->removeNamedItem(oldNameAttr);
document->removeDocExtraNamedItem(oldIdAttr);
@@ -810,6 +812,7 @@
void HTMLObjectElementImpl::childrenChanged()
{
+ updateDocNamedItem();
if (inDocument() && !m_useFallbackContent) {
needWidgetUpdate = true;
setChanged();
@@ -854,6 +857,38 @@
attach();
}
+void HTMLObjectElementImpl::updateDocNamedItem()
+{
+ // The rule is "<object> elements with no children other than
+ // <param> elements and whitespace can be found by name in a
+ // document, and other <object> elements cannot."
+ bool wasNamedItem = m_docNamedItem;
+ bool isNamedItem = true;
+ NodeImpl *child = firstChild();
+ while (child && isNamedItem) {
+ if (child->isElementNode()) {
+ if (!static_cast<ElementImpl *>(child)->hasTagName(paramTag))
+ isNamedItem = false;
+ } else if (child->isTextNode()) {
+ if (!static_cast<TextImpl *>(child)->containsOnlyWhitespace())
+ isNamedItem = false;
+ } else
+ isNamedItem = false;
+ child = child->nextSibling();
+ }
+ if (isNamedItem != wasNamedItem && getDocument()->isHTMLDocument()) {
+ HTMLDocumentImpl *document = static_cast<HTMLDocumentImpl *>(getDocument());
+ if (isNamedItem) {
+ document->addNamedItem(oldNameAttr);
+ document->addDocExtraNamedItem(oldIdAttr);
+ } else {
+ document->removeNamedItem(oldNameAttr);
+ document->removeDocExtraNamedItem(oldIdAttr);
+ }
+ }
+ m_docNamedItem = isNamedItem;
+}
+
DOMString HTMLObjectElementImpl::code() const
{
return getAttribute(codeAttr);
1.37 +3 -0 WebCore/khtml/html/html_objectimpl.h
Index: html_objectimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_objectimpl.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- html_objectimpl.h 16 Sep 2005 22:42:12 -0000 1.36
+++ html_objectimpl.h 24 Oct 2005 21:42:14 -0000 1.37
@@ -236,6 +236,7 @@
DOMString width() const;
void setWidth(const DOMString &);
+ bool isDocNamedItem() const { return m_docNamedItem; }
#if APPLE_CHANGES
KJS::Bindings::Instance *getObjectInstance() const;
#endif
@@ -248,11 +249,13 @@
HTMLImageLoader* m_imageLoader;
private:
+ void updateDocNamedItem();
DOMString oldIdAttr;
DOMString oldNameAttr;
#if APPLE_CHANGES
mutable KJS::Bindings::Instance *objectInstance;
#endif
+ bool m_docNamedItem;
};
// -------------------------------------------------------------------------
1.38 +5 -2 WebCore/khtml/html/html_miscimpl.cpp
Index: html_miscimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_miscimpl.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- html_miscimpl.cpp 3 Oct 2005 21:12:29 -0000 1.37
+++ html_miscimpl.cpp 24 Oct 2005 21:42:15 -0000 1.38
@@ -27,6 +27,7 @@
#include "html/html_formimpl.h"
#include "html/html_imageimpl.h"
#include "html/html_documentimpl.h"
+#include "html/html_objectimpl.h"
#include "dom/dom_node.h"
@@ -393,10 +394,12 @@
e->hasTagName(embedTag) ||
e->hasTagName(iframeTag))
found = e->getAttribute(nameAttr) == m_name;
- else if (e->hasTagName(appletTag) ||
- e->hasTagName(objectTag))
+ else if (e->hasTagName(appletTag))
found = e->getAttribute(nameAttr) == m_name ||
e->getAttribute(idAttr) == m_name;
+ else if (e->hasTagName(objectTag))
+ found = (e->getAttribute(nameAttr) == m_name || e->getAttribute(idAttr) == m_name) &&
+ static_cast<HTMLObjectElementImpl *>(e)->isDocNamedItem();
break;
default:
assert(0);
More information about the webkit-changes
mailing list