Fix for <rdar://problem/
3619890> Feature request: designMode
This change implements the designMode property of a document. This is an IE property that is also supported by Mozilla.
This will enable more JS editing compatibility.
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLDocument::tryGet): added case for designMode
(KJS::HTMLDocument::putValue): added case for designMode
* khtml/ecma/kjs_html.lut.h: (KJS::): regenerated
* khtml/khtml_part.cpp: (KHTMLPart::isContentEditable): Now returns designMode value
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::DocumentImpl): initialize m_designMode member variable
(DocumentImpl::setDesignMode): added function to assign m_designMode value
(DocumentImpl::getDesignMode): return m_designMode value
(DocumentImpl::inDesignMode): if designMode is inherited, this will find the appropriate parent document designMode and return that value.
Otherwise, it will just return the m_designMode value.
(DocumentImpl::parentDocument):
* khtml/xml/dom_docimpl.h: (DOM::DocumentImpl::): added InheritedBool enum, prototypes, and m_designMode member variable.
* kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::isContentEditable): added check for isContentEditable function in KHTMLPart
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7887
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2004-10-25 Adele Amchan <adele@apple.com>
+
+ Reviewed by Darin.
+
+ Fix for <rdar://problem/3619890> Feature request: designMode
+
+ This change implements the designMode property of a document. This is an IE property that is also supported by Mozilla.
+ This will enable more JS editing compatibility.
+
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLDocument::tryGet): added case for designMode
+ (KJS::HTMLDocument::putValue): added case for designMode
+ * khtml/ecma/kjs_html.lut.h: (KJS::): regenerated
+ * khtml/khtml_part.cpp: (KHTMLPart::isContentEditable): Now returns designMode value
+ * khtml/xml/dom_docimpl.cpp:
+ (DocumentImpl::DocumentImpl): initialize m_designMode member variable
+ (DocumentImpl::setDesignMode): added function to assign m_designMode value
+ (DocumentImpl::getDesignMode): return m_designMode value
+ (DocumentImpl::inDesignMode): if designMode is inherited, this will find the appropriate parent document designMode and return that value.
+ Otherwise, it will just return the m_designMode value.
+ (DocumentImpl::parentDocument):
+ * khtml/xml/dom_docimpl.h: (DOM::DocumentImpl::): added InheritedBool enum, prototypes, and m_designMode member variable.
+ * kwq/KWQKHTMLPart.mm: (KWQKHTMLPart::isContentEditable): added check for isContentEditable function in KHTMLPart
+
2004-10-22 Ken Kocienda <kocienda@apple.com>
Reviewed by Hyatt
using namespace KJS;
+using DOM::DocumentImpl;
+using DOM::DOMString;
using DOM::HTMLFrameElementImpl;
using DOM::HTMLIFrameElementImpl;
height HTMLDocument::Height DontDelete|ReadOnly
width HTMLDocument::Width DontDelete|ReadOnly
dir HTMLDocument::Dir DontDelete
+ designMode HTMLDocument::DesignMode DontDelete
#potentially obsolete array properties
# layers
# plugins
return Number(view ? view->contentsWidth() : 0);
case Dir:
return String(body.dir());
+ case DesignMode:
+ {
+ DocumentImpl *docimpl = static_cast<DocumentImpl *>(doc.handle());
+ if (!docimpl)
+ return Undefined();
+ return String(docimpl->inDesignMode() ? "on" : "off");
+ }
}
}
case Dir:
body.setDir(value.toString(exec).string());
break;
+ case DesignMode:
+ {
+ DocumentImpl *docimpl = static_cast<DocumentImpl *>(doc.handle());
+ if (!docimpl)
+ break;
+ DOMString modeString = value.toString(exec).string();
+ DocumentImpl::InheritedBool mode;
+ if (!strcasecmp(modeString, "on"))
+ mode = DocumentImpl::on;
+ else if (!strcasecmp(modeString, "off"))
+ mode = DocumentImpl::off;
+ else
+ mode = DocumentImpl::inherit;
+ docimpl->setDesignMode(mode);
+ }
+ break;
default:
kdWarning() << "HTMLDocument::putValue unhandled token " << token << endl;
}
{ "fgColor", HTMLDocument::FgColor, DontDelete, 0, 0 },
{ "linkColor", HTMLDocument::LinkColor, DontDelete, 0, 0 },
{ "vlinkColor", HTMLDocument::VlinkColor, DontDelete, 0, 0 },
- { "height", HTMLDocument::Height, DontDelete|ReadOnly, 0, 0 },
- { "width", HTMLDocument::Width, DontDelete|ReadOnly, 0, 0 }
+ { "height", HTMLDocument::Height, DontDelete|ReadOnly, 0, &HTMLDocumentTableEntries[40] },
+ { "width", HTMLDocument::Width, DontDelete|ReadOnly, 0, 0 },
+ { "designMode", HTMLDocument::DesignMode, DontDelete, 0, 0 }
};
-const struct HashTable HTMLDocumentTable = { 2, 40, HTMLDocumentTableEntries, 30 };
+const struct HashTable HTMLDocumentTable = { 2, 41, HTMLDocumentTableEntries, 30 };
} // namespace
bool KHTMLPart::isContentEditable() const
{
- return false;
+ if (!d->m_doc)
+ return false;
+ return d->m_doc->inDesignMode();
}
EditCommandPtr KHTMLPart::lastEditCommand()
#endif
#if APPLE_CHANGES
, m_finishedParsing(this, SIGNAL(finishedParsing()))
- , m_inPageCache(false), m_savedRenderer(0)
- , m_passwordFields(0), m_secureForms(0)
- , m_decoder(0), m_createRenderers(true)
+ , m_inPageCache(false)
+ , m_savedRenderer(0)
+ , m_passwordFields(0)
+ , m_secureForms(0)
+ , m_decoder(0)
+ , m_createRenderers(true)
+ , m_designMode(inherit)
, m_hasDashboardRegions(false)
, m_dashboardRegionsDirty(false)
#endif
doc->ref();
}
+void DocumentImpl::setDesignMode(InheritedBool value)
+{
+ m_designMode = value;
+}
+
+DocumentImpl::InheritedBool DocumentImpl::getDesignMode() const
+{
+ return m_designMode;
+}
+
+bool DocumentImpl::inDesignMode()
+{
+ for (DocumentImpl* d = this; d; d = d->parentDocument()) {
+ if (d->m_designMode != inherit)
+ return d->m_designMode;
+ }
+ return false;
+}
+
+DocumentImpl *DocumentImpl::parentDocument() const
+{
+ KHTMLPart *childPart = part();
+ if (!childPart)
+ return 0;
+ KHTMLPart *parent = childPart->parentPart();
+ if (!parent)
+ return 0;
+ return parent->xmlDocImpl();
+}
+
#endif
// ----------------------------------------------------------------------------
void removeAllMarkers();
void shiftMarkers(NodeImpl *node, ulong startOffset, long delta);
QValueList<DocumentMarker> markersForNode(NodeImpl *node);
+
+ /**
+ * designMode support
+ */
+ enum InheritedBool {
+ off=false,
+ on=true,
+ inherit
+ };
+
+ void setDesignMode(InheritedBool value);
+ InheritedBool getDesignMode() const;
+ bool inDesignMode();
+ DocumentImpl *parentDocument() const;
#ifdef KHTML_XSLT
void applyXSLTransform(ProcessingInstructionImpl* pi);
bool m_createRenderers;
+ InheritedBool m_designMode;
+
QValueList<khtml::DashboardRegionValue> m_dashboardRegions;
bool m_hasDashboardRegions;
bool m_dashboardRegionsDirty;
bool KWQKHTMLPart::isContentEditable() const
{
- return [_bridge isEditable];
+ return KHTMLPart::isContentEditable() || [_bridge isEditable];
}
bool KWQKHTMLPart::shouldBeginEditing(const Range &range) const