Ignore:
Timestamp:
Dec 16, 2005, 12:08:23 AM (19 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Maciej.

  • kjs/internal.h:
  • kjs/internal.cpp: (KJS::InterpreterImp::evaluate): Change to take a character pointer and length rather than a UString.
  • kjs/interpreter.h:
  • kjs/interpreter.cpp: (Interpreter::evaluate): Ditto.
  • kjs/protect.h: Remove uneeded "convert to bool" operator since we already have a "convert to raw pointer" operator in this class.

WebCore:

Reviewed by Maciej.

  • khtml/ecma/kjs_dom.cpp: (KJS::DOMNode::getListener): Use listenerObj instead of listenerObjImp.
  • khtml/ecma/kjs_html.cpp: (KJS::Image::getValueProperty): Ditto.
  • khtml/ecma/xmlhttprequest.cpp: (KJS::XMLHttpRequest::getValueProperty): Ditto.
  • khtml/ecma/kjs_window.h:
  • khtml/ecma/kjs_window.cpp: (KJS::Window::getListener): Ditto. (KJS::Window::getJSLazyEventListener): Take code as a DOMString, not QString.
  • khtml/ecma/kjs_events.cpp: (KJS::jsStringOrUndefined): Renamed function and moved it to the top of the file. (KJS::JSAbstractEventListener::handleEvent): Cleaned up function, removed double logging, and fixed code path to not use UString::ascii(). (KJS::JSUnprotectedEventListener::JSUnprotectedEventListener): Updated since type of the window object is now Window. (KJS::JSUnprotectedEventListener::~JSUnprotectedEventListener): Ditto. (KJS::JSUnprotectedEventListener::windowObj): Ditto. (KJS::JSEventListener::JSEventListener): Ditto. (KJS::JSEventListener::~JSEventListener): Ditto. (KJS::JSEventListener::windowObj): Ditto. (KJS::JSLazyEventListener::JSLazyEventListener): Ditto. Also changed code to be a DOMString instead of a QString. (KJS::JSLazyEventListener::handleEvent): Removed function because the base class handleEvent already calls listenerObj which takes care of parseCode -- no need to do an additional parseCode here. (KJS::JSLazyEventListener::parseCode): Rearrange and clean up a bit. Code is now a DOMString instead of a QString. (KJS::Clipboard::Clipboard): Remove explicit ref since we now use a RefPtr for the clipboard object. (KJS::Clipboard::getValueProperty): Update to call jsStringOrUndefined.
  • khtml/ecma/kjs_events.h: Reformatted the file. Changed windowObj functions to return Window* instead of ObjectImp*. Removed listenerObjImp function. Removed destructors from many classes that don't need them. Used a RefPtr for the ClipboardImpl in a Clipboard object.
  • khtml/ecma/kjs_proxy.h:
  • khtml/ecma/kjs_proxy.cpp: (KJSProxyImpl::evaluate): Take filename and code as DOMString instead of QString. (KJSProxyImpl::createHTMLEventHandler): Take URL and code as DOMString.
  • khtml/xml/dom_docimpl.h:
  • khtml/xml/dom_docimpl.cpp: (DocumentImpl::createHTMLEventListener): Take a DOMString rather than a QString for the JavaScript code. (DocumentImpl::setHTMLWindowEventListener): Added an overload that takes an attribute pointer. Calls through after extracting the code from the attribute value.
  • khtml/html/html_elementimpl.h:
  • khtml/html/html_elementimpl.cpp: (HTMLElementImpl::setHTMLEventListener): New version of function that takes an attribute pointer; calls through to the base class after extracting the code from the attribute value.
  • khtml/html/html_baseimpl.cpp: (HTMLBodyElementImpl::parseMappedAttribute): Change to use new setHTMLWindowEventListener and setHTMLEventListener that takes an attribute pointer. (HTMLFrameElementImpl::parseMappedAttribute): Ditto. (HTMLFrameSetElementImpl::parseMappedAttribute): Ditto.
  • khtml/html/html_elementimpl.cpp: (HTMLElementImpl::parseMappedAttribute): Ditto.
  • khtml/html/html_formimpl.cpp: (DOM::HTMLFormElementImpl::parseMappedAttribute): Ditto. (DOM::HTMLButtonElementImpl::parseMappedAttribute): Ditto. (DOM::HTMLInputElementImpl::parseMappedAttribute): Ditto. (DOM::HTMLLabelElementImpl::parseMappedAttribute): Ditto. (DOM::HTMLSelectElementImpl::parseMappedAttribute): Ditto. (DOM::HTMLTextAreaElementImpl::parseMappedAttribute): Ditto.
  • khtml/html/html_imageimpl.cpp: (DOM::HTMLImageElementImpl::parseMappedAttribute): Ditto.
  • khtml/html/html_objectimpl.cpp: (DOM::HTMLObjectElementImpl::parseMappedAttribute): Ditto.
  • khtml/html/html_headimpl.h:
  • khtml/html/html_headimpl.cpp: (HTMLScriptElementImpl::notifyFinished): Don't convert URL to QString since we now take a DOMString. (HTMLScriptElementImpl::evaluateScript): Change to take script as a DOMString.
  • khtml/khtml_part.h:
  • khtml/khtml_part.cpp: (KHTMLPart::createHTMLEventListener): Take a DOMString rather than a QString for the JavaScript code.
  • kwq/WebCoreScriptDebugger.mm: (-[WebCoreScriptCallFrame evaluateWebScript:]): Change code path so it doesn't convert an NSString to UTF-8 to get it into the JavaScript machinery. Use QString::fromNSString instead for now.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/internal.cpp

    r11566 r11614  
    633633
    634634  // Parser::parse() returns 0 in a syntax error occurs, so we just check for that
    635   RefPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(),code.size(),0,0,0);
     635  RefPtr<ProgramNode> progNode = Parser::parse(UString(), 0, code.data(), code.size(), 0, 0, 0);
    636636  return progNode;
    637637}
    638638
    639 Completion InterpreterImp::evaluate(const UString &code, JSValue *thisV, const UString &sourceURL, int startingLineNumber)
     639Completion InterpreterImp::evaluate(const UChar* code, int codeLength, JSValue* thisV, const UString& sourceURL, int startingLineNumber)
    640640{
    641641  JSLock lock;
    642642
    643643  // prevent against infinite recursion
    644   if (recursion >= 20) {
    645 #if APPLE_CHANGES
    646     Completion result = Completion(Throw, Error::create(&globExec, GeneralError, "Recursion too deep"));
    647     return result;
    648 #else
    649     return Completion(Throw,Error::create(&globExec, GeneralError, "Recursion too deep"));
    650 #endif
    651   }
     644  if (recursion >= 20)
     645    return Completion(Throw, Error::create(&globExec, GeneralError, "Recursion too deep"));
    652646
    653647  // parse the source code
     
    655649  int errLine;
    656650  UString errMsg;
    657   RefPtr<ProgramNode> progNode = Parser::parse(sourceURL, startingLineNumber, code.data(),code.size(),&sid,&errLine,&errMsg);
     651  RefPtr<ProgramNode> progNode = Parser::parse(sourceURL, startingLineNumber, code, codeLength, &sid, &errLine, &errMsg);
    658652
    659653  // notify debugger that source has been parsed
    660654  if (dbg) {
    661     bool cont = dbg->sourceParsed(&globExec, sid, sourceURL, code, errLine);
     655    bool cont = dbg->sourceParsed(&globExec, sid, sourceURL, UString(code, codeLength), errLine);
    662656    if (!cont)
    663657      return Completion(Break);
     
    665659 
    666660  // no program node means a syntax error occurred
    667   if (!progNode) {
    668     JSObject *err = Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL);
    669     return Completion(Throw,err);
    670   }
     661  if (!progNode)
     662    return Completion(Throw, Error::create(&globExec, SyntaxError, errMsg, errLine, sid, &sourceURL));
    671663
    672664  globExec.clearException();
     
    674666  recursion++;
    675667
    676   JSObject *globalObj = globalObject();
    677   JSObject *thisObj = globalObject();
    678 
    679   if (thisV) {
    680     // "this" must be an object... use same rules as Function.prototype.apply()
    681     if (thisV->isUndefinedOrNull())
    682       thisObj = globalObject();
    683     else {
     668  JSObject* globalObj = globalObject();
     669  JSObject* thisObj = globalObj;
     670
     671  // "this" must be an object... use same rules as Function.prototype.apply()
     672  if (thisV && !thisV->isUndefinedOrNull())
    684673      thisObj = thisV->toObject(&globExec);
    685     }
    686   }
    687674
    688675  Completion res;
    689   if (globExec.hadException()) {
    690     // the thisArg->toObject() conversion above might have thrown an exception - if so,
    691     // propagate it back
     676  if (globExec.hadException())
     677    // the thisV->toObject() conversion above might have thrown an exception - if so, propagate it
    692678    res = Completion(Throw, globExec.exception());
    693   }
    694679  else {
    695680    // execute the code
Note: See TracChangeset for help on using the changeset viewer.