Changeset 31950 in webkit


Ignore:
Timestamp:
Apr 16, 2008 12:18:11 PM (16 years ago)
Author:
Adam Roben
Message:

Pass JSConsole's arguments unmodified to Console

Part of Bug 17228: console.{log,warn,info,error} should support format
strings, variable arguments
<http://bugs.webkit.org/show_bug.cgi?id=17228>
<rdar://problem/5732828>

All of JSConsole's methods are now custom, so that we can pass the
arguments unmodified to Console. Console now handles calling
toString() on the first argument. Later it will pass the arguments off
to InspectorController.

There should be no behavioral changes caused by this patch.

Reviewed by Darin Adler.

  • ForwardingHeaders/kjs/list.h: Added.
  • GNUmakefile.am: Added JSConsoleCustom.cpp to the project.
  • WebCore.pro: Ditto.
  • WebCore.vcproj/WebCore.vcproj: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • WebCoreSources.bkl: Ditto.
  • bindings/js/JSConsoleCustom.cpp: Added. (WebCore::JSConsole::error): (WebCore::JSConsole::info): (WebCore::JSConsole::log): (WebCore::JSConsole::warn):
  • page/Console.cpp: Changed all methods to take an ExecState* and a const List&. The first item in the List is toString()ed and passed to Chrome. (WebCore::Console::error): (WebCore::Console::info): (WebCore::Console::log): (WebCore::Console::warn):
  • page/Console.h:
  • page/Console.idl:
