[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/khtml/ecma
From: Maks Orlovich <maksim () kde ! org>
Date: 2009-07-24 15:13:49
Message-ID: 1248448429.752561.9582.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1001942 by orlovich:
Really make the selection object stringify ---
it's not enough to change [[ToString]] since operator +
goes through [[PrimitiveValue]]/[[DefaultValue]], which
will do the "looking up toString property" trick,
and pick up Object.prototype.toString. Instead, provide a
toString of our own in our prototype.
(slowgerman.com, brought up by Chani on IRC)
M +8 -11 kjs_range.cpp
M +1 -2 kjs_range.h
--- trunk/KDE/kdelibs/khtml/ecma/kjs_range.cpp #1001941:1001942
@@ -275,6 +275,7 @@
addRange DOMSelection::AddRange DontDelete|Function 1
removeRange DOMSelection::RemoveRange DontDelete|Function 1
removeAllRanges DOMSelection::RemoveAllRanges DontDelete|Function 0
+ toString DOMSelection::ToString DontDelete|Function 0
@end
*/
KJS_DEFINE_PROTOTYPE(DOMSelectionProto)
@@ -318,8 +319,6 @@
JSValue* DOMSelectionProtoFunc::callAsFunction(ExecState *exec, JSObject *thisObj, \
const List &args) {
- kDebug(6070) << id;
-
KJS_CHECK_THIS(KJS::DOMSelection, thisObj);
DOMSelection* self = static_cast<DOMSelection*>(thisObj);
@@ -440,19 +439,17 @@
case DOMSelection::RemoveAllRanges:
self->m_document->part()->setCaret(DOM::Selection());
break;
+
+ case DOMSelection::ToString:
+ if (sel.isEmpty() || sel.isCollapsed())
+ return jsString(UString());
+ else
+ return jsString(sel.toRange().toString());
+ break;
}
return jsUndefined();
}
-UString DOMSelection::toString(ExecState* /*exec*/) const
-{
- DOM::Selection sel = currentSelection();
- if (sel.isEmpty() || sel.isCollapsed())
- return UString(UString::empty);
- else
- return UString(sel.toRange().toString());
-}
-
DOM::Selection DOMSelection::currentSelection() const
{
if (m_document && m_document->part())
--- trunk/KDE/kdelibs/khtml/ecma/kjs_range.h #1001941:1001942
@@ -63,10 +63,9 @@
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
- UString toString(ExecState *exec) const; // Selections stringify...
enum { AnchorNode, AnchorOffset, FocusNode, FocusOffset, IsCollapsed,
Collapsed, CollapseToStart, CollapseToEnd, SelectAllChildren,
- DeleteFromDocument, RangeCount, GetRangeAt, AddRange, RemoveRange, \
RemoveAllRanges }; + DeleteFromDocument, RangeCount, GetRangeAt, AddRange, \
RemoveRange, RemoveAllRanges, ToString };
DOM::Selection currentSelection() const;
bool attached() const; // if document & part are still alive..
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic