generic: make KJS KHTML exclusive

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-03-04 16:07:03 +02:00
parent e8c09de3c1
commit bb26b6abd8
9 changed files with 88 additions and 92 deletions

View file

@ -99,7 +99,7 @@ set_package_properties(OpenSSL PROPERTIES
DESCRIPTION "Support for secure network communications (SSL and TLS)"
URL "http://openssl.org"
TYPE RECOMMENDED
PURPOSE "KDE uses OpenSSL for the bulk of secure communications, including secure web browsing via HTTPS"
PURPOSE "For the bulk of secure communications, including secure web browsing via HTTPS"
)
macro_optional_find_package(Libintl)
@ -117,6 +117,14 @@ set_package_properties(DBusMenuQt PROPERTIES
TYPE RECOMMENDED
)
macro_optional_find_package(PCRE)
set_package_properties(PCRE PROPERTIES
DESCRIPTION "Perl-compatible regular expressions in KJS"
URL "http://www.pcre.org"
TYPE RECOMMENDED
PURPOSE "Faster regular expression in KJS, increases web pages compatibility"
)
################# Disallow in-source build #################
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")

View file

@ -452,8 +452,6 @@ set(_kde_libraries
khtml
kidletime
kio
kjs
kjsapi
knotifyconfig
kparts
kprintutils

View file

@ -494,22 +494,32 @@ qt4_add_dbus_interface(khtml_LIB_SRCS
kcookiejar_interface
)
add_library(khtml ${LIBRARY_TYPE} ${khtml_LIB_SRCS})
# going trough the extra trouble to not use shared KJS library for performance reasons
add_library(khtml ${LIBRARY_TYPE} ${khtml_LIB_SRCS} $<TARGET_OBJECTS:kjs>)
target_link_libraries(khtml
${KDE4_PHONON_LIBRARY}
${KDE4_KPARTS_LIBS}
ktexteditor
kjs
${X11_LIBRARIES}
kparts
kio
kdeui
kdecore
${X11_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
# for KJS
m
)
# for KJS
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(khtml ${CMAKE_THREAD_LIBS_INIT})
endif()
if(PCRE_FOUND)
target_link_libraries(khtml ${PCRE_LIBRARIES})
endif()
set_target_properties(khtml PROPERTIES
VERSION ${KDE_NON_GENERIC_LIB_VERSION}
SOVERSION ${KDE_NON_GENERIC_LIB_SOVERSION}
@ -640,7 +650,7 @@ install(
kde4_add_plugin(khtmladaptorpart khtmladaptorpart.cpp)
target_link_libraries(khtmladaptorpart ${KDE4_KPARTS_LIBS} kjs)
target_link_libraries(khtmladaptorpart ${KDE4_KPARTS_LIBS} khtml)
install(
TARGETS khtmladaptorpart

View file

@ -234,11 +234,11 @@ ProcessingInstruction &ProcessingInstruction::operator = (const Node &other)
NodeImpl* ohandle = other.handle();
if ( impl != ohandle ) {
if (!ohandle || ohandle->nodeType() != PROCESSING_INSTRUCTION_NODE) {
if ( impl ) impl->deref();
if ( impl ) impl->deref();
impl = 0;
} else {
} else {
Node::operator =(other);
}
}
}
return *this;
}
@ -256,7 +256,7 @@ ProcessingInstruction::~ProcessingInstruction()
DOMString ProcessingInstruction::target() const
{
if (!impl)
return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
return ((ProcessingInstructionImpl*)impl)->target();
}
@ -264,7 +264,7 @@ DOMString ProcessingInstruction::target() const
DOMString ProcessingInstruction::data() const
{
if (!impl)
return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
return ((ProcessingInstructionImpl*)impl)->data();
}
@ -272,12 +272,12 @@ DOMString ProcessingInstruction::data() const
void ProcessingInstruction::setData( const DOMString &_data )
{
if (!impl)
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
return; // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
int exceptioncode = 0;
((ProcessingInstructionImpl*)impl)->setData(_data, exceptioncode);
if (exceptioncode)
throw DOMException(exceptioncode);
throw DOMException(exceptioncode);
}
ProcessingInstruction::ProcessingInstruction(ProcessingInstructionImpl *i) : Node(i)

View file

@ -216,7 +216,7 @@ DOM::DOMString UString::domString() const
QString UString::qstring() const
{
return QString((QChar*) data(), size());
return QString::fromRawData((QChar*) data(), size());
}
DOM::DOMString Identifier::domString() const
@ -226,7 +226,7 @@ DOM::DOMString Identifier::domString() const
QString Identifier::qstring() const
{
return QString((QChar*) data(), size());
return QString::fromRawData((QChar*) data(), size());
}
JSValue* valueGetterAdapter(ExecState* exec, JSObject*, const Identifier& , const PropertySlot& slot)
@ -270,7 +270,7 @@ QVariant ValueToVariant(ExecState* exec, JSValue *val) {
res = QVariant(val->toNumber(exec));
break;
case StringType:
res = QVariant(val->toString(exec).qstring());
res = QVariant(val->toString(exec).ascii());
break;
default:
// everything else will be 'invalid'

View file

@ -128,7 +128,7 @@ JSValue* KJS::HTMLDocFunction::callAsFunction(ExecState *exec, JSObject *thisObj
if (id == HTMLDocument::WriteLn)
str += "\n";
#ifdef KJS_VERBOSE
kDebug(6070) << "document.write: " << str.qstring();
kDebug(6070) << "document.write: " << str.ascii();
#endif
doc.write(str.qstring());
return jsUndefined();
@ -222,7 +222,7 @@ static bool isLateProperty(unsigned token)
bool KJS::HTMLDocument::getOwnPropertySlot(ExecState *exec, const Identifier &propertyName, PropertySlot& slot)
{
#ifdef KJS_VERBOSE
kDebug(6070) << "KJS::HTMLDocument::getOwnPropertySlot " << propertyName.qstring();
kDebug(6070) << "KJS::HTMLDocument::getOwnPropertySlot " << propertyName.ascii();
#endif
DOM::DocumentImpl* docImpl = impl();
@ -261,7 +261,7 @@ bool KJS::HTMLDocument::getOwnPropertySlot(ExecState *exec, const Identifier &pr
// Check for frames/iframes with name==propertyName
if ( part ) {
if (part->findFrame( propertyName.qstring() )) {
if (part->findFrame( propertyName.ascii() )) {
slot.setCustom(this, frameNameGetter);
return true;
}
@ -322,7 +322,7 @@ JSValue *HTMLDocument::frameNameGetter(ExecState*, JSObject*, const Identifier&
{
HTMLDocument *thisObj = static_cast<HTMLDocument*>(slot.slotBase());
// Check for frames/iframes with name==propertyName
return Window::retrieve(thisObj->impl()->part()->findFrame( name.qstring() ));
return Window::retrieve(thisObj->impl()->part()->findFrame( name.ascii() ));
}
JSValue *HTMLDocument::objectNameGetter(ExecState *exec, JSObject*, const Identifier& name, const PropertySlot& slot)

View file

@ -83,7 +83,7 @@ bool pluginRootGet(ExecState* exec, ScriptableExtension* ext, const KJS::Identif
return false;
QVariant v = rootObj.owner->get(0 /* ### we don't expect leaves to check credentials*/,
rootObj.objId, i.qstring());
rootObj.objId, i.ascii());
bool ok = false;
if (!isException(v)) {
@ -102,7 +102,7 @@ bool pluginRootPut(ExecState* /*exec*/, ScriptableExtension* ext, const KJS::Ide
return false;
QVariant qv = ScriptableOperations::exportValue(v, true);
bool ok = rootObj.owner->put(0, rootObj.objId, i.qstring(), qv);
bool ok = rootObj.owner->put(0, rootObj.objId, i.ascii(), qv);
ScriptableExtension::releaseValue(qv);
rootObj.owner->release(rootObj.objId);
@ -199,7 +199,7 @@ bool WrapScriptableObject::getOwnPropertySlot(ExecState* exec, const Identifier&
if (!ok)
return false;
QVariant v = doGet(exec, actualObj, i.qstring(), &ok);
QVariant v = doGet(exec, actualObj, i.ascii(), &ok);
if (!ok)
return false;
@ -217,7 +217,7 @@ void WrapScriptableObject::put(ExecState* exec, const Identifier& i, JSValue* va
return;
QVariant sv = ScriptableOperations::exportValue(value, true);
actualObj.owner->put(principal(exec), actualObj.objId, i.qstring(), sv);
actualObj.owner->put(principal(exec), actualObj.objId, i.ascii(), sv);
ScriptableExtension::releaseValue(sv);
}
@ -230,7 +230,7 @@ bool WrapScriptableObject::deleteProperty(ExecState* exec, const Identifier& i)
return false;
return actualObj.owner->removeProperty(principal(exec),
actualObj.objId, i.qstring());
actualObj.objId, i.ascii());
}
ScriptableExtension::ArgList WrapScriptableObject::exportArgs(const List& l)
@ -550,7 +550,7 @@ QVariant ScriptableOperations::handleReturn(ExecState* exec, JSValue* v)
if (JSObject* eo = e->getObject()) {
JSValue* msgVal = eo->get(exec, exec->propertyNames().message);
if (!msgVal->isUndefined())
msg = msgVal->toString(exec).qstring();
msg = msgVal->toString(exec).ascii();
// in case the get failed too.
exec->clearException();
@ -706,7 +706,7 @@ bool ScriptableOperations::enumerateProperties(ScriptableExtension* caller,
o->getPropertyNames(exec, pa);
for (int i = 0; i < pa.size(); ++i)
result->append(pa[i].qstring());
result->append(pa[i].ascii());
return true;
}

View file

@ -822,7 +822,7 @@ bool Window::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName,
}
// Now do frame indexing.
KParts::ReadOnlyPart *rop = part->findFramePart( propertyName.qstring() );
KParts::ReadOnlyPart *rop = part->findFramePart( propertyName.ascii() );
if (rop) {
slot.setCustom(this, framePartGetter);
return true;
@ -849,7 +849,7 @@ bool Window::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName,
// This isn't necessarily a bug. Some code uses if(!window.blah) window.blah=1
// But it can also mean something isn't loaded or implemented, hence the WARNING to help grepping.
#ifdef KJS_VERBOSE
kDebug(6070) << "WARNING: Window::get property not found: " << propertyName.qstring();
kDebug(6070) << "WARNING: Window::get property not found: " << propertyName.ascii();
#endif
return JSObject::getOwnPropertySlot(exec, propertyName, slot);
@ -881,7 +881,7 @@ JSValue *Window::framePartGetter(ExecState *exec, JSObject*, const Identifier& p
Q_UNUSED(exec);
Window* thisObj = static_cast<Window*>(slot.slotBase());
KHTMLPart *part = qobject_cast<KHTMLPart*>(thisObj->m_frame->m_part);
KParts::ReadOnlyPart *rop = part->findFramePart( propertyName.qstring() );
KParts::ReadOnlyPart *rop = part->findFramePart( propertyName.ascii() );
return thisObj->retrieve(rop);
}
@ -1352,10 +1352,10 @@ void Window::put(ExecState* exec, const Identifier &propertyName, JSValue *value
if (entry)
{
#ifdef KJS_VERBOSE
kDebug(6070) << "Window("<<this<<")::put " << propertyName.qstring();
kDebug(6070) << "Window("<<this<<")::put " << propertyName.ascii();
#endif
if (entry->value == _Location) {
goURL(exec, value->toString(exec).qstring());
goURL(exec, value->toString(exec).ascii());
return;
}
@ -1366,7 +1366,7 @@ void Window::put(ExecState* exec, const Identifier &propertyName, JSValue *value
if (isSafeScript(exec) && part->settings()->windowStatusPolicy(part->url().host())
== KHTMLSettings::KJSWindowStatusAllow) {
UString s = value->toString(exec);
part->setJSStatusBarText(s.qstring());
part->setJSStatusBarText(s.ascii());
}
return;
}
@ -1374,7 +1374,7 @@ void Window::put(ExecState* exec, const Identifier &propertyName, JSValue *value
if (isSafeScript(exec) && part->settings()->windowStatusPolicy(part->url().host())
== KHTMLSettings::KJSWindowStatusAllow) {
UString s = value->toString(exec);
part->setJSDefaultStatusBarText(s.qstring());
part->setJSDefaultStatusBarText(s.ascii());
}
return;
}
@ -1495,7 +1495,7 @@ void Window::put(ExecState* exec, const Identifier &propertyName, JSValue *value
pluginRootPut(exec, m_frame->m_scriptable.data(), propertyName, value))
return;
if (safe) {
//kDebug(6070) << "Window("<<this<<")::put storing " << propertyName.qstring();
//kDebug(6070) << "Window("<<this<<")::put storing " << propertyName.ascii();
JSObject::put(exec, propertyName, value, attr);
}
}
@ -1853,9 +1853,14 @@ JSValue *Window::openWindow(ExecState *exec, const List& args)
}
KHTMLSettings::KJSWindowOpenPolicy policy =
part->settings()->windowOpenPolicy(part->url().host());
part->settings()->windowOpenPolicy(part->url().host());
QString frameName = args.size() > 1 ? args[1]->toString(exec).qstring() : QString("_blank");
char *frameName;
if(args.size() > 1) {
frameName = args[1]->toString(exec).ascii();
} else {
frameName = "_blank";
}
// Always permit opening in an exist frame (including _self, etc.)
if ( targetIsExistingWindow( part, frameName ) )
@ -2220,7 +2225,7 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
return new KJS::DOMSelection(exec, part->xmlDocImpl());
case Window::Navigate:
window->goURL(exec, args[0]->toString(exec).qstring());
window->goURL(exec, args[0]->toString(exec).ascii());
return jsUndefined();
case Window::Focus: {
KHTMLSettings::KJSWindowFocusPolicy policy =
@ -2265,7 +2270,7 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
}
QString sourceOrigin = part->xmlDocImpl()->origin()->toString();
QString targetOrigin = args[1]->toString(exec).qstring();
QString targetOrigin = args[1]->toString(exec).ascii();
KUrl targetURL(targetOrigin);
kDebug(6070) << "postMessage targetting:" << targetOrigin;
@ -2832,7 +2837,7 @@ KParts::ReadOnlyPart *Location::part() const {
bool Location::getOwnPropertySlot(ExecState *exec, const Identifier &p, PropertySlot& slot)
{
#ifdef KJS_VERBOSE
kDebug(6070) << "Location::getOwnPropertySlot " << p.qstring() << " m_part=" << (void*)m_frame->m_part;
kDebug(6070) << "Location::getOwnPropertySlot " << p.ascii() << " m_part=" << (void*)m_frame->m_part;
#endif
if (m_frame.isNull() || m_frame->m_part.isNull())
@ -2910,7 +2915,7 @@ JSValue* Location::getValueProperty(ExecState *exec, int token) const
void Location::put(ExecState *exec, const Identifier &p, JSValue *v, int attr)
{
#ifdef KJS_VERBOSE
kDebug(6070) << "Location::put " << p.qstring() << " m_part=" << (void*)m_frame->m_part;
kDebug(6070) << "Location::put " << p.ascii() << " m_part=" << (void*)m_frame->m_part;
#endif
if (m_frame.isNull() || m_frame->m_part.isNull())
return;
@ -3029,10 +3034,10 @@ JSValue *LocationFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const
switch (id) {
case Location::Assign:
window->goURL(exec, args[0]->toString(exec).qstring());
window->goURL(exec, args[0]->toString(exec).ascii());
break;
case Location::Replace:
window->goURL(exec, args[0]->toString(exec).qstring(), true/*lock history*/);
window->goURL(exec, args[0]->toString(exec).ascii(), true/*lock history*/);
break;
case Location::Reload: {
KHTMLPart *khtmlpart = qobject_cast<KHTMLPart*>(part);

View file

@ -1,9 +1,5 @@
project(kjs)
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
# Configuration checks
include(FindThreads)
check_library_exists(pthread pthread_attr_get_np "" HAVE_PTHREAD_ATTR_GET_NP)
@ -24,16 +20,6 @@ check_symbol_exists(isnan "math.h" HAVE_FUNC_ISNAN)
check_symbol_exists(isinf "math.h" HAVE_FUNC_ISINF)
macro_pop_required_vars()
#Do not make PCRE optional here. PCRE is a hard requirement for modern systems
#but we give old systems some slack... that's why we don't specify "REQUIRED".
find_package(PCRE)
set_package_properties(PCRE PROPERTIES
DESCRIPTION "Perl-compatible regular expressions in KJS"
URL "http://www.pcre.org"
PURPOSE "Without PCRE, KJS will have extremely poor regular expression support, breaking many webpages."
TYPE OPTIONAL
)
macro_bool_to_01(PCRE_FOUND HAVE_PCREPOSIX)
# Generate global.h
@ -180,43 +166,32 @@ set(kjs_LIB_SRCS
propertydescriptor.cpp
)
add_library(kjs ${LIBRARY_TYPE} ${kjs_LIB_SRCS})
add_library(kjs OBJECT ${kjs_LIB_SRCS})
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(kjs ${CMAKE_THREAD_LIBS_INIT})
if(ENABLE_TESTING)
add_library(kjs ${LIBRARY_TYPE} ${kjs_LIB_SRCS})
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(kjs ${CMAKE_THREAD_LIBS_INIT})
endif()
if(PCRE_FOUND)
target_link_libraries(kjs ${PCRE_LIBRARIES})
endif()
target_link_libraries(kjs m)
add_subdirectory(tests)
# 'kjs_bin' because cmake doesn't like having a lib and app with the same name
add_executable(kjs_bin kjs.cpp)
set_target_properties(kjs_bin PROPERTIES RUNTIME_OUTPUT_NAME kjs)
target_link_libraries(kjs_bin kjs)
# it is only for testing purposes, if you use it you abuse it
# install(TARGETS kjs_bin ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()
if(PCRE_FOUND)
target_link_libraries(kjs ${PCRE_LIBRARIES})
endif(PCRE_FOUND)
target_link_libraries(kjs m)
set_target_properties(kjs PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
install(
TARGETS kjs
EXPORT kdelibsLibraryTargets
${INSTALL_TARGETS_DEFAULT_ARGS}
)
########### kjs - basic shell ###############
# 'kjs_bin' because cmake doesn't like having a lib and app with the same name
add_executable(kjs_bin kjs.cpp)
set_target_properties(kjs_bin PROPERTIES RUNTIME_OUTPUT_NAME kjs)
target_link_libraries(kjs_bin kjs)
install(TARGETS kjs_bin ${INSTALL_TARGETS_DEFAULT_ARGS})
########### KDE-specific API ##############
add_subdirectory(api)
########### install files ###############
# install( FILES
# ExecState.h