Location:
trunk/WebCore
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31948 r31950  
     12008-04-15  Adam Roben  <aroben@apple.com>
     2
     3        Pass JSConsole's arguments unmodified to Console
     4
     5        Part of Bug 17228: console.{log,warn,info,error} should support format
     6        strings, variable arguments
     7        <http://bugs.webkit.org/show_bug.cgi?id=17228>
     8        <rdar://problem/5732828>
     9
     10        All of JSConsole's methods are now custom, so that we can pass the
     11        arguments unmodified to Console. Console now handles calling
     12        toString() on the first argument. Later it will pass the arguments off
     13        to InspectorController.
     14
     15        There should be no behavioral changes caused by this patch.
     16
     17        Reviewed by Darin Adler.
     18
     19        * ForwardingHeaders/kjs/list.h: Added.
     20        * GNUmakefile.am: Added JSConsoleCustom.cpp to the project.
     21        * WebCore.pro: Ditto.
     22        * WebCore.vcproj/WebCore.vcproj: Ditto.
     23        * WebCore.xcodeproj/project.pbxproj: Ditto.
     24        * WebCoreSources.bkl: Ditto.
     25        * bindings/js/JSConsoleCustom.cpp: Added.
     26        (WebCore::JSConsole::error):
     27        (WebCore::JSConsole::info):
     28        (WebCore::JSConsole::log):
     29        (WebCore::JSConsole::warn):
     30        * page/Console.cpp: Changed all methods to take an ExecState* and a
     31        const List&. The first item in the List is toString()ed and passed to
     32        Chrome.
     33        (WebCore::Console::error):
     34        (WebCore::Console::info):
     35        (WebCore::Console::log):
     36        (WebCore::Console::warn):
     37        * page/Console.h:
     38        * page/Console.idl:
     39
    1402008-04-16  Sam Weinig  <sam@webkit.org>
    241
  • trunk/WebCore/GNUmakefile.am

    r31893 r31950  
    474474        WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp \
    475475        WebCore/bindings/js/JSClipboardCustom.cpp \
     476        WebCore/bindings/js/JSConsoleCustom.cpp \
    476477        WebCore/bindings/js/JSCSSRuleCustom.cpp \
    477478        WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp \
  • trunk/WebCore/WebCore.pro

    r31899 r31950  
    406406    bindings/js/JSCanvasRenderingContext2DCustom.cpp \
    407407    bindings/js/JSClipboardCustom.cpp \
     408    bindings/js/JSConsoleCustom.cpp \
    408409    bindings/js/JSCSSRuleCustom.cpp \
    409410    bindings/js/JSCSSStyleDeclarationCustom.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r31923 r31950  
    1309513095                                </File>
    1309613096                                <File
     13097                                        RelativePath="..\bindings\js\JSConsoleCustom.cpp"
     13098                                        >
     13099                                </File>
     13100                                <File
    1309713101                                        RelativePath="..\bindings\js\JSCSSRuleCustom.cpp"
    1309813102                                        >
     
    1570015704                                <File
    1570115705                                        RelativePath="..\ForwardingHeaders\kjs\JSLock.h"
     15706                                        >
     15707                                </File>
     15708                                <File
     15709                                        RelativePath="..\ForwardingHeaders\kjs\list.h"
    1570215710                                        >
    1570315711                                </File>
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r31923 r31950  
    38483848                C091588E0DB4209200E55AF4 /* JSQuarantinedObjectWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C09158880DB4209200E55AF4 /* JSQuarantinedObjectWrapper.cpp */; };
    38493849                C091588F0DB4209200E55AF4 /* JSQuarantinedObjectWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = C09158890DB4209200E55AF4 /* JSQuarantinedObjectWrapper.h */; };
     3850                C0DFC8700DB6841A003EAE7C /* JSConsoleCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */; };
    38503851                C6D74AD509AA282E000B0A52 /* ModifySelectionListLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = C6D74AD309AA282E000B0A52 /* ModifySelectionListLevel.h */; };
    38513852                C6D74AE409AA290A000B0A52 /* ModifySelectionListLevel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C6D74AE309AA290A000B0A52 /* ModifySelectionListLevel.cpp */; };
     
    81378138                C09158880DB4209200E55AF4 /* JSQuarantinedObjectWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSQuarantinedObjectWrapper.cpp; sourceTree = "<group>"; };
    81388139                C09158890DB4209200E55AF4 /* JSQuarantinedObjectWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSQuarantinedObjectWrapper.h; sourceTree = "<group>"; };
     8140                C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSConsoleCustom.cpp; sourceTree = "<group>"; };
    81398141                C6D74AD309AA282E000B0A52 /* ModifySelectionListLevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModifySelectionListLevel.h; sourceTree = "<group>"; };
    81408142                C6D74AE309AA290A000B0A52 /* ModifySelectionListLevel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModifySelectionListLevel.cpp; sourceTree = "<group>"; };
     
    1197311975                                E4EEFFC60D34550C00469A58 /* JSAudioConstructor.cpp */,
    1197411976                                E4EEFFC70D34550C00469A58 /* JSAudioConstructor.h */,
     11977                                C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */,
    1197511978                                E10B93C20B73C291003ED890 /* JSCustomXPathNSResolver.cpp */,
    1197611979                                E10B937B0B73C00A003ED890 /* JSCustomXPathNSResolver.h */,
     
    1659016593                                1A8F6BC20DB55CDC001DB794 /* DOMApplicationCache.cpp in Sources */,
    1659116594                                1A8F6BC50DB55CDC001DB794 /* ManifestParser.cpp in Sources */,
     16595                                C0DFC8700DB6841A003EAE7C /* JSConsoleCustom.cpp in Sources */,
    1659216596                        );
    1659316597                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/WebCoreSources.bkl

    r31893 r31950  
    4040        bindings/js/JSCanvasRenderingContext2DCustom.cpp
    4141        bindings/js/JSClipboardCustom.cpp
     42        bindings/js/JSConsoleCustom.cpp
    4243        bindings/js/JSCSSRuleCustom.cpp
    4344        bindings/js/JSCSSStyleDeclarationCustom.cpp
  • trunk/WebCore/page/Console.cpp

    r30434 r31950  
    3535#include "Page.h"
    3636#include "PlatformString.h"
     37#include <kjs/list.h>
     38
     39using namespace KJS;
    3740
    3841namespace WebCore {
     
    4851}
    4952
    50 void Console::error(const String& message)
     53void Console::error(ExecState* exec, const List& arguments)
    5154{
     55    if (arguments.isEmpty())
     56        return;
     57
    5258    if (!m_frame)
    5359        return;
     
    5763        return;
    5864
    59     page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, message, 0, m_frame->loader()->url().prettyURL());
     65    page->chrome()->addMessageToConsole(JSMessageSource, ErrorMessageLevel, arguments[0]->toString(exec), 0, m_frame->loader()->url().prettyURL());
    6066}
    6167
    62 void Console::info(const String& message)
     68void Console::info(ExecState* exec, const List& arguments)
    6369{
     70    if (arguments.isEmpty())
     71        return;
     72
    6473    if (!m_frame)
    6574        return;
     
    6978        return;
    7079
    71     page->chrome()->addMessageToConsole(JSMessageSource, LogMessageLevel, message, 0, m_frame->loader()->url().prettyURL());
     80    page->chrome()->addMessageToConsole(JSMessageSource, LogMessageLevel, arguments[0]->toString(exec), 0, m_frame->loader()->url().prettyURL());
    7281}
    7382
    74 void Console::log(const String& message)
     83void Console::log(ExecState* exec, const List& arguments)
    7584{
     85    if (arguments.isEmpty())
     86        return;
     87
    7688    if (!m_frame)
    7789        return;
     
    8193        return;
    8294
    83     page->chrome()->addMessageToConsole(JSMessageSource, LogMessageLevel, message, 0, m_frame->loader()->url().prettyURL());
     95    page->chrome()->addMessageToConsole(JSMessageSource, LogMessageLevel, arguments[0]->toString(exec), 0, m_frame->loader()->url().prettyURL());
    8496}
    8597
    86 void Console::warn(const String& message)
     98void Console::warn(ExecState* exec, const List& arguments)
    8799{
     100    if (arguments.isEmpty())
     101        return;
     102
    88103    if (!m_frame)
    89104        return;
     
    93108        return;
    94109
    95     page->chrome()->addMessageToConsole(JSMessageSource, WarningMessageLevel, message, 0, m_frame->loader()->url().prettyURL());
     110    page->chrome()->addMessageToConsole(JSMessageSource, WarningMessageLevel, arguments[0]->toString(exec), 0, m_frame->loader()->url().prettyURL());
    96111}
    97112
  • trunk/WebCore/page/Console.h

    r30434 r31950  
    3131
    3232#include <wtf/RefCounted.h>
    33 #include "PlatformString.h"
     33
     34#include <wtf/PassRefPtr.h>
     35
     36namespace KJS {
     37    class ExecState;
     38    class List;
     39}
    3440
    3541namespace WebCore {
     
    4349        void disconnectFrame();
    4450
    45         void error(const String& message);
    46         void info(const String& message);
    47         void log(const String& message);
    48         void warn(const String& message);
     51        void error(KJS::ExecState*, const KJS::List& arguments);
     52        void info(KJS::ExecState*, const KJS::List& arguments);
     53        void log(KJS::ExecState*, const KJS::List& arguments);
     54        void warn(KJS::ExecState*, const KJS::List& arguments);
    4955
    5056    private:
  • trunk/WebCore/page/Console.idl

    r29672 r31950  
    11/*
    2  * Copyright (C) 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131    interface Console {
    32         void error(in DOMString message);
    33         void info(in DOMString message);
    34         void log(in DOMString message);
    35         void warn(in DOMString message);
     32        [Custom] void error();
     33        [Custom] void info();
     34        [Custom] void log();
     35        [Custom] void warn();
    3636    };
    3737
Note: See TracChangeset for help on using the changeset viewer.