diff options
author | Steve Block <steveblock@google.com> | 2010-02-05 14:27:46 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-15 10:49:50 +0000 |
commit | 5e2bc6953fe6923165b8a5d7679939693a1d58d6 (patch) | |
tree | 6ccb8c24bc2bf5e8f413e6cfae250b729b426631 | |
parent | 4a00f4fccc3cb7e9996749a05631f5d7b9de756e (diff) | |
download | external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.zip external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.tar.gz external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.tar.bz2 |
Merge webkit.org at r54340 : Initial merge by git
Change-Id: Ib489d2ff91186ea3652522e1d586e54416a2cf44
405 files changed, 15436 insertions, 3504 deletions
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index 3f64567..578e282 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,335 @@ +2010-02-04 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> + + Reviewed by Simon Hausmann. + + Increase test coverage for the QScriptValue. + + https://bugs.webkit.org/show_bug.cgi?id=34533 + + * qt/tests/qscriptvalue/qscriptvalue.pro: + * qt/tests/qscriptvalue/tst_qscriptvalue.cpp: + (tst_QScriptValue::tst_QScriptValue): + (tst_QScriptValue::~tst_QScriptValue): + (tst_QScriptValue::dataHelper): + (tst_QScriptValue::newRow): + (tst_QScriptValue::testHelper): + (tst_QScriptValue::ctor): + * qt/tests/qscriptvalue/tst_qscriptvalue.h: Added. + * qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp: Added. + (tst_QScriptValue::initScriptValues): + (tst_QScriptValue::isValid_initData): + (tst_QScriptValue::isValid_makeData): + (tst_QScriptValue::isValid_test): + (tst_QScriptValue::isBool_initData): + (tst_QScriptValue::isBool_makeData): + (tst_QScriptValue::isBool_test): + (tst_QScriptValue::isBoolean_initData): + (tst_QScriptValue::isBoolean_makeData): + (tst_QScriptValue::isBoolean_test): + (tst_QScriptValue::isFunction_initData): + (tst_QScriptValue::isFunction_makeData): + (tst_QScriptValue::isFunction_test): + (tst_QScriptValue::isNull_initData): + (tst_QScriptValue::isNull_makeData): + (tst_QScriptValue::isNull_test): + (tst_QScriptValue::isString_initData): + (tst_QScriptValue::isString_makeData): + (tst_QScriptValue::isString_test): + (tst_QScriptValue::isUndefined_initData): + (tst_QScriptValue::isUndefined_makeData): + (tst_QScriptValue::isUndefined_test): + (tst_QScriptValue::isObject_initData): + (tst_QScriptValue::isObject_makeData): + (tst_QScriptValue::isObject_test): + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Define WTF_PLATFORM_BREWMP_SIMULATOR when AEE_SIMULATOR is defined + https://bugs.webkit.org/show_bug.cgi?id=34514 + + PLATFORM(BREWMP_SIMULATOR) guard is needed to make distinction between BREWMP + and BREWMP simulator. + + * wtf/Platform.h: + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Remove COMPILE_ASSERT conflict with the underlying PLATFORM + https://bugs.webkit.org/show_bug.cgi?id=34190 + + COMPILE_ASSERT conflicts with the underlying PLATFORM because it is defined + both in WTF's Assertions.h and BREWMP's AEEClassIDs.h. Include AEEClassIDs.h + in Assertions.h and undef COMPILE_ASSERT to avoid redefining COMPILE_ASSERT. + + * wtf/Assertions.h: + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Implement OwnPtrBrew to make sure BREW instances are freed. + https://bugs.webkit.org/show_bug.cgi?id=34518 + + Add OwnPtrBrew to release IFile, IFileMgr and IBitmap instances. + + * wtf/brew/OwnPtrBrew.cpp: Added. + (WTF::IFileMgr): + (WTF::IFile): + (WTF::IBitmap): + (WTF::freeOwnedPtrBrew): + * wtf/brew/OwnPtrBrew.h: Added. + (WTF::OwnPtrBrew::OwnPtrBrew): + (WTF::OwnPtrBrew::~OwnPtrBrew): + (WTF::OwnPtrBrew::get): + (WTF::OwnPtrBrew::release): + (WTF::OwnPtrBrew::outPtr): + (WTF::OwnPtrBrew::set): + (WTF::OwnPtrBrew::clear): + (WTF::OwnPtrBrew::operator*): + (WTF::OwnPtrBrew::operator->): + (WTF::OwnPtrBrew::operator!): + (WTF::OwnPtrBrew::operator UnspecifiedBoolType): + (WTF::OwnPtrBrew::swap): + (WTF::swap): + (WTF::operator==): + (WTF::operator!=): + (WTF::getPtr): + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Darin Adler. + + Export WTF::fastStrDup symbol + https://bugs.webkit.org/show_bug.cgi?id=34526 + + * JavaScriptCore.exp: + +2010-02-03 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + [wx] Enable JIT compilation for wx. + + https://bugs.webkit.org/show_bug.cgi?id=34536 + + * wtf/Platform.h: + +2010-02-02 Oliver Hunt <oliver@apple.com> + + Reviewed by Geoffrey Garen. + + Crash in CollectorBitmap::get at nbcolympics.com + https://bugs.webkit.org/show_bug.cgi?id=34504 + + This was caused by the use of m_offset to determine the offset of + a new property into the property storage. This patch corrects + the effected cases by incorporating the anonymous slot count. It + also removes the duplicate copy of anonymous slot count from the + property table as keeping this up to date merely increased the + chance of a mismatch. Finally I've added a large number of + assertions in an attempt to prevent such a bug from happening + again. + + With the new assertions in place the existing anonymous slot tests + all fail without the m_offset fixes. + + * runtime/PropertyMapHashTable.h: + * runtime/Structure.cpp: + (JSC::Structure::materializePropertyMap): + (JSC::Structure::addPropertyTransitionToExistingStructure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::removePropertyTransition): + (JSC::Structure::flattenDictionaryStructure): + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::removePropertyWithoutTransition): + (JSC::Structure::copyPropertyTable): + (JSC::Structure::get): + (JSC::Structure::put): + (JSC::Structure::remove): + (JSC::Structure::insertIntoPropertyMapHashTable): + (JSC::Structure::createPropertyMapHashTable): + (JSC::Structure::rehashPropertyMapHashTable): + (JSC::Structure::checkConsistency): + +2010-02-02 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Darin Adler. + + Copyright year updating for Windows version resources should be automatic + https://bugs.webkit.org/show_bug.cgi?id=34503 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Add dummy main thread functions + https://bugs.webkit.org/show_bug.cgi?id=33569 + + Add dummy initializeMainThreadPlatform and + scheduleDispatchFunctionsOnMainThread. + + * wtf/brew/MainThreadBrew.cpp: Added. + (WTF::initializeMainThreadPlatform): + (WTF::scheduleDispatchFunctionsOnMainThread): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Darin Adler. + + Add using WTF::getLocalTime to CurrentTime.h + https://bugs.webkit.org/show_bug.cgi?id=34493 + + * wtf/CurrentTime.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Add HAVE_XXX definitions + https://bugs.webkit.org/show_bug.cgi?id=34414 + + Add HAVE_ERRNO_H=1 + + * wtf/Platform.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Don't define HAVE_TM_GMTOFF, HAVE_TM_ZONE and HAVE_TIMEGM + https://bugs.webkit.org/show_bug.cgi?id=34388 + + BREWMP does not have these features. + + * wtf/Platform.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Define WTF_PLATFORM_BREWMP=1 when BUILDING_BREWMP is defined + https://bugs.webkit.org/show_bug.cgi?id=34386 + + Define WTF_PLATFORM_BREWMP=1 so that PLATFORM(BREWMP) guard can be used. + + * wtf/Platform.h: + +2010-02-01 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Date.UTC() should apply TimeClip operation. + https://bugs.webkit.org/show_bug.cgi?id=34461 + + ECMAScript 5 15.9.4.3: + > 9 Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + * runtime/DateConstructor.cpp: + (JSC::dateUTC): Calls WTF::timeClip(). + +2010-02-01 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Fix a bug that Math.round() retunrs incorrect results for huge integers + https://bugs.webkit.org/show_bug.cgi?id=34462 + + * runtime/MathObject.cpp: + (JSC::mathProtoFuncRound): Avoid "arg + 0.5". + +2010-02-01 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port WTF's currentTime + https://bugs.webkit.org/show_bug.cgi?id=33567 + + Combine GETUTCSECONDS and GETTIMEMS to calculate the number + of milliseconds since 1970/01/01 00:00:00 UTC. + + * wtf/CurrentTime.cpp: + (WTF::currentTime): + +2010-02-01 Patrick Gansterer <paroga@paroga.com> + + Reviewed by Darin Adler. + + [Qt] WinCE buildfix after r52729 and fix for Q_BIG_ENDIAN typo. + https://bugs.webkit.org/show_bug.cgi?id=34378 + + * wtf/Platform.h: + +2010-02-01 Oliver Hunt <oliver@apple.com> + + Reviewed by Gavin Barraclough. + + Structure not accounting for anonymous slots when computing property storage size + https://bugs.webkit.org/show_bug.cgi?id=34441 + + Previously any Structure with anonymous storage would have a property map, so we + were only including anonymous slot size if there was a property map. Given this + is no longer the case we should always include the anonymous slot count in the + property storage size. + + * runtime/Structure.h: + (JSC::Structure::propertyStorageSize): + +2010-02-01 Oliver Hunt <oliver@apple.com> + + Windows build fix, update exports file (again) + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-02-01 Oliver Hunt <oliver@apple.com> + + Windows build fix, update exports file + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-01-31 Oliver Hunt <oliver@apple.com> + + Reviewed by Maciej Stachowiak. + + JSC is failing to propagate anonymous slot count on some transitions + https://bugs.webkit.org/show_bug.cgi?id=34321 + + Remove secondary Structure constructor, and make Structure store a copy + of the number of anonymous slots directly so saving an immediate allocation + of a property map for all structures with anonymous storage, which also + avoids the leaked property map on new property transition in the original + version of this patch. + + We need to propagate the the anonymous slot count otherwise we can end up + with a structure recording incorrect information about the available and + needed space for property storage, or alternatively incorrectly reusing + some slots. + + * JavaScriptCore.exp: + * runtime/Structure.cpp: + (JSC::Structure::Structure): + (JSC::Structure::materializePropertyMap): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::changePrototypeTransition): + (JSC::Structure::despecifyFunctionTransition): + (JSC::Structure::getterSetterTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::flattenDictionaryStructure): + (JSC::Structure::copyPropertyTable): + (JSC::Structure::put): + (JSC::Structure::remove): + (JSC::Structure::insertIntoPropertyMapHashTable): + (JSC::Structure::createPropertyMapHashTable): + * runtime/Structure.h: + (JSC::Structure::create): + (JSC::Structure::hasAnonymousSlots): + (JSC::Structure::anonymousSlotCount): + 2010-01-31 Patrick Gansterer <paroga@paroga.com> Reviewed by Darin Adler. diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp index 3821992..01d3144 100644 --- a/JavaScriptCore/JavaScriptCore.exp +++ b/JavaScriptCore/JavaScriptCore.exp @@ -292,7 +292,7 @@ __ZN3JSC9Structure27despecifyFunctionTransitionEPS0_RKNS_10IdentifierE __ZN3JSC9Structure28addPropertyWithoutTransitionERKNS_10IdentifierEjPNS_6JSCellE __ZN3JSC9Structure3getEPKNS_11UStringImplERjRPNS_6JSCellE __ZN3JSC9Structure40addPropertyTransitionToExistingStructureEPS0_RKNS_10IdentifierEjPNS_6JSCellERm -__ZN3JSC9StructureC1ENS_7JSValueERKNS_8TypeInfoE +__ZN3JSC9StructureC1ENS_7JSValueERKNS_8TypeInfoEj __ZN3JSC9StructureD1Ev __ZN3JSC9constructEPNS_9ExecStateENS_7JSValueENS_13ConstructTypeERKNS_13ConstructDataERKNS_7ArgListE __ZN3JSCeqERKNS_7UStringEPKc @@ -348,6 +348,7 @@ __ZN3WTF8Collator18setOrderLowerFirstEb __ZN3WTF8CollatorC1EPKc __ZN3WTF8CollatorD1Ev __ZN3WTF8fastFreeEPv +__ZN3WTF10fastStrDupEPKc __ZN3WTF8msToYearEd __ZN3WTF9dayInYearEdi __ZN3WTF9ByteArray6createEm diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def index 65ba684..6a0f1d8 100644 --- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def +++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def @@ -14,7 +14,7 @@ EXPORTS ??0PrototypeFunction@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@HABVIdentifier@1@P6I?AVJSValue@1@0PAVJSObject@1@V61@ABVArgList@1@@Z@Z ??0RefCountedLeakCounter@WTF@@QAE@PBD@Z ??0StringObject@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVUString@1@@Z - ??0Structure@JSC@@AAE@VJSValue@1@ABVTypeInfo@1@@Z + ??0Structure@JSC@@AAE@VJSValue@1@ABVTypeInfo@1@I@Z ??0ThreadCondition@WTF@@QAE@XZ ??0UString@JSC@@QAE@PBD@Z ??0UString@JSC@@QAE@PB_WH@Z diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc index 861fa3a..e09e26e 100644 --- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc +++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc @@ -34,7 +34,7 @@ BEGIN VALUE "FileVersion", __VERSION_TEXT__ VALUE "CompanyName", "Apple Inc." VALUE "InternalName", "JavaScriptCore" - VALUE "LegalCopyright", "Copyright Apple Inc. 2003-2010" + VALUE "LegalCopyright", "Copyright Apple Inc. 2003-" __COPYRIGHT_YEAR_END_TEXT__ VALUE "OriginalFilename", "JavaScriptCore.dll" VALUE "ProductName", " JavaScriptCore" VALUE "ProductVersion", __VERSION_TEXT__ diff --git a/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro b/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro index 1ce5bc3..b12337f 100644 --- a/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro +++ b/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro @@ -3,5 +3,9 @@ TARGET = tst_qscriptvalue QT += testlib include(../tests.pri) -SOURCES += tst_qscriptvalue.cpp +SOURCES += \ + tst_qscriptvalue.cpp \ + tst_qscriptvalue_generated.cpp +HEADERS += \ + tst_qscriptvalue.h diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp index 336a1a6..b44c5ca 100644 --- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp @@ -17,35 +17,43 @@ Boston, MA 02110-1301, USA. */ -#include "qscriptengine.h" -#include "qscriptvalue.h" -#include <QtTest/qtest.h> - -Q_DECLARE_METATYPE(QScriptValue*); -Q_DECLARE_METATYPE(QScriptValue); - -class tst_QScriptValue : public QObject { - Q_OBJECT - -public: - tst_QScriptValue() {} - virtual ~tst_QScriptValue() {} - -private slots: - void toString_data(); - void toString(); - void copyConstructor_data(); - void copyConstructor(); - void assignOperator_data(); - void assignOperator(); - void dataSharing(); - void constructors_data(); - void constructors(); - void call(); - - // copied from Qt's QtScript. - void ctor(); -}; +#include "tst_qscriptvalue.h" +#include <QtCore/qnumeric.h> + +tst_QScriptValue::tst_QScriptValue() + : engine(0) +{ +} + +tst_QScriptValue::~tst_QScriptValue() +{ + delete engine; +} + +void tst_QScriptValue::dataHelper(InitDataFunction init, DefineDataFunction define) +{ + QTest::addColumn<QString>("__expression__"); + (this->*init)(); + QHash<QString, QScriptValue>::const_iterator it; + for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) { + m_currentExpression = it.key(); + (this->*define)(it.key().toLatin1()); + } + m_currentExpression = QString(); +} + +QTestData& tst_QScriptValue::newRow(const char* tag) +{ + return QTest::newRow(tag) << m_currentExpression; +} + +void tst_QScriptValue::testHelper(TestFunction fun) +{ + QFETCH(QString, __expression__); + QScriptValue value = m_values.value(__expression__); + (this->*fun)(__expression__.toLatin1(), value); +} + void tst_QScriptValue::ctor() { @@ -53,7 +61,7 @@ void tst_QScriptValue::ctor() { QScriptValue v; QCOMPARE(v.isValid(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(&eng, QScriptValue::UndefinedValue); @@ -168,14 +176,14 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isValid(), true); QCOMPARE(v.isUndefined(), true); QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(QScriptValue::NullValue); QCOMPARE(v.isValid(), true); QCOMPARE(v.isNull(), true); QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(false); @@ -184,7 +192,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isBool(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toBoolean(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(int(1)); @@ -192,7 +200,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(uint(1)); @@ -200,7 +208,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(1.0); @@ -208,7 +216,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v("ciao"); @@ -216,7 +224,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(QString("ciao")); @@ -224,19 +232,19 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } // copy constructor, operator= { QScriptValue v(1.0); QScriptValue v2(v); QCOMPARE(v2.strictlyEquals(v), true); - QCOMPARE(v2.engine(), (QScriptEngine *)0); + QCOMPARE(v2.engine(), (QScriptEngine*)0); QScriptValue v3(v); QCOMPARE(v3.strictlyEquals(v), true); QCOMPARE(v3.strictlyEquals(v2), true); - QCOMPARE(v3.engine(), (QScriptEngine *)0); + QCOMPARE(v3.engine(), (QScriptEngine*)0); QScriptValue v4(2.0); QCOMPARE(v4.strictlyEquals(v), false); @@ -423,5 +431,5 @@ void tst_QScriptValue::call() QVERIFY(incr.call().isValid()); // Exception. } + QTEST_MAIN(tst_QScriptValue) -#include "tst_qscriptvalue.moc" diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h new file mode 100644 index 0000000..ae81c49 --- /dev/null +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h @@ -0,0 +1,133 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef tst_qscriptvalue_h +#define tst_qscriptvalue_h + +#include "qscriptengine.h" +#include "qscriptvalue.h" +#include <QtCore/qnumeric.h> +#include <QtTest/qtest.h> + +Q_DECLARE_METATYPE(QScriptValue*); +Q_DECLARE_METATYPE(QScriptValue); + +class tst_QScriptValue : public QObject { + Q_OBJECT + +public: + tst_QScriptValue(); + virtual ~tst_QScriptValue(); + +private slots: + void toString_data(); + void toString(); + void copyConstructor_data(); + void copyConstructor(); + void assignOperator_data(); + void assignOperator(); + void dataSharing(); + void constructors_data(); + void constructors(); + void call(); + void ctor(); + + // Generated test functions. + void isBool_data(); + void isBool(); + + void isBoolean_data(); + void isBoolean(); + + void isFunction_data(); + void isFunction(); + + void isNull_data(); + void isNull(); + + void isObject_data(); + void isObject(); + + void isString_data(); + void isString(); + + void isUndefined_data(); + void isUndefined(); + + void isValid_data(); + void isValid(); + +private: + typedef void (tst_QScriptValue::*InitDataFunction)(); + typedef void (tst_QScriptValue::*DefineDataFunction)(const char*); + void dataHelper(InitDataFunction init, DefineDataFunction define); + QTestData& newRow(const char* tag); + + typedef void (tst_QScriptValue::*TestFunction)(const char*, const QScriptValue&); + void testHelper(TestFunction fun); + + // Generated functions + + void initScriptValues(); + + void isBool_initData(); + void isBool_makeData(const char* expr); + void isBool_test(const char* expr, const QScriptValue& value); + + void isBoolean_initData(); + void isBoolean_makeData(const char* expr); + void isBoolean_test(const char* expr, const QScriptValue& value); + + void isFunction_initData(); + void isFunction_makeData(const char* expr); + void isFunction_test(const char* expr, const QScriptValue& value); + + void isNull_initData(); + void isNull_makeData(const char* expr); + void isNull_test(const char* expr, const QScriptValue& value); + + void isObject_initData(); + void isObject_makeData(const char* expr); + void isObject_test(const char* expr, const QScriptValue& value); + + void isString_initData(); + void isString_makeData(const char* expr); + void isString_test(const char* expr, const QScriptValue& value); + + void isUndefined_initData(); + void isUndefined_makeData(const char* expr); + void isUndefined_test(const char* expr, const QScriptValue& value); + + void isValid_initData(); + void isValid_makeData(const char* expr); + void isValid_test(const char* expr, const QScriptValue& value); + +private: + QScriptEngine* engine; + QHash<QString, QScriptValue> m_values; + QString m_currentExpression; +}; + +#define DEFINE_TEST_FUNCTION(name) \ +void tst_QScriptValue::name##_data() { dataHelper(&tst_QScriptValue::name##_initData, &tst_QScriptValue::name##_makeData); } \ +void tst_QScriptValue::name() { testHelper(&tst_QScriptValue::name##_test); } + + + +#endif // tst_qscriptvalue_h diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp new file mode 100644 index 0000000..6d8ef48 --- /dev/null +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp @@ -0,0 +1,495 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tst_qscriptvalue.h" + +#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr) + +void tst_QScriptValue::initScriptValues() +{ + m_values.clear(); + if (engine) + delete engine; + engine = new QScriptEngine; + DEFINE_TEST_VALUE(QScriptValue()); + DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue)); + DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue)); + DEFINE_TEST_VALUE(QScriptValue(true)); + DEFINE_TEST_VALUE(QScriptValue(false)); + DEFINE_TEST_VALUE(QScriptValue(int(122))); + DEFINE_TEST_VALUE(QScriptValue(uint(124))); + DEFINE_TEST_VALUE(QScriptValue(0)); + DEFINE_TEST_VALUE(QScriptValue(0.0)); + DEFINE_TEST_VALUE(QScriptValue(123.0)); + DEFINE_TEST_VALUE(QScriptValue(6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(-6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(0x43211234)); + DEFINE_TEST_VALUE(QScriptValue(0x10000)); + DEFINE_TEST_VALUE(QScriptValue(0x10001)); + DEFINE_TEST_VALUE(QScriptValue(qSNaN())); + DEFINE_TEST_VALUE(QScriptValue(qQNaN())); + DEFINE_TEST_VALUE(QScriptValue(qInf())); + DEFINE_TEST_VALUE(QScriptValue(-qInf())); + DEFINE_TEST_VALUE(QScriptValue("NaN")); + DEFINE_TEST_VALUE(QScriptValue("Infinity")); + DEFINE_TEST_VALUE(QScriptValue("-Infinity")); + DEFINE_TEST_VALUE(QScriptValue("ciao")); + DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao"))); + DEFINE_TEST_VALUE(QScriptValue(QString(""))); + DEFINE_TEST_VALUE(QScriptValue(QString())); + DEFINE_TEST_VALUE(QScriptValue(QString("0"))); + DEFINE_TEST_VALUE(QScriptValue(QString("123"))); + DEFINE_TEST_VALUE(QScriptValue(QString("12.4"))); + DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue)); + DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue)); + DEFINE_TEST_VALUE(QScriptValue(0, true)); + DEFINE_TEST_VALUE(QScriptValue(0, false)); + DEFINE_TEST_VALUE(QScriptValue(0, int(122))); + DEFINE_TEST_VALUE(QScriptValue(0, uint(124))); + DEFINE_TEST_VALUE(QScriptValue(0, 0)); + DEFINE_TEST_VALUE(QScriptValue(0, 0.0)); + DEFINE_TEST_VALUE(QScriptValue(0, 123.0)); + DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234)); + DEFINE_TEST_VALUE(QScriptValue(0, 0x10000)); + DEFINE_TEST_VALUE(QScriptValue(0, 0x10001)); + DEFINE_TEST_VALUE(QScriptValue(0, qSNaN())); + DEFINE_TEST_VALUE(QScriptValue(0, qQNaN())); + DEFINE_TEST_VALUE(QScriptValue(0, qInf())); + DEFINE_TEST_VALUE(QScriptValue(0, -qInf())); + DEFINE_TEST_VALUE(QScriptValue(0, "NaN")); + DEFINE_TEST_VALUE(QScriptValue(0, "Infinity")); + DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity")); + DEFINE_TEST_VALUE(QScriptValue(0, "ciao")); + DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao"))); + DEFINE_TEST_VALUE(QScriptValue(0, QString(""))); + DEFINE_TEST_VALUE(QScriptValue(0, QString())); + DEFINE_TEST_VALUE(QScriptValue(0, QString("0"))); + DEFINE_TEST_VALUE(QScriptValue(0, QString("123"))); + DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue)); + DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue)); + DEFINE_TEST_VALUE(QScriptValue(engine, true)); + DEFINE_TEST_VALUE(QScriptValue(engine, false)); + DEFINE_TEST_VALUE(QScriptValue(engine, int(122))); + DEFINE_TEST_VALUE(QScriptValue(engine, uint(124))); + DEFINE_TEST_VALUE(QScriptValue(engine, 0)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0.0)); + DEFINE_TEST_VALUE(QScriptValue(engine, 123.0)); + DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001)); + DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN())); + DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN())); + DEFINE_TEST_VALUE(QScriptValue(engine, qInf())); + DEFINE_TEST_VALUE(QScriptValue(engine, -qInf())); + DEFINE_TEST_VALUE(QScriptValue(engine, "NaN")); + DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity")); + DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity")); + DEFINE_TEST_VALUE(QScriptValue(engine, "ciao")); + DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString(""))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString())); + DEFINE_TEST_VALUE(QScriptValue(engine, QString("0"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString("123"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23"))); + DEFINE_TEST_VALUE(engine->evaluate("[]")); + DEFINE_TEST_VALUE(engine->evaluate("{}")); + DEFINE_TEST_VALUE(engine->evaluate("Object.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Date.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Array.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Function.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Error.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Object")); + DEFINE_TEST_VALUE(engine->evaluate("Array")); + DEFINE_TEST_VALUE(engine->evaluate("Number")); + DEFINE_TEST_VALUE(engine->evaluate("Function")); + DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })")); + DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })")); + DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo'); })")); + DEFINE_TEST_VALUE(engine->evaluate("/foo/")); + DEFINE_TEST_VALUE(engine->evaluate("new Object()")); + DEFINE_TEST_VALUE(engine->evaluate("new Array()")); + DEFINE_TEST_VALUE(engine->evaluate("new Error()")); +} + + +void tst_QScriptValue::isValid_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isValid_makeData(const char* expr) +{ + static QSet<QString> isValid; + if (isValid.isEmpty()) { + isValid << "QScriptValue(QScriptValue::UndefinedValue)" + << "QScriptValue(QScriptValue::NullValue)" + << "QScriptValue(true)" + << "QScriptValue(false)" + << "QScriptValue(int(122))" + << "QScriptValue(uint(124))" + << "QScriptValue(0)" + << "QScriptValue(0.0)" + << "QScriptValue(123.0)" + << "QScriptValue(6.37e-8)" + << "QScriptValue(-6.37e-8)" + << "QScriptValue(0x43211234)" + << "QScriptValue(0x10000)" + << "QScriptValue(0x10001)" + << "QScriptValue(qSNaN())" + << "QScriptValue(qQNaN())" + << "QScriptValue(qInf())" + << "QScriptValue(-qInf())" + << "QScriptValue(\"NaN\")" + << "QScriptValue(\"Infinity\")" + << "QScriptValue(\"-Infinity\")" + << "QScriptValue(\"ciao\")" + << "QScriptValue(QString::fromLatin1(\"ciao\"))" + << "QScriptValue(QString(\"\"))" + << "QScriptValue(QString())" + << "QScriptValue(QString(\"0\"))" + << "QScriptValue(QString(\"123\"))" + << "QScriptValue(QString(\"12.4\"))" + << "QScriptValue(0, QScriptValue::UndefinedValue)" + << "QScriptValue(0, QScriptValue::NullValue)" + << "QScriptValue(0, true)" + << "QScriptValue(0, false)" + << "QScriptValue(0, int(122))" + << "QScriptValue(0, uint(124))" + << "QScriptValue(0, 0)" + << "QScriptValue(0, 0.0)" + << "QScriptValue(0, 123.0)" + << "QScriptValue(0, 6.37e-8)" + << "QScriptValue(0, -6.37e-8)" + << "QScriptValue(0, 0x43211234)" + << "QScriptValue(0, 0x10000)" + << "QScriptValue(0, 0x10001)" + << "QScriptValue(0, qSNaN())" + << "QScriptValue(0, qQNaN())" + << "QScriptValue(0, qInf())" + << "QScriptValue(0, -qInf())" + << "QScriptValue(0, \"NaN\")" + << "QScriptValue(0, \"Infinity\")" + << "QScriptValue(0, \"-Infinity\")" + << "QScriptValue(0, \"ciao\")" + << "QScriptValue(0, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(0, QString(\"\"))" + << "QScriptValue(0, QString())" + << "QScriptValue(0, QString(\"0\"))" + << "QScriptValue(0, QString(\"123\"))" + << "QScriptValue(0, QString(\"12.3\"))" + << "QScriptValue(engine, QScriptValue::UndefinedValue)" + << "QScriptValue(engine, QScriptValue::NullValue)" + << "QScriptValue(engine, true)" + << "QScriptValue(engine, false)" + << "QScriptValue(engine, int(122))" + << "QScriptValue(engine, uint(124))" + << "QScriptValue(engine, 0)" + << "QScriptValue(engine, 0.0)" + << "QScriptValue(engine, 123.0)" + << "QScriptValue(engine, 6.37e-8)" + << "QScriptValue(engine, -6.37e-8)" + << "QScriptValue(engine, 0x43211234)" + << "QScriptValue(engine, 0x10000)" + << "QScriptValue(engine, 0x10001)" + << "QScriptValue(engine, qSNaN())" + << "QScriptValue(engine, qQNaN())" + << "QScriptValue(engine, qInf())" + << "QScriptValue(engine, -qInf())" + << "QScriptValue(engine, \"NaN\")" + << "QScriptValue(engine, \"Infinity\")" + << "QScriptValue(engine, \"-Infinity\")" + << "QScriptValue(engine, \"ciao\")" + << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(engine, QString(\"\"))" + << "QScriptValue(engine, QString())" + << "QScriptValue(engine, QString(\"0\"))" + << "QScriptValue(engine, QString(\"123\"))" + << "QScriptValue(engine, QString(\"1.23\"))" + << "engine->evaluate(\"[]\")" + << "engine->evaluate(\"{}\")" + << "engine->evaluate(\"Object.prototype\")" + << "engine->evaluate(\"Date.prototype\")" + << "engine->evaluate(\"Array.prototype\")" + << "engine->evaluate(\"Function.prototype\")" + << "engine->evaluate(\"Error.prototype\")" + << "engine->evaluate(\"Object\")" + << "engine->evaluate(\"Array\")" + << "engine->evaluate(\"Number\")" + << "engine->evaluate(\"Function\")" + << "engine->evaluate(\"(function() { return 1; })\")" + << "engine->evaluate(\"(function() { return 'ciao'; })\")" + << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" + << "engine->evaluate(\"/foo/\")" + << "engine->evaluate(\"new Object()\")" + << "engine->evaluate(\"new Array()\")" + << "engine->evaluate(\"new Error()\")"; + } + newRow(expr) << isValid.contains(expr); +} + +void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isValid(), expected); +} + +DEFINE_TEST_FUNCTION(isValid) + + +void tst_QScriptValue::isBool_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isBool_makeData(const char* expr) +{ + static QSet<QString> isBool; + if (isBool.isEmpty()) { + isBool << "QScriptValue(true)" + << "QScriptValue(false)" + << "QScriptValue(0, true)" + << "QScriptValue(0, false)" + << "QScriptValue(engine, true)" + << "QScriptValue(engine, false)"; + } + newRow(expr) << isBool.contains(expr); +} + +void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isBool(), expected); +} + +DEFINE_TEST_FUNCTION(isBool) + + +void tst_QScriptValue::isBoolean_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isBoolean_makeData(const char* expr) +{ + static QSet<QString> isBoolean; + if (isBoolean.isEmpty()) { + isBoolean << "QScriptValue(true)" + << "QScriptValue(false)" + << "QScriptValue(0, true)" + << "QScriptValue(0, false)" + << "QScriptValue(engine, true)" + << "QScriptValue(engine, false)"; + } + newRow(expr) << isBoolean.contains(expr); +} + +void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isBoolean(), expected); +} + +DEFINE_TEST_FUNCTION(isBoolean) + + +void tst_QScriptValue::isFunction_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isFunction_makeData(const char* expr) +{ + static QSet<QString> isFunction; + if (isFunction.isEmpty()) { + isFunction << "engine->evaluate(\"Function.prototype\")" + << "engine->evaluate(\"Object\")" + << "engine->evaluate(\"Array\")" + << "engine->evaluate(\"Number\")" + << "engine->evaluate(\"Function\")" + << "engine->evaluate(\"(function() { return 1; })\")" + << "engine->evaluate(\"(function() { return 'ciao'; })\")" + << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" + << "engine->evaluate(\"/foo/\")"; + } + newRow(expr) << isFunction.contains(expr); +} + +void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isFunction(), expected); +} + +DEFINE_TEST_FUNCTION(isFunction) + + +void tst_QScriptValue::isNull_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isNull_makeData(const char* expr) +{ + static QSet<QString> isNull; + if (isNull.isEmpty()) { + isNull << "QScriptValue(QScriptValue::NullValue)" + << "QScriptValue(0, QScriptValue::NullValue)" + << "QScriptValue(engine, QScriptValue::NullValue)"; + } + newRow(expr) << isNull.contains(expr); +} + +void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isNull(), expected); +} + +DEFINE_TEST_FUNCTION(isNull) + + +void tst_QScriptValue::isString_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isString_makeData(const char* expr) +{ + static QSet<QString> isString; + if (isString.isEmpty()) { + isString << "QScriptValue(\"NaN\")" + << "QScriptValue(\"Infinity\")" + << "QScriptValue(\"-Infinity\")" + << "QScriptValue(\"ciao\")" + << "QScriptValue(QString::fromLatin1(\"ciao\"))" + << "QScriptValue(QString(\"\"))" + << "QScriptValue(QString())" + << "QScriptValue(QString(\"0\"))" + << "QScriptValue(QString(\"123\"))" + << "QScriptValue(QString(\"12.4\"))" + << "QScriptValue(0, \"NaN\")" + << "QScriptValue(0, \"Infinity\")" + << "QScriptValue(0, \"-Infinity\")" + << "QScriptValue(0, \"ciao\")" + << "QScriptValue(0, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(0, QString(\"\"))" + << "QScriptValue(0, QString())" + << "QScriptValue(0, QString(\"0\"))" + << "QScriptValue(0, QString(\"123\"))" + << "QScriptValue(0, QString(\"12.3\"))" + << "QScriptValue(engine, \"NaN\")" + << "QScriptValue(engine, \"Infinity\")" + << "QScriptValue(engine, \"-Infinity\")" + << "QScriptValue(engine, \"ciao\")" + << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(engine, QString(\"\"))" + << "QScriptValue(engine, QString())" + << "QScriptValue(engine, QString(\"0\"))" + << "QScriptValue(engine, QString(\"123\"))" + << "QScriptValue(engine, QString(\"1.23\"))"; + } + newRow(expr) << isString.contains(expr); +} + +void tst_QScriptValue::isString_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isString(), expected); +} + +DEFINE_TEST_FUNCTION(isString) + + +void tst_QScriptValue::isUndefined_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isUndefined_makeData(const char* expr) +{ + static QSet<QString> isUndefined; + if (isUndefined.isEmpty()) { + isUndefined << "QScriptValue(QScriptValue::UndefinedValue)" + << "QScriptValue(0, QScriptValue::UndefinedValue)" + << "QScriptValue(engine, QScriptValue::UndefinedValue)" + << "engine->evaluate(\"{}\")"; + } + newRow(expr) << isUndefined.contains(expr); +} + +void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isUndefined(), expected); +} + +DEFINE_TEST_FUNCTION(isUndefined) + +void tst_QScriptValue::isObject_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isObject_makeData(const char* expr) +{ + static QSet<QString> isObject; + if (isObject.isEmpty()) { + isObject << "engine->evaluate(\"[]\")" + << "engine->evaluate(\"Object.prototype\")" + << "engine->evaluate(\"Date.prototype\")" + << "engine->evaluate(\"Array.prototype\")" + << "engine->evaluate(\"Function.prototype\")" + << "engine->evaluate(\"Error.prototype\")" + << "engine->evaluate(\"Object\")" + << "engine->evaluate(\"Array\")" + << "engine->evaluate(\"Number\")" + << "engine->evaluate(\"Function\")" + << "engine->evaluate(\"(function() { return 1; })\")" + << "engine->evaluate(\"(function() { return 'ciao'; })\")" + << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" + << "engine->evaluate(\"/foo/\")" + << "engine->evaluate(\"new Object()\")" + << "engine->evaluate(\"new Array()\")" + << "engine->evaluate(\"new Error()\")"; + } + newRow(expr) << isObject.contains(expr); +} + +void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isObject(), expected); +} + +DEFINE_TEST_FUNCTION(isObject) + + diff --git a/JavaScriptCore/runtime/DateConstructor.cpp b/JavaScriptCore/runtime/DateConstructor.cpp index 2e476b3..e9a5c29 100644 --- a/JavaScriptCore/runtime/DateConstructor.cpp +++ b/JavaScriptCore/runtime/DateConstructor.cpp @@ -177,7 +177,7 @@ static JSValue JSC_HOST_CALL dateUTC(ExecState* exec, JSObject*, JSValue, const t.minute = args.at(4).toInt32(exec); t.second = args.at(5).toInt32(exec); double ms = (n >= 7) ? args.at(6).toNumber(exec) : 0; - return jsNumber(exec, gregorianDateTimeToMS(exec, t, ms, true)); + return jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true))); } } // namespace JSC diff --git a/JavaScriptCore/runtime/MathObject.cpp b/JavaScriptCore/runtime/MathObject.cpp index 98ff3ba..8f22fba 100644 --- a/JavaScriptCore/runtime/MathObject.cpp +++ b/JavaScriptCore/runtime/MathObject.cpp @@ -218,7 +218,8 @@ JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec, JSObject*, JSValue, co double arg = args.at(0).toNumber(exec); if (signbit(arg) && arg >= -0.5) return jsNumber(exec, -0.0); - return jsNumber(exec, floor(arg + 0.5)); + double integer = ceil(arg); + return jsNumber(exec, integer - (integer - arg > 0.5)); } JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec, JSObject*, JSValue, const ArgList& args) diff --git a/JavaScriptCore/runtime/PropertyMapHashTable.h b/JavaScriptCore/runtime/PropertyMapHashTable.h index 5b63f79..44dc2b8 100644 --- a/JavaScriptCore/runtime/PropertyMapHashTable.h +++ b/JavaScriptCore/runtime/PropertyMapHashTable.h @@ -61,7 +61,6 @@ namespace JSC { unsigned size; unsigned keyCount; unsigned deletedSentinelCount; - unsigned anonymousSlotCount; unsigned lastIndexUsed; Vector<unsigned>* deletedOffsets; unsigned entryIndices[1]; diff --git a/JavaScriptCore/runtime/Structure.cpp b/JavaScriptCore/runtime/Structure.cpp index 77330aa..546e2bf 100644 --- a/JavaScriptCore/runtime/Structure.cpp +++ b/JavaScriptCore/runtime/Structure.cpp @@ -123,7 +123,7 @@ void Structure::dumpStatistics() #endif } -Structure::Structure(JSValue prototype, const TypeInfo& typeInfo) +Structure::Structure(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount) : m_typeInfo(typeInfo) , m_prototype(prototype) , m_specificValueInPrevious(0) @@ -135,6 +135,7 @@ Structure::Structure(JSValue prototype, const TypeInfo& typeInfo) , m_hasGetterSetterProperties(false) , m_attributesInPrevious(0) , m_specificFunctionThrashCount(0) + , m_anonymousSlotCount(anonymousSlotCount) { ASSERT(m_prototype); ASSERT(m_prototype.isObject() || m_prototype.isNull()); @@ -275,7 +276,7 @@ void Structure::materializePropertyMap() for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) { structure = structures[i]; structure->m_nameInPrevious->ref(); - PropertyMapEntry entry(structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious, ++m_propertyTable->lastIndexUsed); + PropertyMapEntry entry(structure->m_nameInPrevious.get(), m_anonymousSlotCount + structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious, ++m_propertyTable->lastIndexUsed); insertIntoPropertyMapHashTable(entry); } } @@ -341,7 +342,9 @@ PassRefPtr<Structure> Structure::addPropertyTransitionToExistingStructure(Struct if (Structure* existingTransition = structure->table.get(make_pair(propertyName.ustring().rep(), attributes), specificValue)) { ASSERT(existingTransition->m_offset != noOffset); - offset = existingTransition->m_offset; + offset = existingTransition->m_offset + existingTransition->m_anonymousSlotCount; + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == existingTransition->m_anonymousSlotCount); return existingTransition; } @@ -361,12 +364,14 @@ PassRefPtr<Structure> Structure::addPropertyTransition(Structure* structure, con RefPtr<Structure> transition = toCacheableDictionaryTransition(structure); ASSERT(structure != transition); offset = transition->put(propertyName, attributes, specificValue); + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == transition->m_anonymousSlotCount); if (transition->propertyStorageSize() > transition->propertyStorageCapacity()) transition->growPropertyStorageCapacity(); return transition.release(); } - RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo()); + RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo(), structure->anonymousSlotCount()); transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain; transition->m_previous = structure; @@ -393,11 +398,13 @@ PassRefPtr<Structure> Structure::addPropertyTransition(Structure* structure, con } offset = transition->put(propertyName, attributes, specificValue); + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == transition->m_anonymousSlotCount); if (transition->propertyStorageSize() > transition->propertyStorageCapacity()) transition->growPropertyStorageCapacity(); - transition->m_offset = offset; - + transition->m_offset = offset - structure->m_anonymousSlotCount; + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); structure->table.add(make_pair(propertyName.ustring().rep(), attributes), transition.get(), specificValue); return transition.release(); } @@ -409,13 +416,15 @@ PassRefPtr<Structure> Structure::removePropertyTransition(Structure* structure, RefPtr<Structure> transition = toUncacheableDictionaryTransition(structure); offset = transition->remove(propertyName); + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == transition->m_anonymousSlotCount); return transition.release(); } PassRefPtr<Structure> Structure::changePrototypeTransition(Structure* structure, JSValue prototype) { - RefPtr<Structure> transition = create(prototype, structure->typeInfo()); + RefPtr<Structure> transition = create(prototype, structure->typeInfo(), structure->anonymousSlotCount()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; @@ -427,14 +436,15 @@ PassRefPtr<Structure> Structure::changePrototypeTransition(Structure* structure, structure->materializePropertyMapIfNecessary(); transition->m_propertyTable = structure->copyPropertyTable(); transition->m_isPinnedPropertyTable = true; - + + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } PassRefPtr<Structure> Structure::despecifyFunctionTransition(Structure* structure, const Identifier& replaceFunction) { ASSERT(structure->m_specificFunctionThrashCount < maxSpecificFunctionThrashCount); - RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo()); + RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; @@ -453,13 +463,14 @@ PassRefPtr<Structure> Structure::despecifyFunctionTransition(Structure* structur bool removed = transition->despecifyFunction(replaceFunction); ASSERT_UNUSED(removed, removed); } - + + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure) { - RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo()); + RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = transition->m_hasGetterSetterProperties; transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; @@ -470,7 +481,8 @@ PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure) structure->materializePropertyMapIfNecessary(); transition->m_propertyTable = structure->copyPropertyTable(); transition->m_isPinnedPropertyTable = true; - + + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } @@ -478,7 +490,7 @@ PassRefPtr<Structure> Structure::toDictionaryTransition(Structure* structure, Di { ASSERT(!structure->isUncacheableDictionary()); - RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo()); + RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo(), structure->anonymousSlotCount()); transition->m_dictionaryKind = kind; transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; @@ -489,6 +501,7 @@ PassRefPtr<Structure> Structure::toDictionaryTransition(Structure* structure, Di transition->m_propertyTable = structure->copyPropertyTable(); transition->m_isPinnedPropertyTable = true; + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } @@ -522,7 +535,7 @@ PassRefPtr<Structure> Structure::flattenDictionaryStructure(JSObject* object) // in the order that they are expected to be in, but we need to // reorder the storage, so we have to copy the current values out Vector<JSValue> values(propertyCount); - unsigned anonymousSlotCount = m_propertyTable->anonymousSlotCount; + unsigned anonymousSlotCount = m_anonymousSlotCount; for (unsigned i = 0; i < propertyCount; i++) { PropertyMapEntry* entry = sortedPropertyEntries[i]; values[i] = object->getDirectOffset(entry->offset); @@ -557,6 +570,7 @@ size_t Structure::addPropertyWithoutTransition(const Identifier& propertyName, u m_isPinnedPropertyTable = true; size_t offset = put(propertyName, attributes, specificValue); + ASSERT(offset >= m_anonymousSlotCount); if (propertyStorageSize() > propertyStorageCapacity()) growPropertyStorageCapacity(); return offset; @@ -571,6 +585,7 @@ size_t Structure::removePropertyWithoutTransition(const Identifier& propertyName m_isPinnedPropertyTable = true; size_t offset = remove(propertyName); + ASSERT(offset >= m_anonymousSlotCount); return offset; } @@ -627,7 +642,6 @@ PropertyMapHashTable* Structure::copyPropertyTable() if (m_propertyTable->deletedOffsets) newTable->deletedOffsets = new Vector<unsigned>(*m_propertyTable->deletedOffsets); - newTable->anonymousSlotCount = m_propertyTable->anonymousSlotCount; return newTable; } @@ -650,6 +664,7 @@ size_t Structure::get(const UString::Rep* rep, unsigned& attributes, JSCell*& sp if (rep == m_propertyTable->entries()[entryIndex - 1].key) { attributes = m_propertyTable->entries()[entryIndex - 1].attributes; specificValue = m_propertyTable->entries()[entryIndex - 1].specificValue; + ASSERT(m_propertyTable->entries()[entryIndex - 1].offset >= m_anonymousSlotCount); return m_propertyTable->entries()[entryIndex - 1].offset; } @@ -673,6 +688,7 @@ size_t Structure::get(const UString::Rep* rep, unsigned& attributes, JSCell*& sp if (rep == m_propertyTable->entries()[entryIndex - 1].key) { attributes = m_propertyTable->entries()[entryIndex - 1].attributes; specificValue = m_propertyTable->entries()[entryIndex - 1].specificValue; + ASSERT(m_propertyTable->entries()[entryIndex - 1].offset >= m_anonymousSlotCount); return m_propertyTable->entries()[entryIndex - 1].offset; } } @@ -821,9 +837,10 @@ size_t Structure::put(const Identifier& propertyName, unsigned attributes, JSCel newOffset = m_propertyTable->deletedOffsets->last(); m_propertyTable->deletedOffsets->removeLast(); } else - newOffset = m_propertyTable->keyCount + m_propertyTable->anonymousSlotCount; + newOffset = m_propertyTable->keyCount + m_anonymousSlotCount; m_propertyTable->entries()[entryIndex - 1].offset = newOffset; - + + ASSERT(newOffset >= m_anonymousSlotCount); ++m_propertyTable->keyCount; if ((m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount) * 2 >= m_propertyTable->size) @@ -887,6 +904,7 @@ size_t Structure::remove(const Identifier& propertyName) m_propertyTable->entryIndices[i & m_propertyTable->sizeMask] = deletedSentinelIndex; size_t offset = m_propertyTable->entries()[entryIndex - 1].offset; + ASSERT(offset >= m_anonymousSlotCount); key->deref(); m_propertyTable->entries()[entryIndex - 1].key = 0; @@ -912,7 +930,7 @@ size_t Structure::remove(const Identifier& propertyName) void Structure::insertIntoPropertyMapHashTable(const PropertyMapEntry& entry) { ASSERT(m_propertyTable); - + ASSERT(entry.offset >= m_anonymousSlotCount); unsigned i = entry.key->existingHash(); unsigned k = 0; @@ -991,7 +1009,6 @@ void Structure::rehashPropertyMapHashTable(unsigned newTableSize) m_propertyTable = static_cast<PropertyMapHashTable*>(fastZeroedMalloc(PropertyMapHashTable::allocationSize(newTableSize))); m_propertyTable->size = newTableSize; m_propertyTable->sizeMask = newTableSize - 1; - m_propertyTable->anonymousSlotCount = oldTable->anonymousSlotCount; unsigned lastIndexUsed = 0; unsigned entryCount = oldTable->keyCount + oldTable->deletedSentinelCount; @@ -1121,6 +1138,7 @@ void Structure::checkConsistency() for (unsigned c = 1; c <= m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount; ++c) { ASSERT(m_hasNonEnumerableProperties || !(m_propertyTable->entries()[c].attributes & DontEnum)); UString::Rep* rep = m_propertyTable->entries()[c].key; + ASSERT(m_propertyTable->entries()[c].offset >= m_anonymousSlotCount); if (!rep) continue; ++nonEmptyEntryCount; diff --git a/JavaScriptCore/runtime/Structure.h b/JavaScriptCore/runtime/Structure.h index f73f9b8..1353a5a 100644 --- a/JavaScriptCore/runtime/Structure.h +++ b/JavaScriptCore/runtime/Structure.h @@ -62,15 +62,7 @@ namespace JSC { friend class StructureTransitionTable; static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount) { - Structure* structure = (new Structure(prototype, typeInfo)); - if (anonymousSlotCount) { - structure->materializePropertyMap(); - structure->m_isPinnedPropertyTable = true; - structure->m_propertyTable->anonymousSlotCount = anonymousSlotCount; - // Currently we don't allow more anonymous slots than fit in the inline capacity - ASSERT(structure->propertyStorageSize() <= structure->propertyStorageCapacity()); - } - return adoptRef(structure); + return adoptRef(new Structure(prototype, typeInfo, anonymousSlotCount)); } static void startIgnoringLeaks(); @@ -109,7 +101,7 @@ namespace JSC { void growPropertyStorageCapacity(); unsigned propertyStorageCapacity() const { return m_propertyStorageCapacity; } - unsigned propertyStorageSize() const { return m_propertyTable ? m_propertyTable->keyCount + m_propertyTable->anonymousSlotCount + (m_propertyTable->deletedOffsets ? m_propertyTable->deletedOffsets->size() : 0) : m_offset + 1; } + unsigned propertyStorageSize() const { return m_anonymousSlotCount + (m_propertyTable ? m_propertyTable->keyCount + (m_propertyTable->deletedOffsets ? m_propertyTable->deletedOffsets->size() : 0) : m_offset + 1); } bool isUsingInlineStorage() const; size_t get(const Identifier& propertyName); @@ -134,8 +126,8 @@ namespace JSC { bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; } - bool hasAnonymousSlots() const { return m_propertyTable && m_propertyTable->anonymousSlotCount; } - unsigned anonymousSlotCount() const { return m_propertyTable ? m_propertyTable->anonymousSlotCount : 0; } + bool hasAnonymousSlots() const { return !!m_anonymousSlotCount; } + unsigned anonymousSlotCount() const { return m_anonymousSlotCount; } bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; } @@ -147,12 +139,8 @@ namespace JSC { void getPropertyNames(PropertyNameArray&, EnumerationMode mode); private: - static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo) - { - return adoptRef(new Structure(prototype, typeInfo)); - } - Structure(JSValue prototype, const TypeInfo&); + Structure(JSValue prototype, const TypeInfo&, unsigned anonymousSlotCount); typedef enum { NoneDictionaryKind = 0, @@ -216,6 +204,8 @@ namespace JSC { PropertyMapHashTable* m_propertyTable; uint32_t m_propertyStorageCapacity; + + // m_offset does not account for anonymous slots signed char m_offset; unsigned m_dictionaryKind : 2; @@ -231,7 +221,8 @@ namespace JSC { unsigned m_attributesInPrevious : 7; #endif unsigned m_specificFunctionThrashCount : 2; - // 10 free bits + unsigned m_anonymousSlotCount : 5; + // 5 free bits }; inline size_t Structure::get(const Identifier& propertyName) diff --git a/JavaScriptCore/wtf/Assertions.h b/JavaScriptCore/wtf/Assertions.h index 352a74b..0e02af5 100644 --- a/JavaScriptCore/wtf/Assertions.h +++ b/JavaScriptCore/wtf/Assertions.h @@ -179,6 +179,14 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann #undef ASSERT #endif +#if PLATFORM(BREWMP) +/* FIXME: We include this here only to avoid a conflict with the COMPILE_ASSERT macro. */ +#include <AEEClassIDs.h> + +/* FIXME: Change to use something other than COMPILE_ASSERT to avoid this conflict with the underlying platform */ +#undef COMPILE_ASSERT +#endif + #if ASSERT_DISABLED #define ASSERT(assertion) ((void)0) diff --git a/JavaScriptCore/wtf/CurrentTime.cpp b/JavaScriptCore/wtf/CurrentTime.cpp index b272874..30ca7c3 100644 --- a/JavaScriptCore/wtf/CurrentTime.cpp +++ b/JavaScriptCore/wtf/CurrentTime.cpp @@ -59,6 +59,8 @@ extern "C" time_t mktime(struct tm *t); #include <glib.h> #elif PLATFORM(WX) #include <wx/datetime.h> +#elif PLATFORM(BREWMP) +#include <AEEStdLib.h> #else // Posix systems relying on the gettimeofday() #include <sys/time.h> #endif @@ -277,6 +279,20 @@ double currentTime() return (double)now.GetTicks() + (double)(now.GetMillisecond() / 1000.0); } +#elif PLATFORM(BREWMP) + +// GETUTCSECONDS returns the number of seconds since 1980/01/06 00:00:00 UTC, +// and GETTIMEMS returns the number of milliseconds that have elapsed since the last +// occurrence of 00:00:00 local time. +// We can combine GETUTCSECONDS and GETTIMEMS to calculate the number of milliseconds +// since 1970/01/01 00:00:00 UTC. +double currentTime() +{ + // diffSeconds is the number of seconds from 1970/01/01 to 1980/01/06 + const unsigned diffSeconds = 315964800; + return static_cast<double>(diffSeconds + GETUTCSECONDS() + ((GETTIMEMS() % 1000) / msPerSecond)); +} + #else // Other Posix systems rely on the gettimeofday(). double currentTime() diff --git a/JavaScriptCore/wtf/CurrentTime.h b/JavaScriptCore/wtf/CurrentTime.h index 334a6e9..033448f 100644 --- a/JavaScriptCore/wtf/CurrentTime.h +++ b/JavaScriptCore/wtf/CurrentTime.h @@ -61,6 +61,7 @@ namespace WTF { } // namespace WTF using WTF::currentTime; +using WTF::getLocalTime; #endif // CurrentTime_h diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h index 810c829..166a955 100644 --- a/JavaScriptCore/wtf/Platform.h +++ b/JavaScriptCore/wtf/Platform.h @@ -415,6 +415,13 @@ #define WTF_PLATFORM_GTK 1 #elif defined(BUILDING_HAIKU__) #define WTF_PLATFORM_HAIKU 1 +#elif defined(BUILDING_BREWMP__) +#define WTF_PLATFORM_BREWMP 1 +#if defined(AEE_SIMULATOR) +#define WTF_PLATFORM_BREWMP_SIMULATOR 1 +#else +#define WTF_PLATFORM_BREWMP_SIMULATOR 0 +#endif #elif OS(DARWIN) #define WTF_PLATFORM_MAC 1 #elif OS(WINDOWS) @@ -481,10 +488,10 @@ */ #if OS(WINCE) && PLATFORM(QT) # include <QtGlobal> -# undef WTF_PLATFORM_BIG_ENDIAN -# undef WTF_PLATFORM_MIDDLE_ENDIAN -# if Q_BYTE_ORDER == Q_BIG_EDIAN -# define WTF_PLATFORM_BIG_ENDIAN 1 +# undef WTF_CPU_BIG_ENDIAN +# undef WTF_CPU_MIDDLE_ENDIAN +# if Q_BYTE_ORDER == Q_BIG_ENDIAN +# define WTF_CPU_BIG_ENDIAN 1 # endif # include <ce_time.h> @@ -632,7 +639,7 @@ #if !OS(WINDOWS) && !OS(SOLARIS) && !OS(QNX) \ && !OS(SYMBIAN) && !OS(HAIKU) && !OS(RVCT) \ - && !OS(ANDROID) + && !OS(ANDROID) && !PLATFORM(BREWMP) #define HAVE_TM_GMTOFF 1 #define HAVE_TM_ZONE 1 #define HAVE_TIMEGM 1 @@ -688,6 +695,10 @@ #define HAVE_SYS_PARAM_H 1 #endif +#elif PLATFORM(BREWMP) + +#define HAVE_ERRNO_H 1 + #elif OS(QNX) #define HAVE_ERRNO_H 1 @@ -854,7 +865,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #define ENABLE_JIT 1 #endif -#if PLATFORM(QT) +#if PLATFORM(QT) || PLATFORM(WX) #if CPU(X86_64) && OS(DARWIN) #define ENABLE_JIT 1 #elif CPU(X86) && OS(DARWIN) @@ -918,8 +929,13 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #if (CPU(X86) && PLATFORM(MAC)) \ || (CPU(X86_64) && PLATFORM(MAC)) \ || (CPU(ARM_THUMB2) && PLATFORM(IPHONE)) \ +<<<<<<< HEAD || (CPU(ARM_THUMB2) && PLATFORM(ANDROID) && ENABLE(ANDROID_JSC_JIT)) \ || (CPU(X86) && PLATFORM(WIN)) +======= + || (CPU(X86) && PLATFORM(WIN)) \ + || (CPU(X86) && PLATFORM(WX)) +>>>>>>> webkit.org at r54340 #define ENABLE_YARR 1 #define ENABLE_YARR_JIT 1 #endif diff --git a/JavaScriptCore/wtf/brew/MainThreadBrew.cpp b/JavaScriptCore/wtf/brew/MainThreadBrew.cpp new file mode 100644 index 0000000..2690ea5 --- /dev/null +++ b/JavaScriptCore/wtf/brew/MainThreadBrew.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "MainThread.h" + +namespace WTF { + +void initializeMainThreadPlatform() +{ + // not implemented +} + +void scheduleDispatchFunctionsOnMainThread() +{ + // not implemented +} + +} // namespace WTF + diff --git a/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp b/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp new file mode 100644 index 0000000..dadd82e --- /dev/null +++ b/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Company 100, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "OwnPtrBrew.h" + +#include <AEEBitmap.h> +#include <AEEFile.h> +#include <AEEStdLib.h> + +namespace WTF { + +template <> void freeOwnedPtrBrew<IFileMgr>(IFileMgr* ptr) +{ + if (ptr) + IFILEMGR_Release(ptr); +} + +template <> void freeOwnedPtrBrew<IFile>(IFile* ptr) +{ + if (ptr) + IFILE_Release(ptr); +} + +template <> void freeOwnedPtrBrew<IBitmap>(IBitmap* ptr) +{ + if (ptr) + IBitmap_Release(ptr); +} + +template <typename T> void freeOwnedPtrBrew(T* ptr) +{ + FREEIF(ptr); +} + +} // namespace WTF diff --git a/JavaScriptCore/wtf/brew/OwnPtrBrew.h b/JavaScriptCore/wtf/brew/OwnPtrBrew.h new file mode 100644 index 0000000..1bb44fc --- /dev/null +++ b/JavaScriptCore/wtf/brew/OwnPtrBrew.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Company 100, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef OwnPtrBrew_h +#define OwnPtrBrew_h + +#include <algorithm> +#include <wtf/Assertions.h> +#include <wtf/Noncopyable.h> + +// Forward delcarations at this point avoid the need to include BREW includes +// in WTF headers. +typedef struct _IFileMgr IFileMgr; +typedef struct _IFile IFile; +typedef struct IBitmap IBitmap; + +namespace WTF { + +template <typename T> void freeOwnedPtrBrew(T* ptr); +template<> void freeOwnedPtrBrew<IFileMgr>(IFileMgr*); +template<> void freeOwnedPtrBrew<IFile>(IFile*); +template<> void freeOwnedPtrBrew<IBitmap>(IBitmap*); + +template <typename T> class OwnPtrBrew : public Noncopyable { +public: + explicit OwnPtrBrew(T* ptr = 0) : m_ptr(ptr) { } + ~OwnPtrBrew() { freeOwnedPtrBrew(m_ptr); } + + T* get() const { return m_ptr; } + T* release() + { + T* ptr = m_ptr; + m_ptr = 0; + return ptr; + } + + T*& outPtr() + { + ASSERT(!m_ptr); + return m_ptr; + } + + void set(T* ptr) + { + ASSERT(!ptr || m_ptr != ptr); + freeOwnedPtrBrew(m_ptr); + m_ptr = ptr; + } + + void clear() + { + freeOwnedPtrBrew(m_ptr); + m_ptr = 0; + } + + T& operator*() const + { + ASSERT(m_ptr); + return *m_ptr; + } + + T* operator->() const + { + ASSERT(m_ptr); + return m_ptr; + } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T* OwnPtrBrew::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &OwnPtrBrew::m_ptr : 0; } + + void swap(OwnPtrBrew& o) { std::swap(m_ptr, o.m_ptr); } + +private: + T* m_ptr; +}; + +template <typename T> inline void swap(OwnPtrBrew<T>& a, OwnPtrBrew<T>& b) +{ + a.swap(b); +} + +template <typename T, typename U> inline bool operator==(const OwnPtrBrew<T>& a, U* b) +{ + return a.get() == b; +} + +template <typename T, typename U> inline bool operator==(T* a, const OwnPtrBrew<U>& b) +{ + return a == b.get(); +} + +template <typename T, typename U> inline bool operator!=(const OwnPtrBrew<T>& a, U* b) +{ + return a.get() != b; +} + +template <typename T, typename U> inline bool operator!=(T* a, const OwnPtrBrew<U>& b) +{ + return a != b.get(); +} + +template <typename T> inline typename OwnPtrBrew<T>::PtrType getPtr(const OwnPtrBrew<T>& p) +{ + return p.get(); +} + +} // namespace WTF + +using WTF::OwnPtrBrew; + +#endif // OwnPtrBrew_h diff --git a/WebCore/Android.mk b/WebCore/Android.mk index f153c9c..f2d0245 100644 --- a/WebCore/Android.mk +++ b/WebCore/Android.mk @@ -495,6 +495,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/skia/SkiaUtils.cpp \ platform/graphics/skia/TransformationMatrixSkia.cpp \ \ + platform/graphics/transforms/AffineTransform.cpp \ platform/graphics/transforms/Matrix3DTransformOperation.cpp \ platform/graphics/transforms/MatrixTransformOperation.cpp \ platform/graphics/transforms/PerspectiveTransformOperation.cpp \ diff --git a/WebCore/Android.v8bindings.mk b/WebCore/Android.v8bindings.mk index 602185c..922e233 100644 --- a/WebCore/Android.v8bindings.mk +++ b/WebCore/Android.v8bindings.mk @@ -97,8 +97,17 @@ LOCAL_SRC_FILES += \ \ bindings/v8/custom/V8AbstractWorkerCustom.cpp \ bindings/v8/custom/V8AttrCustom.cpp \ + bindings/v8/custom/V8BarInfoCustom.cpp \ + bindings/v8/custom/V8CSSRuleCustom.cpp \ bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp \ + bindings/v8/custom/V8CSSStyleSheetCustom.cpp \ + bindings/v8/custom/V8CSSValueCustom.cpp \ bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp \ +<<<<<<< HEAD +======= + bindings/v8/custom/V8CanvasPixelArrayCustom.cpp \ + bindings/v8/custom/V8ClientRectListCustom.cpp \ +>>>>>>> webkit.org at r54340 bindings/v8/custom/V8ClipboardCustom.cpp \ bindings/v8/custom/V8ConsoleCustom.cpp \ bindings/v8/custom/V8CoordinatesCustom.cpp \ @@ -112,6 +121,7 @@ LOCAL_SRC_FILES += \ bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp \ bindings/v8/custom/V8CustomVoidCallback.cpp \ bindings/v8/custom/V8DOMApplicationCacheCustom.cpp \ + bindings/v8/custom/V8DOMSelectionCustom.cpp \ bindings/v8/custom/V8DOMWindowCustom.cpp \ bindings/v8/custom/V8DataGridColumnListCustom.cpp \ bindings/v8/custom/V8DatabaseCustom.cpp \ @@ -130,6 +140,7 @@ LOCAL_SRC_FILES += \ bindings/v8/custom/V8HTMLCollectionCustom.cpp \ bindings/v8/custom/V8HTMLDataGridElementCustom.cpp \ bindings/v8/custom/V8HTMLDocumentCustom.cpp \ + bindings/v8/custom/V8HTMLElementCustom.cpp \ bindings/v8/custom/V8HTMLFormElementCustom.cpp \ bindings/v8/custom/V8HTMLFrameElementCustom.cpp \ bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp \ @@ -151,21 +162,29 @@ LOCAL_SRC_FILES += \ bindings/v8/custom/V8NodeFilterCustom.cpp \ bindings/v8/custom/V8NodeIteratorCustom.cpp \ bindings/v8/custom/V8NodeListCustom.cpp \ +<<<<<<< HEAD bindings/v8/custom/V8PopStateEventCustom.cpp \ +======= + bindings/v8/custom/V8ScreenCustom.cpp \ +>>>>>>> webkit.org at r54340 bindings/v8/custom/V8SQLResultSetRowListCustom.cpp \ bindings/v8/custom/V8SQLTransactionCustom.cpp \ bindings/v8/custom/V8WebSocketCustom.cpp ifeq ($(ENABLE_SVG), true) LOCAL_SRC_FILES += \ + bindings/v8/custom/V8SVGDocumentCustom.cpp \ + bindings/v8/custom/V8SVGElementCustom.cpp \ bindings/v8/custom/V8SVGElementInstanceCustom.cpp \ bindings/v8/custom/V8SVGLengthCustom.cpp \ bindings/v8/custom/V8SVGMatrixCustom.cpp + bindings/v8/custom/V8SVGPathSegCustom.cpp \ endif LOCAL_SRC_FILES += \ bindings/v8/custom/V8SharedWorkerCustom.cpp \ bindings/v8/custom/V8StorageCustom.cpp \ + bindings/v8/custom/V8StyleSheetCustom.cpp \ bindings/v8/custom/V8StyleSheetListCustom.cpp \ bindings/v8/custom/V8TreeWalkerCustom.cpp \ bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp \ @@ -185,4 +204,8 @@ LOCAL_SRC_FILES += \ bridge/jni/v8/JNIUtilityPrivate.cpp \ bridge/jni/v8/JavaClassV8.cpp \ bridge/jni/v8/JavaInstanceV8.cpp \ +<<<<<<< HEAD bridge/jni/v8/JavaNPObjectV8.cpp +======= + bridge/jni/v8/JavaNPObject.cpp +>>>>>>> webkit.org at r54340 diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index dfbec52..c738ee0 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,1315 @@ +<<<<<<< HEAD +======= +2010-02-04 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Xan Lopez. + + [Gtk] Check if the renderer() exists in textForObject. + + This is fixing a crash in the textForObject method. It can + happen when inspecting AtkObjects in the accerciser, then + navigating to a new page and still inspecting the old tree. + + In this case the AccessibilityObjectWrapperAtk was still + valid but the included renderer() was returning 0. Add a + check for the accObject->renderer() before trying to use + the result. + + * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: + (textForObject): + +2010-02-04 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Provide strongly typed C++ interface for inspector's injected script. + + https://bugs.webkit.org/show_bug.cgi?id=33616 + + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * bindings/js/JSInjectedScriptHostCustom.cpp: + (WebCore::InjectedScriptHost::injectedScriptFor): + * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: + (WebCore::InjectedScriptHost::injectedScriptFor): + * inspector/InjectedScript.cpp: Added. + (WebCore::InjectedScript::InjectedScript): + (WebCore::InjectedScript::dispatch): + (WebCore::InjectedScript::callFrames): + (WebCore::InjectedScript::wrapAndStringifyForConsole): + (WebCore::InjectedScript::releaseWrapperObjectGroup): + * inspector/InjectedScript.h: Added. + (WebCore::InjectedScript::InjectedScript): + (WebCore::InjectedScript::~InjectedScript): + (WebCore::InjectedScript::hasNoValue): + * inspector/InjectedScriptHost.cpp: + (WebCore::InjectedScriptHost::injectedScriptForId): + (WebCore::InjectedScriptHost::releaseWrapperObjectGroup): + * inspector/InjectedScriptHost.h: + * inspector/InspectorBackend.cpp: + (WebCore::InspectorBackend::dispatchOnInjectedScript): + * inspector/InspectorController.cpp: + (WebCore::InspectorController::InspectorController): + (WebCore::InspectorController::~InspectorController): + (WebCore::InspectorController::inspectedPageDestroyed): + (WebCore::InspectorController::windowScriptObjectAvailable): + (WebCore::InspectorController::scriptObjectReady): + (WebCore::InspectorController::setFrontendProxyObject): + (WebCore::InspectorController::close): + (WebCore::InspectorController::getProfile): + (WebCore::InspectorController::enableDebugger): + (WebCore::InspectorController::didPause): + (WebCore::InspectorController::injectedScriptForNodeId): + * inspector/InspectorController.h: + (WebCore::InspectorController::frontendScriptState): + * inspector/InspectorFrontend.cpp: + (WebCore::InspectorFrontend::addConsoleMessage): + * inspector/front-end/InjectedScript.js: + (injectedScriptConstructor): + +2010-02-04 Philippe Normand <pnormand@igalia.com> + + Rubber stamped by Xan Lopez. + + Missing include, build fix after landing of patch from the bug 34435. + + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + +2010-02-02 Philippe Normand <pnormand@igalia.com> + + Reviewed by Gustavo Noronha Silva. + + [Gtk] libsoup critical warning in media player http cookies injection code + https://bugs.webkit.org/show_bug.cgi?id=34435 + + Fixed the critical warning and refactored the + User-Agent/Referer/cookies injection code, in that order. Previous + order (cookies first) was wrong because if cookies injection could + not be done neither the User-Agent nor Referer were injected. Also + started a non-JSC-specific, gtk-specific GOwnPtr module. + + * GNUmakefile.am: + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + (WebCore::mediaPlayerPrivateSourceChangedCallback): + * platform/gtk/GOwnPtrGtk.cpp: Added. + (WTF::SoupURI): + (WTF::GstElement): + * platform/gtk/GOwnPtrGtk.h: Added. + +2010-02-04 Mikhail Naganov <mnaganov@chromium.org> + + Reviewed by Timothy Hatcher. + + Put JSC-specific debugger & profiler code under "USE(JSC)" defines. + The plan is to enable "JAVASCRIPT_DEBUGGER" in Chromium and then + make this code engine-agnostic. + + https://bugs.webkit.org/show_bug.cgi?id=34531 + + * inspector/InjectedScriptHost.cpp: + * inspector/InjectedScriptHost.h: + * inspector/InspectorBackend.cpp: + * inspector/InspectorBackend.h: + * inspector/InspectorController.cpp: + (WebCore::InspectorController::InspectorController): + (WebCore::InspectorController::setWindowVisible): + (WebCore::InspectorController::scriptObjectReady): + (WebCore::InspectorController::close): + (WebCore::InspectorController::didCommitLoad): + * inspector/InspectorController.h: + * inspector/InspectorFrontend.cpp: + * inspector/InspectorFrontend.h: + * inspector/JavaScriptCallFrame.cpp: + * inspector/JavaScriptCallFrame.h: + * inspector/JavaScriptDebugListener.h: + * inspector/JavaScriptDebugServer.cpp: + * inspector/JavaScriptDebugServer.h: + * inspector/JavaScriptProfile.cpp: + * inspector/JavaScriptProfile.h: + * inspector/JavaScriptProfileNode.cpp: + * inspector/JavaScriptProfileNode.h: + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::continueLoadAfterNavigationPolicy): + * page/Page.cpp: + (WebCore::Page::Page): + +2010-02-03 Nicholas Young <nicholas.young@nokia.com> + + Reviewed by Eric Carlson. + + Defer formatting of times displayed on media controls to the current theme. + https://bugs.webkit.org/show_bug.cgi?id=34405 + + No new tests needed. Refactoring Only. + + * rendering/MediaControlElements.cpp: Removed formatTime() + (WebCore::MediaControlTimeDisplayElement::setCurrentValue): No longer sets inner text + * rendering/MediaControlElements.h: + * rendering/RenderMedia.cpp: + (WebCore::RenderMedia::updateTimeDisplay): Asks the theme to format the time display elements + * rendering/RenderTheme.cpp: + (WebCore::RenderTheme::formatMediaControlsTime): new virtual method + (WebCore::RenderTheme::formatMediaControlsCurrentTime): new virtual method + (WebCore::RenderTheme::formatMediaControlsRemainingTime): new virtual method + * rendering/RenderTheme.h: + +2010-02-03 Steve Falkenburg <sfalken@apple.com> + + Windows Debug_All build fix. + + * platform/graphics/win/WKCACFLayer.cpp: + +2010-02-03 Brady Eidson <beidson@apple.com> + + Reviewed by Alexey Proskuryakov. + + REGRESSION (r51644): WebCore/manual-tests/linkjump-1.html fails + <rdar://problem/7595694> and https://bugs.webkit.org/show_bug.cgi?id=34550 + + Tests: fast/loader/document-with-fragment-url-1.html + fast/loader/document-with-fragment-url-2.html + fast/loader/document-with-fragment-url-3.html + fast/loader/document-with-fragment-url-4.html + + * platform/KURL.cpp: + (WebCore::KURL::init): When resolving new URL from an empty reference relative to an absolute URL, + any fragment identifier from the absolute URL should be removed from the resulting resolution. + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port TextBreakIteratorInternalICU + https://bugs.webkit.org/show_bug.cgi?id=34515 + + Port TextBreakIteratorInternalICU. + + * platform/text/brew/TextBreakIteratorInternalICUBrew.cpp: Added. + (WebCore::currentSearchLocaleID): + (WebCore::currentTextBreakLocaleID): + +2010-02-03 Adele Peterson <adele@apple.com> + + Reviewed by Simon Fraser. + + Fix for <rdar://problem/7594212> + https://bugs.webkit.org/show_bug.cgi?id=34549 - CSS counters crash at http://www.w3.org/TR/css3-content/ + CrashTracer: [USER] 20 crashes in Safari at com.apple.WebCore: WebCore::CounterNode::insertAfter + 319 + + Test: fast/css/counters/counter-before-selector-crash.html + + * rendering/RenderCounter.cpp: (WebCore::updateCounters): nil check. + +2010-02-03 Adele Peterson <adele@apple.com> + + Reviewed by Brady Eidson. + + Initialize the variable in the last checkin to false. I didn't realize DRT relies on this being false. + So ports that want visited link tracking need to set that flag. + + * page/PageGroup.cpp: + +2010-02-03 Adele Peterson <adele@apple.com> + + Reviewed by Brady Eidson. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=34547 + static shouldTrackVisitedLinks is not initialized + + For ports that don't call into WebKit to initialize this, + we should initialize to true so they get the visited link behavior by default. + + * page/PageGroup.cpp: + +2010-02-03 Dan Bernstein <mitz@apple.com> + + Reviewed by Simon Fraser. + + <rdar://problem/7577604> Drag and Drop: background elements are bleeding through + https://bugs.webkit.org/show_bug.cgi?id=34546 + + * manual-tests/drag-image-table-part-decorations.html: Added. + * rendering/RenderFieldset.cpp: + (WebCore::RenderFieldset::paintBoxDecorations): Bail out if this object shouldn’t + paint within the current painting root. + * rendering/RenderTable.cpp: + (WebCore::RenderTable::paintBoxDecorations): Ditto. + * rendering/RenderTableCell.cpp: + (WebCore::RenderTableCell::paintBackgroundsBehindCell): Ditto. + (WebCore::RenderTableCell::paintBoxDecorations): Ditto. + +2010-02-03 Nate Chapin <japhet@chromium.org> + + Unreviewed, Chromium mac build fix. + + [V8] Remove unused V8Proxy* variable from generated wrapping code. + + * bindings/scripts/CodeGeneratorV8.pm: + +2010-02-03 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + [V8] Use toV8() to wrap in the custom bindings, and remove + the old wrapping code from V8DOMWrapper. + + https://bugs.webkit.org/show_bug.cgi?id=32563 + + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/v8/ScriptController.cpp: + * bindings/v8/ScriptObject.cpp: + * bindings/v8/V8AbstractEventListener.cpp: + * bindings/v8/V8Collection.h: + * bindings/v8/V8DOMWindowShell.cpp: + * bindings/v8/V8DOMWrapper.cpp: + * bindings/v8/V8DOMWrapper.h: + * bindings/v8/V8NodeFilterCondition.cpp: + * bindings/v8/V8Proxy.cpp: + * bindings/v8/WorkerContextExecutionProxy.h + * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp: + * bindings/v8/custom/V8CustomPositionCallback.cpp: + * bindings/v8/custom/V8CustomPositionErrorCallback.cpp: + * bindings/v8/custom/V8CustomSQLStatementCallback.cpp: + * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: + * bindings/v8/custom/V8CustomSQLTransactionCallback.cpp: + * bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp: + * bindings/v8/custom/V8DOMWindowCustom.cpp: + * bindings/v8/custom/V8DataGridColumnListCustom.cpp: + * bindings/v8/custom/V8DocumentCustom.cpp: + * bindings/v8/custom/V8DocumentLocationCustom.cpp: + * bindings/v8/custom/V8ElementCustom.cpp: + * bindings/v8/custom/V8EventCustom.cpp: + * bindings/v8/custom/V8HTMLAllCollectionCustom.cpp: + * bindings/v8/custom/V8HTMLAudioElementConstructor.cpp: + * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: + * bindings/v8/custom/V8HTMLCollectionCustom.cpp: + * bindings/v8/custom/V8HTMLDocumentCustom.cpp: + * bindings/v8/custom/V8HTMLFormElementCustom.cpp: + * bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp: + * bindings/v8/custom/V8HTMLImageElementConstructor.cpp: + * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp: + * bindings/v8/custom/V8HTMLSelectElementCustom.cpp: + * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: + * bindings/v8/custom/V8MessageChannelConstructor.cpp: + * bindings/v8/custom/V8MessageEventCustom.cpp: + * bindings/v8/custom/V8NamedNodeMapCustom.cpp: + * bindings/v8/custom/V8NodeIteratorCustom.cpp: + * bindings/v8/custom/V8NodeListCustom.cpp: + * bindings/v8/custom/V8NotificationCenterCustom.cpp: + * bindings/v8/custom/V8SVGMatrixCustom.cpp: + * bindings/v8/custom/V8StyleSheetListCustom.cpp: + * bindings/v8/custom/V8TreeWalkerCustom.cpp: + * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: + * bindings/v8/custom/V8XSLTProcessorCustom.cpp: + +2010-02-03 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Fix drawing buttons in viewless WebKit. + + * platform/mac/ThemeMac.mm: + (WebCore::paintButton): If there is no view, make sure to flip the + context so that the button is drawn correctly. + +2010-02-03 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] WebSockets : Buffer the data in WebKit instead of QtNetwork + https://bugs.webkit.org/show_bug.cgi?id=34425 + + Reverting r54279, it was a misunderstanding. + + * platform/network/qt/SocketStreamHandlePrivate.h: + * platform/network/qt/SocketStreamHandleQt.cpp: + (WebCore::SocketStreamHandlePrivate::SocketStreamHandlePrivate): + (WebCore::SocketStreamHandlePrivate::send): + (WebCore::SocketStreamHandlePrivate::close): + +2010-02-03 Drew Wilson <atwilson@chromium.org> + + Reviewed by Alexey Proskuryakov. + + SharedWorkerScriptLoader should not be an ActiveDOMObject + https://bugs.webkit.org/show_bug.cgi?id=34513 + + Test: Existing tests suffice (fixes test downstream in Chrome). + + * workers/DefaultSharedWorkerRepository.cpp: + (WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader): + Changed to no longer derive from ActiveDOMObject (handles its own refcounting). + (WebCore::SharedWorkerScriptLoader::load): + Now increments own refcount when a load is pending. + (WebCore::SharedWorkerScriptLoader::notifyFinished): + Changed to decrement refcount when load is complete. + * workers/WorkerScriptLoaderClient.h: + Documentation change about reliability of notifyFinished() when used from worker context. + +2010-02-03 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: Inspector renders blank scripts on reloading the webpage. + + https://bugs.webkit.org/show_bug.cgi?id=34537 + + * inspector/front-end/ResourcesPanel.js: + (WebInspector.ResourcesPanel.prototype.recreateViewForResourceIfNeeded): + +2010-02-03 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Provide strongly typed C++ interface for inspector's injected script. + + https://bugs.webkit.org/show_bug.cgi?id=33616 + + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * bindings/js/JSInjectedScriptHostCustom.cpp: + (WebCore::InjectedScriptHost::injectedScriptFor): + * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: + (WebCore::InjectedScriptHost::injectedScriptFor): + * inspector/InjectedScript.cpp: Added. + (WebCore::InjectedScript::InjectedScript): + (WebCore::InjectedScript::dispatch): + (WebCore::InjectedScript::callFrames): + (WebCore::InjectedScript::wrapAndStringify): + (WebCore::InjectedScript::releaseWrapperObjectGroup): + * inspector/InjectedScript.h: Added. + (WebCore::InjectedScript::InjectedScript): + (WebCore::InjectedScript::~InjectedScript): + (WebCore::InjectedScript::hasNoValue): + * inspector/InjectedScriptHost.cpp: + (WebCore::InjectedScriptHost::injectedScriptForId): + (WebCore::InjectedScriptHost::releaseWrapperObjectGroup): + * inspector/InjectedScriptHost.h: + * inspector/InspectorBackend.cpp: + (WebCore::InspectorBackend::dispatchOnInjectedScript): + * inspector/InspectorController.cpp: + (WebCore::InspectorController::InspectorController): + (WebCore::InspectorController::~InspectorController): + (WebCore::InspectorController::inspectedPageDestroyed): + (WebCore::InspectorController::windowScriptObjectAvailable): + (WebCore::InspectorController::scriptObjectReady): + (WebCore::InspectorController::setFrontendProxyObject): + (WebCore::InspectorController::close): + (WebCore::InspectorController::getProfile): + (WebCore::InspectorController::enableDebugger): + (WebCore::InspectorController::didPause): + (WebCore::InspectorController::injectedScriptForNodeId): + * inspector/InspectorController.h: + (WebCore::InspectorController::frontendScriptState): + * inspector/InspectorFrontend.cpp: + (WebCore::InspectorFrontend::addConsoleMessage): + +2010-02-03 Andras Becsi <abecsi@webkit.org> + + Unreviewed build fix. + + [Qt] Roll-out r54281 because it broke the build on the Qt Release bot. + + * platform/graphics/qt/GraphicsLayerQt.cpp: + (WebCore::GraphicsLayerQtImpl::State::State): + (WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl): + (WebCore::GraphicsLayerQtImpl::setBaseTransform): + (WebCore::GraphicsLayerQtImpl::drawContents): + (WebCore::GraphicsLayerQtImpl::notifyChange): + (WebCore::GraphicsLayerQtImpl::flushChanges): + (WebCore::GraphicsLayerQt::setNeedsDisplayInRect): + (WebCore::applyTimingFunction): + (WebCore::webkitAnimationToQtAnimationValue): + (WebCore::AnimationQtBase::updateState): + (WebCore::AnimationQt::updateCurrentTime): + (WebCore::TransformAnimationQt::TransformAnimationQt): + (WebCore::TransformAnimationQt::~TransformAnimationQt): + (WebCore::TransformAnimationQt::applyFrame): + (WebCore::TransformAnimationQt::updateState): + (WebCore::OpacityAnimationQt::updateState): + (WebCore::GraphicsLayerQt::pauseAnimation): + +2010-02-02 Bryan Yeung <bryeung@google.com> + + Reviewed by Darin Adler. + + Avoid using an invalidated KURL object in baseURI. + + https://bugs.webkit.org/show_bug.cgi?id=34492 + + This change fixes baseURI for Chromium (where the KURL implementation + does not allow invalid KURLs to carry relative paths). This is + regression tested by + LayoutTests/svg/W3C-SVG-1.1/struct-image-07-t.svg + + This is a re-application of this patch since it was mistakenly identified as + the cause of a big chromium test regression and rolled out in r54264. + + * dom/Element.cpp: + (WebCore::Element::baseURI): + +2010-02-02 Joel Stanley <joel@jms.id.au> + + Reviewed by David Levin. + + [Chromium] Make setCaretBlinkInterval static. + https://bugs.webkit.org/show_bug.cgi?id=31704 + + This is so it can be called from the newly exposed Chromium API setter + method. + + * rendering/RenderThemeChromiumLinux.cpp: + * rendering/RenderThemeChromiumLinux.h: + +2010-02-02 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] WebSockets : Buffer the data in WebKit instead of QtNetwork + https://bugs.webkit.org/show_bug.cgi?id=34425 + + Buffer the sent data in SocketStreamHandlePrivate instead of relying on + the network layer to do it. This is more robust and more consistent with how + Qt's HTTP stack works. + Close the socket in SocketStreamHandlePrivate::close() regardless of its state. + + No new tests, since no new functionality is introduced. + + * platform/network/qt/SocketStreamHandlePrivate.h: + * platform/network/qt/SocketStreamHandleQt.cpp: + (WebCore::SocketStreamHandlePrivate::SocketStreamHandlePrivate): + (WebCore::SocketStreamHandlePrivate::send): + (WebCore::SocketStreamHandlePrivate::close): + (WebCore::SocketStreamHandlePrivate::socketBytesWritten): + +2010-02-03 Shinichiro Hamaji <hamaji@chromium.org> + + Unreviewed revert of r54259 as it seems to break chromium's unit tests. + The tests pass with r54257 but fail with r54260. + As r54258 and r54260 don't touch code, I'm reverting this change. + + [V8] Generate toV8 conversion helpers, a la JSC bindings. + https://bugs.webkit.org/show_bug.cgi?id=32563 + + * bindings/v8/ScriptController.cpp: + (WebCore::ScriptController::processingUserGesture): + (WebCore::createScriptObject): + (WebCore::ScriptController::createScriptObjectForPluginElement): + * bindings/v8/ScriptObject.cpp: + (WebCore::ScriptGlobalObject::set): + * bindings/v8/V8AbstractEventListener.cpp: + (WebCore::V8AbstractEventListener::handleEvent): + * bindings/v8/V8Collection.h: + (WebCore::getV8Object): + (WebCore::toNativeCollection): + (WebCore::getNamedPropertyOfCollection): + (WebCore::collectionNamedPropertyGetter): + (WebCore::getIndexedPropertyOfCollection): + (WebCore::collectionIndexedPropertyGetter): + (WebCore::nodeCollectionIndexedPropertyEnumerator): + (WebCore::collectionIndexedPropertyEnumerator): + (WebCore::collectionStringOrNullIndexedPropertyGetter): + (WebCore::collectionStringIndexedPropertyGetter): + (WebCore::setCollectionIndexedGetter): + (WebCore::setCollectionNamedGetter): + (WebCore::setCollectionStringOrNullIndexedGetter): + (WebCore::setCollectionStringIndexedGetter): + * bindings/v8/V8DOMWindowShell.cpp: + (WebCore::V8DOMWindowShell::updateDocumentWrapperCache): + * bindings/v8/V8DOMWrapper.cpp: + (WebCore::downcastSVGPathSeg): + (WebCore::V8DOMWrapper::convertSVGElementInstanceToV8Object): + (WebCore::V8DOMWrapper::convertSVGObjectWithContextToV8Object): + (WebCore::V8DOMWrapper::convertToV8Object): + (WebCore::V8DOMWrapper::instantiateV8Object): + (WebCore::V8DOMWrapper::isDOMEventWrapper): + (WebCore::V8DOMWrapper::htmlElementType): + (WebCore::V8DOMWrapper::svgElementType): + (WebCore::V8DOMWrapper::convertEventToV8Object): + (WebCore::): + (WebCore::V8DOMWrapper::convertDocumentToV8Object): + (WebCore::V8DOMWrapper::convertNodeToV8Object): + (WebCore::V8DOMWrapper::convertNewNodeToV8Object): + (WebCore::V8DOMWrapper::convertEventListenerToV8Object): + (WebCore::V8DOMWrapper::convertDOMImplementationToV8Object): + (WebCore::V8DOMWrapper::convertStyleSheetToV8Object): + (WebCore::V8DOMWrapper::convertCSSValueToV8Object): + (WebCore::V8DOMWrapper::convertCSSRuleToV8Object): + (WebCore::V8DOMWrapper::convertWindowToV8Object): + (WebCore::V8DOMWrapper::convertNamedNodeMapToV8Object): + * bindings/v8/V8DOMWrapper.h: + (WebCore::V8DOMWrapper::convertToV8Object): + (WebCore::V8DOMWrapper::convertNodeToV8Object): + (WebCore::V8DOMWrapper::convertNewNodeToV8Object): + (WebCore::V8DOMWrapper::convertEventToV8Object): + (WebCore::V8DOMWrapper::convertEventListenerToV8Object): + (WebCore::V8DOMWrapper::instantiateV8Object): + * bindings/v8/V8NodeFilterCondition.cpp: + (WebCore::V8NodeFilterCondition::acceptNode): + * bindings/v8/V8Proxy.cpp: + (WebCore::V8Proxy::setDOMException): + * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp: + (WebCore::toV8Object): + (WebCore::V8CanvasRenderingContext2D::createPatternCallback): + * bindings/v8/custom/V8CustomPositionCallback.cpp: + (WebCore::V8CustomPositionCallback::handleEvent): + * bindings/v8/custom/V8CustomPositionErrorCallback.cpp: + (WebCore::V8CustomPositionErrorCallback::handleEvent): + * bindings/v8/custom/V8CustomSQLStatementCallback.cpp: + (WebCore::V8CustomSQLStatementCallback::handleEvent): + * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: + (WebCore::V8CustomSQLStatementErrorCallback::handleEvent): + * bindings/v8/custom/V8CustomSQLTransactionCallback.cpp: + (WebCore::V8CustomSQLTransactionCallback::handleEvent): + * bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp: + (WebCore::V8CustomSQLTransactionErrorCallback::handleEvent): + * bindings/v8/custom/V8DOMWindowCustom.cpp: + (WebCore::V8DOMWindow::openCallback): + (WebCore::V8DOMWindow::indexedPropertyGetter): + (WebCore::V8DOMWindow::namedPropertyGetter): + * bindings/v8/custom/V8DataGridColumnListCustom.cpp: + (WebCore::NAMED_PROPERTY_GETTER): + * bindings/v8/custom/V8DocumentCustom.cpp: + (WebCore::V8Document::evaluateCallback): + (WebCore::V8Document::getCSSCanvasContextCallback): + (WebCore::V8Document::implementationAccessorGetter): + * bindings/v8/custom/V8DocumentLocationCustom.cpp: + (WebCore::V8Document::locationAccessorGetter): + * bindings/v8/custom/V8ElementCustom.cpp: + (WebCore::V8Element::setAttributeNodeCallback): + (WebCore::V8Element::setAttributeNodeNSCallback): + * bindings/v8/custom/V8EventCustom.cpp: + (WebCore::V8Event::dataTransferAccessorGetter): + (WebCore::V8Event::clipboardDataAccessorGetter): + * bindings/v8/custom/V8HTMLAllCollectionCustom.cpp: + (WebCore::getNamedItems): + (WebCore::getItem): + (WebCore::V8HTMLAllCollection::callAsFunctionCallback): + * bindings/v8/custom/V8HTMLAudioElementConstructor.cpp: + (WebCore::V8Custom::v8HTMLAudioElementConstructorCallback): + * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: + (WebCore::V8HTMLCanvasElement::getContextCallback): + * bindings/v8/custom/V8HTMLCollectionCustom.cpp: + (WebCore::getNamedItems): + (WebCore::getItem): + (WebCore::V8HTMLCollection::callAsFunctionCallback): + * bindings/v8/custom/V8HTMLDocumentCustom.cpp: + (WebCore::V8HTMLDocument::namedPropertyGetter): + (WebCore::V8HTMLDocument::allAccessorGetter): + * bindings/v8/custom/V8HTMLFormElementCustom.cpp: + (WebCore::V8HTMLFormElement::indexedPropertyGetter): + (WebCore::V8HTMLFormElement::namedPropertyGetter): + * bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp: + (WebCore::V8HTMLFrameSetElement::namedPropertyGetter): + * bindings/v8/custom/V8HTMLImageElementConstructor.cpp: + (WebCore::V8Custom::v8HTMLImageElementConstructorCallback): + * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp: + (WebCore::V8HTMLOptionsCollection::indexedPropertyGetter): + * bindings/v8/custom/V8HTMLSelectElementCustom.cpp: + (WebCore::V8HTMLSelectElement::namedPropertyGetter): + (WebCore::V8HTMLSelectElement::indexedPropertyGetter): + * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: + (WebCore::createInjectedScript): + (WebCore::V8InjectedScriptHost::nodeForIdCallback): + (WebCore::V8InjectedScriptHost::databaseForIdCallback): + * bindings/v8/custom/V8MessageChannelConstructor.cpp: + (WebCore::V8MessageChannel::constructorCallback): + * bindings/v8/custom/V8MessageEventCustom.cpp: + (WebCore::V8MessageEvent::portsAccessorGetter): + * bindings/v8/custom/V8NamedNodeMapCustom.cpp: + (WebCore::V8NamedNodeMap::indexedPropertyGetter): + (WebCore::V8NamedNodeMap::namedPropertyGetter): + * bindings/v8/custom/V8NodeIteratorCustom.cpp: + (WebCore::toV8): + * bindings/v8/custom/V8NodeListCustom.cpp: + (WebCore::V8NodeList::namedPropertyGetter): + (WebCore::V8NodeList::callAsFunctionCallback): + * bindings/v8/custom/V8NotificationCenterCustom.cpp: + (WebCore::V8NotificationCenter::createHTMLNotificationCallback): + (WebCore::V8NotificationCenter::createNotificationCallback): + * bindings/v8/custom/V8SVGMatrixCustom.cpp: + (WebCore::V8SVGMatrix::multiplyCallback): + (WebCore::V8SVGMatrix::inverseCallback): + (WebCore::V8SVGMatrix::rotateFromVectorCallback): + * bindings/v8/custom/V8StyleSheetListCustom.cpp: + (WebCore::V8StyleSheetList::namedPropertyGetter): + * bindings/v8/custom/V8TreeWalkerCustom.cpp: + (WebCore::toV8Object): + * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: + (WebCore::toV8Object): + * bindings/v8/custom/V8XSLTProcessorCustom.cpp: + (WebCore::V8XSLTProcessor::transformToFragmentCallback): + (WebCore::V8XSLTProcessor::transformToDocumentCallback): + +2010-02-03 Mikhail Naganov <mnaganov@chromium.org> + + Reviewed by Pavel Feldman. + + Start unforking debugger and profiler code. + + Remove custom implementation of Console. + Add 'ScriptProfiler' and 'ScriptProfile' types. + Start migration to engine-neutral types in InspectorController. + + https://bugs.webkit.org/show_bug.cgi?id=34481 + + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.xcodeproj/project.pbxproj: + * bindings/js/JSBindingsAllInOne.cpp: + * bindings/js/JSConsoleCustom.cpp: + * bindings/js/ScriptProfile.h: Added. + * bindings/js/ScriptProfiler.cpp: Added. + (WebCore::ScriptProfiler::start): + (WebCore::ScriptProfiler::stop): + * bindings/js/ScriptProfiler.h: Added. + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/v8/ScriptProfile.h: Added. + (WebCore::ScriptProfile::create): + (WebCore::ScriptProfile::~ScriptProfile): + (WebCore::ScriptProfile::title): + (WebCore::ScriptProfile::uid): + (WebCore::ScriptProfile::ScriptProfile): + * bindings/v8/ScriptProfiler.cpp: Added. + (WebCore::ScriptProfiler::start): + (WebCore::ScriptProfiler::stop): + * bindings/v8/ScriptProfiler.h: Added. + * bindings/v8/custom/V8ConsoleCustom.cpp: Removed. + * inspector/InspectorController.cpp: + (WebCore::InspectorController::endGroup): + (WebCore::InspectorController::show): + (WebCore::InspectorController::setDOMStorageItem): + (WebCore::InspectorController::addProfile): + (WebCore::InspectorController::addProfileFinishedMessageToConsole): + (WebCore::InspectorController::addStartProfilingMessageToConsole): + (WebCore::InspectorController::createProfileHeader): + (WebCore::InspectorController::getCurrentUserInitiatedProfileName): + (WebCore::InspectorController::startUserInitiatedProfiling): + (WebCore::InspectorController::stopUserInitiatedProfiling): + (WebCore::InspectorController::enableDebugger): + (WebCore::InspectorController::specialPanelForJSName): + * inspector/InspectorController.h: + (WebCore::InspectorController::searchingForNodeInPage): + * page/Console.cpp: + (WebCore::Console::profile): + (WebCore::Console::profileEnd): + * page/Console.h: + (WebCore::): + (WebCore::Console::create): + (WebCore::Console::profiles): + * page/Console.idl: + +2010-02-02 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Fix a bug that changes for some constraint attributes doesn't + update validation CSS selectors. + https://bugs.webkit.org/show_bug.cgi?id=31716 + + - Rename HTMLFormControlElement::updateValidity() to setNeedsValidityCheck() + - Introduce HTMLFormControlElement::setNeedsWillValidate() + - Introduce HTMLFormControlElement::m_hasName to make willValidate() + work in parseMappedAttribute(). + - We need to call setNeedsValidityCheck() when HTMLInputElement::step or + HTMLTextAreaElement::maxLength is changed. + + * html/HTMLFormControlElement.cpp: + (WebCore::HTMLFormControlElement::HTMLFormControlElement): + (WebCore::HTMLFormControlElement::parseMappedAttribute): + (WebCore::HTMLFormControlElement::insertedIntoTree): + (WebCore::HTMLFormControlElement::removedFromTree): + (WebCore::HTMLFormControlElement::formDestroyed): + (WebCore::HTMLFormControlElement::willValidate): Avoids function calls. + (WebCore::HTMLFormControlElement::setNeedsWillValidateCheck): + (WebCore::HTMLFormControlElement::setNeedsValidityCheck): + * html/HTMLFormControlElement.h: + (WebCore::HTMLFormControlElement::disabled): Move the code from .cpp. + * html/HTMLInputElement.cpp: + (WebCore::HTMLInputElement::setInputType): + (WebCore::HTMLInputElement::parseMappedAttribute): + (WebCore::HTMLInputElement::setValue): + (WebCore::HTMLInputElement::setValueFromRenderer): + (WebCore::HTMLInputElement::setFileListFromRenderer): + * html/HTMLTextAreaElement.cpp: + (WebCore::HTMLTextAreaElement::parseMappedAttribute): + (WebCore::HTMLTextAreaElement::setValue): + * rendering/RenderTextControlMultiLine.cpp: + (WebCore::RenderTextControlMultiLine::subtreeHasChanged): + +2010-02-02 Roland Steiner <rolandsteiner@chromium.org> + + Reviewed by Adele Peterson. + + Bug 34198 - Ruby text should not inherit line-height + (https://bugs.webkit.org/show_bug.cgi?id=34198) + + Resetting line-height to 'normal' in the default UA style sheet. + Adding layout-test to check for this. + + Test: fast/ruby/ruby-line-height.html + + * css/html.css: + +2010-02-02 James Robinson <jamesr@chromium.org> + + Reviewed by Dmitry Titov. + + Add a null check for image, which might be NULL if tileSize is empty + https://bugs.webkit.org/show_bug.cgi?id=34510 + + Test: fast/gradients/crash-on-1px-border.html + + * rendering/RenderBoxModelObject.cpp: + (WebCore::RenderBoxModelScaleObserver::shouldPaintBackgroundAtLowQuality): + +2010-02-02 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + rangeOverflow/rangeUnderflow support for type=datetime, datetime-local, + month, time and week + https://bugs.webkit.org/show_bug.cgi?id=34483 + + Tests: fast/forms/ValidityState-rangeOverflow.html + fast/forms/ValidityState-rangeUnderflow.html + + * html/HTMLInputElement.cpp: + Defines the hard limits for the types as double values. + (WebCore::HTMLInputElement::rangeUnderflow): Supports the types. + (WebCore::HTMLInputElement::rangeOverflow): Supports the types. + (WebCore::HTMLInputElement::minimum): Supports the types. + (WebCore::HTMLInputElement::maximum): Supports the types. + +2010-02-02 Fumitoshi Ukai <ukai@chromium.org> + + Reviewed by Alexey Proskuryakov. + + WebSocket set pending activity to avoid unexpected GC. + https://bugs.webkit.org/show_bug.cgi?id=34014 + + Test: websocket/tests/websocket-pending-activity.html + + * websockets/WebSocket.cpp: + (WebCore::WebSocket::connect): set pending activity until it receives didClose. + (WebCore::WebSocket::contextDestroyed): check socket is already closed. + (WebCore::WebSocket::stop): close the connection and unset pending activity when it stops. + (WebCore::WebSocket::didClose): unset pending activity. + * websockets/WebSocket.h: + * websockets/WebSocketChannel.cpp: + (WebCore::WebSocketChannel::didReceiveData): protect this while it processes received data. + +2010-02-02 Gustavo Noronha Silva <gns@gnome.org> + + No review, rolling out r54261. + http://trac.webkit.org/changeset/54261 + https://bugs.webkit.org/show_bug.cgi?id=34435 + + Causes crashes on release builds + + * GNUmakefile.am: + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + (WebCore::mediaPlayerPrivateSourceChangedCallback): + * platform/gtk/GOwnPtrGtk.cpp: Removed. + * platform/gtk/GOwnPtrGtk.h: Removed. + +2010-02-02 David Levin <levin@chromium.org> + + No review, rolling out r54245. + http://trac.webkit.org/changeset/54245 + https://bugs.webkit.org/show_bug.cgi?id=34492 + + This patch seems to have broken thousands of chromium tests on + Windows (and since it was for chromium, I'm rolling it out). + + * dom/Element.cpp: + (WebCore::Element::baseURI): + +2010-02-02 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Darin Adler. + + Copyright year updating for Windows version resources should be automatic + https://bugs.webkit.org/show_bug.cgi?id=34503 + + * WebCore.vcproj/QTMovieWin.rc: + +2010-02-02 Dimitri Glazkov <dglazkov@chromium.org> + + No review, rolling out r54257. + http://trac.webkit.org/changeset/54257 + https://bugs.webkit.org/show_bug.cgi?id=34491 + + [Chromium] broke thousands of Win tests and a few of Linux tests. + + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::beginTransparencyLayer): + * platform/graphics/skia/PlatformContextSkia.cpp: + (PlatformContextSkia::applyAntiAliasedClipPaths): + * platform/graphics/skia/PlatformContextSkia.h: + +2010-02-02 Philippe Normand <pnormand@igalia.com> + + Reviewed by Gustavo Noronha Silva. + + [Gtk] libsoup critical warning in media player http cookies injection code + https://bugs.webkit.org/show_bug.cgi?id=34435 + + Fixed the critical warning and refactored the + User-Agent/Referer/cookies injection code, in that order. Previous + order (cookies first) was wrong because if cookies injection could + not be done neither the User-Agent not Referer were injected. Also + started a non-JSC-specific, gtk-specific GOwnPtr module. + + * GNUmakefile.am: + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + (WebCore::mediaPlayerPrivateSourceChangedCallback): + * platform/gtk/GOwnPtrGtk.cpp: Added. + (WTF::SoupURI): + (WTF::GstElement): + * platform/gtk/GOwnPtrGtk.h: Added. + +2010-02-02 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + [V8] Use toV8() to wrap in the custom bindings, and remove + the old wrapping code from V8DOMWrapper. + + https://bugs.webkit.org/show_bug.cgi?id=32563 + + * bindings/v8/ScriptController.cpp: + * bindings/v8/ScriptObject.cpp: + * bindings/v8/V8AbstractEventListener.cpp: + * bindings/v8/V8Collection.h: + * bindings/v8/V8DOMWindowShell.cpp: + * bindings/v8/V8DOMWrapper.cpp: + * bindings/v8/V8DOMWrapper.h: + * bindings/v8/V8NodeFilterCondition.cpp: + * bindings/v8/V8Proxy.cpp: + * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp: + * bindings/v8/custom/V8CustomPositionCallback.cpp: + * bindings/v8/custom/V8CustomPositionErrorCallback.cpp: + * bindings/v8/custom/V8CustomSQLStatementCallback.cpp: + * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: + * bindings/v8/custom/V8CustomSQLTransactionCallback.cpp: + * bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp: + * bindings/v8/custom/V8DOMWindowCustom.cpp: + * bindings/v8/custom/V8DataGridColumnListCustom.cpp: + * bindings/v8/custom/V8DocumentCustom.cpp: + * bindings/v8/custom/V8DocumentLocationCustom.cpp: + * bindings/v8/custom/V8ElementCustom.cpp: + * bindings/v8/custom/V8EventCustom.cpp: + * bindings/v8/custom/V8HTMLAllCollectionCustom.cpp: + * bindings/v8/custom/V8HTMLAudioElementConstructor.cpp: + * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp: + * bindings/v8/custom/V8HTMLCollectionCustom.cpp: + * bindings/v8/custom/V8HTMLDocumentCustom.cpp: + * bindings/v8/custom/V8HTMLFormElementCustom.cpp: + * bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp: + * bindings/v8/custom/V8HTMLImageElementConstructor.cpp: + * bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp: + * bindings/v8/custom/V8HTMLSelectElementCustom.cpp: + * bindings/v8/custom/V8InjectedScriptHostCustom.cpp: + * bindings/v8/custom/V8MessageChannelConstructor.cpp: + * bindings/v8/custom/V8MessageEventCustom.cpp: + * bindings/v8/custom/V8NamedNodeMapCustom.cpp: + * bindings/v8/custom/V8NodeIteratorCustom.cpp: + * bindings/v8/custom/V8NodeListCustom.cpp: + * bindings/v8/custom/V8NotificationCenterCustom.cpp: + * bindings/v8/custom/V8SVGMatrixCustom.cpp: + * bindings/v8/custom/V8StyleSheetListCustom.cpp: + * bindings/v8/custom/V8TreeWalkerCustom.cpp: + * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: + * bindings/v8/custom/V8XSLTProcessorCustom.cpp: + +2010-02-02 Garret Kelly <gdk@chromium.org> + + Reviewed by David Levin. + + When using the Skia graphics context, the beginTransparencyLayer call + currently creates a new layer, but does not keep the current + compositing mode for use when merging the created layer back onto the + rest of the context. This patch fixes that. + https://bugs.webkit.org/show_bug.cgi?id=34491 + + fast/backgrounds/svg-as-mask.html is affected by this change in Chromium, + but not fixed. This is the first of a series of patches to fix it. + + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::beginTransparencyLayer): + * platform/graphics/skia/PlatformContextSkia.cpp: + (PlatformContextSkia::beginTransparencyLayer): + * platform/graphics/skia/PlatformContextSkia.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + Use WTF::getLocalTime instead of localtime_r in FTPDirectoryDocument + https://bugs.webkit.org/show_bug.cgi?id=34409 + + Platform guards for localtime_r are not needed because we already have + WTF::getLocalTime which does the same thing. + + * loader/FTPDirectoryDocument.cpp: + (WebCore::processFileDateString): + * loader/FTPDirectoryParser.cpp: + (WebCore::gmtimeQt): + +2010-02-02 Adam Roben <aroben@apple.com> + + Copy WebCore's bindings generation scripts to the PrivateHeaders + directory on Mac + + This will allow other projects to use these scripts. + + Fixes <http://webkit.org/b/34498>. + + Reviewed by Mark Rowe. + + * WebCore.xcodeproj/project.pbxproj: Added the bindings generation + scripst to the Copy Headers phase, and marked them as Private. + +2010-02-02 Adam Roben <aroben@apple.com> + + Copy WebCore's bindings generation scripts to a more sensible location + + Part of Bug 34496: Clean up WebCore's IDL/script copying + <https://bugs.webkit.org/show_bug.cgi?id=34496> + + Reviewed by Steve Falkenburg. + + * WebCore.vcproj/WebCore.make: + * WebCore.vcproj/WebCoreGenerated.vcproj: + Instead of copying to obj/WebKit/DOMInterfaces, copy to obj/WebCore/scripts. + +2010-02-02 Adam Roben <aroben@apple.com> + + Rename the scripts used to copy WebCore's bindings generation scripts + + Part of Bug 34496: Clean up WebCore's IDL/script copying + <https://bugs.webkit.org/show_bug.cgi?id=34496> + + Reviewed by Steve Falkenburg. + + * WebCore.vcproj/MigrateScripts: Renamed from WebCore/WebCore.vcproj/MigrateIDLAndScripts. + * WebCore.vcproj/migrate-scripts.sh: Renamed from WebCore/WebCore.vcproj/migrate-idls.sh. + + * WebCore.vcproj/WebCoreGenerated.vcproj: Updated for renames. + +2010-02-02 Adam Roben <aroben@apple.com> + + Stop copying IDL files into $(WebKitOutputDir) + + No one uses these anymore (as of r52921). + + Part of Bug 34496: Clean up WebCore's IDL/script copying + <https://bugs.webkit.org/show_bug.cgi?id=34496> + + Reviewed by Steve Falkenburg. + + * WebCore.vcproj/MigrateIDLAndScripts: Don't copy the IDL files + anymore. Keep copying the scripts, though, since other projects + (outside of the WebKit repository) do use those. + +2010-02-02 Bryan Yeung <bryeung@google.com> + + Reviewed by Darin Adler. + + Avoid using an invalidated KURL object in baseURI. + + https://bugs.webkit.org/show_bug.cgi?id=34492 + + This change fixes baseURI for Chromium (where the KURL implementation + does not allow invalid KURLs to carry relative paths). This is + regression tested by + LayoutTests/svg/W3C-SVG-1.1/struct-image-07-t.svg + + * dom/Element.cpp: + (WebCore::Element::baseURI): + +2010-02-02 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=34076 + <rdar://problem/7594601> Crash in mangleme in WebCore::Element::getAttribute + + Test: fast/forms/misplaced-img-form-registration.html + + * html/HTMLFormElement.cpp: + (WebCore::HTMLFormElement::registerImgElement): Assert that the same image isn't added + to vector again. + (WebCore::HTMLFormElement::removeImgElement): Similarly, assert that we're removing something + that's actually registered. + + * html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::~HTMLImageElement): If parser fails + to insert the image element, then there will be no removed from tree notification either, + need to unregister right away. + +2010-02-02 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: Eliminate some of the platform flavor-specific stylesheet selectors + + Extract OS version into WebInspector.platformFlavor + https://bugs.webkit.org/show_bug.cgi?id=34469 + + * inspector/front-end/InspectorBackendStub.js: + * inspector/front-end/InspectorFrontendHostStub.js: + (.WebInspector.InspectorFrontendHostStub.prototype.platform): + * inspector/front-end/inspector.css: + * inspector/front-end/inspector.js: + (WebInspector.pendingDispatches.0.URLRegExp.i.get platform): + (WebInspector.get platformFlavor): + (WebInspector._detectPlatformFlavor): + (WebInspector.loaded): + (WebInspector.toolbarDragStart): + (WebInspector.isMac): + +2010-02-02 Steve Block <steveblock@google.com> + + Reviewed by Ariya Hidayat. + + Adds utility functions for converting between JavaInstance and NPAPI types + https://bugs.webkit.org/show_bug.cgi?id=34468 + + This is required by Android for injecting objects into V8 JavaScript. + + No new tests, added utility functions only. + + * Android.v8bindings.mk: Modified. Added JavaNPObjectV8.cpp + * bridge/jni/v8/JavaNPObjectV8.cpp: Added. + (JSC::Bindings::AllocJavaNPObject): + (JSC::Bindings::FreeJavaNPObject): + (JSC::Bindings::): + (JSC::Bindings::JavaInstanceToNPObject): + (JSC::Bindings::ExtractJavaInstance): + (JSC::Bindings::JavaNPObjectHasMethod): + (JSC::Bindings::JavaNPObjectInvoke): + (JSC::Bindings::JavaNPObjectHasProperty): + (JSC::Bindings::JavaNPObjectGetProperty): + * bridge/jni/v8/JavaNPObjectV8.h: Added. + +2010-02-02 Benjamin Poulain <benjamin.poulain@nokia.com> + + Reviewed by Ariya Hidayat. + + [Qt] Symbian plugins include a wrong header file for QPixmap + https://bugs.webkit.org/show_bug.cgi?id=34475 + + * plugins/symbian/PluginViewSymbian.cpp: + +2010-02-02 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: URLs are not syntax-higlighted as links in source view. + + This change enables linkifier in the NativeTextViewer. It adds + "linkify" and "a_node" parse states into the highlighter in order + to detect links and distinguish between resource and external ones. + Contains drive-by fix for the webkit-html-* styles and moves them to the + common location. + + https://bugs.webkit.org/show_bug.cgi?id=34364 + + * inspector/front-end/NativeTextViewer.js: + (WebInspector.NativeTextViewer): + (WebInspector.NativeTextViewer.prototype._createSpan): + (WebInspector.NativeTextViewer.prototype._createLink): + (WebInspector.NativeTextViewer.prototype._rewriteHref): + * inspector/front-end/SourceFrame.js: + (WebInspector.SourceFrame.prototype.setContent): + (WebInspector.SourceFrame.prototype._createEditorIfNeeded): + * inspector/front-end/SourceHTMLTokenizer.js: + (WebInspector.SourceHTMLTokenizer): + (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttribute): + (WebInspector.SourceHTMLTokenizer.prototype._isExpectingAttributeValue): + (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttribute): + (WebInspector.SourceHTMLTokenizer.prototype._setExpectingAttributeValue): + (WebInspector.SourceHTMLTokenizer.prototype._stringToken): + (WebInspector.SourceHTMLTokenizer.prototype._attrValueTokenType): + (WebInspector.SourceHTMLTokenizer.prototype.nextToken): + * inspector/front-end/SourceHTMLTokenizer.re2js: + * inspector/front-end/SourceView.js: + (WebInspector.SourceView.prototype._contentLoaded): + * inspector/front-end/TextEditorHighlighter.js: + (WebInspector.TextEditorHighlighter): + * inspector/front-end/inspector.css: + * inspector/front-end/inspectorSyntaxHighlight.css: + +2010-02-02 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Ariya Hidayat. + + [Qt] Install libraries and headers in package builds + https://bugs.webkit.org/show_bug.cgi?id=34325 + + Add the QtWebKit libraries to the installable items, except on + Symbian where the libraries are always linked in their final + destination. + + Also include the headers generated by syncqt in the installation. + + * WebCore.pro: + +2010-02-02 Kavita Kanetkar <kkanetkar@chromium.org> + + Reviewed by Dmitry Titov. + + [V8] Raising an exception while setting timeout/interval from a detached frame + https://bugs.webkit.org/show_bug.cgi?id=34453 + This fixes the issue/failing test mentioned in Chromium bug: + http://code.google.com/p/chromium/issues/detail?id=32671 + + + * bindings/v8/custom/V8DOMWindowCustom.cpp: + (WebCore::WindowSetTimeoutImpl): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port Screen + https://bugs.webkit.org/show_bug.cgi?id=34299 + + Get the screen size and depth from the main display bitmap. + + * platform/brew/ScreenBrew.cpp: Added. + (WebCore::getDisplayInfo): + (WebCore::screenRect): + (WebCore::screenAvailableRect): + (WebCore::screenDepth): + (WebCore::screenDepthPerComponent): + (WebCore::screenIsMonochrome): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port LocalizedStrings + https://bugs.webkit.org/show_bug.cgi?id=34257 + + Port LocalizedStrings to BREWMP. + + * platform/brew/LocalizedStringsBrew.cpp: Added. + (WebCore::submitButtonDefaultLabel): + (WebCore::inputElementAltText): + (WebCore::resetButtonDefaultLabel): + (WebCore::defaultLanguage): + (WebCore::searchableIndexIntroduction): + (WebCore::fileButtonChooseFileLabel): + (WebCore::fileButtonNoFileSelectedLabel): + (WebCore::contextMenuItemTagOpenLinkInNewWindow): + (WebCore::contextMenuItemTagDownloadLinkToDisk): + (WebCore::contextMenuItemTagCopyLinkToClipboard): + (WebCore::contextMenuItemTagOpenImageInNewWindow): + (WebCore::contextMenuItemTagDownloadImageToDisk): + (WebCore::contextMenuItemTagCopyImageToClipboard): + (WebCore::contextMenuItemTagOpenFrameInNewWindow): + (WebCore::contextMenuItemTagCopy): + (WebCore::contextMenuItemTagGoBack): + (WebCore::contextMenuItemTagGoForward): + (WebCore::contextMenuItemTagStop): + (WebCore::contextMenuItemTagReload): + (WebCore::contextMenuItemTagCut): + (WebCore::contextMenuItemTagPaste): + (WebCore::contextMenuItemTagNoGuessesFound): + (WebCore::contextMenuItemTagIgnoreSpelling): + (WebCore::contextMenuItemTagLearnSpelling): + (WebCore::contextMenuItemTagSearchWeb): + (WebCore::contextMenuItemTagLookUpInDictionary): + (WebCore::contextMenuItemTagOpenLink): + (WebCore::contextMenuItemTagIgnoreGrammar): + (WebCore::contextMenuItemTagSpellingMenu): + (WebCore::contextMenuItemTagShowSpellingPanel): + (WebCore::contextMenuItemTagCheckSpelling): + (WebCore::contextMenuItemTagCheckSpellingWhileTyping): + (WebCore::contextMenuItemTagCheckGrammarWithSpelling): + (WebCore::contextMenuItemTagFontMenu): + (WebCore::contextMenuItemTagBold): + (WebCore::contextMenuItemTagItalic): + (WebCore::contextMenuItemTagUnderline): + (WebCore::contextMenuItemTagOutline): + (WebCore::contextMenuItemTagWritingDirectionMenu): + (WebCore::contextMenuItemTagDefaultDirection): + (WebCore::contextMenuItemTagLeftToRight): + (WebCore::contextMenuItemTagRightToLeft): + (WebCore::contextMenuItemTagInspectElement): + (WebCore::searchMenuNoRecentSearchesText): + (WebCore::searchMenuRecentSearchesText): + (WebCore::searchMenuClearRecentSearchesText): + (WebCore::unknownFileSizeText): + (WebCore::AXWebAreaText): + (WebCore::AXLinkText): + (WebCore::AXListMarkerText): + (WebCore::AXImageMapText): + (WebCore::AXHeadingText): + (WebCore::imageTitle): + (WebCore::contextMenuItemTagTextDirectionMenu): + (WebCore::AXButtonActionVerb): + (WebCore::AXTextFieldActionVerb): + (WebCore::AXRadioButtonActionVerb): + (WebCore::AXCheckedCheckBoxActionVerb): + (WebCore::AXUncheckedCheckBoxActionVerb): + (WebCore::AXLinkActionVerb): + (WebCore::AXMenuListPopupActionVerb): + (WebCore::AXMenuListActionVerb): + (WebCore::AXDefinitionListTermText): + (WebCore::AXDefinitionListDefinitionText): + (WebCore::validationMessageValueMissingText): + (WebCore::validationMessageTypeMismatchText): + (WebCore::validationMessagePatternMismatchText): + (WebCore::validationMessageTooLongText): + (WebCore::validationMessageRangeUnderflowText): + (WebCore::validationMessageRangeOverflowText): + (WebCore::validationMessageStepMismatchText): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port systemBeep + https://bugs.webkit.org/show_bug.cgi?id=33601 + + Implement systemBeep with IShell_Beep. + + * platform/brew/SoundBrew.cpp: Added. + (WebCore::systemBeep): + +2010-02-02 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Eric Seidel. + + [Win] Utilize PrintContext to share the printing code with other ports + https://bugs.webkit.org/show_bug.cgi?id=34312 + + No new tests as this is just a small refactoring. + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Add conversions between IntPoint and AEEPoint + https://bugs.webkit.org/show_bug.cgi?id=34194 + + Make it easy to convert between IntPoint and AEEPoint. + + * platform/graphics/IntPoint.h: + * platform/graphics/brew/IntPointBrew.cpp: Added. + (WebCore::IntPoint::IntPoint): + (WebCore::IntPoint::operator AEEPoint): + +>>>>>>> webkit.org at r54340 2010-02-02 Steve Block <steveblock@google.com> Reviewed by Adam Barth. @@ -11,6 +1323,961 @@ (WebCore::AbstractWeakReferenceMap::~AbstractWeakReferenceMap): Added. (WebCore::AbstractWeakReferenceMap::Visitor::~Visitor): Added. +<<<<<<< HEAD +======= +2010-02-02 Avi Drissman <avi@chromium.org> + + Reviewed by Eric Seidel. + + Sync up Chromium Mac render theme to Mac render theme + https://bugs.webkit.org/show_bug.cgi?id=34340 + + Covered by existing layout tests. + + * platform/chromium/ThemeChromiumMac.mm: + (WebCore::updateStates): + (WebCore::checkbox): + (WebCore::paintCheckbox): + (WebCore::radio): + (WebCore::paintRadio): + (WebCore::listButtonSizes): + (WebCore::setupButtonCell): + (WebCore::button): + (WebCore::paintButton): + (WebCore::ThemeChromiumMac::controlSize): + (WebCore::ThemeChromiumMac::minimumControlSize): + (WebCore::ThemeChromiumMac::controlBorder): + (WebCore::ThemeChromiumMac::paint): + * rendering/RenderThemeChromiumMac.h: + * rendering/RenderThemeChromiumMac.mm: + (-[WebCoreRenderThemeNotificationObserver initWithTheme:WebCore::]): + (WebCore::convertNSColorToColor): + (WebCore::RenderThemeChromiumMac::systemColor): + (WebCore::RenderThemeChromiumMac::isControlStyled): + (WebCore::RenderThemeChromiumMac::adjustRepaintRect): + (WebCore::RenderThemeChromiumMac::convertToPaintingRect): + (WebCore::RenderThemeChromiumMac::paintCapsLockIndicator): + (WebCore::RenderThemeChromiumMac::paintMenuList): + (WebCore::RenderThemeChromiumMac::paintMenuListButton): + (WebCore::RenderThemeChromiumMac::adjustMenuListStyle): + (WebCore::RenderThemeChromiumMac::adjustMenuListButtonStyle): + (WebCore::RenderThemeChromiumMac::paintSliderTrack): + (WebCore::RenderThemeChromiumMac::paintSliderThumb): + (WebCore::RenderThemeChromiumMac::paintSearchField): + (WebCore::RenderThemeChromiumMac::setSearchFieldSize): + (WebCore::RenderThemeChromiumMac::adjustSearchFieldStyle): + (WebCore::RenderThemeChromiumMac::paintSearchFieldResultsButton): + (WebCore::RenderThemeChromiumMac::adjustSliderThumbSize): + (WebCore::RenderThemeChromiumMac::popupButton): + (WebCore::RenderThemeChromiumMac::sliderThumbHorizontal): + (WebCore::RenderThemeChromiumMac::sliderThumbVertical): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port Logging + https://bugs.webkit.org/show_bug.cgi?id=34300 + + Log calls to notImplemented() by default. + + * platform/brew/LoggingBrew.cpp: Added. + (WebCore::InitializeLoggingChannelsIfNecessary): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port FileChooser + https://bugs.webkit.org/show_bug.cgi?id=34261 + + Port FileChooser to BREWMP. + + * platform/brew/FileChooserBrew.cpp: Added. + (WebCore::FileChooser::basenameForWidth): + +2010-02-01 Zoltan Horvath <zoltan@webkit.org> + + Reviewed by Darin Adler. + + Allow custom memory allocation control for IconDatabaseClient class + https://bugs.webkit.org/show_bug.cgi?id=33252 + + Inherits the following struct from Noncopyable because it is + instantiated by 'new' and no need to be copyable: + + class name - instantiated at: WebCore/'location' + class IconDatabaseClient - loader/icon/IconDatabase.cpp:89 + + * loader/icon/IconDatabaseClient.h: + +2010-02-01 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port MIMETypeRegistry + https://bugs.webkit.org/show_bug.cgi?id=34220 + + Port MIMETypeRegistry with an extension map as other ports do. + + * platform/brew: Added. + * platform/brew/MIMETypeRegistryBrew.cpp: Added. + (WebCore::): + (WebCore::MIMETypeRegistry::getMIMETypeForExtension): + +2010-02-01 Dmitry Titov <dimich@chromium.org> + + Not reviewed, revert r54194 that fails new test on Qt and Chromium. + https://bugs.webkit.org/show_bug.cgi?id=34382 + + * html/HTMLFrameElementBase.cpp: + (WebCore::HTMLFrameElementBase::setNameAndOpenURL): + (WebCore::HTMLFrameElementBase::insertedIntoDocument): + * html/HTMLFrameElementBase.h: + * page/Frame.cpp: + * page/Frame.h: + +2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Eric Seidel. + + Provide a way to get page number with layoutTestController + https://bugs.webkit.org/show_bug.cgi?id=33840 + + Test: printing/page-break-always.html + + * WebCore.base.exp: + * WebCore.xcodeproj/project.pbxproj: + * page/PrintContext.cpp: + (WebCore::PrintContext::pageRect): Added a getter function. + (WebCore::PrintContext::computePageRects): Move its logic into computePageRectsWithPageSize. + (WebCore::PrintContext::computePageRectsWithPageSize): Factored out from computePageRects for pageNumberForElement. + (WebCore::enclosingBoxModelObject): Added for pageNumberForElement. + (WebCore::PrintContext::pageNumberForElement): Added for testing. + * page/PrintContext.h: + +2010-02-01 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Add conversions between IntSize and AEESize + https://bugs.webkit.org/show_bug.cgi?id=34197 + + Make it easy to convert between IntSize and AEESize. + + * platform/graphics/IntSize.h: + * platform/graphics/brew/IntSizeBrew.cpp: Added. + (WebCore::IntSize::IntSize): + (WebCore::IntSize::operator AEESize): + +2010-02-01 Stephen White <senorblanco@chromium.org> + + Reviewed by Eric Seidel. + + Fix for Pattern transformations in Chromium/Skia. This required + reworking Pattern a bit to be more like the Gradient implementation. + In particular, it now holds an m_pattern reference to the + platform-specific implementation, and passes along changes to the + m_patternSpaceTransformation, in the same way that Gradient does for + m_gradientSpaceTransformation. This is necessary since Skia creates the + platform-specific pattern (SkShader) once, rather than recreating it + on each draw. + For platforms other than Skia, m_pattern is unused, they will + continue to use the static createPlatformPattern(), and the new + notification functions are stubbed out. Other platforms can switch to + the new implementation if they so choose. + + https://bugs.webkit.org/show_bug.cgi?id=24534 + + Covered by svg/custom/pattern-y-offset.svg, + svg/custom/pattern-cycle-detection.svg, and many more. + + * platform/graphics/Pattern.cpp: + (WebCore::Pattern::Pattern): + Initializer for m_pattern. + (WebCore::Pattern::~Pattern): + call platformDestroy(). + (WebCore::Pattern::setPatternSpaceTransform): + Pass along the transform via setPlatformPatternSpaceTransform(). + (WebCore::Pattern::platformDestroy): + (WebCore::Pattern::setPlatformPatternSpaceTransform): + Stub implementations for non-skia platforms. + * platform/graphics/Pattern.h: + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::setPlatformFillPattern): + (WebCore::GraphicsContext::setPlatformStrokePattern): + Call platformPattern() instead of static version. + Since Pattern now owns its SkShader, no need to unref here. + * platform/graphics/skia/PatternSkia.cpp: + (WebCore::Pattern::platformDestroy): + Unref the SkShader on destroy. + (WebCore::Pattern::platformPattern): + Create the platform pattern (SkShader) once, and cache it. + (WebCore::Pattern::setPlatformPatternSpaceTransform): + Set the shader's local matrix from the m_patternSpaceTransformation. + +2010-02-01 Daniel Bates <dbates@webkit.org> + + Reviewed by Adam Barth. + + https://bugs.webkit.org/show_bug.cgi?id=27312 + + Implements support for full page blocking via the X-XSS-Protection header. + + Tests: http/tests/security/xssAuditor/full-block-base-href.html + http/tests/security/xssAuditor/full-block-get-from-iframe.html + http/tests/security/xssAuditor/full-block-iframe-javascript-url.html + http/tests/security/xssAuditor/full-block-iframe-no-inherit.php + http/tests/security/xssAuditor/full-block-javascript-link.html + http/tests/security/xssAuditor/full-block-link-onclick.html + http/tests/security/xssAuditor/full-block-object-tag.html + http/tests/security/xssAuditor/full-block-post-from-iframe.html + http/tests/security/xssAuditor/full-block-script-tag-with-source.html + http/tests/security/xssAuditor/full-block-script-tag.html + http/tests/security/xssAuditor/malformed-xss-protection-header.html + + * page/XSSAuditor.cpp: + (WebCore::XSSAuditor::shouldFullPageBlockForXSSProtectionHeader): Added. + (WebCore::XSSAuditor::findInRequest): Modified to call method + XSSAuditor::shouldFullPageBlockForXSSProtectionHeader. + * page/XSSAuditor.h: Defined method shouldFullPageBlockForXSSProtectionHeader + and fixed misspelled words in large comment block. + +2010-02-01 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port SharedTimer with IShell_SetTimerEx. + https://bugs.webkit.org/show_bug.cgi?id=33599 + + As fireTime passed in setSharedTimerFireTime is the absolute time, + we must calcalute the interval by subtracting currentTime() from + fireTime and pass the result to ISHELL_SetTimerEx. + + * platform/brew/SharedTimerBrew.cpp: Added. + (WebCore::invokeCallback): + (WebCore::setSharedTimerFiredFunction): + (WebCore::setSharedTimerFireTime): + (WebCore::stopSharedTimer): + +2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> + + [Chromium] Unreviewed attempt to fix the chromium build. + + Corresponding change: http://trac.webkit.org/changeset/54182 + + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/v8/ScriptController.cpp: + (WebCore::ScriptController::processingUserGesture): + * bindings/v8/ScriptController.h: + +2010-02-01 Dmitry Titov <dimich@chromium.org> + + Reviewed by David Levin. + + When a live iframe element is moved between pages, it still depends on the old page. + https://bugs.webkit.org/show_bug.cgi?id=34382 + + Test: fast/frames/iframe-reparenting-new-page.html + + * html/HTMLFrameElementBase.cpp: + (WebCore::HTMLFrameElementBase::setName): + Move the code setting the frame name into a separate function. + + (WebCore::HTMLFrameElementBase::setNameAndOpenURL): + (WebCore::HTMLFrameElementBase::updateLiveFrame): + Update frame tree, reset page in the contentFrame and re-set the name. + + (WebCore::HTMLFrameElementBase::insertedIntoDocument): + * html/HTMLFrameElementBase.h: + + * page/Frame.cpp: + (WebCore::Frame::setPage): + * page/Frame.h: Add setPage method. It is only currently used when iframe is + moved between pages (so the ASSERT(m_ownerElement). + +2010-02-01 Brady Eidson <beidson@apple.com> + + Reviewed by Tim Hatcher. + + Add common IRC ports to port blocking. + <rdar://problem/7593895> and https://bugs.webkit.org/show_bug.cgi?id=34451 + + * platform/KURL.cpp: + (WebCore::portAllowed): + +2010-01-29 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Nate Chapin. + + [V8] Add compile time guards for IndexedDB custom functions + https://bugs.webkit.org/show_bug.cgi?id=34368 + + * bindings/v8/custom/V8IDBRequestCustom.cpp: + * bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp: + +2010-01-29 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Sam Weinig + Oliver Hunt. + + Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds + + Change HTMLMediaElement methods that require checking whether the event is a user gesture to + be passed a boolean. This may be passed from the JSC bindings (where we have an exec state), + or read from the event. Add a Flag to the IDL to mark this information is required. + + * WebCore.Video.exp: + * bindings/js/JSDOMBinding.cpp: + (WebCore::processingUserGesture): + * bindings/js/JSDOMWindowCustom.cpp: + (WebCore::domWindowAllowPopUp): + (WebCore::JSDOMWindow::open): + (WebCore::JSDOMWindow::showModalDialog): + * bindings/js/JSDocumentCustom.cpp: + (WebCore::JSDocument::setLocation): + * bindings/js/ScriptController.cpp: + (WebCore::ScriptController::processingUserGesture): + (WebCore::ScriptController::processingUserGestureEvent): + (WebCore::ScriptController::anyPageIsProcessingUserGesture): + * bindings/js/ScriptController.h: + * bindings/scripts/CodeGeneratorJS.pm: + * dom/Event.cpp: + (WebCore::Event::isUserEvent): + * dom/Event.h: + * html/HTMLMediaElement.cpp: + (WebCore::HTMLMediaElement::removedFromDocument): + (WebCore::HTMLMediaElement::load): + (WebCore::HTMLMediaElement::play): + (WebCore::HTMLMediaElement::pause): + (WebCore::HTMLMediaElement::beginScrubbing): + (WebCore::HTMLMediaElement::documentDidBecomeActive): + (WebCore::HTMLMediaElement::webkitEnterFullScreen): + * html/HTMLMediaElement.h: + * html/HTMLMediaElement.idl: + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::isProcessingUserGesture): + * loader/MediaDocument.cpp: + (WebCore::MediaDocument::defaultEventHandler): + * page/DOMWindow.cpp: + (WebCore::DOMWindow::allowPopUp): + * rendering/MediaControlElements.cpp: + (WebCore::MediaControlSeekButtonElement::defaultEventHandler): + +2010-02-01 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Use the fallback style on Maemo 5 + + https://bugs.webkit.org/show_bug.cgi?id=34376 + + * platform/qt/RenderThemeQt.cpp: + (WebCore::RenderThemeQt::RenderThemeQt): + (WebCore::RenderThemeQt::fallbackStyle): + (WebCore::RenderThemeQt::qStyle): + (WebCore::RenderThemeQt::setPaletteFromPageClientIfExists): + * platform/qt/RenderThemeQt.h: + +2010-02-01 Kavita Kanetkar <kkanetkar@chromium.org> + + Reviewed by Nate Chapin. + + [V8] Making V8 generated classes' GetTemplate() function public + https://bugs.webkit.org/show_bug.cgi?id=34026 + + * bindings/scripts/CodeGeneratorV8.pm: Generated code need not depend on V8CustomBinding.h, made GetTemplate() signature public. + +2010-02-01 Steve Block <steveblock@google.com> + + Reviewed by Ariya Hidayat. + + Adds V8-specific JNI bridge classes + https://bugs.webkit.org/show_bug.cgi?id=34166 + + This is the V8 equivalent of bridge/jni/jsc/JNIBridgeJSC. + + No new tests, build fix only. + + * Android.v8bindings.mk: Modified. Added JNIBridge.cpp and JNIBridgeV8.cpp + * bridge/Bridge.h: Modified. Added missing include for Noncopyable.h + * bridge/jni/v8/JNIBridgeV8.cpp: Added. + (JavaField::JavaField): + * bridge/jni/v8/JNIBridgeV8.h: Added. + (JSC::Bindings::JavaField::name): + (JSC::Bindings::JavaField::type): + (JSC::Bindings::JavaField::getJNIType): + +2010-02-01 Steve Block <steveblock@google.com> + + Reviewed by Ariya Hidayat. + + Adds V8-specific JNI utility functions. + https://bugs.webkit.org/show_bug.cgi?id=33901 + + This is the V8 equivalent of bridge/jni/jsc/JNIUtilityPrivate. + + No new tests, build fix only. + + * Android.v8bindings.mk: Modified. Add JNIUtilityPrivate.cpp + * bridge/jni/v8/JNIUtilityPrivate.cpp: Added. + (JSC::Bindings::convertNPVariantToJValue): + (JSC::Bindings::convertJValueToNPVariant): + * bridge/jni/v8/JNIUtilityPrivate.h: Added. + +2010-02-01 Steve Block <steveblock@google.com> + + Reviewed by Ariya Hidayat. + + Adds V8 version of JavaClass + https://bugs.webkit.org/show_bug.cgi?id=33898 + + This is the V8 equivalent of bridge/jni/jsc/JavaClassJSC + + No new tests, build fix only. + + * Android.v8bindings.mk: Modified. Added JavaClassV8.cpp + * bridge/jni/v8/JavaClassV8.cpp: Added. + (JavaClass::JavaClass): + (JavaClass::~JavaClass): + (JavaClass::methodsNamed): + (JavaClass::fieldNamed): + * bridge/jni/v8/JavaClassV8.h: Added. + +2010-02-01 Steve Block <steveblock@google.com> + + Reviewed by Ariya Hidayat. + + Adds V8 version of JavaInstance + https://bugs.webkit.org/show_bug.cgi?id=33951 + + This is the V8 equivalent of bridge/jni/jsc/JavaInstanceJSC. + Also fixes a typo in a comment in JavaInstanceJSC.cpp. + + No new tests, build fix only. + + * Android.v8bindings.mk: Modified. Added JavaInstanceV8.cpp + * bridge/jni/jsc/JavaInstanceJSC.cpp: Modified. + (JavaInstance::invokeMethod): Modified. Fixed comment + * bridge/jni/v8/JavaInstanceV8.cpp: Added. + (JavaInstance::JavaInstance): + (JavaInstance::~JavaInstance): + (JavaInstance::getClass): + (JavaInstance::invokeMethod): + (JObjectWrapper::JObjectWrapper): + (JObjectWrapper::~JObjectWrapper): + * bridge/jni/v8/JavaInstanceV8.h: Added. + (JSC::Bindings::JObjectWrapper::instance): + (JSC::Bindings::JObjectWrapper::setInstance): + (JSC::Bindings::JObjectWrapper::ref): + (JSC::Bindings::JObjectWrapper::deref): + (JSC::Bindings::JavaInstance::javaInstance): + (JSC::Bindings::JavaInstance::begin): + (JSC::Bindings::JavaInstance::end): + (JSC::Bindings::JavaInstance::virtualBegin): + (JSC::Bindings::JavaInstance::virtualEnd): + +2010-02-01 Dumitru Daniliuc <dumi@chromium.org> + + Reviewed by Eric Seidel. + + Making sure that all in-progress transactions are rolled back on + the database thread before they're destroyed. Otherwise, + SQLiteTransaction's destructor will try to do a rollback and that + would cause an assertion failure, if the object is not destroyed + on the DB thread. + + https://bugs.webkit.org/show_bug.cgi?id=34152 + + * platform/sql/SQLiteTransaction.cpp: + (WebCore::SQLiteTransaction::stop): + * storage/SQLTransaction.cpp: + (WebCore::SQLTransaction::notifyDatabaseThreadIsShuttingDown): + * storage/SQLTransaction.h: + * storage/SQLTransactionCoordinator.cpp: + (WebCore::SQLTransactionCoordinator::shutdown): + +2010-02-01 Sam Weinig <sam@webkit.org> + + Reviewed by Beth Dakin. + + Fix EXPERIMENTAL_SINGLE_VIEW_MODE build. + + * page/EventHandler.h: + * page/mac/EventHandlerMac.mm: + (WebCore::EventHandler::currentNSEvent): + (WebCore::EventHandler::currentKeyboardEvent): + (WebCore::EventHandler::mouseDown): + (WebCore::EventHandler::mouseDragged): + (WebCore::EventHandler::mouseUp): + (WebCore::EventHandler::mouseMoved): + (WebCore::EventHandler::keyEvent): + (WebCore::EventHandler::wheelEvent): + (WebCore::EventHandler::sendContextMenuEvent): + (WebCore::EventHandler::eventMayStartDrag): + (WebCore::EventHandler::sendFakeEventsAfterWidgetTracking): + +2010-02-01 Nate Chapin <japhet@chromium.org> + + Unreviewed, Chromium build fix. + + Failed to properly add new files for http://trac.webkit.org/changeset/54150. + + * bindings/v8/custom/V8BarInfoCustom.cpp: Added. + * bindings/v8/custom/V8CSSRuleCustom.cpp: Added. + * bindings/v8/custom/V8CSSStyleSheetCustom.cpp: Added. + * bindings/v8/custom/V8CSSValueCustom.cpp: Added. + * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp: Added. + * bindings/v8/custom/V8DOMSelectionCustom.cpp: Added. + * bindings/v8/custom/V8HTMLElementCustom.cpp: Added. + * bindings/v8/custom/V8SVGDocumentCustom.cpp: Added. + * bindings/v8/custom/V8SVGElementCustom.cpp: Added. + * bindings/v8/custom/V8SVGPathSegCustom.cpp: Added. + * bindings/v8/custom/V8ScreenCustom.cpp: Added. + * bindings/v8/custom/V8StyleSheetCustom.cpp: Added. + * bindings/v8/custom/V8WebGLArrayCustom.cpp: Added. + +2010-01-27 Matt Perry <mpcomplete@chromium.org> + + Reviewed by Eric Seidel. + + Add support for addUserScript to chromium port. + + * bindings/v8/ScriptController.cpp: + (WebCore::ScriptController::evaluateInWorld): + * bindings/v8/ScriptController.h: + +2010-02-01 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Dan Bernstein. + + https://bugs.webkit.org/show_bug.cgi?id=34448 + <rdar://problem/7598130> + + RenderVideo::intrinsicSizeChanged infinite recursion + + * rendering/RenderImage.h: + (WebCore::RenderImage::intrinsicSizeChanged): Make protected instead of private so it can + be called by RenderVideo. + * rendering/RenderVideo.cpp: + (WebCore::RenderVideo::intrinsicSizeChanged): Call RenderMedia::intrinsicSizeChanged, not + RenderVideo::intrinsicSizeChanged. + (WebCore::RenderVideo::imageChanged): Call RenderMedia::imageChanged instead of + RenderImage::imageChanged. + +2010-02-01 Nate Chapin <japhet@chromium.org> + + Reviewed by Dimitri Glazkov. + + [V8] Generate toV8() converter for most WebCore->V8 conversions, + and defined custom converters in their respective V8<class>Custom.cpp. + + Old converters in V8DOMWrapper will be deleted in a later patch. + + https://bugs.webkit.org/show_bug.cgi?id=32563 + + * Android.v8bindings.mk: + * WebCore.gyp/WebCore.gyp: + * WebCore.gypi: + * bindings/scripts/CodeGeneratorV8.pm: + * bindings/v8/V8Collection.h: + * bindings/v8/V8DOMWrapper.cpp: + * bindings/v8/V8DOMWrapper.h: + * bindings/v8/V8Proxy.h: + * bindings/v8/custom/V8BarInfoCustom.cpp: Added. + * bindings/v8/custom/V8CSSRuleCustom.cpp: Added. + * bindings/v8/custom/V8CSSStyleSheetCustom.cpp: Added. + * bindings/v8/custom/V8CSSValueCustom.cpp: Added. + * bindings/v8/custom/V8CanvasPixelArrayCustom.cpp: Added. + * bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp: + * bindings/v8/custom/V8ConsoleCustom.cpp: + * bindings/v8/custom/V8DOMSelectionCustom.cpp: Added. + * bindings/v8/custom/V8DOMWindowCustom.cpp: + * bindings/v8/custom/V8DocumentCustom.cpp: + * bindings/v8/custom/V8ElementCustom.cpp: + * bindings/v8/custom/V8EventCustom.cpp: + * bindings/v8/custom/V8HTMLDocumentCustom.cpp: + * bindings/v8/custom/V8HTMLElementCustom.cpp: Added. + * bindings/v8/custom/V8HTMLSelectElementCustom.cpp: + * bindings/v8/custom/V8HistoryCustom.cpp: + * bindings/v8/custom/V8LocationCustom.cpp: + * bindings/v8/custom/V8NamedNodeMapCustom.cpp: + * bindings/v8/custom/V8NavigatorCustom.cpp: + * bindings/v8/custom/V8NodeCustom.cpp: + * bindings/v8/custom/V8SVGDocumentCustom.cpp: Added. + * bindings/v8/custom/V8SVGElementCustom.cpp: Added. + * bindings/v8/custom/V8SVGPathSegCustom.cpp: Added. + * bindings/v8/custom/V8ScreenCustom.cpp: Added. + * bindings/v8/custom/V8StyleSheetCustom.cpp: Added. + * bindings/v8/custom/V8TreeWalkerCustom.cpp: + * bindings/v8/custom/V8WebGLArrayCustom.cpp: Added. + * bindings/v8/custom/V8WebGLByteArrayCustom.cpp: + * bindings/v8/custom/V8WebGLFloatArrayCustom.cpp: + * bindings/v8/custom/V8WebGLIntArrayCustom.cpp: + * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: + * bindings/v8/custom/V8WebGLShortArrayCustom.cpp: + * bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp: + * bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp: + * bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp: + * dom/make_names.pl: Add options to generate wrapper factory for V8 bindings. + +2010-02-01 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Pavel Feldman. + + Web Inspector: lazy-load textual resources to avoid UI hangup + https://bugs.webkit.org/show_bug.cgi?id=34332 + + * inspector/front-end/ResourceView.js: + (WebInspector.ResourceView.prototype._innerSelectContentTab): + * inspector/front-end/SourceView.js: + (WebInspector.SourceView.prototype.show): + (WebInspector.SourceView.prototype.contentTabSelected): + +2010-02-01 Brady Eidson <beidson@apple.com> + + Reviewed by Adele Peterson. + + Crash in Safari opening new tabs to "same page" + <rdar://problem/7593857> and https://bugs.webkit.org/show_bug.cgi?id=34444 + + Test: fast/loader/crash-copying-backforwardlist.html + + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::loadItem): Null check currentItem(). + + * page/Page.cpp: + (WebCore::Page::goToItem): Ditto. + +2010-02-01 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + [wx] Remove unused file that doesn't seem to belong to the port. + + https://bugs.webkit.org/show_bug.cgi?id=34445 + + * platform/wx/KeyEventWin.cpp: Removed. + +2010-02-01 Eric Carlson <eric.carlson@apple.com> + + Reviewed by Adele Peterson. + + Fullscreen API should be on HTMLVideoElement + https://bugs.webkit.org/show_bug.cgi?id=34438 + + Move fullscreen DOM APIs from HTMLMediaElement to HTMLVideoElement. + + * html/HTMLMediaElement.cpp: + * html/HTMLMediaElement.h: + * html/HTMLMediaElement.idl: + * html/HTMLVideoElement.cpp: + (WebCore::HTMLVideoElement::paint): Removed outdated FIXME. + (WebCore::HTMLVideoElement::paintCurrentFrameInContext): Ditto. + (WebCore::HTMLVideoElement::webkitEnterFullScreen): Moved from HTMLMediaElement. + (WebCore::HTMLVideoElement::webkitExitFullScreen): Ditto. + (WebCore::HTMLVideoElement::webkitSupportsFullscreen): Ditto. + (WebCore::HTMLVideoElement::webkitDisplayingFullscreen): Ditto. + * html/HTMLVideoElement.h: + * html/HTMLVideoElement.idl: + +2010-02-01 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: Syntax highlighting in source view of + Resources pane stops half-way. + + There were two problems here: (1) styles for html highlighter were not + added into the css file (they used to be injected manually in the + SourceFrame before). (2) 'Tag' needed to be lexer's state, not parser's. + Otherwise unbalanced quotes in the text nodes were matching too match + into the string tokens. + + https://bugs.webkit.org/show_bug.cgi?id=34359 + + * inspector/front-end/NativeTextViewer.js: + (WebInspector.NativeTextViewer.prototype._createLineDivs): + (WebInspector.NativeTextViewer.prototype._lineHeight): + (WebInspector.NativeTextViewer.prototype.initFontMetrics): + * inspector/front-end/SourceFrame.js: + (WebInspector.SourceFrame.prototype._createEditorIfNeeded): + * inspector/front-end/SourceHTMLTokenizer.js: + (WebInspector.SourceHTMLTokenizer): + (WebInspector.SourceHTMLTokenizer.prototype.nextToken): + * inspector/front-end/SourceHTMLTokenizer.re2js: + * inspector/front-end/TextEditor.js: + (WebInspector.TextEditor.prototype.initFontMetrics): + (WebInspector.TextEditor.prototype._registerShortcuts): + * inspector/front-end/inspectorSyntaxHighlight.css: + +2010-02-01 Ben Murdoch <benm@google.com> + + Reviewed by Darin Adler. + + ScriptCallFrame's do not get line numbers/source id's if the caller is unkown. + https://bugs.webkit.org/show_bug.cgi?id=34335 + + * bindings/js/ScriptCallStack.cpp: + (WebCore::ScriptCallStack::ScriptCallStack): If the caller is unknown, the line number and source information is still availble so pass it to the ScriptCallFrame being constructed. + +2010-02-01 Dirk Schulze <krit@webkit.org> + + Reviewed by Simon Fraser. + + Add back an AffineTransform class for use by SVG + https://bugs.webkit.org/show_bug.cgi?id=33750 + + These are the first steps on reimplementing AffineTransform. Unlike + the old affine code, this one is platform independent like TransformationMatrix. + AffineTransform has the benefit, that it stores just 6 doubles instead of + 16 in TransformationMatrix. The calculations of transformations are not that + complex and can improve the memory usage and speed of SVG. + AffineTransform can be used by HTML Canvas3D or SVG, since they are 2D related (at + least for the moment). + HTML Canvas is the first that makes use of the new AffineTransform. Next patches + will introduce the affine code to SVG. + + No new tests. The new AffineTransformation code is tested by fast/canvas. + + * Android.mk: + * GNUmakefile.am: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * html/canvas/CanvasRenderingContext2D.cpp: + (WebCore::CanvasRenderingContext2D::scale): + (WebCore::CanvasRenderingContext2D::rotate): + (WebCore::CanvasRenderingContext2D::translate): + (WebCore::CanvasRenderingContext2D::transform): + (WebCore::CanvasRenderingContext2D::setTransform): + (WebCore::CanvasRenderingContext2D::isPointInPath): + (WebCore::CanvasRenderingContext2D::willDraw): + * html/canvas/CanvasRenderingContext2D.h: + * platform/graphics/GraphicsContext.h: + * platform/graphics/Path.h: + * platform/graphics/cairo/GraphicsContextCairo.cpp: + (WebCore::GraphicsContext::getAffineCTM): + (WebCore::GraphicsContext::concatCTM): + * platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h: + (WebCore::GraphicsContextPlatformPrivate::concatCTM): + * platform/graphics/cairo/PathCairo.cpp: + (WebCore::Path::transform): + * platform/graphics/cairo/TransformationMatrixCairo.cpp: + (WebCore::AffineTransform::operator cairo_matrix_t): + * platform/graphics/cg/GraphicsContextCG.cpp: + (WebCore::GraphicsContext::concatCTM): + (WebCore::GraphicsContext::getAffineCTM): + * platform/graphics/cg/GraphicsContextPlatformPrivateCG.h: + (WebCore::GraphicsContextPlatformPrivate::concatCTM): + * platform/graphics/cg/PathCG.cpp: + (WebCore::Path::transform): + * platform/graphics/cg/TransformationMatrixCG.cpp: + (WebCore::AffineTransform::operator CGAffineTransform): + * platform/graphics/haiku/GraphicsContextHaiku.cpp: + (WebCore::GraphicsContext::getAffineCTM): + (WebCore::GraphicsContext::concatCTM): + * platform/graphics/haiku/PathHaiku.cpp: + (WebCore::Path::transform): + * platform/graphics/qt/GraphicsContextQt.cpp: + (WebCore::GraphicsContext::getAffineCTM): + (WebCore::GraphicsContext::concatCTM): + * platform/graphics/qt/PathQt.cpp: + (WebCore::Path::transform): + * platform/graphics/qt/TransformationMatrixQt.cpp: + (WebCore::AffineTransform::operator QTransform): + * platform/graphics/skia/GraphicsContextSkia.cpp: + (WebCore::GraphicsContext::concatCTM): + (WebCore::GraphicsContext::getAffineCTM): + * platform/graphics/skia/PathSkia.cpp: + (WebCore::Path::transform): + * platform/graphics/skia/TransformationMatrixSkia.cpp: + (WebCore::AffineTransform::operator SkMatrix): + * platform/graphics/transforms/AffineTransform.cpp: Added. + (WebCore::affineTransformDecompose): + (WebCore::affineTransformCompose): + (WebCore::AffineTransform::AffineTransform): + (WebCore::AffineTransform::reset): + (WebCore::AffineTransform::setMatrix): + (WebCore::AffineTransform::isIdentity): + (WebCore::AffineTransform::det): + (WebCore::AffineTransform::isInvertible): + (WebCore::AffineTransform::inverse): + (WebCore::AffineTransform::multiply): + (WebCore::AffineTransform::multLeft): + (WebCore::AffineTransform::rotate): + (WebCore::AffineTransform::scale): + (WebCore::AffineTransform::translate): + (WebCore::AffineTransform::scaleNonUniform): + (WebCore::AffineTransform::rotateFromVector): + (WebCore::AffineTransform::flipX): + (WebCore::AffineTransform::flipY): + (WebCore::AffineTransform::shear): + (WebCore::AffineTransform::skew): + (WebCore::AffineTransform::skewX): + (WebCore::AffineTransform::skewY): + (WebCore::makeMapBetweenRects): + (WebCore::AffineTransform::map): + (WebCore::AffineTransform::mapPoint): + (WebCore::AffineTransform::mapRect): + (WebCore::AffineTransform::blend): + (WebCore::AffineTransform::toTransformationMatrix): + * platform/graphics/transforms/AffineTransform.h: Added. + (WebCore::AffineTransform::a): + (WebCore::AffineTransform::setA): + (WebCore::AffineTransform::b): + (WebCore::AffineTransform::setB): + (WebCore::AffineTransform::c): + (WebCore::AffineTransform::setC): + (WebCore::AffineTransform::d): + (WebCore::AffineTransform::setD): + (WebCore::AffineTransform::e): + (WebCore::AffineTransform::setE): + (WebCore::AffineTransform::f): + (WebCore::AffineTransform::setF): + (WebCore::AffineTransform::operator== ): + (WebCore::AffineTransform::operator!=): + (WebCore::AffineTransform::operator*=): + (WebCore::AffineTransform::operator*): + (WebCore::AffineTransform::setMatrix): + * platform/graphics/win/GraphicsContextWin.cpp: + (WebCore::GraphicsContextPlatformPrivate::concatCTM): + * platform/graphics/wince/GraphicsContextWince.cpp: + (WebCore::GraphicsContext::concatCTM): + (WebCore::GraphicsContext::getAffineCTM): + * platform/graphics/wx/GraphicsContextWx.cpp: + (WebCore::GraphicsContext::getAffineCTM): + (WebCore::GraphicsContext::concatCTM): + * platform/graphics/wx/PathWx.cpp: + (WebCore::Path::transform): + * platform/graphics/wx/TransformationMatrixWx.cpp: + (WebCore::AffineTransform::operator wxGraphicsMatrix): + +2010-01-29 Philippe Normand <pnormand@igalia.com> + + Reviewed by Eric Carlson. + + [GTK] set playbin mute property depending on volume value + https://bugs.webkit.org/show_bug.cgi?id=31586 + + New API in MediaPlayer for mute control. 3 new methods are + introduced: + + - bool supportsMuting() const; + - bool muted() const; + - void setMuted(bool); + + Platform MediaPlayer implementations can support it easily if the + underlying sound daemon/API supports muting (eg. not only setting + volume to 0) like PulseAudio for instance on Linux. At the moment + the only player supporting this new API is the + MediaPlayerPrivateGStreamer. + + * html/HTMLMediaElement.cpp: + (WebCore::HTMLMediaElement::setMuted): + (WebCore::HTMLMediaElement::mediaPlayerVolumeChanged): + (WebCore::HTMLMediaElement::mediaPlayerMuteChanged): + * html/HTMLMediaElement.h: + * platform/graphics/MediaPlayer.cpp: + (WebCore::NullMediaPlayerPrivate::supportsMuting): + (WebCore::NullMediaPlayerPrivate::setMuted): + (WebCore::MediaPlayer::MediaPlayer): + (WebCore::MediaPlayer::muted): + (WebCore::MediaPlayer::supportsMuting): + (WebCore::MediaPlayer::setMuted): + (WebCore::MediaPlayer::volumeChanged): + (WebCore::MediaPlayer::muteChanged): + * platform/graphics/MediaPlayer.h: + (WebCore::MediaPlayerClient::mediaPlayerMuteChanged): + * platform/graphics/MediaPlayerPrivate.h: + (WebCore::MediaPlayerPrivateInterface::supportsMuting): + (WebCore::MediaPlayerPrivateInterface::setMuted): + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: + (WebCore::mediaPlayerPrivateVolumeChangedCallback): + (WebCore::notifyVolumeIdleCallback): + (WebCore::mediaPlayerPrivateMuteChangedCallback): + (WebCore::notifyMuteIdleCallback): + (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): + (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): + (WebCore::MediaPlayerPrivate::volumeChangedCallback): + (WebCore::MediaPlayerPrivate::volumeChanged): + (WebCore::MediaPlayerPrivate::supportsMuting): + (WebCore::MediaPlayerPrivate::setMuted): + (WebCore::MediaPlayerPrivate::muteChangedCallback): + (WebCore::MediaPlayerPrivate::muteChanged): + (WebCore::MediaPlayerPrivate::createGSTPlayBin): + * platform/graphics/gtk/MediaPlayerPrivateGStreamer.h: + +2010-02-01 Henry Haverinen <henry.haverinen@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Build without SSL support is broken + + Added missing #ifdefs for OpenSSL support and one null-pointer + check for the socket. + + https://bugs.webkit.org/show_bug.cgi?id=34416 + + * platform/network/qt/SocketStreamHandlePrivate.h: + * platform/network/qt/SocketStreamHandleQt.cpp: + (WebCore::SocketStreamHandlePrivate::SocketStreamHandlePrivate): + (WebCore::SocketStreamHandlePrivate::send): + +2010-02-01 Pavel Feldman <pfeldman@chromium.org> + + Reviewed by Timothy Hatcher. + + Web Inspector: Fix rest of the NativeTextViewer (line numbers, + conditional breakpoints, selection). + + * inspector/front-end/NativeTextViewer.js: + (WebInspector.NativeTextViewer): + (WebInspector.NativeTextViewer.prototype._updatePreferredSize): + (WebInspector.NativeTextViewer.prototype._registerMouseListeners): + (WebInspector.NativeTextViewer.prototype._mouseDown): + (WebInspector.NativeTextViewer.prototype._contextMenu): + (WebInspector.NativeTextViewer.prototype._lineForMouseEvent): + (WebInspector.NativeTextViewer.prototype._lineHeight): + * inspector/front-end/TextEditor.js: + (WebInspector.TextEditor): + (WebInspector.TextEditor.prototype._registerMouseListeners): + (WebInspector.TextEditor.prototype._offsetToLine): + (WebInspector.TextEditor.prototype._lineHeight): + (WebInspector.TextEditor.prototype.reveal): + (WebInspector.TextEditor.prototype._paint): + (WebInspector.TextEditor.prototype._updateDivDecorations): + (WebInspector.TextEditor.prototype._paintSelection): + +2010-02-01 Steve Block <steveblock@google.com> + + Reviewed by Ariya Hidayat. + + Adds implementation of JavaString for V8. + https://bugs.webkit.org/show_bug.cgi?id=33953 + + No new tests, build fix only. + + * bridge/jni/JNIBridge.h: Modified. Include JavaStringV8.h for V8 + * bridge/jni/v8: Added. + * bridge/jni/v8/JavaStringV8.h: Added. + (JSC::Bindings::JavaStringImpl::init): + (JSC::Bindings::JavaStringImpl::UTF8String): + (JSC::Bindings::JavaStringImpl::uchars): + (JSC::Bindings::JavaStringImpl::length): + +2010-02-01 Alex Milowski <alex@milowski.com> + + Reviewed by Darin Adler. + + Added compile time debug support for mathml layout (block boundary & baseline) + + * mathml/RenderMathMLBlock.cpp: + (WebCore::RenderMathMLBlock::stretchToHeight): + (WebCore::RenderMathMLBlock::paint): + * mathml/RenderMathMLBlock.h: + +>>>>>>> webkit.org at r54340 2010-02-01 Philippe Normand <pnormand@igalia.com> Rubber stamped by Xan Lopez. diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am index 7afe8d8..f2dacec 100644 --- a/WebCore/GNUmakefile.am +++ b/WebCore/GNUmakefile.am @@ -484,6 +484,9 @@ webcore_sources += \ WebCore/bindings/js/ScriptInstance.h \ WebCore/bindings/js/ScriptObject.cpp \ WebCore/bindings/js/ScriptObject.h \ + WebCore/bindings/js/ScriptProfile.h \ + WebCore/bindings/js/ScriptProfiler.cpp \ + WebCore/bindings/js/ScriptProfiler.h \ WebCore/bindings/js/ScriptSourceCode.h \ WebCore/bindings/js/ScriptSourceProvider.h \ WebCore/bindings/js/ScriptState.cpp \ @@ -1191,6 +1194,8 @@ webcore_sources += \ WebCore/icu/unicode/uversion.h \ WebCore/inspector/ConsoleMessage.cpp \ WebCore/inspector/ConsoleMessage.h \ + WebCore/inspector/InjectedScript.cpp \ + WebCore/inspector/InjectedScript.h \ WebCore/inspector/InjectedScriptHost.cpp \ WebCore/inspector/InjectedScriptHost.h \ WebCore/inspector/InspectorBackend.cpp \ @@ -1601,6 +1606,8 @@ webcore_sources += \ WebCore/platform/graphics/UnitBezier.h \ WebCore/platform/graphics/WidthIterator.cpp \ WebCore/platform/graphics/WidthIterator.h \ + WebCore/platform/graphics/transforms/AffineTransform.cpp \ + WebCore/platform/graphics/transforms/AffineTransform.h \ WebCore/platform/graphics/transforms/IdentityTransformOperation.h \ WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp \ WebCore/platform/graphics/transforms/MatrixTransformOperation.h \ @@ -2004,6 +2011,8 @@ webcoregtk_sources += \ WebCore/platform/gtk/FileSystemGtk.cpp \ WebCore/platform/gtk/GRefPtrGtk.cpp \ WebCore/platform/gtk/GRefPtrGtk.h \ + WebCore/platform/gtk/GOwnPtrGtk.cpp \ + WebCore/platform/gtk/GOwnPtrGtk.h \ WebCore/platform/gtk/GtkPluginWidget.cpp \ WebCore/platform/gtk/GtkPluginWidget.h \ WebCore/platform/gtk/KURLGtk.cpp \ diff --git a/WebCore/WebCore.Video.exp b/WebCore/WebCore.Video.exp index 57619b4..da79150 100644 --- a/WebCore/WebCore.Video.exp +++ b/WebCore/WebCore.Video.exp @@ -3,13 +3,14 @@ __ZN7WebCore16HTMLMediaElement12endScrubbingEv __ZN7WebCore16HTMLMediaElement14beginScrubbingEv __ZN7WebCore16HTMLMediaElement14exitFullscreenEv __ZN7WebCore16HTMLMediaElement14setCurrentTimeEfRi -__ZN7WebCore16HTMLMediaElement4playEv -__ZN7WebCore16HTMLMediaElement5pauseEv +__ZN7WebCore16HTMLMediaElement4playEb +__ZN7WebCore16HTMLMediaElement5pauseEb __ZN7WebCore16HTMLMediaElement6rewindEf __ZN7WebCore16HTMLMediaElement8setMutedEb __ZN7WebCore16HTMLMediaElement9setVolumeEfRi __ZNK7WebCore16HTMLMediaElement11currentTimeEv __ZNK7WebCore16HTMLMediaElement13platformMediaEv +__ZNK7WebCore16HTMLMediaElement21processingUserGestureEv __ZNK7WebCore16HTMLMediaElement5mutedEv __ZNK7WebCore16HTMLMediaElement6volumeEv __ZNK7WebCore16HTMLMediaElement7canPlayEv diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp index 5b013e7..fbab12e 100644 --- a/WebCore/WebCore.base.exp +++ b/WebCore/WebCore.base.exp @@ -249,6 +249,7 @@ __ZN7WebCore12IconDatabase4openERKNS_6StringE __ZN7WebCore12IconDatabase5closeEv __ZN7WebCore12IconDatabase9setClientEPNS_18IconDatabaseClientE __ZN7WebCore12PluginWidget14invalidateRectERKNS_7IntRectE +__ZN7WebCore12PrintContext20pageNumberForElementEPNS_7ElementERKNS_9FloatSizeE __ZN7WebCore12RenderObject16repaintRectangleERKNS_7IntRectEb __ZN7WebCore12RenderWidget19showSubstituteImageEN3WTF10PassRefPtrINS_5ImageEEE __ZN7WebCore12SchedulePairC1EP9NSRunLoopPK10__CFString diff --git a/WebCore/WebCore.gyp/WebCore.gyp b/WebCore/WebCore.gyp/WebCore.gyp index 184990a..e40da56 100644 --- a/WebCore/WebCore.gyp/WebCore.gyp +++ b/WebCore/WebCore.gyp/WebCore.gyp @@ -302,9 +302,8 @@ '<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLNames.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLNames.h', '<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLElementFactory.cpp', - # Pass --wrapperFactory to make_names to get these (JSC build?) - #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSHTMLElementWrapperFactory.cpp', - #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSHTMLElementWrapperFactory.h', + '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.cpp', + '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.h', ], 'action': [ 'python', @@ -314,6 +313,7 @@ '<@(_inputs)', '--', '--factory', + '--wrapperFactoryV8', '--extraDefines', '<(feature_defines)' ], }, @@ -329,9 +329,8 @@ '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGNames.h', '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.h', - # Pass --wrapperFactory to make_names to get these (JSC build?) - #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSSVGElementWrapperFactory.cpp', - #'<(SHARED_INTERMEDIATE_DIR)/webkit/JSSVGElementWrapperFactory.h', + '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.cpp', + '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.h', ], 'action': [ 'python', @@ -341,6 +340,7 @@ '<@(_inputs)', '--', '--factory', + '--wrapperFactoryV8', '--extraDefines', '<(feature_defines)' ], }, @@ -586,6 +586,8 @@ '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGElementFactory.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/SVGNames.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/UserAgentStyleSheetsData.cpp', + '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.cpp', + '<(SHARED_INTERMEDIATE_DIR)/webkit/V8SVGElementWrapperFactory.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/XLinkNames.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/XMLNSNames.cpp', '<(SHARED_INTERMEDIATE_DIR)/webkit/XMLNames.cpp', diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index c4f64c7..8291811 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -654,7 +654,10 @@ 'bindings/v8/ChildThreadDOMData.h', 'bindings/v8/custom/V8AbstractWorkerCustom.cpp', 'bindings/v8/custom/V8AttrCustom.cpp', + 'bindings/v8/custom/V8BarInfoCustom.cpp', + 'bindings/v8/custom/V8CanvasPixelArrayCustom.cpp', 'bindings/v8/custom/V8WebGLArrayCustom.h', + 'bindings/v8/custom/V8WebGLArrayCustom.cpp', 'bindings/v8/custom/V8WebGLArrayBufferCustom.cpp', 'bindings/v8/custom/V8WebGLByteArrayCustom.cpp', 'bindings/v8/custom/V8WebGLIntArrayCustom.cpp', @@ -667,8 +670,10 @@ 'bindings/v8/custom/V8WebGLRenderingContextCustom.cpp', 'bindings/v8/custom/V8ClipboardCustom.cpp', 'bindings/v8/custom/V8CoordinatesCustom.cpp', + 'bindings/v8/custom/V8CSSRuleCustom.cpp', 'bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp', - 'bindings/v8/custom/V8ConsoleCustom.cpp', + 'bindings/v8/custom/V8CSSStyleSheetCustom.cpp', + 'bindings/v8/custom/V8CSSValueCustom.cpp', 'bindings/v8/custom/V8CustomBinding.h', 'bindings/v8/custom/V8CustomEventListener.cpp', 'bindings/v8/custom/V8CustomEventListener.h', @@ -693,6 +698,7 @@ 'bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp', 'bindings/v8/custom/V8DocumentLocationCustom.cpp', 'bindings/v8/custom/V8DOMApplicationCacheCustom.cpp', + 'bindings/v8/custom/V8DOMSelectionCustom.cpp', 'bindings/v8/custom/V8DOMWindowCustom.cpp', 'bindings/v8/custom/V8DocumentCustom.cpp', 'bindings/v8/custom/V8ElementCustom.cpp', @@ -708,6 +714,7 @@ 'bindings/v8/custom/V8HTMLCollectionCustom.cpp', 'bindings/v8/custom/V8HTMLDataGridElementCustom.cpp', 'bindings/v8/custom/V8HTMLDocumentCustom.cpp', + 'bindings/v8/custom/V8HTMLElementCustom.cpp', 'bindings/v8/custom/V8HTMLFormElementCustom.cpp', 'bindings/v8/custom/V8HTMLFrameElementCustom.cpp', 'bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp', @@ -743,10 +750,15 @@ 'bindings/v8/custom/V8StorageCustom.cpp', 'bindings/v8/custom/V8SQLResultSetRowListCustom.cpp', 'bindings/v8/custom/V8SQLTransactionCustom.cpp', + 'bindings/v8/custom/V8SVGDocumentCustom.cpp', + 'bindings/v8/custom/V8SVGElementCustom.cpp', 'bindings/v8/custom/V8SVGElementInstanceCustom.cpp', 'bindings/v8/custom/V8SVGLengthCustom.cpp', 'bindings/v8/custom/V8SVGMatrixCustom.cpp', + 'bindings/v8/custom/V8SVGPathSegCustom.cpp', + 'bindings/v8/custom/V8ScreenCustom.cpp', 'bindings/v8/custom/V8SharedWorkerCustom.cpp', + 'bindings/v8/custom/V8StyleSheetCustom.cpp', 'bindings/v8/custom/V8StyleSheetListCustom.cpp', 'bindings/v8/custom/V8TreeWalkerCustom.cpp', 'bindings/v8/custom/V8WebKitCSSMatrixConstructor.cpp', @@ -797,6 +809,9 @@ 'bindings/v8/ScriptInstance.h', 'bindings/v8/ScriptObject.cpp', 'bindings/v8/ScriptObject.h', + 'bindings/v8/ScriptProfile.h', + 'bindings/v8/ScriptProfiler.cpp', + 'bindings/v8/ScriptProfiler.h', 'bindings/v8/ScriptScope.cpp', 'bindings/v8/ScriptScope.h', 'bindings/v8/ScriptSourceCode.h', @@ -1566,6 +1581,8 @@ 'inspector/InspectorClient.h', 'inspector/ConsoleMessage.cpp', 'inspector/ConsoleMessage.h', + 'inspector/InjectedScript.cpp', + 'inspector/InjectedScript.h', 'inspector/InjectedScriptHost.cpp', 'inspector/InjectedScriptHost.h', 'inspector/InspectorBackend.cpp', @@ -2136,6 +2153,8 @@ 'platform/graphics/skia/SkiaUtils.cpp', 'platform/graphics/skia/SkiaUtils.h', 'platform/graphics/skia/TransformationMatrixSkia.cpp', + 'platform/graphics/transforms/AffineTransform.cpp', + 'platform/graphics/transforms/AffineTransform.h', 'platform/graphics/transforms/IdentityTransformOperation.h', 'platform/graphics/transforms/Matrix3DTransformOperation.cpp', 'platform/graphics/transforms/Matrix3DTransformOperation.h', diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro index d7a8c79..be4244d 100644 --- a/WebCore/WebCore.pro +++ b/WebCore/WebCore.pro @@ -346,6 +346,7 @@ SOURCES += \ bindings/js/ScriptEventListener.cpp \ bindings/js/ScriptFunctionCall.cpp \ bindings/js/ScriptObject.cpp \ + bindings/js/ScriptProfiler.cpp \ bindings/js/ScriptState.cpp \ bindings/js/ScriptValue.cpp \ bindings/js/ScheduledAction.cpp \ @@ -663,6 +664,7 @@ SOURCES += \ html/PreloadScanner.cpp \ html/ValidityState.cpp \ inspector/ConsoleMessage.cpp \ + inspector/InjectedScript.cpp \ inspector/InjectedScriptHost.cpp \ inspector/InspectorBackend.cpp \ inspector/InspectorController.cpp \ @@ -804,6 +806,7 @@ SOURCES += \ platform/graphics/Pen.cpp \ platform/graphics/SegmentedFontData.cpp \ platform/graphics/SimpleFontData.cpp \ + platform/graphics/transforms/AffineTransform.cpp \ platform/graphics/transforms/TransformationMatrix.cpp \ platform/graphics/transforms/MatrixTransformOperation.cpp \ platform/graphics/transforms/Matrix3DTransformOperation.cpp \ @@ -1353,6 +1356,7 @@ HEADERS += \ html/TimeRanges.h \ html/ValidityState.h \ inspector/ConsoleMessage.h \ + inspector/InjectedScript.h \ inspector/InjectedScriptHost.h \ inspector/InspectorBackend.h \ inspector/InspectorController.h \ @@ -2660,7 +2664,19 @@ SOURCES += \ include($$PWD/../WebKit/qt/Api/headers.pri) HEADERS += $$WEBKIT_API_HEADERS -!CONFIG(standalone_package) { +CONFIG(standalone_package) { + + !symbian { + target.path = $$[QT_INSTALL_LIBS] + INSTALLS += target + } + + include($$PWD/../include/QtWebKit/headers.pri) + headers.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES + headers.path = $$[QT_INSTALL_HEADERS]/QtWebKit + INSTALLS += headers + +} else { target.path = $$[QT_INSTALL_LIBS] headers.files = $$WEBKIT_API_HEADERS headers.path = $$[QT_INSTALL_HEADERS]/QtWebKit diff --git a/WebCore/WebCore.vcproj/MigrateIDLAndScripts b/WebCore/WebCore.vcproj/MigrateIDLAndScripts deleted file mode 100644 index ee5d02d..0000000 --- a/WebCore/WebCore.vcproj/MigrateIDLAndScripts +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright (C) 2007 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of -# its contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -.PHONY : all -all : \ - $(WEBKIT_OUTPUT)/Node.idl \ - $(WEBKIT_OUTPUT)/Attr.idl \ - $(WEBKIT_OUTPUT)/Element.idl \ - $(WEBKIT_OUTPUT)/NodeList.idl \ - $(WEBKIT_OUTPUT)/Document.idl \ - $(WEBKIT_OUTPUT)/CharacterData.idl \ - $(WEBKIT_OUTPUT)/CDATASection.idl \ - $(WEBKIT_OUTPUT)/Comment.idl \ - $(WEBKIT_OUTPUT)/Text.idl \ - $(WEBKIT_OUTPUT)/DocumentFragment.idl \ - $(WEBKIT_OUTPUT)/DocumentType.idl \ - $(WEBKIT_OUTPUT)/DOMImplementation.idl \ - $(WEBKIT_OUTPUT)/Entity.idl \ - $(WEBKIT_OUTPUT)/EntityReference.idl \ - $(WEBKIT_OUTPUT)/NamedNodeMap.idl \ - $(WEBKIT_OUTPUT)/Notation.idl \ - $(WEBKIT_OUTPUT)/ProcessingInstruction.idl \ - \ - $(WEBKIT_OUTPUT)/HTMLAnchorElement.idl \ - $(WEBKIT_OUTPUT)/HTMLAppletElement.idl \ - $(WEBKIT_OUTPUT)/HTMLAreaElement.idl \ - $(WEBKIT_OUTPUT)/HTMLBRElement.idl \ - $(WEBKIT_OUTPUT)/HTMLBaseElement.idl \ - $(WEBKIT_OUTPUT)/HTMLBaseFontElement.idl \ - $(WEBKIT_OUTPUT)/HTMLBlockquoteElement.idl \ - $(WEBKIT_OUTPUT)/HTMLBodyElement.idl \ - $(WEBKIT_OUTPUT)/HTMLButtonElement.idl \ - $(WEBKIT_OUTPUT)/HTMLCollection.idl \ - $(WEBKIT_OUTPUT)/HTMLDListElement.idl \ - $(WEBKIT_OUTPUT)/HTMLDirectoryElement.idl \ - $(WEBKIT_OUTPUT)/HTMLDivElement.idl \ - $(WEBKIT_OUTPUT)/HTMLDocument.idl \ - $(WEBKIT_OUTPUT)/HTMLElement.idl \ - $(WEBKIT_OUTPUT)/HTMLEmbedElement.idl \ - $(WEBKIT_OUTPUT)/HTMLFieldSetElement.idl \ - $(WEBKIT_OUTPUT)/HTMLFontElement.idl \ - $(WEBKIT_OUTPUT)/HTMLFormElement.idl \ - $(WEBKIT_OUTPUT)/HTMLFrameElement.idl \ - $(WEBKIT_OUTPUT)/HTMLFrameSetElement.idl \ - $(WEBKIT_OUTPUT)/HTMLHRElement.idl \ - $(WEBKIT_OUTPUT)/HTMLHeadElement.idl \ - $(WEBKIT_OUTPUT)/HTMLHeadingElement.idl \ - $(WEBKIT_OUTPUT)/HTMLHtmlElement.idl \ - $(WEBKIT_OUTPUT)/HTMLIFrameElement.idl \ - $(WEBKIT_OUTPUT)/HTMLImageElement.idl \ - $(WEBKIT_OUTPUT)/HTMLInputElement.idl \ - $(WEBKIT_OUTPUT)/HTMLIsIndexElement.idl \ - $(WEBKIT_OUTPUT)/HTMLLIElement.idl \ - $(WEBKIT_OUTPUT)/HTMLLabelElement.idl \ - $(WEBKIT_OUTPUT)/HTMLLegendElement.idl \ - $(WEBKIT_OUTPUT)/HTMLLinkElement.idl \ - $(WEBKIT_OUTPUT)/HTMLMapElement.idl \ - $(WEBKIT_OUTPUT)/HTMLMarqueeElement.idl \ - $(WEBKIT_OUTPUT)/HTMLMenuElement.idl \ - $(WEBKIT_OUTPUT)/HTMLMetaElement.idl \ - $(WEBKIT_OUTPUT)/HTMLModElement.idl \ - $(WEBKIT_OUTPUT)/HTMLOListElement.idl \ - $(WEBKIT_OUTPUT)/HTMLObjectElement.idl \ - $(WEBKIT_OUTPUT)/HTMLOptGroupElement.idl \ - $(WEBKIT_OUTPUT)/HTMLOptionElement.idl \ - $(WEBKIT_OUTPUT)/HTMLOptionsCollection.idl \ - $(WEBKIT_OUTPUT)/HTMLParagraphElement.idl \ - $(WEBKIT_OUTPUT)/HTMLParamElement.idl \ - $(WEBKIT_OUTPUT)/HTMLPreElement.idl \ - $(WEBKIT_OUTPUT)/HTMLQuoteElement.idl \ - $(WEBKIT_OUTPUT)/HTMLScriptElement.idl \ - $(WEBKIT_OUTPUT)/HTMLSelectElement.idl \ - $(WEBKIT_OUTPUT)/HTMLStyleElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTableCaptionElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTableCellElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTableColElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTableElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTableRowElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTableSectionElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTextAreaElement.idl \ - $(WEBKIT_OUTPUT)/HTMLTitleElement.idl \ - $(WEBKIT_OUTPUT)/HTMLUListElement.idl \ - \ - $(WEBKIT_OUTPUT)/CSSCharsetRule.idl \ - $(WEBKIT_OUTPUT)/CSSFontFaceRule.idl \ - $(WEBKIT_OUTPUT)/CSSImportRule.idl \ - $(WEBKIT_OUTPUT)/CSSMediaRule.idl \ - $(WEBKIT_OUTPUT)/CSSPageRule.idl \ - $(WEBKIT_OUTPUT)/CSSPrimitiveValue.idl \ - $(WEBKIT_OUTPUT)/CSSRule.idl \ - $(WEBKIT_OUTPUT)/CSSRuleList.idl \ - $(WEBKIT_OUTPUT)/CSSStyleDeclaration.idl \ - $(WEBKIT_OUTPUT)/CSSStyleRule.idl \ - $(WEBKIT_OUTPUT)/CSSStyleSheet.idl \ - $(WEBKIT_OUTPUT)/CSSUnknownRule.idl \ - $(WEBKIT_OUTPUT)/CSSValue.idl \ - $(WEBKIT_OUTPUT)/CSSValueList.idl \ - $(WEBKIT_OUTPUT)/Counter.idl \ - $(WEBKIT_OUTPUT)/MediaList.idl \ - $(WEBKIT_OUTPUT)/Rect.idl \ - $(WEBKIT_OUTPUT)/StyleSheet.idl \ - $(WEBKIT_OUTPUT)/StyleSheetList.idl \ - \ - $(WEBKIT_OUTPUT)/Event.idl \ - $(WEBKIT_OUTPUT)/EventTarget.idl \ - $(WEBKIT_OUTPUT)/EventListener.idl \ - \ - $(WEBKIT_OUTPUT)/CodeGenerator.pm \ - $(WEBKIT_OUTPUT)/IDLParser.pm \ - $(WEBKIT_OUTPUT)/IDLStructure.pm \ - $(WEBKIT_OUTPUT)/generate-bindings.pl \ -# - -# $(WEBKIT_OUTPUT)/CanvasGradient.idl \ -# $(WEBKIT_OUTPUT)/CanvasPattern.idl \ -# $(WEBKIT_OUTPUT)/CanvasRenderingContext2D.idl \ -# $(WEBKIT_OUTPUT)/HTMLCanvasElement.idl \ -# $(WEBKIT_OUTPUT)/RGBColor.idl \ - -MIGRATE_CMD = cp $< $@ - -# Migrate core/event IDLs -$(WEBKIT_OUTPUT)/% : $(WEBCORE)/dom/% - $(MIGRATE_CMD) - -# Migrate html IDLs -$(WEBKIT_OUTPUT)/% : $(WEBCORE)/html/% - $(MIGRATE_CMD) - -# Migrate css IDLs -$(WEBKIT_OUTPUT)/% : $(WEBCORE)/css/% - $(MIGRATE_CMD) - -# Migrate workers IDLs -$(WEBKIT_OUTPUT)/% : $(WEBCORE)/workers/% - $(MIGRATE_CMD) - - -# Migrate generation scripts -$(WEBKIT_OUTPUT)/% : $(WEBCORE)/bindings/scripts/% - $(MIGRATE_CMD) diff --git a/WebCore/WebCore.vcproj/MigrateScripts b/WebCore/WebCore.vcproj/MigrateScripts new file mode 100644 index 0000000..d6df830 --- /dev/null +++ b/WebCore/WebCore.vcproj/MigrateScripts @@ -0,0 +1,39 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of +# its contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +.PHONY : all +all : \ + $(WEBKIT_OUTPUT)/CodeGenerator.pm \ + $(WEBKIT_OUTPUT)/IDLParser.pm \ + $(WEBKIT_OUTPUT)/IDLStructure.pm \ + $(WEBKIT_OUTPUT)/generate-bindings.pl \ +# + +MIGRATE_CMD = cp $< $@ + +# Migrate generation scripts +$(WEBKIT_OUTPUT)/% : $(WEBCORE)/bindings/scripts/% + $(MIGRATE_CMD) diff --git a/WebCore/WebCore.vcproj/QTMovieWin.rc b/WebCore/WebCore.vcproj/QTMovieWin.rc index 459679b..ee374e1 100644 --- a/WebCore/WebCore.vcproj/QTMovieWin.rc +++ b/WebCore/WebCore.vcproj/QTMovieWin.rc @@ -34,7 +34,7 @@ BEGIN VALUE "FileVersion", __VERSION_TEXT__ VALUE "CompanyName", "Apple Inc." VALUE "InternalName", "WebKit" - VALUE "LegalCopyright", "Copyright Apple Inc. 2007-2010" + VALUE "LegalCopyright", "Copyright Apple Inc. 2007-" __COPYRIGHT_YEAR_END_TEXT__ VALUE "OriginalFilename", "QTMovieWin.dll" VALUE "ProductName", "WebKit" VALUE "ProductVersion", __VERSION_TEXT__ diff --git a/WebCore/WebCore.vcproj/WebCore.make b/WebCore/WebCore.vcproj/WebCore.make index 3a6d697..26ad54f 100644 --- a/WebCore/WebCore.vcproj/WebCore.make +++ b/WebCore/WebCore.vcproj/WebCore.make @@ -12,6 +12,6 @@ install: xcopy "$(OBJROOT)\include\*" "$(DSTROOT)\AppleInternal\include\" /e/v/i/h/y xcopy "$(OBJROOT)\lib\*" "$(DSTROOT)\AppleInternal\lib\" /e/v/i/h/y xcopy "$(OBJROOT)\bin\WebKit.resources\*" "$(DSTROOT)\AppleInternal\bin\WebKit.resources" /e/v/i/h/y - xcopy "$(OBJROOT)\obj\WebKit\DOMInterfaces\*" "$(DSTROOT)\AppleInternal\obj\WebKit\DOMInterfaces" /e/v/i/h/y + xcopy "$(OBJROOT)\obj\WebCore\scripts\*" "$(DSTROOT)\AppleInternal\obj\WebCore\scripts" /e/v/i/h/y xcopy "$(OBJROOT)\bin\*.pdb" "$(DSTROOT)\AppleInternal\bin\" /e/v/i/h/y xcopy "$(OBJROOT)\bin\*.dll" "$(DSTROOT)\AppleInternal\bin\" /e/v/i/h/y diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj index aa2a16a..b46e5c1 100644 --- a/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/WebCore/WebCore.vcproj/WebCore.vcproj @@ -20953,6 +20953,14 @@ >
</File>
<File
+ RelativePath="..\page\PrintContext.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\page\PrintContext.h"
+ >
+ </File>
+ <File
RelativePath="..\page\Screen.cpp"
>
</File>
@@ -24127,6 +24135,14 @@ Name="transforms"
>
<File
+ RelativePath="..\platform\graphics\transforms\AffineTransform.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\platform\graphics\transforms\AffineTransform.h"
+ >
+ </File>
+ <File
RelativePath="..\platform\graphics\transforms\IdentityTransformOperation.h"
>
</File>
@@ -42561,6 +42577,14 @@ >
</File>
<File
+ RelativePath="..\inspector\InjectedScript.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\inspector\InjectedScript.h"
+ >
+ </File>
+ <File
RelativePath="..\inspector\InjectedScriptHost.cpp"
>
</File>
diff --git a/WebCore/WebCore.vcproj/WebCoreGenerated.vcproj b/WebCore/WebCore.vcproj/WebCoreGenerated.vcproj index 744fdd0..4315c52 100644 --- a/WebCore/WebCore.vcproj/WebCoreGenerated.vcproj +++ b/WebCore/WebCore.vcproj/WebCoreGenerated.vcproj @@ -22,9 +22,9 @@ >
<Tool
Name="VCNMakeTool"
- BuildCommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" windows
bash migrate-idls.sh "$(WebKitOutputDir)/obj/WebKit/DOMInterfaces"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
- ReBuildCommandLine="echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebKit\DOMInterfaces"
%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" windows
bash migrate-idls.sh "$(WebKitOutputDir)/obj/WebKit/DOMInterfaces"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
- CleanCommandLine="del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebKit\DOMInterfaces"
if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
+ BuildCommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" windows
bash migrate-scripts.sh "$(WebKitOutputDir)/obj/WebCore/scripts"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
+ ReBuildCommandLine="echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebCore\scripts"
%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" windows
bash migrate-scripts.sh "$(WebKitOutputDir)/obj/WebCore/scripts"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
+ CleanCommandLine="del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebCore\scripts"
if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
Output=""
PreprocessorDefinitions=""
IncludeSearchPath=""
@@ -42,9 +42,9 @@ >
<Tool
Name="VCNMakeTool"
- BuildCommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" cairo
bash migrate-idls.sh "$(WebKitOutputDir)/obj/WebKit/DOMInterfaces"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
- ReBuildCommandLine="echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebKit\DOMInterfaces"
%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" cairo
bash migrate-idls.sh "$(WebKitOutputDir)/obj/WebKit/DOMInterfaces"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
- CleanCommandLine="del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebKit\DOMInterfaces"
if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
+ BuildCommandLine="%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
if exist "$(WebKitOutputDir)\buildfailed" grep XX$(ProjectName)XX "$(WebKitOutputDir)\buildfailed"
if errorlevel 1 exit 1
echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" cairo
bash migrate-scripts.sh "$(WebKitOutputDir)/obj/WebCore/scripts"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
+ ReBuildCommandLine="echo XX$(ProjectName)XX > "$(WebKitOutputDir)\buildfailed"

del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebCore\scripts"
%SystemDrive%\cygwin\bin\which.exe bash
if errorlevel 1 set PATH=%SystemDrive%\cygwin\bin;%PATH%
cmd /c
bash build-generated-files.sh "$(WebKitOutputDir)" "$(WebKitLibrariesDir)" cairo
bash migrate-scripts.sh "$(WebKitOutputDir)/obj/WebCore/scripts"

if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
+ CleanCommandLine="del /s /q "$(WebKitOutputDir)\obj\WebCore\DerivedSources"
del /s /q "$(WebKitOutputDir)\obj\WebCore\scripts"
if exist "$(WebKitOutputDir)\buildfailed" del "$(WebKitOutputDir)\buildfailed"
"
Output=""
PreprocessorDefinitions=""
IncludeSearchPath=""
diff --git a/WebCore/WebCore.vcproj/migrate-idls.sh b/WebCore/WebCore.vcproj/migrate-scripts.sh index 651f230..ec59154 100644 --- a/WebCore/WebCore.vcproj/migrate-idls.sh +++ b/WebCore/WebCore.vcproj/migrate-scripts.sh @@ -1,6 +1,6 @@ #!/usr/bin/bash -# Copyright (C) 2007 Apple Inc. All rights reserved. +# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -55,4 +55,4 @@ export XDSTROOT export WEBCORE=$XSRCROOT export WEBKIT_OUTPUT=$XDSTROOT -make -f "$WEBCORE/WebCore.vcproj/MigrateIDLandScripts" -j ${NUMCPUS} || exit 1 +make -f "$WEBCORE/WebCore.vcproj/MigrateScripts" -j ${NUMCPUS} || exit 1 diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj index 5edb6e7..e54897e 100644 --- a/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/WebCore/WebCore.xcodeproj/project.pbxproj @@ -1315,6 +1315,8 @@ 84A81F3E0FC7DFF000955300 /* SourceAlpha.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F3C0FC7DFF000955300 /* SourceAlpha.h */; }; 84A81F410FC7E02700955300 /* SourceGraphic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A81F3F0FC7E02700955300 /* SourceGraphic.cpp */; }; 84A81F420FC7E02700955300 /* SourceGraphic.h in Headers */ = {isa = PBXBuildFile; fileRef = 84A81F400FC7E02700955300 /* SourceGraphic.h */; }; + 84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84D0C4031115F1D40018AA34 /* AffineTransform.cpp */; }; + 84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D0C4051115F1EA0018AA34 /* AffineTransform.h */; }; 85004D940ACEEAEF00C438F6 /* DOMSVGDefsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85004D880ACEEAEF00C438F6 /* DOMSVGDefsElement.h */; }; 85004D950ACEEAEF00C438F6 /* DOMSVGDefsElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 85004D890ACEEAEF00C438F6 /* DOMSVGDefsElement.mm */; }; 85004D960ACEEAEF00C438F6 /* DOMSVGDescElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 85004D8A0ACEEAEF00C438F6 /* DOMSVGDescElement.h */; }; @@ -2455,6 +2457,9 @@ 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */; }; 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */; }; 97EF7DFE107E55B700D7C49C /* ScriptControllerBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */; }; + 9F72304F11184B4100AD0126 /* ScriptProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F72304C11184B4100AD0126 /* ScriptProfile.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 9F72305011184B4100AD0126 /* ScriptProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9F72304D11184B4100AD0126 /* ScriptProfiler.cpp */; }; + 9F72305111184B4100AD0126 /* ScriptProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F72304E11184B4100AD0126 /* ScriptProfiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */; }; A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */; }; A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -4100,6 +4105,8 @@ B5A684240FFABEAA00D24689 /* SQLiteFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5A684230FFABEAA00D24689 /* SQLiteFileSystem.cpp */; }; B5C1123B102B6C4600096578 /* SQLTransactionCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */; }; B5C1123C102B6C4600096578 /* SQLTransactionCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */; }; + B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */ = {isa = PBXBuildFile; fileRef = B776D43A1104525D00BEB0EC /* PrintContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; + B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B776D43C1104527500BEB0EC /* PrintContext.cpp */; }; BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00EFFE0E0A185500FD04E3 /* DOMFile.h */; }; BC00F0050E0A185500FD04E3 /* DOMFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */; }; BC00F0060E0A185500FD04E3 /* DOMFileInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00F0000E0A185500FD04E3 /* DOMFileInternal.h */; }; @@ -4616,6 +4623,10 @@ BCFE2F120C1B58380020235F /* JSRect.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFE2F100C1B58370020235F /* JSRect.h */; }; BCFF64910EAD15C200C1D6F7 /* LengthBox.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFF648F0EAD15C200C1D6F7 /* LengthBox.h */; settings = {ATTRIBUTES = (Private, ); }; }; BCFF64920EAD15C200C1D6F7 /* LengthSize.h in Headers */ = {isa = PBXBuildFile; fileRef = BCFF64900EAD15C200C1D6F7 /* LengthSize.h */; settings = {ATTRIBUTES = (Private, ); }; }; + C0C054CB1118C8E400CE2636 /* CodeGenerator.pm in Headers */ = {isa = PBXBuildFile; fileRef = 93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */; settings = {ATTRIBUTES = (Private, ); }; }; + C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */ = {isa = PBXBuildFile; fileRef = 93F8B3070A300FEA00F61AB8 /* generate-bindings.pl */; settings = {ATTRIBUTES = (Private, ); }; }; + C0C054CD1118C8E400CE2636 /* IDLParser.pm in Headers */ = {isa = PBXBuildFile; fileRef = 14813BF309EDF88E00F757E1 /* IDLParser.pm */; settings = {ATTRIBUTES = (Private, ); }; }; + C0C054CE1118C8E400CE2636 /* IDLStructure.pm in Headers */ = {isa = PBXBuildFile; fileRef = 93F8B3080A300FEA00F61AB8 /* IDLStructure.pm */; settings = {ATTRIBUTES = (Private, ); }; }; C0DFC8700DB6841A003EAE7C /* JSConsoleCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0DFC86F0DB6841A003EAE7C /* JSConsoleCustom.cpp */; }; C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; }; C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; }; @@ -4805,6 +4816,8 @@ ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED501DC50B249F2900AE18D9 /* EditorMac.mm */; }; EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = EDE3A4FF0C7A430600956A37 /* ColorMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; }; + F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; }; + F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; }; F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; }; F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */; }; F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5C041D70FFCA7CE00839D4A /* HTMLDataListElement.cpp */; }; @@ -6720,6 +6733,8 @@ 84B2B1F7056BEF3A00D2B771 /* WebCoreKeyGenerator.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreKeyGenerator.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 84B2B1F8056BEF3A00D2B771 /* WebCoreKeyGenerator.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebCoreKeyGenerator.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 84B2B24F056BF15F00D2B771 /* SSLKeyGeneratorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SSLKeyGeneratorMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; + 84D0C4031115F1D40018AA34 /* AffineTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AffineTransform.cpp; path = transforms/AffineTransform.cpp; sourceTree = "<group>"; }; + 84D0C4051115F1EA0018AA34 /* AffineTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AffineTransform.h; path = transforms/AffineTransform.h; sourceTree = "<group>"; }; 85004D880ACEEAEF00C438F6 /* DOMSVGDefsElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGDefsElement.h; sourceTree = "<group>"; }; 85004D890ACEEAEF00C438F6 /* DOMSVGDefsElement.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGDefsElement.mm; sourceTree = "<group>"; }; 85004D8A0ACEEAEF00C438F6 /* DOMSVGDescElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGDescElement.h; sourceTree = "<group>"; }; @@ -7783,6 +7798,9 @@ 97DD4D840FDF4D6D00ECF9A4 /* XSSAuditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSSAuditor.cpp; sourceTree = "<group>"; }; 97DD4D850FDF4D6E00ECF9A4 /* XSSAuditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSSAuditor.h; sourceTree = "<group>"; }; 97EF7DFD107E55B700D7C49C /* ScriptControllerBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptControllerBase.cpp; sourceTree = "<group>"; }; + 9F72304C11184B4100AD0126 /* ScriptProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptProfile.h; sourceTree = "<group>"; }; + 9F72304D11184B4100AD0126 /* ScriptProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptProfiler.cpp; sourceTree = "<group>"; }; + 9F72304E11184B4100AD0126 /* ScriptProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptProfiler.h; sourceTree = "<group>"; }; A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; }; A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; }; A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; }; @@ -9322,6 +9340,8 @@ B5A684230FFABEAA00D24689 /* SQLiteFileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteFileSystem.cpp; path = sql/SQLiteFileSystem.cpp; sourceTree = "<group>"; }; B5C11239102B6C4600096578 /* SQLTransactionCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLTransactionCoordinator.cpp; sourceTree = "<group>"; }; B5C1123A102B6C4600096578 /* SQLTransactionCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLTransactionCoordinator.h; sourceTree = "<group>"; }; + B776D43A1104525D00BEB0EC /* PrintContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintContext.h; sourceTree = "<group>"; }; + B776D43C1104527500BEB0EC /* PrintContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintContext.cpp; sourceTree = "<group>"; }; BC00EFFE0E0A185500FD04E3 /* DOMFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFile.h; sourceTree = "<group>"; }; BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMFile.mm; sourceTree = "<group>"; }; BC00F0000E0A185500FD04E3 /* DOMFileInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFileInternal.h; sourceTree = "<group>"; }; @@ -10079,6 +10099,8 @@ ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = EditorMac.mm; path = mac/EditorMac.mm; sourceTree = "<group>"; }; EDE3A4FF0C7A430600956A37 /* ColorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMac.h; sourceTree = "<group>"; }; EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; }; + F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; }; + F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; }; F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; }; F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OpenTypeSanitizer.h; path = opentype/OpenTypeSanitizer.h; sourceTree = "<group>"; }; F523D23B02DE4396018635CA /* HTMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDocument.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; @@ -10578,6 +10600,8 @@ 1C81B9590E97330800266E07 /* front-end */, 41F0618D0F5F069800A07EAC /* ConsoleMessage.cpp */, 41F0618C0F5F069800A07EAC /* ConsoleMessage.h */, + F3644AFD1119805900E0D537 /* InjectedScript.cpp */, + F3644AFE1119805900E0D537 /* InjectedScript.h */, 7A0E76F610BF08ED00A0276E /* InjectedScriptHost.cpp */, 7A0E76F710BF08ED00A0276E /* InjectedScriptHost.h */, 7A0E76F810BF08ED00A0276E /* InjectedScriptHost.idl */, @@ -10903,6 +10927,8 @@ 49E911B20EF86D27009D0CAF /* transforms */ = { isa = PBXGroup; children = ( + 84D0C4051115F1EA0018AA34 /* AffineTransform.h */, + 84D0C4031115F1D40018AA34 /* AffineTransform.cpp */, 49E911B50EF86D47009D0CAF /* IdentityTransformOperation.h */, 49D5DC270F423A73008F20FD /* Matrix3DTransformOperation.cpp */, 49D5DC280F423A73008F20FD /* Matrix3DTransformOperation.h */, @@ -11474,6 +11500,8 @@ FE80D7C00E9C1F25000D6F75 /* PositionError.idl */, FE80D7C10E9C1F25000D6F75 /* PositionErrorCallback.h */, FE80D7C30E9C1F25000D6F75 /* PositionOptions.h */, + B776D43C1104527500BEB0EC /* PrintContext.cpp */, + B776D43A1104525D00BEB0EC /* PrintContext.h */, BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */, BCEC01BB0C274DAC009F4EC9 /* Screen.h */, BCEC01BC0C274DAC009F4EC9 /* Screen.idl */, @@ -14611,6 +14639,9 @@ 934CC1160EDCAC7300A658F2 /* ScriptInstance.h */, 41F066E30F64BCF600A07EAC /* ScriptObject.cpp */, 41F066E20F64BCF600A07EAC /* ScriptObject.h */, + 9F72304C11184B4100AD0126 /* ScriptProfile.h */, + 9F72304D11184B4100AD0126 /* ScriptProfiler.cpp */, + 9F72304E11184B4100AD0126 /* ScriptProfiler.h */, 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */, CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */, 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */, @@ -16133,6 +16164,7 @@ 4B8AF4AA0B1CE02B00687690 /* ClipboardAccessPolicy.h in Headers */, 85031B400A44EFC700F992E0 /* ClipboardEvent.h in Headers */, 93F199E708245E59001E9ABC /* ClipboardMac.h in Headers */, + C0C054CB1118C8E400CE2636 /* CodeGenerator.pm in Headers */, BC5EB5DF0E81B9AB00B25965 /* CollapsedBorderValue.h in Headers */, 93C441F00F813A1A00C1A634 /* CollectionCache.h in Headers */, 93C442000F813AE100C1A634 /* CollectionType.h in Headers */, @@ -17079,6 +17111,7 @@ 51C81B8A0C4422F70019ECE3 /* FTPDirectoryParser.h in Headers */, 935C477509AC4D8E00A6AAB4 /* GapRects.h in Headers */, 1432E8470C51493800B1500F /* GCController.h in Headers */, + C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */, BC23F0DB0DAFF4A4009FDC91 /* GeneratedImage.h in Headers */, BCE04C8A0DAFF7A0007A0F41 /* Generator.h in Headers */, 2E4346440F546A8200B0F1BA /* GenericWorkerTask.h in Headers */, @@ -17212,6 +17245,8 @@ 51E1ECC10C91C90400DC255B /* IconRecord.h in Headers */, 1A71D57C0F33819000F9CE4E /* IdentifierRep.h in Headers */, 49E911C50EF86D47009D0CAF /* IdentityTransformOperation.h in Headers */, + C0C054CD1118C8E400CE2636 /* IDLParser.pm in Headers */, + C0C054CE1118C8E400CE2636 /* IDLStructure.pm in Headers */, B27535700B053814002CE64F /* Image.h in Headers */, B2A10B920B3818BD00099AA4 /* ImageBuffer.h in Headers */, A779791A0D6B9D0C003851B9 /* ImageData.h in Headers */, @@ -18470,8 +18505,16 @@ E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */, 93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */, E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */, + F3644B001119805900E0D537 /* InjectedScript.h in Headers */, 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */, +<<<<<<< HEAD 599ABBC91119762B0083897F /* GeolocationPositionCache.h in Headers */, +======= + 84D0C4061115F1EA0018AA34 /* AffineTransform.h in Headers */, + B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */, + 9F72304F11184B4100AD0126 /* ScriptProfile.h in Headers */, + 9F72305111184B4100AD0126 /* ScriptProfiler.h in Headers */, +>>>>>>> webkit.org at r54340 ); runOnlyForDeploymentPostprocessing = 0; }; @@ -20643,10 +20686,17 @@ 93F19B0308245E59001E9ABC /* XSLStyleSheetLibxslt.cpp in Sources */, E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */, 93F19B0408245E59001E9ABC /* XSLTProcessor.cpp in Sources */, + F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */, 93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */, E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */, 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */, +<<<<<<< HEAD 599ABBC51119761C0083897F /* GeolocationPositionCache.cpp in Sources */, +======= + 84D0C4041115F1D40018AA34 /* AffineTransform.cpp in Sources */, + B776D43D1104527500BEB0EC /* PrintContext.cpp in Sources */, + 9F72305011184B4100AD0126 /* ScriptProfiler.cpp in Sources */, +>>>>>>> webkit.org at r54340 ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp index 87070cd..a4d1638 100644 --- a/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp +++ b/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp @@ -876,7 +876,7 @@ gchar* textForObject(AccessibilityRenderObject* accObject) g_string_append(str, "\n"); range = accObject->doAXRangeForLine(++lineNumber); } - } else { + } else if (accObject->renderer()) { // For RenderBlocks, piece together the text from the RenderText objects they contain. for (RenderObject* obj = accObject->renderer()->firstChild(); obj; obj = obj->nextSibling()) { if (obj->isBR()) { diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp index e539042..8a918a3 100644 --- a/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -142,6 +142,7 @@ #include "ScriptControllerWin.cpp" #include "ScriptEventListener.cpp" #include "ScriptFunctionCall.cpp" +#include "ScriptProfiler.cpp" #include "ScriptState.cpp" #include "SerializedScriptValue.cpp" #include "WorkerScriptController.cpp" diff --git a/WebCore/bindings/js/JSConsoleCustom.cpp b/WebCore/bindings/js/JSConsoleCustom.cpp index 8366b39..b631cdd 100644 --- a/WebCore/bindings/js/JSConsoleCustom.cpp +++ b/WebCore/bindings/js/JSConsoleCustom.cpp @@ -24,13 +24,14 @@ */ #include "config.h" + #include "JSConsole.h" + +#include "Console.h" #include "JavaScriptProfile.h" #include "ScriptCallStack.h" #include <runtime/JSArray.h> -#include "Console.h" - using namespace JSC; namespace WebCore { @@ -51,22 +52,6 @@ JSValue JSConsole::profiles(ExecState* exec) const return constructArray(exec, list); } -JSValue JSConsole::profile(ExecState* exec, const ArgList& args) -{ - ScriptCallStack callStack(exec, args, 1); - const UString title = valueToStringWithUndefinedOrNullCheck(exec, args.at(0)); - impl()->profile(title, &callStack); - return jsUndefined(); -} - -JSValue JSConsole::profileEnd(ExecState* exec, const ArgList& args) -{ - ScriptCallStack callStack(exec, args, 1); - const UString title = valueToStringWithUndefinedOrNullCheck(exec, args.at(0)); - impl()->profileEnd(title, &callStack); - return jsUndefined(); -} - #endif } // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp index 04b6dc9..abba405 100644 --- a/WebCore/bindings/js/JSDOMBinding.cpp +++ b/WebCore/bindings/js/JSDOMBinding.cpp @@ -776,7 +776,7 @@ Frame* toDynamicFrame(ExecState* exec) bool processingUserGesture(ExecState* exec) { Frame* frame = toDynamicFrame(exec); - return frame && frame->script()->processingUserGesture(); + return frame && frame->script()->processingUserGesture(currentWorld(exec)); } KURL completeURL(ExecState* exec, const String& relativeURL) diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 1da5af2..f7be2c5 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -716,6 +716,14 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF return newFrame; } +static bool domWindowAllowPopUp(Frame* activeFrame, ExecState* exec) +{ + ASSERT(activeFrame); + if (activeFrame->script()->processingUserGesture(currentWorld(exec))) + return true; + return DOMWindow::allowPopUp(activeFrame); +} + JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args) { String urlString = valueToStringWithUndefinedOrNullCheck(exec, args.at(0)); @@ -736,7 +744,7 @@ JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args) // Because FrameTree::find() returns true for empty strings, we must check for empty framenames. // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker. - if (!DOMWindow::allowPopUp(dynamicFrame) && (frameName.isEmpty() || !frame->tree()->find(frameName))) + if (!domWindowAllowPopUp(dynamicFrame, exec) && (frameName.isEmpty() || !frame->tree()->find(frameName))) return jsUndefined(); // Get the target frame for the special cases of _top and _parent. In those @@ -806,7 +814,7 @@ JSValue JSDOMWindow::showModalDialog(ExecState* exec, const ArgList& args) if (!dynamicFrame) return jsUndefined(); - if (!DOMWindow::canShowModalDialogNow(frame) || !DOMWindow::allowPopUp(dynamicFrame)) + if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame, exec)) return jsUndefined(); HashMap<String, String> features; diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp index 9366399..eda153e 100644 --- a/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/WebCore/bindings/js/JSDocumentCustom.cpp @@ -87,7 +87,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value) if (activeFrame) str = activeFrame->document()->completeURL(str).string(); - bool userGesture = activeFrame->script()->processingUserGesture(); + bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec)); frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture); } diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp index d38d8ee..96c5c43 100644 --- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp +++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp @@ -43,6 +43,7 @@ #include "ExceptionCode.h" #include "Frame.h" #include "FrameLoader.h" +#include "InjectedScript.h" #include "InjectedScriptHost.h" #include "InspectorController.h" #include "InspectorResource.h" @@ -194,20 +195,21 @@ JSValue JSInjectedScriptHost::selectDOMStorage(ExecState*, const ArgList& args) } #endif -ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) +InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState) { JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject()); JSObject* injectedScript = globalObject->injectedScript(); if (injectedScript) - return ScriptObject(scriptState, injectedScript); + return InjectedScript(ScriptObject(scriptState, injectedScript)); ASSERT(!m_injectedScriptSource.isEmpty()); ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, scriptState, m_nextInjectedScriptId); globalObject->setInjectedScript(injectedScriptObject.jsObject()); - m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject); + InjectedScript result(injectedScriptObject); + m_idToInjectedScript.set(m_nextInjectedScriptId, result); m_nextInjectedScriptId++; - return injectedScriptObject; + return result; } } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index 083e931..bd36689 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -222,39 +222,19 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world) return windowShell; } -bool ScriptController::processingUserGesture() const +bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const { - return m_allowPopupsFromPlugin || processingUserGestureEvent() || isJavaScriptAnchorNavigation(); + return m_allowPopupsFromPlugin || processingUserGestureEvent(world) || isJavaScriptAnchorNavigation(); } -bool ScriptController::processingUserGestureEvent() const +bool ScriptController::processingUserGestureEvent(DOMWrapperWorld* world) const { - JSDOMWindowShell* shell = existingWindowShell(mainThreadNormalWorld()); + JSDOMWindowShell* shell = existingWindowShell(world); if (!shell) return false; - if (Event* event = shell->window()->currentEvent()) { - if (event->createdByDOM()) - return false; - - const AtomicString& type = event->type(); - if ( // mouse events - type == eventNames().clickEvent || type == eventNames().mousedownEvent - || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent - // keyboard events - || type == eventNames().keydownEvent || type == eventNames().keypressEvent - || type == eventNames().keyupEvent -#if ENABLE(TOUCH_EVENTS) - // touch events - || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent - || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent -#endif - // other accepted events - || type == eventNames().selectEvent || type == eventNames().changeEvent - || type == eventNames().focusEvent || type == eventNames().blurEvent - || type == eventNames().submitEvent) - return true; - } + if (Event* event = shell->window()->currentEvent()) + return event->fromUserGesture(); return false; } @@ -280,7 +260,20 @@ bool ScriptController::anyPageIsProcessingUserGesture() const HashSet<Page*>::const_iterator end = pages.end(); for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) { - if (frame->script()->processingUserGesture()) + ScriptController* script = frame->script(); + + if (script->m_allowPopupsFromPlugin) + return true; + + const ShellMap::const_iterator iterEnd = m_windowShells.end(); + for (ShellMap::const_iterator iter = m_windowShells.begin(); iter != iterEnd; ++iter) { + JSDOMWindowShell* shell = iter->second.get(); + Event* event = shell->window()->currentEvent(); + if (event && event->fromUserGesture()) + return true; + } + + if (isJavaScriptAnchorNavigation()) return true; } } diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index f3e5adf..1cbb56d 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -107,7 +107,7 @@ public: int eventHandlerLineNumber() { return m_handlerLineNumber; } void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; } - bool processingUserGesture() const; + bool processingUserGesture(DOMWrapperWorld*) const; bool anyPageIsProcessingUserGesture() const; bool canExecuteScripts(); @@ -164,7 +164,7 @@ private: void disconnectPlatformScriptObjects(); - bool processingUserGestureEvent() const; + bool processingUserGestureEvent(DOMWrapperWorld*) const; bool isJavaScriptAnchorNavigation() const; ShellMap m_windowShells; diff --git a/WebCore/bindings/js/ScriptProfile.h b/WebCore/bindings/js/ScriptProfile.h new file mode 100644 index 0000000..32095e3 --- /dev/null +++ b/WebCore/bindings/js/ScriptProfile.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScriptProfile_h +#define ScriptProfile_h + +#if ENABLE(JAVASCRIPT_DEBUGGER) +#include <profiler/Profile.h> + +namespace WebCore { + +typedef JSC::Profile ScriptProfile; + +} // namespace WebCore + +#endif // ENABLE(JAVASCRIPT_DEBUGGER) + +#endif // ScriptProfile_h diff --git a/WebCore/bindings/js/ScriptProfiler.cpp b/WebCore/bindings/js/ScriptProfiler.cpp new file mode 100644 index 0000000..789e3d3 --- /dev/null +++ b/WebCore/bindings/js/ScriptProfiler.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(JAVASCRIPT_DEBUGGER) + +#include "ScriptProfiler.h" + +#include <profiler/Profiler.h> + +namespace WebCore { + +void ScriptProfiler::start(ScriptState* state, const String& title) +{ + JSC::Profiler::profiler()->startProfiling(state, title); +} + +PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title) +{ + return JSC::Profiler::profiler()->stopProfiling(state, title); +} + +} // namespace WebCore + +#endif // ENABLE(JAVASCRIPT_DEBUGGER) diff --git a/WebCore/bindings/js/ScriptProfiler.h b/WebCore/bindings/js/ScriptProfiler.h new file mode 100644 index 0000000..a86bcfb --- /dev/null +++ b/WebCore/bindings/js/ScriptProfiler.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScriptProfiler_h +#define ScriptProfiler_h + +#if ENABLE(JAVASCRIPT_DEBUGGER) +#include "ScriptProfile.h" +#include "ScriptState.h" + +#include <wtf/Noncopyable.h> + +namespace WebCore { + +class ScriptProfiler : public Noncopyable { +public: + static void start(ScriptState* state, const String& title); + static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); +}; + +} // namespace WebCore + +#endif // ENABLE(JAVASCRIPT_DEBUGGER) + +#endif // ScriptProfiler_h diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 7a55a3d..c774a57 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -1676,7 +1676,12 @@ sub GenerateImplementation } else { $functionString .= $name; } + $paramIndex++; + } + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionString .= ", " if $paramIndex; + $functionString .= "processingUserGesture(exec)"; $paramIndex++; } diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index 305fdfd..cb4d04a 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -156,14 +156,15 @@ sub AddIncludesForType # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. - if ($codeGenerator->IsPrimitiveType($type) or AvoidInclusionOfType($type)) { - } elsif ($type =~ /SVGPathSeg/) { - $joinedName = $type; - $joinedName =~ s/Abs|Rel//; - $implIncludes{"${joinedName}.h"} = 1; - } else { + if (!$codeGenerator->IsPrimitiveType($type) and !AvoidInclusionOfType($type) and $type ne "Date") { # default, include the same named file - $implIncludes{GetImplementationFileName(${type})} = 1; + $implIncludes{GetV8HeaderName(${type})} = 1; + + if ($type =~ /SVGPathSeg/) { + $joinedName = $type; + $joinedName =~ s/Abs|Rel//; + $implIncludes{"${joinedName}.h"} = 1; + } } # additional includes (things needed to compile the bindings but not the header) @@ -210,17 +211,6 @@ sub AddClassForwardIfNeeded push(@headerContent, "class $implClassName;\n\n") unless $codeGenerator->IsSVGAnimatedType($implClassName); } -sub GetImplementationFileName -{ - my $iface = shift; - return "Event.h" if $iface eq "DOMTimeStamp"; - return "NamedAttrMap.h" if $iface eq "NamedNodeMap"; - return "NameNodeList.h" if $iface eq "NodeList"; - return "XMLHttpRequest.h" if $iface eq "XMLHttpRequest"; - - return "${iface}.h"; -} - # If the node has a [Conditional=XXX] attribute, returns an "ENABLE(XXX)" string for use in an #if. sub GenerateConditionalString { @@ -258,7 +248,6 @@ sub GenerateHeader # Get correct pass/store types respecting PODType flag my $podType = $dataNode->extendedAttributes->{"PODType"}; - my $passType = $podType ? "JSSVGPODTypeWrapper<$podType>*" : "$implClassName*"; push(@headerContent, "#include \"$podType.h\"\n") if $podType and ($podType ne "double" and $podType ne "float" and $podType ne "RGBA32"); @@ -268,15 +257,23 @@ sub GenerateHeader push(@headerContent, "#include \"V8Index.h\"\n"); push(@headerContent, GetHeaderClassInclude($implClassName)); push(@headerContent, "\nnamespace WebCore {\n"); + if ($podType) { + push(@headerContent, "\ntemplate<typename PODType> class V8SVGPODTypeWrapper;\n"); + } push(@headerContent, "\nclass $className {\n"); - - my $toNativeReturnType = GetReturnTypeForToNative($interfaceName); + + my $nativeType = GetNativeTypeForConversions($interfaceName); + if ($podType) { + $nativeType = "V8SVGPODTypeWrapper<${nativeType} >"; + } + my $forceNewObjectParameter = IsDOMNodeType($interfaceName) ? ", bool forceNewObject = false" : ""; push(@headerContent, <<END); public: static bool HasInstance(v8::Handle<v8::Value> value); static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); - static ${toNativeReturnType}* toNative(v8::Handle<v8::Object>); + static ${nativeType}* toNative(v8::Handle<v8::Object>); + static v8::Handle<v8::Object> wrap(${nativeType}*${forceNewObjectParameter}); END if ($implClassName eq "DOMWindow") { @@ -346,7 +343,13 @@ END friend class V8ClassIndex; }; + v8::Handle<v8::Value> toV8(${nativeType}*${forceNewObjectParameter}); +END + if (IsRefPtrType($implClassName)) { + push(@headerContent, <<END); + v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} >${forceNewObjectParameter}); END + } push(@headerContent, "}\n\n"); push(@headerContent, "#endif // $className" . "_H\n"); @@ -665,7 +668,7 @@ sub GenerateNormalAttrGetter $attrIsPodType = 0; } - my $getterStringUsesImp = $implClassName ne "double"; + my $getterStringUsesImp = $implClassName ne "float"; # Getter push(@implContentDecls, <<END); @@ -821,13 +824,16 @@ END push(@implContentDecls, GenerateSVGContextAssignment($implClassName, "wrapper.get()", " ")); } else { push(@implContentDecls, GenerateSVGContextRetrieval($implClassName, " ")); - $result = "V8Proxy::withSVGContext($result, context)"; + # The templating associated with passing withSVGContext()'s return value directly into toV8 can get compilers confused, + # so just manually set the return value to a PassRefPtr of the expected type. + push(@implContentDecls, " PassRefPtr<$attrType> resultAsPassRefPtr = V8Proxy::withSVGContext($result, context);\n"); + $result = "resultAsPassRefPtr"; } } if ($attrIsPodType) { - my $classIndex = uc($attrType); - push(@implContentDecls, " return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"); + $implIncludes{"V8${attrType}.h"} = 1; + push(@implContentDecls, " return toV8(wrapper.release().get());\n"); } else { push(@implContentDecls, " " . ReturnNativeToJSValue($attribute->signature, $result, " ").";\n"); } @@ -943,7 +949,7 @@ END push(@implContentDecls, " ExceptionCode ec = 0;\n"); } - if ($implClassName eq "double") { + if ($implClassName eq "float") { push(@implContentDecls, " *imp = $result;\n"); } else { my $implSetterFunctionName = $codeGenerator->WK_ucfirst($attrName); @@ -956,7 +962,6 @@ END push(@implContentDecls, " imp->setAttribute(${namespace}::${contentAttributeName}Attr, $result"); } elsif ($attribute->signature->type eq "EventListener") { $implIncludes{"V8AbstractEventListener.h"} = 1; - $implIncludes{"V8CustomBinding.h"} = 1; push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, V8${interfaceName}::cacheIndex);\n"); push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(imp, value, true, ListenerFindOrCreate)"); } else { @@ -1472,7 +1477,9 @@ sub GenerateImplementation "#include \"config.h\"\n" . "#include \"V8Proxy.h\"\n" . "#include \"V8Binding.h\"\n" . - "#include \"V8BindingState.h\"\n\n" . + "#include \"V8BindingState.h\"\n" . + "#include \"V8DOMWrapper.h\"\n" . + "#include \"V8IsolatedContext.h\"\n\n" . "#undef LOG\n\n"); push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; @@ -1498,10 +1505,8 @@ sub GenerateImplementation # Generate special code for the constructor attributes. if ($attrType =~ /Constructor$/) { - if ($attribute->signature->extendedAttributes->{"CustomGetter"} || - $attribute->signature->extendedAttributes->{"V8CustomGetter"}) { - $implIncludes{"V8CustomBinding.h"} = 1; - } else { + if (!($attribute->signature->extendedAttributes->{"CustomGetter"} || + $attribute->signature->extendedAttributes->{"V8CustomGetter"})) { $hasConstructors = 1; } next; @@ -1516,25 +1521,22 @@ sub GenerateImplementation # implementation. if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"V8Custom"}) { - $implIncludes{"V8CustomBinding.h"} = 1; next; } # Generate the accessor. - if ($attribute->signature->extendedAttributes->{"CustomGetter"} || - $attribute->signature->extendedAttributes->{"V8CustomGetter"}) { - $implIncludes{"V8CustomBinding.h"} = 1; - } else { + if (!($attribute->signature->extendedAttributes->{"CustomGetter"} || + $attribute->signature->extendedAttributes->{"V8CustomGetter"})) { GenerateNormalAttrGetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName); } - if ($attribute->signature->extendedAttributes->{"CustomSetter"} || - $attribute->signature->extendedAttributes->{"V8CustomSetter"}) { - $implIncludes{"V8CustomBinding.h"} = 1; - } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) { - $dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"} || die "Replaceable attribute can only be used in interface that defines ExtendsDOMGlobalObject attribute!"; - # GenerateReplaceableAttrSetter($implClassName); - } elsif ($attribute->type !~ /^readonly/ && !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) { - GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName); + if (!($attribute->signature->extendedAttributes->{"CustomSetter"} || + $attribute->signature->extendedAttributes->{"V8CustomSetter"})) { + if ($attribute->signature->extendedAttributes->{"Replaceable"}) { + $dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"} || die "Replaceable attribute can only be used in interface that defines ExtendsDOMGlobalObject attribute!"; + # GenerateReplaceableAttrSetter($implClassName); + } elsif ($attribute->type !~ /^readonly/ && !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) { + GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName); + } } } @@ -1548,9 +1550,7 @@ sub GenerateImplementation foreach my $function (@{$dataNode->functions}) { # hack for addEventListener/RemoveEventListener # FIXME: avoid naming conflict - if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"}) { - $implIncludes{"V8CustomBinding.h"} = 1; - } else { + if (!($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"V8Custom"})) { GenerateFunctionCallback($function, $dataNode, $classIndex, $implClassName); } @@ -1888,7 +1888,10 @@ END END } - $toNativeReturnType = GetReturnTypeForToNative($interfaceName); + my $nativeType = GetNativeTypeForConversions($interfaceName); + if ($dataNode->extendedAttributes->{"PODType"}) { + $nativeType = "V8SVGPODTypeWrapper<${nativeType}>"; + } push(@implContent, <<END); // Custom toString template @@ -1906,8 +1909,8 @@ v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() { return ${className}_cache_; } -${toNativeReturnType}* ${className}::toNative(v8::Handle<v8::Object> object) { - return reinterpret_cast<${toNativeReturnType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); +${nativeType}* ${className}::toNative(v8::Handle<v8::Object> object) { + return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); } bool ${className}::HasInstance(v8::Handle<v8::Value> value) { @@ -1928,6 +1931,8 @@ v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate() { } END } + + GenerateToV8Converters($dataNode, $interfaceName, $className, $nativeType); push(@implContent, <<END); } // namespace WebCore @@ -1936,7 +1941,194 @@ END push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } -sub GetReturnTypeForToNative +sub GenerateToV8Converters +{ + my $dataNode = shift; + my $interfaceName = shift; + my $className = shift; + my $nativeType = shift; + + my $wrapperType = "V8ClassIndex::" . uc($interfaceName); + my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName); + my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : ""; + my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : ""; + + push(@implContent, <<END); + +v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) { + v8::Handle<v8::Object> wrapper; +END + if (!NeedsWorkerContextExecutionProxyToV8($interfaceName)) { + push(@implContent, <<END); + V8Proxy* proxy = 0; +END + } + + if (IsNodeSubType($dataNode)) { + push(@implContent, <<END); + if (impl->document()) { + proxy = V8Proxy::retrieve(impl->document()->frame()); + if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) + proxy->windowShell()->initContextIfNeeded(); + } + +END + } + + if ($domMapFunction) { + push(@implContent, " if (!forceNewObject) {\n") if IsDOMNodeType($interfaceName); + if (IsNodeSubType($dataNode)) { + push(@implContent, " wrapper = V8DOMWrapper::getWrapper(impl);\n"); + } else { + push(@implContent, " wrapper = ${domMapFunction}.get(impl);\n"); + } + push(@implContent, <<END); + if (!wrapper.IsEmpty()) + return wrapper; +END + push(@implContent, " }\n") if IsDOMNodeType($interfaceName); + } + if (IsNodeSubType($dataNode)) { + push(@implContent, <<END); + + v8::Handle<v8::Context> context; + if (proxy) + context = proxy->context(); + + // Enter the node's context and create the wrapper in that context. + if (!context.IsEmpty()) + context->Enter(); +END + } + + if (NeedsWorkerContextExecutionProxyToV8($interfaceName)) { + $implIncludes{"WorkerContextExecutionProxy.h"} = 1; + push(@implContent, <<END); + wrapper = WorkerContextExecutionProxy::toV8(${wrapperType}, impl); +END + } else { + push(@implContent, <<END); + wrapper = V8DOMWrapper::instantiateV8Object(proxy, ${wrapperType}, impl); +END + } + + if (IsNodeSubType($dataNode)) { + push(@implContent, <<END); + // Exit the node's context if it was entered. + if (!context.IsEmpty()) + context->Exit(); +END + } + + push(@implContent, <<END); + if (wrapper.IsEmpty()) + return wrapper; +END + push(@implContent, "\n impl->ref();\n") if IsRefPtrType($interfaceName); + + if ($domMapFunction) { + push(@implContent, <<END); + ${domMapFunction}.set(impl, v8::Persistent<v8::Object>::New(wrapper)); +END + } + + push(@implContent, <<END); + return wrapper; +} +END + + if (IsRefPtrType($interfaceName)) { + push(@implContent, <<END); + +v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} > impl${forceNewObjectInput}) { + return toV8(impl.get()${forceNewObjectCall}); +} +END + } + + if (!HasCustomToV8Implementation($dataNode, $interfaceName)) { + push(@implContent, <<END); + +v8::Handle<v8::Value> toV8(${nativeType}* impl${forceNewObjectInput}) { + if (!impl) + return v8::Null(); + return ${className}::wrap(impl${forceNewObjectCall}); +} +END + } +} + +sub NeedsWorkerContextExecutionProxyToV8 { + # These objects can be constructed under WorkerContextExecutionProxy. They need special + # handling, since if we call V8Proxy::retrieve(), we will crash. + # FIXME: websocket? + $interfaceName = shift; + return 1 if $interfaceName eq "DOMCoreException"; + return 1 if $interfaceName eq "EventException"; + return 1 if $interfaceName eq "RangeException"; + return 1 if $interfaceName eq "XMLHttpRequestException"; + return 1 if $interfaceName eq "MessagePort"; + return 0; +} + +sub HasCustomToV8Implementation { + # FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)? + $dataNode = shift; + $interfaceName = shift; + + # We generate a custom converter (but JSC doesn't) for the following: + return 1 if $interfaceName eq "BarInfo"; + return 1 if $interfaceName eq "CSSStyleSheet"; + return 1 if $interfaceName eq "CanvasPixelArray"; + return 1 if $interfaceName eq "DOMSelection"; + return 1 if $interfaceName eq "DOMWindow"; + return 1 if $interfaceName eq "Element"; + return 1 if $interfaceName eq "Location"; + return 1 if $interfaceName eq "HTMLDocument"; + return 1 if $interfaceName eq "HTMLElement"; + return 1 if $interfaceName eq "History"; + return 1 if $interfaceName eq "NamedNodeMap"; + return 1 if $interfaceName eq "Navigator"; + return 1 if $interfaceName eq "SVGDocument"; + return 1 if $interfaceName eq "SVGElement"; + return 1 if $interfaceName eq "Screen"; + + # We don't generate a custom converter (but JSC does) for the following: + return 0 if $interfaceName eq "AbstractWorker"; + return 0 if $interfaceName eq "CanvasRenderingContext"; + return 0 if $interfaceName eq "ImageData"; + return 0 if $interfaceName eq "SVGElementInstance"; + + # For everything else, do what JSC does. + return $dataNode->extendedAttributes->{"CustomToJS"}; +} + +sub GetDomMapFunction +{ + my $dataNode = shift; + my $type = shift; + return "getDOMSVGElementInstanceMap()" if $type eq "SVGElementInstance"; + return "getDOMNodeMap()" if IsNodeSubType($dataNode); + # Only use getDOMSVGObjectWithContextMap() for non-node svg objects + return "getDOMSVGObjectWithContextMap()" if $type =~ /SVG/; + return "" if $type eq "DOMImplementation"; + return "getActiveDOMObjectMap()" if IsActiveDomType($type); + return "getDOMObjectMap()"; +} + +sub IsActiveDomType +{ + # FIXME: Consider making this an .idl attribute. + my $type = shift; + return 1 if $type eq "MessagePort"; + return 1 if $type eq "XMLHttpRequest"; + return 1 if $type eq "WebSocket"; + return 1 if $type eq "Worker"; + return 1 if $type eq "SharedWorker"; + return 0; +} + +sub GetNativeTypeForConversions { my $type = shift; return "FloatRect" if $type eq "SVGRect"; @@ -1991,7 +2183,6 @@ sub GenerateFunctionCallString() my $first = 1; my $index = 0; - my $nodeToReturn = 0; foreach my $parameter (@{$function->parameters}) { if ($index eq $numberOfParameters) { @@ -2013,10 +2204,6 @@ sub GenerateFunctionCallString() } else { $functionString .= $paramName; } - - if ($parameter->extendedAttributes->{"Return"}) { - $nodeToReturn = $parameter->name; - } $index++; } @@ -2026,6 +2213,14 @@ sub GenerateFunctionCallString() if ($first) { $first = 0; } } + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionString .= ", " if not $first; + # FIXME: We need to pass DOMWrapperWorld as a parameter. + # See http://trac.webkit.org/changeset/54182 + $functionString .= "processingUserGesture()"; + if ($first) { $first = 0; } + } + if (@{$function->raisesExceptions}) { $functionString .= ", " if not $first; $functionString .= "ec"; @@ -2035,19 +2230,7 @@ sub GenerateFunctionCallString() my $return = "result"; my $returnIsRef = IsRefPtrType($returnType); - if ($nodeToReturn) { - # Special case for insertBefore, replaceChild, removeChild and - # appendChild functions from Node. - $result .= $indent . "bool success = $functionString;\n"; - if (@{$function->raisesExceptions}) { - $result .= $indent . "if (UNLIKELY(ec)) goto fail;\n"; - } - $result .= $indent . "if (success)\n"; - $result .= $indent . " " . - "return V8DOMWrapper::convertNodeToV8Object($nodeToReturn);\n"; - $result .= $indent . "return v8::Null();\n"; - return $result; - } elsif ($returnType eq "void") { + if ($returnType eq "void") { $result .= $indent . "$functionString;\n"; } elsif ($copyFirst) { $result .= @@ -2106,8 +2289,8 @@ sub GenerateFunctionCallString() } if ($returnsPodType) { - my $classIndex = uc($returnType); - $result .= $indent . "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, wrapper.release());\n"; + $implIncludes{"V8${returnType}.h"} = 1; + $result .= $indent . "return toV8(wrapper.release());\n"; } else { $return .= ".release()" if ($returnIsRef); $result .= $indent . ReturnNativeToJSValue($function->signature, $return, $indent) . ";\n"; @@ -2167,6 +2350,7 @@ sub IsRefPtrType return 0 if $type eq "unsigned"; return 0 if $type eq "unsigned long"; return 0 if $type eq "unsigned short"; + return 0 if $type eq "SVGAnimatedPoints"; return 1; } @@ -2207,7 +2391,7 @@ sub GetNativeType return "SVGTransform" if $type eq "SVGTransform"; return "SVGLength" if $type eq "SVGLength"; return "SVGAngle" if $type eq "SVGAngle"; - return "double" if $type eq "SVGNumber"; + return "float" if $type eq "SVGNumber"; return "SVGPreserveAspectRatio" if $type eq "SVGPreserveAspectRatio"; return "SVGPaint::SVGPaintType" if $type eq "SVGPaintType"; return "DOMTimeStamp" if $type eq "DOMTimeStamp"; @@ -2423,7 +2607,11 @@ sub JSValueToNative sub GetV8HeaderName { my $type = shift; - return "V8" . GetImplementationFileName($type); + return "V8Event.h" if $type eq "DOMTimeStamp"; + return "EventListener.h" if $type eq "EventListener"; + return "EventTarget.h" if $type eq "EventTarget"; + return "SerializedScriptValue.h" if $type eq "SerializedScriptValue"; + return "V8${type}.h"; } @@ -2548,7 +2736,6 @@ sub ReturnNativeToJSValue my $value = shift; my $indent = shift; my $type = GetTypeFromSignature($signature); - my $className= "V8$type"; return "return v8::Date::New(static_cast<double>($value))" if $type eq "DOMTimeStamp"; return "return v8Boolean($value)" if $type eq "boolean"; @@ -2575,29 +2762,20 @@ sub ReturnNativeToJSValue return "return v8String($value)"; } - # V8 specific. - my $implClassName = $type; AddIncludesForType($type); # special case for non-DOM node interfaces if (IsDOMNodeType($type)) { - if ($signature->extendedAttributes->{"ReturnsNew"}) { - return "return V8DOMWrapper::convertNewNodeToV8Object($value)"; - } else { - return "return V8DOMWrapper::convertNodeToV8Object($value)"; - } + return "return toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")"); } - if ($type eq "EventTarget" or $type eq "SVGElementInstance") { + if ($type eq "EventTarget") { return "return V8DOMWrapper::convertEventTargetToV8Object($value)"; } - if ($type eq "Event") { - return "return V8DOMWrapper::convertEventToV8Object($value)"; - } - if ($type eq "EventListener") { - return "return V8DOMWrapper::convertEventListenerToV8Object(imp->scriptExecutionContext(), $value)"; + $implIncludes{"V8AbstractEventListener.h"} = 1; + return "return ${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())"; } if ($type eq "SerializedScriptValue") { @@ -2617,18 +2795,15 @@ sub ReturnNativeToJSValue return "return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::$classIndex, $value)"; } - else { - $implIncludes{"wtf/RefCounted.h"} = 1; - $implIncludes{"wtf/RefPtr.h"} = 1; - $implIncludes{"wtf/GetPtr.h"} = 1; - my $classIndex = uc($type); + $implIncludes{"wtf/RefCounted.h"} = 1; + $implIncludes{"wtf/RefPtr.h"} = 1; + $implIncludes{"wtf/GetPtr.h"} = 1; - if (IsPodType($type)) { - $value = GenerateSVGStaticPodTypeWrapper($type, $value); - } - - return "return V8DOMWrapper::convertToV8Object(V8ClassIndex::$classIndex, $value)"; + if (IsPodType($type)) { + $value = GenerateSVGStaticPodTypeWrapper($type, $value) . ".get()"; } + + return "return toV8($value)"; } sub GenerateSVGStaticPodTypeWrapper { diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index 8db55a1..e2b886d 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -50,7 +50,9 @@ #include "Settings.h" #include "V8Binding.h" #include "V8BindingState.h" +#include "V8DOMWindow.h" #include "V8Event.h" +#include "V8HTMLEmbedElement.h" #include "V8IsolatedContext.h" #include "V8NPObject.h" #include "V8Proxy.h" @@ -148,7 +150,7 @@ void ScriptController::updatePlatformScriptObjects() notImplemented(); } -bool ScriptController::processingUserGesture() const +bool ScriptController::processingUserGesture(DOMWrapperWorld*) const { Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext(); // No script is running, so it must be run by users. @@ -169,7 +171,7 @@ bool ScriptController::processingUserGesture() const v8::Handle<v8::Object> global = v8Context->Global(); v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event")); - Event* event = V8DOMWrapper::isDOMEventWrapper(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0; + Event* event = (!jsEvent.IsEmpty() && jsEvent->IsObject()) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0; // Based on code from kjs_bindings.cpp. // Note: This is more liberal than Firefox's implementation. @@ -353,6 +355,15 @@ void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds) worlds.append(mainThreadNormalWorld()); } +void ScriptController::evaluateInWorld(const ScriptSourceCode& source, + DOMWrapperWorld* world) +{ + Vector<ScriptSourceCode> sources; + sources.append(source); + // FIXME: Get an ID from the world param. + evaluateInIsolatedWorld(0, sources); +} + static NPObject* createNoScriptObject() { notImplemented(); @@ -368,7 +379,7 @@ static NPObject* createScriptObject(Frame* frame) v8::Context::Scope scope(v8Context); DOMWindow* window = frame->domWindow(); - v8::Handle<v8::Value> global = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, window); + v8::Handle<v8::Value> global = toV8(window); ASSERT(global->IsObject()); return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), window); } @@ -405,7 +416,7 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement v8::Context::Scope scope(v8Context); DOMWindow* window = m_frame->domWindow(); - v8::Handle<v8::Value> v8plugin = V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLEMBEDELEMENT, plugin); + v8::Handle<v8::Value> v8plugin = toV8(static_cast<HTMLEmbedElement*>(plugin)); if (!v8plugin->IsObject()) return createNoScriptObject(); diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h index b45bdef..b3995b2 100644 --- a/WebCore/bindings/v8/ScriptController.h +++ b/WebCore/bindings/v8/ScriptController.h @@ -143,7 +143,9 @@ public: void setEventHandlerLineNumber(int lineNumber); void setProcessingTimerCallback(bool processingTimerCallback) { m_processingTimerCallback = processingTimerCallback; } - bool processingUserGesture() const; + // FIXME: Currently we don't use the parameter world at all. + // See http://trac.webkit.org/changeset/54182 + bool processingUserGesture(DOMWrapperWorld* world = 0) const; bool anyPageIsProcessingUserGesture() const; void setPaused(bool paused) { m_paused = paused; } @@ -165,7 +167,7 @@ public: #endif // Dummy method to avoid a bunch of ifdef's in WebCore. - void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*) { } + void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*); static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds); private: diff --git a/WebCore/bindings/v8/ScriptObject.cpp b/WebCore/bindings/v8/ScriptObject.cpp index 8d80d34..0fcd16f 100644 --- a/WebCore/bindings/v8/ScriptObject.cpp +++ b/WebCore/bindings/v8/ScriptObject.cpp @@ -36,9 +36,10 @@ #include "Document.h" #include "Frame.h" -#include "InspectorBackend.h" -#include "InspectorFrontendHost.h" #include "V8Binding.h" +#include "V8InjectedScriptHost.h" +#include "V8InspectorBackend.h" +#include "V8InspectorFrontendHost.h" #include "V8Proxy.h" #include <v8.h> @@ -144,21 +145,21 @@ bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, const S bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorBackend* value) { ScriptScope scope(scriptState); - scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORBACKEND, value)); + scope.global()->Set(v8::String::New(name), toV8(value)); return scope.success(); } bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InspectorFrontendHost* value) { ScriptScope scope(scriptState); - scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INSPECTORFRONTENDHOST, value)); + scope.global()->Set(v8::String::New(name), toV8(value)); return scope.success(); } bool ScriptGlobalObject::set(ScriptState* scriptState, const char* name, InjectedScriptHost* value) { ScriptScope scope(scriptState); - scope.global()->Set(v8::String::New(name), V8DOMWrapper::convertToV8Object(V8ClassIndex::INJECTEDSCRIPTHOST, value)); + scope.global()->Set(v8::String::New(name), toV8(value)); return scope.success(); } #endif diff --git a/WebCore/bindings/v8/ScriptProfile.h b/WebCore/bindings/v8/ScriptProfile.h new file mode 100644 index 0000000..1a4d677 --- /dev/null +++ b/WebCore/bindings/v8/ScriptProfile.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2010, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScriptProfile_h +#define ScriptProfile_h + +#include "PlatformString.h" + +namespace WebCore { + +class ScriptProfile : public RefCounted<ScriptProfile> { +public: + static PassRefPtr<ScriptProfile> create(const String& title, unsigned uid) + { + return adoptRef(new ScriptProfile(title, uid)); + } + virtual ~ScriptProfile() {} + + String title() const { return m_title; } + unsigned int uid() const { return m_uid; } + +protected: + ScriptProfile(const String& title, unsigned uid) + : m_title(title) + , m_uid(uid) + {} + +private: + String m_title; + unsigned int m_uid; +}; + +} // namespace WebCore + +#endif // ScriptProfile_h diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/ScriptProfiler.cpp index 0dbdcd7..f238f6f 100644 --- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp +++ b/WebCore/bindings/v8/ScriptProfiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (c) 2010, Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -29,29 +29,22 @@ */ #include "config.h" -#include "V8Console.h" -#include "V8Binding.h" -#include "V8CustomBinding.h" -#include "V8Proxy.h" -#include <v8.h> +#include "ScriptProfiler.h" namespace WebCore { -v8::Handle<v8::Value> V8Console::profileCallback(const v8::Arguments& args) +void ScriptProfiler::start(ScriptState* state, const String& title) { - INC_STATS("console.profile()"); v8::HandleScope scope; - v8::Context::Scope context_scope(v8::Context::GetCurrent()); + v8::Context::Scope contextScope(v8::Context::GetCurrent()); v8::V8::ResumeProfiler(); - return v8::Undefined(); } -v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args) +PassRefPtr<ScriptProfile> ScriptProfiler::stop(ScriptState* state, const String& title) { - INC_STATS("console.profileEnd()"); v8::V8::PauseProfiler(); - return v8::Undefined(); + return 0; } } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptProfiler.h b/WebCore/bindings/v8/ScriptProfiler.h new file mode 100644 index 0000000..c02cc32 --- /dev/null +++ b/WebCore/bindings/v8/ScriptProfiler.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2010, Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ScriptProfiler_h +#define ScriptProfiler_h + +#include "PlatformString.h" +#include "ScriptProfile.h" +#include "ScriptState.h" + +#include <wtf/Noncopyable.h> + +namespace WebCore { + +class ScriptProfiler : public Noncopyable { +public: + static void start(ScriptState* state, const String& title); + static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title); +}; + +} // namespace WebCore + +#endif // ScriptProfiler_h diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp index 0f5b5c8..944fd57 100644 --- a/WebCore/bindings/v8/V8AbstractEventListener.cpp +++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp @@ -36,6 +36,7 @@ #include "Event.h" #include "Frame.h" #include "V8Binding.h" +#include "V8Event.h" #include "V8EventListenerList.h" #include "V8Proxy.h" #include "V8Utilities.h" @@ -84,7 +85,7 @@ void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event v8::Context::Scope scope(v8Context); // Get the V8 wrapper for the event object. - v8::Handle<v8::Value> jsEvent = V8DOMWrapper::convertEventToV8Object(event); + v8::Handle<v8::Value> jsEvent = toV8(event); invokeEventHandler(context, event, jsEvent); diff --git a/WebCore/bindings/v8/V8Collection.h b/WebCore/bindings/v8/V8Collection.h index 84150d8..9611571 100644 --- a/WebCore/bindings/v8/V8Collection.h +++ b/WebCore/bindings/v8/V8Collection.h @@ -38,155 +38,149 @@ #include <v8.h> namespace WebCore { - // FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param). - // See https://bugs.webkit.org/show_bug.cgi?id=24664. - - inline v8::Handle<v8::Value> getV8Object(void* implementation, v8::Local<v8::Value> implementationType) - { - if (!implementation) - return v8::Handle<v8::Value>(); - V8ClassIndex::V8WrapperType type = V8ClassIndex::FromInt(implementationType->Int32Value()); - if (type == V8ClassIndex::NODE) - return V8DOMWrapper::convertNodeToV8Object(static_cast<Node*>(implementation)); - return V8DOMWrapper::convertToV8Object(type, implementation); +// FIXME: These functions should be named using to* since they return the item (get* is used for method that take a ref param). +// See https://bugs.webkit.org/show_bug.cgi?id=24664. + +template<class T> static v8::Handle<v8::Value> getV8Object(T* implementation) +{ + if (!implementation) + return v8::Handle<v8::Value>(); + return toV8(implementation); +} + +template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object) +{ + return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); +} + +template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation) +{ + return getV8Object(implementation.get()); +} + +// Returns named property of a collection. +template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object) +{ + // FIXME: assert object is a collection type + ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); + ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE); + Collection* collection = toNativeCollection<Collection>(object); + AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name); + return getV8Object<ItemType>(collection->namedItem(propertyName)); +} + +// A template of named property accessor of collections. +template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name); + + if (!value.IsEmpty()) + return value; + + // Search local callback properties next to find IDL defined + // properties. + if (info.Holder()->HasRealNamedCallbackProperty(name)) + return notHandledByInterceptor(); + return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder()); +} + +// Returns the property at the index of a collection. +template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object) +{ + // FIXME: Assert that object must be a collection type. + ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); + ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE); + Collection* collection = toNativeCollection<Collection>(object); + return getV8Object<ItemType>(collection->item(index)); +} + +// A template of index interceptor of collections. +template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) +{ + return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder()); +} + +// Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement. +template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info) +{ + ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); + Collection* collection = toNativeCollection<Collection>(info.Holder()); + int length = collection->length(); + v8::Handle<v8::Array> properties = v8::Array::New(length); + for (int i = 0; i < length; ++i) { + // FIXME: Do we need to check that the item function returns a non-null value for this index? + v8::Handle<v8::Integer> integer = v8::Integer::New(i); + properties->Set(integer, integer); } - - template<class Collection> static Collection* toNativeCollection(v8::Local<v8::Object> object) - { - return reinterpret_cast<Collection*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); - } - - template<class T> static v8::Handle<v8::Value> getV8Object(PassRefPtr<T> implementation, v8::Local<v8::Value> implementationType) - { - return getV8Object(implementation.get(), implementationType); - } - - // Returns named property of a collection. - template<class Collection, class ItemType> static v8::Handle<v8::Value> getNamedPropertyOfCollection(v8::Local<v8::String> name, v8::Local<v8::Object> object, - v8::Local<v8::Value> implementationType) - { - // FIXME: assert object is a collection type - ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); - ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE); - Collection* collection = toNativeCollection<Collection>(object); - AtomicString propertyName = toAtomicWebCoreStringWithNullCheck(name); - return getV8Object<ItemType>(collection->namedItem(propertyName), implementationType); - } - - // A template of named property accessor of collections. - template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) - { - v8::Handle<v8::Value> value = info.Holder()->GetRealNamedPropertyInPrototypeChain(name); - - if (!value.IsEmpty()) - return value; - - // Search local callback properties next to find IDL defined - // properties. - if (info.Holder()->HasRealNamedCallbackProperty(name)) - return notHandledByInterceptor(); - return getNamedPropertyOfCollection<Collection, ItemType>(name, info.Holder(), info.Data()); + return properties; +} + +// Get an array containing the names of indexed properties in a collection. +template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info) +{ + ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); + Collection* collection = toNativeCollection<Collection>(info.Holder()); + int length = collection->length(); + v8::Handle<v8::Array> properties = v8::Array::New(length); + for (int i = 0; i < length; ++i) { + // FIXME: Do we need to check that the item function returns a non-null value for this index? + v8::Handle<v8::Integer> integer = v8::Integer::New(i); + properties->Set(integer, integer); } - - // Returns the property at the index of a collection. - template<class Collection, class ItemType> static v8::Handle<v8::Value> getIndexedPropertyOfCollection(uint32_t index, v8::Local<v8::Object> object, - v8::Local<v8::Value> implementationType) - { - // FIXME: Assert that object must be a collection type. - ASSERT(V8DOMWrapper::maybeDOMWrapper(object)); - ASSERT(V8DOMWrapper::domWrapperType(object) != V8ClassIndex::NODE); - Collection* collection = toNativeCollection<Collection>(object); - return getV8Object<ItemType>(collection->item(index), implementationType); - } - - // A template of index interceptor of collections. - template<class Collection, class ItemType> static v8::Handle<v8::Value> collectionIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) - { - return getIndexedPropertyOfCollection<Collection, ItemType>(index, info.Holder(), info.Data()); - } - - // Get an array containing the names of indexed properties of HTMLSelectElement and HTMLFormElement. - template<class Collection> static v8::Handle<v8::Array> nodeCollectionIndexedPropertyEnumerator(const v8::AccessorInfo& info) - { - ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); - ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE); - Collection* collection = toNativeCollection<Collection>(info.Holder()); - int length = collection->length(); - v8::Handle<v8::Array> properties = v8::Array::New(length); - for (int i = 0; i < length; ++i) { - // FIXME: Do we need to check that the item function returns a non-null value for this index? - v8::Handle<v8::Integer> integer = v8::Integer::New(i); - properties->Set(integer, integer); - } - return properties; - } - - // Get an array containing the names of indexed properties in a collection. - template<class Collection> static v8::Handle<v8::Array> collectionIndexedPropertyEnumerator(const v8::AccessorInfo& info) - { - ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); - Collection* collection = toNativeCollection<Collection>(info.Holder()); - int length = collection->length(); - v8::Handle<v8::Array> properties = v8::Array::New(length); - for (int i = 0; i < length; ++i) { - // FIXME: Do we need to check that the item function returns a non-null value for this index? - v8::Handle<v8::Integer> integer = v8::Integer::New(i); - properties->Set(integer, integer); - } - return properties; - } - - - // A template for indexed getters on collections of strings that should return null if the resulting string is a null string. - template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) - { - // FIXME: assert that object must be a collection type - ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); - Collection* collection = toNativeCollection<Collection>(info.Holder()); - String result = collection->item(index); - return v8StringOrNull(result); - } - - - // A template for indexed getters on collections of strings. - template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) - { - // FIXME: assert that object must be a collection type - ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); - Collection* collection = toNativeCollection<Collection>(info.Holder()); - String result = collection->item(index); - return v8String(result); - } - - - // Add indexed getter to the function template for a collection. - template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type) - { - desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>, - v8::Integer::New(V8ClassIndex::ToInt(type))); - } - - - // Add named getter to the function template for a collection. - template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type) - { - desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type))); - } - - // Add indexed getter returning a string or null to a function template for a collection. - template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc) - { - desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>); - } - - - // Add indexed getter returning a string to a function template for a collection. - template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc) - { - desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>); - } - - v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*); + return properties; +} + + +// A template for indexed getters on collections of strings that should return null if the resulting string is a null string. +template<class Collection> static v8::Handle<v8::Value> collectionStringOrNullIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) +{ + // FIXME: assert that object must be a collection type + ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); + Collection* collection = toNativeCollection<Collection>(info.Holder()); + String result = collection->item(index); + return v8StringOrNull(result); +} + + +// A template for indexed getters on collections of strings. +template<class Collection> static v8::Handle<v8::Value> collectionStringIndexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) +{ + // FIXME: assert that object must be a collection type + ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); + Collection* collection = toNativeCollection<Collection>(info.Holder()); + String result = collection->item(index); + return v8String(result); +} + + +// Add indexed getter to the function template for a collection. +template<class Collection, class ItemType> static void setCollectionIndexedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type) +{ + desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionIndexedPropertyGetter<Collection, ItemType>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>, + v8::Integer::New(V8ClassIndex::ToInt(type))); +} + + +// Add named getter to the function template for a collection. +template<class Collection, class ItemType> static void setCollectionNamedGetter(v8::Handle<v8::FunctionTemplate> desc, V8ClassIndex::V8WrapperType type) +{ + desc->InstanceTemplate()->SetNamedPropertyHandler(collectionNamedPropertyGetter<Collection, ItemType>, 0, 0, 0, 0, v8::Integer::New(V8ClassIndex::ToInt(type))); +} + +// Add indexed getter returning a string or null to a function template for a collection. +template<class Collection> static void setCollectionStringOrNullIndexedGetter(v8::Handle<v8::FunctionTemplate> desc) +{ + desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringOrNullIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>); +} + + +// Add indexed getter returning a string to a function template for a collection. +template<class Collection> static void setCollectionStringIndexedGetter(v8::Handle<v8::FunctionTemplate> desc) +{ + desc->InstanceTemplate()->SetIndexedPropertyHandler(collectionStringIndexedPropertyGetter<Collection>, 0, 0, 0, collectionIndexedPropertyEnumerator<Collection>); +} + +v8::Handle<v8::Value> toOptionsCollectionSetter(uint32_t index, v8::Handle<v8::Value>, HTMLSelectElement*); } // namespace WebCore diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp index 7e1452b..683fea5 100644 --- a/WebCore/bindings/v8/V8DOMWindowShell.cpp +++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp @@ -48,9 +48,9 @@ #include "V8BindingState.h" #include "V8Collection.h" #include "V8ConsoleMessage.h" -#include "V8CustomBinding.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" +#include "V8Document.h" #include "V8HiddenPropertyName.h" #include "V8History.h" #include "V8Index.h" @@ -430,7 +430,7 @@ void V8DOMWindowShell::updateDocumentWrapperCache() return; } - v8::Handle<v8::Value> documentWrapper = V8DOMWrapper::convertNodeToV8Object(m_frame->document()); + v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document()); // If instantiation of the document wrapper fails, clear the cache // and let the DOMWindow accessor handle access to the document. diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp index a24742d..fd0edc5 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -43,8 +43,8 @@ #include "V8AbstractEventListener.h" #include "V8Binding.h" #include "V8Collection.h" -#include "V8CustomBinding.h" #include "V8CustomEventListener.h" +#include "V8DOMApplicationCache.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" #include "V8EventListenerList.h" @@ -52,12 +52,18 @@ #include "V8HTMLDocument.h" #include "V8Index.h" #include "V8IsolatedContext.h" -#include "V8MessageChannel.h" #include "V8Location.h" +#include "V8MessageChannel.h" #include "V8NamedNodeMap.h" +#include "V8Node.h" #include "V8NodeList.h" +#include "V8Notification.h" #include "V8Proxy.h" +#include "V8SVGElementInstance.h" +#include "V8SharedWorker.h" #include "V8StyleSheet.h" +#include "V8WebSocket.h" +#include "V8Worker.h" #include "WebGLArray.h" #include "WebGLContextAttributes.h" #include "WebGLUniformLocation.h" @@ -77,93 +83,6 @@ namespace WebCore { typedef HashMap<Node*, v8::Object*> DOMNodeMap; typedef HashMap<void*, v8::Object*> DOMObjectMap; -#if ENABLE(SVG) - -static V8ClassIndex::V8WrapperType downcastSVGPathSeg(void* pathSeg) -{ - SVGPathSeg* realPathSeg = reinterpret_cast<SVGPathSeg*>(pathSeg); - - switch (realPathSeg->pathSegType()) { - case SVGPathSeg::PATHSEG_CLOSEPATH: return V8ClassIndex::SVGPATHSEGCLOSEPATH; - case SVGPathSeg::PATHSEG_MOVETO_ABS: return V8ClassIndex::SVGPATHSEGMOVETOABS; - case SVGPathSeg::PATHSEG_MOVETO_REL: return V8ClassIndex::SVGPATHSEGMOVETOREL; - case SVGPathSeg::PATHSEG_LINETO_ABS: return V8ClassIndex::SVGPATHSEGLINETOABS; - case SVGPathSeg::PATHSEG_LINETO_REL: return V8ClassIndex::SVGPATHSEGLINETOREL; - case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: return V8ClassIndex::SVGPATHSEGCURVETOCUBICABS; - case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: return V8ClassIndex::SVGPATHSEGCURVETOCUBICREL; - case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICABS; - case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICREL; - case SVGPathSeg::PATHSEG_ARC_ABS: return V8ClassIndex::SVGPATHSEGARCABS; - case SVGPathSeg::PATHSEG_ARC_REL: return V8ClassIndex::SVGPATHSEGARCREL; - case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALABS; - case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: return V8ClassIndex::SVGPATHSEGLINETOHORIZONTALREL; - case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: return V8ClassIndex::SVGPATHSEGLINETOVERTICALABS; - case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: return V8ClassIndex::SVGPATHSEGLINETOVERTICALREL; - case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHABS; - case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: return V8ClassIndex::SVGPATHSEGCURVETOCUBICSMOOTHREL; - case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHABS; - case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: return V8ClassIndex::SVGPATHSEGCURVETOQUADRATICSMOOTHREL; - default: return V8ClassIndex::INVALID_CLASS_INDEX; - } -} - -v8::Handle<v8::Value> V8DOMWrapper::convertSVGElementInstanceToV8Object(SVGElementInstance* instance) -{ - if (!instance) - return v8::Null(); - - v8::Handle<v8::Object> existingInstance = getDOMSVGElementInstanceMap().get(instance); - if (!existingInstance.IsEmpty()) - return existingInstance; - - instance->ref(); - - // Instantiate the V8 object and remember it - v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::SVGELEMENTINSTANCE, V8ClassIndex::SVGELEMENTINSTANCE, instance); - if (!result.IsEmpty()) { - // Only update the DOM SVG element map if the result is non-empty. - getDOMSVGElementInstanceMap().set(instance, v8::Persistent<v8::Object>::New(result)); - } - return result; -} - -v8::Handle<v8::Value> V8DOMWrapper::convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType type, void* object) -{ - if (!object) - return v8::Null(); - - v8::Persistent<v8::Object> result = getDOMSVGObjectWithContextMap().get(object); - if (!result.IsEmpty()) - return result; - - // Special case: SVGPathSegs need to be downcast to their real type - if (type == V8ClassIndex::SVGPATHSEG) - type = downcastSVGPathSeg(object); - - v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, object); - if (!v8Object.IsEmpty()) { - result = v8::Persistent<v8::Object>::New(v8Object); - switch (type) { -#define MAKE_CASE(TYPE, NAME) \ - case V8ClassIndex::TYPE: static_cast<NAME*>(object)->ref(); break; - SVG_OBJECT_TYPES(MAKE_CASE) -#undef MAKE_CASE -#define MAKE_CASE(TYPE, NAME) \ - case V8ClassIndex::TYPE: \ - static_cast<V8SVGPODTypeWrapper<NAME>*>(object)->ref(); break; - SVG_POD_NATIVE_TYPES(MAKE_CASE) -#undef MAKE_CASE - default: - ASSERT_NOT_REACHED(); - } - getDOMSVGObjectWithContextMap().set(object, result); - } - - return result; -} - -#endif // ENABLE(SVG) - #if ENABLE(3D_CANVAS) void V8DOMWrapper::setIndexedPropertiesToExternalArray(v8::Handle<v8::Object> wrapper, int index, @@ -317,188 +236,6 @@ v8::Local<v8::Function> V8DOMWrapper::getConstructor(V8ClassIndex::V8WrapperType return getConstructorForContext(type, context); } -v8::Handle<v8::Value> V8DOMWrapper::convertToV8Object(V8ClassIndex::V8WrapperType type, void* impl) -{ - ASSERT(type != V8ClassIndex::EVENTLISTENER); - ASSERT(type != V8ClassIndex::EVENTTARGET); - ASSERT(type != V8ClassIndex::EVENT); - - // These objects can be constructed under WorkerContextExecutionProxy. They need special - // handling, since if we proceed below V8Proxy::retrieve() will get called and will crash. - // TODO(ukai): websocket? - if ((type == V8ClassIndex::DOMCOREEXCEPTION - || type == V8ClassIndex::RANGEEXCEPTION - || type == V8ClassIndex::EVENTEXCEPTION - || type == V8ClassIndex::XMLHTTPREQUESTEXCEPTION - || type == V8ClassIndex::MESSAGEPORT) - && WorkerContextExecutionProxy::retrieve()) { - return WorkerContextExecutionProxy::convertToV8Object(type, impl); - } - - bool isActiveDomObject = false; - switch (type) { -#define MAKE_CASE(TYPE, NAME) case V8ClassIndex::TYPE: - DOM_NODE_TYPES(MAKE_CASE) -#if ENABLE(SVG) - SVG_NODE_TYPES(MAKE_CASE) -#endif - return convertNodeToV8Object(static_cast<Node*>(impl)); - case V8ClassIndex::CSSVALUE: - return convertCSSValueToV8Object(static_cast<CSSValue*>(impl)); - case V8ClassIndex::CSSRULE: - return convertCSSRuleToV8Object(static_cast<CSSRule*>(impl)); - case V8ClassIndex::STYLESHEET: - return convertStyleSheetToV8Object(static_cast<StyleSheet*>(impl)); - case V8ClassIndex::DOMWINDOW: - return convertWindowToV8Object(static_cast<DOMWindow*>(impl)); - case V8ClassIndex::NAMEDNODEMAP: - return convertNamedNodeMapToV8Object(static_cast<NamedNodeMap*>(impl)); -#if ENABLE(SVG) - SVG_NONNODE_TYPES(MAKE_CASE) - if (type == V8ClassIndex::SVGELEMENTINSTANCE) - return convertSVGElementInstanceToV8Object(static_cast<SVGElementInstance*>(impl)); - return convertSVGObjectWithContextToV8Object(type, impl); -#endif - - ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE) - isActiveDomObject = true; - break; - default: - break; - } - -#undef MAKE_CASE - - if (!impl) - return v8::Null(); - - // Non DOM node - v8::Persistent<v8::Object> result = isActiveDomObject ? getActiveDOMObjectMap().get(impl) : getDOMObjectMap().get(impl); - if (result.IsEmpty()) { -#if ENABLE(3D_CANVAS) - if (type == V8ClassIndex::WEBGLARRAY && impl) { - // Determine which subclass we are wrapping. - WebGLArray* array = reinterpret_cast<WebGLArray*>(impl); - if (array->isByteArray()) - type = V8ClassIndex::WEBGLBYTEARRAY; - else if (array->isFloatArray()) - type = V8ClassIndex::WEBGLFLOATARRAY; - else if (array->isIntArray()) - type = V8ClassIndex::WEBGLINTARRAY; - else if (array->isShortArray()) - type = V8ClassIndex::WEBGLSHORTARRAY; - else if (array->isUnsignedByteArray()) - type = V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY; - else if (array->isUnsignedIntArray()) - type = V8ClassIndex::WEBGLUNSIGNEDINTARRAY; - else if (array->isUnsignedShortArray()) - type = V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY; - } -#endif - - v8::Local<v8::Object> v8Object = instantiateV8Object(type, type, impl); - if (!v8Object.IsEmpty()) { - // Go through big switch statement, it has some duplications - // that were handled by code above (such as CSSVALUE, CSSRULE, etc). - switch (type) { -#define MAKE_CASE(TYPE, NAME) \ - case V8ClassIndex::TYPE: static_cast<NAME*>(impl)->ref(); break; - DOM_OBJECT_TYPES(MAKE_CASE) -#undef MAKE_CASE - default: - ASSERT_NOT_REACHED(); - } - result = v8::Persistent<v8::Object>::New(v8Object); - if (isActiveDomObject) - setJSWrapperForActiveDOMObject(impl, result); - else - setJSWrapperForDOMObject(impl, result); - - if (type == V8ClassIndex::CANVASPIXELARRAY) { - CanvasPixelArray* pixels = reinterpret_cast<CanvasPixelArray*>(impl); - result->SetIndexedPropertiesToPixelData(pixels->data()->data(), pixels->length()); - } - -#if ENABLE(3D_CANVAS) - // Set up WebGLArray subclasses' accesses similarly. - switch (type) { - case V8ClassIndex::WEBGLBYTEARRAY: - case V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY: - case V8ClassIndex::WEBGLSHORTARRAY: - case V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY: - case V8ClassIndex::WEBGLINTARRAY: - case V8ClassIndex::WEBGLUNSIGNEDINTARRAY: - case V8ClassIndex::WEBGLFLOATARRAY: { - WebGLArray* array = reinterpret_cast<WebGLArray*>(impl); - setIndexedPropertiesToExternalArray(result, - V8ClassIndex::ToInt(type), - array->baseAddress(), - array->length()); - break; - } - default: - break; - } -#endif - - // Special case for non-node objects associated with a - // DOMWindow. Both Safari and FF let the JS wrappers for these - // objects survive GC. To mimic their behavior, V8 creates - // hidden references from the DOMWindow to these wrapper - // objects. These references get cleared when the DOMWindow is - // reused by a new page. - switch (type) { - case V8ClassIndex::CONSOLE: - setHiddenWindowReference(static_cast<Console*>(impl)->frame(), V8DOMWindow::consoleIndex, result); - break; - case V8ClassIndex::HISTORY: - setHiddenWindowReference(static_cast<History*>(impl)->frame(), V8DOMWindow::historyIndex, result); - break; - case V8ClassIndex::NAVIGATOR: - setHiddenWindowReference(static_cast<Navigator*>(impl)->frame(), V8DOMWindow::navigatorIndex, result); - break; - case V8ClassIndex::SCREEN: - setHiddenWindowReference(static_cast<Screen*>(impl)->frame(), V8DOMWindow::screenIndex, result); - break; - case V8ClassIndex::LOCATION: - setHiddenWindowReference(static_cast<Location*>(impl)->frame(), V8DOMWindow::locationIndex, result); - break; - case V8ClassIndex::DOMSELECTION: - setHiddenWindowReference(static_cast<DOMSelection*>(impl)->frame(), V8DOMWindow::domSelectionIndex, result); - break; - case V8ClassIndex::BARINFO: { - BarInfo* barInfo = static_cast<BarInfo*>(impl); - Frame* frame = barInfo->frame(); - switch (barInfo->type()) { - case BarInfo::Locationbar: - setHiddenWindowReference(frame, V8DOMWindow::locationbarIndex, result); - break; - case BarInfo::Menubar: - setHiddenWindowReference(frame, V8DOMWindow::menubarIndex, result); - break; - case BarInfo::Personalbar: - setHiddenWindowReference(frame, V8DOMWindow::personalbarIndex, result); - break; - case BarInfo::Scrollbars: - setHiddenWindowReference(frame, V8DOMWindow::scrollbarsIndex, result); - break; - case BarInfo::Statusbar: - setHiddenWindowReference(frame, V8DOMWindow::statusbarIndex, result); - break; - case BarInfo::Toolbar: - setHiddenWindowReference(frame, V8DOMWindow::toolbarIndex, result); - break; - } - break; - } - default: - break; - } - } - } - return result; -} - void V8DOMWrapper::setHiddenWindowReference(Frame* frame, const int internalIndex, v8::Handle<v8::Object> jsObject) { // Get DOMWindow @@ -542,12 +279,8 @@ PassRefPtr<NodeFilter> V8DOMWrapper::wrapNativeNodeFilter(v8::Handle<v8::Value> return NodeFilter::create(condition); } -v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType descriptorType, V8ClassIndex::V8WrapperType cptrType, void* impl) +v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl) { - // Make a special case for document.all - if (descriptorType == V8ClassIndex::HTMLCOLLECTION && static_cast<HTMLCollection*>(impl)->type() == DocAll) - descriptorType = V8ClassIndex::HTMLALLCOLLECTION; - if (V8IsolatedContext::getEntered()) { // This effectively disables the wrapper cache for isolated worlds. proxy = 0; @@ -560,14 +293,14 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassI v8::Local<v8::Object> instance; if (proxy) // FIXME: Fix this to work properly with isolated worlds (see above). - instance = proxy->windowShell()->createWrapperFromCache(descriptorType); + instance = proxy->windowShell()->createWrapperFromCache(type); else { - v8::Local<v8::Function> function = getTemplate(descriptorType)->GetFunction(); + v8::Local<v8::Function> function = getTemplate(type)->GetFunction(); instance = SafeAllocation::newInstance(function); } if (!instance.IsEmpty()) { // Avoid setting the DOM wrapper for failed allocations. - setDOMWrapper(instance, V8ClassIndex::ToInt(cptrType), impl); + setDOMWrapper(instance, V8ClassIndex::ToInt(type), impl); } return instance; } @@ -595,13 +328,6 @@ bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value) } #endif -bool V8DOMWrapper::isDOMEventWrapper(v8::Handle<v8::Value> value) -{ - // All kinds of events use EVENT as dom type in JS wrappers. - // See EventToV8Object - return isWrapperOfType(value, V8ClassIndex::EVENT); -} - bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8WrapperType classType) { if (value.IsEmpty() || !value->IsObject()) @@ -623,6 +349,7 @@ bool V8DOMWrapper::isWrapperOfType(v8::Handle<v8::Value> value, V8ClassIndex::V8 return V8ClassIndex::FromInt(type->Int32Value()) == classType; } +<<<<<<< HEAD #if ENABLE(VIDEO) #define FOR_EACH_VIDEO_TAG(macro) \ macro(audio, AUDIO) \ @@ -982,13 +709,16 @@ v8::Handle<v8::Value> V8DOMWrapper::convertDocumentToV8Object(Document* document } static v8::Handle<v8::Value> getWrapper(Node* node) +======= +v8::Handle<v8::Object> V8DOMWrapper::getWrapper(Node* node) +>>>>>>> webkit.org at r54340 { ASSERT(WTF::isMainThread()); V8IsolatedContext* context = V8IsolatedContext::getEntered(); if (LIKELY(!context)) { v8::Persistent<v8::Object>* wrapper = node->wrapper(); if (!wrapper) - return v8::Handle<v8::Value>(); + return v8::Handle<v8::Object>(); return *wrapper; } @@ -996,101 +726,6 @@ static v8::Handle<v8::Value> getWrapper(Node* node) return domNodeMap.get(node); } -v8::Handle<v8::Value> V8DOMWrapper::convertNodeToV8Object(Node* node) -{ - if (!node) - return v8::Null(); - - v8::Handle<v8::Value> wrapper = getWrapper(node); - if (!wrapper.IsEmpty()) - return wrapper; - - Document* document = node->document(); - if (node == document) - return convertDocumentToV8Object(document); - - return convertNewNodeToV8Object(node, 0, getDOMNodeMap()); -} - -// Caller checks node is not null. -v8::Handle<v8::Value> V8DOMWrapper::convertNewNodeToV8Object(Node* node, V8Proxy* proxy, DOMNodeMapping& domNodeMap) -{ - if (!proxy && node->document()) - proxy = V8Proxy::retrieve(node->document()->frame()); - - bool isDocument = false; // document type node has special handling - V8ClassIndex::V8WrapperType type; - - Node::NodeType nodeType = node->nodeType(); - if (nodeType == Node::ELEMENT_NODE) { - if (node->isHTMLElement()) - type = htmlElementType(static_cast<HTMLElement*>(node)); -#if ENABLE(SVG) - else if (node->isSVGElement()) - type = svgElementType(static_cast<SVGElement*>(node)); -#endif - else - type = V8ClassIndex::ELEMENT; - } else if (nodeType == Node::DOCUMENT_NODE) { - isDocument = true; - Document* document = static_cast<Document*>(node); - if (document->isHTMLDocument()) - type = V8ClassIndex::HTMLDOCUMENT; -#if ENABLE(SVG) - else if (document->isSVGDocument()) - type = V8ClassIndex::SVGDOCUMENT; -#endif - else - type = V8ClassIndex::DOCUMENT; - } else { - ASSERT(nodeType < static_cast<int>(sizeof(mapping)/sizeof(mapping[0]))); - type = mapping[nodeType]; - ASSERT(type != V8ClassIndex::INVALID_CLASS_INDEX); - } - - v8::Handle<v8::Context> context; - if (proxy) - context = proxy->context(); - - // Enter the node's context and create the wrapper in that context. - if (!context.IsEmpty()) - context->Enter(); - - v8::Local<v8::Object> result = instantiateV8Object(proxy, type, V8ClassIndex::NODE, node); - - // Exit the node's context if it was entered. - if (!context.IsEmpty()) - context->Exit(); - - if (result.IsEmpty()) { - // If instantiation failed it's important not to add the result - // to the DOM node map. Instead we return an empty handle, which - // should already be handled by callers of this function in case - // the node is NULL. - return result; - } - - node->ref(); - domNodeMap.set(node, v8::Persistent<v8::Object>::New(result)); - - if (isDocument) { - if (proxy) - proxy->windowShell()->updateDocumentWrapper(result); - - if (type == V8ClassIndex::HTMLDOCUMENT) { - // Create marker object and insert it in two internal fields. - // This is used to implement temporary shadowing of - // document.all. - ASSERT(result->InternalFieldCount() == V8HTMLDocument::internalFieldCount); - v8::Local<v8::Object> marker = v8::Object::New(); - result->SetInternalField(V8HTMLDocument::markerIndex, marker); - result->SetInternalField(V8HTMLDocument::shadowIndex, marker); - } - } - - return result; -} - // A JS object of type EventTarget is limited to a small number of possible classes. // Check EventTarget.h for new type conversion methods v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* target) @@ -1099,91 +734,70 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta return v8::Null(); #if ENABLE(SVG) - SVGElementInstance* instance = target->toSVGElementInstance(); - if (instance) - return convertToV8Object(V8ClassIndex::SVGELEMENTINSTANCE, instance); + if (SVGElementInstance* instance = target->toSVGElementInstance()) + return toV8(instance); #endif #if ENABLE(WORKERS) - Worker* worker = target->toWorker(); - if (worker) - return convertToV8Object(V8ClassIndex::WORKER, worker); + if (Worker* worker = target->toWorker()) + return toV8(worker); #endif // WORKERS #if ENABLE(SHARED_WORKERS) - SharedWorker* sharedWorker = target->toSharedWorker(); - if (sharedWorker) - return convertToV8Object(V8ClassIndex::SHAREDWORKER, sharedWorker); + if (SharedWorker* sharedWorker = target->toSharedWorker()) + return toV8(sharedWorker); #endif // SHARED_WORKERS #if ENABLE(NOTIFICATIONS) - Notification* notification = target->toNotification(); - if (notification) - return convertToV8Object(V8ClassIndex::NOTIFICATION, notification); + if (Notification* notification = target->toNotification()) + return toV8(notification); #endif #if ENABLE(WEB_SOCKETS) - WebSocket* webSocket = target->toWebSocket(); - if (webSocket) - return convertToV8Object(V8ClassIndex::WEBSOCKET, webSocket); + if (WebSocket* webSocket = target->toWebSocket()) + return toV8(webSocket); #endif - Node* node = target->toNode(); - if (node) - return convertNodeToV8Object(node); + if (Node* node = target->toNode()) + return toV8(node); if (DOMWindow* domWindow = target->toDOMWindow()) - return convertToV8Object(V8ClassIndex::DOMWINDOW, domWindow); + return toV8(domWindow); // XMLHttpRequest is created within its JS counterpart. - XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest(); - if (xmlHttpRequest) { + if (XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest()) { v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(xmlHttpRequest); ASSERT(!wrapper.IsEmpty()); return wrapper; } // MessagePort is created within its JS counterpart - MessagePort* port = target->toMessagePort(); - if (port) { + if (MessagePort* port = target->toMessagePort()) { v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(port); ASSERT(!wrapper.IsEmpty()); return wrapper; } - XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload(); - if (upload) { + if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload()) { v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(upload); ASSERT(!wrapper.IsEmpty()); return wrapper; } #if ENABLE(OFFLINE_WEB_APPLICATIONS) - DOMApplicationCache* domAppCache = target->toDOMApplicationCache(); - if (domAppCache) - return convertToV8Object(V8ClassIndex::DOMAPPLICATIONCACHE, domAppCache); + if (DOMApplicationCache* domAppCache = target->toDOMApplicationCache()) + return toV8(domAppCache); #endif #if ENABLE(EVENTSOURCE) - EventSource* eventSource = target->toEventSource(); - if (eventSource) - return convertToV8Object(V8ClassIndex::EVENTSOURCE, eventSource); + if (EventSource* eventSource = target->toEventSource()) + return toV8(eventSource); #endif ASSERT(0); return notHandledByInterceptor(); } -v8::Handle<v8::Value> V8DOMWrapper::convertEventListenerToV8Object(ScriptExecutionContext* context, EventListener* listener) -{ - if (!listener) - return v8::Null(); - - // FIXME: can a user take a lazy event listener and set to other places? - V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListener*>(listener); - return v8listener->getListenerObject(context); -} - PassRefPtr<EventListener> V8DOMWrapper::getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup) { return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute); @@ -1269,193 +883,4 @@ PassRefPtr<EventListener> V8DOMWrapper::getEventListener(V8Proxy* proxy, v8::Loc return (lookup == ListenerFindOnly) ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute); } -v8::Handle<v8::Value> V8DOMWrapper::convertDOMImplementationToV8Object(DOMImplementation* impl) -{ - v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::DOMIMPLEMENTATION, V8ClassIndex::DOMIMPLEMENTATION, impl); - if (result.IsEmpty()) { - // If the instantiation failed, we ignore it and return null instead - // of returning an empty handle. - return v8::Null(); - } - return result; -} - -v8::Handle<v8::Value> V8DOMWrapper::convertStyleSheetToV8Object(StyleSheet* sheet) -{ - if (!sheet) - return v8::Null(); - - v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(sheet); - if (!wrapper.IsEmpty()) - return wrapper; - - V8ClassIndex::V8WrapperType type = V8ClassIndex::STYLESHEET; - if (sheet->isCSSStyleSheet()) - type = V8ClassIndex::CSSSTYLESHEET; - - v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::STYLESHEET, sheet); - if (!result.IsEmpty()) { - // Only update the DOM object map if the result is non-empty. - sheet->ref(); - setJSWrapperForDOMObject(sheet, v8::Persistent<v8::Object>::New(result)); - } - - // Add a hidden reference from stylesheet object to its owner node. - Node* ownerNode = sheet->ownerNode(); - if (ownerNode) { - v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(ownerNode)); - result->SetInternalField(V8StyleSheet::ownerNodeIndex, owner); - } - - return result; -} - -v8::Handle<v8::Value> V8DOMWrapper::convertCSSValueToV8Object(CSSValue* value) -{ - if (!value) - return v8::Null(); - - v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(value); - if (!wrapper.IsEmpty()) - return wrapper; - - V8ClassIndex::V8WrapperType type; - - if (value->isWebKitCSSTransformValue()) - type = V8ClassIndex::WEBKITCSSTRANSFORMVALUE; - else if (value->isValueList()) - type = V8ClassIndex::CSSVALUELIST; - else if (value->isPrimitiveValue()) - type = V8ClassIndex::CSSPRIMITIVEVALUE; -#if ENABLE(SVG) - else if (value->isSVGPaint()) - type = V8ClassIndex::SVGPAINT; - else if (value->isSVGColor()) - type = V8ClassIndex::SVGCOLOR; -#endif - else - type = V8ClassIndex::CSSVALUE; - - v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSVALUE, value); - if (!result.IsEmpty()) { - // Only update the DOM object map if the result is non-empty. - value->ref(); - setJSWrapperForDOMObject(value, v8::Persistent<v8::Object>::New(result)); - } - - return result; -} - -v8::Handle<v8::Value> V8DOMWrapper::convertCSSRuleToV8Object(CSSRule* rule) -{ - if (!rule) - return v8::Null(); - - v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(rule); - if (!wrapper.IsEmpty()) - return wrapper; - - V8ClassIndex::V8WrapperType type; - - switch (rule->type()) { - case CSSRule::STYLE_RULE: - type = V8ClassIndex::CSSSTYLERULE; - break; - case CSSRule::CHARSET_RULE: - type = V8ClassIndex::CSSCHARSETRULE; - break; - case CSSRule::IMPORT_RULE: - type = V8ClassIndex::CSSIMPORTRULE; - break; - case CSSRule::MEDIA_RULE: - type = V8ClassIndex::CSSMEDIARULE; - break; - case CSSRule::FONT_FACE_RULE: - type = V8ClassIndex::CSSFONTFACERULE; - break; - case CSSRule::PAGE_RULE: - type = V8ClassIndex::CSSPAGERULE; - break; - case CSSRule::VARIABLES_RULE: - type = V8ClassIndex::CSSVARIABLESRULE; - break; - case CSSRule::WEBKIT_KEYFRAME_RULE: - type = V8ClassIndex::WEBKITCSSKEYFRAMERULE; - break; - case CSSRule::WEBKIT_KEYFRAMES_RULE: - type = V8ClassIndex::WEBKITCSSKEYFRAMESRULE; - break; - default: // CSSRule::UNKNOWN_RULE - type = V8ClassIndex::CSSRULE; - break; - } - - v8::Handle<v8::Object> result = instantiateV8Object(type, V8ClassIndex::CSSRULE, rule); - if (!result.IsEmpty()) { - // Only update the DOM object map if the result is non-empty. - rule->ref(); - setJSWrapperForDOMObject(rule, v8::Persistent<v8::Object>::New(result)); - } - return result; -} - -v8::Handle<v8::Value> V8DOMWrapper::convertWindowToV8Object(DOMWindow* window) -{ - if (!window) - return v8::Null(); - // Initializes environment of a frame, and return the global object - // of the frame. - Frame* frame = window->frame(); - if (!frame) - return v8::Handle<v8::Object>(); - - // Special case: Because of evaluateInIsolatedWorld() one DOMWindow can have - // multiple contexts and multiple global objects associated with it. When - // code running in one of those contexts accesses the window object, we - // want to return the global object associated with that context, not - // necessarily the first global object associated with that DOMWindow. - v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent(); - v8::Handle<v8::Object> currentGlobal = currentContext->Global(); - v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, currentGlobal); - if (!windowWrapper.IsEmpty()) { - if (V8DOMWindow::toNative(windowWrapper) == window) - return currentGlobal; - } - - // Otherwise, return the global object associated with this frame. - v8::Handle<v8::Context> context = V8Proxy::context(frame); - if (context.IsEmpty()) - return v8::Handle<v8::Object>(); - - v8::Handle<v8::Object> global = context->Global(); - ASSERT(!global.IsEmpty()); - return global; -} - -v8::Handle<v8::Value> V8DOMWrapper::convertNamedNodeMapToV8Object(NamedNodeMap* map) -{ - if (!map) - return v8::Null(); - - v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(map); - if (!wrapper.IsEmpty()) - return wrapper; - - v8::Handle<v8::Object> result = instantiateV8Object(V8ClassIndex::NAMEDNODEMAP, V8ClassIndex::NAMEDNODEMAP, map); - if (result.IsEmpty()) - return result; - - // Only update the DOM object map if the result is non-empty. - map->ref(); - setJSWrapperForDOMObject(map, v8::Persistent<v8::Object>::New(result)); - - // Add a hidden reference from named node map to its owner node. - if (Element* element = map->element()) { - v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(convertNodeToV8Object(element)); - result->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner); - } - - return result; -} - } // namespace WebCore diff --git a/WebCore/bindings/v8/V8DOMWrapper.h b/WebCore/bindings/v8/V8DOMWrapper.h index 3cff691..51abff7 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.h +++ b/WebCore/bindings/v8/V8DOMWrapper.h @@ -36,7 +36,6 @@ #include "Node.h" #include "NodeFilter.h" #include "PlatformString.h" // for WebCore::String -#include "V8CustomBinding.h" #include "V8CustomXPathNSResolver.h" #include "V8DOMMap.h" #include "V8Event.h" @@ -123,45 +122,8 @@ namespace WebCore { return object.IsEmpty() ? object : object->FindInstanceInPrototypeChain(getTemplate(type)); } - template<typename T> - static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType type, PassRefPtr<T> imp) - { - return convertToV8Object(type, imp.get()); - } - - static v8::Handle<v8::Value> convertToV8Object(V8ClassIndex::V8WrapperType, void*); - - // Fast-path for Node objects. - static v8::Handle<v8::Value> convertNodeToV8Object(PassRefPtr<Node> node) - { - return convertNodeToV8Object(node.get()); - } - - static v8::Handle<v8::Value> convertNodeToV8Object(Node*); - - static v8::Handle<v8::Value> convertDocumentToV8Object(Document*); - - static v8::Handle<v8::Value> convertNewNodeToV8Object(PassRefPtr<Node> node) - { - return convertNewNodeToV8Object(node.get()); - } - - static v8::Handle<v8::Value> convertNewNodeToV8Object(Node* node) - { - return convertNewNodeToV8Object(node, 0, getDOMNodeMap()); - } - - static v8::Handle<v8::Value> convertNewNodeToV8Object(Node*, V8Proxy*, DOMNodeMapping&); - static V8ClassIndex::V8WrapperType domWrapperType(v8::Handle<v8::Object>); - static v8::Handle<v8::Value> convertEventToV8Object(PassRefPtr<Event> event) - { - return convertEventToV8Object(event.get()); - } - - static v8::Handle<v8::Value> convertEventToV8Object(Event*); - static v8::Handle<v8::Value> convertEventTargetToV8Object(PassRefPtr<EventTarget> eventTarget) { return convertEventTargetToV8Object(eventTarget.get()); @@ -169,14 +131,6 @@ namespace WebCore { static v8::Handle<v8::Value> convertEventTargetToV8Object(EventTarget*); - // Wrap and unwrap JS event listeners. - static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext* context, PassRefPtr<EventListener> eventListener) - { - return convertEventListenerToV8Object(context, eventListener.get()); - } - - static v8::Handle<v8::Value> convertEventListenerToV8Object(ScriptExecutionContext*, EventListener*); - static PassRefPtr<EventListener> getEventListener(Node* node, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup); static PassRefPtr<EventListener> getEventListener(SVGElementInstance* element, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup); @@ -211,10 +165,6 @@ namespace WebCore { return resolver; } #endif - // DOMImplementation is a singleton and it is handled in a special - // way. A wrapper is generated per document and stored in an - // internal field of the document. - static v8::Handle<v8::Value> convertDOMImplementationToV8Object(DOMImplementation*); // Wrap JS node filter in C++. static PassRefPtr<NodeFilter> wrapNativeNodeFilter(v8::Handle<v8::Value>); @@ -233,50 +183,18 @@ namespace WebCore { // Check whether a V8 value is a wrapper of type |classType|. static bool isWrapperOfType(v8::Handle<v8::Value>, V8ClassIndex::V8WrapperType); - // Check whether a V8 value is a DOM Event wrapper. - static bool isDOMEventWrapper(v8::Handle<v8::Value>); - - static v8::Handle<v8::Value> convertStyleSheetToV8Object(StyleSheet*); - static v8::Handle<v8::Value> convertCSSValueToV8Object(CSSValue*); - static v8::Handle<v8::Value> convertCSSRuleToV8Object(CSSRule*); - // Returns the JS wrapper of a window object, initializes the environment - // of the window frame if needed. - static v8::Handle<v8::Value> convertWindowToV8Object(DOMWindow*); - static v8::Handle<v8::Value> convertNamedNodeMapToV8Object(NamedNodeMap*); - -#if ENABLE(SVG) - static v8::Handle<v8::Value> convertSVGElementInstanceToV8Object(SVGElementInstance*); - static v8::Handle<v8::Value> convertSVGObjectWithContextToV8Object(V8ClassIndex::V8WrapperType, void*); -#endif - #if ENABLE(3D_CANVAS) static void setIndexedPropertiesToExternalArray(v8::Handle<v8::Object>, int, void*, int); #endif - - private: // Set hidden references in a DOMWindow object of a frame. static void setHiddenWindowReference(Frame*, const int internalIndex, v8::Handle<v8::Object>); - static V8ClassIndex::V8WrapperType htmlElementType(HTMLElement*); -#if ENABLE(SVG) - static V8ClassIndex::V8WrapperType svgElementType(SVGElement*); -#endif - - // The first V8WrapperType specifies the function descriptor - // used to create JS object. The second V8WrapperType specifies - // the actual type of the void* for type casting. - // For example, a HTML element has HTMLELEMENT for the first V8WrapperType, but always - // use NODE as the second V8WrapperType. JS wrapper stores the second - // V8WrapperType and the void* as internal fields. - static v8::Local<v8::Object> instantiateV8Object(V8ClassIndex::V8WrapperType descType, V8ClassIndex::V8WrapperType cptrType, void* impl) - { - return instantiateV8Object(NULL, descType, cptrType, impl); - } + static v8::Local<v8::Object> instantiateV8Object(V8Proxy* proxy, V8ClassIndex::V8WrapperType type, void* impl); - static v8::Local<v8::Object> instantiateV8Object(V8Proxy*, V8ClassIndex::V8WrapperType, V8ClassIndex::V8WrapperType, void*); + static v8::Handle<v8::Object> getWrapper(Node*); }; } diff --git a/WebCore/bindings/v8/V8NodeFilterCondition.cpp b/WebCore/bindings/v8/V8NodeFilterCondition.cpp index 9f57a44..a8868b5 100644 --- a/WebCore/bindings/v8/V8NodeFilterCondition.cpp +++ b/WebCore/bindings/v8/V8NodeFilterCondition.cpp @@ -34,6 +34,7 @@ #include "Node.h" #include "NodeFilter.h" #include "ScriptState.h" +#include "V8Node.h" #include "V8Proxy.h" #include <wtf/OwnArrayPtr.h> @@ -69,7 +70,7 @@ short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global(); v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(m_filter); OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[1]); - args[0] = V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node); + args[0] = toV8(node); V8Proxy* proxy = V8Proxy::retrieve(); ASSERT(proxy); diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp index 7ed1c46..b0a47b8 100644 --- a/WebCore/bindings/v8/V8Proxy.cpp +++ b/WebCore/bindings/v8/V8Proxy.cpp @@ -45,12 +45,17 @@ #include "V8BindingState.h" #include "V8Collection.h" #include "V8ConsoleMessage.h" -#include "V8CustomBinding.h" +#include "V8DOMCoreException.h" #include "V8DOMMap.h" #include "V8DOMWindow.h" +#include "V8EventException.h" #include "V8HiddenPropertyName.h" #include "V8Index.h" #include "V8IsolatedContext.h" +#include "V8RangeException.h" +#include "V8SVGException.h" +#include "V8XMLHttpRequestException.h" +#include "V8XPathException.h" #include "WorkerContextExecutionProxy.h" #include <algorithm> @@ -656,25 +661,25 @@ void V8Proxy::setDOMException(int exceptionCode) v8::Handle<v8::Value> exception; switch (description.type) { case DOMExceptionType: - exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMCOREEXCEPTION, DOMCoreException::create(description)); + exception = toV8(DOMCoreException::create(description)); break; case RangeExceptionType: - exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::RANGEEXCEPTION, RangeException::create(description)); + exception = toV8(RangeException::create(description)); break; case EventExceptionType: - exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::EVENTEXCEPTION, EventException::create(description)); + exception = toV8(EventException::create(description)); break; case XMLHttpRequestExceptionType: - exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XMLHTTPREQUESTEXCEPTION, XMLHttpRequestException::create(description)); + exception = toV8(XMLHttpRequestException::create(description)); break; #if ENABLE(SVG) case SVGExceptionType: - exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGEXCEPTION, SVGException::create(description)); + exception = toV8(SVGException::create(description)); break; #endif #if ENABLE(XPATH) case XPathExceptionType: - exception = V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHEXCEPTION, XPathException::create(description)); + exception = toV8(XPathException::create(description)); break; #endif } diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h index 6f6470e..9aba723 100644 --- a/WebCore/bindings/v8/V8Proxy.h +++ b/WebCore/bindings/v8/V8Proxy.h @@ -191,7 +191,9 @@ namespace WebCore { setSVGContext(object.get(), context); return object; } - static void* withSVGContext(void* object, SVGElement* context) + + template <typename T> + static T* withSVGContext(T* object, SVGElement* context) { setSVGContext(object, context); return object; diff --git a/WebCore/bindings/v8/WorkerContextExecutionProxy.h b/WebCore/bindings/v8/WorkerContextExecutionProxy.h index 3b8ab9e..b5e6afb 100644 --- a/WebCore/bindings/v8/WorkerContextExecutionProxy.h +++ b/WebCore/bindings/v8/WorkerContextExecutionProxy.h @@ -95,6 +95,11 @@ namespace WebCore { static v8::Handle<v8::Value> convertEventTargetToV8Object(EventTarget*); static v8::Handle<v8::Value> convertWorkerContextToV8Object(WorkerContext*); + static v8::Local<v8::Object> toV8(V8ClassIndex::V8WrapperType type, void* impl) + { + return toV8(type, type, impl); + } + private: void initV8IfNeeded(); void initContextIfNeeded(); diff --git a/WebCore/bindings/v8/custom/V8BarInfoCustom.cpp b/WebCore/bindings/v8/custom/V8BarInfoCustom.cpp new file mode 100644 index 0000000..44f0b62 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8BarInfoCustom.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8BarInfo.h" + +#include "V8DOMWindow.h" +#include "V8DOMWrapper.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(BarInfo* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (wrapper.IsEmpty()) { + wrapper = V8BarInfo::wrap(impl); + if (!wrapper.IsEmpty()) { + Frame* frame = impl->frame(); + switch (impl->type()) { + case BarInfo::Locationbar: + V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::locationbarIndex, wrapper); + break; + case BarInfo::Menubar: + V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::menubarIndex, wrapper); + break; + case BarInfo::Personalbar: + V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::personalbarIndex, wrapper); + break; + case BarInfo::Scrollbars: + V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::scrollbarsIndex, wrapper); + break; + case BarInfo::Statusbar: + V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::statusbarIndex, wrapper); + break; + case BarInfo::Toolbar: + V8DOMWrapper::setHiddenWindowReference(frame, V8DOMWindow::toolbarIndex, wrapper); + break; + } + } + } + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp b/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp new file mode 100644 index 0000000..90a111c --- /dev/null +++ b/WebCore/bindings/v8/custom/V8CSSRuleCustom.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8CSSRule.h" + +#include "V8CSSCharsetRule.h" +#include "V8CSSFontFaceRule.h" +#include "V8CSSImportRule.h" +#include "V8CSSMediaRule.h" +#include "V8CSSPageRule.h" +#include "V8CSSStyleRule.h" +#include "V8CSSVariablesRule.h" +#include "V8WebKitCSSKeyframeRule.h" +#include "V8WebKitCSSKeyframesRule.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(CSSRule* impl) +{ + if (!impl) + return v8::Null(); + switch (impl->type()) { + case CSSRule::STYLE_RULE: + return toV8(static_cast<CSSStyleRule*>(impl)); + case CSSRule::CHARSET_RULE: + return toV8(static_cast<CSSCharsetRule*>(impl)); + case CSSRule::IMPORT_RULE: + return toV8(static_cast<CSSImportRule*>(impl)); + case CSSRule::MEDIA_RULE: + return toV8(static_cast<CSSMediaRule*>(impl)); + case CSSRule::FONT_FACE_RULE: + return toV8(static_cast<CSSFontFaceRule*>(impl)); + case CSSRule::PAGE_RULE: + return toV8(static_cast<CSSPageRule*>(impl)); + case CSSRule::VARIABLES_RULE: + return toV8(static_cast<CSSVariablesRule*>(impl)); + case CSSRule::WEBKIT_KEYFRAME_RULE: + return toV8(static_cast<WebKitCSSKeyframeRule*>(impl)); + case CSSRule::WEBKIT_KEYFRAMES_RULE: + return toV8(static_cast<WebKitCSSKeyframesRule*>(impl)); + } + return V8CSSRule::wrap(impl); +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp b/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp new file mode 100644 index 0000000..5dcc966 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8CSSStyleSheetCustom.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8CSSStyleSheet.h" + +#include "V8Node.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(CSSStyleSheet* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8CSSStyleSheet::wrap(impl); + // Add a hidden reference from stylesheet object to its owner node. + Node* ownerNode = impl->ownerNode(); + if (ownerNode && !wrapper.IsEmpty()) + wrapper->SetInternalField(V8CSSStyleSheet::ownerNodeIndex, toV8(ownerNode)); + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp b/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp new file mode 100644 index 0000000..9e692ad --- /dev/null +++ b/WebCore/bindings/v8/custom/V8CSSValueCustom.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8CSSValue.h" + +#include "V8CSSPrimitiveValue.h" +#include "V8CSSValueList.h" +#include "V8SVGColor.h" +#include "V8SVGPaint.h" +#include "V8WebKitCSSTransformValue.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(CSSValue* impl) +{ + if (!impl) + return v8::Null(); + if (impl->isWebKitCSSTransformValue()) + return toV8(static_cast<WebKitCSSTransformValue*>(impl)); + if (impl->isValueList()) + return toV8(static_cast<CSSValueList*>(impl)); + if (impl->isPrimitiveValue()) + return toV8(static_cast<CSSPrimitiveValue*>(impl)); + if (impl->isSVGPaint()) + return toV8(static_cast<SVGPaint*>(impl)); + if (impl->isSVGColor()) + return toV8(static_cast<SVGColor*>(impl)); + return V8CSSValue::wrap(impl); +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp new file mode 100644 index 0000000..cd638ce --- /dev/null +++ b/WebCore/bindings/v8/custom/V8CanvasPixelArrayCustom.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8CanvasPixelArray.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(CanvasPixelArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8CanvasPixelArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToPixelData(impl->data()->data(), impl->length()); + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp index b45ef35..70be193 100644 --- a/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp @@ -50,13 +50,13 @@ namespace WebCore { -static v8::Handle<v8::Value> toV8(CanvasStyle* style) +static v8::Handle<v8::Value> toV8Object(CanvasStyle* style) { if (style->canvasGradient()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASGRADIENT, style->canvasGradient()); + return toV8(style->canvasGradient()); if (style->canvasPattern()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, style->canvasPattern()); + return toV8(style->canvasPattern()); return v8String(style->color()); } @@ -78,7 +78,7 @@ static PassRefPtr<CanvasStyle> toCanvasStyle(v8::Handle<v8::Value> value) v8::Handle<v8::Value> V8CanvasRenderingContext2D::strokeStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder()); - return toV8(impl->strokeStyle()); + return toV8Object(impl->strokeStyle()); } void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -90,7 +90,7 @@ void V8CanvasRenderingContext2D::strokeStyleAccessorSetter(v8::Local<v8::String> v8::Handle<v8::Value> V8CanvasRenderingContext2D::fillStyleAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { CanvasRenderingContext2D* impl = V8CanvasRenderingContext2D::toNative(info.Holder()); - return toV8(impl->fillStyle()); + return toV8Object(impl->fillStyle()); } void V8CanvasRenderingContext2D::fillStyleAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -348,7 +348,7 @@ v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8 V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release()); + return toV8(pattern.release()); } if (V8HTMLCanvasElement::HasInstance(arg)) { @@ -359,7 +359,7 @@ v8::Handle<v8::Value> V8CanvasRenderingContext2D::createPatternCallback(const v8 V8Proxy::setDOMException(ec); return notHandledByInterceptor(); } - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASPATTERN, pattern.release()); + return toV8(pattern.release()); } V8Proxy::setDOMException(TYPE_MISMATCH_ERR); diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp index 5e9a8f2..19300b0 100644 --- a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp @@ -28,6 +28,7 @@ #include "Frame.h" #include "V8CustomVoidCallback.h" // For invokeCallback +#include "V8Geoposition.h" namespace WebCore { @@ -53,7 +54,7 @@ void V8CustomPositionCallback::handleEvent(Geoposition* position) v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8DOMWrapper::convertToV8Object(V8ClassIndex::GEOPOSITION, position) + toV8(position) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp index 117f374..c6c632b 100644 --- a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp @@ -28,6 +28,7 @@ #include "Frame.h" #include "V8CustomVoidCallback.h" // For invokeCallback +#include "V8PositionError.h" namespace WebCore { @@ -53,7 +54,7 @@ void V8CustomPositionErrorCallback::handleEvent(PositionError* error) v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8DOMWrapper::convertToV8Object(V8ClassIndex::POSITIONERROR, error) + toV8(error) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp index 64abdc4..d30b95a 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp @@ -36,6 +36,8 @@ #include "Frame.h" #include "V8CustomVoidCallback.h" +#include "V8SQLResultSet.h" +#include "V8SQLTransaction.h" namespace WebCore { @@ -61,8 +63,8 @@ void V8CustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLR v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction), - V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLRESULTSET, resultSet) + toV8(transaction), + toV8(resultSet) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp index 1af3562..84a3b96 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp @@ -36,6 +36,8 @@ #include "Frame.h" #include "V8CustomVoidCallback.h" +#include "V8SQLError.h" +#include "V8SQLTransaction.h" namespace WebCore { @@ -61,8 +63,8 @@ bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction), - V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error) + toV8(transaction), + toV8(error) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp index 2cef6b3..68002d7 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp @@ -36,6 +36,7 @@ #include "Frame.h" #include "V8CustomVoidCallback.h" +#include "V8SQLTransaction.h" namespace WebCore { @@ -62,7 +63,7 @@ void V8CustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bo v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLTRANSACTION, transaction) + toV8(transaction) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp index 1a0939d..cf5a0ef 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp @@ -36,6 +36,7 @@ #include "Frame.h" #include "V8CustomVoidCallback.h" +#include "V8SQLError.h" namespace WebCore { @@ -61,7 +62,7 @@ void V8CustomSQLTransactionErrorCallback::handleEvent(SQLError* error) v8::Context::Scope scope(context); v8::Handle<v8::Value> argv[] = { - V8DOMWrapper::convertToV8Object(V8ClassIndex::SQLERROR, error) + toV8(error) }; // Protect the frame until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp b/WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp new file mode 100644 index 0000000..0c9e745 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8DOMSelectionCustom.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8DOMSelection.h" + +#include "V8DOMWindow.h" +#include "V8DOMWrapper.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(DOMSelection* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (wrapper.IsEmpty()) { + wrapper = V8DOMSelection::wrap(impl); + V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::domSelectionIndex, wrapper); + } + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index 2933b4d..ba6c738 100644 --- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -57,7 +57,9 @@ #include "V8BindingState.h" #include "V8CustomBinding.h" #include "V8CustomEventListener.h" +#include "V8HTMLCollection.h" #include "V8MessagePortCustom.h" +#include "V8Node.h" #include "V8Proxy.h" #include "V8Utilities.h" #if ENABLE(WEB_SOCKETS) @@ -78,8 +80,15 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl if (argumentCount < 1) return v8::Undefined(); - v8::Handle<v8::Value> function = args[0]; + DOMWindow* imp = V8DOMWindow::toNative(args.Holder()); + ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document()); + + if (!scriptContext) { + V8Proxy::setDOMException(INVALID_ACCESS_ERR); + return v8::Undefined(); + } + v8::Handle<v8::Value> function = args[0]; WebCore::String functionString; if (!function->IsFunction()) { if (function->IsString()) @@ -104,16 +113,9 @@ v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args, bool singl if (argumentCount >= 2) timeout = args[1]->Int32Value(); - DOMWindow* imp = V8DOMWindow::toNative(args.Holder()); - if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true)) return v8::Undefined(); - ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document()); - - if (!scriptContext) - return v8::Undefined(); - int id; if (function->IsFunction()) { int paramCount = argumentCount >= 2 ? argumentCount - 2 : 0; @@ -708,7 +710,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args) frame->redirectScheduler()->scheduleLocationChange(completedUrl, referrer, false, userGesture); } - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return toV8(frame->domWindow()); } // In the case of a named frame or a new window, we'll use the @@ -768,7 +770,7 @@ v8::Handle<v8::Value> V8DOMWindow::openCallback(const v8::Arguments& args) if (!frame) return v8::Undefined(); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return toV8(frame->domWindow()); } @@ -786,7 +788,7 @@ v8::Handle<v8::Value> V8DOMWindow::indexedPropertyGetter(uint32_t index, const v Frame* child = frame->tree()->child(index); if (child) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); + return toV8(child->domWindow()); return notHandledByInterceptor(); } @@ -809,7 +811,7 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam AtomicString propName = v8StringToAtomicWebCoreString(name); Frame* child = frame->tree()->child(propName); if (child) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow()); + return toV8(child->domWindow()); // Search IDL functions defined in the prototype v8::Handle<v8::Value> result = info.Holder()->GetRealNamedProperty(name); @@ -824,8 +826,8 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam RefPtr<HTMLCollection> items = doc->windowNamedItems(propName); if (items->length() >= 1) { if (items->length() == 1) - return V8DOMWrapper::convertNodeToV8Object(items->firstItem()); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release()); + return toV8(items->firstItem()); + return toV8(items.release()); } } } @@ -925,4 +927,37 @@ bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t inde return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false); } +v8::Handle<v8::Value> toV8(DOMWindow* window) +{ + if (!window) + return v8::Null(); + // Initializes environment of a frame, and return the global object + // of the frame. + Frame* frame = window->frame(); + if (!frame) + return v8::Handle<v8::Object>(); + + // Special case: Because of evaluateInIsolatedWorld() one DOMWindow can have + // multiple contexts and multiple global objects associated with it. When + // code running in one of those contexts accesses the window object, we + // want to return the global object associated with that context, not + // necessarily the first global object associated with that DOMWindow. + v8::Handle<v8::Context> currentContext = v8::Context::GetCurrent(); + v8::Handle<v8::Object> currentGlobal = currentContext->Global(); + v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, currentGlobal); + if (!windowWrapper.IsEmpty()) { + if (V8DOMWindow::toNative(windowWrapper) == window) + return currentGlobal; + } + + // Otherwise, return the global object associated with this frame. + v8::Handle<v8::Context> context = V8Proxy::context(frame); + if (context.IsEmpty()) + return v8::Handle<v8::Object>(); + + v8::Handle<v8::Object> global = context->Global(); + ASSERT(!global.IsEmpty()); + return global; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp index 8980cfe..58e5d01 100644 --- a/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DataGridColumnListCustom.cpp @@ -57,7 +57,7 @@ NAMED_PROPERTY_GETTER(DataGridColumnList) DataGridColumn* result = imp->itemWithName(toWebCoreString(name)); if (!result) return notHandledByInterceptor(); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DATAGRIDCOLUMN, result); + return toV8(result); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp index 9cb8ae1..d8dde7a 100644 --- a/WebCore/bindings/v8/custom/V8DocumentCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DocumentCustom.cpp @@ -37,16 +37,23 @@ #include "Node.h" #include "XPathNSResolver.h" #include "XPathResult.h" -#include "CanvasRenderingContext.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8CanvasRenderingContext2D.h" #include "V8CustomXPathNSResolver.h" +#include "V8DOMImplementation.h" +#include "V8HTMLDocument.h" +#include "V8IsolatedContext.h" #include "V8Node.h" #include "V8Proxy.h" +<<<<<<< HEAD // ANDROID // TODO: Upstream to webkit.org #if ENABLE(XPATH) +======= +#include "V8SVGDocument.h" +#include "V8WebGLRenderingContext.h" +>>>>>>> webkit.org at r54340 #include "V8XPathNSResolver.h" #include "V8XPathResult.h" #endif @@ -86,7 +93,7 @@ v8::Handle<v8::Value> V8Document::evaluateCallback(const v8::Arguments& args) if (ec) return throwError(ec); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::XPATHRESULT, result.release()); + return toV8(result.release()); } #endif @@ -103,10 +110,10 @@ v8::Handle<v8::Value> V8Document::getCSSCanvasContextCallback(const v8::Argument if (!result) return v8::Undefined(); if (result->is2d()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result); + return toV8(static_cast<CanvasRenderingContext2D*>(result)); #if ENABLE(3D_CANVAS) else if (result->is3d()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result); + return toV8(static_cast<WebGLRenderingContext*>(result)); #endif // ENABLE(3D_CANVAS) ASSERT_NOT_REACHED(); return v8::Undefined(); @@ -132,7 +139,7 @@ v8::Handle<v8::Value> V8Document::implementationAccessorGetter(v8::Local<v8::Str // Generate a wrapper. Document* document = V8Document::toNative(info.Holder()); - v8::Handle<v8::Value> wrapper = V8DOMWrapper::convertDOMImplementationToV8Object(document->implementation()); + v8::Handle<v8::Value> wrapper = toV8(document->implementation()); // Store the wrapper in the internal field. info.Holder()->SetInternalField(implementationIndex, wrapper); @@ -140,4 +147,20 @@ v8::Handle<v8::Value> V8Document::implementationAccessorGetter(v8::Local<v8::Str return wrapper; } +v8::Handle<v8::Value> toV8(Document* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + if (impl->isHTMLDocument()) + return toV8(static_cast<HTMLDocument*>(impl), forceNewObject); + if (impl->isSVGDocument()) + return toV8(static_cast<SVGDocument*>(impl), forceNewObject); + v8::Handle<v8::Value> wrapper = V8Document::wrap(impl, forceNewObject); + if (!V8IsolatedContext::getEntered()) { + if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame())) + proxy->windowShell()->updateDocumentWrapper(wrapper); + } + return wrapper; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp index 8dc4672..f86054b 100644 --- a/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp @@ -27,8 +27,7 @@ #include "DOMWindow.h" #include "Frame.h" #include "V8Binding.h" -#include "V8CustomBinding.h" -#include "V8Document.h" +#include "V8Location.h" #include "V8Proxy.h" namespace WebCore { @@ -40,7 +39,7 @@ v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> n return v8::Null(); DOMWindow* window = document->frame()->domWindow(); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::LOCATION, window->location()); + return toV8(window->location()); } void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/WebCore/bindings/v8/custom/V8ElementCustom.cpp b/WebCore/bindings/v8/custom/V8ElementCustom.cpp index 0f13f9d..b420f6a 100644 --- a/WebCore/bindings/v8/custom/V8ElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ElementCustom.cpp @@ -44,7 +44,9 @@ #include "V8Binding.h" #include "V8BindingState.h" #include "V8CustomBinding.h" +#include "V8HTMLElement.h" #include "V8Proxy.h" +#include "V8SVGElement.h" #include <wtf/RefPtr.h> @@ -85,7 +87,7 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeCallback(const v8::Arguments& a if (ec) throwError(ec); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } v8::Handle<v8::Value> V8Element::setAttributeNSCallback(const v8::Arguments& args) @@ -124,7 +126,17 @@ v8::Handle<v8::Value> V8Element::setAttributeNodeNSCallback(const v8::Arguments& if (ec) throwError(ec); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } +v8::Handle<v8::Value> toV8(Element* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + if (impl->isHTMLElement()) + return toV8(static_cast<HTMLElement*>(impl), forceNewObject); + if (impl->isSVGElement()) + return toV8(static_cast<SVGElement*>(impl), forceNewObject); + return V8Element::wrap(impl, forceNewObject); +} } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp index 65cd41e..a13603e 100644 --- a/WebCore/bindings/v8/custom/V8EventCustom.cpp +++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp @@ -34,10 +34,28 @@ #include "Clipboard.h" #include "ClipboardEvent.h" #include "Event.h" -#include "MouseEvent.h" +#include "V8BeforeLoadEvent.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8Clipboard.h" +#include "V8CompositionEvent.h" +#include "V8ErrorEvent.h" +#include "V8KeyboardEvent.h" +#include "V8MessageEvent.h" +#include "V8MouseEvent.h" +#include "V8MutationEvent.h" +#include "V8OverflowEvent.h" +#include "V8PageTransitionEvent.h" +#include "V8PopStateEvent.h" +#include "V8ProgressEvent.h" #include "V8Proxy.h" +#include "V8SVGZoomEvent.h" +#include "V8StorageEvent.h" +#include "V8TextEvent.h" +#include "V8UIEvent.h" +#include "V8WebKitAnimationEvent.h" +#include "V8WebKitTransitionEvent.h" +#include "V8WheelEvent.h" +#include "V8XMLHttpRequestProgressEvent.h" namespace WebCore { @@ -52,7 +70,7 @@ v8::Handle<v8::Value> V8Event::dataTransferAccessorGetter(v8::Local<v8::String> Event* event = V8Event::toNative(info.Holder()); if (event->isDragEvent()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<MouseEvent*>(event)->clipboard()); + return toV8(static_cast<MouseEvent*>(event)->clipboard()); return v8::Undefined(); } @@ -62,9 +80,61 @@ v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String> Event* event = V8Event::toNative(info.Holder()); if (event->isClipboardEvent()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CLIPBOARD, static_cast<ClipboardEvent*>(event)->clipboard()); + return toV8(static_cast<ClipboardEvent*>(event)->clipboard()); return v8::Undefined(); } +v8::Handle<v8::Value> toV8(Event* impl) +{ + if (!impl) + return v8::Null(); + if (impl->isUIEvent()) { + if (impl->isKeyboardEvent()) + return toV8(static_cast<KeyboardEvent*>(impl)); + if (impl->isTextEvent()) + return toV8(static_cast<TextEvent*>(impl)); + if (impl->isMouseEvent()) + return toV8(static_cast<MouseEvent*>(impl)); + if (impl->isWheelEvent()) + return toV8(static_cast<WheelEvent*>(impl)); +#if ENABLE(SVG) + if (impl->isSVGZoomEvent()) + return toV8(static_cast<SVGZoomEvent*>(impl)); +#endif + if (impl->isCompositionEvent()) + return toV8(static_cast<CompositionEvent*>(impl)); + return toV8(static_cast<UIEvent*>(impl)); + } + if (impl->isMutationEvent()) + return toV8(static_cast<MutationEvent*>(impl)); + if (impl->isOverflowEvent()) + return toV8(static_cast<OverflowEvent*>(impl)); + if (impl->isMessageEvent()) + return toV8(static_cast<MessageEvent*>(impl)); + if (impl->isPageTransitionEvent()) + return toV8(static_cast<PageTransitionEvent*>(impl)); + if (impl->isPopStateEvent()) + return toV8(static_cast<PopStateEvent*>(impl)); + if (impl->isProgressEvent()) { + if (impl->isXMLHttpRequestProgressEvent()) + return toV8(static_cast<XMLHttpRequestProgressEvent*>(impl)); + return toV8(static_cast<ProgressEvent*>(impl)); + } + if (impl->isWebKitAnimationEvent()) + return toV8(static_cast<WebKitAnimationEvent*>(impl)); + if (impl->isWebKitTransitionEvent()) + return toV8(static_cast<WebKitTransitionEvent*>(impl)); +#if ENABLE(WORKERS) + if (impl->isErrorEvent()) + return toV8(static_cast<ErrorEvent*>(impl)); +#endif +#if ENABLE(DOM_STORAGE) + if (impl->isStorageEvent()) + return toV8(static_cast<StorageEvent*>(impl)); +#endif + if (impl->isBeforeLoadEvent()) + return toV8(static_cast<BeforeLoadEvent*>(impl)); + return V8Event::wrap(impl); +} } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp index c34d9e7..88b3a9d 100644 --- a/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLAllCollectionCustom.cpp @@ -36,6 +36,8 @@ #include "V8Binding.h" #include "V8CustomBinding.h" #include "V8NamedNodesCollection.h" +#include "V8Node.h" +#include "V8NodeList.h" #include "V8Proxy.h" namespace WebCore { @@ -49,10 +51,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, Atomic return v8::Handle<v8::Value>(); if (namedItems.size() == 1) - return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release()); + return toV8(namedItems.at(0).release()); NodeList* list = new V8NamedNodesCollection(namedItems); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list); + return toV8(list); } static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v8::Value> argument) @@ -68,7 +70,7 @@ static v8::Handle<v8::Value> getItem(HTMLAllCollection* collection, v8::Handle<v } RefPtr<Node> result = collection->item(index->Uint32Value()); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } v8::Handle<v8::Value> V8HTMLAllCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -130,7 +132,7 @@ v8::Handle<v8::Value> V8HTMLAllCollection::callAsFunctionCallback(const v8::Argu Node* node = imp->namedItem(name); while (node) { if (!current) - return V8DOMWrapper::convertNodeToV8Object(node); + return toV8(node); node = imp->nextNamedItem(name); current--; diff --git a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp index e634003..28b0a99 100644 --- a/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLAudioElementConstructor.cpp @@ -36,6 +36,7 @@ #include "Frame.h" #include "HTMLNames.h" #include "V8Binding.h" +#include "V8Document.h" #include "V8HTMLAudioElement.h" #include "V8Proxy.h" @@ -78,7 +79,7 @@ v8::Handle<v8::Value> V8Custom::v8HTMLAudioElementConstructorCallback(const v8:: // Make sure the document is added to the DOM Node map. Otherwise, the HTMLAudioElement instance // may end up being the only node in the map and get garbage-ccollected prematurely. - V8DOMWrapper::convertNodeToV8Object(document); + toV8(document); RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document); audio->setAutobuffer(true); diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp index 0d1ff44..54a003c 100644 --- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp @@ -36,9 +36,10 @@ #include "HTMLCanvasElement.h" #include "WebGLContextAttributes.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8CanvasRenderingContext2D.h" #include "V8Node.h" #include "V8Proxy.h" +#include "V8WebGLRenderingContext.h" namespace WebCore { @@ -77,10 +78,10 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument if (!result) return v8::Undefined(); if (result->is2d()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::CANVASRENDERINGCONTEXT2D, result); + return toV8(static_cast<CanvasRenderingContext2D*>(result)); #if ENABLE(3D_CANVAS) else if (result->is3d()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERINGCONTEXT, result); + return toV8(static_cast<WebGLRenderingContext*>(result)); #endif ASSERT_NOT_REACHED(); return v8::Undefined(); diff --git a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp index 8bb3c3a..29ff6eb 100644 --- a/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLCollectionCustom.cpp @@ -34,7 +34,10 @@ #include "HTMLCollection.h" #include "V8Binding.h" #include "V8CustomBinding.h" +#include "V8HTMLAllCollection.h" #include "V8NamedNodesCollection.h" +#include "V8Node.h" +#include "V8NodeList.h" #include "V8Proxy.h" namespace WebCore { @@ -48,10 +51,10 @@ static v8::Handle<v8::Value> getNamedItems(HTMLCollection* collection, AtomicStr return v8::Handle<v8::Value>(); if (namedItems.size() == 1) - return V8DOMWrapper::convertNodeToV8Object(namedItems.at(0).release()); + return toV8(namedItems.at(0).release()); NodeList* list = new V8NamedNodesCollection(namedItems); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list); + return toV8(list); } static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8::Value> argument) @@ -67,7 +70,7 @@ static v8::Handle<v8::Value> getItem(HTMLCollection* collection, v8::Handle<v8:: } RefPtr<Node> result = collection->item(index->Uint32Value()); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } v8::Handle<v8::Value> V8HTMLCollection::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -129,7 +132,7 @@ v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Argumen Node* node = imp->namedItem(name); while (node) { if (!current) - return V8DOMWrapper::convertNodeToV8Object(node); + return toV8(node); node = imp->nextNamedItem(name); current--; @@ -138,4 +141,11 @@ v8::Handle<v8::Value> V8HTMLCollection::callAsFunctionCallback(const v8::Argumen return v8::Undefined(); } +v8::Handle<v8::Value> toV8(HTMLCollection* impl) +{ + if (impl->type() == DocAll) + return toV8(static_cast<HTMLAllCollection*>(impl)); + return V8HTMLCollection::wrap(impl); +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp index 13243ef..6478e07 100644 --- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp @@ -38,6 +38,11 @@ #include "HTMLIFrameElement.h" #include "HTMLNames.h" #include "V8Binding.h" +#include "V8DOMWindow.h" +#include "V8HTMLAllCollection.h" +#include "V8HTMLCollection.h" +#include "V8IsolatedContext.h" +#include "V8Node.h" #include "V8Proxy.h" #include <wtf/RefPtr.h> #include <wtf/StdLibExtras.h> @@ -91,12 +96,12 @@ v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String> Node* node = items->firstItem(); Frame* frame = 0; if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame())) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return toV8(frame->domWindow()); - return V8DOMWrapper::convertNodeToV8Object(node); + return toV8(node); } - return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, items.release()); + return toV8(items.release()); } v8::Handle<v8::Value> V8HTMLDocument::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo &info) @@ -181,10 +186,9 @@ v8::Handle<v8::Value> V8HTMLDocument::openCallback(const v8::Arguments& args) v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.HTMLDocument.all._get"); - v8::HandleScope scope; v8::Handle<v8::Object> holder = info.Holder(); HTMLDocument* htmlDocument = V8HTMLDocument::toNative(holder); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::HTMLCOLLECTION, htmlDocument->all()); + return toV8(htmlDocument->all()); } void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -195,4 +199,22 @@ void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8: info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, value); } +v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8HTMLDocument::wrap(impl, forceNewObject); + if (!V8IsolatedContext::getEntered()) { + if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame())) + proxy->windowShell()->updateDocumentWrapper(wrapper); + } + // Create marker object and insert it in two internal fields. + // This is used to implement temporary shadowing of document.all. + ASSERT(wrapper->InternalFieldCount() == V8HTMLDocument::internalFieldCount); + v8::Local<v8::Object> marker = v8::Object::New(); + wrapper->SetInternalField(V8HTMLDocument::markerIndex, marker); + wrapper->SetInternalField(V8HTMLDocument::shadowIndex, marker); + return wrapper; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp new file mode 100644 index 0000000..0eb55e9 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8HTMLElementCustom.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8HTMLElement.h" + +#include "V8HTMLElementWrapperFactory.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(HTMLElement* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + return createV8HTMLWrapper(impl, forceNewObject); +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp index d819e9b..0a9e8dd 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp @@ -34,8 +34,9 @@ #include "HTMLCollection.h" #include "HTMLFormElement.h" #include "V8Binding.h" -#include "V8CustomBinding.h" #include "V8NamedNodesCollection.h" +#include "V8Node.h" +#include "V8NodeList.h" #include "V8Proxy.h" namespace WebCore { @@ -48,7 +49,7 @@ v8::Handle<v8::Value> V8HTMLFormElement::indexedPropertyGetter(uint32_t index, c RefPtr<Node> formElement = form->elements()->item(index); if (!formElement) return notHandledByInterceptor(); - return V8DOMWrapper::convertNodeToV8Object(formElement.release()); + return toV8(formElement.release()); } v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -74,10 +75,10 @@ v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin ASSERT(!elements.isEmpty()); if (elements.size() == 1) - return V8DOMWrapper::convertNodeToV8Object(elements.at(0).release()); + return toV8(elements.at(0).release()); NodeList* collection = new V8NamedNodesCollection(elements); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, collection); + return toV8(collection); } v8::Handle<v8::Value> V8HTMLFormElement::submitCallback(const v8::Arguments& args) diff --git a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp index 214b11e..6a45be7 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp @@ -40,7 +40,7 @@ #include "Node.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8DOMWindow.h" #include "V8Proxy.h" namespace WebCore { @@ -55,7 +55,7 @@ v8::Handle<v8::Value> V8HTMLFrameSetElement::namedPropertyGetter(v8::Local<v8::S if (!doc) return v8::Undefined(); if (Frame* frame = doc->frame()) - return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, frame->domWindow()); + return toV8(frame->domWindow()); } return notHandledByInterceptor(); } diff --git a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp index 57efa34..2c28fa5 100644 --- a/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp @@ -36,6 +36,7 @@ #include "Frame.h" #include "HTMLNames.h" #include "V8Binding.h" +#include "V8Document.h" #include "V8HTMLImageElement.h" #include "V8Proxy.h" @@ -78,7 +79,7 @@ v8::Handle<v8::Value> V8Custom::v8HTMLImageElementConstructorCallback(const v8:: // Make sure the document is added to the DOM Node map. Otherwise, the HTMLImageElement instance // may end up being the only node in the map and get garbage-ccollected prematurely. - V8DOMWrapper::convertNodeToV8Object(document); + toV8(document); RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document); if (args.Length() > 0) { diff --git a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp index c060df7..81bc287 100644 --- a/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLOptionsCollectionCustom.cpp @@ -37,9 +37,9 @@ #include "V8Binding.h" #include "V8Collection.h" -#include "V8CustomBinding.h" #include "V8HTMLOptionElement.h" #include "V8HTMLSelectElementCustom.h" +#include "V8Node.h" #include "V8Proxy.h" namespace WebCore { @@ -123,7 +123,7 @@ v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertyGetter(uint32_t in if (!result) return notHandledByInterceptor(); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } v8::Handle<v8::Value> V8HTMLOptionsCollection::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp index 0904b3e..d0d8dac 100644 --- a/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLSelectElementCustom.cpp @@ -37,10 +37,11 @@ #include "V8Binding.h" #include "V8Collection.h" -#include "V8CustomBinding.h" #include "V8HTMLOptionElement.h" #include "V8HTMLSelectElement.h" #include "V8NamedNodesCollection.h" +#include "V8Node.h" +#include "V8NodeList.h" #include "V8Proxy.h" namespace WebCore { @@ -67,21 +68,20 @@ v8::Handle<v8::Value> V8HTMLSelectElement::namedPropertyGetter(v8::Local<v8::Str return notHandledByInterceptor(); if (items.size() == 1) - return V8DOMWrapper::convertNodeToV8Object(items.at(0).release()); + return toV8(items.at(0).release()); NodeList* list = new V8NamedNodesCollection(items); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODELIST, list); + return toV8(list); } v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info) { ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); - ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE); RefPtr<Node> result = V8HTMLSelectElement::toNative(info.Holder())->item(index); if (!result) return notHandledByInterceptor(); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } v8::Handle<v8::Value> V8HTMLSelectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info) diff --git a/WebCore/bindings/v8/custom/V8HistoryCustom.cpp b/WebCore/bindings/v8/custom/V8HistoryCustom.cpp index b857d6e..5e9c7c8 100644 --- a/WebCore/bindings/v8/custom/V8HistoryCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HistoryCustom.cpp @@ -37,6 +37,7 @@ #include "V8Binding.h" #include "V8BindingState.h" #include "V8CustomBinding.h" +#include "V8DOMWindow.h" #include "V8Proxy.h" namespace WebCore { @@ -99,4 +100,17 @@ bool V8History::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Val return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), history->frame(), false); } +v8::Handle<v8::Value> toV8(History* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (wrapper.IsEmpty()) { + wrapper = V8History::wrap(impl); + if (!wrapper.IsEmpty()) + V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::historyIndex, wrapper); + } + return wrapper; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp b/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp index 5ee9542..ccf4d0e 100644 --- a/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp +++ b/WebCore/bindings/v8/custom/V8IDBRequestCustom.cpp @@ -29,6 +29,8 @@ */ #include "config.h" + +#if ENABLE(INDEXED_DATABASE) #include "V8IDBRequest.h" #include "SerializedScriptValue.h" @@ -47,3 +49,5 @@ v8::Handle<v8::Value> V8IDBRequest::resultAccessorGetter(v8::Local<v8::String> n } } // namespace WebCore + +#endif diff --git a/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp b/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp index 66220ea..0fd182c 100644 --- a/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp +++ b/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp @@ -29,6 +29,8 @@ */ #include "config.h" + +#if ENABLE(INDEXED_DATABASE) #include "V8IndexedDatabaseRequest.h" #include "V8Binding.h" @@ -55,3 +57,5 @@ v8::Handle<v8::Value> V8IndexedDatabaseRequest::openCallback(const v8::Arguments } } // namespace WebCore + +#endif diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp index 0ddcf97..ad4ed01 100644 --- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp +++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp @@ -34,13 +34,13 @@ #include "DOMWindow.h" #include "Database.h" #include "Frame.h" +#include "InjectedScript.h" #include "InjectedScriptHost.h" #include "InspectorController.h" #include "Node.h" #include "Page.h" #include "V8Binding.h" -#include "V8CustomBinding.h" #include "V8Database.h" #include "V8Node.h" #include "V8Proxy.h" @@ -85,7 +85,7 @@ static ScriptObject createInjectedScript(const String& scriptSource, InjectedScr v8::Context::Scope contextScope(inspectedContext); // Call custom code to create InjectedScripHost wrapper specific for the context - // instead of calling V8DOMWrapper::convertToV8Object that would create the + // instead of calling toV8() that would create the // wrapper in the current context. // FIXME: make it possible to use generic bindings factory for InjectedScriptHost. v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrapper(injectedScriptHost); @@ -130,7 +130,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Argument if (!ic) return v8::Undefined(); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node); + return toV8(node); } v8::Handle<v8::Value> V8InjectedScriptHost::pushNodePathToFrontendCallback(const v8::Arguments& args) @@ -160,7 +160,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::databaseForIdCallback(const v8::Argu Database* database = host->databaseForId(args[0]->ToInt32()->Value()); if (!database) return v8::Undefined(); - return V8DOMWrapper::convertToV8Object<Database>(V8ClassIndex::DATABASE, database); + return toV8(database); } v8::Handle<v8::Value> V8InjectedScriptHost::selectDatabaseCallback(const v8::Arguments& args) @@ -194,7 +194,7 @@ v8::Handle<v8::Value> V8InjectedScriptHost::selectDOMStorageCallback(const v8::A } #endif -ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState) +InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState) { v8::HandleScope handleScope; v8::Local<v8::Context> context = inspectedScriptState->context(); @@ -208,14 +208,15 @@ ScriptObject InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptS v8::Local<v8::String> key = v8::String::New("Devtools_InjectedScript"); v8::Local<v8::Value> val = global->GetHiddenValue(key); if (!val.IsEmpty() && val->IsObject()) - return ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)); + return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val))); ASSERT(!m_injectedScriptSource.isEmpty()); ScriptObject injectedScriptObject = createInjectedScript(m_injectedScriptSource, this, inspectedScriptState, m_nextInjectedScriptId); - m_idToInjectedScript.set(m_nextInjectedScriptId, injectedScriptObject); + InjectedScript result(injectedScriptObject); + m_idToInjectedScript.set(m_nextInjectedScriptId, result); ++m_nextInjectedScriptId; global->SetHiddenValue(key, injectedScriptObject.v8Object()); - return injectedScriptObject; + return result; } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8LocationCustom.cpp b/WebCore/bindings/v8/custom/V8LocationCustom.cpp index ce816b6..7c9c529 100644 --- a/WebCore/bindings/v8/custom/V8LocationCustom.cpp +++ b/WebCore/bindings/v8/custom/V8LocationCustom.cpp @@ -43,6 +43,7 @@ #include "V8BindingState.h" #include "V8CustomBinding.h" #include "V8CustomEventListener.h" +#include "V8DOMWindow.h" #include "V8Location.h" #include "V8Utilities.h" #include "V8Proxy.h" @@ -358,5 +359,18 @@ bool V8Location::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Va return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false); } +v8::Handle<v8::Value> toV8(Location* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (wrapper.IsEmpty()) { + wrapper = V8Location::wrap(impl); + if (!wrapper.IsEmpty()) + V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::locationIndex, wrapper); + } + return wrapper; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp index 3ea8e26..4fb82ba 100644 --- a/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp +++ b/WebCore/bindings/v8/custom/V8MessageChannelConstructor.cpp @@ -35,6 +35,7 @@ #include "Frame.h" #include "MessageChannel.h" #include "V8Binding.h" +#include "V8MessagePort.h" #include "V8Proxy.h" #include "V8Utilities.h" #include "WorkerContext.h" @@ -66,8 +67,8 @@ v8::Handle<v8::Value> V8MessageChannel::constructorCallback(const v8::Arguments& // Create references from the MessageChannel wrapper to the two // MessagePort wrappers to make sure that the MessagePort wrappers // stay alive as long as the MessageChannel wrapper is around. - messageChannel->SetInternalField(V8MessageChannel::port1Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port1())); - messageChannel->SetInternalField(V8MessageChannel::port2Index, V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, obj->port2())); + messageChannel->SetInternalField(V8MessageChannel::port1Index, toV8(obj->port1())); + messageChannel->SetInternalField(V8MessageChannel::port2Index, toV8(obj->port2())); // Setup the standard wrapper object internal fields. V8DOMWrapper::setDOMWrapper(messageChannel, V8ClassIndex::MESSAGECHANNEL, obj.get()); diff --git a/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp b/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp index 9e40855..9f2c080 100644 --- a/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp +++ b/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp @@ -35,8 +35,8 @@ #include "SerializedScriptValue.h" #include "V8Binding.h" -#include "V8CustomBinding.h" #include "V8DOMWindow.h" +#include "V8MessagePort.h" #include "V8MessagePortCustom.h" #include "V8Proxy.h" @@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8MessageEvent::portsAccessorGetter(v8::Local<v8::String> v8::Local<v8::Array> portArray = v8::Array::New(ports->size()); for (size_t i = 0; i < ports->size(); ++i) - portArray->Set(v8::Integer::New(i), V8DOMWrapper::convertToV8Object(V8ClassIndex::MESSAGEPORT, (*ports)[i].get())); + portArray->Set(v8::Integer::New(i), toV8((*ports)[i].get())); return portArray; } diff --git a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp index c7fff5a..611ab94 100644 --- a/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NamedNodeMapCustom.cpp @@ -33,7 +33,8 @@ #include "NamedNodeMap.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8Element.h" +#include "V8Node.h" #include "V8Proxy.h" #include <wtf/RefPtr.h> @@ -48,7 +49,7 @@ v8::Handle<v8::Value> V8NamedNodeMap::indexedPropertyGetter(uint32_t index, cons if (!result) return notHandledByInterceptor(); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) @@ -69,7 +70,21 @@ v8::Handle<v8::Value> V8NamedNodeMap::namedPropertyGetter(v8::Local<v8::String> if (!result) return notHandledByInterceptor(); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); +} + +v8::Handle<v8::Value> toV8(NamedNodeMap* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8NamedNodeMap::wrap(impl); + // Add a hidden reference from named node map to its owner node. + Element* element = impl->element(); + if (!wrapper.IsEmpty() && element) { + v8::Handle<v8::Value> owner = toV8(element); + wrapper->SetInternalField(V8NamedNodeMap::ownerNodeIndex, owner); + } + return wrapper; } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp index ec5c1dc..22e84c9 100644 --- a/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NavigatorCustom.cpp @@ -33,12 +33,17 @@ #include "ExceptionCode.h" #include "RuntimeEnabledFeatures.h" +<<<<<<< HEAD #include "V8Binding.h" #include "V8Proxy.h" #if PLATFORM(ANDROID) #include "V8CustomApplicationInstalledCallback.h" #endif +======= +#include "V8DOMWindow.h" +#include "V8DOMWrapper.h" +>>>>>>> webkit.org at r54340 namespace WebCore { @@ -49,6 +54,7 @@ bool V8Navigator::GeolocationEnabled() } #endif +<<<<<<< HEAD #if PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) static PassRefPtr<ApplicationInstalledCallback> createApplicationInstalledCallback( @@ -93,4 +99,19 @@ v8::Handle<v8::Value> V8Navigator::isApplicationInstalledCallback(const v8::Argu #endif // PLATFORM(ANDROID) && ENABLE(APPLICATION_INSTALLED) +======= +v8::Handle<v8::Value> toV8(Navigator* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (wrapper.IsEmpty()) { + wrapper = V8Navigator::wrap(impl); + if (!wrapper.IsEmpty()) + V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::navigatorIndex, wrapper); + } + return wrapper; +} + +>>>>>>> webkit.org at r54340 } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8NodeCustom.cpp b/WebCore/bindings/v8/custom/V8NodeCustom.cpp index 79afbe8..06489fd 100644 --- a/WebCore/bindings/v8/custom/V8NodeCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeCustom.cpp @@ -35,11 +35,23 @@ #include "EventListener.h" #include "V8AbstractEventListener.h" +#include "V8Attr.h" #include "V8Binding.h" +#include "V8CDATASection.h" +#include "V8Comment.h" #include "V8CustomBinding.h" #include "V8CustomEventListener.h" +#include "V8Document.h" +#include "V8DocumentFragment.h" +#include "V8DocumentType.h" +#include "V8Element.h" +#include "V8Entity.h" +#include "V8EntityReference.h" #include "V8Node.h" +#include "V8Notation.h" +#include "V8ProcessingInstruction.h" #include "V8Proxy.h" +#include "V8Text.h" #include <wtf/RefPtr.h> @@ -152,4 +164,43 @@ v8::Handle<v8::Value> V8Node::appendChildCallback(const v8::Arguments& args) return v8::Null(); } +v8::Handle<v8::Value> toV8(Node* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + + if (!forceNewObject) { + v8::Handle<v8::Value> wrapper = V8DOMWrapper::getWrapper(impl); + if (!wrapper.IsEmpty()) + return wrapper; + } + switch (impl->nodeType()) { + case Node::ELEMENT_NODE: + return toV8(static_cast<Element*>(impl), forceNewObject); + case Node::ATTRIBUTE_NODE: + return toV8(static_cast<Attr*>(impl), forceNewObject); + case Node::TEXT_NODE: + return toV8(static_cast<Text*>(impl), forceNewObject); + case Node::CDATA_SECTION_NODE: + return toV8(static_cast<CDATASection*>(impl), forceNewObject); + case Node::ENTITY_REFERENCE_NODE: + return toV8(static_cast<EntityReference*>(impl), forceNewObject); + case Node::ENTITY_NODE: + return toV8(static_cast<Entity*>(impl), forceNewObject); + case Node::PROCESSING_INSTRUCTION_NODE: + return toV8(static_cast<ProcessingInstruction*>(impl), forceNewObject); + case Node::COMMENT_NODE: + return toV8(static_cast<Comment*>(impl), forceNewObject); + case Node::DOCUMENT_NODE: + return toV8(static_cast<Document*>(impl), forceNewObject); + case Node::DOCUMENT_TYPE_NODE: + return toV8(static_cast<DocumentType*>(impl), forceNewObject); + case Node::DOCUMENT_FRAGMENT_NODE: + return toV8(static_cast<DocumentFragment*>(impl), forceNewObject); + case Node::NOTATION_NODE: + return toV8(static_cast<Notation*>(impl), forceNewObject); + default: break; // XPATH_NAMESPACE_NODE + } + return V8Node::wrap(impl, forceNewObject); +} } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp index 074eac3..728b3dc 100644 --- a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp @@ -35,7 +35,7 @@ #include "ScriptState.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8Node.h" #include "V8Proxy.h" #include <wtf/PassRefPtr.h> @@ -54,7 +54,7 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ExceptionCode if (!object) return v8::Null(); - return V8DOMWrapper::convertNodeToV8Object(object); + return toV8(object); } v8::Handle<v8::Value> V8NodeIterator::nextNodeCallback(const v8::Arguments& args) diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp index 5721a7e..20a5471 100644 --- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp @@ -32,9 +32,8 @@ #include "V8NodeList.h" #include "NodeList.h" - #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8Node.h" #include "V8Proxy.h" #include <wtf/RefPtr.h> @@ -57,7 +56,7 @@ v8::Handle<v8::Value> V8NodeList::namedPropertyGetter(v8::Local<v8::String> name if (!result) return notHandledByInterceptor(); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } // Need to support call so that list(0) works. @@ -75,7 +74,7 @@ v8::Handle<v8::Value> V8NodeList::callAsFunctionCallback(const v8::Arguments& ar return v8::Undefined(); RefPtr<Node> result = list->item(index->Uint32Value()); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp index 1cb4554..5531b48 100644 --- a/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NotificationCenterCustom.cpp @@ -37,7 +37,6 @@ #include "Notification.h" #include "NotificationCenter.h" #include "V8Binding.h" -#include "V8CustomBinding.h" #include "V8CustomEventListener.h" #include "V8CustomVoidCallback.h" #include "V8Notification.h" @@ -95,7 +94,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createHTMLNotificationCallback(const if (notificationCenter->context()->isWorkerContext()) return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get()); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get()); + return toV8(notification.get()); } v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8::Arguments& args) @@ -112,7 +111,7 @@ v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8: if (notificationCenter->context()->isWorkerContext()) return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get()); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::NOTIFICATION, notification.get()); + return toV8(notification.get()); } v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::Arguments& args) diff --git a/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp new file mode 100644 index 0000000..4cefc0e --- /dev/null +++ b/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8SVGDocument.h" + +#include "V8IsolatedContext.h" +#include "V8Proxy.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(SVGDocument* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8SVGDocument::wrap(impl, forceNewObject); + if (!V8IsolatedContext::getEntered()) { + if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame())) + proxy->windowShell()->updateDocumentWrapper(wrapper); + } + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp b/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp new file mode 100644 index 0000000..0ce48ce --- /dev/null +++ b/WebCore/bindings/v8/custom/V8SVGElementCustom.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms") return toV8(static_cast<SVGwith or without + * modification") return toV8(static_cast<SVGare permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice") return toV8(static_cast<SVGthis list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice") return toV8(static_cast<SVGthis list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES") return toV8(static_cast<SVGINCLUDING") return toV8(static_cast<SVGBUT NOT + * LIMITED TO") return toV8(static_cast<SVGTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT") return toV8(static_cast<SVGINDIRECT") return toV8(static_cast<SVGINCIDENTAL, + * SPECIAL") return toV8(static_cast<SVGEXEMPLARY") return toV8(static_cast<SVGOR CONSEQUENTIAL DAMAGES (INCLUDING") return toV8(static_cast<SVGBUT NOT + * LIMITED TO") return toV8(static_cast<SVGPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA") return toV8(static_cast<SVGOR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY") return toV8(static_cast<SVGWHETHER IN CONTRACT") return toV8(static_cast<SVGSTRICT LIABILITY") return toV8(static_cast<SVGOR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE") return toV8(static_cast<SVGEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8SVGElement.h" + +#if ENABLE(SVG) + +#include "V8SVGElementWrapperFactory.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(SVGElement* impl, bool forceNewObject) +{ + if (!impl) + return v8::Null(); + return createV8SVGWrapper(impl, forceNewObject); +} + +} // namespace WebCore + +#endif // ENABLE(SVG) diff --git a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp index 78284cd..0a75c9f 100644 --- a/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SVGMatrixCustom.cpp @@ -31,16 +31,13 @@ #include <config.h> #if ENABLE(SVG) - #include "TransformationMatrix.h" #include "SVGException.h" - #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8Proxy.h" #include "V8SVGMatrix.h" #include "V8SVGPODTypeWrapper.h" -#include "V8Proxy.h" namespace WebCore { @@ -56,7 +53,8 @@ v8::Handle<v8::Value> V8SVGMatrix::multiplyCallback(const v8::Arguments& args) TransformationMatrix m1 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(args.Holder()); TransformationMatrix m2 = *V8SVGPODTypeWrapper<TransformationMatrix>::toNative(v8::Handle<v8::Object>::Cast(args[0])); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2))); + RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(m1.multLeft(m2)); + return toV8(wrapper.get()); } v8::Handle<v8::Value> V8SVGMatrix::inverseCallback(const v8::Arguments& args) @@ -74,7 +72,8 @@ v8::Handle<v8::Value> V8SVGMatrix::inverseCallback(const v8::Arguments& args) return v8::Handle<v8::Value>(); } - return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result)); + RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result); + return toV8(wrapper.get()); } v8::Handle<v8::Value> V8SVGMatrix::rotateFromVectorCallback(const v8::Arguments& args) @@ -94,7 +93,8 @@ v8::Handle<v8::Value> V8SVGMatrix::rotateFromVectorCallback(const v8::Arguments& return v8::Handle<v8::Value>(); } - return V8DOMWrapper::convertToV8Object(V8ClassIndex::SVGMATRIX, V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result)); + RefPtr<V8SVGStaticPODTypeWrapper<TransformationMatrix> > wrapper = V8SVGStaticPODTypeWrapper<TransformationMatrix>::create(result); + return toV8(wrapper.get()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp b/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp new file mode 100644 index 0000000..a96d55e --- /dev/null +++ b/WebCore/bindings/v8/custom/V8SVGPathSegCustom.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8SVGPathSeg.h" + +#include "V8DOMWindow.h" +#include "V8DOMWrapper.h" +#include "V8SVGPathSegArcAbs.h" +#include "V8SVGPathSegArcRel.h" +#include "V8SVGPathSegClosePath.h" +#include "V8SVGPathSegCurvetoCubicAbs.h" +#include "V8SVGPathSegCurvetoCubicRel.h" +#include "V8SVGPathSegCurvetoCubicSmoothAbs.h" +#include "V8SVGPathSegCurvetoCubicSmoothRel.h" +#include "V8SVGPathSegCurvetoQuadraticAbs.h" +#include "V8SVGPathSegCurvetoQuadraticRel.h" +#include "V8SVGPathSegCurvetoQuadraticSmoothAbs.h" +#include "V8SVGPathSegCurvetoQuadraticSmoothRel.h" +#include "V8SVGPathSegLinetoAbs.h" +#include "V8SVGPathSegLinetoHorizontalAbs.h" +#include "V8SVGPathSegLinetoHorizontalRel.h" +#include "V8SVGPathSegLinetoRel.h" +#include "V8SVGPathSegLinetoVerticalAbs.h" +#include "V8SVGPathSegLinetoVerticalRel.h" +#include "V8SVGPathSegMovetoAbs.h" +#include "V8SVGPathSegMovetoRel.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(SVGPathSeg* impl) +{ + if (!impl) + return v8::Null(); + switch (impl->pathSegType()) { + case SVGPathSeg::PATHSEG_CLOSEPATH: + return toV8(static_cast<SVGPathSegClosePath*>(impl)); + case SVGPathSeg::PATHSEG_MOVETO_ABS: + return toV8(static_cast<SVGPathSegMovetoAbs*>(impl)); + case SVGPathSeg::PATHSEG_MOVETO_REL: + return toV8(static_cast<SVGPathSegMovetoRel*>(impl)); + case SVGPathSeg::PATHSEG_LINETO_ABS: + return toV8(static_cast<SVGPathSegLinetoAbs*>(impl)); + case SVGPathSeg::PATHSEG_LINETO_REL: + return toV8(static_cast<SVGPathSegLinetoRel*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: + return toV8(static_cast<SVGPathSegCurvetoCubicAbs*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: + return toV8(static_cast<SVGPathSegCurvetoCubicRel*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: + return toV8(static_cast<SVGPathSegCurvetoQuadraticAbs*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: + return toV8(static_cast<SVGPathSegCurvetoQuadraticRel*>(impl)); + case SVGPathSeg::PATHSEG_ARC_ABS: + return toV8(static_cast<SVGPathSegArcAbs*>(impl)); + case SVGPathSeg::PATHSEG_ARC_REL: + return toV8(static_cast<SVGPathSegArcRel*>(impl)); + case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: + return toV8(static_cast<SVGPathSegLinetoHorizontalAbs*>(impl)); + case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: + return toV8(static_cast<SVGPathSegLinetoHorizontalRel*>(impl)); + case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: + return toV8(static_cast<SVGPathSegLinetoVerticalAbs*>(impl)); + case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: + return toV8(static_cast<SVGPathSegLinetoVerticalRel*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + return toV8(static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + return toV8(static_cast<SVGPathSegCurvetoCubicSmoothRel*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(impl)); + case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + return toV8(static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(impl)); + } + ASSERT_NOT_REACHED(); + return V8SVGPathSeg::wrap(impl); +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8ScreenCustom.cpp b/WebCore/bindings/v8/custom/V8ScreenCustom.cpp new file mode 100644 index 0000000..98d9dd7 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8ScreenCustom.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8Screen.h" + +#include "V8DOMWindow.h" +#include "V8DOMWrapper.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(Screen* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(impl); + if (wrapper.IsEmpty()) { + wrapper = V8Screen::wrap(impl); + if (!wrapper.IsEmpty()) + V8DOMWrapper::setHiddenWindowReference(impl->frame(), V8DOMWindow::screenIndex, wrapper); + } + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp b/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp new file mode 100644 index 0000000..b062cdc --- /dev/null +++ b/WebCore/bindings/v8/custom/V8StyleSheetCustom.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "V8StyleSheet.h" + +#include "V8CSSStyleSheet.h" +#include "V8Node.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(StyleSheet* impl) +{ + if (!impl) + return v8::Null(); + if (impl->isCSSStyleSheet()) + return toV8(static_cast<CSSStyleSheet*>(impl)); + v8::Handle<v8::Object> wrapper = V8StyleSheet::wrap(impl); + // Add a hidden reference from stylesheet object to its owner node. + Node* ownerNode = impl->ownerNode(); + if (ownerNode && !wrapper.IsEmpty()) { + v8::Handle<v8::Object> owner = v8::Handle<v8::Object>::Cast(toV8(ownerNode)); + wrapper->SetInternalField(V8StyleSheet::ownerNodeIndex, owner); + } + return wrapper; +} + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp index a718451..cee1838 100644 --- a/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8StyleSheetListCustom.cpp @@ -34,8 +34,8 @@ #include "HTMLStyleElement.h" #include "StyleSheetList.h" #include "V8Binding.h" -#include "V8CustomBinding.h" #include "V8Proxy.h" +#include "V8StyleSheet.h" namespace WebCore { @@ -52,7 +52,7 @@ v8::Handle<v8::Value> V8StyleSheetList::namedPropertyGetter(v8::Local<v8::String if (!item) return notHandledByInterceptor(); - return V8DOMWrapper::convertToV8Object(V8ClassIndex::STYLESHEET, item->sheet()); + return toV8(item->sheet()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp index b848197..37087df 100644 --- a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp +++ b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp @@ -36,7 +36,7 @@ #include "TreeWalker.h" #include "V8Binding.h" -#include "V8CustomBinding.h" +#include "V8Node.h" #include "V8Proxy.h" #include <wtf/PassRefPtr.h> @@ -44,7 +44,7 @@ namespace WebCore { -static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ScriptState* state) +static inline v8::Handle<v8::Value> toV8Object(PassRefPtr<Node> object, ScriptState* state) { if (state->hadException()) return throwError(state->exception()); @@ -52,7 +52,7 @@ static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ScriptState* s if (!object) return v8::Null(); - return V8DOMWrapper::convertNodeToV8Object(object); + return toV8(object); } v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args) @@ -62,7 +62,7 @@ v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args EmptyScriptState state; RefPtr<Node> result = treeWalker->parentNode(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args) @@ -72,7 +72,7 @@ v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args EmptyScriptState state; RefPtr<Node> result = treeWalker->firstChild(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args) @@ -82,7 +82,7 @@ v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args) EmptyScriptState state; RefPtr<Node> result = treeWalker->lastChild(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args) @@ -92,7 +92,7 @@ v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args) EmptyScriptState state; RefPtr<Node> result = treeWalker->nextNode(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& args) @@ -102,7 +102,7 @@ v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& ar EmptyScriptState state; RefPtr<Node> result = treeWalker->previousNode(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& args) @@ -112,7 +112,7 @@ v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& arg EmptyScriptState state; RefPtr<Node> result = treeWalker->nextSibling(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments& args) @@ -122,7 +122,7 @@ v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments& EmptyScriptState state; RefPtr<Node> result = treeWalker->previousSibling(&state); - return toV8(result.release(), &state); + return toV8Object(result.release(), &state); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp new file mode 100644 index 0000000..a92e4f2 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#if ENABLE(3D_CANVAS) +#include "V8WebGLArray.h" + +#include "V8WebGLByteArray.h" +#include "V8WebGLFloatArray.h" +#include "V8WebGLIntArray.h" +#include "V8WebGLShortArray.h" +#include "V8WebGLUnsignedByteArray.h" +#include "V8WebGLUnsignedIntArray.h" +#include "V8WebGLUnsignedShortArray.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(WebGLArray* impl) +{ + if (!impl) + return v8::Null(); + if (impl->isByteArray()) + return toV8(static_cast<WebGLByteArray*>(impl)); + if (impl->isFloatArray()) + return toV8(static_cast<WebGLFloatArray*>(impl)); + if (impl->isIntArray()) + return toV8(static_cast<WebGLIntArray*>(impl)); + if (impl->isShortArray()) + return toV8(static_cast<WebGLShortArray*>(impl)); + if (impl->isUnsignedByteArray()) + return toV8(static_cast<WebGLUnsignedByteArray*>(impl)); + if (impl->isUnsignedIntArray()) + return toV8(static_cast<WebGLUnsignedIntArray*>(impl)); + if (impl->isUnsignedShortArray()) + return toV8(static_cast<WebGLUnsignedShortArray*>(impl)); + return v8::Handle<v8::Value>(); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp index 6d52c83..95f6879 100644 --- a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLByteArray::setCallback(const v8::Arguments& args) return setWebGLArray<WebGLByteArray, V8WebGLByteArray>(args, V8ClassIndex::WEBGLBYTEARRAY); } +v8::Handle<v8::Value> toV8(WebGLByteArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLByteArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp index 4d4b0e2..5882450 100644 --- a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLFloatArray::setCallback(const v8::Arguments& args) return setWebGLArray<WebGLFloatArray, V8WebGLFloatArray>(args, V8ClassIndex::WEBGLFLOATARRAY); } +v8::Handle<v8::Value> toV8(WebGLFloatArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLFloatArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp index 7dde0a0..7e2f2ed 100644 --- a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLIntArray::setCallback(const v8::Arguments& args) return setWebGLArray<WebGLIntArray, V8WebGLIntArray>(args, V8ClassIndex::WEBGLINTARRAY); } +v8::Handle<v8::Value> toV8(WebGLIntArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLIntArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 19b73d4..78de5e6 100644 --- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -42,12 +42,16 @@ #include "V8Binding.h" #include "V8WebGLArray.h" +#include "V8WebGLBuffer.h" #include "V8WebGLByteArray.h" #include "V8WebGLFloatArray.h" +#include "V8WebGLFramebuffer.h" #include "V8WebGLIntArray.h" #include "V8WebGLProgram.h" +#include "V8WebGLRenderbuffer.h" #include "V8WebGLShader.h" #include "V8WebGLShortArray.h" +#include "V8WebGLTexture.h" #include "V8WebGLUniformLocation.h" #include "V8WebGLUnsignedByteArray.h" #include "V8WebGLUnsignedIntArray.h" @@ -175,7 +179,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::bufferSubDataCallback(const v8::A return v8::Undefined(); } -static v8::Handle<v8::Value> toV8(const WebGLGetInfo& info) +static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info) { switch (info.getType()) { case WebGLGetInfo::kTypeBool: @@ -191,23 +195,23 @@ static v8::Handle<v8::Value> toV8(const WebGLGetInfo& info) case WebGLGetInfo::kTypeUnsignedLong: return v8::Integer::NewFromUnsigned(info.getUnsignedLong()); case WebGLGetInfo::kTypeWebGLBuffer: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLBUFFER, info.getWebGLBuffer()); + return toV8(info.getWebGLBuffer()); case WebGLGetInfo::kTypeWebGLFloatArray: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFLOATARRAY, info.getWebGLFloatArray()); + return toV8(info.getWebGLFloatArray()); case WebGLGetInfo::kTypeWebGLFramebuffer: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLFRAMEBUFFER, info.getWebGLFramebuffer()); + return toV8(info.getWebGLFramebuffer()); case WebGLGetInfo::kTypeWebGLIntArray: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLINTARRAY, info.getWebGLIntArray()); + return toV8(info.getWebGLIntArray()); // FIXME: implement WebGLObjectArray // case WebGLGetInfo::kTypeWebGLObjectArray: case WebGLGetInfo::kTypeWebGLProgram: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLPROGRAM, info.getWebGLProgram()); + return toV8(info.getWebGLProgram()); case WebGLGetInfo::kTypeWebGLRenderbuffer: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLRENDERBUFFER, info.getWebGLRenderbuffer()); + return toV8(info.getWebGLRenderbuffer()); case WebGLGetInfo::kTypeWebGLTexture: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLTEXTURE, info.getWebGLTexture()); + return toV8(info.getWebGLTexture()); case WebGLGetInfo::kTypeWebGLUnsignedByteArray: - return V8DOMWrapper::convertToV8Object(V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY, info.getWebGLUnsignedByteArray()); + return toV8(info.getWebGLUnsignedByteArray()); default: notImplemented(); return v8::Undefined(); @@ -261,7 +265,7 @@ static v8::Handle<v8::Value> getObjectParameter(const v8::Arguments& args, Objec V8Proxy::setDOMException(ec); return v8::Undefined(); } - return toV8(info); + return toV8Object(info); } static WebGLUniformLocation* toWebGLUniformLocation(v8::Handle<v8::Value> value, bool& ok) @@ -317,7 +321,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getFramebufferAttachmentParameter V8Proxy::setDOMException(ec); return v8::Undefined(); } - return toV8(info); + return toV8Object(info); } v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Arguments& args) @@ -342,7 +346,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getParameterCallback(const v8::Ar V8Proxy::setDOMException(ec); return v8::Undefined(); } - return toV8(info); + return toV8Object(info); } v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const v8::Arguments& args) @@ -368,7 +372,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const V8Proxy::setDOMException(ec); return v8::Undefined(); } - return toV8(info); + return toV8Object(info); } v8::Handle<v8::Value> V8WebGLRenderingContext::getRenderbufferParameterCallback(const v8::Arguments& args) @@ -400,7 +404,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const V8Proxy::setDOMException(ec); return v8::Undefined(); } - return toV8(info); + return toV8Object(info); } v8::Handle<v8::Value> V8WebGLRenderingContext::getTexParameterCallback(const v8::Arguments& args) @@ -434,7 +438,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu V8Proxy::setDOMException(ec); return v8::Undefined(); } - return toV8(info); + return toV8Object(info); } v8::Handle<v8::Value> V8WebGLRenderingContext::getVertexAttribCallback(const v8::Arguments& args) diff --git a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp index 9d3b478..4cbccf5 100644 --- a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLShortArray::setCallback(const v8::Arguments& args) return setWebGLArray<WebGLShortArray, V8WebGLShortArray>(args, V8ClassIndex::WEBGLSHORTARRAY); } +v8::Handle<v8::Value> toV8(WebGLShortArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLShortArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp index 3cc658a..962e390 100644 --- a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedByteArray::setCallback(const v8::Arguments& return setWebGLArray<WebGLUnsignedByteArray, V8WebGLUnsignedByteArray>(args, V8ClassIndex::WEBGLUNSIGNEDBYTEARRAY); } +v8::Handle<v8::Value> toV8(WebGLUnsignedByteArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLUnsignedByteArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp index 93ccbd4..eb0b7cf 100644 --- a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedIntArray::setCallback(const v8::Arguments& return setWebGLArray<WebGLUnsignedIntArray, V8WebGLUnsignedIntArray>(args, V8ClassIndex::WEBGLUNSIGNEDINTARRAY); } +v8::Handle<v8::Value> toV8(WebGLUnsignedIntArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLUnsignedIntArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp index d9e47cd..5f30de3 100644 --- a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp @@ -63,6 +63,16 @@ v8::Handle<v8::Value> V8WebGLUnsignedShortArray::setCallback(const v8::Arguments return setWebGLArray<WebGLUnsignedShortArray, V8WebGLUnsignedShortArray>(args, V8ClassIndex::WEBGLUNSIGNEDSHORTARRAY); } +v8::Handle<v8::Value> toV8(WebGLUnsignedShortArray* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8WebGLUnsignedShortArray::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length()); + return wrapper; +} + } // namespace WebCore #endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp index fd0305a..89f804c 100644 --- a/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XSLTProcessorCustom.cpp @@ -36,8 +36,8 @@ #include "Node.h" #include "V8Binding.h" -#include "V8CustomBinding.h" #include "V8Document.h" +#include "V8DocumentFragment.h" #include "V8Node.h" #include "V8Proxy.h" #include "XSLTProcessor.h" @@ -78,7 +78,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToFragmentCallback(const v8::Arg Node* source = V8Node::toNative(v8::Handle<v8::Object>::Cast(args[0])); Document* owner = V8Document::toNative(v8::Handle<v8::Object>::Cast(args[1])); RefPtr<DocumentFragment> result = imp->transformToFragment(source, owner); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } @@ -99,7 +99,7 @@ v8::Handle<v8::Value> V8XSLTProcessor::transformToDocumentCallback(const v8::Arg if (!result) return v8::Undefined(); - return V8DOMWrapper::convertNodeToV8Object(result.release()); + return toV8(result.release()); } diff --git a/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp index 9352983..1944108 100644 --- a/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp +++ b/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp @@ -134,9 +134,15 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case float_type: { if (type == NPVariantType_Int32) +<<<<<<< HEAD result.f = static_cast<jfloat>(NPVARIANT_TO_INT32(value)); else if (type == NPVariantType_Double) result.f = static_cast<jfloat>(NPVARIANT_TO_DOUBLE(value)); +======= + result.j = static_cast<jfloat>(NPVARIANT_TO_INT32(value)); + else if (type == NPVariantType_Double) + result.j = static_cast<jfloat>(NPVARIANT_TO_DOUBLE(value)); +>>>>>>> webkit.org at r54340 else bzero(&result, sizeof(jvalue)); } @@ -145,9 +151,15 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja case double_type: { if (type == NPVariantType_Int32) +<<<<<<< HEAD result.d = static_cast<jdouble>(NPVARIANT_TO_INT32(value)); else if (type == NPVariantType_Double) result.d = static_cast<jdouble>(NPVARIANT_TO_DOUBLE(value)); +======= + result.j = static_cast<jdouble>(NPVARIANT_TO_INT32(value)); + else if (type == NPVariantType_Double) + result.j = static_cast<jdouble>(NPVARIANT_TO_DOUBLE(value)); +>>>>>>> webkit.org at r54340 else bzero(&result, sizeof(jvalue)); } diff --git a/WebCore/css/html.css b/WebCore/css/html.css index 913dbe5..9d9225c 100644 --- a/WebCore/css/html.css +++ b/WebCore/css/html.css @@ -621,7 +621,8 @@ a:-webkit-any-link:active { /* HTML5 ruby elements */ ruby, rt { - text-indent: 0; /* blocks used for ruby rendering should not trigger this */ + text-indent: 0; /* blocks used for ruby rendering should not trigger this */ + line-height: normal; } ruby > rt { diff --git a/WebCore/dom/Element.cpp b/WebCore/dom/Element.cpp index ac4fdb3..729ec8d 100644 --- a/WebCore/dom/Element.cpp +++ b/WebCore/dom/Element.cpp @@ -702,7 +702,8 @@ void Element::setPrefix(const AtomicString& prefix, ExceptionCode& ec) KURL Element::baseURI() const { - KURL base(KURL(), getAttribute(baseAttr)); + const AtomicString& baseAttribute = getAttribute(baseAttr); + KURL base(KURL(), baseAttribute); if (!base.protocol().isEmpty()) return base; @@ -714,7 +715,7 @@ KURL Element::baseURI() const if (parentBase.isNull()) return base; - return KURL(parentBase, base.string()); + return KURL(parentBase, baseAttribute); } void Element::createAttributeMap() const diff --git a/WebCore/dom/Event.cpp b/WebCore/dom/Event.cpp index be2b37b..b6abb2a 100644 --- a/WebCore/dom/Event.cpp +++ b/WebCore/dom/Event.cpp @@ -194,6 +194,30 @@ bool Event::isTouchEvent() const } #endif +bool Event::fromUserGesture() +{ + if (createdByDOM()) + return false; + + const AtomicString& type = this->type(); + return + // mouse events + type == eventNames().clickEvent || type == eventNames().mousedownEvent + || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent + // keyboard events + || type == eventNames().keydownEvent || type == eventNames().keypressEvent + || type == eventNames().keyupEvent +#if ENABLE(TOUCH_EVENTS) + // touch events + || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent + || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent +#endif + // other accepted events + || type == eventNames().selectEvent || type == eventNames().changeEvent + || type == eventNames().focusEvent || type == eventNames().blurEvent + || type == eventNames().submitEvent; +} + bool Event::storesResultAsString() const { return false; diff --git a/WebCore/dom/Event.h b/WebCore/dom/Event.h index 9b55bb8..1ba5e3d 100644 --- a/WebCore/dom/Event.h +++ b/WebCore/dom/Event.h @@ -129,6 +129,7 @@ namespace WebCore { #if ENABLE(TOUCH_EVENTS) virtual bool isTouchEvent() const; #endif + bool fromUserGesture(); bool propagationStopped() const { return m_propagationStopped; } diff --git a/WebCore/dom/make_names.pl b/WebCore/dom/make_names.pl index daf45ef..083e309 100755 --- a/WebCore/dom/make_names.pl +++ b/WebCore/dom/make_names.pl @@ -38,7 +38,8 @@ use InFilesParser; use Switch; my $printFactory = 0; -my $printWrapperFactory = 0; +my $printWrapperFactory = 0; +my $printWrapperFactoryV8 = 0; my $tagsFile = ""; my $attrsFile = ""; my $outputDir = "."; @@ -55,7 +56,8 @@ GetOptions( 'outputDir=s' => \$outputDir, 'extraDefines=s' => \$extraDefines, 'preprocessor=s' => \$preprocessor, - 'wrapperFactory' => \$printWrapperFactory + 'wrapperFactory' => \$printWrapperFactory, + 'wrapperFactoryV8' => \$printWrapperFactoryV8 ); die "You must specify at least one of --tags <file> or --attrs <file>" unless (length($tagsFile) || length($attrsFile)); @@ -71,7 +73,7 @@ $parameters{namespacePrefix} = $parameters{namespace} unless $parameters{namespa mkpath($outputDir); my $namesBasePath = "$outputDir/$parameters{namespace}Names"; my $factoryBasePath = "$outputDir/$parameters{namespace}ElementFactory"; -my $wrapperFactoryBasePath = "$outputDir/JS$parameters{namespace}ElementWrapperFactory"; +my $wrapperFactoryFileName = "$parameters{namespace}ElementWrapperFactory"; printNamesHeaderFile("$namesBasePath.h"); printNamesCppFile("$namesBasePath.cpp"); @@ -81,9 +83,17 @@ if ($printFactory) { printFactoryHeaderFile("$factoryBasePath.h"); } +die "You cannot specify both --wrapperFactory and --wrapperFactoryV8" if $printWrapperFactory && $printWrapperFactoryV8; +my $wrapperFactoryType = ""; if ($printWrapperFactory) { - printWrapperFactoryCppFile("$wrapperFactoryBasePath.cpp"); - printWrapperFactoryHeaderFile("$wrapperFactoryBasePath.h"); + $wrapperFactoryType = "JS"; +} elsif ($printWrapperFactoryV8) { + $wrapperFactoryType = "V8"; +} + +if ($wrapperFactoryType) { + printWrapperFactoryCppFile($outputDir, $wrapperFactoryType, $wrapperFactoryFileName); + printWrapperFactoryHeaderFile($outputDir, $wrapperFactoryType, $wrapperFactoryFileName); } ### Hash initialization @@ -555,6 +565,7 @@ print F "\nvoid init() sub printJSElementIncludes { my $F = shift; + my $wrapperFactoryType = shift; my %tagsSeen; for my $tagName (sort keys %tags) { @@ -562,7 +573,7 @@ sub printJSElementIncludes next if defined($tagsSeen{$JSInterfaceName}) || usesDefaultJSWrapper($tagName); $tagsSeen{$JSInterfaceName} = 1; - print F "#include \"JS${JSInterfaceName}.h\"\n"; + print F "#include \"${wrapperFactoryType}${JSInterfaceName}.h\"\n"; } } @@ -799,6 +810,7 @@ sub usesDefaultJSWrapper sub printWrapperFunctions { my $F = shift; + my $wrapperFactoryType = shift; my %tagsSeen; for my $tagName (sort keys %tags) { @@ -813,10 +825,11 @@ sub printWrapperFunctions print F "#if ${conditionalString}\n\n"; } - # Hack for the media tags - # FIXME: This should have been done via a CustomWrapper attribute and a separate *Custom file. - if ($tags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { - print F <<END + if ($wrapperFactoryType eq "JS") { + # Hack for the media tags + # FIXME: This should have been done via a CustomWrapper attribute and a separate *Custom file. + if ($tags{$tagName}{wrapperOnlyIfMediaIsAvailable}) { + print F <<END static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element) { if (!MediaPlayer::isAvailable()) @@ -826,8 +839,8 @@ static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObjec END ; - } else { - print F <<END + } else { + print F <<END static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element) { return CREATE_DOM_NODE_WRAPPER(exec, globalObject, ${JSInterfaceName}, element.get()); @@ -835,6 +848,16 @@ static JSNode* create${JSInterfaceName}Wrapper(ExecState* exec, JSDOMGlobalObjec END ; + } + } elsif ($wrapperFactoryType eq "V8") { + print F <<END +static v8::Handle<v8::Value> create${JSInterfaceName}Wrapper($parameters{namespace}Element* element) +{ + return toV8(static_cast<${JSInterfaceName}*>(element)); +} + +END +; } if ($conditional) { @@ -845,9 +868,11 @@ END sub printWrapperFactoryCppFile { - my $cppPath = shift; + my $outputDir = shift; + my $wrapperFactoryType = shift; + my $wrapperFactoryFileName = shift; my $F; - open F, ">$cppPath"; + open F, ">" . $outputDir . "/" . $wrapperFactoryType . $wrapperFactoryFileName . ".cpp"; printLicenseHeader($F); @@ -855,38 +880,73 @@ sub printWrapperFactoryCppFile print F "#if $parameters{guardFactoryWith}\n\n" if $parameters{guardFactoryWith}; - print F "#include \"JS$parameters{namespace}ElementWrapperFactory.h\"\n"; + print F "#include \"$wrapperFactoryType$parameters{namespace}ElementWrapperFactory.h\"\n"; - printJSElementIncludes($F); + printJSElementIncludes($F, $wrapperFactoryType); print F "\n#include \"$parameters{namespace}Names.h\"\n\n"; printElementIncludes($F); print F "\n#include <wtf/StdLibExtras.h>\n\n"; - - print F <<END + + if ($wrapperFactoryType eq "JS") { + print F <<END using namespace JSC; +END +; + } elsif ($wrapperFactoryType eq "V8") { + print F <<END +#include "V8$parameters{namespace}Element.h" + +#include <v8.h> +END +; + } + + print F <<END namespace WebCore { using namespace $parameters{namespace}Names; +END +; + if ($wrapperFactoryType eq "JS") { + print F <<END typedef JSNode* (*Create$parameters{namespace}ElementWrapperFunction)(ExecState*, JSDOMGlobalObject*, PassRefPtr<$parameters{namespace}Element>); END ; + } elsif ($wrapperFactoryType eq "V8") { + print F <<END +typedef v8::Handle<v8::Value> (*Create$parameters{namespace}ElementWrapperFunction)($parameters{namespace}Element*); + +END +; + } - printWrapperFunctions($F); + printWrapperFunctions($F, $wrapperFactoryType); - print F <<END + if ($wrapperFactoryType eq "JS") { + print F <<END JSNode* createJS$parameters{namespace}Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<$parameters{namespace}Element> element) -{ +{ + typedef HashMap<WebCore::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap; + DEFINE_STATIC_LOCAL(FunctionMap, map, ()); + if (map.isEmpty()) { +END +; + } elsif ($wrapperFactoryType eq "V8") { + print F <<END +v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element* element, bool forceNewObject) +{ typedef HashMap<WebCore::AtomicStringImpl*, Create$parameters{namespace}ElementWrapperFunction> FunctionMap; DEFINE_STATIC_LOCAL(FunctionMap, map, ()); if (map.isEmpty()) { END ; + } for my $tag (sort keys %tags) { # Do not add the name to the map if it does not have a JS wrapper constructor or uses the default wrapper. @@ -910,8 +970,22 @@ END } Create$parameters{namespace}ElementWrapperFunction createWrapperFunction = map.get(element->localName().impl()); if (createWrapperFunction) +END +; + if ($wrapperFactoryType eq "JS") { + print F <<END return createWrapperFunction(exec, globalObject, element); return CREATE_DOM_NODE_WRAPPER(exec, globalObject, $parameters{namespace}Element, element.get()); +END +; + } elsif ($wrapperFactoryType eq "V8") { + print F <<END + return createWrapperFunction(element); + return V8$parameters{namespace}Element::wrap(element, forceNewObject); +END +; + } + print F <<END } } @@ -926,18 +1000,21 @@ END sub printWrapperFactoryHeaderFile { - my $headerPath = shift; + my $outputDir = shift; + my $wrapperFactoryType = shift; + my $wrapperFactoryFileName = shift; my $F; - open F, ">$headerPath"; + open F, ">" . $outputDir . "/" . $wrapperFactoryType . $wrapperFactoryFileName . ".h"; printLicenseHeader($F); - print F "#ifndef JS$parameters{namespace}ElementWrapperFactory_h\n"; - print F "#define JS$parameters{namespace}ElementWrapperFactory_h\n\n"; + print F "#ifndef $wrapperFactoryType$parameters{namespace}ElementWrapperFactory_h\n"; + print F "#define $wrapperFactoryType$parameters{namespace}ElementWrapperFactory_h\n\n"; print F "#if $parameters{guardFactoryWith}\n" if $parameters{guardFactoryWith}; - print F <<END + if ($wrapperFactoryType eq "JS") { + print F <<END #include <wtf/Forward.h> namespace JSC { @@ -956,10 +1033,23 @@ namespace WebCore { END ; + } elsif ($wrapperFactoryType eq "V8") { + print F <<END +#include <v8.h> + +namespace WebCore { + + class $parameters{namespace}Element; + + v8::Handle<v8::Value> createV8$parameters{namespace}Wrapper($parameters{namespace}Element*, bool); +} +END +; + } print F "#endif // $parameters{guardFactoryWith}\n\n" if $parameters{guardFactoryWith}; - print F "#endif // JS$parameters{namespace}ElementWrapperFactory_h\n"; + print F "#endif // $wrapperFactoryType$parameters{namespace}ElementWrapperFactory_h\n"; close F; } diff --git a/WebCore/html/HTMLFormControlElement.cpp b/WebCore/html/HTMLFormControlElement.cpp index eb25c40..6f24e0c 100644 --- a/WebCore/html/HTMLFormControlElement.cpp +++ b/WebCore/html/HTMLFormControlElement.cpp @@ -52,6 +52,7 @@ using namespace HTMLNames; HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) : HTMLElement(tagName, doc) , m_form(f) + , m_hasName(false) , m_disabled(false) , m_readOnly(false) , m_required(false) @@ -89,8 +90,9 @@ ValidityState* HTMLFormControlElement::validity() void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) { + bool oldWillValidate = willValidate(); if (attr->name() == nameAttr) - setNeedsStyleRecalc(); + m_hasName = !attr->isEmpty(); else if (attr->name() == disabledAttr) { bool oldDisabled = m_disabled; m_disabled = !attr->isNull(); @@ -114,6 +116,8 @@ void HTMLFormControlElement::parseMappedAttribute(MappedAttribute *attr) setNeedsStyleRecalc(); } else HTMLElement::parseMappedAttribute(attr); + if (oldWillValidate != willValidate()) + setNeedsWillValidateCheck(); } void HTMLFormControlElement::attach() @@ -149,9 +153,10 @@ void HTMLFormControlElement::insertedIntoTree(bool deep) // setting a form, we will already have a non-null value for m_form, // and so we don't need to do anything. m_form = findFormAncestor(); - if (m_form) + if (m_form) { m_form->registerFormElement(this); - else + setNeedsWillValidateCheck(); + } else document()->checkedRadioButtons().addButton(this); } @@ -178,11 +183,19 @@ void HTMLFormControlElement::removedFromTree(bool deep) if (m_form && !(parser && parser->isHandlingResidualStyleAcrossBlocks()) && findRoot(this) != findRoot(m_form)) { m_form->removeFormElement(this); m_form = 0; + setNeedsWillValidateCheck(); } HTMLElement::removedFromTree(deep); } +void HTMLFormControlElement::formDestroyed() +{ + if (m_form) + setNeedsWillValidateCheck(); + m_form = 0; +} + const AtomicString& HTMLFormControlElement::formControlName() const { const AtomicString& n = getAttribute(nameAttr); @@ -199,11 +212,6 @@ void HTMLFormControlElement::dispatchFormControlChangeEvent() dispatchEvent(Event::create(eventNames().changeEvent, true, false)); } -bool HTMLFormControlElement::disabled() const -{ - return m_disabled; -} - void HTMLFormControlElement::setDisabled(bool b) { setAttribute(disabledAttr, b ? "" : 0); @@ -297,7 +305,7 @@ bool HTMLFormControlElement::willValidate() const // The control does not have a repetition template as an ancestor. // The control does not have a datalist element as an ancestor. // The control is not an output element. - return form() && !name().isEmpty() && !disabled() && !isReadOnlyFormControl(); + return m_form && m_hasName && !m_disabled && !m_readOnly; } String HTMLFormControlElement::validationMessage() @@ -305,6 +313,12 @@ String HTMLFormControlElement::validationMessage() return validity()->validationMessage(); } +void HTMLFormControlElement::setNeedsWillValidateCheck() +{ + setNeedsStyleRecalc(); + // FIXME: Show/hide a validation message. +} + bool HTMLFormControlElement::checkValidity() { if (willValidate() && !isValidFormControlElement()) { @@ -315,12 +329,13 @@ bool HTMLFormControlElement::checkValidity() return true; } -void HTMLFormControlElement::updateValidity() +void HTMLFormControlElement::setNeedsValidityCheck() { if (willValidate()) { // Update style for pseudo classes such as :valid :invalid. setNeedsStyleRecalc(); } + // FIXME: show/hide a validation message. } void HTMLFormControlElement::setCustomValidity(const String& error) diff --git a/WebCore/html/HTMLFormControlElement.h b/WebCore/html/HTMLFormControlElement.h index 358546b..117087b 100644 --- a/WebCore/html/HTMLFormControlElement.h +++ b/WebCore/html/HTMLFormControlElement.h @@ -63,7 +63,7 @@ public: virtual void dispatchFormControlChangeEvent(); - bool disabled() const; + bool disabled() const { return m_disabled; } void setDisabled(bool); virtual bool supportsFocus() const; @@ -109,19 +109,22 @@ public: virtual bool willValidate() const; String validationMessage(); bool checkValidity(); - void updateValidity(); + // This must be called when a validation constraint or control value is changed. + void setNeedsValidityCheck(); void setCustomValidity(const String&); virtual bool valueMissing() const { return false; } virtual bool patternMismatch() const { return false; } virtual bool tooLong() const { return false; } - void formDestroyed() { m_form = 0; } + void formDestroyed(); virtual void dispatchFocusEvent(); virtual void dispatchBlurEvent(); protected: void removeFromForm(); + // This must be called any time the result of willValidate() has changed. + void setNeedsWillValidateCheck(); private: virtual HTMLFormElement* virtualForm() const; @@ -130,6 +133,7 @@ private: HTMLFormElement* m_form; OwnPtr<ValidityState> m_validityState; + bool m_hasName : 1; bool m_disabled : 1; bool m_readOnly : 1; bool m_required : 1; diff --git a/WebCore/html/HTMLFormElement.cpp b/WebCore/html/HTMLFormElement.cpp index bf25bf6..2f88894 100644 --- a/WebCore/html/HTMLFormElement.cpp +++ b/WebCore/html/HTMLFormElement.cpp @@ -524,11 +524,13 @@ bool HTMLFormElement::isURLAttribute(Attribute* attr) const void HTMLFormElement::registerImgElement(HTMLImageElement* e) { + ASSERT(imgElements.find(e) == notFound); imgElements.append(e); } void HTMLFormElement::removeImgElement(HTMLImageElement* e) { + ASSERT(imgElements.find(e) != notFound); removeFromVector(imgElements, e); } diff --git a/WebCore/html/HTMLImageElement.cpp b/WebCore/html/HTMLImageElement.cpp index 34646ad..4592461 100644 --- a/WebCore/html/HTMLImageElement.cpp +++ b/WebCore/html/HTMLImageElement.cpp @@ -54,6 +54,8 @@ HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document* doc, HTMLImageElement::~HTMLImageElement() { + if (m_form) + m_form->removeImgElement(this); } bool HTMLImageElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp index 5567fe2..79f8c14 100644 --- a/WebCore/html/HTMLInputElement.cpp +++ b/WebCore/html/HTMLInputElement.cpp @@ -83,12 +83,20 @@ static const double numberDefaultStep = 1.0; static const double numberStepScaleFactor = 1.0; // Constant values for minimum(). static const double dateDefaultMinimum = -12219292800000.0; // This means 1582-10-15T00:00Z. +static const double dateTimeDefaultMinimum = -12219292800000.0; // ditto. +static const double monthDefaultMinimum = (1582.0 - 1970) * 12 + 10 - 1; // 1582-10 static const double numberDefaultMinimum = -DBL_MAX; static const double rangeDefaultMinimum = 0.0; +static const double timeDefaultMinimum = 0.0; // 00:00:00.000 +static const double weekDefaultMinimum = -12212380800000.0; // 1583-01-03, the first Monday of 1583. // Constant values for maximum(). static const double dateDefaultMaximum = DBL_MAX; +static const double dateTimeDefaultMaximum = DBL_MAX; +static const double monthDefaultMaximum = DBL_MAX; static const double numberDefaultMaximum = DBL_MAX; static const double rangeDefaultMaximum = 100.0; +static const double timeDefaultMaximum = 86399999.0; // 23:59:59.999 +static const double weekDefaultMaximum = DBL_MAX; HTMLInputElement::HTMLInputElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) : HTMLTextFormControlElement(tagName, doc, f) @@ -274,22 +282,24 @@ bool HTMLInputElement::rangeUnderflow() const const double nan = numeric_limits<double>::quiet_NaN(); switch (inputType()) { case DATE: + case DATETIME: + case DATETIMELOCAL: + case MONTH: case NUMBER: - case RANGE: { + case RANGE: + case TIME: + case WEEK: { double doubleValue = parseToDouble(value(), nan); return isfinite(doubleValue) && doubleValue < minimum(); } case BUTTON: case CHECKBOX: case COLOR: - case DATETIME: - case DATETIMELOCAL: case EMAIL: case FILE: case HIDDEN: case IMAGE: case ISINDEX: - case MONTH: case PASSWORD: case RADIO: case RESET: @@ -297,9 +307,7 @@ bool HTMLInputElement::rangeUnderflow() const case SUBMIT: case TELEPHONE: case TEXT: - case TIME: case URL: - case WEEK: break; } return false; @@ -310,22 +318,24 @@ bool HTMLInputElement::rangeOverflow() const const double nan = numeric_limits<double>::quiet_NaN(); switch (inputType()) { case DATE: + case DATETIME: + case DATETIMELOCAL: + case MONTH: case NUMBER: - case RANGE: { + case RANGE: + case TIME: + case WEEK: { double doubleValue = parseToDouble(value(), nan); return isfinite(doubleValue) && doubleValue > maximum(); } case BUTTON: case CHECKBOX: case COLOR: - case DATETIME: - case DATETIMELOCAL: case EMAIL: case FILE: case HIDDEN: case IMAGE: case ISINDEX: - case MONTH: case PASSWORD: case RADIO: case RESET: @@ -333,9 +343,7 @@ bool HTMLInputElement::rangeOverflow() const case SUBMIT: case TELEPHONE: case TEXT: - case TIME: case URL: - case WEEK: break; } return false; @@ -346,21 +354,27 @@ double HTMLInputElement::minimum() const switch (inputType()) { case DATE: return parseToDouble(getAttribute(minAttr), dateDefaultMinimum); + case DATETIME: + case DATETIMELOCAL: + return parseToDouble(getAttribute(minAttr), dateTimeDefaultMinimum); + case MONTH: + return parseToDouble(getAttribute(minAttr), monthDefaultMinimum); case NUMBER: return parseToDouble(getAttribute(minAttr), numberDefaultMinimum); case RANGE: return parseToDouble(getAttribute(minAttr), rangeDefaultMinimum); + case TIME: + return parseToDouble(getAttribute(minAttr), timeDefaultMinimum); + case WEEK: + return parseToDouble(getAttribute(minAttr), weekDefaultMinimum); case BUTTON: case CHECKBOX: case COLOR: - case DATETIME: - case DATETIMELOCAL: case EMAIL: case FILE: case HIDDEN: case IMAGE: case ISINDEX: - case MONTH: case PASSWORD: case RADIO: case RESET: @@ -368,9 +382,7 @@ double HTMLInputElement::minimum() const case SUBMIT: case TELEPHONE: case TEXT: - case TIME: case URL: - case WEEK: break; } ASSERT_NOT_REACHED(); @@ -382,6 +394,11 @@ double HTMLInputElement::maximum() const switch (inputType()) { case DATE: return parseToDouble(getAttribute(maxAttr), dateDefaultMaximum); + case DATETIME: + case DATETIMELOCAL: + return parseToDouble(getAttribute(maxAttr), dateTimeDefaultMaximum); + case MONTH: + return parseToDouble(getAttribute(maxAttr), monthDefaultMaximum); case NUMBER: return parseToDouble(getAttribute(maxAttr), numberDefaultMaximum); case RANGE: { @@ -393,17 +410,18 @@ double HTMLInputElement::maximum() const max = std::max(min, rangeDefaultMaximum); return max; } + case TIME: + return parseToDouble(getAttribute(maxAttr), timeDefaultMaximum); + case WEEK: + return parseToDouble(getAttribute(maxAttr), weekDefaultMaximum); case BUTTON: case CHECKBOX: case COLOR: - case DATETIME: - case DATETIMELOCAL: case EMAIL: case FILE: case HIDDEN: case IMAGE: case ISINDEX: - case MONTH: case PASSWORD: case RADIO: case RESET: @@ -411,9 +429,7 @@ double HTMLInputElement::maximum() const case SUBMIT: case TELEPHONE: case TEXT: - case TIME: case URL: - case WEEK: break; } ASSERT_NOT_REACHED(); @@ -704,6 +720,7 @@ void HTMLInputElement::setInputType(const String& t) // type change, otherwise a JavaScript programmer would be able to set a text // field's value to something like /etc/passwd and then change it to a file field. if (inputType() != newType) { + bool oldWillValidate = willValidate(); if (newType == FILE && m_haveType) // Set the attribute back to the old value. // Useful in case we were called from inside parseMappedAttribute. @@ -760,8 +777,10 @@ void HTMLInputElement::setInputType(const String& t) checkedRadioButtons(this).addButton(this); } + setNeedsValidityCheck(); + if (oldWillValidate != willValidate()) + setNeedsWillValidateCheck(); InputElement::notifyFormStateChanged(this); - updateValidity(); } m_haveType = true; @@ -983,17 +1002,18 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr) if (m_data.value().isNull()) setNeedsStyleRecalc(); setFormControlValueMatchesRenderer(false); - updateValidity(); + setNeedsValidityCheck(); } else if (attr->name() == checkedAttr) { m_defaultChecked = !attr->isNull(); if (m_useDefaultChecked) { setChecked(m_defaultChecked); m_useDefaultChecked = true; } - updateValidity(); - } else if (attr->name() == maxlengthAttr) + setNeedsValidityCheck(); + } else if (attr->name() == maxlengthAttr) { InputElement::parseMaxLengthAttribute(m_data, this, this, attr); - else if (attr->name() == sizeAttr) + setNeedsValidityCheck(); + } else if (attr->name() == sizeAttr) InputElement::parseSizeAttribute(m_data, this, attr); else if (attr->name() == altAttr) { if (renderer() && inputType() == IMAGE) @@ -1037,15 +1057,16 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr) attach(); } setNeedsStyleRecalc(); - } else if (attr->name() == autosaveAttr || - attr->name() == incrementalAttr || - attr->name() == minAttr || - attr->name() == maxAttr || - attr->name() == multipleAttr || - attr->name() == precisionAttr) + } else if (attr->name() == autosaveAttr + || attr->name() == incrementalAttr) setNeedsStyleRecalc(); - else if (attr->name() == patternAttr) - updateValidity(); + else if (attr->name() == minAttr + || attr->name() == maxAttr + || attr->name() == multipleAttr + || attr->name() == patternAttr + || attr->name() == precisionAttr + || attr->name() == stepAttr) + setNeedsValidityCheck(); #if ENABLE(DATALIST) else if (attr->name() == listAttr) m_hasNonEmptyList = !attr->isEmpty(); @@ -1491,7 +1512,7 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent) dispatchFormControlChangeEvent(); InputElement::notifyFormStateChanged(this); - updateValidity(); + setNeedsValidityCheck(); } double HTMLInputElement::parseToDouble(const String& src, double defaultValue) const @@ -1765,7 +1786,7 @@ void HTMLInputElement::setValueFromRenderer(const String& value) m_data.setSuggestedValue(String()); updatePlaceholderVisibility(false); InputElement::setValueFromRenderer(m_data, this, this, value); - updateValidity(); + setNeedsValidityCheck(); } void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths) @@ -1777,7 +1798,7 @@ void HTMLInputElement::setFileListFromRenderer(const Vector<String>& paths) setFormControlValueMatchesRenderer(true); InputElement::notifyFormStateChanged(this); - updateValidity(); + setNeedsValidityCheck(); } bool HTMLInputElement::storesValueSeparateFromAttribute() const diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp index 5cd0157..279aac7 100644 --- a/WebCore/html/HTMLMediaElement.cpp +++ b/WebCore/html/HTMLMediaElement.cpp @@ -270,7 +270,7 @@ void HTMLMediaElement::insertedIntoDocument() void HTMLMediaElement::removedFromDocument() { if (m_networkState > NETWORK_EMPTY) - pause(); + pause(processingUserGesture()); if (m_isFullscreen) exitFullscreen(); HTMLElement::removedFromDocument(); @@ -421,9 +421,9 @@ String HTMLMediaElement::canPlayType(const String& mimeType) const return canPlay; } -void HTMLMediaElement::load(ExceptionCode& ec) +void HTMLMediaElement::load(bool isUserGesture, ExceptionCode& ec) { - if (m_restrictions & RequireUserGestureForLoadRestriction && !processingUserGesture()) + if (m_restrictions & RequireUserGestureForLoadRestriction && !isUserGesture) ec = INVALID_STATE_ERR; else { prepareForLoad(); @@ -1120,9 +1120,9 @@ void HTMLMediaElement::setAutobuffer(bool b) setBooleanAttribute(autobufferAttr, b); } -void HTMLMediaElement::play() +void HTMLMediaElement::play(bool isUserGesture) { - if (m_restrictions & RequireUserGestureForRateChangeRestriction && !processingUserGesture()) + if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture) return; playInternal(); @@ -1155,9 +1155,9 @@ void HTMLMediaElement::playInternal() updatePlayState(); } -void HTMLMediaElement::pause() +void HTMLMediaElement::pause(bool isUserGesture) { - if (m_restrictions & RequireUserGestureForRateChangeRestriction && !processingUserGesture()) + if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture) return; pauseInternal(); @@ -1235,7 +1235,15 @@ void HTMLMediaElement::setMuted(bool muted) { if (m_muted != muted) { m_muted = muted; - updateVolume(); + // Avoid recursion when the player reports volume changes. + if (!processingMediaPlayerCallback()) { + if (m_player && m_player->supportsMuting()) { + m_player->setMuted(m_muted); + if (renderer()) + renderer()->updateFromElement(); + } else + updateVolume(); + } scheduleEvent(eventNames().volumechangeEvent); } } @@ -1257,7 +1265,7 @@ void HTMLMediaElement::beginScrubbing() // Because a media element stays in non-paused state when it reaches end, playback resumes // when the slider is dragged from the end to another position unless we pause first. Do // a "hard pause" so an event is generated, since we want to stay paused after scrubbing finishes. - pause(); + pause(processingUserGesture()); } else { // Not at the end but we still want to pause playback so the media engine doesn't try to // continue playing during scrubbing. Pause without generating an event as we will @@ -1444,10 +1452,20 @@ void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*) void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*) { beginProcessingMediaPlayerCallback(); + if (m_player) + m_volume = m_player->volume(); updateVolume(); endProcessingMediaPlayerCallback(); } +void HTMLMediaElement::mediaPlayerMuteChanged(MediaPlayer*) +{ + beginProcessingMediaPlayerCallback(); + if (m_player) + setMuted(m_player->muted()); + endProcessingMediaPlayerCallback(); +} + void HTMLMediaElement::mediaPlayerDurationChanged(MediaPlayer*) { beginProcessingMediaPlayerCallback(); @@ -1743,7 +1761,7 @@ void HTMLMediaElement::documentDidBecomeActive() // MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards). // This behavior is not specified but it seems like a sensible thing to do. ExceptionCode ec; - load(ec); + load(processingUserGesture(), ec); } if (renderer()) @@ -1860,37 +1878,6 @@ PlatformMedia HTMLMediaElement::platformMedia() const return m_player ? m_player->platformMedia() : NoPlatformMedia; } -void HTMLMediaElement::webkitEnterFullScreen(ExceptionCode& ec) -{ - if (m_isFullscreen) - return; - - // Generate an exception if this isn't called in response to a user gesture, or if the - // element does not support fullscreen. - if (!processingUserGesture() || !supportsFullscreen()) { - ec = INVALID_STATE_ERR; - return; - } - - enterFullscreen(); -} - -void HTMLMediaElement::webkitExitFullScreen() -{ - if (m_isFullscreen) - exitFullscreen(); -} - -bool HTMLMediaElement::webkitSupportsFullscreen() -{ - return supportsFullscreen(); -} - -bool HTMLMediaElement::webkitDisplayingFullscreen() -{ - return m_isFullscreen; -} - bool HTMLMediaElement::hasClosedCaptions() const { return m_player && m_player->hasClosedCaptions(); diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h index 9ee2c25..45a41c6 100644 --- a/WebCore/html/HTMLMediaElement.h +++ b/WebCore/html/HTMLMediaElement.h @@ -102,7 +102,7 @@ public: void setAutobuffer(bool); PassRefPtr<TimeRanges> buffered() const; - void load(ExceptionCode&); + void load(bool isUserGesture, ExceptionCode&); String canPlayType(const String& mimeType) const; // ready state @@ -129,14 +129,8 @@ public: void setAutoplay(bool b); bool loop() const; void setLoop(bool b); - void play(); - void pause(); - -// fullscreen - void webkitEnterFullScreen(ExceptionCode&); - void webkitExitFullScreen(); - bool webkitSupportsFullscreen(); - bool webkitDisplayingFullscreen(); + void play(bool isUserGesture); + void pause(bool isUserGesture); // captions bool webkitHasClosedCaptions() const; @@ -177,6 +171,8 @@ public: bool closedCaptionsVisible() const; void setClosedCaptionsVisible(bool); + bool processingUserGesture() const; + protected: float getTimeOffsetAttribute(const QualifiedName&, float valueOnError) const; void setTimeOffsetAttribute(const QualifiedName&, float value); @@ -196,6 +192,7 @@ private: // MediaPlayerClient virtual void mediaPlayerReadyStateChanged(MediaPlayer*); virtual void mediaPlayerTimeChanged(MediaPlayer*); virtual void mediaPlayerVolumeChanged(MediaPlayer*); + virtual void mediaPlayerMuteChanged(MediaPlayer*); virtual void mediaPlayerDurationChanged(MediaPlayer*); virtual void mediaPlayerRateChanged(MediaPlayer*); virtual void mediaPlayerSawUnsupportedTracks(MediaPlayer*); @@ -246,7 +243,6 @@ private: void prepareForLoad(); - bool processingUserGesture() const; bool processingMediaPlayerCallback() const { return m_processingMediaPlayerCallback > 0; } void beginProcessingMediaPlayerCallback() { ++m_processingMediaPlayerCallback; } void endProcessingMediaPlayerCallback() { ASSERT(m_processingMediaPlayerCallback); --m_processingMediaPlayerCallback; } diff --git a/WebCore/html/HTMLMediaElement.idl b/WebCore/html/HTMLMediaElement.idl index 1097e55..46a2b86 100644 --- a/WebCore/html/HTMLMediaElement.idl +++ b/WebCore/html/HTMLMediaElement.idl @@ -42,7 +42,7 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement { attribute boolean autobuffer; readonly attribute TimeRanges buffered; - void load() + [NeedsUserGestureCheck] void load() raises (DOMException); DOMString canPlayType(in DOMString type); @@ -68,8 +68,8 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement { readonly attribute boolean ended; attribute boolean autoplay; attribute boolean loop; - void play(); - void pause(); + [NeedsUserGestureCheck] void play(); + [NeedsUserGestureCheck] void pause(); // controls attribute boolean controls; @@ -80,13 +80,6 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement { // WebKit extensions attribute boolean webkitPreservesPitch; - readonly attribute boolean webkitSupportsFullscreen; - readonly attribute boolean webkitDisplayingFullscreen; - - void webkitEnterFullScreen() - raises (DOMException); - void webkitExitFullScreen(); - readonly attribute boolean webkitHasClosedCaptions; attribute boolean webkitClosedCaptionsVisible; }; diff --git a/WebCore/html/HTMLTextAreaElement.cpp b/WebCore/html/HTMLTextAreaElement.cpp index 7159cc7..f74040d 100644 --- a/WebCore/html/HTMLTextAreaElement.cpp +++ b/WebCore/html/HTMLTextAreaElement.cpp @@ -154,7 +154,9 @@ void HTMLTextAreaElement::parseMappedAttribute(MappedAttribute* attr) } else if (attr->name() == alignAttr) { // Don't map 'align' attribute. This matches what Firefox, Opera and IE do. // See http://bugs.webkit.org/show_bug.cgi?id=7075 - } else + } else if (attr->name() == maxlengthAttr) + setNeedsValidityCheck(); + else HTMLTextFormControlElement::parseMappedAttribute(attr); } @@ -305,9 +307,8 @@ void HTMLTextAreaElement::setValue(const String& value) setSelectionRange(endOfString, endOfString); } - setNeedsStyleRecalc(); + setNeedsValidityCheck(); notifyFormStateChanged(this); - updateValidity(); } String HTMLTextAreaElement::defaultValue() const diff --git a/WebCore/html/HTMLVideoElement.cpp b/WebCore/html/HTMLVideoElement.cpp index 1fae354..be8f884 100644 --- a/WebCore/html/HTMLVideoElement.cpp +++ b/WebCore/html/HTMLVideoElement.cpp @@ -33,6 +33,7 @@ #include "CSSHelper.h" #include "CSSPropertyNames.h" #include "Document.h" +#include "ExceptionCode.h" #include "HTMLImageLoader.h" #include "HTMLNames.h" #include "MappedAttribute.h" @@ -197,8 +198,6 @@ void HTMLVideoElement::updatePosterImage() void HTMLVideoElement::paint(GraphicsContext* context, const IntRect& destRect) { - // FIXME: We should also be able to paint the poster image. - MediaPlayer* player = HTMLMediaElement::player(); if (!player) return; @@ -209,8 +208,6 @@ void HTMLVideoElement::paint(GraphicsContext* context, const IntRect& destRect) void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& destRect) { - // FIXME: We should also be able to paint the poster image. - MediaPlayer* player = HTMLMediaElement::player(); if (!player) return; @@ -227,5 +224,37 @@ bool HTMLVideoElement::hasAvailableVideoFrame() const return m_player->hasAvailableVideoFrame(); } +void HTMLVideoElement::webkitEnterFullScreen(bool isUserGesture, ExceptionCode& ec) +{ + if (m_isFullscreen) + return; + + // Generate an exception if this isn't called in response to a user gesture, or if the + // element does not support fullscreen. + if (!isUserGesture || !supportsFullscreen()) { + ec = INVALID_STATE_ERR; + return; + } + + enterFullscreen(); +} + +void HTMLVideoElement::webkitExitFullScreen() +{ + if (m_isFullscreen) + exitFullscreen(); +} + +bool HTMLVideoElement::webkitSupportsFullscreen() +{ + return supportsFullscreen(); +} + +bool HTMLVideoElement::webkitDisplayingFullscreen() +{ + return m_isFullscreen; +} + + } #endif diff --git a/WebCore/html/HTMLVideoElement.h b/WebCore/html/HTMLVideoElement.h index 834ec4c..a5c005c 100644 --- a/WebCore/html/HTMLVideoElement.h +++ b/WebCore/html/HTMLVideoElement.h @@ -64,6 +64,12 @@ public: const KURL& poster() const { return m_posterURL; } void setPoster(const String&); +// fullscreen + void webkitEnterFullScreen(bool isUserGesture, ExceptionCode&); + void webkitExitFullScreen(); + bool webkitSupportsFullscreen(); + bool webkitDisplayingFullscreen(); + void updatePosterImage(); bool shouldDisplayPosterImage() const { return m_shouldDisplayPosterImage; } diff --git a/WebCore/html/HTMLVideoElement.idl b/WebCore/html/HTMLVideoElement.idl index f43bf82..c4764ac 100644 --- a/WebCore/html/HTMLVideoElement.idl +++ b/WebCore/html/HTMLVideoElement.idl @@ -30,5 +30,13 @@ module html { readonly attribute unsigned long videoWidth; readonly attribute unsigned long videoHeight; attribute [ConvertNullToNullString] DOMString poster; + + readonly attribute boolean webkitSupportsFullscreen; + readonly attribute boolean webkitDisplayingFullscreen; + + [NeedsUserGestureCheck] void webkitEnterFullScreen() + raises (DOMException); + void webkitExitFullScreen(); + }; } diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.cpp b/WebCore/html/canvas/CanvasRenderingContext2D.cpp index 1e09534..8add19c 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.cpp +++ b/WebCore/html/canvas/CanvasRenderingContext2D.cpp @@ -30,7 +30,7 @@ #include "config.h" #include "CanvasRenderingContext2D.h" -#include "TransformationMatrix.h" +#include "AffineTransform.h" #include "CSSParser.h" #include "CachedImage.h" #include "CanvasGradient.h" @@ -357,7 +357,7 @@ void CanvasRenderingContext2D::scale(float sx, float sy) if (!isfinite(sx) | !isfinite(sy)) return; - TransformationMatrix newTransform = state().m_transform; + AffineTransform newTransform = state().m_transform; newTransform.scaleNonUniform(sx, sy); if (!newTransform.isInvertible()) { state().m_invertibleCTM = false; @@ -366,7 +366,7 @@ void CanvasRenderingContext2D::scale(float sx, float sy) state().m_transform = newTransform; c->scale(FloatSize(sx, sy)); - m_path.transform(TransformationMatrix().scaleNonUniform(1.0/sx, 1.0/sy)); + m_path.transform(AffineTransform().scaleNonUniform(1.0 / sx, 1.0 / sy)); } void CanvasRenderingContext2D::rotate(float angleInRadians) @@ -380,7 +380,7 @@ void CanvasRenderingContext2D::rotate(float angleInRadians) if (!isfinite(angleInRadians)) return; - TransformationMatrix newTransform = state().m_transform; + AffineTransform newTransform = state().m_transform; newTransform.rotate(angleInRadians / piDouble * 180.0); if (!newTransform.isInvertible()) { state().m_invertibleCTM = false; @@ -389,7 +389,7 @@ void CanvasRenderingContext2D::rotate(float angleInRadians) state().m_transform = newTransform; c->rotate(angleInRadians); - m_path.transform(TransformationMatrix().rotate(-angleInRadians / piDouble * 180.0)); + m_path.transform(AffineTransform().rotate(-angleInRadians / piDouble * 180.0)); } void CanvasRenderingContext2D::translate(float tx, float ty) @@ -403,7 +403,7 @@ void CanvasRenderingContext2D::translate(float tx, float ty) if (!isfinite(tx) | !isfinite(ty)) return; - TransformationMatrix newTransform = state().m_transform; + AffineTransform newTransform = state().m_transform; newTransform.translate(tx, ty); if (!newTransform.isInvertible()) { state().m_invertibleCTM = false; @@ -412,7 +412,7 @@ void CanvasRenderingContext2D::translate(float tx, float ty) state().m_transform = newTransform; c->translate(tx, ty); - m_path.transform(TransformationMatrix().translate(-tx, -ty)); + m_path.transform(AffineTransform().translate(-tx, -ty)); } void CanvasRenderingContext2D::transform(float m11, float m12, float m21, float m22, float dx, float dy) @@ -427,8 +427,8 @@ void CanvasRenderingContext2D::transform(float m11, float m12, float m21, float !isfinite(m12) | !isfinite(m22) | !isfinite(dy)) return; - TransformationMatrix transform(m11, m12, m21, m22, dx, dy); - TransformationMatrix newTransform = transform * state().m_transform; + AffineTransform transform(m11, m12, m21, m22, dx, dy); + AffineTransform newTransform = transform * state().m_transform; if (!newTransform.isInvertible()) { state().m_invertibleCTM = false; return; @@ -449,7 +449,7 @@ void CanvasRenderingContext2D::setTransform(float m11, float m12, float m21, flo !isfinite(m12) | !isfinite(m22) | !isfinite(dy)) return; - TransformationMatrix ctm = state().m_transform; + AffineTransform ctm = state().m_transform; if (!ctm.isInvertible()) return; c->concatCTM(c->getCTM().inverse()); @@ -708,7 +708,7 @@ bool CanvasRenderingContext2D::isPointInPath(const float x, const float y) return false; FloatPoint point(x, y); - TransformationMatrix ctm = state().m_transform; + AffineTransform ctm = state().m_transform; FloatPoint transformedPoint = ctm.inverse().mapPoint(point); return m_path.contains(transformedPoint); } @@ -1241,7 +1241,7 @@ void CanvasRenderingContext2D::willDraw(const FloatRect& r, unsigned options) FloatRect dirtyRect = r; if (options & CanvasWillDrawApplyTransform) { - TransformationMatrix ctm = state().m_transform; + AffineTransform ctm = state().m_transform; dirtyRect = ctm.mapRect(r); } diff --git a/WebCore/html/canvas/CanvasRenderingContext2D.h b/WebCore/html/canvas/CanvasRenderingContext2D.h index 283f92c..553ffd2 100644 --- a/WebCore/html/canvas/CanvasRenderingContext2D.h +++ b/WebCore/html/canvas/CanvasRenderingContext2D.h @@ -26,8 +26,8 @@ #ifndef CanvasRenderingContext2D_h #define CanvasRenderingContext2D_h +#include "AffineTransform.h" #include "CanvasRenderingContext.h" -#include "TransformationMatrix.h" #include "FloatSize.h" #include "Font.h" #include "GraphicsTypes.h" @@ -218,7 +218,7 @@ namespace WebCore { String m_shadowColor; float m_globalAlpha; CompositeOperator m_globalComposite; - TransformationMatrix m_transform; + AffineTransform m_transform; bool m_invertibleCTM; // Text state. diff --git a/WebCore/inspector/InjectedScript.cpp b/WebCore/inspector/InjectedScript.cpp new file mode 100644 index 0000000..5525877 --- /dev/null +++ b/WebCore/inspector/InjectedScript.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "InjectedScript.h" + +#if ENABLE(INSPECTOR) + +#include "PlatformString.h" +#include "ScriptFunctionCall.h" + +namespace WebCore { + +InjectedScript::InjectedScript(ScriptObject injectedScriptObject) + : m_injectedScriptObject(injectedScriptObject) +{ +} + +void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException) +{ + ASSERT(!hasNoValue()); + ScriptState* scriptState = m_injectedScriptObject.scriptState(); + ScriptFunctionCall function(scriptState, m_injectedScriptObject, "dispatch"); + function.appendArgument(methodName); + function.appendArgument(arguments); + if (async) + function.appendArgument(callId); + *hadException = false; + ScriptValue resultValue = function.call(*hadException); + if (!*hadException) + *result = resultValue.toString(scriptState); +} + +#if ENABLE(JAVASCRIPT_DEBUGGER) +String InjectedScript::callFrames() +{ + ASSERT(!hasNoValue()); + ScriptState* scriptState = m_injectedScriptObject.scriptState(); + ScriptFunctionCall function(scriptState, m_injectedScriptObject, "callFrames"); + ScriptValue callFramesValue = function.call(); + return callFramesValue.toString(scriptState); +} +#endif + +String InjectedScript::wrapAndStringifyForConsole(ScriptValue value) +{ + ASSERT(!hasNoValue()); + ScriptState* scriptState = m_injectedScriptObject.scriptState(); + ScriptFunctionCall wrapFunction(scriptState, m_injectedScriptObject, "wrapAndStringifyObject"); + wrapFunction.appendArgument(value); + wrapFunction.appendArgument("console"); + ScriptValue r = wrapFunction.call(); + if (r.hasNoValue()) + return ""; + return r.toString(scriptState); +} + +void InjectedScript::releaseWrapperObjectGroup(const String& objectGroup) +{ + ASSERT(!hasNoValue()); + ScriptState* scriptState = m_injectedScriptObject.scriptState(); + ScriptFunctionCall releaseFunction(scriptState, m_injectedScriptObject, "releaseWrapperObjectGroup"); + releaseFunction.appendArgument(objectGroup); + releaseFunction.call(); +} + +} // namespace WebCore + +#endif // ENABLE(INSPECTOR) diff --git a/WebCore/inspector/InjectedScript.h b/WebCore/inspector/InjectedScript.h new file mode 100644 index 0000000..b70ee39 --- /dev/null +++ b/WebCore/inspector/InjectedScript.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef InjectedScript_h +#define InjectedScript_h + +#include "InjectedScriptHost.h" +#include "ScriptObject.h" +#include <wtf/Noncopyable.h> + +namespace WebCore { + +class String; + +class InjectedScript { +public: + InjectedScript() { } + ~InjectedScript() { } + + bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); } + + void dispatch(long callId, const String& methodName, const String& arguments, bool async, String* result, bool* hadException); +#if ENABLE(JAVASCRIPT_DEBUGGER) + String callFrames(); +#endif + String wrapAndStringifyForConsole(ScriptValue); + void releaseWrapperObjectGroup(const String&); + +private: + friend InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState*); + explicit InjectedScript(ScriptObject); + ScriptObject m_injectedScriptObject; +}; + +} // namespace WebCore + +#endif diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp index d5bbd1c..13e156a 100644 --- a/WebCore/inspector/InjectedScriptHost.cpp +++ b/WebCore/inspector/InjectedScriptHost.cpp @@ -38,6 +38,7 @@ #include "Frame.h" #include "FrameLoader.h" #include "HTMLFrameOwnerElement.h" +#include "InjectedScript.h" #include "InspectorClient.h" #include "InspectorController.h" #include "InspectorDOMAgent.h" @@ -47,7 +48,7 @@ #include "ScriptArray.h" #include "ScriptFunctionCall.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "JavaScriptCallFrame.h" #include "JavaScriptDebugServer.h" using namespace JSC; @@ -131,7 +132,7 @@ long InjectedScriptHost::pushNodeByPathToFrontend(const String& path) return domAgent->pushNodePathToFrontend(node); } -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) JavaScriptCallFrame* InjectedScriptHost::currentCallFrame() const { return JavaScriptDebugServer::shared().currentCallFrame(); @@ -167,7 +168,7 @@ void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, const St frontend->didDispatchOnInjectedScript(callId, result, isException); } -ScriptObject InjectedScriptHost::injectedScriptForId(long id) +InjectedScript InjectedScriptHost::injectedScriptForId(long id) { return m_idToInjectedScript.get(id); } @@ -180,13 +181,13 @@ void InjectedScriptHost::discardInjectedScripts() void InjectedScriptHost::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup) { if (injectedScriptId) { - ScriptObject injectedScript = m_idToInjectedScript.get(injectedScriptId); + InjectedScript injectedScript = m_idToInjectedScript.get(injectedScriptId); if (!injectedScript.hasNoValue()) - releaseWrapperObjectGroup(injectedScript, objectGroup); + injectedScript.releaseWrapperObjectGroup(objectGroup); } else { // Iterate over all injected scripts if injectedScriptId is not specified. for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != m_idToInjectedScript.end(); ++it) - releaseWrapperObjectGroup(it->second, objectGroup); + it->second.releaseWrapperObjectGroup(objectGroup); } } @@ -204,13 +205,6 @@ InspectorFrontend* InjectedScriptHost::inspectorFrontend() return m_inspectorController->m_frontend.get(); } -void InjectedScriptHost::releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup) -{ - ScriptFunctionCall releaseFunction(injectedScript.scriptState(), injectedScript, "releaseWrapperObjectGroup"); - releaseFunction.appendArgument(objectGroup); - releaseFunction.call(); -} - } // namespace WebCore #endif // ENABLE(INSPECTOR) diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h index d91c8e2..901472c 100644 --- a/WebCore/inspector/InjectedScriptHost.h +++ b/WebCore/inspector/InjectedScriptHost.h @@ -41,6 +41,7 @@ namespace WebCore { class Database; +class InjectedScript; class InspectorDOMAgent; class InspectorFrontend; class JavaScriptCallFrame; @@ -71,7 +72,7 @@ public: void addNodesToSearchResult(const String& nodeIds); long pushNodeByPathToFrontend(const String& path); -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) JavaScriptCallFrame* currentCallFrame() const; #endif #if ENABLE(DATABASE) @@ -83,8 +84,8 @@ public: #endif void reportDidDispatchOnInjectedScript(long callId, const String& result, bool isException); - ScriptObject injectedScriptFor(ScriptState*); - ScriptObject injectedScriptForId(long); + InjectedScript injectedScriptFor(ScriptState*); + InjectedScript injectedScriptForId(long); void discardInjectedScripts(); void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup); @@ -93,12 +94,10 @@ private: InspectorDOMAgent* inspectorDOMAgent(); InspectorFrontend* inspectorFrontend(); - void releaseWrapperObjectGroup(const ScriptObject& injectedScript, const String& objectGroup); - InspectorController* m_inspectorController; String m_injectedScriptSource; long m_nextInjectedScriptId; - typedef HashMap<long, ScriptObject> IdToInjectedScriptMap; + typedef HashMap<long, InjectedScript> IdToInjectedScriptMap; IdToInjectedScriptMap m_idToInjectedScript; }; diff --git a/WebCore/inspector/InspectorBackend.cpp b/WebCore/inspector/InspectorBackend.cpp index 999a4b7..1ce0e69 100644 --- a/WebCore/inspector/InspectorBackend.cpp +++ b/WebCore/inspector/InspectorBackend.cpp @@ -40,6 +40,7 @@ #include "Frame.h" #include "FrameLoader.h" #include "HTMLFrameOwnerElement.h" +#include "InjectedScript.h" #include "InjectedScriptHost.h" #include "InspectorClient.h" #include "InspectorController.h" @@ -54,7 +55,7 @@ #include "Storage.h" #endif -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "JavaScriptCallFrame.h" #include "JavaScriptDebugServer.h" using namespace JSC; @@ -147,7 +148,7 @@ void InspectorBackend::stopTimelineProfiler() m_inspectorController->stopTimelineProfiler(); } -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) bool InspectorBackend::debuggerEnabled() const { if (m_inspectorController) @@ -285,7 +286,7 @@ void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScript // FIXME: explicitly pass injectedScriptId along with node id to the frontend. bool injectedScriptIdIsNodeId = injectedScriptId <= 0; - ScriptObject injectedScript; + InjectedScript injectedScript; if (injectedScriptIdIsNodeId) injectedScript = m_inspectorController->injectedScriptForNodeId(-injectedScriptId); else @@ -294,19 +295,12 @@ void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScript if (injectedScript.hasNoValue()) return; - ScriptFunctionCall function(injectedScript.scriptState(), injectedScript, "dispatch"); - function.appendArgument(methodName); - function.appendArgument(arguments); - if (async) - function.appendArgument(callId); + String result; bool hadException = false; - ScriptValue result = function.call(hadException); + injectedScript.dispatch(callId, methodName, arguments, async, &result, &hadException); if (async) return; // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript. - if (hadException) - frontend->didDispatchOnInjectedScript(callId, "", true); - else - frontend->didDispatchOnInjectedScript(callId, result.toString(injectedScript.scriptState()), false); + frontend->didDispatchOnInjectedScript(callId, result, hadException); } void InspectorBackend::getChildNodes(long callId, long nodeId) diff --git a/WebCore/inspector/InspectorBackend.h b/WebCore/inspector/InspectorBackend.h index 81c1f2d..7c9644f 100644 --- a/WebCore/inspector/InspectorBackend.h +++ b/WebCore/inspector/InspectorBackend.h @@ -73,7 +73,7 @@ public: void startTimelineProfiler(); void stopTimelineProfiler(); -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) bool debuggerEnabled() const; void enableDebugger(bool always); void disableDebugger(bool always); diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp index 5ab1354..1dbb898 100644 --- a/WebCore/inspector/InspectorController.cpp +++ b/WebCore/inspector/InspectorController.cpp @@ -39,9 +39,9 @@ #include "ConsoleMessage.h" #include "Cookie.h" #include "CookieJar.h" +#include "DOMWindow.h" #include "Document.h" #include "DocumentLoader.h" -#include "DOMWindow.h" #include "Element.h" #include "FloatConversion.h" #include "FloatQuad.h" @@ -53,16 +53,17 @@ #include "GraphicsContext.h" #include "HTMLFrameOwnerElement.h" #include "HitTestResult.h" -#include "InspectorBackend.h" #include "InjectedScriptHost.h" +#include "InjectedScript.h" +#include "InspectorBackend.h" #include "InspectorClient.h" -#include "InspectorFrontend.h" -#include "InspectorFrontendHost.h" -#include "InspectorDatabaseResource.h" #include "InspectorDOMAgent.h" #include "InspectorDOMStorageResource.h" -#include "InspectorTimelineAgent.h" +#include "InspectorDatabaseResource.h" +#include "InspectorFrontend.h" +#include "InspectorFrontendHost.h" #include "InspectorResource.h" +#include "InspectorTimelineAgent.h" #include "JavaScriptProfile.h" #include "Page.h" #include "ProgressTracker.h" @@ -73,6 +74,8 @@ #include "ScriptCallStack.h" #include "ScriptFunctionCall.h" #include "ScriptObject.h" +#include "ScriptProfile.h" +#include "ScriptProfiler.h" #include "ScriptString.h" #include "SecurityOrigin.h" #include "Settings.h" @@ -93,15 +96,12 @@ #include "StorageArea.h" #endif -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) +#include "JSJavaScriptCallFrame.h" #include "JavaScriptCallFrame.h" #include "JavaScriptDebugServer.h" -#include "JSJavaScriptCallFrame.h" -#include <profiler/Profile.h> -#include <profiler/Profiler.h> #include <runtime/JSLock.h> -#include <runtime/StringBuilder.h> #include <runtime/UString.h> using namespace JSC; @@ -132,7 +132,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client) , m_client(client) , m_page(0) , m_expiredConsoleMessageCount(0) - , m_scriptState(0) + , m_frontendScriptState(0) , m_windowVisible(false) , m_showAfterVisible(CurrentPanel) , m_groupLevel(0) @@ -143,7 +143,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client) , m_inspectorBackend(InspectorBackend::create(this)) , m_inspectorFrontendHost(InspectorFrontendHost::create(this, client)) , m_injectedScriptHost(InjectedScriptHost::create(this)) -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) , m_debuggerEnabled(false) , m_attachDebuggerWhenShown(false) , m_profilerEnabled(false) @@ -162,7 +162,7 @@ InspectorController::~InspectorController() { // These should have been cleared in inspectedPageDestroyed(). ASSERT(!m_client); - ASSERT(!m_scriptState); + ASSERT(!m_frontendScriptState); ASSERT(!m_inspectedPage); ASSERT(!m_page || (m_page && !m_page->parentInspectorController())); @@ -183,10 +183,9 @@ void InspectorController::inspectedPageDestroyed() { close(); - if (m_scriptState) { - ScriptGlobalObject::remove(m_scriptState, "InspectorBackend"); - ScriptGlobalObject::remove(m_scriptState, "InspectorFrontendHost"); - ScriptGlobalObject::remove(m_scriptState, "InjectedScriptHost"); + if (m_frontendScriptState) { + ScriptGlobalObject::remove(m_frontendScriptState, "InspectorBackend"); + ScriptGlobalObject::remove(m_frontendScriptState, "InspectorFrontendHost"); } ASSERT(m_inspectedPage); m_inspectedPage = 0; @@ -303,13 +302,13 @@ void InspectorController::setWindowVisible(bool visible, bool attached) if (m_nodeToFocus) focusNode(); -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) if (m_attachDebuggerWhenShown) enableDebugger(); #endif showPanel(m_showAfterVisible); } else { -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) // If the window is being closed with the debugger enabled, // remember this state to re-enable debugger on the next window // opening. @@ -390,7 +389,7 @@ void InspectorController::startGroup(MessageSource source, ScriptCallStack* call void InspectorController::endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL) { - if (m_groupLevel == 0) + if (!m_groupLevel) return; --m_groupLevel; @@ -509,24 +508,23 @@ void InspectorController::windowScriptObjectAvailable() // Grant the inspector the ability to script the inspected page. m_page->mainFrame()->document()->securityOrigin()->grantUniversalAccess(); - m_scriptState = scriptStateFromPage(debuggerWorld(), m_page); - ScriptGlobalObject::set(m_scriptState, "InspectorBackend", m_inspectorBackend.get()); - ScriptGlobalObject::set(m_scriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get()); + m_frontendScriptState = scriptStateFromPage(debuggerWorld(), m_page); + ScriptGlobalObject::set(m_frontendScriptState, "InspectorBackend", m_inspectorBackend.get()); + ScriptGlobalObject::set(m_frontendScriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get()); } void InspectorController::scriptObjectReady() { - ASSERT(m_scriptState); - if (!m_scriptState) + ASSERT(m_frontendScriptState); + if (!m_frontendScriptState) return; ScriptObject webInspectorObj; - if (!ScriptGlobalObject::get(m_scriptState, "WebInspector", webInspectorObj)) + if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) return; - ScriptObject injectedScriptObj; - setFrontendProxyObject(m_scriptState, webInspectorObj, injectedScriptObj); + setFrontendProxyObject(m_frontendScriptState, webInspectorObj); -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) String debuggerEnabled = setting(debuggerEnabledSettingName); if (debuggerEnabled == "true") enableDebugger(); @@ -543,7 +541,7 @@ void InspectorController::scriptObjectReady() void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject) { - m_scriptState = scriptState; + m_frontendScriptState = scriptState; m_frontend.set(new InspectorFrontend(this, scriptState, webInspectorObj)); releaseDOMAgent(); m_domAgent = InspectorDOMAgent::create(m_frontend.get()); @@ -558,7 +556,7 @@ void InspectorController::show() if (!m_page) { if (m_frontend) - return; // We are using custom frontend - no need to create page. + return; // We are using custom frontend - no need to create page. m_page = m_client->createPage(); if (!m_page) @@ -595,7 +593,7 @@ void InspectorController::close() if (!enabled()) return; -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) stopUserInitiatedProfiling(); disableDebugger(); #endif @@ -604,7 +602,7 @@ void InspectorController::close() releaseDOMAgent(); m_frontend.set(0); m_timelineAgent = 0; - m_scriptState = 0; + m_frontendScriptState = 0; if (m_page) { if (!m_page->mainFrame() || !m_page->mainFrame()->loader() || !m_page->mainFrame()->loader()->isLoading()) { m_page->setParentInspectorController(0); @@ -745,7 +743,7 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) m_times.clear(); m_counts.clear(); -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) m_profiles.clear(); m_currentUserInitiatedProfileNumber = 1; m_nextUserInitiatedProfileNumber = 1; @@ -1306,7 +1304,7 @@ void InspectorController::setDOMStorageItem(long callId, long storageId, const S if (storageResource) { ExceptionCode exception = 0; storageResource->domStorage()->setItem(key, value, exception); - success = (exception == 0); + success = !exception; } m_frontend->didSetDOMStorageItem(callId, success); } @@ -1344,13 +1342,13 @@ void InspectorController::moveWindowBy(float x, float y) const m_page->chrome()->setWindowRect(frameRect); } -#if ENABLE(JAVASCRIPT_DEBUGGER) -void InspectorController::addProfile(PassRefPtr<Profile> prpProfile, unsigned lineNumber, const UString& sourceURL) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) +void InspectorController::addProfile(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL) { if (!enabled()) return; - RefPtr<Profile> profile = prpProfile; + RefPtr<ScriptProfile> profile = prpProfile; m_profiles.add(profile->uid(), profile); if (m_frontend) { @@ -1361,30 +1359,18 @@ void InspectorController::addProfile(PassRefPtr<Profile> prpProfile, unsigned li addProfileFinishedMessageToConsole(profile, lineNumber, sourceURL); } -void InspectorController::addProfileFinishedMessageToConsole(PassRefPtr<Profile> prpProfile, unsigned lineNumber, const UString& sourceURL) +void InspectorController::addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL) { - RefPtr<Profile> profile = prpProfile; + RefPtr<ScriptProfile> profile = prpProfile; - JSC::StringBuilder message; - message.append("Profile \"webkit-profile://"); - message.append((UString)encodeWithURLEscapeSequences(CPUProfileType)); - message.append("/"); - message.append((UString)encodeWithURLEscapeSequences(profile->title())); - message.append("#"); - message.append(UString::from(profile->uid())); - message.append("\" finished."); - addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message.release(), lineNumber, sourceURL); + String message = String::format("Profile \"webkit-profile://%s/%s#%d\" finished.", CPUProfileType, encodeWithURLEscapeSequences(profile->title()).utf8().data(), profile->uid()); + addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); } -void InspectorController::addStartProfilingMessageToConsole(const UString& title, unsigned lineNumber, const UString& sourceURL) +void InspectorController::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL) { - JSC::StringBuilder message; - message.append("Profile \"webkit-profile://"); - message.append(encodeWithURLEscapeSequences(CPUProfileType)); - message.append("/"); - message.append(encodeWithURLEscapeSequences(title)); - message.append("#0\" started."); - addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message.release(), lineNumber, sourceURL); + String message = String::format("Profile \"webkit-profile://%s/%s#0\" started.", CPUProfileType, encodeWithURLEscapeSequences(title).utf8().data()); + addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL); } void InspectorController::getProfileHeaders(long callId) @@ -1405,29 +1391,24 @@ void InspectorController::getProfile(long callId, unsigned uid) return; ProfilesMap::iterator it = m_profiles.find(uid); if (it != m_profiles.end()) - m_frontend->didGetProfile(callId, toJS(m_scriptState, it->second.get())); + m_frontend->didGetProfile(callId, toJS(m_frontendScriptState, it->second.get())); } -ScriptObject InspectorController::createProfileHeader(const JSC::Profile& profile) +ScriptObject InspectorController::createProfileHeader(const ScriptProfile& profile) { ScriptObject header = m_frontend->newScriptObject(); header.set("title", profile.title()); header.set("uid", profile.uid()); - header.set("typeId", UString(CPUProfileType)); + header.set("typeId", String(CPUProfileType)); return header; } -UString InspectorController::getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false) +String InspectorController::getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false) { if (incrementProfileNumber) m_currentUserInitiatedProfileNumber = m_nextUserInitiatedProfileNumber++; - JSC::StringBuilder title; - title.append(UserInitiatedProfileName); - title.append("."); - title.append(UString::from(m_currentUserInitiatedProfileNumber)); - - return title.release(); + return String::format("%s.%d", UserInitiatedProfileName, m_currentUserInitiatedProfileNumber); } void InspectorController::startUserInitiatedProfilingSoon() @@ -1447,12 +1428,12 @@ void InspectorController::startUserInitiatedProfiling(Timer<InspectorController> m_recordingUserInitiatedProfile = true; - UString title = getCurrentUserInitiatedProfileName(true); + String title = getCurrentUserInitiatedProfileName(true); ExecState* scriptState = toJSDOMWindow(m_inspectedPage->mainFrame(), debuggerWorld())->globalExec(); - Profiler::profiler()->startProfiling(scriptState, title); + ScriptProfiler::start(scriptState, title); - addStartProfilingMessageToConsole(title, 0, UString()); + addStartProfilingMessageToConsole(title, 0, String()); toggleRecordButton(true); } @@ -1464,12 +1445,12 @@ void InspectorController::stopUserInitiatedProfiling() m_recordingUserInitiatedProfile = false; - UString title = getCurrentUserInitiatedProfileName(); + String title = getCurrentUserInitiatedProfileName(); ExecState* scriptState = toJSDOMWindow(m_inspectedPage->mainFrame(), debuggerWorld())->globalExec(); - RefPtr<Profile> profile = Profiler::profiler()->stopProfiling(scriptState, title); + RefPtr<ScriptProfile> profile = ScriptProfiler::stop(scriptState, title); if (profile) - addProfile(profile, 0, UString()); + addProfile(profile, 0, String()); toggleRecordButton(false); } @@ -1536,9 +1517,9 @@ void InspectorController::enableDebugger() if (m_debuggerEnabled) return; - if (!m_scriptState || !m_frontend) { + if (!m_frontendScriptState || !m_frontend) m_attachDebuggerWhenShown = true; - } else { + else { m_frontend->attachDebuggerWhenShown(); m_attachDebuggerWhenShown = false; } @@ -1587,11 +1568,8 @@ void InspectorController::didPause() JavaScriptCallFrame* callFrame = m_injectedScriptHost->currentCallFrame(); ScriptState* scriptState = callFrame->scopeChain()->globalObject->globalExec(); ASSERT(scriptState); - ScriptObject injectedScriptObj = m_injectedScriptHost->injectedScriptFor(scriptState); - ScriptFunctionCall function(scriptState, injectedScriptObj, "getCallFrames"); - ScriptValue callFramesValue = function.call(); - String callFrames = callFramesValue.toString(scriptState); - + InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(scriptState); + String callFrames = injectedScript.callFrames(); m_frontend->pausedScript(callFrames); } @@ -1803,20 +1781,19 @@ InspectorController::SpecialPanels InspectorController::specialPanelForJSName(co { if (panelName == "elements") return ElementsPanel; - else if (panelName == "resources") + if (panelName == "resources") return ResourcesPanel; - else if (panelName == "scripts") + if (panelName == "scripts") return ScriptsPanel; - else if (panelName == "timeline") + if (panelName == "timeline") return TimelinePanel; - else if (panelName == "profiles") + if (panelName == "profiles") return ProfilesPanel; - else if (panelName == "storage" || panelName == "databases") + if (panelName == "storage" || panelName == "databases") return StoragePanel; - else if (panelName == "console") + if (panelName == "console") return ConsolePanel; - else - return ElementsPanel; + return ElementsPanel; } void InspectorController::deleteCookie(const String& cookieName, const String& domain) @@ -1829,7 +1806,7 @@ void InspectorController::deleteCookie(const String& cookieName, const String& d } } -ScriptObject InspectorController::injectedScriptForNodeId(long id) +InjectedScript InspectorController::injectedScriptForNodeId(long id) { Frame* frame = 0; @@ -1847,7 +1824,7 @@ ScriptObject InspectorController::injectedScriptForNodeId(long id) if (frame) return m_injectedScriptHost->injectedScriptFor(mainWorldScriptState(frame)); - return ScriptObject(); + return InjectedScript(); } } // namespace WebCore diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h index 860bf49..6904380 100644 --- a/WebCore/inspector/InspectorController.h +++ b/WebCore/inspector/InspectorController.h @@ -35,6 +35,7 @@ #include "PlatformString.h" #include "ScriptArray.h" #include "ScriptObject.h" +#include "ScriptProfile.h" #include "ScriptState.h" #include "ScriptValue.h" #include "StringHash.h" @@ -46,12 +47,11 @@ #include <wtf/RefCounted.h> #include <wtf/Vector.h> -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "JavaScriptDebugListener.h" namespace JSC { - class Profile; - class UString; +class UString; } #endif @@ -64,6 +64,7 @@ class DocumentLoader; class Element; class GraphicsContext; class HitTestResult; +class InjectedScript; class InjectedScriptHost; class InspectorBackend; class InspectorClient; @@ -89,7 +90,7 @@ class InspectorDOMStorageResource; class InspectorResource; class InspectorController -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) : JavaScriptDebugListener, public Noncopyable #else : public Noncopyable @@ -149,7 +150,7 @@ public: void detachWindow(); void toggleSearchForNodeInPage(); - bool searchingForNodeInPage() { return m_searchingForNode; }; + bool searchingForNodeInPage() const { return m_searchingForNode; } void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); void handleMousePressOnNode(Node*); @@ -157,7 +158,7 @@ public: void windowScriptObjectAvailable(); void setFrontendProxyObject(ScriptState* state, ScriptObject webInspectorObj, ScriptObject injectedScriptObj = ScriptObject()); - ScriptState* frontendScriptState() const { return m_scriptState; } + ScriptState* frontendScriptState() const { return m_frontendScriptState; } void populateScriptObjects(); void resetScriptObjects(); @@ -219,14 +220,14 @@ public: void markTimeline(const String& message); -#if ENABLE(JAVASCRIPT_DEBUGGER) - void addProfile(PassRefPtr<JSC::Profile>, unsigned lineNumber, const JSC::UString& sourceURL); - void addProfileFinishedMessageToConsole(PassRefPtr<JSC::Profile>, unsigned lineNumber, const JSC::UString& sourceURL); - void addStartProfilingMessageToConsole(const JSC::UString& title, unsigned lineNumber, const JSC::UString& sourceURL); +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) + void addProfile(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); + void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL); + void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL); bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; } - JSC::UString getCurrentUserInitiatedProfileName(bool incrementProfileNumber); + String getCurrentUserInitiatedProfileName(bool incrementProfileNumber); void startUserInitiatedProfiling(Timer<InspectorController>* = 0); void stopUserInitiatedProfiling(); @@ -248,7 +249,7 @@ public: void evaluateForTestInFrontend(long callId, const String& script); - ScriptObject injectedScriptForNodeId(long id); + InjectedScript injectedScriptForNodeId(long id); private: static const char* const FrontendSettingsSettingName; @@ -267,15 +268,15 @@ private: void deleteCookie(const String& cookieName, const String& domain); -#if ENABLE(JAVASCRIPT_DEBUGGER) - typedef HashMap<unsigned int, RefPtr<JSC::Profile> > ProfilesMap; +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) + typedef HashMap<unsigned int, RefPtr<ScriptProfile> > ProfilesMap; void startUserInitiatedProfilingSoon(); void toggleRecordButton(bool); void enableDebuggerFromFrontend(bool always); void getProfileHeaders(long callId); void getProfile(long callId, unsigned uid); - ScriptObject createProfileHeader(const JSC::Profile& profile); + ScriptObject createProfileHeader(const ScriptProfile& profile); #endif #if ENABLE(DATABASE) void selectDatabase(Database* database); @@ -328,7 +329,7 @@ private: #if ENABLE(DOM_STORAGE) DOMStorageResourcesMap m_domStorageResources; #endif - ScriptState* m_scriptState; + ScriptState* m_frontendScriptState; bool m_windowVisible; SpecialPanels m_showAfterVisible; RefPtr<Node> m_highlightedNode; @@ -345,7 +346,7 @@ private: mutable Settings m_settings; Vector<pair<long, String> > m_pendingEvaluateTestCommands; -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) bool m_debuggerEnabled; bool m_attachDebuggerWhenShown; bool m_profilerEnabled; diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp index d5c817d..c3bf1b4 100644 --- a/WebCore/inspector/InspectorFrontend.cpp +++ b/WebCore/inspector/InspectorFrontend.cpp @@ -34,6 +34,7 @@ #include "ConsoleMessage.h" #include "Frame.h" +#include "InjectedScript.h" #include "InjectedScriptHost.h" #include "InspectorController.h" #include "Node.h" @@ -43,7 +44,7 @@ #include "ScriptString.h" #include <wtf/OwnPtr.h> -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include <parser/SourceCode.h> #include <runtime/JSValue.h> #include <runtime/UString.h> @@ -105,15 +106,9 @@ void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const function.appendArgument(frames[i]); } else if (!arguments.isEmpty()) { function.appendArgument(true); - ScriptObject injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState); + InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState); for (unsigned i = 0; i < arguments.size(); ++i) { - ScriptFunctionCall wrapFunction(scriptState, injectedScript, "wrapAndStringifyObject"); - wrapFunction.appendArgument(arguments[i]); - wrapFunction.appendArgument("console"); - ScriptValue r = wrapFunction.call(); - if (r.hasNoValue()) - return; - String s = r.toString(scriptState); + String s = injectedScript.wrapAndStringifyForConsole(arguments[i]); function.appendArgument(s); } } else { @@ -252,7 +247,7 @@ void InspectorFrontend::addRecordToTimeline(const ScriptObject& record) function.call(); } -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) void InspectorFrontend::attachDebuggerWhenShown() { callSimpleFunction("attachDebuggerWhenShown"); diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h index 0b52566..a36a323 100644 --- a/WebCore/inspector/InspectorFrontend.h +++ b/WebCore/inspector/InspectorFrontend.h @@ -35,7 +35,7 @@ #include "ScriptState.h" #include <wtf/PassOwnPtr.h> -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) namespace JSC { class JSValue; class SourceCode; @@ -84,7 +84,7 @@ namespace WebCore { void resourceTrackingWasEnabled(); void resourceTrackingWasDisabled(); -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) void attachDebuggerWhenShown(); void debuggerWasEnabled(); void debuggerWasDisabled(); diff --git a/WebCore/inspector/JavaScriptCallFrame.cpp b/WebCore/inspector/JavaScriptCallFrame.cpp index cbc5314..e6f75b8 100644 --- a/WebCore/inspector/JavaScriptCallFrame.cpp +++ b/WebCore/inspector/JavaScriptCallFrame.cpp @@ -27,7 +27,7 @@ #include "JavaScriptCallFrame.h" #include "JSDOMBinding.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "PlatformString.h" #include <debugger/DebuggerCallFrame.h> diff --git a/WebCore/inspector/JavaScriptCallFrame.h b/WebCore/inspector/JavaScriptCallFrame.h index 47cdac2..bf61c4b 100644 --- a/WebCore/inspector/JavaScriptCallFrame.h +++ b/WebCore/inspector/JavaScriptCallFrame.h @@ -26,7 +26,7 @@ #ifndef JavaScriptCallFrame_h #define JavaScriptCallFrame_h -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include <interpreter/CallFrame.h> #include <wtf/PassRefPtr.h> diff --git a/WebCore/inspector/JavaScriptDebugListener.h b/WebCore/inspector/JavaScriptDebugListener.h index 912a751..6570065 100644 --- a/WebCore/inspector/JavaScriptDebugListener.h +++ b/WebCore/inspector/JavaScriptDebugListener.h @@ -29,7 +29,7 @@ #ifndef JavaScriptDebugListener_h #define JavaScriptDebugListener_h -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) namespace JSC { class ExecState; diff --git a/WebCore/inspector/JavaScriptDebugServer.cpp b/WebCore/inspector/JavaScriptDebugServer.cpp index 4aab347..03c3577 100644 --- a/WebCore/inspector/JavaScriptDebugServer.cpp +++ b/WebCore/inspector/JavaScriptDebugServer.cpp @@ -29,7 +29,7 @@ #include "config.h" #include "JavaScriptDebugServer.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "DOMWindow.h" #include "EventLoop.h" diff --git a/WebCore/inspector/JavaScriptDebugServer.h b/WebCore/inspector/JavaScriptDebugServer.h index b5b713d..d7c23bc 100644 --- a/WebCore/inspector/JavaScriptDebugServer.h +++ b/WebCore/inspector/JavaScriptDebugServer.h @@ -29,7 +29,7 @@ #ifndef JavaScriptDebugServer_h #define JavaScriptDebugServer_h -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "Timer.h" #include <debugger/Debugger.h> diff --git a/WebCore/inspector/JavaScriptProfile.cpp b/WebCore/inspector/JavaScriptProfile.cpp index 3a65fb8..2203f0b 100644 --- a/WebCore/inspector/JavaScriptProfile.cpp +++ b/WebCore/inspector/JavaScriptProfile.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "JavaScriptProfile.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "JavaScriptProfileNode.h" #include <profiler/Profile.h> diff --git a/WebCore/inspector/JavaScriptProfile.h b/WebCore/inspector/JavaScriptProfile.h index 28fd3e4..2500881 100644 --- a/WebCore/inspector/JavaScriptProfile.h +++ b/WebCore/inspector/JavaScriptProfile.h @@ -26,7 +26,7 @@ #ifndef JavaScriptProfile_h #define JavaScriptProfile_h -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include <runtime/JSValue.h> diff --git a/WebCore/inspector/JavaScriptProfileNode.cpp b/WebCore/inspector/JavaScriptProfileNode.cpp index 2d462f6..6387c85 100644 --- a/WebCore/inspector/JavaScriptProfileNode.cpp +++ b/WebCore/inspector/JavaScriptProfileNode.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "JavaScriptProfileNode.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "JSDOMBinding.h" #include <profiler/ProfileNode.h> diff --git a/WebCore/inspector/JavaScriptProfileNode.h b/WebCore/inspector/JavaScriptProfileNode.h index ad72b71..2685ac6 100644 --- a/WebCore/inspector/JavaScriptProfileNode.h +++ b/WebCore/inspector/JavaScriptProfileNode.h @@ -26,7 +26,7 @@ #ifndef JavaScriptProfileNode_h #define JavaScriptProfileNode_h -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include <runtime/JSValue.h> #include <JavaScriptCore/JSBase.h> diff --git a/WebCore/inspector/front-end/ElementsTreeOutline.js b/WebCore/inspector/front-end/ElementsTreeOutline.js index d38a7bb..8d8d5db 100644 --- a/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -898,29 +898,18 @@ WebInspector.ElementsTreeElement.prototype = { if (!hrefValue || hrefValue.indexOf("://") > 0) return hrefValue; - var match; - var documentURL; for (var frameOwnerCandidate = node; frameOwnerCandidate; frameOwnerCandidate = frameOwnerCandidate.parentNode) { if (frameOwnerCandidate.documentURL) { - documentURL = frameOwnerCandidate.documentURL; + var result = WebInspector.completeURL(frameOwnerCandidate.documentURL, hrefValue); + if (result) + return result; break; } } - if (documentURL) { - match = documentURL.match(WebInspector.URLRegExp); - if (match) { - var path = hrefValue; - if (path.charAt(0) !== "/") { - var documentPath = match[4] || "/"; - path = documentPath.substring(0, documentPath.lastIndexOf("/")) + "/" + path; - } - return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path; - } - } // documentURL not found or has bad value for (var url in WebInspector.resourceURLMap) { - match = url.match(WebInspector.URLRegExp); + var match = url.match(WebInspector.URLRegExp); if (match && match[4] === hrefValue) return url; } diff --git a/WebCore/inspector/front-end/InjectedScript.js b/WebCore/inspector/front-end/InjectedScript.js index 9389117..337628f 100644 --- a/WebCore/inspector/front-end/InjectedScript.js +++ b/WebCore/inspector/front-end/InjectedScript.js @@ -923,7 +923,7 @@ InjectedScript.openInInspectedWindow = function(url) return true; } -InjectedScript.getCallFrames = function() +InjectedScript.callFrames = function() { var callFrame = InjectedScriptHost.currentCallFrame(); if (!callFrame) diff --git a/WebCore/inspector/front-end/InspectorBackendStub.js b/WebCore/inspector/front-end/InspectorBackendStub.js index 5ddb74a..ed03f73 100644 --- a/WebCore/inspector/front-end/InspectorBackendStub.js +++ b/WebCore/inspector/front-end/InspectorBackendStub.js @@ -46,17 +46,6 @@ WebInspector.InspectorBackendStub.prototype = { return func; }, - platform: function() - { - return "mac-leopard"; - }, - - port: function() - { - return "unknown"; - }, - - closeWindow: function() { this._windowVisible = false; diff --git a/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/WebCore/inspector/front-end/InspectorFrontendHostStub.js index dc7da61..f1decb6 100644 --- a/WebCore/inspector/front-end/InspectorFrontendHostStub.js +++ b/WebCore/inspector/front-end/InspectorFrontendHostStub.js @@ -35,10 +35,12 @@ WebInspector.InspectorFrontendHostStub = function() this._attachedWindowHeight = 0; } +WebInspector._platformFlavor = WebInspector.PlatformFlavor.MacLeopard; + WebInspector.InspectorFrontendHostStub.prototype = { platform: function() { - return "mac-leopard"; + return "mac"; }, port: function() diff --git a/WebCore/inspector/front-end/NativeTextViewer.js b/WebCore/inspector/front-end/NativeTextViewer.js index 53b213d..5e7db27 100644 --- a/WebCore/inspector/front-end/NativeTextViewer.js +++ b/WebCore/inspector/front-end/NativeTextViewer.js @@ -28,13 +28,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -WebInspector.NativeTextViewer = function(textModel, platform) +WebInspector.NativeTextViewer = function(textModel, platform, url) { WebInspector.TextEditor.call(this, textModel, platform); - this._sheet.className = "monospace"; this._sheet.tabIndex = 0; this._canvas.style.zIndex = 0; this._createLineDivs(); + this._url = url; + this._selectionColor = "rgb(241, 234, 0)"; } WebInspector.NativeTextViewer.prototype = { @@ -52,9 +53,13 @@ WebInspector.NativeTextViewer.prototype = { for (var i = 0; i < this._textModel.linesCount; ++i) { var lineDiv = document.createElement("div"); lineDiv.className = "native-text-editor-line"; - lineDiv.textContent = this._textModel.line(i); + var text = this._textModel.line(i); + lineDiv.textContent = text; + if (!text) + lineDiv.style.minHeight = this._textLineHeight + "px"; this._sheet.appendChild(lineDiv); this._textModel.setAttribute(i, "line-div", lineDiv); + this._textModel.removeAttribute(i, "div-highlighted"); } this._container.appendChild(this._sheet); }, @@ -68,7 +73,7 @@ WebInspector.NativeTextViewer.prototype = { var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount); this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth; - this._sheet.style.paddingLeft = this._textWidth + this._lineNumberWidth + "px"; + this._container.style.left = this._lineNumberWidth + "px"; this._lineNumberDigits = newLineNumberDigits; this.repaintAll(); @@ -86,7 +91,8 @@ WebInspector.NativeTextViewer.prototype = { _registerMouseListeners: function() { - this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false); + this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false); + this.element.addEventListener("mousedown", this._mouseDown.bind(this), false); }, _registerKeyboardListeners: function() @@ -99,44 +105,48 @@ WebInspector.NativeTextViewer.prototype = { // Noop - let browser take care of this. }, - _paintSelection: function() + _positionDivDecoration: function() { - // Noop - let browser take care of this. + // Div decorations have fixed positions in our case. }, - _positionDivDecoration: function() + _registerShortcuts: function() { - // Div decorations have fixed positions in our case. + // Noop. }, _mouseDown: function(e) { - if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator) - return; - - if (e.button === 2 || (this._isMac && e.ctrlKey)) + if (e.target !== this.element || e.button === 2 || (this._isMac && e.ctrlKey)) return; - - var location = this._caretForMouseEvent(e); - this._lineNumberDecorator.mouseDown(location.line, e); + this._lineNumberDecorator.mouseDown(this._lineForMouseEvent(e), e); }, _contextMenu: function(e) { - // Override editor's implementation to add the line's offsets. - if (e.offsetX + e.target.offsetTop >= this._lineNumberWidth && this._lineNumberDecorator) + if (e.target !== this.element) return; + this._lineNumberDecorator.contextMenu(this._lineForMouseEvent(e), e); + }, - var location = this._caretForMouseEvent(e); - this._lineNumberDecorator.contextMenu(location.line, e); + _lineForMouseEvent: function(e) + { + return Math.max(0, this._offsetToLine(e.offsetY + this._scrollTop) - 1); }, - _caretForMouseEvent: function(e) + _lineHeight: function(lineNumber) { - // Override editor's implementation to add the line's offsets. - var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + e.target.offsetTop) - 1); - var offset = e.offsetX + e.target.offsetLeft + this._scrollLeft - this._lineNumberWidth; - return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) }; + // Use cached value first. + if (this._lineOffsetsCache[lineNumber + 1]) + return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber]; + + // Get metrics from the browser. + var element = this._textModel.getAttribute(lineNumber, "line-div"); + if (lineNumber + 1 < this._textModel.linesCount) { + var nextElement = this._textModel.getAttribute(lineNumber + 1, "line-div"); + return nextElement.offsetTop - element.offsetTop; + } + return element.parentElement.offsetHeight - element.offsetTop; }, _paintLine: function(lineNumber, lineOffset) @@ -181,12 +191,41 @@ WebInspector.NativeTextViewer.prototype = { _createSpan: function(content, className) { + if (className === "html-resource-link" || className === "html-external-link") + return this._createLink(content, className === "html-external-link"); + var span = document.createElement("span"); span.className = "webkit-" + className; span.appendChild(document.createTextNode(content)); return span; }, + _createLink: function(content, isExternal) + { + var quote = content.charAt(0); + if (content.length > 1 && (quote === "\"" || quote === "'")) + content = content.substring(1, content.length - 1); + else + quote = null; + + var a = WebInspector.linkifyURLAsNode(this._rewriteHref(content), content, null, isExternal); + var span = document.createElement("span"); + span.className = "webkit-html-attribute-value"; + if (quote) + span.appendChild(document.createTextNode(quote)); + span.appendChild(a); + if (quote) + span.appendChild(document.createTextNode(quote)); + return span; + }, + + _rewriteHref: function(hrefValue, isExternal) + { + if (!this._url || !hrefValue || hrefValue.indexOf("://") > 0) + return hrefValue; + return WebInspector.completeURL(this._url, hrefValue); + }, + setDivDecoration: function(lineNumber, element) { var existingElement = this._textModel.getAttribute(lineNumber, "div-decoration"); @@ -203,6 +242,16 @@ WebInspector.NativeTextViewer.prototype = { this._textModel.setAttribute(lineNumber, "div-decoration", element); } this.revalidateDecorationsAndPaint(); + }, + + initFontMetrics: function() + { + WebInspector.TextEditor.prototype.initFontMetrics.call(this); + for (var i = 0; i < this._textModel.linesCount; ++i) { + var lineDiv = this._textModel.getAttribute(i, "line-div"); + if (!this._textModel.line(i)) + lineDiv.style.minHeight = this._textLineHeight + "px"; + } } } diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js index 334847e..b7b01ac 100644 --- a/WebCore/inspector/front-end/ResourceView.js +++ b/WebCore/inspector/front-end/ResourceView.js @@ -183,6 +183,8 @@ WebInspector.ResourceView.prototype = { this.headersElement.addStyleClass("hidden"); if ("resize" in this) this.resize(); + if ("contentTabSelected" in this) + this.contentTabSelected(); }, _refreshURL: function() diff --git a/WebCore/inspector/front-end/ResourcesPanel.js b/WebCore/inspector/front-end/ResourcesPanel.js index e0c5521..40a380c 100644 --- a/WebCore/inspector/front-end/ResourcesPanel.js +++ b/WebCore/inspector/front-end/ResourcesPanel.js @@ -429,7 +429,7 @@ WebInspector.ResourcesPanel.prototype = { return; var newView = this._createResourceView(resource); - if (newView.prototype === resource._resourcesView.prototype) + if (newView.__proto__ === resource._resourcesView.__proto__) return; resource.warnings = 0; @@ -439,6 +439,7 @@ WebInspector.ResourcesPanel.prototype = { resource._itemsTreeElement.updateErrorsAndWarnings(); var oldView = resource._resourcesView; + var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null; resource._resourcesView.detach(); delete resource._resourcesView; @@ -447,8 +448,8 @@ WebInspector.ResourcesPanel.prototype = { newView.headersVisible = oldView.headersVisible; - if (oldView.visible && oldView.element.parentNode) - newView.show(oldView.element.parentNode); + if (oldViewParentNode) + newView.show(oldViewParentNode); }, canShowSourceLineForURL: function(url) diff --git a/WebCore/inspector/front-end/Settings.js b/WebCore/inspector/front-end/Settings.js index 1838068..bc0daa5 100644 --- a/WebCore/inspector/front-end/Settings.js +++ b/WebCore/inspector/front-end/Settings.js @@ -39,7 +39,7 @@ var Preferences = { showMissingLocalizedStrings: false, samplingCPUProfiler: false, showColorNicknames: true, - useCanvasBasedEditor: true + useCanvasBasedEditor: false } WebInspector.populateFrontendSettings = function(settingsString) diff --git a/WebCore/inspector/front-end/SourceFrame.js b/WebCore/inspector/front-end/SourceFrame.js index 1e1bd0c..e30dbdb 100644 --- a/WebCore/inspector/front-end/SourceFrame.js +++ b/WebCore/inspector/front-end/SourceFrame.js @@ -123,11 +123,12 @@ WebInspector.SourceFrame.prototype = { this._editor.revalidateDecorationsAndPaint(); }, - setContent: function(mimeType, content) + setContent: function(mimeType, content, url) { this._loaded = true; this._textModel.setText(null, content); this._mimeType = mimeType; + this._url = url; this._createEditorIfNeeded(); }, @@ -137,13 +138,14 @@ WebInspector.SourceFrame.prototype = { return; var editorConstructor = Preferences.useCanvasBasedEditor ? WebInspector.TextEditor : WebInspector.NativeTextViewer; - this._editor = new editorConstructor(this._textModel, WebInspector.platform); + this._editor = new editorConstructor(this._textModel, WebInspector.platform, this._url); this._editor.lineNumberDecorator = new WebInspector.BreakpointLineNumberDecorator(this, this._editor.textModel); this._editor.lineDecorator = new WebInspector.ExecutionLineDecorator(this); this._editor.readOnly = true; this._element = this._editor.element; this._element.addEventListener("keydown", this._keyDown.bind(this), true); this._parentElement.appendChild(this._element); + this._editor.initFontMetrics(); this._editor.mimeType = this._mimeType; diff --git a/WebCore/inspector/front-end/SourceHTMLTokenizer.js b/WebCore/inspector/front-end/SourceHTMLTokenizer.js index 1212ffe..8856ff5 100644 --- a/WebCore/inspector/front-end/SourceHTMLTokenizer.js +++ b/WebCore/inspector/front-end/SourceHTMLTokenizer.js @@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 on Thu Jan 28 20:49:22 2010 */ +/* Generated by re2c 0.13.5 on Tue Feb 2 00:44:38 2010 */ /* * Copyright (C) 2009 Google Inc. All rights reserved. * @@ -45,72 +45,81 @@ WebInspector.SourceHTMLTokenizer = function() { WebInspector.SourceTokenizer.call(this); + // The order is determined by the generated code. this._lexConditions = { INITIAL: 0, COMMENT: 1, - DSTRING: 2, - SSTRING: 3 + DOCTYPE: 2, + TAG: 3, + DSTRING: 4, + SSTRING: 5 }; + this.case_INITIAL = 1000; + this.case_COMMENT = 1001; + this.case_DOCTYPE = 1002; + this.case_TAG = 1003; + this.case_DSTRING = 1004; + this.case_SSTRING = 1005; this._parseConditions = { INITIAL: 0, - TAG: 1, - ATTRIBUTE: 2, - ATTRIBUTE_VALUE: 3, - SCRIPT: 4, - SCRIPT_ATTRIBUTE: 5, - SCRIPT_ATTRIBUTE_VALUE: 6, - DOCTYPE: 7 + ATTRIBUTE: 1, + ATTRIBUTE_VALUE: 2, + LINKIFY: 4, + A_NODE: 8, + SCRIPT: 16 }; - this.case_INITIAL = 1000; - this.case_COMMENT = 1001; - this.case_DSTRING = 1002; - this.case_SSTRING = 1003; - this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; } WebInspector.SourceHTMLTokenizer.prototype = { - _isAttribute: function() + _isExpectingAttribute: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE; + return this._parseCondition & this._parseConditions.ATTRIBUTE; }, - _isAttributeValue: function() + _isExpectingAttributeValue: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE; }, - _setAttributeValue: function() + _setExpectingAttribute: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE) - this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + if (this._isExpectingAttributeValue()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE; + this._parseCondition |= this._parseConditions.ATTRIBUTE; }, - _setAttribute: function() + _setExpectingAttributeValue: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.ATTRIBUTE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + if (this._isExpectingAttribute()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE; + this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE; }, _stringToken: function(cursor, stringEnds) { - if (this._isAttributeValue()) { - this.tokenType = "html-attr-value"; - if (stringEnds) - this._setAttribute(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else + if (!this._isExpectingAttributeValue()) { this.tokenType = null; + return cursor; + } + this.tokenType = this._attrValueTokenType(); + if (stringEnds) + this._setExpectingAttribute(); return cursor; }, + _attrValueTokenType: function() + { + if (this._parseCondition & this._parseConditions.LINKIFY) { + if (this._parseCondition & this._parseConditions.A_NODE) + return "html-external-link"; + return "html-resource-link"; + } + return "html-attribute-value"; + }, + nextToken: function(cursor) { var cursorOnEnter = cursor; @@ -122,17 +131,25 @@ WebInspector.SourceHTMLTokenizer.prototype = { { case 1: var yych; var yyaccept = 0; - if (this.getLexCondition() < 2) { + if (this.getLexCondition() < 3) { if (this.getLexCondition() < 1) { { gotoCase = this.case_INITIAL; continue; }; } else { - { gotoCase = this.case_COMMENT; continue; }; + if (this.getLexCondition() < 2) { + { gotoCase = this.case_COMMENT; continue; }; + } else { + { gotoCase = this.case_DOCTYPE; continue; }; + } } } else { - if (this.getLexCondition() < 3) { - { gotoCase = this.case_DSTRING; continue; }; + if (this.getLexCondition() < 4) { + { gotoCase = this.case_TAG; continue; }; } else { - { gotoCase = this.case_SSTRING; continue; }; + if (this.getLexCondition() < 5) { + { gotoCase = this.case_DSTRING; continue; }; + } else { + { gotoCase = this.case_SSTRING; continue; }; + } } } /* *********************************** */ @@ -193,393 +210,438 @@ case 12: { gotoCase = 5; continue; }; } /* *********************************** */ -case this.case_DSTRING: +case this.case_DOCTYPE: yych = this._charAt(cursor); if (yych <= '\f') { if (yych == '\n') { gotoCase = 18; continue; }; { gotoCase = 17; continue; }; } else { if (yych <= '\r') { gotoCase = 18; continue; }; - if (yych == '"') { gotoCase = 20; continue; }; + if (yych == '>') { gotoCase = 20; continue; }; { gotoCase = 17; continue; }; } case 16: - { return this._stringToken(cursor); } + { this.tokenType = "html-doctype"; return cursor; } case 17: yych = this._charAt(++cursor); - { gotoCase = 24; continue; }; + { gotoCase = 23; continue; }; case 18: ++cursor; { this.tokenType = null; return cursor; } case 20: ++cursor; -case 21: this.setLexCondition(this._lexConditions.INITIAL); - { return this._stringToken(cursor, true); } + { this.tokenType = "html-doctype"; return cursor; } case 22: - yych = this._charAt(++cursor); - { gotoCase = 21; continue; }; -case 23: ++cursor; yych = this._charAt(cursor); -case 24: +case 23: if (yych <= '\f') { if (yych == '\n') { gotoCase = 16; continue; }; - { gotoCase = 23; continue; }; + { gotoCase = 22; continue; }; } else { if (yych <= '\r') { gotoCase = 16; continue; }; - if (yych == '"') { gotoCase = 22; continue; }; - { gotoCase = 23; continue; }; + if (yych == '>') { gotoCase = 16; continue; }; + { gotoCase = 22; continue; }; } /* *********************************** */ -case this.case_INITIAL: +case this.case_DSTRING: yych = this._charAt(cursor); - if (yych <= '=') { - if (yych <= '\'') { - if (yych == '"') { gotoCase = 29; continue; }; - if (yych >= '\'') { gotoCase = 30; continue; }; - } else { - if (yych <= '9') { - if (yych >= '0') { gotoCase = 31; continue; }; - } else { - if (yych <= ';') { gotoCase = 27; continue; }; - if (yych <= '<') { gotoCase = 33; continue; }; - { gotoCase = 35; continue; }; - } - } + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 28; continue; }; + { gotoCase = 27; continue; }; } else { - if (yych <= '^') { - if (yych <= '>') { gotoCase = 37; continue; }; - if (yych <= '@') { gotoCase = 27; continue; }; - if (yych <= 'Z') { gotoCase = 31; continue; }; - } else { - if (yych <= '`') { - if (yych <= '_') { gotoCase = 31; continue; }; - } else { - if (yych <= 'z') { gotoCase = 31; continue; }; - if (yych >= 0x80) { gotoCase = 31; continue; }; - } - } + if (yych <= '\r') { gotoCase = 28; continue; }; + if (yych == '"') { gotoCase = 30; continue; }; + { gotoCase = 27; continue; }; } +case 26: + { return this._stringToken(cursor); } case 27: - ++cursor; + yych = this._charAt(++cursor); + { gotoCase = 34; continue; }; case 28: + ++cursor; { this.tokenType = null; return cursor; } -case 29: - yyaccept = 0; - yych = this._charAt(YYMARKER = ++cursor); - { gotoCase = 82; continue; }; case 30: - yyaccept = 0; - yych = this._charAt(YYMARKER = ++cursor); - { gotoCase = 76; continue; }; -case 31: ++cursor; - yych = this._charAt(cursor); - { gotoCase = 74; continue; }; +case 31: + this.setLexCondition(this._lexConditions.TAG); + { return this._stringToken(cursor, true); } case 32: - { - if (this._parseCondition === this._parseConditions.SCRIPT) { - this.tokenType = null; - return cursor; - } - - if (this._parseCondition === this._parseConditions.TAG) { - this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.ATTRIBUTE; - } else if (this._isAttribute()) - this.tokenType = "html-attr-name"; - else if (this._isAttributeValue()) - this.tokenType = "html-attr-value"; - else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = null; - return cursor; - } + yych = this._charAt(++cursor); + { gotoCase = 31; continue; }; case 33: - yyaccept = 1; + ++cursor; + yych = this._charAt(cursor); +case 34: + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 26; continue; }; + { gotoCase = 33; continue; }; + } else { + if (yych <= '\r') { gotoCase = 26; continue; }; + if (yych == '"') { gotoCase = 32; continue; }; + { gotoCase = 33; continue; }; + } +/* *********************************** */ +case this.case_INITIAL: + yych = this._charAt(cursor); + if (yych == '<') { gotoCase = 39; continue; }; + ++cursor; + { this.tokenType = null; return cursor; } +case 39: + yyaccept = 0; yych = this._charAt(YYMARKER = ++cursor); if (yych <= '/') { - if (yych == '!') { gotoCase = 42; continue; }; - if (yych >= '/') { gotoCase = 39; continue; }; + if (yych == '!') { gotoCase = 44; continue; }; + if (yych >= '/') { gotoCase = 41; continue; }; } else { if (yych <= 'S') { - if (yych >= 'S') { gotoCase = 40; continue; }; + if (yych >= 'S') { gotoCase = 42; continue; }; } else { - if (yych == 's') { gotoCase = 40; continue; }; + if (yych == 's') { gotoCase = 42; continue; }; } } -case 34: +case 40: + this.setLexCondition(this._lexConditions.TAG); { - if (this._parseCondition === this._parseConditions.SCRIPT) { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents, keep lexer state although processing "<". + this.setLexCondition(this._lexConditions.INITIAL); this.tokenType = null; return cursor; } + this._parseCondition = this._parseConditions.INITIAL; this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.TAG; - return cursor; - } -case 35: - ++cursor; - { - if (this._isAttribute()) { - this.tokenType = null; - this._setAttributeValue(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = null; - return cursor; - } -case 37: - ++cursor; - { - if (this._parseCondition === this._parseConditions.SCRIPT) { - this.tokenType = null; - return cursor; - } - - if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = "html-tag"; - - if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT; - else - this._parseCondition = this._parseConditions.INITIAL; return cursor; } -case 39: - yyaccept = 1; +case 41: + yyaccept = 0; yych = this._charAt(YYMARKER = ++cursor); - if (yych == 'S') { gotoCase = 66; continue; }; - if (yych == 's') { gotoCase = 66; continue; }; - { gotoCase = 34; continue; }; -case 40: + if (yych == 'S') { gotoCase = 68; continue; }; + if (yych == 's') { gotoCase = 68; continue; }; + { gotoCase = 40; continue; }; +case 42: yych = this._charAt(++cursor); - if (yych == 'C') { gotoCase = 60; continue; }; - if (yych == 'c') { gotoCase = 60; continue; }; -case 41: + if (yych == 'C') { gotoCase = 62; continue; }; + if (yych == 'c') { gotoCase = 62; continue; }; +case 43: cursor = YYMARKER; - if (yyaccept <= 0) { - { gotoCase = 28; continue; }; - } else { - { gotoCase = 34; continue; }; - } -case 42: + { gotoCase = 40; continue; }; +case 44: yych = this._charAt(++cursor); if (yych <= 'C') { - if (yych != '-') { gotoCase = 41; continue; }; + if (yych != '-') { gotoCase = 43; continue; }; } else { - if (yych <= 'D') { gotoCase = 44; continue; }; - if (yych == 'd') { gotoCase = 44; continue; }; - { gotoCase = 41; continue; }; + if (yych <= 'D') { gotoCase = 46; continue; }; + if (yych == 'd') { gotoCase = 46; continue; }; + { gotoCase = 43; continue; }; } yych = this._charAt(++cursor); - if (yych == '-') { gotoCase = 52; continue; }; - { gotoCase = 41; continue; }; -case 44: - yych = this._charAt(++cursor); - if (yych == 'O') { gotoCase = 45; continue; }; - if (yych != 'o') { gotoCase = 41; continue; }; -case 45: - yych = this._charAt(++cursor); - if (yych == 'C') { gotoCase = 46; continue; }; - if (yych != 'c') { gotoCase = 41; continue; }; + if (yych == '-') { gotoCase = 54; continue; }; + { gotoCase = 43; continue; }; case 46: yych = this._charAt(++cursor); - if (yych == 'T') { gotoCase = 47; continue; }; - if (yych != 't') { gotoCase = 41; continue; }; + if (yych == 'O') { gotoCase = 47; continue; }; + if (yych != 'o') { gotoCase = 43; continue; }; case 47: yych = this._charAt(++cursor); - if (yych == 'Y') { gotoCase = 48; continue; }; - if (yych != 'y') { gotoCase = 41; continue; }; + if (yych == 'C') { gotoCase = 48; continue; }; + if (yych != 'c') { gotoCase = 43; continue; }; case 48: yych = this._charAt(++cursor); - if (yych == 'P') { gotoCase = 49; continue; }; - if (yych != 'p') { gotoCase = 41; continue; }; + if (yych == 'T') { gotoCase = 49; continue; }; + if (yych != 't') { gotoCase = 43; continue; }; case 49: yych = this._charAt(++cursor); - if (yych == 'E') { gotoCase = 50; continue; }; - if (yych != 'e') { gotoCase = 41; continue; }; + if (yych == 'Y') { gotoCase = 50; continue; }; + if (yych != 'y') { gotoCase = 43; continue; }; case 50: - ++cursor; - { - this.tokenType = "html-doctype"; - this._parseCondition = this._parseConditions.DOCTYPE; - return cursor; - } + yych = this._charAt(++cursor); + if (yych == 'P') { gotoCase = 51; continue; }; + if (yych != 'p') { gotoCase = 43; continue; }; +case 51: + yych = this._charAt(++cursor); + if (yych == 'E') { gotoCase = 52; continue; }; + if (yych != 'e') { gotoCase = 43; continue; }; case 52: ++cursor; + this.setLexCondition(this._lexConditions.DOCTYPE); + { this.tokenType = "html-doctype"; return cursor; } +case 54: + ++cursor; yych = this._charAt(cursor); if (yych <= '\f') { - if (yych == '\n') { gotoCase = 55; continue; }; - { gotoCase = 52; continue; }; + if (yych == '\n') { gotoCase = 57; continue; }; + { gotoCase = 54; continue; }; } else { - if (yych <= '\r') { gotoCase = 55; continue; }; - if (yych != '-') { gotoCase = 52; continue; }; + if (yych <= '\r') { gotoCase = 57; continue; }; + if (yych != '-') { gotoCase = 54; continue; }; } ++cursor; yych = this._charAt(cursor); - if (yych == '-') { gotoCase = 57; continue; }; - { gotoCase = 41; continue; }; -case 55: + if (yych == '-') { gotoCase = 59; continue; }; + { gotoCase = 43; continue; }; +case 57: ++cursor; this.setLexCondition(this._lexConditions.COMMENT); { this.tokenType = "html-comment"; return cursor; } -case 57: +case 59: ++cursor; yych = this._charAt(cursor); - if (yych != '>') { gotoCase = 52; continue; }; + if (yych != '>') { gotoCase = 54; continue; }; ++cursor; { this.tokenType = "html-comment"; return cursor; } -case 60: - yych = this._charAt(++cursor); - if (yych == 'R') { gotoCase = 61; continue; }; - if (yych != 'r') { gotoCase = 41; continue; }; -case 61: - yych = this._charAt(++cursor); - if (yych == 'I') { gotoCase = 62; continue; }; - if (yych != 'i') { gotoCase = 41; continue; }; case 62: yych = this._charAt(++cursor); - if (yych == 'P') { gotoCase = 63; continue; }; - if (yych != 'p') { gotoCase = 41; continue; }; + if (yych == 'R') { gotoCase = 63; continue; }; + if (yych != 'r') { gotoCase = 43; continue; }; case 63: yych = this._charAt(++cursor); - if (yych == 'T') { gotoCase = 64; continue; }; - if (yych != 't') { gotoCase = 41; continue; }; + if (yych == 'I') { gotoCase = 64; continue; }; + if (yych != 'i') { gotoCase = 43; continue; }; case 64: + yych = this._charAt(++cursor); + if (yych == 'P') { gotoCase = 65; continue; }; + if (yych != 'p') { gotoCase = 43; continue; }; +case 65: + yych = this._charAt(++cursor); + if (yych == 'T') { gotoCase = 66; continue; }; + if (yych != 't') { gotoCase = 43; continue; }; +case 66: ++cursor; + this.setLexCondition(this._lexConditions.TAG); { this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + this._parseCondition = this._parseConditions.SCRIPT; + this._setExpectingAttribute(); return cursor; } -case 66: - yych = this._charAt(++cursor); - if (yych == 'C') { gotoCase = 67; continue; }; - if (yych != 'c') { gotoCase = 41; continue; }; -case 67: - yych = this._charAt(++cursor); - if (yych == 'R') { gotoCase = 68; continue; }; - if (yych != 'r') { gotoCase = 41; continue; }; case 68: yych = this._charAt(++cursor); - if (yych == 'I') { gotoCase = 69; continue; }; - if (yych != 'i') { gotoCase = 41; continue; }; + if (yych == 'C') { gotoCase = 69; continue; }; + if (yych != 'c') { gotoCase = 43; continue; }; case 69: yych = this._charAt(++cursor); - if (yych == 'P') { gotoCase = 70; continue; }; - if (yych != 'p') { gotoCase = 41; continue; }; + if (yych == 'R') { gotoCase = 70; continue; }; + if (yych != 'r') { gotoCase = 43; continue; }; case 70: yych = this._charAt(++cursor); - if (yych == 'T') { gotoCase = 71; continue; }; - if (yych != 't') { gotoCase = 41; continue; }; + if (yych == 'I') { gotoCase = 71; continue; }; + if (yych != 'i') { gotoCase = 43; continue; }; case 71: + yych = this._charAt(++cursor); + if (yych == 'P') { gotoCase = 72; continue; }; + if (yych != 'p') { gotoCase = 43; continue; }; +case 72: + yych = this._charAt(++cursor); + if (yych == 'T') { gotoCase = 73; continue; }; + if (yych != 't') { gotoCase = 43; continue; }; +case 73: ++cursor; + this.setLexCondition(this._lexConditions.TAG); { this.tokenType = "html-tag"; this._parseCondition = this._parseConditions.INITIAL; return cursor; } -case 73: +/* *********************************** */ +case this.case_SSTRING: + yych = this._charAt(cursor); + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 79; continue; }; + { gotoCase = 78; continue; }; + } else { + if (yych <= '\r') { gotoCase = 79; continue; }; + if (yych == '\'') { gotoCase = 81; continue; }; + { gotoCase = 78; continue; }; + } +case 77: + { return this._stringToken(cursor); } +case 78: + yych = this._charAt(++cursor); + { gotoCase = 85; continue; }; +case 79: + ++cursor; + { this.tokenType = null; return cursor; } +case 81: + ++cursor; +case 82: + this.setLexCondition(this._lexConditions.TAG); + { return this._stringToken(cursor, true); } +case 83: + yych = this._charAt(++cursor); + { gotoCase = 82; continue; }; +case 84: ++cursor; yych = this._charAt(cursor); -case 74: - if (yych <= '^') { - if (yych <= '9') { - if (yych <= '/') { gotoCase = 32; continue; }; - { gotoCase = 73; continue; }; +case 85: + if (yych <= '\f') { + if (yych == '\n') { gotoCase = 77; continue; }; + { gotoCase = 84; continue; }; + } else { + if (yych <= '\r') { gotoCase = 77; continue; }; + if (yych == '\'') { gotoCase = 83; continue; }; + { gotoCase = 84; continue; }; + } +/* *********************************** */ +case this.case_TAG: + yych = this._charAt(cursor); + if (yych <= '&') { + if (yych <= '\r') { + if (yych == '\n') { gotoCase = 90; continue; }; + if (yych >= '\r') { gotoCase = 90; continue; }; } else { - if (yych <= '@') { gotoCase = 32; continue; }; - if (yych <= 'Z') { gotoCase = 73; continue; }; - { gotoCase = 32; continue; }; + if (yych <= ' ') { + if (yych >= ' ') { gotoCase = 90; continue; }; + } else { + if (yych == '"') { gotoCase = 92; continue; }; + } } } else { - if (yych <= '`') { - if (yych <= '_') { gotoCase = 73; continue; }; - { gotoCase = 32; continue; }; + if (yych <= '>') { + if (yych <= ';') { + if (yych <= '\'') { gotoCase = 93; continue; }; + } else { + if (yych <= '<') { gotoCase = 90; continue; }; + if (yych <= '=') { gotoCase = 94; continue; }; + { gotoCase = 96; continue; }; + } } else { - if (yych <= 'z') { gotoCase = 73; continue; }; - if (yych <= 0x7F) { gotoCase = 32; continue; }; - { gotoCase = 73; continue; }; + if (yych <= '[') { + if (yych >= '[') { gotoCase = 90; continue; }; + } else { + if (yych == ']') { gotoCase = 90; continue; }; + } } } -case 75: ++cursor; yych = this._charAt(cursor); -case 76: + { gotoCase = 109; continue; }; +case 89: + { + if (this._parseCondition === this._parseConditions.SCRIPT) { + // Fall through if expecting attributes. + this.tokenType = null; + return cursor; + } + + if (this._parseCondition === this._parseConditions.INITIAL) { + this.tokenType = "html-tag"; + this._setExpectingAttribute(); + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "a") + this._parseCondition |= this._parseConditions.A_NODE; + else if (this._parseCondition & this._parseConditions.A_NODE) + this._parseCondition ^= this._parseConditions.A_NODE; + } else if (this._isExpectingAttribute()) { + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "href" || token === "src") + this._parseCondition |= this._parseConditions.LINKIFY; + else if (this._parseCondition |= this._parseConditions.LINKIFY) + this._parseCondition ^= this._parseConditions.LINKIFY; + this.tokenType = "html-attribute-name"; + } else if (this._isExpectingAttributeValue()) + this.tokenType = this._attrValueTokenType(); + else + this.tokenType = null; + return cursor; + } +case 90: + ++cursor; + { this.tokenType = null; return cursor; } +case 92: + yyaccept = 0; + yych = this._charAt(YYMARKER = ++cursor); + { gotoCase = 105; continue; }; +case 93: + yyaccept = 0; + yych = this._charAt(YYMARKER = ++cursor); + { gotoCase = 99; continue; }; +case 94: + ++cursor; + { + if (this._isExpectingAttribute()) + this._setExpectingAttributeValue(); + this.tokenType = null; + return cursor; + } +case 96: + ++cursor; + this.setLexCondition(this._lexConditions.INITIAL); + { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents. + this.tokenType = null; + return cursor; + } + + this._parseCondition = this._parseConditions.INITIAL; + this.tokenType = "html-tag"; + return cursor; + } +case 98: + ++cursor; + yych = this._charAt(cursor); +case 99: if (yych <= '\f') { - if (yych != '\n') { gotoCase = 75; continue; }; + if (yych != '\n') { gotoCase = 98; continue; }; } else { - if (yych <= '\r') { gotoCase = 77; continue; }; - if (yych == '\'') { gotoCase = 79; continue; }; - { gotoCase = 75; continue; }; + if (yych <= '\r') { gotoCase = 100; continue; }; + if (yych == '\'') { gotoCase = 102; continue; }; + { gotoCase = 98; continue; }; } -case 77: +case 100: ++cursor; this.setLexCondition(this._lexConditions.SSTRING); { return this._stringToken(cursor); } -case 79: +case 102: ++cursor; { return this._stringToken(cursor, true); } -case 81: +case 104: ++cursor; yych = this._charAt(cursor); -case 82: +case 105: if (yych <= '\f') { - if (yych != '\n') { gotoCase = 81; continue; }; + if (yych != '\n') { gotoCase = 104; continue; }; } else { - if (yych <= '\r') { gotoCase = 83; continue; }; - if (yych == '"') { gotoCase = 79; continue; }; - { gotoCase = 81; continue; }; + if (yych <= '\r') { gotoCase = 106; continue; }; + if (yych == '"') { gotoCase = 102; continue; }; + { gotoCase = 104; continue; }; } -case 83: +case 106: ++cursor; this.setLexCondition(this._lexConditions.DSTRING); { return this._stringToken(cursor); } -/* *********************************** */ -case this.case_SSTRING: - yych = this._charAt(cursor); - if (yych <= '\f') { - if (yych == '\n') { gotoCase = 89; continue; }; - { gotoCase = 88; continue; }; - } else { - if (yych <= '\r') { gotoCase = 89; continue; }; - if (yych == '\'') { gotoCase = 91; continue; }; - { gotoCase = 88; continue; }; - } -case 87: - { return this._stringToken(cursor); } -case 88: - yych = this._charAt(++cursor); - { gotoCase = 95; continue; }; -case 89: - ++cursor; - { this.tokenType = null; return cursor; } -case 91: - ++cursor; -case 92: - this.setLexCondition(this._lexConditions.INITIAL); - { return this._stringToken(cursor, true); } -case 93: - yych = this._charAt(++cursor); - { gotoCase = 92; continue; }; -case 94: +case 108: ++cursor; yych = this._charAt(cursor); -case 95: - if (yych <= '\f') { - if (yych == '\n') { gotoCase = 87; continue; }; - { gotoCase = 94; continue; }; +case 109: + if (yych <= '"') { + if (yych <= '\r') { + if (yych == '\n') { gotoCase = 89; continue; }; + if (yych <= '\f') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } else { + if (yych == ' ') { gotoCase = 89; continue; }; + if (yych <= '!') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } } else { - if (yych <= '\r') { gotoCase = 87; continue; }; - if (yych == '\'') { gotoCase = 93; continue; }; - { gotoCase = 94; continue; }; + if (yych <= '>') { + if (yych == '\'') { gotoCase = 89; continue; }; + if (yych <= ';') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } else { + if (yych <= '[') { + if (yych <= 'Z') { gotoCase = 108; continue; }; + { gotoCase = 89; continue; }; + } else { + if (yych == ']') { gotoCase = 89; continue; }; + { gotoCase = 108; continue; }; + } + } } } diff --git a/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js b/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js index e56f3ff..89c535a 100644 --- a/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js +++ b/WebCore/inspector/front-end/SourceHTMLTokenizer.re2js @@ -44,72 +44,81 @@ WebInspector.SourceHTMLTokenizer = function() { WebInspector.SourceTokenizer.call(this); + // The order is determined by the generated code. this._lexConditions = { INITIAL: 0, COMMENT: 1, - DSTRING: 2, - SSTRING: 3 + DOCTYPE: 2, + TAG: 3, + DSTRING: 4, + SSTRING: 5 }; + this.case_INITIAL = 1000; + this.case_COMMENT = 1001; + this.case_DOCTYPE = 1002; + this.case_TAG = 1003; + this.case_DSTRING = 1004; + this.case_SSTRING = 1005; this._parseConditions = { INITIAL: 0, - TAG: 1, - ATTRIBUTE: 2, - ATTRIBUTE_VALUE: 3, - SCRIPT: 4, - SCRIPT_ATTRIBUTE: 5, - SCRIPT_ATTRIBUTE_VALUE: 6, - DOCTYPE: 7 + ATTRIBUTE: 1, + ATTRIBUTE_VALUE: 2, + LINKIFY: 4, + A_NODE: 8, + SCRIPT: 16 }; - this.case_INITIAL = 1000; - this.case_COMMENT = 1001; - this.case_DSTRING = 1002; - this.case_SSTRING = 1003; - this.initialCondition = { lexCondition: this._lexConditions.INITIAL, parseCondition: this._parseConditions.INITIAL }; } WebInspector.SourceHTMLTokenizer.prototype = { - _isAttribute: function() + _isExpectingAttribute: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE; + return this._parseCondition & this._parseConditions.ATTRIBUTE; }, - _isAttributeValue: function() + _isExpectingAttributeValue: function() { - return this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE || this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + return this._parseCondition & this._parseConditions.ATTRIBUTE_VALUE; }, - _setAttributeValue: function() + _setExpectingAttribute: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE) - this._parseCondition = this._parseConditions.ATTRIBUTE_VALUE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE_VALUE; + if (this._isExpectingAttributeValue()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE_VALUE; + this._parseCondition |= this._parseConditions.ATTRIBUTE; }, - _setAttribute: function() + _setExpectingAttributeValue: function() { - if (this._parseCondition === this._parseConditions.ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.ATTRIBUTE; - else if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE_VALUE) - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + if (this._isExpectingAttribute()) + this._parseCondition ^= this._parseConditions.ATTRIBUTE; + this._parseCondition |= this._parseConditions.ATTRIBUTE_VALUE; }, _stringToken: function(cursor, stringEnds) { - if (this._isAttributeValue()) { - this.tokenType = "html-attr-value"; - if (stringEnds) - this._setAttribute(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else + if (!this._isExpectingAttributeValue()) { this.tokenType = null; + return cursor; + } + this.tokenType = this._attrValueTokenType(); + if (stringEnds) + this._setExpectingAttribute(); return cursor; }, + _attrValueTokenType: function() + { + if (this._parseCondition & this._parseConditions.LINKIFY) { + if (this._parseCondition & this._parseConditions.A_NODE) + return "html-external-link"; + return "html-resource-link"; + } + return "html-attribute-value"; + }, + nextToken: function(cursor) { var cursorOnEnter = cursor; @@ -134,7 +143,9 @@ WebInspector.SourceHTMLTokenizer.prototype = { CommentStart = "<!--" CommentContent [\r\n]; CommentEnd = CommentContent "-->"; - DocTypeLT = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee]; + DocTypeStart = "<!" [Dd] [Oo] [Cc] [Tt] [Yy] [Pp] [Ee]; + DocTypeContent = [^\r\n>]*; + ScriptStart = "<" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt]; ScriptEnd = "</" [Ss] [Cc] [Rr] [Ii] [Pp] [Tt]; @@ -150,101 +161,100 @@ WebInspector.SourceHTMLTokenizer.prototype = { SingleStringStart = "'" SingleStringContent [\r\n]; SingleStringEnd = SingleStringContent "'"; - Identifier = [_a-zA-Z0-9\x80-\xFF]+; + Identifier = [^ \r\n"'<>\[\]=]+; <INITIAL> Comment { this.tokenType = "html-comment"; return cursor; } <INITIAL> CommentStart => COMMENT { this.tokenType = "html-comment"; return cursor; } <COMMENT> CommentContent => COMMENT { this.tokenType = "html-comment"; return cursor; } <COMMENT> CommentEnd => INITIAL { this.tokenType = "html-comment"; return cursor; } - <INITIAL> DocTypeLT => INITIAL - { - this.tokenType = "html-doctype"; - this._parseCondition = this._parseConditions.DOCTYPE; - return cursor; - } + <INITIAL> DocTypeStart => DOCTYPE { this.tokenType = "html-doctype"; return cursor; } + <DOCTYPE> DocTypeContent => DOCTYPE { this.tokenType = "html-doctype"; return cursor; } + <DOCTYPE> GT => INITIAL { this.tokenType = "html-doctype"; return cursor; } - <INITIAL> ScriptStart => INITIAL + <INITIAL> ScriptStart => TAG { this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.SCRIPT_ATTRIBUTE; + this._parseCondition = this._parseConditions.SCRIPT; + this._setExpectingAttribute(); return cursor; } - <INITIAL> ScriptEnd => INITIAL + <INITIAL> ScriptEnd => TAG { this.tokenType = "html-tag"; this._parseCondition = this._parseConditions.INITIAL; return cursor; } - <INITIAL> LT => INITIAL + <INITIAL> LT => TAG { - if (this._parseCondition === this._parseConditions.SCRIPT) { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents, keep lexer state although processing "<". + this.setLexCondition(this._lexConditions.INITIAL); this.tokenType = null; return cursor; } + this._parseCondition = this._parseConditions.INITIAL; this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.TAG; return cursor; } - <INITIAL> GT => INITIAL + <TAG> GT => INITIAL { - if (this._parseCondition === this._parseConditions.SCRIPT) { + if (this._parseCondition & this._parseConditions.SCRIPT) { + // Do not tokenize script tag contents. this.tokenType = null; return cursor; } - if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = "html-tag"; - - if (this._parseCondition === this._parseConditions.SCRIPT_ATTRIBUTE) - this._parseCondition = this._parseConditions.SCRIPT; - else - this._parseCondition = this._parseConditions.INITIAL; + this._parseCondition = this._parseConditions.INITIAL; + this.tokenType = "html-tag"; return cursor; } - <INITIAL> StringLiteral { return this._stringToken(cursor, true); } - <INITIAL> DoubleStringStart => DSTRING { return this._stringToken(cursor); } + <TAG> StringLiteral { return this._stringToken(cursor, true); } + <TAG> DoubleStringStart => DSTRING { return this._stringToken(cursor); } <DSTRING> DoubleStringContent => DSTRING { return this._stringToken(cursor); } - <DSTRING> DoubleStringEnd => INITIAL { return this._stringToken(cursor, true); } - <INITIAL> SingleStringStart => SSTRING { return this._stringToken(cursor); } + <DSTRING> DoubleStringEnd => TAG { return this._stringToken(cursor, true); } + <TAG> SingleStringStart => SSTRING { return this._stringToken(cursor); } <SSTRING> SingleStringContent => SSTRING { return this._stringToken(cursor); } - <SSTRING> SingleStringEnd => INITIAL { return this._stringToken(cursor, true); } + <SSTRING> SingleStringEnd => TAG { return this._stringToken(cursor, true); } - <INITIAL> EqualSign => INITIAL + <TAG> EqualSign => TAG { - if (this._isAttribute()) { - this.tokenType = null; - this._setAttributeValue(); - } else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; - else - this.tokenType = null; + if (this._isExpectingAttribute()) + this._setExpectingAttributeValue(); + this.tokenType = null; return cursor; } - <INITIAL> Identifier + <TAG> Identifier { if (this._parseCondition === this._parseConditions.SCRIPT) { + // Fall through if expecting attributes. this.tokenType = null; return cursor; } - if (this._parseCondition === this._parseConditions.TAG) { + if (this._parseCondition === this._parseConditions.INITIAL) { this.tokenType = "html-tag"; - this._parseCondition = this._parseConditions.ATTRIBUTE; - } else if (this._isAttribute()) - this.tokenType = "html-attr-name"; - else if (this._isAttributeValue()) - this.tokenType = "html-attr-value"; - else if (this._parseCondition === this._parseConditions.DOCTYPE) - this.tokenType = "html-doctype"; + this._setExpectingAttribute(); + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "a") + this._parseCondition |= this._parseConditions.A_NODE; + else if (this._parseCondition & this._parseConditions.A_NODE) + this._parseCondition ^= this._parseConditions.A_NODE; + } else if (this._isExpectingAttribute()) { + var token = this._line.substring(cursorOnEnter, cursor); + if (token === "href" || token === "src") + this._parseCondition |= this._parseConditions.LINKIFY; + else if (this._parseCondition |= this._parseConditions.LINKIFY) + this._parseCondition ^= this._parseConditions.LINKIFY; + this.tokenType = "html-attribute-name"; + } else if (this._isExpectingAttributeValue()) + this.tokenType = this._attrValueTokenType(); else this.tokenType = null; return cursor; diff --git a/WebCore/inspector/front-end/SourceView.js b/WebCore/inspector/front-end/SourceView.js index 292b8af..7fc8499 100644 --- a/WebCore/inspector/front-end/SourceView.js +++ b/WebCore/inspector/front-end/SourceView.js @@ -41,7 +41,6 @@ WebInspector.SourceView.prototype = { show: function(parentElement) { WebInspector.ResourceView.prototype.show.call(this, parentElement); - this.setupSourceFrameIfNeeded(); this.sourceFrame.visible = true; this.resize(); }, @@ -79,10 +78,15 @@ WebInspector.SourceView.prototype = { delete this._frameNeedsSetup; WebInspector.getResourceContent(this.resource.identifier, this._contentLoaded.bind(this)); }, - + + contentTabSelected: function() + { + this.setupSourceFrameIfNeeded(); + }, + _contentLoaded: function(content) { - this.sourceFrame.setContent(this.resource.mimeType, content); + this.sourceFrame.setContent(this.resource.mimeType, content, this.resource.url); this._sourceFrameSetupFinished(); }, diff --git a/WebCore/inspector/front-end/TextEditor.js b/WebCore/inspector/front-end/TextEditor.js index afa97c1..9268280 100644 --- a/WebCore/inspector/front-end/TextEditor.js +++ b/WebCore/inspector/front-end/TextEditor.js @@ -35,7 +35,8 @@ WebInspector.TextEditor = function(textModel, platform) this._highlighter = new WebInspector.TextEditorHighlighter(this._textModel, this._highlightChanged.bind(this)); this.element = document.createElement("div"); - this.element.className = "text-editor"; + this.element.className = "text-editor monospace"; + this.element.tabIndex = 0; this._canvas = document.createElement("canvas"); this._canvas.className = "text-editor-canvas"; @@ -43,7 +44,6 @@ WebInspector.TextEditor = function(textModel, platform) this._container = document.createElement("div"); this._container.className = "text-editor-container"; - this._container.tabIndex = 0; this.element.appendChild(this._container); this._sheet = document.createElement("div"); @@ -55,7 +55,6 @@ WebInspector.TextEditor = function(textModel, platform) this._cursor = new WebInspector.TextCursor(cursorElement); this._container.addEventListener("scroll", this._scroll.bind(this), false); - this._sheet.addEventListener("contextmenu", this._contextMenu.bind(this), false); this._registerMouseListeners(); this._registerKeyboardListeners(); @@ -69,9 +68,6 @@ WebInspector.TextEditor = function(textModel, platform) this._selection = new WebInspector.TextSelectionModel(this._selectionChanged.bind(this)); this._isMac = platform && (platform.indexOf("mac") === 0); - - this._initFont(); - this._paintCoalescingLevel = 0; this._registerShortcuts(); @@ -84,6 +80,7 @@ WebInspector.TextEditor = function(textModel, platform) this._lineOffsetsCache = [0]; this._readOnly = false; + this._selectionColor = "rgb(181, 213, 255)"; } WebInspector.TextEditor.prototype = { @@ -152,11 +149,12 @@ WebInspector.TextEditor.prototype = { _registerMouseListeners: function() { - this._sheet.addEventListener("mouseup", this._mouseUp.bind(this), false); - this._sheet.addEventListener("mousedown", this._mouseDown.bind(this), false); - this._sheet.addEventListener("mousemove", this._mouseMove.bind(this), false); - this._sheet.addEventListener("mouseout", this._mouseOut.bind(this), false); - this._sheet.addEventListener("dblclick", this._dblClick.bind(this), false); + this.element.addEventListener("contextmenu", this._contextMenu.bind(this), false); + this.element.addEventListener("mouseup", this._mouseUp.bind(this), false); + this.element.addEventListener("mousedown", this._mouseDown.bind(this), false); + this.element.addEventListener("mousemove", this._mouseMove.bind(this), false); + this.element.addEventListener("mouseout", this._mouseOut.bind(this), false); + this.element.addEventListener("dblclick", this._dblClick.bind(this), false); }, _registerKeyboardListeners: function() @@ -180,7 +178,7 @@ WebInspector.TextEditor.prototype = { if (offset > this._lineOffsetsCache[this._lineOffsetsCache.length - 1]) { // Seeking outside cached area. Fill the cache. var lineNumber = this._lineOffsetsCache.length; - while (this._lineToOffset(lineNumber) < offset) + while (lineNumber < this._textModel.linesCount && this._lineToOffset(lineNumber) < offset) lineNumber++; return lineNumber; } @@ -217,6 +215,10 @@ WebInspector.TextEditor.prototype = { _lineHeight: function(lineNumber) { + // Use cached value first. + if (this._lineOffsetsCache[lineNumber + 1]) + return this._lineOffsetsCache[lineNumber + 1] - this._lineOffsetsCache[lineNumber]; + var element = this._textModel.getAttribute(lineNumber, "div-decoration"); if (element) return 2 * this._textLineHeight + element.clientHeight; @@ -225,6 +227,9 @@ WebInspector.TextEditor.prototype = { reveal: function(line, column) { + this._scrollTop = this._container.scrollTop; + this._scrollLeft = this._container.scrollLeft; + var maxScrollTop = this._lineToOffset(line); var minScrollTop = maxScrollTop + this._lineHeight(line) - this._canvas.height; if (this._scrollTop > maxScrollTop) @@ -237,8 +242,10 @@ WebInspector.TextEditor.prototype = { var minScrollLeft = maxScrollLeft - this._container.clientWidth + this._lineNumberWidth; if (this._scrollLeft < minScrollLeft) this._container.scrollLeft = minScrollLeft + 100; - if (this._scrollLeft > maxScrollLeft) + else if (this._scrollLeft > maxScrollLeft) this._container.scrollLeft = maxScrollLeft; + else if (minScrollLeft < 0 && maxScrollLeft > 0) + this._container.scrollLeft = 0; }, // WebInspector.TextModel listener @@ -326,8 +333,9 @@ WebInspector.TextEditor.prototype = { var newLineNumberDigits = this._decimalDigits(this._textModel.linesCount); this._lineNumberWidth = (newLineNumberDigits + 2) * this._digitWidth; + this._container.style.left = this._lineNumberWidth + "px"; - var newWidth = this._textWidth + this._lineNumberWidth + "px"; + var newWidth = this._textWidth + "px"; var newHeight = this._lineToOffset(this._textModel.linesCount) + "px"; this._sheet.style.width = newWidth; this._sheet.style.height = newHeight; @@ -345,7 +353,7 @@ WebInspector.TextEditor.prototype = { resize: function() { if (this._canvas.width !== this._container.clientWidth || this._canvas.height !== this._container.clientHeight) { - this._canvas.width = this._container.clientWidth; + this._canvas.width = this._container.clientWidth + this._lineNumberWidth; this._canvas.height = this._container.clientHeight; this.repaintAll(); } @@ -376,16 +384,20 @@ WebInspector.TextEditor.prototype = { _paint: function() { + this._scrollTop = this._container.scrollTop; + this._scrollLeft = this._container.scrollLeft; + if (this._paintCoalescingLevel) return; + this._updateDivDecorations(); + this.paintLineNumbers(); for (var i = 0; this._damage && i < this._damage.length; ++i) this._paintLines(this._damage[i].startLine, this._damage[i].endLine); delete this._damage; - this._updateDivDecorations(); this._updateCursor(this._selection.endLine, this._selection.endColumn); }, @@ -556,7 +568,7 @@ WebInspector.TextEditor.prototype = { var location = this._caretForMouseEvent(e); - if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) { + if (e.target === this.element && this._lineNumberDecorator) { if (this._lineNumberDecorator.mouseDown(location.line, e)) return; } @@ -590,7 +602,7 @@ WebInspector.TextEditor.prototype = { _contextMenu: function(e) { - if (e.offsetX < this._lineNumberWidth && this._lineNumberDecorator) { + if (e.target === this.element && this._lineNumberDecorator) { var location = this._caretForMouseEvent(e); if (this._lineNumberDecorator.contextMenu(location.line, e)) return; @@ -607,8 +619,8 @@ WebInspector.TextEditor.prototype = { _caretForMouseEvent: function(e) { - var lineNumber = Math.max(0, this._offsetToLine(e.offsetY) - 1); - var offset = e.offsetX + this._scrollLeft - this._lineNumberWidth; + var lineNumber = Math.max(0, this._offsetToLine(e.offsetY + (e.target === this.element ? this._scrollTop : 0)) - 1); + var offset = e.offsetX + this._scrollLeft; return { line: lineNumber, column: this._columnForOffset(lineNumber, offset) }; }, @@ -811,8 +823,10 @@ WebInspector.TextEditor.prototype = { var linesCount = this._textModel.linesCount; for (var i = 0; i < linesCount; ++i) { var element = this._textModel.getAttribute(i, "div-decoration"); - if (element) + if (element) { + this._lineOffsetsCache.length = Math.min(this._lineOffsetsCache.length, i + 1); this._positionDivDecoration(i, element, i > firstLine && i < lastLine); + } } }, @@ -848,7 +862,7 @@ WebInspector.TextEditor.prototype = { if (this._selection.isEmpty()) return; var range = this._selection.range(); - this._ctx.fillStyle = "rgb(181, 213, 255)"; + this._ctx.fillStyle = this._selectionColor; firstLine = Math.max(firstLine, range.startLine); endLine = Math.min(lastLine, range.endLine + 1); @@ -962,34 +976,14 @@ WebInspector.TextEditor.prototype = { this._updateCursor(this._selection.endLine, this._selection.endColumn); }, - _initFont: function(sansSerif) + initFontMetrics: function() { - if (!WebInspector.TextEditor.PlatformFonts) { - WebInspector.TextEditor.PlatformFonts = {}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.Windows] = {size: 12, face: "Lucida Console"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.WindowsVistaOrLater] = {size: 12, face: "Courier"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacSnowLeopard] = {size: 11, face: "Menlo"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacLeopard] = {size: 10, face: "Monaco"}; - WebInspector.TextEditor.PlatformFonts[WebInspector.OS.MacTiger] = {size: 10, face: "Monaco"}; - } - - if (sansSerif) { - this._isMonospace = false; - this._fontSize = 11; - this._font = this._fontSize + "px sans-serif"; - } else { - this._isMonospace = true; - const platform = WebInspector.platform; - const fontInfo = WebInspector.TextEditor.PlatformFonts[platform] || {size: 10, face: "monospace"}; - this._fontSize = fontInfo.size; - this._font = this._fontSize + "px " + fontInfo.face; - } + var computedStyle = window.getComputedStyle(this.element); + this._font = computedStyle.fontSize + " " + computedStyle.fontFamily; this._ctx.font = this._font; this._digitWidth = this._ctx.measureText("0").width; - - this._textLineHeight = Math.floor(this._fontSize * 1.4); + this._textLineHeight = Math.floor(parseInt(this._ctx.font) * 1.4); this._cursor.setTextLineHeight(this._textLineHeight); - this._lineOffsetsCache = [0]; }, _registerShortcuts: function() @@ -999,15 +993,11 @@ WebInspector.TextEditor.prototype = { this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleUndo.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("z", modifiers.Shift | (this._isMac ? modifiers.Meta : modifiers.Ctrl))] = this._handleRedo.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("a", this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._selectAll.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Plus, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomIn.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Minus, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomOut.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.KeyCodes.Zero, this._isMac ? modifiers.Meta : modifiers.Ctrl)] = this._handleZoomReset.bind(this); if (this._isMac) this._shortcuts[WebInspector.KeyboardShortcut.makeKey("d", modifiers.Ctrl)] = this._handleDeleteKey.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("d", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleDebugMode.bind(this); this._shortcuts[WebInspector.KeyboardShortcut.makeKey("h", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleHighlightMode.bind(this); - this._shortcuts[WebInspector.KeyboardShortcut.makeKey("m", modifiers.Ctrl | modifiers.Alt)] = this._handleToggleMonospaceMode.bind(this); }, _handleUndo: function() @@ -1065,34 +1055,6 @@ WebInspector.TextEditor.prototype = { this._debugMode = !this._debugMode; }, - _handleZoomIn: function() - { - if (this._fontSize < 25) - this._changeFont(!this._isMonospace, this._fontSize + 1); - }, - - _handleZoomOut: function() - { - if (this._fontSize > 1) - this._changeFont(!this._isMonospace, this._fontSize - 1); - }, - - _handleZoomReset: function() - { - this._changeFont(!this._isMonospace); - }, - - _handleToggleMonospaceMode: function() - { - this._changeFont(this._isMonospace, this._fontSize); - }, - - _changeFont: function(sansSerif, fontSize) { - this._initFont(sansSerif, fontSize); - this._updatePreferredSize(0, this._textModel.linesCount); - this.repaintAll(); - }, - _handleToggleHighlightMode: function() { this._highlightingEnabled = !this._highlightingEnabled; diff --git a/WebCore/inspector/front-end/TextEditorHighlighter.js b/WebCore/inspector/front-end/TextEditorHighlighter.js index 9a7a050..c73e036 100644 --- a/WebCore/inspector/front-end/TextEditorHighlighter.js +++ b/WebCore/inspector/front-end/TextEditorHighlighter.js @@ -47,10 +47,12 @@ WebInspector.TextEditorHighlighter = function(textModel, damageCallback) /* Keep this in sync with inspector.css and view-source.css */ this._styles["html-tag"] = "rgb(136, 18, 128)"; - this._styles["html-attr-name"] = "rgb(153, 69, 0)"; - this._styles["html-attr-value"] = "rgb(26, 26, 166)"; + this._styles["html-attribute-name"] = "rgb(153, 69, 0)"; + this._styles["html-attribute-value"] = "rgb(26, 26, 166)"; this._styles["html-comment"] = "rgb(35, 110, 37)"; this._styles["html-doctype"] = "rgb(192, 192, 192)"; + this._styles["html-external-link"] = "#00e"; + this._styles["html-resource-link"] = "#00e"; this._styles["javascript-comment"] = "rgb(0, 116, 0)"; this._styles["javascript-string"] = "rgb(196, 26, 22)"; diff --git a/WebCore/inspector/front-end/inspector.css b/WebCore/inspector/front-end/inspector.css index 501915d..45b8ec3 100644 --- a/WebCore/inspector/front-end/inspector.css +++ b/WebCore/inspector/front-end/inspector.css @@ -246,13 +246,11 @@ body.attached.port-qt .toolbar-item.close-left, body.attached.port-qt .toolbar-i display: none; } -body.platform-mac-tiger .toolbar-item.close-right, -body.platform-mac-leopard .toolbar-item.close-right, -body.platform-mac-snowleopard .toolbar-item.close-right { +body.platform-mac .toolbar-item.close-right { display: none; } -body:not(.platform-mac-tiger):not(.platform-mac-leopard):not(.platform-mac-snowleopard) .toolbar-item.close-left { +body:not(.platform-mac) .toolbar-item.close-left { display: none; } @@ -503,20 +501,18 @@ body.drawer-visible #drawer { font-family: monospace; } -body.platform-mac-tiger .monospace, body.platform-mac-leopard .monospace, -body.platform-mac-tiger .source-code, body.platform-mac-leopard .source-code { - font-size: 10px; +body.platform-mac .monospace, body.platform-mac .source-code { font-family: Monaco, monospace; } -body.platform-mac-snowleopard .monospace, -body.platform-mac-snowleopard .source-code { +/* Keep .platform-mac to make the rule more specific than the general one above. */ +body.platform-mac.platform-mac-snowleopard .monospace, +body.platform-mac.platform-mac-snowleopard .source-code { font-size: 11px; font-family: Menlo, monospace; } -body.platform-windows .monospace, body.platform-windows-vista-or-later .monospace, -body.platform-windows .source-code, body.platform-windows-vista-or-later .source-code { +body.platform-windows .monospace, body.platform-windows .source-code { font-size: 12px; font-family: Consolas, Lucida Console, monospace; } @@ -1188,46 +1184,6 @@ body.platform-windows .source-code, body.platform-windows-vista-or-later .source display: block; } -.webkit-html-comment { - /* Keep this in sync with view-source.css (.webkit-html-comment) */ - color: rgb(35, 110, 37); -} - -.webkit-html-tag { - /* Keep this in sync with view-source.css (.webkit-html-tag) */ - color: rgb(136, 18, 128); -} - -.webkit-html-doctype { - /* Keep this in sync with view-source.css (.webkit-html-doctype) */ - color: rgb(192, 192, 192); -} - -.webkit-html-attribute-name { - /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ - color: rgb(153, 69, 0); -} - -.webkit-html-attribute-value { - /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */ - color: rgb(26, 26, 166); -} - -.webkit-html-external-link, .webkit-html-resource-link { - /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */ - color: #00e; -} - -.webkit-html-external-link { - /* Keep this in sync with view-source.css (.webkit-html-external-link) */ - text-decoration: none; -} - -.webkit-html-external-link:hover { - /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */ - text-decoration: underline; -} - .add-attribute { margin-left: 1px; margin-right: 1px; diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js index c637f37..de20739 100644 --- a/WebCore/inspector/front-end/inspector.js +++ b/WebCore/inspector/front-end/inspector.js @@ -67,37 +67,44 @@ var WebInspector = { get platform() { if (!("_platform" in this)) - this._platform = this._detectPlatform(); + this._platform = InspectorFrontendHost.platform(); return this._platform; }, - _detectPlatform: function() + get platformFlavor() + { + if (!("_platformFlavor" in this)) + this._platformFlavor = this._detectPlatformFlavor(); + + return this._platformFlavor; + }, + + _detectPlatformFlavor: function() { const userAgent = navigator.userAgent; - var nativePlatform = InspectorFrontendHost.platform(); - if (nativePlatform === "windows") { + if (this.platform === "windows") { var match = userAgent.match(/Windows NT (\d+)\.(?:\d+)/); if (match && match[1] >= 6) - return WebInspector.OS.WindowsVistaOrLater; - return WebInspector.OS.Windows; - } else if (nativePlatform === "mac") { + return WebInspector.PlatformFlavor.WindowsVista; + return null; + } else if (this.platform === "mac") { var match = userAgent.match(/Mac OS X\s*(?:(\d+)_(\d+))?/); if (!match || match[1] != 10) - return WebInspector.OS.MacSnowLeopard; + return WebInspector.PlatformFlavor.MacSnowLeopard; switch (Number(match[2])) { case 4: - return WebInspector.OS.MacTiger; + return WebInspector.PlatformFlavor.MacTiger; case 5: - return WebInspector.OS.MacLeopard; + return WebInspector.PlatformFlavor.MacLeopard; case 6: default: - return WebInspector.OS.MacSnowLeopard; + return WebInspector.PlatformFlavor.MacSnowLeopard; } } - return nativePlatform; + return null; }, get port() @@ -415,9 +422,8 @@ var WebInspector = { } } -WebInspector.OS = { - Windows: "windows", - WindowsVistaOrLater: "windows-vista-or-later", +WebInspector.PlatformFlavor = { + WindowsVista: "windows-vista", MacTiger: "mac-tiger", MacLeopard: "mac-leopard", MacSnowLeopard: "mac-snowleopard" @@ -429,6 +435,9 @@ WebInspector.loaded = function() var platform = WebInspector.platform; document.body.addStyleClass("platform-" + platform); + var flavor = WebInspector.platformFlavor; + if (flavor) + document.body.addStyleClass("platform-" + flavor); var port = WebInspector.port; document.body.addStyleClass("port-" + port); @@ -871,7 +880,7 @@ WebInspector.toggleAttach = function() WebInspector.toolbarDragStart = function(event) { - if ((!WebInspector.attached && WebInspector.platform !== "mac-leopard") || WebInspector.port == "qt") + if ((!WebInspector.attached && WebInspector.platformFlavor !== WebInspector.PlatformFlavor.MacLeopard && WebInspector.platformFlavor !== WebInspector.PlatformFlavor.MacSnowLeopard) || WebInspector.port == "qt") return; var target = event.target; @@ -1528,6 +1537,20 @@ WebInspector.linkifyURL = function(url, linkText, classes, isExternal, tooltipTe return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal, tooltipText).outerHTML; } +WebInspector.completeURL = function(baseURL, href) +{ + var match = baseURL.match(WebInspector.URLRegExp); + if (match) { + var path = href; + if (path.charAt(0) !== "/") { + var basePath = match[4] || "/"; + path = basePath.substring(0, basePath.lastIndexOf("/")) + "/" + path; + } + return match[1] + "://" + match[2] + (match[3] ? (":" + match[3]) : "") + path; + } + return null; +} + WebInspector.addMainEventListeners = function(doc) { doc.defaultView.addEventListener("focus", this.windowFocused.bind(this), false); @@ -1685,7 +1708,7 @@ WebInspector.UIString = function(string) WebInspector.isMac = function() { if (!("_isMac" in this)) - this._isMac = WebInspector.platform.indexOf("mac-") === 0; + this._isMac = WebInspector.platform === "mac"; return this._isMac; } diff --git a/WebCore/inspector/front-end/inspectorSyntaxHighlight.css b/WebCore/inspector/front-end/inspectorSyntaxHighlight.css index e3e3074..1292f00 100644 --- a/WebCore/inspector/front-end/inspectorSyntaxHighlight.css +++ b/WebCore/inspector/front-end/inspectorSyntaxHighlight.css @@ -65,3 +65,43 @@ .webkit-javascript-string, .webkit-javascript-regexp { color: rgb(196, 26, 22); } + +.webkit-html-comment { + /* Keep this in sync with view-source.css (.webkit-html-comment) */ + color: rgb(35, 110, 37); +} + +.webkit-html-tag { + /* Keep this in sync with view-source.css (.webkit-html-tag) */ + color: rgb(136, 18, 128); +} + +.webkit-html-doctype { + /* Keep this in sync with view-source.css (.webkit-html-doctype) */ + color: rgb(192, 192, 192); +} + +.webkit-html-attribute-name { + /* Keep this in sync with view-source.css (.webkit-html-attribute-name) */ + color: rgb(153, 69, 0); +} + +.webkit-html-attribute-value { + /* Keep this in sync with view-source.css (.webkit-html-attribute-value) */ + color: rgb(26, 26, 166); +} + +.webkit-html-external-link, .webkit-html-resource-link { + /* Keep this in sync with view-source.css (.webkit-html-external-link, .webkit-html-resource-link) */ + color: #00e; +} + +.webkit-html-external-link { + /* Keep this in sync with view-source.css (.webkit-html-external-link) */ + text-decoration: none; +} + +.webkit-html-external-link:hover { + /* Keep this in sync with view-source.css (.webkit-html-external-link:hover) */ + text-decoration: underline; +} diff --git a/WebCore/inspector/front-end/textEditor.css b/WebCore/inspector/front-end/textEditor.css index 9629a07..93495f2 100644 --- a/WebCore/inspector/front-end/textEditor.css +++ b/WebCore/inspector/front-end/textEditor.css @@ -45,7 +45,6 @@ } .native-text-editor-line { - height: 14px; white-space: pre; } diff --git a/WebCore/loader/FTPDirectoryDocument.cpp b/WebCore/loader/FTPDirectoryDocument.cpp index 7a71d02..62173f5 100644 --- a/WebCore/loader/FTPDirectoryDocument.cpp +++ b/WebCore/loader/FTPDirectoryDocument.cpp @@ -38,14 +38,9 @@ #include "Settings.h" #include "SharedBuffer.h" #include "Text.h" -#include <wtf/StdLibExtras.h> -#if PLATFORM(QT) -#include <QDateTime> -// On Windows, use the threadsafe *_r functions provided by pthread. -#elif OS(WINDOWS) && (USE(PTHREADS) || HAVE(PTHREAD_H)) -#include <pthread.h> -#endif +#include <wtf/CurrentTime.h> +#include <wtf/StdLibExtras.h> using namespace std; @@ -200,48 +195,6 @@ static bool wasLastDayOfMonth(int year, int month, int day) return lastDays[month] == day; } -#if PLATFORM(QT) - -/*! - Replacement for localtime_r() which is not available on MinGW. - - We use this on all of Qt's platforms for portability. - */ -struct tm gmtimeQt(const QDateTime &input) -{ - tm result; - - const QDate date(input.date()); - result.tm_year = date.year() - 1900; - result.tm_mon = date.month(); - result.tm_mday = date.day(); - result.tm_wday = date.dayOfWeek(); - result.tm_yday = date.dayOfYear(); - - const QTime time(input.time()); - result.tm_sec = time.second(); - result.tm_min = time.minute(); - result.tm_hour = time.hour(); - - return result; -} - -static struct tm *localTimeQt(const time_t *const timep, struct tm *result) -{ - const QDateTime dt(QDateTime::fromTime_t(*timep)); - *result = WebCore::gmtimeQt(dt.toLocalTime()); - return result; -} - -#define localtime_r(x, y) localTimeQt(x, y) -#elif OS(WINDOWS) && !defined(localtime_r) -#if defined(_MSC_VER) && (_MSC_VER >= 1400) -#define localtime_r(x, y) localtime_s((y), (x)) -#else /* !_MSC_VER */ -#define localtime_r(x,y) (localtime(x)?(*(y)=*localtime(x),(y)):0) -#endif -#endif - static String processFileDateString(const FTPTime& fileTime) { // FIXME: Need to localize this string? @@ -267,7 +220,7 @@ static String processFileDateString(const FTPTime& fileTime) // If it was today or yesterday, lets just do that - but we have to compare to the current time struct tm now; time_t now_t = time(NULL); - localtime_r(&now_t, &now); + getLocalTime(&now_t, &now); // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes now.tm_year += 1900; diff --git a/WebCore/loader/FTPDirectoryParser.cpp b/WebCore/loader/FTPDirectoryParser.cpp index 34c19a4..142f2a3 100644 --- a/WebCore/loader/FTPDirectoryParser.cpp +++ b/WebCore/loader/FTPDirectoryParser.cpp @@ -38,8 +38,27 @@ using namespace WTF; namespace WebCore { #if PLATFORM(QT) && defined(Q_WS_WIN32) -// Defined in FTPDirectoryDocument.cpp. -struct tm gmtimeQt(const QDateTime &input); + +// Replacement for gmtime_r() which is not available on MinGW. +// We use this on Win32 Qt platform for portability. +struct tm gmtimeQt(const QDateTime& input) +{ + tm result; + + QDate date(input.date()); + result.tm_year = date.year() - 1900; + result.tm_mon = date.month(); + result.tm_mday = date.day(); + result.tm_wday = date.dayOfWeek(); + result.tm_yday = date.dayOfYear(); + + QTime time(input.time()); + result.tm_sec = time.second(); + result.tm_min = time.minute(); + result.tm_hour = time.hour(); + + return result; +} static struct tm *gmtimeQt(const time_t *const timep, struct tm *result) { diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 6422535..9e264b5 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -1501,7 +1501,7 @@ bool FrameLoader::isProcessingUserGesture() Frame* frame = m_frame->tree()->top(); if (!frame->script()->canExecuteScripts()) return true; // If JavaScript is disabled, a user gesture must have initiated the navigation. - return frame->script()->processingUserGesture(); // FIXME: Use pageIsProcessingUserGesture. + return frame->script()->processingUserGesture(mainThreadNormalWorld()); // FIXME: Use pageIsProcessingUserGesture. } void FrameLoader::resetMultipleFormSubmissionProtection() @@ -3579,7 +3579,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass if (!m_frame->page()) return; -#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) +#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) && USE(JSC) if (Page* page = m_frame->page()) { if (page->mainFrame() == m_frame) page->inspectorController()->resumeDebugger(); @@ -3900,7 +3900,9 @@ void FrameLoader::loadItem(HistoryItem* item, FrameLoadType loadType) // - The HistoryItem has a history state object // - Navigating to an anchor within the page, with no form data stored on the target item or the current history entry, // and the URLs in the frame tree match the history item for fragment scrolling. - bool sameDocumentNavigation = (!item->formData() && !(history()->currentItem() && history()->currentItem()->formData()) && history()->urlsMatchItem(item)) || item->documentSequenceNumber() == history()->currentItem()->documentSequenceNumber(); + HistoryItem* currentItem = history()->currentItem(); + bool sameDocumentNavigation = (!item->formData() && !(currentItem && currentItem->formData()) && history()->urlsMatchItem(item)) + || (currentItem && item->documentSequenceNumber() == currentItem->documentSequenceNumber()); #if ENABLE(WML) // All WML decks should go through the real load mechanism, not the scroll-to-anchor code diff --git a/WebCore/loader/MediaDocument.cpp b/WebCore/loader/MediaDocument.cpp index 656d0a0..a2d6276 100644 --- a/WebCore/loader/MediaDocument.cpp +++ b/WebCore/loader/MediaDocument.cpp @@ -159,12 +159,12 @@ void MediaDocument::defaultEventHandler(Event* event) HTMLVideoElement* video = static_cast<HTMLVideoElement*>(targetNode); if (event->type() == eventNames().clickEvent) { if (!video->canPlay()) { - video->pause(); + video->pause(event->fromUserGesture()); event->setDefaultHandled(); } } else if (event->type() == eventNames().dblclickEvent) { if (video->canPlay()) { - video->play(); + video->play(event->fromUserGesture()); event->setDefaultHandled(); } } @@ -186,9 +186,9 @@ void MediaDocument::defaultEventHandler(Event* event) if (keyboardEvent->keyIdentifier() == "U+0020") { // space if (video->paused()) { if (video->canPlay()) - video->play(); + video->play(event->fromUserGesture()); } else - video->pause(); + video->pause(event->fromUserGesture()); event->setDefaultHandled(); } } diff --git a/WebCore/loader/icon/IconDatabaseClient.h b/WebCore/loader/icon/IconDatabaseClient.h index 8806406..1811214 100644 --- a/WebCore/loader/icon/IconDatabaseClient.h +++ b/WebCore/loader/icon/IconDatabaseClient.h @@ -29,6 +29,8 @@ #ifndef IconDatabaseClient_h #define IconDatabaseClient_h +#include <wtf/Noncopyable.h> + // All of these client methods will be called from a non-main thread // Take appropriate measures @@ -36,7 +38,7 @@ namespace WebCore { class String; -class IconDatabaseClient { +class IconDatabaseClient : public Noncopyable { public: virtual ~IconDatabaseClient() { } virtual bool performImport() { return true; } diff --git a/WebCore/manual-tests/drag-image-table-part-decorations.html b/WebCore/manual-tests/drag-image-table-part-decorations.html new file mode 100644 index 0000000..467cc54 --- /dev/null +++ b/WebCore/manual-tests/drag-image-table-part-decorations.html @@ -0,0 +1,16 @@ +<!DOCTYPE HTML> +<p> + When dragging each of the black squares below, the drag image should include + only the hollow black square, and no blue background. +</p> +<div style="background-color: blue; display: table; height: 100px; width: 100px;"></div> +<div style="width: 94px; height: 94px; border: solid; -webkit-user-drag: element; margin-top: -50px; margin-bottom: 10px;"></div> + +<div style="background-color: blue; display: table-row; height: 100px;"><div style="width: 100px"></div></div> +<div style="width: 94px; height: 94px; border: solid; -webkit-user-drag: element; margin-top: -50px; margin-bottom: 10px;"></div> + +<div style="background-color: blue; display: table-cell; height: 100px; width: 100px;"></div> +<div style="width: 94px; height: 94px; border: solid; -webkit-user-drag: element; margin-top: -50px; margin-bottom: 10px;"></div> + +<fieldset style="background-color: blue; border: none; height: 100px; width: 100px;"><legend></legend></fieldset> +<div style="width: 94px; height: 94px; border: solid; -webkit-user-drag: element; margin-top: -50px; "></div> diff --git a/WebCore/mathml/RenderMathMLBlock.cpp b/WebCore/mathml/RenderMathMLBlock.cpp index 249c136..a897ff5 100644 --- a/WebCore/mathml/RenderMathMLBlock.cpp +++ b/WebCore/mathml/RenderMathMLBlock.cpp @@ -30,6 +30,7 @@ #include "RenderMathMLBlock.h" #include "FontSelector.h" +#include "GraphicsContext.h" #include "MathMLNames.h" #include "RenderInline.h" #include "RenderText.h" @@ -73,6 +74,39 @@ void RenderMathMLBlock::stretchToHeight(int height) } } +#if ENABLE(DEBUG_MATH_LAYOUT) +void RenderMathMLBlock::paint(PaintInfo& info, int tx, int ty) +{ + RenderBlock::paint(info, tx, ty); + + if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground) + return; + + tx += x(); + ty += y(); + + info.context->save(); + + info.context->setStrokeThickness(1.0f); + info.context->setStrokeStyle(SolidStroke); + info.context->setStrokeColor(Color(0, 0, 255), sRGBColorSpace); + + info.context->drawLine(IntPoint(tx, ty), IntPoint(tx + offsetWidth(), ty)); + info.context->drawLine(IntPoint(tx + offsetWidth(), ty), IntPoint(tx + offsetWidth(), ty + offsetHeight())); + info.context->drawLine(IntPoint(tx, ty + offsetHeight()), IntPoint(tx + offsetWidth(), ty + offsetHeight())); + info.context->drawLine(IntPoint(tx, ty), IntPoint(tx, ty + offsetHeight())); + + int baseline = baselinePosition(true); + + info.context->setStrokeColor(Color(255, 0, 0), sRGBColorSpace); + + info.context->drawLine(IntPoint(tx, ty + baseline), IntPoint(tx + offsetWidth(), ty + baseline)); + + info.context->restore(); + +} +#endif // ENABLE(DEBUG_MATH_LAYOUT) + } diff --git a/WebCore/mathml/RenderMathMLBlock.h b/WebCore/mathml/RenderMathMLBlock.h index b274a69..e01a325 100644 --- a/WebCore/mathml/RenderMathMLBlock.h +++ b/WebCore/mathml/RenderMathMLBlock.h @@ -30,6 +30,8 @@ #include "RenderBlock.h" +#define ENABLE_DEBUG_MATH_LAYOUT 0 + namespace WebCore { class RenderMathMLBlock : public RenderBlock { @@ -44,6 +46,10 @@ public: virtual bool hasBase() const { return false; } virtual int nonOperatorHeight() const; virtual void stretchToHeight(int height); + +#if ENABLE(DEBUG_MATH_LAYOUT) + virtual void paint(PaintInfo&, int tx, int ty); +#endif protected: virtual PassRefPtr<RenderStyle> makeBlockStyle(); diff --git a/WebCore/page/Console.cpp b/WebCore/page/Console.cpp index 2273a5e..8f55c78 100644 --- a/WebCore/page/Console.cpp +++ b/WebCore/page/Console.cpp @@ -41,11 +41,9 @@ #include "PageGroup.h" #include "PlatformString.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) -#include <profiler/Profiler.h> -#endif - #include "ScriptCallStack.h" +#include "ScriptProfile.h" +#include "ScriptProfiler.h" #include <stdio.h> #include <wtf/UnusedParam.h> @@ -314,38 +312,40 @@ String Console::lastWMLErrorMessage() const } #endif -#if ENABLE(JAVASCRIPT_DEBUGGER) +// FIXME: "USE(V8)" and "USE(JSC)" below are temporary measures until JAVASCRIPT_DEBUGGER is +// enabled when building Chromium. +#if ENABLE(JAVASCRIPT_DEBUGGER) || USE(V8) -void Console::profile(const JSC::UString& title, ScriptCallStack* callStack) +void Console::profile(const String& title, ScriptCallStack* callStack) { Page* page = this->page(); if (!page) return; -#if ENABLE(INSPECTOR) +#if ENABLE(INSPECTOR) && USE(JSC) InspectorController* controller = page->inspectorController(); // FIXME: log a console message when profiling is disabled. if (!controller->profilerEnabled()) return; #endif - JSC::UString resolvedTitle = title; - if (title.isNull()) // no title so give it the next user initiated profile title. -#if ENABLE(INSPECTOR) + String resolvedTitle = title; + if (title.isNull()) // no title so give it the next user initiated profile title. +#if ENABLE(INSPECTOR) && USE(JSC) resolvedTitle = controller->getCurrentUserInitiatedProfileName(true); #else resolvedTitle = ""; #endif - JSC::Profiler::profiler()->startProfiling(callStack->state(), resolvedTitle); + ScriptProfiler::start(callStack->state(), resolvedTitle); -#if ENABLE(INSPECTOR) +#if ENABLE(INSPECTOR) && USE(JSC) const ScriptCallFrame& lastCaller = callStack->at(0); controller->addStartProfilingMessageToConsole(resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL()); #endif } -void Console::profileEnd(const JSC::UString& title, ScriptCallStack* callStack) +void Console::profileEnd(const String& title, ScriptCallStack* callStack) { Page* page = this->page(); if (!page) @@ -354,19 +354,19 @@ void Console::profileEnd(const JSC::UString& title, ScriptCallStack* callStack) if (!this->page()) return; -#if ENABLE(INSPECTOR) +#if ENABLE(INSPECTOR) && USE(JSC) InspectorController* controller = page->inspectorController(); if (!controller->profilerEnabled()) return; #endif - RefPtr<JSC::Profile> profile = JSC::Profiler::profiler()->stopProfiling(callStack->state(), title); + RefPtr<ScriptProfile> profile = ScriptProfiler::stop(callStack->state(), title); if (!profile) return; m_profiles.append(profile); -#if ENABLE(INSPECTOR) +#if ENABLE(INSPECTOR) && USE(JSC) const ScriptCallFrame& lastCaller = callStack->at(0); controller->addProfile(profile, lastCaller.lineNumber(), lastCaller.sourceURL()); #endif diff --git a/WebCore/page/Console.h b/WebCore/page/Console.h index ea3a161..bbf2ac7 100644 --- a/WebCore/page/Console.h +++ b/WebCore/page/Console.h @@ -31,101 +31,101 @@ #include "PlatformString.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) -#include <profiler/Profile.h> -#endif +#include "ScriptProfile.h" -#include <wtf/RefCounted.h> #include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> namespace WebCore { -#if ENABLE(JAVASCRIPT_DEBUGGER) - typedef Vector<RefPtr<JSC::Profile> > ProfilesArray; +// FIXME: "USE(V8)" and "USE(JSC)" below are temporary measures until JAVASCRIPT_DEBUGGER is +// enabled when building Chromium. +#if ENABLE(JAVASCRIPT_DEBUGGER) || USE(V8) +typedef Vector<RefPtr<ScriptProfile> > ProfilesArray; #endif - class Frame; - class Page; - class String; - class ScriptCallStack; - - // Keep in sync with inspector/front-end/Console.js - enum MessageSource { - HTMLMessageSource, - WMLMessageSource, - XMLMessageSource, - JSMessageSource, - CSSMessageSource, - OtherMessageSource - }; - - enum MessageType { - LogMessageType, - ObjectMessageType, - TraceMessageType, - StartGroupMessageType, - EndGroupMessageType, - AssertMessageType - }; - - enum MessageLevel { - TipMessageLevel, - LogMessageLevel, - WarningMessageLevel, - ErrorMessageLevel, - DebugMessageLevel - }; - - class Console : public RefCounted<Console> { - public: - static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); } - - Frame* frame() const; - void disconnectFrame(); - - void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); - - void debug(ScriptCallStack*); - void error(ScriptCallStack*); - void info(ScriptCallStack*); - void log(ScriptCallStack*); - void warn(ScriptCallStack*); - void dir(ScriptCallStack*); - void dirxml(ScriptCallStack*); - void trace(ScriptCallStack*); - void assertCondition(bool condition, ScriptCallStack*); - void count(ScriptCallStack*); - void markTimeline(ScriptCallStack*); +class Frame; +class Page; +class String; +class ScriptCallStack; + +// Keep in sync with inspector/front-end/Console.js +enum MessageSource { + HTMLMessageSource, + WMLMessageSource, + XMLMessageSource, + JSMessageSource, + CSSMessageSource, + OtherMessageSource +}; + +enum MessageType { + LogMessageType, + ObjectMessageType, + TraceMessageType, + StartGroupMessageType, + EndGroupMessageType, + AssertMessageType +}; + +enum MessageLevel { + TipMessageLevel, + LogMessageLevel, + WarningMessageLevel, + ErrorMessageLevel, + DebugMessageLevel +}; + +class Console : public RefCounted<Console> { +public: + static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); } + + Frame* frame() const; + void disconnectFrame(); + + void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL); + + void debug(ScriptCallStack*); + void error(ScriptCallStack*); + void info(ScriptCallStack*); + void log(ScriptCallStack*); + void warn(ScriptCallStack*); + void dir(ScriptCallStack*); + void dirxml(ScriptCallStack*); + void trace(ScriptCallStack*); + void assertCondition(bool condition, ScriptCallStack*); + void count(ScriptCallStack*); + void markTimeline(ScriptCallStack*); #if ENABLE(WML) - String lastWMLErrorMessage() const; + String lastWMLErrorMessage() const; #endif -#if ENABLE(JAVASCRIPT_DEBUGGER) - void profile(const JSC::UString&, ScriptCallStack*); - void profileEnd(const JSC::UString&, ScriptCallStack*); +#if ENABLE(JAVASCRIPT_DEBUGGER) || USE(V8) + void profile(const String&, ScriptCallStack*); + void profileEnd(const String&, ScriptCallStack*); #endif - void time(const String&); - void timeEnd(const String&, ScriptCallStack*); - void group(ScriptCallStack*); - void groupEnd(); + void time(const String&); + void timeEnd(const String&, ScriptCallStack*); + void group(ScriptCallStack*); + void groupEnd(); - static bool shouldPrintExceptions(); - static void setShouldPrintExceptions(bool); + static bool shouldPrintExceptions(); + static void setShouldPrintExceptions(bool); #if ENABLE(JAVASCRIPT_DEBUGGER) - const ProfilesArray& profiles() const { return m_profiles; } + const ProfilesArray& profiles() const { return m_profiles; } #endif - private: - inline Page* page() const; - void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false); +private: + inline Page* page() const; + void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false); - Console(Frame*); + Console(Frame*); - Frame* m_frame; -#if ENABLE(JAVASCRIPT_DEBUGGER) - ProfilesArray m_profiles; + Frame* m_frame; +#if ENABLE(JAVASCRIPT_DEBUGGER) || USE(V8) + ProfilesArray m_profiles; #endif - }; +}; } // namespace WebCore diff --git a/WebCore/page/Console.idl b/WebCore/page/Console.idl index b9c0a57..290235b 100644 --- a/WebCore/page/Console.idl +++ b/WebCore/page/Console.idl @@ -51,8 +51,8 @@ module window { #endif #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER || defined(V8_BINDING) && V8_BINDING - [Custom] void profile(in [ConvertUndefinedOrNullToNullString] DOMString title); - [Custom] void profileEnd(in [ConvertUndefinedOrNullToNullString] DOMString title); + [CustomArgumentHandling] void profile(in [ConvertUndefinedOrNullToNullString] DOMString title); + [CustomArgumentHandling] void profileEnd(in [ConvertUndefinedOrNullToNullString] DOMString title); #endif void time(in [ConvertUndefinedOrNullToNullString] DOMString title); diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp index 3eb2b8e..2f0f84f 100644 --- a/WebCore/page/DOMWindow.cpp +++ b/WebCore/page/DOMWindow.cpp @@ -342,8 +342,6 @@ void DOMWindow::parseModalDialogFeatures(const String& featuresArg, HashMap<Stri bool DOMWindow::allowPopUp(Frame* activeFrame) { ASSERT(activeFrame); - if (activeFrame->script()->processingUserGesture()) - return true; Settings* settings = activeFrame->settings(); return settings && settings->javaScriptCanOpenWindowsAutomatically(); } diff --git a/WebCore/page/EventHandler.h b/WebCore/page/EventHandler.h index f267ef5..861dce9 100644 --- a/WebCore/page/EventHandler.h +++ b/WebCore/page/EventHandler.h @@ -33,7 +33,7 @@ #include <wtf/Forward.h> #include <wtf/RefPtr.h> -#if PLATFORM(MAC) && !defined(__OBJC__) && !ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) +#if PLATFORM(MAC) && !defined(__OBJC__) class NSView; #endif @@ -183,7 +183,7 @@ public: void sendResizeEvent(); void sendScrollEvent(); -#if PLATFORM(MAC) && defined(__OBJC__) && !ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) +#if PLATFORM(MAC) && defined(__OBJC__) PassRefPtr<KeyboardEvent> currentKeyboardEvent() const; void mouseDown(NSEvent *); @@ -415,9 +415,11 @@ private: RefPtr<Node> m_previousWheelScrolledNode; -#if PLATFORM(MAC) && !ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) +#if PLATFORM(MAC) +#if !ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) NSView *m_mouseDownView; bool m_sendingEventToSubview; +#endif int m_activationEventNumber; #endif #if ENABLE(TOUCH_EVENTS) diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index b685e59..a3e89b5 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -69,7 +69,7 @@ #include "StorageNamespace.h" #endif -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) #include "JavaScriptDebugServer.h" #endif @@ -191,7 +191,7 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi m_pluginHalter->setPluginAllowedRunTime(m_settings->pluginAllowedRunTime()); } -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) JavaScriptDebugServer::shared().pageCreated(this); #endif @@ -308,7 +308,8 @@ void Page::goBackOrForward(int distance) void Page::goToItem(HistoryItem* item, FrameLoadType type) { // Abort any current load unless we're navigating the current document to a new state object - if (!item->stateObject() || item->documentSequenceNumber() != m_mainFrame->loader()->history()->currentItem()->documentSequenceNumber()) { + HistoryItem* currentItem = m_mainFrame->loader()->history()->currentItem(); + if (!item->stateObject() || !currentItem || item->documentSequenceNumber() != currentItem->documentSequenceNumber()) { // Define what to do with any open database connections. By default we stop them and terminate the database thread. DatabasePolicy databasePolicy = DatabasePolicyStop; diff --git a/WebCore/page/PageGroup.cpp b/WebCore/page/PageGroup.cpp index 0ebbfba..f376d52 100644 --- a/WebCore/page/PageGroup.cpp +++ b/WebCore/page/PageGroup.cpp @@ -51,7 +51,7 @@ static unsigned getUniqueIdentifier() // -------- -static bool shouldTrackVisitedLinks; +static bool shouldTrackVisitedLinks = false; PageGroup::PageGroup(const String& name) : m_name(name) diff --git a/WebCore/page/PrintContext.cpp b/WebCore/page/PrintContext.cpp index 4d3a839..4c902a9 100644 --- a/WebCore/page/PrintContext.cpp +++ b/WebCore/page/PrintContext.cpp @@ -45,6 +45,11 @@ int PrintContext::pageCount() const return m_pageRects.size(); } +const IntRect& PrintContext::pageRect(int pageNumber) const +{ + return m_pageRects[pageNumber]; +} + void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight) { m_pageRects.clear(); @@ -60,11 +65,6 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig return; } - if (userScaleFactor <= 0) { - LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor); - return; - } - float ratio = printRect.height() / printRect.width(); float pageWidth = (float)root->rightLayoutOverflow(); @@ -77,14 +77,31 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig return; } - float currPageHeight = pageHeight / userScaleFactor; + computePageRectsWithPageSize(FloatSize(pageWidth, pageHeight), userScaleFactor); +} + +void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, float userScaleFactor) +{ + RenderView* root = toRenderView(m_frame->document()->renderer()); + + if (!root) { + LOG_ERROR("document to be printed has no renderer"); + return; + } + + if (userScaleFactor <= 0) { + LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor); + return; + } + + float currPageHeight = pageSizeInPixels.height() / userScaleFactor; float docHeight = root->layer()->height(); - float currPageWidth = pageWidth / userScaleFactor; + float currPageWidth = pageSizeInPixels.width() / userScaleFactor; // always return at least one page, since empty files should print a blank page - float printedPagesHeight = 0.0; + float printedPagesHeight = 0; do { - float proposedBottom = std::min(docHeight, printedPagesHeight + pageHeight); + float proposedBottom = std::min(docHeight, printedPagesHeight + pageSizeInPixels.height()); m_frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight); currPageHeight = max(1.0f, proposedBottom - printedPagesHeight); @@ -134,4 +151,40 @@ void PrintContext::end() m_frame->setPrinting(false, 0, 0, true); } +static RenderBoxModelObject* enclosingBoxModelObject(RenderObject* object) +{ + + while (object && !object->isBoxModelObject()) + object = object->parent(); + if (!object) + return 0; + return toRenderBoxModelObject(object); +} + +int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSizeInPixels) +{ + // Make sure the element is not freed during the layout. + RefPtr<Element> elementRef(element); + element->document()->updateLayout(); + + RenderBoxModelObject* box = enclosingBoxModelObject(element->renderer()); + if (!box) + return -1; + + Frame* frame = element->document()->frame(); + FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels); + PrintContext printContext(frame); + printContext.begin(pageRect.width()); + printContext.computePageRectsWithPageSize(pageSizeInPixels, 1); + + int top = box->offsetTop(); + int left = box->offsetLeft(); + for (int pageNumber = 0; pageNumber < printContext.pageCount(); pageNumber++) { + const IntRect& page = printContext.pageRect(pageNumber); + if (page.x() <= left && left < page.right() && page.y() <= top && top < page.bottom()) + return pageNumber; + } + return -1; +} + } diff --git a/WebCore/page/PrintContext.h b/WebCore/page/PrintContext.h index 0b3b303..38b28c4 100644 --- a/WebCore/page/PrintContext.h +++ b/WebCore/page/PrintContext.h @@ -25,8 +25,10 @@ namespace WebCore { +class Element; class Frame; class FloatRect; +class FloatSize; class GraphicsContext; class IntRect; @@ -36,6 +38,8 @@ public: ~PrintContext(); int pageCount() const; + const IntRect& pageRect(int pageNumber) const; + const Vector<IntRect>& pageRects() const { return m_pageRects; } void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight); @@ -47,7 +51,12 @@ public: void end(); + // Used by layout tests. + static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels); + protected: + void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, float userScaleFactor); + Frame* m_frame; Vector<IntRect> m_pageRects; }; diff --git a/WebCore/page/XSSAuditor.cpp b/WebCore/page/XSSAuditor.cpp index 0129b52..b71fa49 100644 --- a/WebCore/page/XSSAuditor.cpp +++ b/WebCore/page/XSSAuditor.cpp @@ -290,14 +290,38 @@ bool XSSAuditor::isSameOriginResource(const String& url) const return (m_frame->document()->url().host() == resourceURL.host() && resourceURL.query().isEmpty()); } +bool XSSAuditor::shouldFullPageBlockForXSSProtectionHeader() const +{ + // If we detect an XSS attack and find the HTTP header "X-XSS-Protection: 12" then + // we will stop loading the page as opposed to ignoring the script. The value "12" + // came from a personal communication, see <https://bugs.webkit.org/show_bug.cgi?id=27312> + // for more details. + DEFINE_STATIC_LOCAL(String, XSSProtectionHeader, ("X-XSS-Protection")); + + Frame* frame = m_frame; + if (frame->document()->url() == blankURL()) + frame = m_frame->tree()->parent(); + + // We strip any whitespace characters to conform to the behavior in Internet Explorer. + String xssProtectionValue = frame->loader()->documentLoader()->response().httpHeaderField(XSSProtectionHeader).stripWhiteSpace(); + return (xssProtectionValue.length() >= 2 && xssProtectionValue[0] == '1' && xssProtectionValue[1] == '2'); +} + bool XSSAuditor::findInRequest(const FindTask& task) const { bool result = false; Frame* parentFrame = m_frame->tree()->parent(); + Frame* blockFrame = parentFrame; if (parentFrame && m_frame->document()->url() == blankURL()) result = findInRequest(parentFrame, task); - if (!result) + if (!result) { result = findInRequest(m_frame, task); + blockFrame = m_frame; + } + if (result && blockFrame && shouldFullPageBlockForXSSProtectionHeader()) { + blockFrame->loader()->stopAllLoaders(); + blockFrame->redirectScheduler()->scheduleLocationChange(blankURL(), String()); + } return result; } diff --git a/WebCore/page/XSSAuditor.h b/WebCore/page/XSSAuditor.h index d976f52..3ad50a1 100644 --- a/WebCore/page/XSSAuditor.h +++ b/WebCore/page/XSSAuditor.h @@ -36,7 +36,7 @@ namespace WebCore { class ScriptSourceCode; // The XSSAuditor class is used to prevent type 1 cross-site scripting - // vulnerabilites (also known as reflected vulnerabilities). + // vulnerabilities (also known as reflected vulnerabilities). // // More specifically, the XSSAuditor class decides whether the execution of // a script is to be allowed or denied based on the content of any @@ -53,7 +53,7 @@ namespace WebCore { // // Bindings // - // An XSSAuditor is instantiated within the contructor of a + // An XSSAuditor is instantiated within the constructor of a // ScriptController object and passed the Frame the script originated. The // ScriptController calls back to the XSSAuditor to determine whether a // JavaScript script is safe to execute before executing it. The following @@ -144,6 +144,8 @@ namespace WebCore { bool findInRequest(const FindTask&) const; bool findInRequest(Frame*, const FindTask&) const; + bool shouldFullPageBlockForXSSProtectionHeader() const; + // The frame to audit. Frame* m_frame; diff --git a/WebCore/page/mac/EventHandlerMac.mm b/WebCore/page/mac/EventHandlerMac.mm index 91a2018..650c0e1 100644 --- a/WebCore/page/mac/EventHandlerMac.mm +++ b/WebCore/page/mac/EventHandlerMac.mm @@ -663,6 +663,11 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const #else // ENABLE(EXPERIMENTAL_SINGLE_VIEW_MODE) +NSEvent *EventHandler::currentNSEvent() +{ + return 0; +} + bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) { subframe->eventHandler()->handleMousePressEvent(mev.event()); @@ -711,6 +716,62 @@ bool EventHandler::eventActivatedView(const PlatformMouseEvent&) const return false; } +PassRefPtr<KeyboardEvent> EventHandler::currentKeyboardEvent() const +{ + return 0; +} + +void EventHandler::mouseDown(NSEvent *) +{ + notImplemented(); +} + +void EventHandler::mouseDragged(NSEvent *) +{ + notImplemented(); +} + +void EventHandler::mouseUp(NSEvent *) +{ + notImplemented(); +} + +void EventHandler::mouseMoved(NSEvent *) +{ + notImplemented(); +} + +bool EventHandler::keyEvent(NSEvent *) +{ + notImplemented(); + return false; +} + +bool EventHandler::wheelEvent(NSEvent *) +{ + notImplemented(); + return false; +} + +#if ENABLE(CONTEXT_MENUS) +bool EventHandler::sendContextMenuEvent(NSEvent *) +{ + notImplemented(); + return false; +} +#endif + +bool EventHandler::eventMayStartDrag(NSEvent *) +{ + notImplemented(); + return false; +} + +void EventHandler::sendFakeEventsAfterWidgetTracking(NSEvent *) +{ +} + + #endif #if ENABLE(DRAG_SUPPORT) diff --git a/WebCore/page/win/FrameWin.cpp b/WebCore/page/win/FrameWin.cpp index 8440a80..2b5435d 100644 --- a/WebCore/page/win/FrameWin.cpp +++ b/WebCore/page/win/FrameWin.cpp @@ -29,64 +29,20 @@ #include "Bridge.h" #include "Document.h" #include "FloatRect.h" +#include "PrintContext.h" #include "RenderView.h" #include "Settings.h" #include "TransformationMatrix.h" -using std::min; - namespace WebCore { -void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& pages, int& outPageHeight) +void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight) { - ASSERT(frame); - - pages.clear(); - outPageHeight = 0; - - if (!frame->document() || !frame->view() || !frame->document()->renderer()) - return; - - RenderView* root = toRenderView(frame->document()->renderer()); - - if (!root) { - LOG_ERROR("document to be printed has no renderer"); - return; - } - - if (userScaleFactor <= 0) { - LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor); - return; - } - - float ratio = static_cast<float>(printRect.height()) / static_cast<float>(printRect.width()); - - float pageWidth = static_cast<float>(root->rightLayoutOverflow()); - float pageHeight = pageWidth * ratio; - outPageHeight = static_cast<int>(pageHeight); // this is the height of the page adjusted by margins - pageHeight -= (headerHeight + footerHeight); - - if (pageHeight <= 0) { - LOG_ERROR("pageHeight has bad value %.2f", pageHeight); - return; - } - - float currPageHeight = pageHeight / userScaleFactor; - float docHeight = root->layer()->height(); - float docWidth = root->layer()->width(); - float currPageWidth = pageWidth / userScaleFactor; - - - // always return at least one page, since empty files should print a blank page - float printedPagesHeight = 0.0f; - do { - float proposedBottom = min(docHeight, printedPagesHeight + pageHeight); - frame->view()->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight); - currPageHeight = max(1.0f, proposedBottom - printedPagesHeight); - - pages.append(IntRect(0, printedPagesHeight, currPageWidth, currPageHeight)); - printedPagesHeight += currPageHeight; - } while (printedPagesHeight < docHeight); + PrintContext printContext(frame); + float pageHeight = 0; + printContext.computePageRects(printRect, headerHeight, footerHeight, userScaleFactor, pageHeight); + outPageHeight = static_cast<int>(pageHeight); + outPages = printContext.pageRects(); } DragImageRef Frame::dragImageForSelection() diff --git a/WebCore/page/win/FrameWin.h b/WebCore/page/win/FrameWin.h index 9cf9683..4c274b7 100644 --- a/WebCore/page/win/FrameWin.h +++ b/WebCore/page/win/FrameWin.h @@ -37,7 +37,7 @@ namespace WebCore { class IntRect; HBITMAP imageFromSelection(Frame* frame, bool forceWhiteText); - void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& pages, int& pageHeight); + void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight); } diff --git a/WebCore/platform/KURL.cpp b/WebCore/platform/KURL.cpp index 9783bd8..79bb6e2 100644 --- a/WebCore/platform/KURL.cpp +++ b/WebCore/platform/KURL.cpp @@ -422,9 +422,9 @@ void KURL::init(const KURL& base, const String& relative, const TextEncoding& en switch (str[0]) { case '\0': - // the reference must be empty - the RFC says this is a - // reference to the same document + // The reference is empty, so this is a reference to the same document with any fragment identifier removed. *this = base; + removeFragmentIdentifier(); break; case '#': { // must be fragment-only reference @@ -1752,6 +1752,12 @@ bool portAllowed(const KURL& url) 3659, // apple-sasl / PasswordServer [Apple addition] 4045, // lockd 6000, // X11 + 6665, // Alternate IRC [Apple addition] + 6666, // Alternate IRC [Apple addition] + 6667, // Standard IRC [Apple addition] + 6668, // Alternate IRC [Apple addition] + 6669, // Alternate IRC [Apple addition] + }; const unsigned short* const blockedPortListEnd = blockedPortList + sizeof(blockedPortList) / sizeof(blockedPortList[0]); diff --git a/WebCore/platform/brew/FileChooserBrew.cpp b/WebCore/platform/brew/FileChooserBrew.cpp new file mode 100644 index 0000000..79755bb --- /dev/null +++ b/WebCore/platform/brew/FileChooserBrew.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2007-2009 Torch Mobile, Inc. + * Copyright (C) 2009 Company 100 Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "FileChooser.h" + +#include "FileSystem.h" +#include "LocalizedStrings.h" +#include "StringTruncator.h" + +namespace WebCore { + +String FileChooser::basenameForWidth(const Font& font, int width) const +{ + if (width <= 0) + return String(); + + String string; + if (m_filenames.isEmpty()) + string = fileButtonNoFileSelectedLabel(); + else if (m_filenames.size() == 1) + string = pathGetFileName(m_filenames[0]); + else + return StringTruncator::rightTruncate(String::number(m_filenames.size()) + " files", width, font, false); + + return StringTruncator::centerTruncate(string, width, font, false); +} + +} diff --git a/WebCore/platform/brew/LocalizedStringsBrew.cpp b/WebCore/platform/brew/LocalizedStringsBrew.cpp new file mode 100644 index 0000000..4588f0f --- /dev/null +++ b/WebCore/platform/brew/LocalizedStringsBrew.cpp @@ -0,0 +1,397 @@ +/* + * Copyright (C) 2009 Company 100, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "LocalizedStrings.h" + +#include "NotImplemented.h" +#include "PlatformString.h" + +namespace WebCore { + +String submitButtonDefaultLabel() +{ + return "Submit"; +} + +String inputElementAltText() +{ + return String(); +} + +String resetButtonDefaultLabel() +{ + return "Reset"; +} + +String defaultLanguage() +{ + return "en"; +} + +String searchableIndexIntroduction() +{ + return "Searchable Index"; +} + +String fileButtonChooseFileLabel() +{ + return "Choose File"; +} + +String fileButtonNoFileSelectedLabel() +{ + return "No file selected"; +} + +String contextMenuItemTagOpenLinkInNewWindow() +{ + return "Open in new tab"; +} + +String contextMenuItemTagDownloadLinkToDisk() +{ + return "Download link to disk"; +} + +String contextMenuItemTagCopyLinkToClipboard() +{ + return "Copy link to clipboard"; +} + +String contextMenuItemTagOpenImageInNewWindow() +{ + return "Open image in new window"; +} + +String contextMenuItemTagDownloadImageToDisk() +{ + return "Download image to disk"; +} + +String contextMenuItemTagCopyImageToClipboard() +{ + return "Copy image to clipboard"; +} + +String contextMenuItemTagOpenFrameInNewWindow() +{ + return "Open frame in new window"; +} + +String contextMenuItemTagCopy() +{ + return "Copy"; +} + +String contextMenuItemTagGoBack() +{ + return "Go back"; +} + +String contextMenuItemTagGoForward() +{ + return "Go forward"; +} + +String contextMenuItemTagStop() +{ + return "Stop"; +} + +String contextMenuItemTagReload() +{ + return "Reload"; +} + +String contextMenuItemTagCut() +{ + return "Cut"; +} + +String contextMenuItemTagPaste() +{ + return "Paste"; +} + +String contextMenuItemTagNoGuessesFound() +{ + return "No guesses found"; +} + +String contextMenuItemTagIgnoreSpelling() +{ + return "Ignore spelling"; +} + +String contextMenuItemTagLearnSpelling() +{ + return "Learn spelling"; +} + +String contextMenuItemTagSearchWeb() +{ + return "Search web"; +} + +String contextMenuItemTagLookUpInDictionary() +{ + return "Lookup in dictionary"; +} + +String contextMenuItemTagOpenLink() +{ + return "Open link"; +} + +String contextMenuItemTagIgnoreGrammar() +{ + return "Ignore grammar"; +} + +String contextMenuItemTagSpellingMenu() +{ + return "Spelling menu"; +} + +String contextMenuItemTagShowSpellingPanel(bool show) +{ + return "Show spelling panel"; +} + +String contextMenuItemTagCheckSpelling() +{ + return "Check spelling"; +} + +String contextMenuItemTagCheckSpellingWhileTyping() +{ + return "Check spelling while typing"; +} + +String contextMenuItemTagCheckGrammarWithSpelling() +{ + return "Check for grammar with spelling"; +} + +String contextMenuItemTagFontMenu() +{ + return "Font menu"; +} + +String contextMenuItemTagBold() +{ + return "Bold"; +} + +String contextMenuItemTagItalic() +{ + return "Italic"; +} + +String contextMenuItemTagUnderline() +{ + return "Underline"; +} + +String contextMenuItemTagOutline() +{ + return "Outline"; +} + +String contextMenuItemTagWritingDirectionMenu() +{ + return "Writing direction menu"; +} + +String contextMenuItemTagDefaultDirection() +{ + return "Default direction"; +} + +String contextMenuItemTagLeftToRight() +{ + return "Left to right"; +} + +String contextMenuItemTagRightToLeft() +{ + return "Right to left"; +} + +String contextMenuItemTagInspectElement() +{ + return "Inspect"; +} + +String searchMenuNoRecentSearchesText() +{ + return "No recent text searches"; +} + +String searchMenuRecentSearchesText() +{ + return "Recent text searches"; +} + +String searchMenuClearRecentSearchesText() +{ + return "Clear recent text searches"; +} + +String unknownFileSizeText() +{ + return "Unknown"; +} + +String AXWebAreaText() +{ + return String(); +} + +String AXLinkText() +{ + return String(); +} + +String AXListMarkerText() +{ + return String(); +} + +String AXImageMapText() +{ + return String(); +} + +String AXHeadingText() +{ + return String(); +} + +String imageTitle(const String& filename, const IntSize& size) +{ + return String(filename); +} + +String contextMenuItemTagTextDirectionMenu() +{ + return String(); +} + +String AXButtonActionVerb() +{ + return String(); +} + +String AXTextFieldActionVerb() +{ + return String(); +} + +String AXRadioButtonActionVerb() +{ + return String(); +} + +String AXCheckedCheckBoxActionVerb() +{ + return String(); +} + +String AXUncheckedCheckBoxActionVerb() +{ + return String(); +} + +String AXLinkActionVerb() +{ + return String(); +} + +String AXMenuListPopupActionVerb() +{ + return String(); +} + +String AXMenuListActionVerb() +{ + return String(); +} + +String AXDefinitionListTermText() +{ + return String(); +} + +String AXDefinitionListDefinitionText() +{ + return String(); +} + +String validationMessageValueMissingText() +{ + notImplemented(); + return String(); +} + +String validationMessageTypeMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessagePatternMismatchText() +{ + notImplemented(); + return String(); +} + +String validationMessageTooLongText() +{ + notImplemented(); + return String(); +} + +String validationMessageRangeUnderflowText() +{ + notImplemented(); + return String(); +} + +String validationMessageRangeOverflowText() +{ + notImplemented(); + return String(); +} + +String validationMessageStepMismatchText() +{ + notImplemented(); + return String(); +} + +} // namespace WebCore + diff --git a/WebCore/platform/brew/LoggingBrew.cpp b/WebCore/platform/brew/LoggingBrew.cpp new file mode 100644 index 0000000..e8f79f7 --- /dev/null +++ b/WebCore/platform/brew/LoggingBrew.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Logging.h" + +namespace WebCore { + +void InitializeLoggingChannelsIfNecessary() +{ + // FIXME: Should read the logging channels from a file. + static bool haveInitializedLoggingChannels = false; + if (haveInitializedLoggingChannels) + return; + + haveInitializedLoggingChannels = true; + + // By default we log calls to notImplemented(). + LogNotYetImplemented.state = WTFLogChannelOn; +} + +} // namespace WebCore + diff --git a/WebCore/platform/brew/MIMETypeRegistryBrew.cpp b/WebCore/platform/brew/MIMETypeRegistryBrew.cpp new file mode 100644 index 0000000..d194116 --- /dev/null +++ b/WebCore/platform/brew/MIMETypeRegistryBrew.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2006 Zack Rusin <zack@kde.org> + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2007 Trolltech ASA + * Copyright (C) 2009 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "MIMETypeRegistry.h" + +#include "PlatformString.h" + +namespace WebCore { + +struct ExtensionMap { + const char* extension; + const char* mimeType; +}; + +static const ExtensionMap extensionMap[] = { + { "bmp", "image/bmp" }, + { "css", "text/css" }, + { "gif", "image/gif" }, + { "html", "text/html" }, + { "htm", "text/html" }, + { "ico", "image/x-icon" }, + { "jpeg", "image/jpeg" }, + { "jpg", "image/jpeg" }, + { "js", "application/x-javascript" }, + { "pdf", "application/pdf" }, + { "png", "image/png" }, + { "rss", "application/rss+xml" }, + { "svg", "image/svg+xml" }, + { "text", "text/plain" }, + { "txt", "text/plain" }, + { "xbm", "image/x-xbitmap" }, + { "xml", "text/xml" }, + { "xsl", "text/xsl" }, + { "xhtml", "application/xhtml+xml" }, + { 0, 0 } +}; + +String MIMETypeRegistry::getMIMETypeForExtension(const String &ext) +{ + String str = ext.lower(); + + const ExtensionMap* e = extensionMap; + while (e->extension) { + if (str == e->extension) + return e->mimeType; + ++e; + } + + // unknown, let's just assume plain text + return "text/plain"; +} + +} // namespace WebCore + diff --git a/WebCore/platform/brew/ScreenBrew.cpp b/WebCore/platform/brew/ScreenBrew.cpp new file mode 100644 index 0000000..b141b34 --- /dev/null +++ b/WebCore/platform/brew/ScreenBrew.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2009 Company 100, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Screen.h" + +#include "FloatRect.h" +#include "Frame.h" +#include "FrameView.h" +#include "IntRect.h" +#include "NotImplemented.h" +#include "Page.h" +#include "Widget.h" + +#include <AEEAppGen.h> +#include <AEEStdLib.h> + +namespace WebCore { + +struct DisplayInfo { + int width; + int height; + int depth; +}; + +static void getDisplayInfo(DisplayInfo& info) +{ + IDisplay* display = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIDisplay; + IBitmap* bitmap = IDisplay_GetDestination(display); + ASSERT(bitmap); + + AEEBitmapInfo bitmapInfo; + IBitmap_GetInfo(bitmap, &bitmapInfo, sizeof(AEEBitmapInfo)); + + info.width = bitmapInfo.cx; + info.height = bitmapInfo.cy; + info.depth = bitmapInfo.nDepth; + + IBitmap_Release(bitmap); +} + +FloatRect screenRect(Widget*) +{ + DisplayInfo info; + getDisplayInfo(info); + + return FloatRect(0, 0, info.width, info.height); +} + +FloatRect screenAvailableRect(Widget* widget) +{ + return screenRect(widget); +} + +int screenDepth(Widget*) +{ + DisplayInfo info; + getDisplayInfo(info); + + return info.depth; +} + +int screenDepthPerComponent(Widget* widget) +{ + return screenDepth(widget); +} + +bool screenIsMonochrome(Widget*) +{ + return false; +} + +} // namespace WebCore + diff --git a/WebCore/platform/brew/SharedTimerBrew.cpp b/WebCore/platform/brew/SharedTimerBrew.cpp new file mode 100644 index 0000000..d20fe48 --- /dev/null +++ b/WebCore/platform/brew/SharedTimerBrew.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2009 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SharedTimer.h" + +#include <AEEAppGen.h> +#include <AEEStdLib.h> + +#include <wtf/CurrentTime.h> + +namespace WebCore { + +static void (*sharedTimerFiredFunction)(); + +static AEECallback sharedTimerCallback; + +static void invokeCallback(void*) +{ + sharedTimerFiredFunction(); +} + +void setSharedTimerFiredFunction(void (*f)()) +{ + sharedTimerFiredFunction = f; +} + +void setSharedTimerFireTime(double fireTime) +{ + ASSERT(sharedTimerFiredFunction); + + CALLBACK_Cancel(&sharedTimerCallback); + + double interval = fireTime - currentTime(); + int intervalInMS; + + if (interval < 0) + intervalInMS = 0; + else { + interval *= 1000; + intervalInMS = static_cast<int>(interval); + } + + sharedTimerCallback.pfnCancel = 0; + sharedTimerCallback.pfnNotify = invokeCallback; + sharedTimerCallback.pNotifyData = 0; + + IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; + ISHELL_SetTimerEx(shell, intervalInMS, &sharedTimerCallback); +} + +void stopSharedTimer() +{ + CALLBACK_Cancel(&sharedTimerCallback); +} + +} diff --git a/WebCore/platform/brew/SoundBrew.cpp b/WebCore/platform/brew/SoundBrew.cpp new file mode 100644 index 0000000..a616943 --- /dev/null +++ b/WebCore/platform/brew/SoundBrew.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 Company 100, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "Sound.h" + +#include <AEEAppGen.h> +#include <AEEStdLib.h> + +namespace WebCore { + +void systemBeep() +{ + // systemBeep is used by Editor to notify errors when a user cuts or pastes + // where these operations are not permitted. + // Use BEEP_ERROR with loud volume. + IShell* shell = reinterpret_cast<AEEApplet*>(GETAPPINSTANCE())->m_pIShell; + ISHELL_Beep(shell, BEEP_ERROR, TRUE); +} + +} // namespace WebCore + diff --git a/WebCore/platform/chromium/ThemeChromiumMac.mm b/WebCore/platform/chromium/ThemeChromiumMac.mm index 3c97428..1c14207 100644 --- a/WebCore/platform/chromium/ThemeChromiumMac.mm +++ b/WebCore/platform/chromium/ThemeChromiumMac.mm @@ -21,7 +21,7 @@ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #import "config.h" @@ -115,19 +115,19 @@ static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& mi static void updateStates(NSCell* cell, ControlStates states) { // Hover state is not supported by Aqua. - + // Pressed state bool oldPressed = [cell isHighlighted]; bool pressed = states & PressedState; if (pressed != oldPressed) [cell setHighlighted:pressed]; - + // Enabled state bool oldEnabled = [cell isEnabled]; bool enabled = states & EnabledState; if (enabled != oldEnabled) [cell setEnabled:enabled]; - + // Focused state bool oldFocused = [cell showsFirstResponder]; bool focused = states & FocusState; @@ -141,7 +141,7 @@ static void updateStates(NSCell* cell, ControlStates states) bool oldChecked = [cell state] == NSOnState; if (oldIndeterminate != indeterminate || checked != oldChecked) [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSOffState)]; - + // Window Inactive state NSControlTint oldTint = [cell controlTint]; bool windowInactive = (states & WindowInactiveState); @@ -197,9 +197,9 @@ static LengthSize checkboxSize(const Font& font, const LengthSize& zoomedSize, f return sizeFromFont(font, zoomedSize, zoomFactor, checkboxSizes()); } -static NSButtonCell* checkbox(ControlStates states, const IntRect& zoomedRect, float zoomFactor) +static NSButtonCell *checkbox(ControlStates states, const IntRect& zoomedRect, float zoomFactor) { - static NSButtonCell* checkboxCell; + static NSButtonCell *checkboxCell; if (!checkboxCell) { checkboxCell = [[NSButtonCell alloc] init]; [checkboxCell setButtonType:NSSwitchButton]; @@ -207,13 +207,13 @@ static NSButtonCell* checkbox(ControlStates states, const IntRect& zoomedRect, f [checkboxCell setAllowsMixedState:YES]; [checkboxCell setFocusRingType:NSFocusRingTypeExterior]; } - + // Set the control size based off the rectangle we're painting into. setControlSize(checkboxCell, checkboxSizes(), zoomedRect.size(), zoomFactor); // Update the various states we respond to. updateStates(checkboxCell, states); - + return checkboxCell; } @@ -223,7 +223,7 @@ static void paintCheckbox(ControlStates states, GraphicsContext* context, const BEGIN_BLOCK_OBJC_EXCEPTIONS // Determine the width and height needed for the control and prepare the cell for painting. - NSButtonCell* checkboxCell = checkbox(states, zoomedRect, zoomFactor); + NSButtonCell *checkboxCell = checkbox(states, zoomedRect, zoomFactor); context->save(); @@ -232,7 +232,7 @@ static void paintCheckbox(ControlStates states, GraphicsContext* context, const zoomedSize.setWidth(zoomedSize.width() * zoomFactor); zoomedSize.setHeight(zoomedSize.height() * zoomFactor); IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, checkboxMargins(controlSize), zoomFactor); - + if (zoomFactor != 1.0f) { inflatedRect.setWidth(inflatedRect.width() / zoomFactor); inflatedRect.setHeight(inflatedRect.height() / zoomFactor); @@ -240,12 +240,12 @@ static void paintCheckbox(ControlStates states, GraphicsContext* context, const context->scale(FloatSize(zoomFactor, zoomFactor)); context->translate(-inflatedRect.x(), -inflatedRect.y()); } - + [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:FlippedView()]; [checkboxCell setControlView:nil]; context->restore(); - + END_BLOCK_OBJC_EXCEPTIONS } @@ -278,29 +278,29 @@ static LengthSize radioSize(const Font& font, const LengthSize& zoomedSize, floa return sizeFromFont(font, zoomedSize, zoomFactor, radioSizes()); } -static NSButtonCell* radio(ControlStates states, const IntRect& zoomedRect, float zoomFactor) +static NSButtonCell *radio(ControlStates states, const IntRect& zoomedRect, float zoomFactor) { - static NSButtonCell* radioCell; + static NSButtonCell *radioCell; if (!radioCell) { radioCell = [[NSButtonCell alloc] init]; [radioCell setButtonType:NSRadioButton]; [radioCell setTitle:nil]; [radioCell setFocusRingType:NSFocusRingTypeExterior]; } - + // Set the control size based off the rectangle we're painting into. setControlSize(radioCell, radioSizes(), zoomedRect.size(), zoomFactor); // Update the various states we respond to. updateStates(radioCell, states); - + return radioCell; } static void paintRadio(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView) { // Determine the width and height needed for the control and prepare the cell for painting. - NSButtonCell* radioCell = radio(states, zoomedRect, zoomFactor); + NSButtonCell *radioCell = radio(states, zoomedRect, zoomFactor); context->save(); @@ -309,7 +309,7 @@ static void paintRadio(ControlStates states, GraphicsContext* context, const Int zoomedSize.setWidth(zoomedSize.width() * zoomFactor); zoomedSize.setHeight(zoomedSize.height() * zoomFactor); IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, radioMargins(controlSize), zoomFactor); - + if (zoomFactor != 1.0f) { inflatedRect.setWidth(inflatedRect.width() / zoomFactor); inflatedRect.setHeight(inflatedRect.height() / zoomFactor); @@ -317,7 +317,7 @@ static void paintRadio(ControlStates states, GraphicsContext* context, const Int context->scale(FloatSize(zoomFactor, zoomFactor)); context->translate(-inflatedRect.x(), -inflatedRect.y()); } - + BEGIN_BLOCK_OBJC_EXCEPTIONS [radioCell drawWithFrame:NSRect(inflatedRect) inView:FlippedView()]; [radioCell setControlView:nil]; @@ -335,6 +335,14 @@ static const IntSize* buttonSizes() return sizes; } +#if ENABLE(DATALIST) +static const IntSize* listButtonSizes() +{ + static const IntSize sizes[3] = { IntSize(21, 21), IntSize(19, 18), IntSize(17, 16) }; + return sizes; +} +#endif + static const int* buttonMargins(NSControlSize controlSize) { static const int margins[3][4] = @@ -346,17 +354,24 @@ static const int* buttonMargins(NSControlSize controlSize) return margins[controlSize]; } -static NSButtonCell* button(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor) +static void setupButtonCell(NSButtonCell *&buttonCell, ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor) { - static NSButtonCell *buttonCell; - static bool defaultButton; if (!buttonCell) { buttonCell = [[NSButtonCell alloc] init]; [buttonCell setTitle:nil]; [buttonCell setButtonType:NSMomentaryPushInButton]; + if (states & DefaultState) + [buttonCell setKeyEquivalent:@"\r"]; } // Set the control size based off the rectangle we're painting into. + const IntSize* sizes = buttonSizes(); +#if ENABLE(DATALIST) + if (part == ListButtonPart) { + [buttonCell setBezelStyle:NSRoundedDisclosureBezelStyle]; + sizes = listButtonSizes(); + } else +#endif if (part == SquareButtonPart || zoomedRect.height() > buttonSizes()[NSRegularControlSize].height() * zoomFactor) { // Use the square button if ([buttonCell bezelStyle] != NSShadowlessSquareBezelStyle) @@ -364,29 +379,34 @@ static NSButtonCell* button(ControlPart part, ControlStates states, const IntRec } else if ([buttonCell bezelStyle] != NSRoundedBezelStyle) [buttonCell setBezelStyle:NSRoundedBezelStyle]; - setControlSize(buttonCell, buttonSizes(), zoomedRect.size(), zoomFactor); - - if (defaultButton != (states & DefaultState)) { - defaultButton = !defaultButton; - [buttonCell setKeyEquivalent:(defaultButton ? @"\r" : @"")]; - } + setControlSize(buttonCell, sizes, zoomedRect.size(), zoomFactor); // Update the various states we respond to. updateStates(buttonCell, states); - - return buttonCell; +} + +static NSButtonCell *button(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor) +{ + bool isDefault = states & DefaultState; + static NSButtonCell *cells[2]; + setupButtonCell(cells[isDefault], part, states, zoomedRect, zoomFactor); + return cells[isDefault]; } static void paintButton(ControlPart part, ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView) { BEGIN_BLOCK_OBJC_EXCEPTIONS - + // Determine the width and height needed for the control and prepare the cell for painting. NSButtonCell *buttonCell = button(part, states, zoomedRect, zoomFactor); LocalCurrentGraphicsContext localContext(context); NSControlSize controlSize = [buttonCell controlSize]; +#if ENABLE(DATALIST) + IntSize zoomedSize = (part == ListButtonPart ? listButtonSizes() : buttonSizes())[controlSize]; +#else IntSize zoomedSize = buttonSizes()[controlSize]; +#endif zoomedSize.setWidth(zoomedRect.width()); // Buttons don't ever constrain width, so the zoomed width can just be honored. zoomedSize.setHeight(zoomedSize.height() * zoomFactor); IntRect inflatedRect = zoomedRect; @@ -407,7 +427,7 @@ static void paintButton(ControlPart part, ControlStates states, GraphicsContext* context->scale(FloatSize(zoomFactor, zoomFactor)); context->translate(-inflatedRect.x(), -inflatedRect.y()); } - } + } [buttonCell drawWithFrame:NSRect(inflatedRect) inView:FlippedView()]; [buttonCell setControlView:nil]; @@ -453,6 +473,10 @@ LengthSize ThemeChromiumMac::controlSize(ControlPart part, const Font& font, con case PushButtonPart: // Height is reset to auto so that specified heights can be ignored. return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, buttonSizes()); +#if ENABLE(DATALIST) + case ListButtonPart: + return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, listButtonSizes()); +#endif default: return zoomedSize; } @@ -464,6 +488,7 @@ LengthSize ThemeChromiumMac::minimumControlSize(ControlPart part, const Font& fo case SquareButtonPart: case DefaultButtonPart: case ButtonPart: + case ListButtonPart: return LengthSize(Length(0, Fixed), Length(static_cast<int>(15 * zoomFactor), Fixed)); default: return Theme::minimumControlSize(part, font, zoomFactor); @@ -476,6 +501,7 @@ LengthBox ThemeChromiumMac::controlBorder(ControlPart part, const Font& font, co case SquareButtonPart: case DefaultButtonPart: case ButtonPart: + case ListButtonPart: return LengthBox(0, zoomedBox.right().value(), 0, zoomedBox.left().value()); default: return Theme::controlBorder(part, font, zoomedBox, zoomFactor); @@ -559,6 +585,7 @@ void ThemeChromiumMac::paint(ControlPart part, ControlStates states, GraphicsCon case DefaultButtonPart: case ButtonPart: case SquareButtonPart: + case ListButtonPart: paintButton(part, states, context, zoomedRect, zoomFactor, scrollView); break; default: diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h index 063c490..5199d93 100644 --- a/WebCore/platform/graphics/GraphicsContext.h +++ b/WebCore/platform/graphics/GraphicsContext.h @@ -119,6 +119,7 @@ namespace WebCore { const int cMisspellingLinePatternWidth = 4; const int cMisspellingLinePatternGapWidth = 1; + class AffineTransform; class Font; class Generator; class Gradient; @@ -339,7 +340,9 @@ namespace WebCore { void setURLForRect(const KURL&, const IntRect&); void concatCTM(const TransformationMatrix&); + void concatCTM(const AffineTransform&); TransformationMatrix getCTM() const; + AffineTransform getAffineCTM() const; #if OS(WINCE) && !PLATFORM(QT) void setBitmap(PassRefPtr<SharedBitmap>); diff --git a/WebCore/platform/graphics/IntPoint.h b/WebCore/platform/graphics/IntPoint.h index ab5f3ec..5137485 100644 --- a/WebCore/platform/graphics/IntPoint.h +++ b/WebCore/platform/graphics/IntPoint.h @@ -63,6 +63,10 @@ class BPoint; class wxPoint; #endif +#if PLATFORM(BREWMP) +typedef struct _point AEEPoint; +#endif + #if PLATFORM(SKIA) struct SkPoint; struct SkIPoint; @@ -133,6 +137,11 @@ public: operator wxPoint() const; #endif +#if PLATFORM(BREWMP) + IntPoint(const AEEPoint&); + operator AEEPoint() const; +#endif + #if PLATFORM(SKIA) IntPoint(const SkIPoint&); operator SkIPoint() const; diff --git a/WebCore/platform/graphics/IntSize.h b/WebCore/platform/graphics/IntSize.h index 13d9e22..6938afd 100644 --- a/WebCore/platform/graphics/IntSize.h +++ b/WebCore/platform/graphics/IntSize.h @@ -55,6 +55,10 @@ class BSize; class wxSize; #endif +#if PLATFORM(BREWMP) +typedef struct AEESize AEESize; +#endif + namespace WebCore { class IntSize { @@ -130,6 +134,11 @@ public: operator wxSize() const; #endif +#if PLATFORM(BREWMP) + IntSize(const AEESize&); + operator AEESize() const; +#endif + private: int m_width, m_height; }; diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp index aed9c95..2b09885 100644 --- a/WebCore/platform/graphics/MediaPlayer.cpp +++ b/WebCore/platform/graphics/MediaPlayer.cpp @@ -89,6 +89,9 @@ public: virtual void setVolume(float) { } + virtual bool supportsMuting() const { return false; } + virtual void setMuted(bool) { } + virtual bool hasClosedCaptions() const { return false; } virtual void setClosedCaptionsVisible(bool) { }; @@ -195,6 +198,7 @@ MediaPlayer::MediaPlayer(MediaPlayerClient* client) , m_visible(false) , m_rate(1.0f) , m_volume(1.0f) + , m_muted(false) , m_preservesPitch(true) , m_autobuffer(false) #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) @@ -381,6 +385,22 @@ void MediaPlayer::setVolume(float volume) m_private->setVolume(volume); } +bool MediaPlayer::muted() const +{ + return m_muted; +} + +bool MediaPlayer::supportsMuting() const +{ + return m_private->supportsMuting(); +} + +void MediaPlayer::setMuted(bool muted) +{ + m_muted = muted; + m_private->setMuted(muted); +} + bool MediaPlayer::hasClosedCaptions() const { return m_private->hasClosedCaptions(); @@ -544,12 +564,20 @@ void MediaPlayer::readyStateChanged() m_mediaPlayerClient->mediaPlayerReadyStateChanged(this); } -void MediaPlayer::volumeChanged() +void MediaPlayer::volumeChanged(float newVolume) { + m_volume = newVolume; if (m_mediaPlayerClient) m_mediaPlayerClient->mediaPlayerVolumeChanged(this); } +void MediaPlayer::muteChanged(bool newMuted) +{ + m_muted = newMuted; + if (m_mediaPlayerClient) + m_mediaPlayerClient->mediaPlayerMuteChanged(this); +} + void MediaPlayer::timeChanged() { if (m_mediaPlayerClient) diff --git a/WebCore/platform/graphics/MediaPlayer.h b/WebCore/platform/graphics/MediaPlayer.h index fa85cfd..40ed8ae 100644 --- a/WebCore/platform/graphics/MediaPlayer.h +++ b/WebCore/platform/graphics/MediaPlayer.h @@ -81,9 +81,12 @@ public: // the ready state has changed virtual void mediaPlayerReadyStateChanged(MediaPlayer*) { } - // the volume or muted state has changed + // the volume state has changed virtual void mediaPlayerVolumeChanged(MediaPlayer*) { } + // the mute state has changed + virtual void mediaPlayerMuteChanged(MediaPlayer*) { } + // time has jumped, eg. not as a result of normal playback virtual void mediaPlayerTimeChanged(MediaPlayer*) { } @@ -177,6 +180,10 @@ public: float volume() const; void setVolume(float); + bool supportsMuting() const; + bool muted() const; + void setMuted(bool); + bool hasClosedCaptions() const; void setClosedCaptionsVisible(bool closedCaptionsVisible); @@ -197,7 +204,8 @@ public: void networkStateChanged(); void readyStateChanged(); - void volumeChanged(); + void volumeChanged(float); + void muteChanged(bool); void timeChanged(); void sizeChanged(); void rateChanged(); @@ -239,6 +247,7 @@ private: bool m_visible; float m_rate; float m_volume; + bool m_muted; bool m_preservesPitch; bool m_autobuffer; #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) diff --git a/WebCore/platform/graphics/MediaPlayerPrivate.h b/WebCore/platform/graphics/MediaPlayerPrivate.h index 6cf12ba..3b7c4d4 100644 --- a/WebCore/platform/graphics/MediaPlayerPrivate.h +++ b/WebCore/platform/graphics/MediaPlayerPrivate.h @@ -74,6 +74,9 @@ public: virtual void setVolume(float) = 0; + virtual bool supportsMuting() const { return false; } + virtual void setMuted(bool) { } + virtual bool hasClosedCaptions() const { return false; } virtual void setClosedCaptionsVisible(bool) { } diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h index 79d6cc4..aad6f3e 100644 --- a/WebCore/platform/graphics/Path.h +++ b/WebCore/platform/graphics/Path.h @@ -67,6 +67,7 @@ typedef PlatformPath* PlatformPathPtr; namespace WebCore { + class AffineTransform; class FloatPoint; class FloatRect; class FloatSize; @@ -145,6 +146,7 @@ namespace WebCore { static Path createLine(const FloatPoint&, const FloatPoint&); void apply(void* info, PathApplierFunction) const; + void transform(const AffineTransform&); void transform(const TransformationMatrix&); private: diff --git a/WebCore/platform/graphics/Pattern.cpp b/WebCore/platform/graphics/Pattern.cpp index d388bd7..3409d16 100644 --- a/WebCore/platform/graphics/Pattern.cpp +++ b/WebCore/platform/graphics/Pattern.cpp @@ -35,12 +35,32 @@ Pattern::Pattern(Image* image, bool repeatX, bool repeatY) : m_tileImage(image) , m_repeatX(repeatX) , m_repeatY(repeatY) +#if PLATFORM(SKIA) + , m_pattern(0) +#endif { ASSERT(image); } Pattern::~Pattern() { + platformDestroy(); } +void Pattern::setPatternSpaceTransform(const TransformationMatrix& patternSpaceTransformation) +{ + m_patternSpaceTransformation = patternSpaceTransformation; + setPlatformPatternSpaceTransform(); +} + +#if !PLATFORM(SKIA) +void Pattern::platformDestroy() +{ +} + +void Pattern::setPlatformPatternSpaceTransform() +{ +} +#endif + } diff --git a/WebCore/platform/graphics/Pattern.h b/WebCore/platform/graphics/Pattern.h index f7f612a..b0188b9 100644 --- a/WebCore/platform/graphics/Pattern.h +++ b/WebCore/platform/graphics/Pattern.h @@ -74,9 +74,16 @@ namespace WebCore { Image* tileImage() const { return m_tileImage.get(); } + void platformDestroy(); + // Pattern space is an abstract space that maps to the default user space by the transformation 'userSpaceTransformation' +#if PLATFORM(SKIA) + PlatformPatternPtr platformPattern(const TransformationMatrix& userSpaceTransformation); +#else PlatformPatternPtr createPlatformPattern(const TransformationMatrix& userSpaceTransformation) const; - void setPatternSpaceTransform(const TransformationMatrix& patternSpaceTransformation) { m_patternSpaceTransformation = patternSpaceTransformation; } +#endif + void setPatternSpaceTransform(const TransformationMatrix& patternSpaceTransformation); + void setPlatformPatternSpaceTransform(); private: Pattern(Image*, bool repeatX, bool repeatY); @@ -85,6 +92,7 @@ namespace WebCore { bool m_repeatX; bool m_repeatY; TransformationMatrix m_patternSpaceTransformation; + PlatformPatternPtr m_pattern; }; } //namespace diff --git a/WebCore/platform/graphics/brew/IntPointBrew.cpp b/WebCore/platform/graphics/brew/IntPointBrew.cpp new file mode 100644 index 0000000..8792b1d --- /dev/null +++ b/WebCore/platform/graphics/brew/IntPointBrew.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Company 100, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IntPoint.h" + +#include <AEEPoint.h> + +namespace WebCore { + +IntPoint::IntPoint(const AEEPoint& point) + : m_x(point.x) + , m_y(point.y) +{ +} + +IntPoint::operator AEEPoint() const +{ + AEEPoint point; + point.x = static_cast<int16>(m_x); + point.y = static_cast<int16>(m_y); + return point; +} + +} // namespace WebCore + diff --git a/WebCore/platform/graphics/brew/IntSizeBrew.cpp b/WebCore/platform/graphics/brew/IntSizeBrew.cpp new file mode 100644 index 0000000..01c3365 --- /dev/null +++ b/WebCore/platform/graphics/brew/IntSizeBrew.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2009 Company 100, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "IntSize.h" + +#include <AEE.h> + +namespace WebCore { + +IntSize::IntSize(const AEESize& size) + : m_width(size.cx) + , m_height(size.cy) +{ +} + +IntSize::operator AEESize() const +{ + AEESize size; + size.cx = width(); + size.cy = height(); + return size; +} + +} // namespace WebCore + diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp index d866b6c..ccbbf3b 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp +++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp @@ -32,6 +32,7 @@ #if PLATFORM(CAIRO) +#include "AffineTransform.h" #include "CairoPath.h" #include "FEGaussianBlur.h" #include "FloatRect.h" @@ -216,6 +217,14 @@ TransformationMatrix GraphicsContext::getCTM() const return TransformationMatrix(m.xx, m.yx, m.xy, m.yy, m.x0, m.y0); } +AffineTransform GraphicsContext::getAffineCTM() const +{ + cairo_t* cr = platformContext(); + cairo_matrix_t m; + cairo_get_matrix(cr, &m); + return AffineTransform(m.xx, m.yx, m.xy, m.yy, m.x0, m.y0); +} + cairo_t* GraphicsContext::platformContext() const { return m_data->cr; @@ -802,6 +811,17 @@ void GraphicsContext::concatCTM(const TransformationMatrix& transform) m_data->concatCTM(transform); } +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + if (paintingDisabled()) + return; + + cairo_t* cr = m_data->cr; + const cairo_matrix_t matrix = cairo_matrix_t(transform); + cairo_transform(cr, &matrix); + m_data->concatCTM(transform); +} + void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h index cedc684..5e38832 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h +++ b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h @@ -71,6 +71,7 @@ public: void scale(const FloatSize&); void rotate(float); void translate(float, float); + void concatCTM(const AffineTransform&); void concatCTM(const TransformationMatrix&); void beginTransparencyLayer() { m_transparencyCount++; } void endTransparencyLayer() { m_transparencyCount--; } @@ -85,6 +86,7 @@ public: void scale(const FloatSize&) {} void rotate(float) {} void translate(float, float) {} + void concatCTM(const AffineTransform&) {} void concatCTM(const TransformationMatrix&) {} void beginTransparencyLayer() {} void endTransparencyLayer() {} diff --git a/WebCore/platform/graphics/cairo/PathCairo.cpp b/WebCore/platform/graphics/cairo/PathCairo.cpp index 8bde57e..a265937 100644 --- a/WebCore/platform/graphics/cairo/PathCairo.cpp +++ b/WebCore/platform/graphics/cairo/PathCairo.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "Path.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "CairoPath.h" #include "FloatRect.h" @@ -326,6 +327,14 @@ void Path::apply(void* info, PathApplierFunction function) const cairo_path_destroy(path); } +void Path::transform(const AffineTransform& trans) +{ + cairo_t* m_cr = platformPath()->m_cr; + cairo_matrix_t c_matrix = cairo_matrix_t(trans); + cairo_matrix_invert(&c_matrix); + cairo_transform(m_cr, &c_matrix); +} + void Path::transform(const TransformationMatrix& trans) { cairo_t* m_cr = platformPath()->m_cr; diff --git a/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp b/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp index 1b83a29..c73dd02 100644 --- a/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp +++ b/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp @@ -23,6 +23,7 @@ */ #include "config.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "IntRect.h" @@ -46,6 +47,20 @@ TransformationMatrix::operator cairo_matrix_t() const return m; } +AffineTransform::operator cairo_matrix_t() const +{ + cairo_matrix_t m; + + cairo_matrix_init (&m, + a(), + b(), + c(), + d(), + e(), + f()); + return m; +} + } // vim: ts=4 sw=4 et diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index b11ba66..a339982 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "GraphicsContext.h" +#include "AffineTransform.h" #include "FloatConversion.h" #include "GraphicsContextPlatformPrivateCG.h" #include "GraphicsContextPrivate.h" @@ -958,6 +959,15 @@ void GraphicsContext::translate(float x, float y) m_data->m_userToDeviceTransformKnownToBeIdentity = false; } +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + if (paintingDisabled()) + return; + CGContextConcatCTM(platformContext(), transform); + m_data->concatCTM(transform); + m_data->m_userToDeviceTransformKnownToBeIdentity = false; +} + void GraphicsContext::concatCTM(const TransformationMatrix& transform) { if (paintingDisabled()) @@ -967,6 +977,12 @@ void GraphicsContext::concatCTM(const TransformationMatrix& transform) m_data->m_userToDeviceTransformKnownToBeIdentity = false; } +AffineTransform GraphicsContext::getAffineCTM() const +{ + CGAffineTransform t = CGContextGetCTM(platformContext()); + return AffineTransform(t.a, t.b, t.c, t.d, t.tx, t.ty); +} + TransformationMatrix GraphicsContext::getCTM() const { CGAffineTransform t = CGContextGetCTM(platformContext()); diff --git a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h index ff1816f..7b80d5b 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h +++ b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h @@ -73,6 +73,7 @@ public: void scale(const FloatSize&) {} void rotate(float) {} void translate(float, float) {} + void concatCTM(const AffineTransform&) {} void concatCTM(const TransformationMatrix&) {} void beginTransparencyLayer() {} void endTransparencyLayer() {} @@ -88,6 +89,7 @@ public: void scale(const FloatSize&); void rotate(float); void translate(float, float); + void concatCTM(const AffineTransform&); void concatCTM(const TransformationMatrix&); void beginTransparencyLayer() { m_transparencyCount++; } void endTransparencyLayer() { m_transparencyCount--; } diff --git a/WebCore/platform/graphics/cg/PathCG.cpp b/WebCore/platform/graphics/cg/PathCG.cpp index 3b05641..01680df 100644 --- a/WebCore/platform/graphics/cg/PathCG.cpp +++ b/WebCore/platform/graphics/cg/PathCG.cpp @@ -29,6 +29,7 @@ #if PLATFORM(CG) +#include "AffineTransform.h" #include "TransformationMatrix.h" #include <ApplicationServices/ApplicationServices.h> #include "FloatRect.h" @@ -346,6 +347,15 @@ void Path::apply(void* info, PathApplierFunction function) const CGPathApply(m_path, &pinfo, CGPathApplierToPathApplier); } +void Path::transform(const AffineTransform& transform) +{ + CGMutablePathRef path = CGPathCreateMutable(); + CGAffineTransform transformCG = transform; + CGPathAddPath(path, &transformCG, m_path); + CGPathRelease(m_path); + m_path = path; +} + void Path::transform(const TransformationMatrix& transform) { CGMutablePathRef path = CGPathCreateMutable(); diff --git a/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp b/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp index 568a6b3..5fe2122 100644 --- a/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp +++ b/WebCore/platform/graphics/cg/TransformationMatrixCG.cpp @@ -24,6 +24,7 @@ */ #include "config.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #if PLATFORM(CG) @@ -43,6 +44,16 @@ TransformationMatrix::operator CGAffineTransform() const narrowPrecisionToCGFloat(f())); } +AffineTransform::operator CGAffineTransform() const +{ + return CGAffineTransformMake(narrowPrecisionToCGFloat(a()), + narrowPrecisionToCGFloat(b()), + narrowPrecisionToCGFloat(c()), + narrowPrecisionToCGFloat(d()), + narrowPrecisionToCGFloat(e()), + narrowPrecisionToCGFloat(f())); +} + } #endif // PLATFORM(CG) diff --git a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp index 41f90f0..0372021 100644 --- a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp +++ b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp @@ -32,6 +32,7 @@ #include "Document.h" #include "Frame.h" #include "FrameView.h" +#include "GOwnPtrGtk.h" #include "GraphicsContext.h" #include "IntRect.h" #include "KURL.h" @@ -131,63 +132,87 @@ gboolean mediaPlayerPrivateMessageCallback(GstBus* bus, GstMessage* message, gpo void mediaPlayerPrivateSourceChangedCallback(GObject *object, GParamSpec *pspec, gpointer data) { MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data); - GstElement* element; + GOwnPtr<GstElement> element; - g_object_get(mp->m_playBin, "source", &element, NULL); - gst_object_replace((GstObject**) &mp->m_source, (GstObject*) element); + g_object_get(mp->m_playBin, "source", &element.outPtr(), NULL); + gst_object_replace((GstObject**) &mp->m_source, (GstObject*) element.get()); - if (element) { - GParamSpec* pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(element), "cookies"); + if (!element) + return; - // First check if the source element has a cookies property - // of the format we expect - if (!pspec || pspec->value_type != G_TYPE_STRV) - return; + GOwnPtr<char> location; + g_object_get(element.get(), "location", &location.outPtr(), NULL); - // Then get the cookies for the URI and set them - SoupSession* session = webkit_get_default_session(); - SoupCookieJar* cookieJar = SOUP_COOKIE_JAR(soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR)); + // Do injection only for elements dealing with uris. + if (!gst_uri_is_valid(location.get())) + return; - char* location; - g_object_get(element, "location", &location, NULL); + GOwnPtr<SoupURI> uri(soup_uri_new(location.get())); - SoupURI* uri = soup_uri_new(location); - g_free(location); + // Do injection only for http(s) uris. + if (!SOUP_URI_VALID_FOR_HTTP(uri)) + return; - // Let Apple web servers know we want to access their nice movie trailers. - if (g_str_equal(uri->host, "movies.apple.com")) - g_object_set(element, "user-agent", "Quicktime/7.2.0", NULL); + // Let Apple web servers know we want to access their nice movie trailers. + if (g_str_equal(uri->host, "movies.apple.com")) + g_object_set(element.get(), "user-agent", "Quicktime/7.2.0", NULL); + + // Set the HTTP referer. + Frame* frame = mp->m_player->frameView() ? mp->m_player->frameView()->frame() : 0; + Document* document = frame ? frame->document() : 0; + if (document) { + GstStructure* extraHeaders = gst_structure_new("extra-headers", + "Referer", G_TYPE_STRING, + document->documentURI().utf8().data(), 0); + g_object_set(element.get(), "extra-headers", extraHeaders, NULL); + gst_structure_free(extraHeaders); + } - char* cookies = soup_cookie_jar_get_cookies(cookieJar, uri, FALSE); - soup_uri_free(uri); + // Deal with the cookies from now on. + GParamSpec* cookiesParamSpec = g_object_class_find_property(G_OBJECT_GET_CLASS(element.get()), "cookies"); - char* cookiesStrv[] = {cookies, NULL}; - g_object_set(element, "cookies", cookiesStrv, NULL); - g_free(cookies); + // First check if the source element has a cookies property + // of the format we expect + if (!cookiesParamSpec || cookiesParamSpec->value_type != G_TYPE_STRV) + return; - Frame* frame = mp->m_player->frameView() ? mp->m_player->frameView()->frame() : 0; - Document* document = frame ? frame->document() : 0; - if (document) { - GstStructure* extraHeaders = gst_structure_new("extra-headers", - "Referer", G_TYPE_STRING, - document->documentURI().utf8().data(), 0); - g_object_set(element, "extra-headers", extraHeaders, NULL); - gst_structure_free(extraHeaders); - } - } + // Then get the cookies for the URI and set them + SoupSession* session = webkit_get_default_session(); + SoupSessionFeature* cookieJarFeature = soup_session_get_feature(session, SOUP_TYPE_COOKIE_JAR); + if (!cookieJarFeature) + return; - gst_object_unref(element); + SoupCookieJar* cookieJar = SOUP_COOKIE_JAR(cookieJarFeature); + GOwnPtr<char> cookies(soup_cookie_jar_get_cookies(cookieJar, uri.get(), FALSE)); + char* cookiesStrv[] = {cookies.get(), 0}; + g_object_set(element.get(), "cookies", cookiesStrv, NULL); } void mediaPlayerPrivateVolumeChangedCallback(GObject *element, GParamSpec *pspec, gpointer data) { + // This is called when playbin receives the notify::volume signal. MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data); mp->volumeChanged(); } -gboolean notifyVolumeIdleCallback(MediaPlayer* mp) +gboolean notifyVolumeIdleCallback(gpointer data) { - mp->volumeChanged(); + MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data); + mp->volumeChangedCallback(); + return FALSE; +} + +void mediaPlayerPrivateMuteChangedCallback(GObject *element, GParamSpec *pspec, gpointer data) +{ + // This is called when playbin receives the notify::mute signal. + MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data); + mp->muteChanged(); +} + +gboolean notifyMuteIdleCallback(gpointer data) +{ + MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data); + mp->muteChangedCallback(); return FALSE; } @@ -291,8 +316,9 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player) , m_seeking(false) , m_playbackRate(1) , m_errorOccured(false) - , m_volumeIdleId(-1) + , m_volumeIdleId(0) , m_mediaDuration(0.0) + , m_muteIdleId(0) { doGstInit(); } @@ -301,7 +327,12 @@ MediaPlayerPrivate::~MediaPlayerPrivate() { if (m_volumeIdleId) { g_source_remove(m_volumeIdleId); - m_volumeIdleId = -1; + m_volumeIdleId = 0; + } + + if (m_muteIdleId) { + g_source_remove(m_muteIdleId); + m_muteIdleId = 0; } if (m_buffer) @@ -532,16 +563,20 @@ void MediaPlayerPrivate::setVolume(float volume) g_object_set(m_playBin, "volume", static_cast<double>(volume), NULL); } +void MediaPlayerPrivate::volumeChangedCallback() +{ + double volume; + g_object_get(m_playBin, "volume", &volume, NULL); + m_player->volumeChanged(static_cast<float>(volume)); +} + void MediaPlayerPrivate::volumeChanged() { - if (m_volumeIdleId) { + if (m_volumeIdleId) g_source_remove(m_volumeIdleId); - m_volumeIdleId = -1; - } - m_volumeIdleId = g_idle_add((GSourceFunc) notifyVolumeIdleCallback, m_player); + m_volumeIdleId = g_idle_add((GSourceFunc) notifyVolumeIdleCallback, this); } - void MediaPlayerPrivate::setRate(float rate) { // Avoid useless playback rate update. @@ -922,6 +957,34 @@ void MediaPlayerPrivate::durationChanged() m_player->durationChanged(); } +bool MediaPlayerPrivate::supportsMuting() const +{ + return true; +} + +void MediaPlayerPrivate::setMuted(bool muted) +{ + if (!m_playBin) + return; + + g_object_set(m_playBin, "mute", muted, NULL); +} + +void MediaPlayerPrivate::muteChangedCallback() +{ + gboolean muted; + g_object_get(m_playBin, "mute", &muted, NULL); + m_player->muteChanged(static_cast<bool>(muted)); +} + +void MediaPlayerPrivate::muteChanged() +{ + if (m_muteIdleId) + g_source_remove(m_muteIdleId); + + m_muteIdleId = g_idle_add((GSourceFunc) notifyMuteIdleCallback, this); +} + void MediaPlayerPrivate::loadingFailed(MediaPlayer::NetworkState error) { m_errorOccured = true; @@ -1140,6 +1203,7 @@ void MediaPlayerPrivate::createGSTPlayBin(String url) g_signal_connect(m_playBin, "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this); g_signal_connect(m_playBin, "notify::source", G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this); + g_signal_connect(m_playBin, "notify::mute", G_CALLBACK(mediaPlayerPrivateMuteChangedCallback), this); m_videoSink = webkit_video_sink_new(); diff --git a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h index ec55b29..34257ca 100644 --- a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h +++ b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h @@ -76,8 +76,15 @@ class MediaPlayerPrivate : public MediaPlayerPrivateInterface { void seek(float); void setRate(float); + void setVolume(float); void volumeChanged(); + void volumeChangedCallback(); + + bool supportsMuting() const; + void setMuted(bool); + void muteChanged(); + void muteChangedCallback(); MediaPlayer::NetworkState networkState() const; MediaPlayer::ReadyState readyState() const; @@ -149,6 +156,7 @@ class MediaPlayerPrivate : public MediaPlayerPrivateInterface { bool m_errorOccured; guint m_volumeIdleId; gfloat m_mediaDuration; + guint m_muteIdleId; }; } diff --git a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp index 6038c6a..3970ebc 100644 --- a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp +++ b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "GraphicsContext.h" +#include "AffineTransform.h" #include "CString.h" #include "Color.h" #include "Font.h" @@ -391,6 +392,12 @@ void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*) notImplemented(); } +AffineTransform GraphicsContext::getAffineCTM() const +{ + notImplemented(); + return AffineTransform(); +} + TransformationMatrix GraphicsContext::getCTM() const { notImplemented(); @@ -451,6 +458,14 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness notImplemented(); } +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + if (paintingDisabled()) + return; + + notImplemented(); +} + void GraphicsContext::concatCTM(const TransformationMatrix& transform) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/haiku/PathHaiku.cpp b/WebCore/platform/graphics/haiku/PathHaiku.cpp index d0da025..70dad29 100644 --- a/WebCore/platform/graphics/haiku/PathHaiku.cpp +++ b/WebCore/platform/graphics/haiku/PathHaiku.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "Path.h" +#include "AffineTransform.h" #include "FloatRect.h" #include "NotImplemented.h" #include "PlatformString.h" @@ -146,6 +147,11 @@ void Path::apply(void* info, PathApplierFunction function) const notImplemented(); } +void Path::transform(const AffineTransform& transform) +{ + notImplemented(); +} + void Path::transform(const TransformationMatrix& transform) { notImplemented(); diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index b78a6e8..9046449 100644 --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -40,6 +40,7 @@ #include <windows.h> #endif +#include "AffineTransform.h" #include "Color.h" #include "FloatConversion.h" #include "Font.h" @@ -275,6 +276,13 @@ PlatformGraphicsContext* GraphicsContext::platformContext() const return m_data->p(); } +AffineTransform GraphicsContext::getAffineCTM() const +{ + QTransform matrix(platformContext()->combinedTransform()); + return AffineTransform(matrix.m11(), matrix.m12(), matrix.m21(), + matrix.m22(), matrix.dx(), matrix.dy()); +} + TransformationMatrix GraphicsContext::getCTM() const { QTransform matrix(platformContext()->combinedTransform()); @@ -1188,6 +1196,24 @@ void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, p->setRenderHint(QPainter::Antialiasing, antiAlias); } +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + if (paintingDisabled()) + return; + + m_data->p()->setWorldTransform(transform, true); + + // Transformations to the context shouldn't transform the currentPath. + // We have to undo every change made to the context from the currentPath + // to avoid wrong drawings. + if (!m_data->currentPath.isEmpty() && transform.isInvertible()) { + QTransform matrix = transform.inverse(); + m_data->currentPath = m_data->currentPath * matrix; + m_common->state.pathTransform.multiply(transform.toTransformationMatrix()); + } +} + + void GraphicsContext::concatCTM(const TransformationMatrix& transform) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp index 4716d32..2721984 100644 --- a/WebCore/platform/graphics/qt/PathQt.cpp +++ b/WebCore/platform/graphics/qt/PathQt.cpp @@ -1,7 +1,7 @@ /* * Copyright (C) 2006 Zack Rusin <zack@kde.org> * 2006 Rob Buis <buis@kde.org> - * 2009 Dirk Schulze <krit@webkit.org> + * 2009, 2010 Dirk Schulze <krit@webkit.org> * * All rights reserved. * @@ -30,12 +30,13 @@ #include "config.h" #include "Path.h" -#include "TransformationMatrix.h" +#include "AffineTransform.h" #include "FloatRect.h" #include "GraphicsContext.h" #include "ImageBuffer.h" #include "PlatformString.h" #include "StrokeStyleApplier.h" +#include "TransformationMatrix.h" #include <QPainterPath> #include <QTransform> #include <QString> @@ -379,6 +380,11 @@ void Path::apply(void* info, PathApplierFunction function) const } } +void Path::transform(const AffineTransform& transform) +{ + m_path = QTransform(transform).map(m_path); +} + void Path::transform(const TransformationMatrix& transform) { m_path = QTransform(transform).map(m_path); diff --git a/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp b/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp index 37b86f3..a5bc3c3 100644 --- a/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp +++ b/WebCore/platform/graphics/qt/TransformationMatrixQt.cpp @@ -24,6 +24,7 @@ */ #include "config.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "IntRect.h" @@ -36,6 +37,11 @@ TransformationMatrix::operator QTransform() const return QTransform(m11(), m12(), m14(), m21(), m22(), m24(), m41(), m42(), m44()); } +AffineTransform::operator QTransform() const +{ + return QTransform(a(), b(), c(), d(), e(), f()); +} + } // vim: ts=4 sw=4 et diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index 985442c..bd97ca2 100644 --- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -31,6 +31,7 @@ #include "config.h" #include "GraphicsContext.h" +#include "AffineTransform.h" #include "Color.h" #include "FloatRect.h" #include "Gradient.h" @@ -439,6 +440,13 @@ void GraphicsContext::clipToImageBuffer(const FloatRect& rect, #endif } +void GraphicsContext::concatCTM(const AffineTransform& affine) +{ + if (paintingDisabled()) + return; + platformContext()->canvas()->concat(affine); +} + void GraphicsContext::concatCTM(const TransformationMatrix& xform) { if (paintingDisabled()) @@ -805,6 +813,17 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, platformContext()->canvas()->drawPath(path, paint); } +AffineTransform GraphicsContext::getAffineCTM() const +{ + const SkMatrix& m = platformContext()->canvas()->getTotalMatrix(); + return AffineTransform(SkScalarToDouble(m.getScaleX()), // a + SkScalarToDouble(m.getSkewY()), // b + SkScalarToDouble(m.getSkewX()), // c + SkScalarToDouble(m.getScaleY()), // d + SkScalarToDouble(m.getTranslateX()), // e + SkScalarToDouble(m.getTranslateY())); // f +} + TransformationMatrix GraphicsContext::getCTM() const { const SkMatrix& m = platformContext()->canvas()->getTotalMatrix(); @@ -978,9 +997,7 @@ void GraphicsContext::setPlatformFillPattern(Pattern* pattern) if (paintingDisabled()) return; - SkShader* pat = pattern->createPlatformPattern(getCTM()); - platformContext()->setFillShader(pat); - pat->safeUnref(); + platformContext()->setFillShader(pattern->platformPattern(getCTM())); } void GraphicsContext::setPlatformShadow(const IntSize& size, @@ -1065,9 +1082,7 @@ void GraphicsContext::setPlatformStrokePattern(Pattern* pattern) if (paintingDisabled()) return; - SkShader* pat = pattern->createPlatformPattern(getCTM()); - platformContext()->setStrokeShader(pat); - pat->safeUnref(); + platformContext()->setStrokeShader(pattern->platformPattern(getCTM())); } void GraphicsContext::setPlatformTextDrawingMode(int mode) diff --git a/WebCore/platform/graphics/skia/PathSkia.cpp b/WebCore/platform/graphics/skia/PathSkia.cpp index 2cbb759..fe4c3d0 100644 --- a/WebCore/platform/graphics/skia/PathSkia.cpp +++ b/WebCore/platform/graphics/skia/PathSkia.cpp @@ -30,6 +30,7 @@ #include "config.h" #include "Path.h" +#include "AffineTransform.h" #include "FloatRect.h" #include "ImageBuffer.h" #include "StrokeStyleApplier.h" @@ -214,6 +215,11 @@ void Path::apply(void* info, PathApplierFunction function) const } } +void Path::transform(const AffineTransform& xform) +{ + m_path->transform(xform); +} + void Path::transform(const TransformationMatrix& xform) { m_path->transform(xform); diff --git a/WebCore/platform/graphics/skia/PatternSkia.cpp b/WebCore/platform/graphics/skia/PatternSkia.cpp index 11b5cf1..b98825b 100644 --- a/WebCore/platform/graphics/skia/PatternSkia.cpp +++ b/WebCore/platform/graphics/skia/PatternSkia.cpp @@ -40,8 +40,17 @@ namespace WebCore { -PlatformPatternPtr Pattern::createPlatformPattern(const TransformationMatrix& patternTransform) const +void Pattern::platformDestroy() { + m_pattern->safeUnref(); + m_pattern = 0; +} + +PlatformPatternPtr Pattern::platformPattern(const TransformationMatrix& patternTransform) +{ + if (m_pattern) + return m_pattern; + // Note: patternTransform is ignored since it seems to be applied elsewhere // (when the pattern is used?). Applying it to the pattern (i.e. // shader->setLocalMatrix) results in a double transformation. This can be @@ -53,31 +62,42 @@ PlatformPatternPtr Pattern::createPlatformPattern(const TransformationMatrix& pa SkBitmap* bm = m_tileImage->nativeImageForCurrentFrame(); // If we don't have a bitmap, return a transparent shader. if (!bm) - return new SkColorShader(SkColorSetARGB(0, 0, 0, 0)); + m_pattern = new SkColorShader(SkColorSetARGB(0, 0, 0, 0)); - if (m_repeatX && m_repeatY) - return SkShader::CreateBitmapShader(*bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); + else if (m_repeatX && m_repeatY) + m_pattern = SkShader::CreateBitmapShader(*bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); - // Skia does not have a "draw the tile only once" option. Clamp_TileMode - // repeats the last line of the image after drawing one tile. To avoid - // filling the space with arbitrary pixels, this workaround forces the - // image to have a line of transparent pixels on the "repeated" edge(s), - // thus causing extra space to be transparent filled. - SkShader::TileMode tileModeX = m_repeatX ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode; - SkShader::TileMode tileModeY = m_repeatY ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode; - int expandW = m_repeatX ? 0 : 1; - int expandH = m_repeatY ? 0 : 1; + else { - // Create a transparent bitmap 1 pixel wider and/or taller than the - // original, then copy the orignal into it. - // FIXME: Is there a better way to pad (not scale) an image in skia? - SkBitmap bm2; - bm2.setConfig(bm->config(), bm->width() + expandW, bm->height() + expandH); - bm2.allocPixels(); - bm2.eraseARGB(0x00, 0x00, 0x00, 0x00); - SkCanvas canvas(bm2); - canvas.drawBitmap(*bm, 0, 0); - return SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY); + // Skia does not have a "draw the tile only once" option. Clamp_TileMode + // repeats the last line of the image after drawing one tile. To avoid + // filling the space with arbitrary pixels, this workaround forces the + // image to have a line of transparent pixels on the "repeated" edge(s), + // thus causing extra space to be transparent filled. + SkShader::TileMode tileModeX = m_repeatX ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode; + SkShader::TileMode tileModeY = m_repeatY ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode; + int expandW = m_repeatX ? 0 : 1; + int expandH = m_repeatY ? 0 : 1; + + // Create a transparent bitmap 1 pixel wider and/or taller than the + // original, then copy the orignal into it. + // FIXME: Is there a better way to pad (not scale) an image in skia? + SkBitmap bm2; + bm2.setConfig(bm->config(), bm->width() + expandW, bm->height() + expandH); + bm2.allocPixels(); + bm2.eraseARGB(0x00, 0x00, 0x00, 0x00); + SkCanvas canvas(bm2); + canvas.drawBitmap(*bm, 0, 0); + m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY); + } + m_pattern->setLocalMatrix(m_patternSpaceTransformation); + return m_pattern; +} + +void Pattern::setPlatformPatternSpaceTransform() +{ + if (m_pattern) + m_pattern->setLocalMatrix(m_patternSpaceTransformation); } } // namespace WebCore diff --git a/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp b/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp index 2d0f9f8..dc610d7 100644 --- a/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp +++ b/WebCore/platform/graphics/skia/TransformationMatrixSkia.cpp @@ -28,6 +28,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "config.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "SkiaUtils.h" @@ -54,4 +55,24 @@ TransformationMatrix::operator SkMatrix() const return result; } +AffineTransform::operator SkMatrix() const +{ + SkMatrix result; + + result.setScaleX(WebCoreDoubleToSkScalar(a())); + result.setSkewX(WebCoreDoubleToSkScalar(c())); + result.setTranslateX(WebCoreDoubleToSkScalar(e())); + + result.setScaleY(WebCoreDoubleToSkScalar(d())); + result.setSkewY(WebCoreDoubleToSkScalar(b())); + result.setTranslateY(WebCoreDoubleToSkScalar(f())); + + // FIXME: Set perspective properly. + result.setPerspX(0); + result.setPerspY(0); + result.set(SkMatrix::kMPersp2, SK_Scalar1); + + return result; +} + } // namespace WebCore diff --git a/WebCore/platform/graphics/transforms/AffineTransform.cpp b/WebCore/platform/graphics/transforms/AffineTransform.cpp new file mode 100644 index 0000000..f26bcb7 --- /dev/null +++ b/WebCore/platform/graphics/transforms/AffineTransform.cpp @@ -0,0 +1,325 @@ +/* + * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. + * 2010 Dirk Schulze <krit@webkit.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "AffineTransform.h" + +#include "FloatConversion.h" +#include "FloatQuad.h" +#include "FloatRect.h" +#include "IntRect.h" + +#include <wtf/MathExtras.h> + +namespace WebCore { + +static void affineTransformDecompose(const AffineTransform& matrix, double sr[9]) +{ + AffineTransform m(matrix); + + // Compute scaling factors + double sx = sqrt(m.a() * m.a() + m.b() * m.b()); + double sy = sqrt(m.c() * m.c() + m.d() * m.d()); + + // Compute cross product of transformed unit vectors. If negative, + // one axis was flipped. + if (m.a() * m.d() - m.c() * m.b() < 0.0) { + // Flip axis with minimum unit vector dot product + if (m.a() < m.d()) + sx = -sx; + else + sy = -sy; + } + + // Remove scale from matrix + m.scale(1.0 / sx, 1.0 / sy); + + // Compute rotation + double angle = atan2(m.b(), m.a()); + + // Remove rotation from matrix + m.rotate(rad2deg(-angle)); + + // Return results + sr[0] = sx; + sr[1] = sy; + sr[2] = angle; + sr[3] = m.a(); + sr[4] = m.b(); + sr[5] = m.c(); + sr[6] = m.d(); + sr[7] = m.e(); + sr[8] = m.f(); +} + +static void affineTransformCompose(AffineTransform& m, const double sr[9]) +{ + m.setA(sr[3]); + m.setB(sr[4]); + m.setC(sr[5]); + m.setD(sr[6]); + m.setE(sr[7]); + m.setF(sr[8]); + m.rotate(rad2deg(sr[2])); + m.scale(sr[0], sr[1]); +} + +AffineTransform::AffineTransform() +{ + setMatrix(1, 0, 0, 1, 0, 0); +} + +AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f) +{ + setMatrix(a, b, c, d, e, f); +} + +void AffineTransform::reset() +{ + setMatrix(1, 0, 0, 1, 0, 0); +} + +void AffineTransform::setMatrix(double a, double b, double c, double d, double e, double f) +{ + m_transform[0] = a; + m_transform[1] = b; + m_transform[2] = c; + m_transform[3] = d; + m_transform[4] = e; + m_transform[5] = f; +} + +bool AffineTransform::isIdentity() const +{ + return (m_transform[0] == 1 && m_transform[1] == 0 + && m_transform[2] == 0 && m_transform[3] == 1 + && m_transform[4] == 0 && m_transform[5] == 0); +} + +double AffineTransform::det() const +{ + return m_transform[0] * m_transform[3] - m_transform[1] * m_transform[2]; +} + +bool AffineTransform::isInvertible() const +{ + return det() != 0.0; +} + +AffineTransform AffineTransform::inverse() const +{ + double determinant = det(); + if (determinant == 0.0) + return AffineTransform(); + + AffineTransform result; + result.m_transform[0] = m_transform[3] / determinant; + result.m_transform[1] = -m_transform[1] / determinant; + result.m_transform[2] = -m_transform[2] / determinant; + result.m_transform[3] = m_transform[0] / determinant; + result.m_transform[4] = (m_transform[2] * m_transform[5] + - m_transform[3] * m_transform[4]) / determinant; + result.m_transform[5] = (m_transform[1] * m_transform[4] + - m_transform[0] * m_transform[5]) / determinant; + + return result; +} + +AffineTransform& AffineTransform::multiply(const AffineTransform& other) +{ + return (*this) *= other; +} + +AffineTransform& AffineTransform::multLeft(const AffineTransform& other) +{ + AffineTransform trans; + + trans.m_transform[0] = other.m_transform[0] * m_transform[0] + other.m_transform[1] * m_transform[2]; + trans.m_transform[1] = other.m_transform[0] * m_transform[1] + other.m_transform[1] * m_transform[3]; + trans.m_transform[2] = other.m_transform[2] * m_transform[0] + other.m_transform[3] * m_transform[2]; + trans.m_transform[3] = other.m_transform[2] * m_transform[1] + other.m_transform[3] * m_transform[3]; + trans.m_transform[4] = other.m_transform[4] * m_transform[0] + other.m_transform[5] * m_transform[2] + m_transform[4]; + trans.m_transform[5] = other.m_transform[4] * m_transform[1] + other.m_transform[5] * m_transform[3] + m_transform[5]; + + setMatrix(trans.m_transform); + return *this; +} + +AffineTransform& AffineTransform::rotate(double a) +{ + // angle is in degree. Switch to radian + a = deg2rad(a); + double cosAngle = cos(a); + double sinAngle = sin(a); + AffineTransform rot(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0); + + multLeft(rot); + return *this; +} + +AffineTransform& AffineTransform::scale(double s) +{ + return scale(s, s); +} + +AffineTransform& AffineTransform::scale(double sx, double sy) +{ + m_transform[0] *= sx; + m_transform[3] *= sy; + return *this; +} + +AffineTransform& AffineTransform::translate(double tx, double ty) +{ + m_transform[4] += tx; + m_transform[5] += ty; + return *this; +} + +AffineTransform& AffineTransform::scaleNonUniform(double sx, double sy) +{ + return scale(sx, sy); +} + +AffineTransform& AffineTransform::rotateFromVector(double x, double y) +{ + return rotate(rad2deg(atan2(y, x))); +} + +AffineTransform& AffineTransform::flipX() +{ + return scale(-1, 1); +} + +AffineTransform& AffineTransform::flipY() +{ + return scale(1, -1); +} + +AffineTransform& AffineTransform::shear(double sx, double sy) +{ + AffineTransform shear(1, sy, sx, 1, 0, 0); + + multLeft(shear); + return *this; +} + +AffineTransform& AffineTransform::skew(double angleX, double angleY) +{ + return shear(tan(deg2rad(angleX)), tan(deg2rad(angleY))); +} + +AffineTransform& AffineTransform::skewX(double angle) +{ + return shear(tan(deg2rad(angle)), 0); +} + +AffineTransform& AffineTransform::skewY(double angle) +{ + return shear(0, tan(deg2rad(angle))); +} + +AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& dest) +{ + AffineTransform transform; + transform.translate(dest.x() - source.x(), dest.y() - source.y()); + transform.scale(dest.width() / source.width(), dest.height() / source.height()); + return transform; +} + +void AffineTransform::map(double x, double y, double* x2, double* y2) const +{ + *x2 = (m_transform[0] * x + m_transform[2] * y + m_transform[4]); + *y2 = (m_transform[1] * x + m_transform[3] * y + m_transform[5]); +} + +IntPoint AffineTransform::mapPoint(const IntPoint& point) const +{ + double x2, y2; + map(point.x(), point.y(), &x2, &y2); + + // Round the point. + return IntPoint(lround(x2), lround(y2)); +} + +FloatPoint AffineTransform::mapPoint(const FloatPoint& point) const +{ + double x2, y2; + map(point.x(), point.y(), &x2, &y2); + + return FloatPoint(narrowPrecisionToFloat(x2), narrowPrecisionToFloat(y2)); +} + +FloatRect AffineTransform::mapRect(const FloatRect& rect) const +{ + FloatQuad q(rect); + + FloatQuad result; + result.setP1(mapPoint(q.p1())); + result.setP2(mapPoint(q.p2())); + result.setP3(mapPoint(q.p3())); + result.setP4(mapPoint(q.p4())); + return result.boundingBox(); +} + +void AffineTransform::blend(const AffineTransform& from, double progress) +{ + double srA[9], srB[9]; + + affineTransformDecompose(from, srA); + affineTransformDecompose(*this, srB); + + // If x-axis of one is flipped, and y-axis of the other, convert to an unflipped rotation. + if ((srA[0] < 0 && srB[1] < 0) || (srA[1] < 0 && srB[0] < 0)) { + srA[0] = -srA[0]; + srA[1] = -srA[1]; + srA[2] += srA[2] < 0 ? piDouble : -piDouble; + } + + // Don't rotate the long way around. + srA[2] = fmod(srA[2], 2.0 * piDouble); + srB[2] = fmod(srB[2], 2.0 * piDouble); + + if (fabs(srA[2] - srB[2]) > piDouble) { + if (srA[2] > srB[2]) + srA[2] -= piDouble * 2.0; + else + srB[2] -= piDouble * 2.0; + } + + for (int i = 0; i < 9; i++) + srA[i] = srA[i] + progress * (srB[i] - srA[i]); + + affineTransformCompose(*this, srA); +} + +TransformationMatrix AffineTransform::toTransformationMatrix() const +{ + return TransformationMatrix(m_transform[0], m_transform[1], m_transform[2], + m_transform[3], m_transform[4], m_transform[5]); +} + +} diff --git a/WebCore/platform/graphics/transforms/AffineTransform.h b/WebCore/platform/graphics/transforms/AffineTransform.h new file mode 100644 index 0000000..49add18 --- /dev/null +++ b/WebCore/platform/graphics/transforms/AffineTransform.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. + * 2010 Dirk Schulze <krit@webkit.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef AffineTransform_h +#define AffineTransform_h + +#include "TransformationMatrix.h" + +#include <string.h> // for memcpy +#include <wtf/FastAllocBase.h> + +#if PLATFORM(CG) +#include <CoreGraphics/CGAffineTransform.h> +#elif PLATFORM(CAIRO) +#include <cairo.h> +#elif PLATFORM(QT) +#include <QTransform> +#elif PLATFORM(SKIA) +#include <SkMatrix.h> +#elif PLATFORM(WX) && USE(WXGC) +#include <wx/graphics.h> +#endif + +namespace WebCore { + +class FloatPoint; +class FloatQuad; +class FloatRect; +class IntPoint; +class IntRect; + +class AffineTransform : public FastAllocBase { +public: + typedef double Transform[6]; + + AffineTransform(); + AffineTransform(double a, double b, double c, double d, double e, double f); + + void setMatrix(double a, double b, double c, double d, double e, double f); + + void map(double x, double y, double* x2, double* y2) const; + + // Rounds the mapped point to the nearest integer value. + IntPoint mapPoint(const IntPoint&) const; + + FloatPoint mapPoint(const FloatPoint&) const; + + // Rounds the resulting mapped rectangle out. This is helpful for bounding + // box computations but may not be what is wanted in other contexts. + IntRect mapRect(const IntRect&) const; + + FloatRect mapRect(const FloatRect&) const; + + bool isIdentity() const; + + double a() const { return m_transform[0]; } + void setA(double a) { m_transform[0] = a; } + double b() const { return m_transform[1]; } + void setB(double b) { m_transform[1] = b; } + double c() const { return m_transform[2]; } + void setC(double c) { m_transform[2] = c; } + double d() const { return m_transform[3]; } + void setD(double d) { m_transform[3] = d; } + double e() const { return m_transform[4]; } + void setE(double e) { m_transform[4] = e; } + double f() const { return m_transform[5]; } + void setF(double f) { m_transform[5] = f; } + + void reset(); + + AffineTransform& multiply(const AffineTransform&); + AffineTransform& multLeft(const AffineTransform&); + AffineTransform& scale(double); + AffineTransform& scale(double sx, double sy); + AffineTransform& scaleNonUniform(double sx, double sy); + AffineTransform& rotate(double d); + AffineTransform& rotateFromVector(double x, double y); + AffineTransform& translate(double tx, double ty); + AffineTransform& shear(double sx, double sy); + AffineTransform& flipX(); + AffineTransform& flipY(); + AffineTransform& skew(double angleX, double angleY); + AffineTransform& skewX(double angle); + AffineTransform& skewY(double angle); + + double det() const; + bool isInvertible() const; + AffineTransform inverse() const; + + void blend(const AffineTransform& from, double progress); + + TransformationMatrix toTransformationMatrix() const; + + bool operator== (const AffineTransform& m2) const + { + return (m_transform[0] == m2.m_transform[0] + && m_transform[1] == m2.m_transform[1] + && m_transform[2] == m2.m_transform[2] + && m_transform[3] == m2.m_transform[3] + && m_transform[4] == m2.m_transform[4] + && m_transform[5] == m2.m_transform[5]); + } + + bool operator!=(const AffineTransform& other) const { return !(*this == other); } + + // *this = *this * t (i.e., a multRight) + AffineTransform& operator*=(const AffineTransform& t) + { + *this = *this * t; + return *this; + } + + // result = *this * t (i.e., a multRight) + AffineTransform operator*(const AffineTransform& t) const + { + AffineTransform result = t; + result.multLeft(*this); + return result; + } + +#if PLATFORM(CG) + operator CGAffineTransform() const; +#elif PLATFORM(CAIRO) + operator cairo_matrix_t() const; +#elif PLATFORM(QT) + operator QTransform() const; +#elif PLATFORM(SKIA) + operator SkMatrix() const; +#elif PLATFORM(WX) && USE(WXGC) + operator wxGraphicsMatrix() const; +#endif + +private: + void setMatrix(const Transform m) + { + if (m && m != m_transform) + memcpy(m_transform, m, sizeof(Transform)); + } + + Transform m_transform; +}; + +AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& dest); + +} + +#endif diff --git a/WebCore/platform/graphics/win/GraphicsContextWin.cpp b/WebCore/platform/graphics/win/GraphicsContextWin.cpp index 54b0cb2..68c12d1 100644 --- a/WebCore/platform/graphics/win/GraphicsContextWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextWin.cpp @@ -32,6 +32,7 @@ #include "GraphicsContextPlatformPrivateCairo.h" #endif +#include "AffineTransform.h" #include "BitmapInfo.h" #include "TransformationMatrix.h" #include "NotImplemented.h" @@ -189,6 +190,16 @@ void GraphicsContextPlatformPrivate::translate(float x , float y) ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); } +void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform) +{ + if (!m_hdc) + return; + + XFORM xform = TransformationMatrix(transform.a(), transform.b(), transform.c(), + transform.d(), transform.e(), transform.f()); + ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY); +} + void GraphicsContextPlatformPrivate::concatCTM(const TransformationMatrix& transform) { if (!m_hdc) diff --git a/WebCore/platform/graphics/win/WKCACFLayer.cpp b/WebCore/platform/graphics/win/WKCACFLayer.cpp index ad1fc85..e97fac9 100644 --- a/WebCore/platform/graphics/win/WKCACFLayer.cpp +++ b/WebCore/platform/graphics/win/WKCACFLayer.cpp @@ -39,10 +39,11 @@ #ifdef DEBUG_ALL #pragma comment(lib, "QuartzCore_debug") +#pragma comment(lib, "QuartzCoreInterface_debug") #else #pragma comment(lib, "QuartzCore") -#endif #pragma comment(lib, "QuartzCoreInterface") +#endif namespace WebCore { diff --git a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp index 0e387f5..410aeb1 100644 --- a/WebCore/platform/graphics/wince/GraphicsContextWince.cpp +++ b/WebCore/platform/graphics/wince/GraphicsContextWince.cpp @@ -21,6 +21,7 @@ #include "config.h" #include "GraphicsContext.h" +#include "AffineTransform.h" #include "CharacterNames.h" #include "GlyphBuffer.h" #include "Gradient.h" @@ -1143,6 +1144,11 @@ void GraphicsContext::endTransparencyLayer() m_data->restore(); } +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + m_data->concatCTM(transform); +} + void GraphicsContext::concatCTM(const TransformationMatrix& transform) { m_data->concatCTM(transform); @@ -1531,6 +1537,11 @@ void GraphicsContext::fillRect(const FloatRect& r, const Gradient* gradient) GradientFill(dc, tv.data(), tv.size(), mesh.data(), mesh.size(), vertical ? GRADIENT_FILL_RECT_V : GRADIENT_FILL_RECT_H); } +AffineTransform GraphicsContext::getAffineCTM() const +{ + return m_data->m_transform; +} + TransformationMatrix GraphicsContext::getCTM() const { return m_data->m_transform; diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp index 839bc59..e35334e 100644 --- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "GraphicsContext.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "FloatRect.h" #include "Font.h" @@ -359,6 +360,12 @@ void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*) notImplemented(); } +AffineTransform GraphicsContext::getAffineCTM() const +{ + notImplemented(); + return AffineTransform(); +} + TransformationMatrix GraphicsContext::getCTM() const { notImplemented(); @@ -471,6 +478,15 @@ void GraphicsContext::setPlatformFillColor(const Color& color, ColorSpace colorS m_data->context->SetBrush(wxBrush(color)); } +void GraphicsContext::concatCTM(const AffineTransform& transform) +{ + if (paintingDisabled()) + return; + + notImplemented(); + return; +} + void GraphicsContext::concatCTM(const TransformationMatrix& transform) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/wx/PathWx.cpp b/WebCore/platform/graphics/wx/PathWx.cpp index cebc05a..21693c9 100644 --- a/WebCore/platform/graphics/wx/PathWx.cpp +++ b/WebCore/platform/graphics/wx/PathWx.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "Path.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "FloatPoint.h" #include "FloatRect.h" @@ -202,6 +203,14 @@ void Path::addEllipse(const FloatRect& rect) #endif } +void Path::transform(const AffineTransform& transform) +{ +#if USE(WXGC) + if (m_path) + m_path->Transform(transform); +#endif +} + void Path::transform(const TransformationMatrix& transform) { #if USE(WXGC) diff --git a/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp b/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp index 9684a3c..1937986 100644 --- a/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp +++ b/WebCore/platform/graphics/wx/TransformationMatrixWx.cpp @@ -24,6 +24,7 @@ */ #include "config.h" +#include "AffineTransform.h" #include "TransformationMatrix.h" #include "Assertions.h" @@ -45,6 +46,15 @@ TransformationMatrix::operator wxGraphicsMatrix() const wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f()); return matrix; } + +AffineTransform::operator wxGraphicsMatrix() const +{ + wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer(); + ASSERT(renderer); + + wxGraphicsMatrix matrix = renderer->CreateMatrix(a(), b(), c(), d(), e(), f()); + return matrix; +} #endif } diff --git a/WebCore/platform/gtk/GOwnPtrGtk.cpp b/WebCore/platform/gtk/GOwnPtrGtk.cpp new file mode 100644 index 0000000..3bb1335 --- /dev/null +++ b/WebCore/platform/gtk/GOwnPtrGtk.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 Igalia S.L + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include "config.h" +#include "GOwnPtrGtk.h" + +#include <gst/gstelement.h> +#include <libsoup/soup-uri.h> + +namespace WTF { + +template <> void freeOwnedGPtr<SoupURI>(SoupURI* ptr) +{ + if (ptr) + soup_uri_free(ptr); +} + +template <> void freeOwnedGPtr<GstElement>(GstElement* ptr) +{ + if (ptr) + gst_object_unref(ptr); +} + +} diff --git a/WebCore/platform/gtk/GOwnPtrGtk.h b/WebCore/platform/gtk/GOwnPtrGtk.h new file mode 100644 index 0000000..c585002 --- /dev/null +++ b/WebCore/platform/gtk/GOwnPtrGtk.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2010 Igalia S.L + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef GOwnPtrGtk_h +#define GOwnPtrGtk_h + +#include "GOwnPtr.h" + +typedef struct _SoupURI SoupURI; +typedef struct _GstElement GstElement; + +namespace WTF { + +template<> void freeOwnedGPtr<SoupURI>(SoupURI* ptr); +template<> void freeOwnedGPtr<GstElement>(GstElement* ptr); + +} + +#endif diff --git a/WebCore/platform/mac/ThemeMac.mm b/WebCore/platform/mac/ThemeMac.mm index 2812607..b71a651 100644 --- a/WebCore/platform/mac/ThemeMac.mm +++ b/WebCore/platform/mac/ThemeMac.mm @@ -415,9 +415,20 @@ static void paintButton(ControlPart part, ControlStates states, GraphicsContext* } else if ([previousDefaultButtonCell isEqual:buttonCell]) [window setDefaultButtonCell:nil]; + if (!view) { + context->save(); + context->translate(inflatedRect.x(), inflatedRect.y()); + context->scale(FloatSize(1, -1)); + context->translate(0, -inflatedRect.height()); + inflatedRect.setLocation(IntPoint()); + } + [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view]; [buttonCell setControlView:nil]; + if (!view) + context->restore(); + if (![previousDefaultButtonCell isEqual:buttonCell]) [window setDefaultButtonCell:previousDefaultButtonCell]; diff --git a/WebCore/platform/network/qt/SocketStreamHandlePrivate.h b/WebCore/platform/network/qt/SocketStreamHandlePrivate.h index 9433d3f..235f1b1 100644 --- a/WebCore/platform/network/qt/SocketStreamHandlePrivate.h +++ b/WebCore/platform/network/qt/SocketStreamHandlePrivate.h @@ -59,7 +59,9 @@ public slots: void socketError(QAbstractSocket::SocketError); void socketClosedCallback(); void socketErrorCallback(int); +#ifndef QT_NO_OPENSSL void socketSslErrors(const QList<QSslError>&); +#endif public: QTcpSocket* m_socket; SocketStreamHandle* m_streamHandle; diff --git a/WebCore/platform/network/qt/SocketStreamHandleQt.cpp b/WebCore/platform/network/qt/SocketStreamHandleQt.cpp index d61d901..e666ff7 100644 --- a/WebCore/platform/network/qt/SocketStreamHandleQt.cpp +++ b/WebCore/platform/network/qt/SocketStreamHandleQt.cpp @@ -45,10 +45,17 @@ SocketStreamHandlePrivate::SocketStreamHandlePrivate(SocketStreamHandle* streamH m_streamHandle = streamHandle; m_socket = 0; bool isSecure = url.protocolIs("wss"); - if (isSecure) + + if (isSecure) { +#ifndef QT_NO_OPENSSL m_socket = new QSslSocket(this); - else +#endif + } else m_socket = new QTcpSocket(this); + + if (!m_socket) + return; + connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(m_socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead())); connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketClosed())); @@ -59,9 +66,11 @@ SocketStreamHandlePrivate::SocketStreamHandlePrivate(SocketStreamHandle* streamH unsigned int port = url.hasPort() ? url.port() : (isSecure ? 443 : 80); QString host = url.host(); - if (isSecure) + if (isSecure) { +#ifndef QT_NO_OPENSSL static_cast<QSslSocket*>(m_socket)->connectToHostEncrypted(host, port); - else +#endif + } else m_socket->connectToHost(host, port); } @@ -88,7 +97,7 @@ void SocketStreamHandlePrivate::socketReadyRead() int SocketStreamHandlePrivate::send(const char* data, int len) { - if (m_socket->state() != QAbstractSocket::ConnectedState) + if (!m_socket || m_socket->state() != QAbstractSocket::ConnectedState) return 0; quint64 sentSize = m_socket->write(data, len); QMetaObject::invokeMethod(this, "socketSentData", Qt::QueuedConnection); @@ -138,6 +147,7 @@ void SocketStreamHandlePrivate::socketErrorCallback(int error) } } +#ifndef QT_NO_OPENSSL void SocketStreamHandlePrivate::socketSslErrors(const QList<QSslError>&) { // FIXME: based on http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-68#page-15 @@ -145,6 +155,8 @@ void SocketStreamHandlePrivate::socketSslErrors(const QList<QSslError>&) // We don't abort while this is still work in progress. static_cast<QSslSocket*>(m_socket)->ignoreSslErrors(); } +#endif + SocketStreamHandle::SocketStreamHandle(const KURL& url, SocketStreamHandleClient* client) : SocketStreamHandleBase(url, client) { diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp index 83e3746..271c11a 100644 --- a/WebCore/platform/qt/RenderThemeQt.cpp +++ b/WebCore/platform/qt/RenderThemeQt.cpp @@ -129,7 +129,6 @@ PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page) RenderThemeQt::RenderThemeQt(Page* page) : RenderTheme() , m_page(page) - , m_fallbackStyle(0) { QPushButton button; button.setAttribute(Qt::WA_MacSmallSize); @@ -139,6 +138,8 @@ RenderThemeQt::RenderThemeQt(Page* page) #ifdef Q_WS_MAC m_buttonFontPixelSize = fontInfo.pixelSize(); #endif + + m_fallbackStyle = QStyleFactory::create(QLatin1String("windows")); } RenderThemeQt::~RenderThemeQt() @@ -147,19 +148,17 @@ RenderThemeQt::~RenderThemeQt() } // for some widget painting, we need to fallback to Windows style -QStyle* RenderThemeQt::fallbackStyle() +QStyle* RenderThemeQt::fallbackStyle() const { - if (!m_fallbackStyle) - m_fallbackStyle = QStyleFactory::create(QLatin1String("windows")); - - if (!m_fallbackStyle) - m_fallbackStyle = QApplication::style(); - - return m_fallbackStyle; + return (m_fallbackStyle) ? m_fallbackStyle : QApplication::style(); } QStyle* RenderThemeQt::qStyle() const { +#ifdef Q_WS_MAEMO_5 + return fallbackStyle(); +#endif + if (m_page) { QWebPageClient* pageClient = m_page->chrome()->client()->platformPageClient(); @@ -773,6 +772,11 @@ bool RenderThemeQt::supportsFocus(ControlPart appearance) const void RenderThemeQt::setPaletteFromPageClientIfExists(QPalette& palette) const { +#ifdef Q_WS_MAEMO_5 + static QPalette lightGrayPalette(Qt::lightGray); + palette = lightGrayPalette; + return; +#endif // If the webview has a custom palette, use it if (!m_page) return; diff --git a/WebCore/platform/qt/RenderThemeQt.h b/WebCore/platform/qt/RenderThemeQt.h index e6bab7e..5385881 100644 --- a/WebCore/platform/qt/RenderThemeQt.h +++ b/WebCore/platform/qt/RenderThemeQt.h @@ -145,7 +145,7 @@ private: void setPaletteFromPageClientIfExists(QPalette&) const; - QStyle* fallbackStyle(); + QStyle* fallbackStyle() const; Page* m_page; diff --git a/WebCore/platform/sql/SQLiteTransaction.cpp b/WebCore/platform/sql/SQLiteTransaction.cpp index a4b2ac8..a34613f 100644 --- a/WebCore/platform/sql/SQLiteTransaction.cpp +++ b/WebCore/platform/sql/SQLiteTransaction.cpp @@ -64,6 +64,11 @@ void SQLiteTransaction::begin() void SQLiteTransaction::commit() { + // FIXME: this code is buggy; it assumes that COMMIT always succeeds which is not the case: + // the transaction could've been silently rolled back before getting to the COMMIT statement + // (https://bugs.webkit.org/show_bug.cgi?id=34280). However, the rest of the code does not + // know how to deal with a premature rollback and a failed COMMIT at this moment, so until + // we figure out what to do with bug 34280, it's better to leave this code as it is. if (m_inProgress) { ASSERT(m_db.m_transactionInProgress); m_db.executeCommand("COMMIT;"); @@ -84,8 +89,10 @@ void SQLiteTransaction::rollback() void SQLiteTransaction::stop() { - m_inProgress = false; - m_db.m_transactionInProgress = false; + if (m_inProgress) { + m_inProgress = false; + m_db.m_transactionInProgress = false; + } } } // namespace WebCore diff --git a/WebCore/platform/text/brew/TextBreakIteratorInternalICUBrew.cpp b/WebCore/platform/text/brew/TextBreakIteratorInternalICUBrew.cpp new file mode 100644 index 0000000..4384411 --- /dev/null +++ b/WebCore/platform/text/brew/TextBreakIteratorInternalICUBrew.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Company 100, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + */ + +#include "config.h" +#include "TextBreakIteratorInternalICU.h" + +#include "NotImplemented.h" + +namespace WebCore { + +const char* currentSearchLocaleID() +{ + notImplemented(); + return ""; +} + +const char* currentTextBreakLocaleID() +{ + notImplemented(); + return "en_us"; +} + +} // namespace WebCore + diff --git a/WebCore/platform/wx/KeyEventWin.cpp b/WebCore/platform/wx/KeyEventWin.cpp index f8f0155..e69de29 100644 --- a/WebCore/platform/wx/KeyEventWin.cpp +++ b/WebCore/platform/wx/KeyEventWin.cpp @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "PlatformKeyboardEvent.h" -#include <windows.h> - -#define REPEAT_COUNT_MASK 0x0000FFFF -#define NEW_RELEASE_STATE_MASK 0x80000000 -#define PREVIOUS_DOWN_STATE_MASK 0x40000000 -#define ALT_KEY_DOWN_MASK 0x20000000 - -#define HIGH_BIT_MASK_SHORT 0x8000 - -namespace WebCore { - -// FIXME: This is incomplete. We should change this to mirror -// more like what Firefox does, and generate these switch statements -// at build time. -static String keyIdentifierForWindowsKeyCode(short keyCode) -{ - switch (keyCode) { - case VK_MENU: - return "Alt"; - case VK_CLEAR: - return "Clear"; - case VK_DOWN: - return "Down"; - // "End" - case VK_END: - return "End"; - // "Enter" - case VK_RETURN: - return "Enter"; - case VK_EXECUTE: - return "Execute"; - case VK_F1: - return "F1"; - case VK_F2: - return "F2"; - case VK_F3: - return "F3"; - case VK_F4: - return "F4"; - case VK_F5: - return "F5"; - case VK_F6: - return "F6"; - case VK_F7: - return "F7"; - case VK_F8: - return "F8"; - case VK_F9: - return "F9"; - case VK_F10: - return "F11"; - case VK_F12: - return "F12"; - case VK_F13: - return "F13"; - case VK_F14: - return "F14"; - case VK_F15: - return "F15"; - case VK_F16: - return "F16"; - case VK_F17: - return "F17"; - case VK_F18: - return "F18"; - case VK_F19: - return "F19"; - case VK_F20: - return "F20"; - case VK_F21: - return "F21"; - case VK_F22: - return "F22"; - case VK_F23: - return "F23"; - case VK_F24: - return "F24"; - case VK_HELP: - return "Help"; - case VK_HOME: - return "Home"; - case VK_INSERT: - return "Insert"; - case VK_LEFT: - return "Left"; - case VK_NEXT: - return "PageDown"; - case VK_PRIOR: - return "PageUp"; - case VK_PAUSE: - return "Pause"; - case VK_SNAPSHOT: - return "PrintScreen"; - case VK_RIGHT: - return "Right"; - case VK_SCROLL: - return "Scroll"; - case VK_SELECT: - return "Select"; - case VK_UP: - return "Up"; - // Standard says that DEL becomes U+007F. - case VK_DELETE: - return "U+007F"; - default: - return String::sprintf("U+%04X", toupper(keyCode)); - } -} - -static String singleCharacterString(UChar c) { return String(&c, 1); } - -PlatformKeyboardEvent::PlatformKeyboardEvent(HWND hWnd, WPARAM wParam, LPARAM lParam) - : m_text(singleCharacterString(wParam)) - , m_unmodifiedText(singleCharacterString(wParam)) - , m_keyIdentifier(keyIdentifierForWindowsKeyCode(wParam)) - , m_isKeyUp((lParam & NEW_RELEASE_STATE_MASK)) - , m_autoRepeat(lParam & REPEAT_COUNT_MASK) - , m_WindowsKeyCode(wParam) - , m_isKeypad(false) // FIXME - , m_shiftKey(GetAsyncKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT) - , m_ctrlKey(GetAsyncKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT) - , m_altKey(lParam & ALT_KEY_DOWN_MASK) - , m_metaKey(lParam & ALT_KEY_DOWN_MASK) // FIXME: Is this right? - , m_isModifierKeyPress(false) -{ - if (!m_shiftKey) - m_text = String(singleCharacterString(tolower(wParam))); -} - -} diff --git a/WebCore/plugins/symbian/PluginViewSymbian.cpp b/WebCore/plugins/symbian/PluginViewSymbian.cpp index 4a93e45..3492868 100644 --- a/WebCore/plugins/symbian/PluginViewSymbian.cpp +++ b/WebCore/plugins/symbian/PluginViewSymbian.cpp @@ -54,7 +54,7 @@ #include "npruntime_impl.h" #include "runtime_root.h" #include <QKeyEvent> -#include <QPixmap.h> +#include <QPixmap> #include <QRegion> #include <QVector> #include <QWidget> diff --git a/WebCore/rendering/MediaControlElements.cpp b/WebCore/rendering/MediaControlElements.cpp index 9c56756..2b7a8c8 100644 --- a/WebCore/rendering/MediaControlElements.cpp +++ b/WebCore/rendering/MediaControlElements.cpp @@ -504,7 +504,7 @@ void MediaControlSeekButtonElement::defaultEventHandler(Event* event) m_capturing = true; frame->eventHandler()->setCapturingMouseEventsNode(this); } - m_mediaElement->pause(); + m_mediaElement->pause(event->fromUserGesture()); m_seekTimer.startRepeating(cSeekRepeatDelay); event->setDefaultHandled(); } else if (event->type() == eventNames().mouseupEvent) { @@ -731,30 +731,9 @@ void MediaControlTimeDisplayElement::setVisible(bool visible) renderer()->setStyle(style.get()); } -String MediaControlTimeDisplayElement::formatTime(float time) -{ - if (!isfinite(time)) - time = 0; - int seconds = (int)fabsf(time); - int hours = seconds / (60 * 60); - int minutes = (seconds / 60) % 60; - seconds %= 60; - if (hours) { - if (hours > 9) - return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); - - return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); - } - - return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds); -} - void MediaControlTimeDisplayElement::setCurrentValue(float time) { m_currentValue = time; - - ExceptionCode ec; - setInnerText(formatTime(m_currentValue), ec); } diff --git a/WebCore/rendering/MediaControlElements.h b/WebCore/rendering/MediaControlElements.h index 0ba4aba..21831ce 100644 --- a/WebCore/rendering/MediaControlElements.h +++ b/WebCore/rendering/MediaControlElements.h @@ -268,8 +268,6 @@ public: float currentValue() const { return m_currentValue; } private: - String formatTime(float time); - float m_currentValue; bool m_isVisible; }; diff --git a/WebCore/rendering/RenderBoxModelObject.cpp b/WebCore/rendering/RenderBoxModelObject.cpp index f2cd9bd..a68c930 100644 --- a/WebCore/rendering/RenderBoxModelObject.cpp +++ b/WebCore/rendering/RenderBoxModelObject.cpp @@ -118,7 +118,7 @@ bool RenderBoxModelScaleObserver::shouldPaintBackgroundAtLowQuality(GraphicsCont { // If the image is not a bitmap image, then none of this is relevant and we just paint at high // quality. - if (!image->isBitmapImage()) + if (!image || !image->isBitmapImage()) return false; // Make sure to use the unzoomed image size, since if a full page zoom is in effect, the image diff --git a/WebCore/rendering/RenderCounter.cpp b/WebCore/rendering/RenderCounter.cpp index 46bf9f4..3cb9a07 100644 --- a/WebCore/rendering/RenderCounter.cpp +++ b/WebCore/rendering/RenderCounter.cpp @@ -430,7 +430,8 @@ static void updateCounters(RenderObject* renderer) continue; if (parent) parent->removeChild(node, it->first.get()); - newParent->insertAfter(node, newPreviousSibling, it->first.get()); + if (newParent) + newParent->insertAfter(node, newPreviousSibling, it->first.get()); } } diff --git a/WebCore/rendering/RenderFieldset.cpp b/WebCore/rendering/RenderFieldset.cpp index 1f2b371..889b0bc 100644 --- a/WebCore/rendering/RenderFieldset.cpp +++ b/WebCore/rendering/RenderFieldset.cpp @@ -119,6 +119,9 @@ RenderBox* RenderFieldset::findLegend() const void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { + if (!shouldPaintWithinRoot(paintInfo)) + return; + int w = width(); int h = height(); RenderBox* legend = findLegend(); diff --git a/WebCore/rendering/RenderImage.h b/WebCore/rendering/RenderImage.h index bc5e2d8..b89a652 100644 --- a/WebCore/rendering/RenderImage.h +++ b/WebCore/rendering/RenderImage.h @@ -64,6 +64,8 @@ protected: bool isWidthSpecified() const; bool isHeightSpecified() const; + virtual void intrinsicSizeChanged() { imageChanged(imagePtr()); } + private: virtual const char* renderName() const { return "RenderImage"; } @@ -89,8 +91,6 @@ private: virtual IntSize imageSize(float multiplier) const { return m_cachedImage ? m_cachedImage->imageSize(multiplier) : IntSize(); } virtual WrappedImagePtr imagePtr() const { return m_cachedImage.get(); } - virtual void intrinsicSizeChanged() { imageChanged(imagePtr()); } - int calcAspectRatioWidth() const; int calcAspectRatioHeight() const; diff --git a/WebCore/rendering/RenderMedia.cpp b/WebCore/rendering/RenderMedia.cpp index 8acebfb..7100435 100644 --- a/WebCore/rendering/RenderMedia.cpp +++ b/WebCore/rendering/RenderMedia.cpp @@ -412,10 +412,15 @@ void RenderMedia::updateTimeDisplay() { if (!m_currentTimeDisplay || !m_currentTimeDisplay->renderer() || m_currentTimeDisplay->renderer()->style()->display() == NONE || style()->visibility() != VISIBLE) return; + float now = mediaElement()->currentTime(); float duration = mediaElement()->duration(); + // Allow the theme to format the time + ExceptionCode ec; + m_currentTimeDisplay->setInnerText(theme()->formatMediaControlsCurrentTime(now, duration), ec); m_currentTimeDisplay->setCurrentValue(now); + m_timeRemainingDisplay->setInnerText(theme()->formatMediaControlsRemainingTime(now, duration), ec); m_timeRemainingDisplay->setCurrentValue(now - duration); } diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp index 677851e..61e05ad 100644 --- a/WebCore/rendering/RenderTable.cpp +++ b/WebCore/rendering/RenderTable.cpp @@ -552,6 +552,9 @@ void RenderTable::paintObject(PaintInfo& paintInfo, int tx, int ty) void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { + if (!shouldPaintWithinRoot(paintInfo)) + return; + int w = width(); int h = height(); diff --git a/WebCore/rendering/RenderTableCell.cpp b/WebCore/rendering/RenderTableCell.cpp index 2395527..39a821f 100644 --- a/WebCore/rendering/RenderTableCell.cpp +++ b/WebCore/rendering/RenderTableCell.cpp @@ -814,6 +814,9 @@ void RenderTableCell::paintCollapsedBorder(GraphicsContext* graphicsContext, int void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, int tx, int ty, RenderObject* backgroundObject) { + if (!shouldPaintWithinRoot(paintInfo)) + return; + if (!backgroundObject) return; @@ -853,6 +856,9 @@ void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, int tx, i void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, int tx, int ty) { + if (!shouldPaintWithinRoot(paintInfo)) + return; + RenderTable* tableElt = table(); if (!tableElt->collapseBorders() && style()->emptyCells() == HIDE && !firstChild()) return; diff --git a/WebCore/rendering/RenderTextControlMultiLine.cpp b/WebCore/rendering/RenderTextControlMultiLine.cpp index afc3edd..0b4c7a7 100644 --- a/WebCore/rendering/RenderTextControlMultiLine.cpp +++ b/WebCore/rendering/RenderTextControlMultiLine.cpp @@ -50,7 +50,7 @@ void RenderTextControlMultiLine::subtreeHasChanged() RenderTextControl::subtreeHasChanged(); HTMLTextAreaElement* textArea = static_cast<HTMLTextAreaElement*>(node()); textArea->setFormControlValueMatchesRenderer(false); - textArea->updateValidity(); + textArea->setNeedsValidityCheck(); if (!node()->focused()) return; diff --git a/WebCore/rendering/RenderTheme.cpp b/WebCore/rendering/RenderTheme.cpp index af92465..f1e564b 100644 --- a/WebCore/rendering/RenderTheme.cpp +++ b/WebCore/rendering/RenderTheme.cpp @@ -440,6 +440,35 @@ bool RenderTheme::shouldRenderMediaControlPart(ControlPart part, Element* e) return true; } } + +String RenderTheme::formatMediaControlsTime(float time) const +{ + if (!isfinite(time)) + time = 0; + int seconds = (int)fabsf(time); + int hours = seconds / (60 * 60); + int minutes = (seconds / 60) % 60; + seconds %= 60; + if (hours) { + if (hours > 9) + return String::format("%s%02d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); + + return String::format("%s%01d:%02d:%02d", (time < 0 ? "-" : ""), hours, minutes, seconds); + } + + return String::format("%s%02d:%02d", (time < 0 ? "-" : ""), minutes, seconds); +} + +String RenderTheme::formatMediaControlsCurrentTime(float currentTime, float /*duration*/) const +{ + return formatMediaControlsTime(currentTime); +} + +String RenderTheme::formatMediaControlsRemainingTime(float currentTime, float duration) const +{ + return formatMediaControlsTime(currentTime - duration); +} + #endif Color RenderTheme::activeSelectionBackgroundColor() const diff --git a/WebCore/rendering/RenderTheme.h b/WebCore/rendering/RenderTheme.h index a7c6e13..32ae5e5 100644 --- a/WebCore/rendering/RenderTheme.h +++ b/WebCore/rendering/RenderTheme.h @@ -175,6 +175,9 @@ public: virtual bool shouldRenderMediaControlPart(ControlPart, Element*); virtual double mediaControlsFadeInDuration() { return 0.1; } virtual double mediaControlsFadeOutDuration() { return 0.3; } + virtual String formatMediaControlsTime(float time) const; + virtual String formatMediaControlsCurrentTime(float currentTime, float duration) const; + virtual String formatMediaControlsRemainingTime(float currentTime, float duration) const; #endif protected: diff --git a/WebCore/rendering/RenderThemeChromiumLinux.cpp b/WebCore/rendering/RenderThemeChromiumLinux.cpp index f972a12..13c9cd6 100644 --- a/WebCore/rendering/RenderThemeChromiumLinux.cpp +++ b/WebCore/rendering/RenderThemeChromiumLinux.cpp @@ -25,8 +25,8 @@ #include "config.h" #include "RenderThemeChromiumLinux.h" -#include "Color.h" #include "CSSValueKeywords.h" +#include "Color.h" #include "RenderObject.h" #include "UserAgentStyleSheets.h" @@ -44,6 +44,8 @@ unsigned RenderThemeChromiumLinux::m_inactiveSelectionBackgroundColor = unsigned RenderThemeChromiumLinux::m_inactiveSelectionForegroundColor = 0xff323232; +double RenderThemeChromiumLinux::m_caretBlinkInterval; + PassRefPtr<RenderTheme> RenderThemeChromiumLinux::create() { return adoptRef(new RenderThemeChromiumLinux()); diff --git a/WebCore/rendering/RenderThemeChromiumLinux.h b/WebCore/rendering/RenderThemeChromiumLinux.h index 90b043d..c60dec3 100644 --- a/WebCore/rendering/RenderThemeChromiumLinux.h +++ b/WebCore/rendering/RenderThemeChromiumLinux.h @@ -56,7 +56,7 @@ namespace WebCore { virtual void adjustSliderThumbSize(RenderObject*) const; - void setCaretBlinkInterval(double interval); + static void setCaretBlinkInterval(double interval); virtual double caretBlinkIntervalInternal() const; static void setSelectionColors(unsigned activeBackgroundColor, @@ -78,7 +78,7 @@ namespace WebCore { // A general method asking if any control tinting is supported at all. virtual bool supportsControlTints() const; - double m_caretBlinkInterval; + static double m_caretBlinkInterval; static unsigned m_activeSelectionBackgroundColor; static unsigned m_activeSelectionForegroundColor; diff --git a/WebCore/rendering/RenderThemeChromiumMac.h b/WebCore/rendering/RenderThemeChromiumMac.h index 61b5e8f..8101038 100644 --- a/WebCore/rendering/RenderThemeChromiumMac.h +++ b/WebCore/rendering/RenderThemeChromiumMac.h @@ -191,7 +191,6 @@ private: mutable HashMap<int, RGBA32> m_systemColorCache; RetainPtr<WebCoreRenderThemeNotificationObserver> m_notificationObserver; - bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*); }; } // namespace WebCore diff --git a/WebCore/rendering/RenderThemeChromiumMac.mm b/WebCore/rendering/RenderThemeChromiumMac.mm index 4e57cb5..e274b05 100644 --- a/WebCore/rendering/RenderThemeChromiumMac.mm +++ b/WebCore/rendering/RenderThemeChromiumMac.mm @@ -41,7 +41,7 @@ #import "RenderSlider.h" #import "RenderView.h" #import "SharedBuffer.h" -#import "UserAgentStyleSheets.h" +#import "TimeRanges.h" #import "WebCoreSystemInterface.h" #import "UserAgentStyleSheets.h" #import <Carbon/Carbon.h> @@ -78,7 +78,7 @@ using std::min; // The methods in this file are specific to the Mac OS X platform. -// FIXME: The platform-independent code in this class should be factored out and merged with RenderThemeSafari. +// FIXME: The platform-independent code in this class should be factored out and merged with RenderThemeSafari. @interface WebCoreRenderThemeNotificationObserver : NSObject { @@ -96,7 +96,7 @@ using std::min; { [super init]; _theme = theme; - + return self; } @@ -322,7 +322,7 @@ static RGBA32 convertNSColorToColor(NSColor *color) static_cast<int>(scaleFactor * [colorInColorSpace blueComponent])); } - // This conversion above can fail if the NSColor in question is an NSPatternColor + // This conversion above can fail if the NSColor in question is an NSPatternColor // (as many system colors are). These colors are actually a repeating pattern // not just a solid color. To work around this we simply draw a 1x1 image of // the color and use that pixel's color. It might be better to use an average of @@ -390,7 +390,7 @@ Color RenderThemeChromiumMac::systemColor(int cssValueId) const { if (m_systemColorCache.contains(cssValueId)) return m_systemColorCache.get(cssValueId); - + Color color; switch (cssValueId) { case CSSValueActiveborder: @@ -504,7 +504,7 @@ bool RenderThemeChromiumMac::isControlStyled(const RenderStyle* style, const Bor { if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart || style->appearance() == ListboxPart) return style->border() != border; - + // FIXME: This is horrible, but there is not much else that can be done. Menu lists cannot draw properly when // scaled. They can't really draw properly when transformed either. We can't detect the transform case at style // adjustment time so that will just have to stay broken. We can however detect that we're zooming. If zooming @@ -518,13 +518,14 @@ bool RenderThemeChromiumMac::isControlStyled(const RenderStyle* style, const Bor void RenderThemeChromiumMac::adjustRepaintRect(const RenderObject* o, IntRect& r) { ControlPart part = o->style()->appearance(); - + #if USE(NEW_THEME) switch (part) { case CheckboxPart: case RadioPart: case PushButtonPart: case SquareButtonPart: + case ListButtonPart: case DefaultButtonPart: case ButtonPart: return RenderTheme::adjustRepaintRect(o, r); @@ -565,7 +566,7 @@ IntRect RenderThemeChromiumMac::inflateRect(const IntRect& r, const IntSize& siz FloatRect RenderThemeChromiumMac::convertToPaintingRect(const RenderObject* inputRenderer, const RenderObject* partRenderer, const FloatRect& inputRect, const IntRect& r) const { FloatRect partRect(inputRect); - + // Compute an offset between the part renderer and the input renderer FloatSize offsetFromInputRenderer; const RenderObject* renderer = partRenderer; @@ -760,7 +761,7 @@ bool RenderThemeChromiumMac::paintCapsLockIndicator(RenderObject*, const RenderO LocalCurrentGraphicsContext localContext(paintInfo.context); wkDrawCapsLockIndicator(paintInfo.context->platformContext(), r); - + return false; } @@ -820,7 +821,7 @@ bool RenderThemeChromiumMac::paintMenuList(RenderObject* o, const RenderObject:: inflatedRect = inflateRect(inflatedRect, size, popupButtonMargins(), zoomLevel); paintInfo.context->save(); - + #ifndef BUILDING_ON_TIGER // On Leopard, the cell will draw outside of the given rect, so we have to clip to the rect paintInfo.context->clip(inflatedRect); @@ -980,10 +981,10 @@ bool RenderThemeChromiumMac::paintMenuListButton(RenderObject* o, const RenderOb if (bounds.width() < arrowWidth + arrowPaddingLeft * o->style()->effectiveZoom()) return false; - + paintInfo.context->save(); - paintInfo.context->setFillColor(o->style()->color(), DeviceColorSpace); + paintInfo.context->setFillColor(o->style()->color(), o->style()->colorSpace()); paintInfo.context->setStrokeStyle(NoStroke); FloatPoint arrow1[3]; @@ -1036,7 +1037,7 @@ void RenderThemeChromiumMac::adjustMenuListStyle(CSSStyleSelector* selector, Ren style->resetBorder(); style->resetPadding(); - + // Height is locked to auto. style->setHeight(Length(Auto)); @@ -1106,7 +1107,7 @@ void RenderThemeChromiumMac::adjustMenuListButtonStyle(CSSStyleSelector*, Render const int minHeight = 15; style->setMinHeight(Length(minHeight, Fixed)); - + style->setLineHeight(RenderStyle::initialLineHeight()); } @@ -1136,6 +1137,9 @@ int RenderThemeChromiumMac::minimumMenuListSize(RenderStyle* style) const return sizeForSystemFont(style, menuListSizes()).width(); } +const int trackWidth = 5; +const int trackRadius = 2; + void RenderThemeChromiumMac::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element*) const { style->setBoxShadow(0); @@ -1143,9 +1147,6 @@ void RenderThemeChromiumMac::adjustSliderTrackStyle(CSSStyleSelector*, RenderSty bool RenderThemeChromiumMac::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { - static const int trackWidth = 5; - static const int trackRadius = 2; - IntRect bounds = r; float zoomLevel = o->style()->effectiveZoom(); float zoomedTrackWidth = trackWidth * zoomLevel; @@ -1179,7 +1180,7 @@ bool RenderThemeChromiumMac::paintSliderTrack(RenderObject* o, const RenderObjec radius, radius); CGContextDrawShading(context, mainShading.get()); paintInfo.context->restore(); - + return false; } @@ -1201,7 +1202,7 @@ bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObjec LocalCurrentGraphicsContext localContext(paintInfo.context); // Update the various states we respond to. - updateActiveState(sliderThumbCell, o); + updateActiveState(sliderThumbCell, o->parent()); updateEnabledState(sliderThumbCell, o->parent()); updateFocusedState(sliderThumbCell, o->parent()); @@ -1233,7 +1234,7 @@ bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObjec paintInfo.context->save(); float zoomLevel = o->style()->effectiveZoom(); - + FloatRect unzoomedRect = bounds; if (zoomLevel != 1.0f) { unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); @@ -1251,22 +1252,6 @@ bool RenderThemeChromiumMac::paintSliderThumb(RenderObject* o, const RenderObjec return false; } -void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const -{ - static const int sliderThumbWidth = 15; - static const int sliderThumbHeight = 15; - - float zoomLevel = o->style()->effectiveZoom(); - if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->appearance() == SliderThumbVerticalPart) { - o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fixed)); - o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel), Fixed)); - } - -#if ENABLE(VIDEO) - RenderMediaControlsChromium::adjustMediaSliderThumbSize(o); -#endif -} - bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r) { NSSearchFieldCell* search = this->search(); @@ -1279,7 +1264,7 @@ bool RenderThemeChromiumMac::paintSearchField(RenderObject* o, const RenderObjec float zoomLevel = o->style()->effectiveZoom(); IntRect unzoomedRect = r; - + if (zoomLevel != 1.0f) { unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); unzoomedRect.setHeight(unzoomedRect.height() / zoomLevel); @@ -1328,7 +1313,7 @@ void RenderThemeChromiumMac::setSearchFieldSize(RenderStyle* style) const // If the width and height are both specified, then we have nothing to do. if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) return; - + // Use the font size to determine the intrinsic width of the control. setSizeFromFont(style, searchFieldSizes()); } @@ -1345,19 +1330,19 @@ void RenderThemeChromiumMac::adjustSearchFieldStyle(CSSStyleSelector* selector, style->setBorderBottomWidth(borderWidth); style->setBorderBottomStyle(INSET); style->setBorderTopWidth(borderWidth); - style->setBorderTopStyle(INSET); - + style->setBorderTopStyle(INSET); + // Override height. style->setHeight(Length(Auto)); setSearchFieldSize(style); - + // Override padding size to match AppKit text positioning. const int padding = 1 * style->effectiveZoom(); style->setPaddingLeft(Length(padding, Fixed)); style->setPaddingRight(Length(padding, Fixed)); style->setPaddingTop(Length(padding, Fixed)); style->setPaddingBottom(Length(padding, Fixed)); - + NSControlSize controlSize = controlSizeForFont(style); setFontFromControlSize(selector, style, controlSize); @@ -1495,7 +1480,7 @@ bool RenderThemeChromiumMac::paintSearchFieldResultsButton(RenderObject* o, cons FloatRect localBounds = [search searchButtonRectForBounds:NSRect(input->renderBox()->borderBoxRect())]; localBounds = convertToPaintingRect(input->renderer(), o, localBounds, r); - + IntRect unzoomedRect(localBounds); if (zoomLevel != 1.0f) { unzoomedRect.setWidth(unzoomedRect.width() / zoomLevel); @@ -1507,12 +1492,28 @@ bool RenderThemeChromiumMac::paintSearchFieldResultsButton(RenderObject* o, cons [[search searchButtonCell] drawWithFrame:unzoomedRect inView:FlippedView()]; [[search searchButtonCell] setControlView:nil]; - + paintInfo.context->restore(); return false; } +const int sliderThumbWidth = 15; +const int sliderThumbHeight = 15; + +void RenderThemeChromiumMac::adjustSliderThumbSize(RenderObject* o) const +{ + float zoomLevel = o->style()->effectiveZoom(); + if (o->style()->appearance() == SliderThumbHorizontalPart || o->style()->appearance() == SliderThumbVerticalPart) { + o->style()->setWidth(Length(static_cast<int>(sliderThumbWidth * zoomLevel), Fixed)); + o->style()->setHeight(Length(static_cast<int>(sliderThumbHeight * zoomLevel), Fixed)); + } + +#if ENABLE(VIDEO) + RenderMediaControlsChromium::adjustMediaSliderThumbSize(o); +#endif +} + #if ENABLE(VIDEO) bool RenderThemeChromiumMac::shouldRenderMediaControlPart(ControlPart part, Element* e) { @@ -1553,7 +1554,7 @@ bool RenderThemeChromiumMac::paintMediaControlsBackground(RenderObject* object, { return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect); } - + String RenderThemeChromiumMac::extraMediaControlsStyleSheet() { return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet)); @@ -1568,7 +1569,7 @@ NSPopUpButtonCell* RenderThemeChromiumMac::popupButton() const [m_popupButton.get() setUsesItemFromMenu:NO]; [m_popupButton.get() setFocusRingType:NSFocusRingTypeExterior]; } - + return m_popupButton.get(); } @@ -1602,7 +1603,7 @@ NSSliderCell* RenderThemeChromiumMac::sliderThumbHorizontal() const [m_sliderThumbHorizontal.get() setControlSize:NSSmallControlSize]; [m_sliderThumbHorizontal.get() setFocusRingType:NSFocusRingTypeExterior]; } - + return m_sliderThumbHorizontal.get(); } @@ -1615,7 +1616,7 @@ NSSliderCell* RenderThemeChromiumMac::sliderThumbVertical() const [m_sliderThumbVertical.get() setControlSize:NSSmallControlSize]; [m_sliderThumbVertical.get() setFocusRingType:NSFocusRingTypeExterior]; } - + return m_sliderThumbVertical.get(); } diff --git a/WebCore/rendering/RenderVideo.cpp b/WebCore/rendering/RenderVideo.cpp index d2a9620..813f2ef 100644 --- a/WebCore/rendering/RenderVideo.cpp +++ b/WebCore/rendering/RenderVideo.cpp @@ -85,7 +85,7 @@ RenderVideo::~RenderVideo() void RenderVideo::intrinsicSizeChanged() { if (videoElement()->shouldDisplayPosterImage()) - RenderVideo::intrinsicSizeChanged(); + RenderMedia::intrinsicSizeChanged(); videoSizeChanged(); } @@ -104,7 +104,7 @@ void RenderVideo::videoSizeChanged() void RenderVideo::imageChanged(WrappedImagePtr newImage, const IntRect* rect) { - RenderImage::imageChanged(newImage, rect); + RenderMedia::imageChanged(newImage, rect); // Cache the image intrinsic size so we can continue to use it to draw the image correctly // even after we know the video intrisic size but aren't able to draw video frames yet diff --git a/WebCore/storage/SQLTransaction.cpp b/WebCore/storage/SQLTransaction.cpp index de615ca..db25e1a 100644 --- a/WebCore/storage/SQLTransaction.cpp +++ b/WebCore/storage/SQLTransaction.cpp @@ -35,6 +35,7 @@ #include "Database.h" #include "DatabaseAuthorizer.h" #include "DatabaseDetails.h" +#include "DatabaseThread.h" #include "ExceptionCode.h" #include "Logging.h" #include "Page.h" @@ -83,6 +84,7 @@ SQLTransaction::SQLTransaction(Database* db, PassRefPtr<SQLTransactionCallback> SQLTransaction::~SQLTransaction() { + ASSERT(!m_sqliteTransaction); } void SQLTransaction::executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments, PassRefPtr<SQLStatementCallback> callback, PassRefPtr<SQLStatementErrorCallback> callbackError, ExceptionCode& e) @@ -203,6 +205,16 @@ void SQLTransaction::performPendingCallback() (this->*m_nextStep)(); } +void SQLTransaction::notifyDatabaseThreadIsShuttingDown() +{ + ASSERT(currentThread() == database()->scriptExecutionContext()->databaseThread()->getThreadID()); + + // If the transaction is in progress, we should roll it back here, since this is our last + // oportunity to do something related to this transaction on the DB thread. + // Clearing m_sqliteTransaction invokes SQLiteTransaction's destructor which does just that. + m_sqliteTransaction.clear(); +} + void SQLTransaction::acquireLock() { m_database->transactionCoordinator()->acquireLock(this); @@ -491,6 +503,7 @@ void SQLTransaction::cleanupAfterSuccessCallback() // There is no next step LOG(StorageAPI, "Transaction %p is complete\n", this); ASSERT(!m_database->m_sqliteDatabase.transactionInProgress()); + m_sqliteTransaction.clear(); m_nextStep = 0; // Release the lock on this database diff --git a/WebCore/storage/SQLTransaction.h b/WebCore/storage/SQLTransaction.h index 6d6a8d7..1b02d01 100644 --- a/WebCore/storage/SQLTransaction.h +++ b/WebCore/storage/SQLTransaction.h @@ -80,6 +80,7 @@ public: Database* database() { return m_database.get(); } bool isReadOnly() { return m_readOnly; } + void notifyDatabaseThreadIsShuttingDown(); private: SQLTransaction(Database*, PassRefPtr<SQLTransactionCallback>, PassRefPtr<SQLTransactionErrorCallback>, diff --git a/WebCore/storage/SQLTransactionCoordinator.cpp b/WebCore/storage/SQLTransactionCoordinator.cpp index efdcd1d..0fe5bda 100644 --- a/WebCore/storage/SQLTransactionCoordinator.cpp +++ b/WebCore/storage/SQLTransactionCoordinator.cpp @@ -109,6 +109,20 @@ void SQLTransactionCoordinator::releaseLock(SQLTransaction* transaction) void SQLTransactionCoordinator::shutdown() { + // Notify all transactions in progress that the database thread is shutting down + for (CoordinationInfoMap::iterator coordinationInfoIterator = m_coordinationInfoMap.begin(); + coordinationInfoIterator != m_coordinationInfoMap.end(); ++coordinationInfoIterator) { + CoordinationInfo& info = coordinationInfoIterator->second; + if (info.activeWriteTransaction) + info.activeWriteTransaction->notifyDatabaseThreadIsShuttingDown(); + for (HashSet<RefPtr<SQLTransaction> >::iterator activeReadTransactionsIterator = + info.activeReadTransactions.begin(); + activeReadTransactionsIterator != info.activeReadTransactions.end(); + ++activeReadTransactionsIterator) { + (*activeReadTransactionsIterator)->notifyDatabaseThreadIsShuttingDown(); + } + } + // Clean up all pending transactions for all databases m_coordinationInfoMap.clear(); } diff --git a/WebCore/websockets/WebSocket.cpp b/WebCore/websockets/WebSocket.cpp index 0435490..f50dc5c 100644 --- a/WebCore/websockets/WebSocket.cpp +++ b/WebCore/websockets/WebSocket.cpp @@ -151,6 +151,7 @@ void WebSocket::connect(const KURL& url, const String& protocol, ExceptionCode& m_channel = ThreadableWebSocketChannel::create(scriptExecutionContext(), this, m_url, m_protocol); m_channel->connect(); + ActiveDOMObject::setPendingActivity(this); } bool WebSocket::send(const String& message, ExceptionCode& ec) @@ -198,6 +199,26 @@ ScriptExecutionContext* WebSocket::scriptExecutionContext() const return ActiveDOMObject::scriptExecutionContext(); } +void WebSocket::contextDestroyed() +{ + LOG(Network, "WebSocket %p scriptExecutionContext destroyed", this); + ASSERT(!m_channel); + ASSERT(m_state == CLOSED); + ActiveDOMObject::contextDestroyed(); +} + +void WebSocket::stop() +{ + bool pending = hasPendingActivity(); + if (m_channel) + m_channel->disconnect(); + m_channel = 0; + m_state = CLOSED; + ActiveDOMObject::stop(); + if (pending) + ActiveDOMObject::unsetPendingActivity(this); +} + void WebSocket::didConnect() { LOG(Network, "WebSocket %p didConnect", this); @@ -224,6 +245,9 @@ void WebSocket::didClose() LOG(Network, "WebSocket %p didClose", this); m_state = CLOSED; dispatchEvent(Event::create(eventNames().closeEvent, false, false)); + m_channel = 0; + if (hasPendingActivity()) + ActiveDOMObject::unsetPendingActivity(this); } EventTargetData* WebSocket::eventTargetData() diff --git a/WebCore/websockets/WebSocket.h b/WebCore/websockets/WebSocket.h index 18e2b25..c72dbbd 100644 --- a/WebCore/websockets/WebSocket.h +++ b/WebCore/websockets/WebSocket.h @@ -82,6 +82,8 @@ namespace WebCore { virtual WebSocket* toWebSocket() { return this; } virtual ScriptExecutionContext* scriptExecutionContext() const; + virtual void contextDestroyed(); + virtual void stop(); using RefCounted<WebSocket>::ref; using RefCounted<WebSocket>::deref; diff --git a/WebCore/websockets/WebSocketChannel.cpp b/WebCore/websockets/WebSocketChannel.cpp index 5c0f4c3..df66c14 100644 --- a/WebCore/websockets/WebSocketChannel.cpp +++ b/WebCore/websockets/WebSocketChannel.cpp @@ -141,6 +141,7 @@ void WebSocketChannel::didClose(SocketStreamHandle* handle) void WebSocketChannel::didReceiveData(SocketStreamHandle* handle, const char* data, int len) { LOG(Network, "WebSocketChannel %p didReceiveData %d", this, len); + RefPtr<WebSocketChannel> protect(this); // The client can close the channel, potentially removing the last reference. ASSERT(handle == m_handle); if (!appendToBuffer(data, len)) { handle->close(); diff --git a/WebCore/workers/DefaultSharedWorkerRepository.cpp b/WebCore/workers/DefaultSharedWorkerRepository.cpp index 655b90e..e4fa5d3 100644 --- a/WebCore/workers/DefaultSharedWorkerRepository.cpp +++ b/WebCore/workers/DefaultSharedWorkerRepository.cpp @@ -248,7 +248,7 @@ private: }; // Loads the script on behalf of a worker. -class SharedWorkerScriptLoader : public RefCounted<SharedWorkerScriptLoader>, public ActiveDOMObject, private WorkerScriptLoaderClient { +class SharedWorkerScriptLoader : public RefCounted<SharedWorkerScriptLoader>, private WorkerScriptLoaderClient { public: SharedWorkerScriptLoader(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, PassRefPtr<SharedWorkerProxy>); void load(const KURL&); @@ -264,8 +264,7 @@ private: }; SharedWorkerScriptLoader::SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, PassRefPtr<SharedWorkerProxy> proxy) - : ActiveDOMObject(worker->scriptExecutionContext(), this) - , m_worker(worker) + : m_worker(worker) , m_port(port) , m_proxy(proxy) { @@ -274,25 +273,27 @@ SharedWorkerScriptLoader::SharedWorkerScriptLoader(PassRefPtr<SharedWorker> work void SharedWorkerScriptLoader::load(const KURL& url) { // Mark this object as active for the duration of the load. - ASSERT(!hasPendingActivity()); m_scriptLoader = new WorkerScriptLoader(); - m_scriptLoader->loadAsynchronously(scriptExecutionContext(), url, DenyCrossOriginRequests, this); + m_scriptLoader->loadAsynchronously(m_worker->scriptExecutionContext(), url, DenyCrossOriginRequests, this); - // Stay alive until the load finishes. - setPendingActivity(this); + // Stay alive (and keep the SharedWorker and JS wrapper alive) until the load finishes. + this->ref(); m_worker->setPendingActivity(m_worker.get()); } void SharedWorkerScriptLoader::notifyFinished() { + // FIXME: This method is not guaranteed to be invoked if we are loading from WorkerContext (see comment for WorkerScriptLoaderClient::notifyFinished()). + // We need to address this before supporting nested workers. + // Hand off the just-loaded code to the repository to start up the worker thread. if (m_scriptLoader->failed()) m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true)); else - DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), m_port.release()); + DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, m_worker->scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), m_port.release()); m_worker->unsetPendingActivity(m_worker.get()); - unsetPendingActivity(this); // This frees this object - must be the last action in this function. + this->deref(); // This frees this object - must be the last action in this function. } DefaultSharedWorkerRepository& DefaultSharedWorkerRepository::instance() diff --git a/WebCore/workers/WorkerScriptLoaderClient.h b/WebCore/workers/WorkerScriptLoaderClient.h index e3903c0..7dc3a1e 100644 --- a/WebCore/workers/WorkerScriptLoaderClient.h +++ b/WebCore/workers/WorkerScriptLoaderClient.h @@ -34,8 +34,10 @@ namespace WebCore { class WorkerScriptLoaderClient { public: + // FIXME: notifyFinished() is not currently guaranteed to be invoked if used from worker context and the worker shuts down in the middle of an operation. + // This will cause leaks when we support nested workers. virtual void notifyFinished() { } - + protected: virtual ~WorkerScriptLoaderClient() { } }; diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog index 6a8e76a..58c37a8 100644 --- a/WebKit/chromium/ChangeLog +++ b/WebKit/chromium/ChangeLog @@ -1,3 +1,322 @@ +2010-02-04 Yury Semikhatsky <yurys@chromium.org> + + Unreviewed. Revert 54333 which broke Chromium build. + + * WebKit.gyp: + * tests/TransparencyWinTest.cpp: Removed. + * tests/UniscribeHelperTest.cpp: Removed. + +2010-02-04 Yaar Schnitman <yaar@chromium.org> + + Reviewed by Darin Fisher. + + Upstreaming gtests from chromium: UniscribeHelper and TransparencyWin. + https://bugs.webkit.org/show_bug.cgi?id=34509 + + * WebKit.gyp: + * tests/TransparencyWinTest.cpp: Added. + (WebCore::RECTToFloatRect): + (WebCore::drawNativeRect): + (WebCore::getPixelAt): + (WebCore::clearTopLayerAlphaChannel): + (WebCore::clearTopLayerAlphaPixel): + (WebCore::operator<<): + (WebCore::TEST): + * tests/UniscribeHelperTest.cpp: Added. + (WebCore::UniscribeTest::UniscribeTest): + (WebCore::UniscribeTest::MakeFont): + (WebCore::UniscribeTest::SetUp): + (WebCore::UniscribeTest::TearDown): + (WebCore::TEST_F): + +2010-02-04 Jeremy Moskovich <jeremy@chromium.org> + + Reviewed by David Levin. + + [Chromium] WebKit side of "Writing direction" context menu on OS X. + https://bugs.webkit.org/show_bug.cgi?id=34524 + + * public/WebContextMenuData.h: + (WebKit::WebContextMenuData::): + * src/ContextMenuClientImpl.cpp: + (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems): + +2010-02-03 Drew Wilson <atwilson@chromium.org> + + Reviewed by Alexey Proskuryakov. + + SharedWorkerScriptLoader should not be an ActiveDOMObject + https://bugs.webkit.org/show_bug.cgi?id=34513 + + * src/SharedWorkerRepository.cpp: + (WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader): + Changed SharedWorkerScriptLoader to manage its own lifecycle without using ActiveDOMObject. + (WebCore::SharedWorkerScriptLoader::parentContext): + (WebCore::pendingLoaders): + Now we manually track pending loads so we can shut them down when the parent context shuts down. + (WebCore::SharedWorkerScriptLoader::contextDetached): + Shuts down/frees any pending worker loads. + (WebCore::SharedWorkerScriptLoader::~SharedWorkerScriptLoader): + Marks the SharedWorker object as not having pending activity if there was a load active (handles case where load was pending when parent document exits). + (WebCore::SharedWorkerScriptLoader::load): + (WebCore::SharedWorkerRepository::documentDetached): + Now calls SharedWorkerScriptLoader::contextDetached() to shutdown any pending worker loads. + +2010-02-03 Alexander Pavlov <apavlov@chromium.org> + + Reviewed by Timothy Hatcher. + + [Chromium] Return a consistent set of platforms from WebDevToolsFrontendImpl + https://bugs.webkit.org/show_bug.cgi?id=34523 + + * src/WebDevToolsFrontendImpl.cpp: + (WebKit::WebDevToolsFrontendImpl::jsPlatform): + +2010-02-02 Joel Stanley <joel@jms.id.au> + + Reviewed by David Levin. + + [Chromium] Add API method for setting caret blink frequency. + https://bugs.webkit.org/show_bug.cgi?id=31704 + + This enables the RenderThemeChromiumLinux::setCaretBlinkInterval method + to be called Chromium's API. The API is linux-only as it is currently + the only port to implement RenderTheme::setCaretBlinkInterval. + + * WebKit.gyp: Add WebRenderTheme.{h,cpp} + * public/linux/WebRenderTheme.h: Added. + * src/linux/WebRenderTheme.cpp: Added. + (WebKit::setCaretBlinkInterval): Exposed API + +2010-02-02 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Dimitri Glazkov. + + [Chromium] Implement WebFrameImpl::pageNumberForElementById + https://bugs.webkit.org/show_bug.cgi?id=34471 + + * public/WebFrame.h: + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::pageNumberForElementById): + * src/WebFrameImpl.h: + +2010-02-02 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Upstream DevTools code. + + https://bugs.webkit.org/show_bug.cgi?id=34326 + + * WebKit.gyp: + * src/APUAgentDelegate.h: Added. + * src/BoundObject.cpp: Added. + (WebKit::BoundObject::BoundObject): + (WebKit::BoundObject::~BoundObject): + (WebKit::BoundObject::addProtoFunction): + (WebKit::BoundObject::build): + * src/BoundObject.h: Added. + * src/DebuggerAgent.h: Added. + * src/DebuggerAgentImpl.cpp: Added. + (WebKit::DebuggerAgentImpl::DebuggerAgentImpl): + (WebKit::DebuggerAgentImpl::~DebuggerAgentImpl): + (WebKit::DebuggerAgentImpl::getContextId): + (WebKit::DebuggerAgentImpl::debuggerOutput): + (WebKit::DebuggerAgentImpl::createUtilityContext): + (WebKit::DebuggerAgentImpl::executeUtilityFunction): + (WebKit::DebuggerAgentImpl::executeVoidJavaScript): + (WebKit::DebuggerAgentImpl::page): + * src/DebuggerAgentImpl.h: Added. + (WebKit::DebuggerAgentImpl::setAutoContinueOnException): + (WebKit::DebuggerAgentImpl::autoContinueOnException): + (WebKit::DebuggerAgentImpl::webdevtoolsAgent): + (WebKit::DebuggerAgentImpl::webView): + * src/DebuggerAgentManager.cpp: Added. + (WebKit::DebuggerAgentManager::debugHostDispatchHandler): + (WebKit::DebuggerAgentManager::debugAttach): + (WebKit::DebuggerAgentManager::debugDetach): + (WebKit::DebuggerAgentManager::onV8DebugMessage): + (WebKit::DebuggerAgentManager::pauseScript): + (WebKit::DebuggerAgentManager::executeDebuggerCommand): + (WebKit::DebuggerAgentManager::setMessageLoopDispatchHandler): + (WebKit::DebuggerAgentManager::setHostId): + (WebKit::DebuggerAgentManager::onWebViewClosed): + (WebKit::DebuggerAgentManager::onNavigate): + (WebKit::DebuggerAgentManager::sendCommandToV8): + (WebKit::DebuggerAgentManager::sendContinueCommandToV8): + (WebKit::DebuggerAgentManager::findAgentForCurrentV8Context): + (WebKit::DebuggerAgentManager::debuggerAgentForHostId): + * src/DebuggerAgentManager.h: Added. + (WebKit::DebuggerAgentManager::UtilityContextScope::UtilityContextScope): + (WebKit::DebuggerAgentManager::UtilityContextScope::~UtilityContextScope): + * src/DevToolsRPC.h: Added. + (WebKit::): + (WebKit::DevToolsRPC::Delegate::Delegate): + (WebKit::DevToolsRPC::Delegate::~Delegate): + (WebKit::DevToolsRPC::DevToolsRPC): + (WebKit::DevToolsRPC::~DevToolsRPC): + (WebKit::DevToolsRPC::sendRpcMessage): + * src/DevToolsRPCJS.h: Added. + * src/ProfilerAgent.h: Added. + * src/ProfilerAgentImpl.cpp: Added. + (WebKit::ProfilerAgentImpl::getActiveProfilerModules): + (WebKit::ProfilerAgentImpl::getLogLines): + * src/ProfilerAgentImpl.h: Added. + (WebKit::ProfilerAgentImpl::ProfilerAgentImpl): + (WebKit::ProfilerAgentImpl::~ProfilerAgentImpl): + * src/ToolsAgent.h: Added. + * src/WebDevToolsAgentImpl.cpp: Added. + (WebKit::): + (WebKit::WebDevToolsAgentImpl::WebDevToolsAgentImpl): + (WebKit::WebDevToolsAgentImpl::~WebDevToolsAgentImpl): + (WebKit::WebDevToolsAgentImpl::disposeUtilityContext): + (WebKit::WebDevToolsAgentImpl::unhideResourcesPanelIfNecessary): + (WebKit::WebDevToolsAgentImpl::attach): + (WebKit::WebDevToolsAgentImpl::detach): + (WebKit::WebDevToolsAgentImpl::didNavigate): + (WebKit::WebDevToolsAgentImpl::didCommitProvisionalLoad): + (WebKit::WebDevToolsAgentImpl::didClearWindowObject): + (WebKit::WebDevToolsAgentImpl::forceRepaint): + (WebKit::WebDevToolsAgentImpl::dispatchOnInspectorController): + (WebKit::WebDevToolsAgentImpl::dispatchOnInjectedScript): + (WebKit::WebDevToolsAgentImpl::executeVoidJavaScript): + (WebKit::WebDevToolsAgentImpl::dispatchMessageFromFrontend): + (WebKit::WebDevToolsAgentImpl::inspectElementAt): + (WebKit::WebDevToolsAgentImpl::setRuntimeFeatureEnabled): + (WebKit::WebDevToolsAgentImpl::sendRpcMessage): + (WebKit::WebDevToolsAgentImpl::compileUtilityScripts): + (WebKit::WebDevToolsAgentImpl::initDevToolsAgentHost): + (WebKit::WebDevToolsAgentImpl::createInspectorBackendV8Wrapper): + (WebKit::WebDevToolsAgentImpl::resetInspectorFrontendProxy): + (WebKit::WebDevToolsAgentImpl::setApuAgentEnabled): + (WebKit::WebDevToolsAgentImpl::jsDispatchOnClient): + (WebKit::WebDevToolsAgentImpl::jsDispatchToApu): + (WebKit::WebDevToolsAgentImpl::jsEvaluateOnSelf): + (WebKit::WebDevToolsAgentImpl::jsOnRuntimeFeatureStateChanged): + (WebKit::WebDevToolsAgentImpl::inspectorController): + (WebKit::WebDevToolsAgentImpl::identifierForInitialRequest): + (WebKit::WebDevToolsAgentImpl::willSendRequest): + (WebKit::WebDevToolsAgentImpl::didReceiveData): + (WebKit::WebDevToolsAgentImpl::didReceiveResponse): + (WebKit::WebDevToolsAgentImpl::didFinishLoading): + (WebKit::WebDevToolsAgentImpl::didFailLoading): + (WebKit::WebDevToolsAgentImpl::evaluateInWebInspector): + (WebKit::WebDevToolsAgentImpl::setTimelineProfilingEnabled): + (WebKit::WebDevToolsAgent::create): + (WebKit::WebDevToolsAgent::executeDebuggerCommand): + (WebKit::WebDevToolsAgent::debuggerPauseScript): + (WebKit::WebDevToolsAgent::setMessageLoopDispatchHandler): + (WebKit::WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread): + * src/WebDevToolsAgentImpl.h: Added. + (WebKit::WebDevToolsAgentImpl::hostId): + * src/WebDevToolsFrontendImpl.cpp: Added. + (WebKit::ToV8String): + (WebKit::WebDevToolsFrontend::create): + (WebKit::WebDevToolsFrontendImpl::WebDevToolsFrontendImpl): + (WebKit::WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl): + (WebKit::WebDevToolsFrontendImpl::dispatchMessageFromAgent): + (WebKit::WebDevToolsFrontendImpl::executeScript): + (WebKit::WebDevToolsFrontendImpl::dispatchOnWebInspector): + (WebKit::WebDevToolsFrontendImpl::sendRpcMessage): + (WebKit::WebDevToolsFrontendImpl::contextMenuItemSelected): + (WebKit::WebDevToolsFrontendImpl::contextMenuCleared): + (WebKit::WebDevToolsFrontendImpl::jsLoaded): + (WebKit::WebDevToolsFrontendImpl::jsPlatform): + (WebKit::WebDevToolsFrontendImpl::jsPort): + (WebKit::WebDevToolsFrontendImpl::jsCopyText): + (WebKit::WebDevToolsFrontendImpl::jsActivateWindow): + (WebKit::WebDevToolsFrontendImpl::jsCloseWindow): + (WebKit::WebDevToolsFrontendImpl::jsDockWindow): + (WebKit::WebDevToolsFrontendImpl::jsUndockWindow): + (WebKit::WebDevToolsFrontendImpl::jsLocalizedStringsURL): + (WebKit::WebDevToolsFrontendImpl::jsHiddenPanels): + (WebKit::WebDevToolsFrontendImpl::jsDebuggerCommand): + (WebKit::WebDevToolsFrontendImpl::jsSetting): + (WebKit::WebDevToolsFrontendImpl::jsSetSetting): + (WebKit::WebDevToolsFrontendImpl::jsDebuggerPauseScript): + (WebKit::WebDevToolsFrontendImpl::jsWindowUnloading): + (WebKit::WebDevToolsFrontendImpl::jsShowContextMenu): + * src/WebDevToolsFrontendImpl.h: Added. + (WebKit::WebDevToolsFrontendImpl::MenuProvider::create): + (WebKit::WebDevToolsFrontendImpl::MenuProvider::~MenuProvider): + (WebKit::WebDevToolsFrontendImpl::MenuProvider::disconnect): + (WebKit::WebDevToolsFrontendImpl::MenuProvider::populateContextMenu): + (WebKit::WebDevToolsFrontendImpl::MenuProvider::contextMenuItemSelected): + (WebKit::WebDevToolsFrontendImpl::MenuProvider::contextMenuCleared): + (WebKit::WebDevToolsFrontendImpl::MenuProvider::MenuProvider): + +2010-02-01 Jeremy Orlow <jorlow@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Add WebSecurityOrigin::createFromString factory + https://bugs.webkit.org/show_bug.cgi?id=34460 + + * public/WebSecurityOrigin.h: + * src/WebSecurityOrigin.cpp: + (WebKit::WebSecurityOrigin::createFromString): + +2010-02-02 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Fisher. + + [Chromium] Should not select a word on right-click. + https://bugs.webkit.org/show_bug.cgi?id=33364 + + For non-Mac platforms, do not select a word around the caret when + a context menu is opening. This behavior is not common in non-Mac + platforms, and it prevents pasting with a context menu. + + In order that the spell checker works without the selection, we + introduce WebFrame::selectWordAroundCaret(). We can replace a word + around the caret with selectWordAroundCaret() + replaceSelection(). + + * public/WebFrame.h: Add pure selectWordAroundCaret() declaration. + * src/ContextMenuClientImpl.cpp: + (WebKit::selectMisspelledWord): Move word-selection code to + WebFrameImpl::selectWordAroundPosition(), and clear the selection + on non-Mac. + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::selectWordAroundPosition): + (WebKit::WebFrameImpl::selectWordAroundCaret): + * src/WebFrameImpl.h: Add selectWordAroundCaret() declaration. + +2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> + + Unreviewed attempt to fix the broken build. + + This was introduced in http://trac.webkit.org/changeset/54182 + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::performMediaPlayerAction): + +2010-01-27 Matt Perry <mpcomplete@chromium.org> + + Reviewed by Eric Seidel. + + Add support for addUserScript to chromium port. + + * public/WebView.h: + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::addUserScript): + (WebKit::WebViewImpl::removeAllUserContent): + * src/WebViewImpl.h: + +2010-01-29 Philippe Normand <pnormand@igalia.com> + + Reviewed by Eric Carlson. + + [GTK] set playbin mute property depending on volume value + https://bugs.webkit.org/show_bug.cgi?id=31586 + + New API in MediaPlayer for mute control + + * public/WebMediaPlayerClient.h: + * src/WebMediaPlayerClientImpl.cpp: + (WebKit::WebMediaPlayerClientImpl::volumeChanged): + (WebKit::WebMediaPlayerClientImpl::muteChanged): + * src/WebMediaPlayerClientImpl.h: + 2010-01-31 Kent Tamura <tkent@chromium.org> Reviewed by Jeremy Orlow. @@ -12,6 +331,17 @@ 2010-01-29 Jeremy Orlow <jorlow@chromium.org> + Reviewed by Eric Seidel. + + [Chromium] Clean up WebStorageArea + https://bugs.webkit.org/show_bug.cgi?id=34353 + + Get rid of legacy glue code and fix a typo. + + * public/WebStorageArea.h: + +2010-01-29 Jeremy Orlow <jorlow@chromium.org> + Reviewed by Dimitri Glazkov. A first step towards the Indexed Database API diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp index 3b5a17f..4f6d3f6 100644 --- a/WebKit/chromium/WebKit.gyp +++ b/WebKit/chromium/WebKit.gyp @@ -70,6 +70,7 @@ 'sources': [ 'public/gtk/WebInputEventFactory.h', 'public/linux/WebFontRendering.h', + 'public/linux/WebRenderTheme.h', 'public/x11/WebScreenInfoFactory.h', 'public/mac/WebInputEventFactory.h', 'public/mac/WebScreenInfoFactory.h', @@ -192,6 +193,7 @@ 'public/win/WebSandboxSupport.h', 'public/win/WebScreenInfoFactory.h', 'public/win/WebScreenInfoFactory.h', + 'src/APUAgentDelegate.h', 'src/ApplicationCacheHost.cpp', 'src/ApplicationCacheHostInternal.h', 'src/AssertMatchingEnums.cpp', @@ -199,6 +201,8 @@ 'src/AutocompletePopupMenuClient.h', 'src/BackForwardListClientImpl.cpp', 'src/BackForwardListClientImpl.h', + 'src/BoundObject.cpp', + 'src/BoundObject.h', 'src/ChromeClientImpl.cpp', 'src/ChromeClientImpl.h', 'src/ChromiumBridge.cpp', @@ -207,6 +211,13 @@ 'src/ContextMenuClientImpl.cpp', 'src/ContextMenuClientImpl.h', 'src/DatabaseObserver.cpp', + 'src/DebuggerAgent.h', + 'src/DebuggerAgentImpl.cpp', + 'src/DebuggerAgentImpl.h', + 'src/DebuggerAgentManager.cpp', + 'src/DebuggerAgentManager.h', + 'src/DevToolsRPC.h', + 'src/DevToolsRPCJS.h', 'src/DOMUtilitiesPrivate.cpp', 'src/DOMUtilitiesPrivate.h', 'src/DragClientImpl.cpp', @@ -223,6 +234,7 @@ 'src/InspectorClientImpl.cpp', 'src/InspectorClientImpl.h', 'src/linux/WebFontRendering.cpp', + 'src/linux/WebRenderTheme.cpp', 'src/x11/WebScreenInfoFactory.cpp', 'src/mac/WebInputEventFactory.mm', 'src/mac/WebScreenInfoFactory.mm', @@ -232,6 +244,9 @@ 'src/NotificationPresenterImpl.cpp', 'src/PlatformMessagePortChannel.cpp', 'src/PlatformMessagePortChannel.h', + 'src/ProfilerAgent.h', + 'src/ProfilerAgentImpl.cpp', + 'src/ProfilerAgentImpl.h', 'src/ResourceHandle.cpp', 'src/SharedWorkerRepository.cpp', 'src/SocketStreamHandle.cpp', @@ -243,6 +258,7 @@ 'src/StorageNamespaceProxy.cpp', 'src/StorageNamespaceProxy.h', 'src/TemporaryGlue.h', + 'src/ToolsAgent.h', 'src/WebAccessibilityCache.cpp', 'src/WebAccessibilityCacheImpl.cpp', 'src/WebAccessibilityCacheImpl.h', @@ -259,6 +275,10 @@ 'src/WebDatabase.cpp', 'src/WebDataSourceImpl.cpp', 'src/WebDataSourceImpl.h', + 'src/WebDevToolsAgentImpl.cpp', + 'src/WebDevToolsAgentImpl.h', + 'src/WebDevToolsFrontendImpl.cpp', + 'src/WebDevToolsFrontendImpl.h', 'src/WebDocument.cpp', 'src/WebDragData.cpp', 'src/WebElement.cpp', diff --git a/WebKit/chromium/public/WebContextMenuData.h b/WebKit/chromium/public/WebContextMenuData.h index b4acb1c..049da9c 100644 --- a/WebKit/chromium/public/WebContextMenuData.h +++ b/WebKit/chromium/public/WebContextMenuData.h @@ -97,6 +97,18 @@ struct WebContextMenuData { // Whether context is editable. bool isEditable; + enum CheckableMenuItemFlags { + CheckableMenuItemDisabled = 0x0, + CheckableMenuItemEnabled = 0x1, + CheckableMenuItemChecked = 0x2, + }; + + // Writing direction menu items. + // Currently only used on OS X. + int writingDirectionDefault; + int writingDirectionLeftToRight; + int writingDirectionRightToLeft; + enum EditFlags { CanDoNone = 0x0, CanUndo = 0x1, diff --git a/WebKit/chromium/public/WebFrame.h b/WebKit/chromium/public/WebFrame.h index 4197c23..a56e6cb 100644 --- a/WebKit/chromium/public/WebFrame.h +++ b/WebKit/chromium/public/WebFrame.h @@ -357,6 +357,11 @@ public: virtual WebString selectionAsText() const = 0; virtual WebString selectionAsMarkup() const = 0; + // Expands the selection to a word around the caret and returns + // true. Does nothing and returns false if there is no caret or + // there is ranged selection. + virtual bool selectWordAroundCaret() = 0; + // Printing ------------------------------------------------------------ @@ -478,6 +483,13 @@ public: // used to support layout tests. virtual WebString counterValueForElementById(const WebString& id) const = 0; + + // Returns the number of page where the specified element will be put. + // This method is used to support layout tests. + virtual int pageNumberForElementById(const WebString& id, + float pageWidthInPixels, + float pageHeightInPixels) const = 0; + protected: ~WebFrame() { } }; diff --git a/WebKit/chromium/public/WebMediaPlayerClient.h b/WebKit/chromium/public/WebMediaPlayerClient.h index 558fb4a..47ce64e 100644 --- a/WebKit/chromium/public/WebMediaPlayerClient.h +++ b/WebKit/chromium/public/WebMediaPlayerClient.h @@ -40,7 +40,8 @@ class WebMediaPlayerClient { public: virtual void networkStateChanged() = 0; virtual void readyStateChanged() = 0; - virtual void volumeChanged() = 0; + virtual void volumeChanged(float) = 0; + virtual void muteChanged(bool) = 0; virtual void timeChanged() = 0; virtual void repaint() = 0; virtual void durationChanged() = 0; diff --git a/WebKit/chromium/public/WebSecurityOrigin.h b/WebKit/chromium/public/WebSecurityOrigin.h index 7b04aac..1285b10 100644 --- a/WebKit/chromium/public/WebSecurityOrigin.h +++ b/WebKit/chromium/public/WebSecurityOrigin.h @@ -55,7 +55,9 @@ public: return *this; } + // FIXME: This should return a WebSecurityOrigin, not a pointer to one. WEBKIT_API static WebSecurityOrigin* createFromDatabaseIdentifier(const WebString& databaseIdentifier); + WEBKIT_API static WebSecurityOrigin createFromString(const WebString&); WEBKIT_API void reset(); WEBKIT_API void assign(const WebSecurityOrigin&); diff --git a/WebKit/chromium/public/WebStorageArea.h b/WebKit/chromium/public/WebStorageArea.h index 302e10c..19d98c6 100644 --- a/WebKit/chromium/public/WebStorageArea.h +++ b/WebKit/chromium/public/WebStorageArea.h @@ -57,44 +57,17 @@ public: // no entry for that key. virtual WebString getItem(const WebString& key) = 0; - // Set the value that corresponds to a specific key. QuotaException is set if we've + // Set the value that corresponds to a specific key. QuotaException is set if // the StorageArea would have exceeded its quota. The value is NOT set when there's // an exception. url is the url that should be used if a storage event fires. - // FIXME: The following is a hack to keep Chromium compiling until the other half is landed. Remove soon. - virtual void setItem(const WebString& key, const WebString& newValue, const WebURL& url, bool& quotaException) // Deprecated. - { - WebString oldValue; - setItem(key, newValue, url, quotaException, oldValue); - } - virtual void setItem(const WebString& key, const WebString& newValue, const WebURL& url, bool& quotaException, WebString& oldValue) - { - setItem(key, newValue, url, quotaException); - } + virtual void setItem(const WebString& key, const WebString& newValue, const WebURL& url, bool& quotaException, WebString& oldValue) = 0; // Remove the value associated with a particular key. url is the url that should be used // if a storage event fires. - // FIXME: The following is a hack to keep Chromium compiling until the other half is landed. Remove soon. - virtual void removeItem(const WebString& key, const WebURL& url) // Deprecated. - { - WebString oldValue; - removeItem(key, url, oldValue); - } - virtual void removeItem(const WebString& key, const WebURL& url, WebString& oldValue) - { - removeItem(key, url); - } + virtual void removeItem(const WebString& key, const WebURL& url, WebString& oldValue) = 0; // Clear all key/value pairs. url is the url that should be used if a storage event fires. - // FIXME: The following is a hack to keep Chromium compiling until the other half is landed. Remove soon. - virtual void clear(const WebURL& url) // Deprecated. - { - bool somethingCleared; - clear(url, somethingCleared); - } - virtual void clear(const WebURL& url, bool& somethingCleared) - { - clear(url); - } + virtual void clear(const WebURL& url, bool& somethingCleared) = 0; }; } // namespace WebKit diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h index aba556c..7b3294f 100644 --- a/WebKit/chromium/public/WebView.h +++ b/WebKit/chromium/public/WebView.h @@ -262,6 +262,10 @@ public: unsigned inactiveBackgroundColor, unsigned inactiveForegroundColor) = 0; + // User scripts -------------------------------------------------------- + virtual void addUserScript(const WebString& sourceCode, + bool runAtStart) = 0; + virtual void removeAllUserContent() = 0; // Modal dialog support ------------------------------------------------ diff --git a/WebKit/chromium/public/linux/WebRenderTheme.h b/WebKit/chromium/public/linux/WebRenderTheme.h new file mode 100644 index 0000000..e3be69d --- /dev/null +++ b/WebKit/chromium/public/linux/WebRenderTheme.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2009 Joel Stanley. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebRenderTheme_h +#define WebRenderTheme_h + +#include "../WebCommon.h" + +namespace WebKit { + +// Set caret blink interval for text input areas. +WEBKIT_API void setCaretBlinkInterval(double); + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/APUAgentDelegate.h b/WebKit/chromium/src/APUAgentDelegate.h new file mode 100644 index 0000000..70be702 --- /dev/null +++ b/WebKit/chromium/src/APUAgentDelegate.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef APUAgentDelegate_h +#define APUAgentDelegate_h + +#include "DevToolsRPC.h" + +namespace WebKit { + +#define APU_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, MEHTOD4, METHOD5) \ + /* Sends a json object to apu. */ \ + METHOD1(dispatchToApu, String /* data */) + +DEFINE_RPC_CLASS(ApuAgentDelegate, APU_AGENT_DELEGATE_STRUCT) + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/BoundObject.cpp b/WebKit/chromium/src/BoundObject.cpp new file mode 100644 index 0000000..90096c2 --- /dev/null +++ b/WebKit/chromium/src/BoundObject.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BoundObject.h" + +#include "V8Proxy.h" + +namespace WebKit { + +BoundObject::BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName) + : m_objectName(objectName) + , m_context(context) + , m_v8This(v8This) +{ + v8::Context::Scope contextScope(context); + v8::Local<v8::FunctionTemplate> localTemplate = v8::FunctionTemplate::New(WebCore::V8Proxy::checkNewLegal); + m_hostTemplate = v8::Persistent<v8::FunctionTemplate>::New(localTemplate); + m_hostTemplate->SetClassName(v8::String::New(objectName)); +} + +BoundObject::~BoundObject() +{ + m_hostTemplate.Dispose(); +} + +void BoundObject::addProtoFunction(const char* name, v8::InvocationCallback callback) +{ + v8::Context::Scope contextScope(m_context); + v8::Local<v8::Signature> signature = v8::Signature::New(m_hostTemplate); + v8::Local<v8::ObjectTemplate> proto = m_hostTemplate->PrototypeTemplate(); + v8::Local<v8::External> v8This = v8::External::New(m_v8This); + proto->Set( + v8::String::New(name), + v8::FunctionTemplate::New( + callback, + v8This, + signature), + static_cast<v8::PropertyAttribute>(v8::DontDelete)); +} + +void BoundObject::build() +{ + v8::Context::Scope contextScope(m_context); + v8::Local<v8::Function> constructor = m_hostTemplate->GetFunction(); + v8::Local<v8::Object> boundObject = WebCore::SafeAllocation::newInstance(constructor); + + v8::Handle<v8::Object> global = m_context->Global(); + global->Set(v8::String::New(m_objectName), boundObject); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/BoundObject.h b/WebKit/chromium/src/BoundObject.h new file mode 100644 index 0000000..769e83f --- /dev/null +++ b/WebKit/chromium/src/BoundObject.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef BoundObject_h +#define BoundObject_h + +#include <v8.h> +#include <wtf/Noncopyable.h> + +namespace WebKit { + +// BoundObject is a helper class that lets you map JavaScript method calls +// directly to C++ method calls. It should be destroyed once JS object is +// built. +class BoundObject : public Noncopyable { +public: + BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName); + virtual ~BoundObject(); + + void addProtoFunction(const char* name, v8::InvocationCallback callback); + void build(); + +private: + v8::HandleScope m_handleScope; + const char* m_objectName; + v8::Handle<v8::Context> m_context; + v8::Persistent<v8::FunctionTemplate> m_hostTemplate; + void* m_v8This; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/ContextMenuClientImpl.cpp b/WebKit/chromium/src/ContextMenuClientImpl.cpp index 72b861f..8472082 100644 --- a/WebKit/chromium/src/ContextMenuClientImpl.cpp +++ b/WebKit/chromium/src/ContextMenuClientImpl.cpp @@ -31,6 +31,8 @@ #include "config.h" #include "ContextMenuClientImpl.h" +#include "CSSPropertyNames.h" +#include "CSSStyleDeclaration.h" #include "ContextMenu.h" #include "Document.h" #include "DocumentLoader.h" @@ -89,7 +91,7 @@ static bool isASingleWord(const String& text) // Helper function to get misspelled word on which context menu // is to be evolked. This function also sets the word on which context menu // has been evoked to be the selected word, as required. This function changes -// the selection only when there were no selected characters. +// the selection only when there were no selected characters on OS X. static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame) { // First select from selectedText to check for multiple word selection. @@ -110,27 +112,21 @@ static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* select VisiblePosition pos(innerNode->renderer()->positionForPoint( hitTestResult.localPoint())); - VisibleSelection selection; - if (pos.isNotNull()) { - selection = VisibleSelection(pos); - selection.expandUsingGranularity(WordGranularity); - } - - if (selection.isRange()) - selectedFrame->setSelectionGranularity(WordGranularity); - - if (selectedFrame->shouldChangeSelection(selection)) - selectedFrame->selection()->setSelection(selection); + if (pos.isNull()) + return misspelledWord; // It is empty. + WebFrameImpl::selectWordAroundPosition(selectedFrame, pos); misspelledWord = selectedFrame->selectedText().stripWhiteSpace(); +#if OS(DARWIN) // If misspelled word is still empty, then that portion should not be // selected. Set the selection to that position only, and do not expand. - if (misspelledWord.isEmpty()) { - selection = VisibleSelection(pos); - selectedFrame->selection()->setSelection(selection); - } - + if (misspelledWord.isEmpty()) + selectedFrame->selection()->setSelection(VisibleSelection(pos)); +#else + // On non-Mac, right-click should not make a range selection in any case. + selectedFrame->selection()->setSelection(VisibleSelection(pos)); +#endif return misspelledWord; } @@ -207,6 +203,22 @@ PlatformMenuDescription ContextMenuClientImpl::getCustomMenuFromDefaultItems( } } +#if OS(DARWIN) + // Writing direction context menu. + data.writingDirectionDefault = WebContextMenuData::CheckableMenuItemDisabled; + data.writingDirectionLeftToRight = WebContextMenuData::CheckableMenuItemEnabled; + data.writingDirectionRightToLeft = WebContextMenuData::CheckableMenuItemEnabled; + + ExceptionCode ec = 0; + RefPtr<CSSStyleDeclaration> style = selectedFrame->document()->createCSSStyleDeclaration(); + style->setProperty(CSSPropertyDirection, "ltr", false, ec); + if (selectedFrame->editor()->selectionHasStyle(style.get()) != FalseTriState) + data.writingDirectionLeftToRight |= WebContextMenuData::CheckableMenuItemChecked; + style->setProperty(CSSPropertyDirection, "rtl", false, ec); + if (selectedFrame->editor()->selectionHasStyle(style.get()) != FalseTriState) + data.writingDirectionRightToLeft |= WebContextMenuData::CheckableMenuItemChecked; +#endif // OS(DARWIN) + // Now retrieve the security info. DocumentLoader* dl = selectedFrame->loader()->documentLoader(); WebDataSource* ds = WebDataSourceImpl::fromDocumentLoader(dl); diff --git a/WebKit/chromium/src/DebuggerAgent.h b/WebKit/chromium/src/DebuggerAgent.h new file mode 100644 index 0000000..cac9686 --- /dev/null +++ b/WebKit/chromium/src/DebuggerAgent.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DebuggerAgent_h +#define DebuggerAgent_h + +#include "DevToolsRPC.h" + +namespace WebKit { + +#define DEBUGGER_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4, METHOD5) \ + /* Requests global context id of the inspected tab. */ \ + METHOD0(getContextId) + +DEFINE_RPC_CLASS(DebuggerAgent, DEBUGGER_AGENT_STRUCT) + +#define DEBUGGER_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4, METHOD5) \ + METHOD1(debuggerOutput, String /* output text */) \ + \ + /* Pushes debugger context id into the client. */ \ + METHOD1(setContextId, int /* context id */) + +DEFINE_RPC_CLASS(DebuggerAgentDelegate, DEBUGGER_AGENT_DELEGATE_STRUCT) + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/DebuggerAgentImpl.cpp b/WebKit/chromium/src/DebuggerAgentImpl.cpp new file mode 100644 index 0000000..0c3d1ea --- /dev/null +++ b/WebKit/chromium/src/DebuggerAgentImpl.cpp @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DebuggerAgentImpl.h" + +#include "DebuggerAgentManager.h" +#include "Document.h" +#include "Frame.h" +#include "Page.h" +#include "V8Binding.h" +#include "V8DOMWindow.h" +#include "V8Index.h" +#include "V8Proxy.h" +#include "WebDevToolsAgentImpl.h" +#include "WebViewImpl.h" +#include <wtf/HashSet.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> + +using WebCore::DOMWindow; +using WebCore::Document; +using WebCore::Frame; +using WebCore::Page; +using WebCore::String; +using WebCore::V8ClassIndex; +using WebCore::V8Custom; +using WebCore::V8DOMWindow; +using WebCore::V8DOMWrapper; +using WebCore::V8Proxy; + +namespace WebKit { + +DebuggerAgentImpl::DebuggerAgentImpl( + WebViewImpl* webViewImpl, + DebuggerAgentDelegate* delegate, + WebDevToolsAgentImpl* webdevtoolsAgent) + : m_webViewImpl(webViewImpl) + , m_delegate(delegate) + , m_webdevtoolsAgent(webdevtoolsAgent) + , m_autoContinueOnException(false) +{ + DebuggerAgentManager::debugAttach(this); +} + +DebuggerAgentImpl::~DebuggerAgentImpl() +{ + DebuggerAgentManager::debugDetach(this); +} + +void DebuggerAgentImpl::getContextId() +{ + m_delegate->setContextId(m_webdevtoolsAgent->hostId()); +} + +void DebuggerAgentImpl::debuggerOutput(const String& command) +{ + m_delegate->debuggerOutput(command); + m_webdevtoolsAgent->forceRepaint(); +} + +// static +void DebuggerAgentImpl::createUtilityContext(Frame* frame, v8::Persistent<v8::Context>* context) +{ + v8::HandleScope scope; + + // Set up the DOM window as the prototype of the new global object. + v8::Handle<v8::Context> windowContext = V8Proxy::context(frame); + v8::Handle<v8::Object> windowGlobal = windowContext->Global(); + v8::Handle<v8::Object> windowWrapper = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, windowGlobal); + + ASSERT(V8DOMWindow::toNative(windowWrapper) == frame->domWindow()); + + v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New(); + + // TODO(yurys): provide a function in v8 bindings that would make the + // utility context more like main world context of the inspected frame, + // otherwise we need to manually make it satisfy various invariants + // that V8Proxy::getEntered and some other V8Proxy methods expect to find + // on v8 contexts on the contexts stack. + // See V8Proxy::createNewContext. + // + // Install a security handler with V8. + globalTemplate->SetAccessCheckCallbacks( + V8DOMWindow::namedSecurityCheck, + V8DOMWindow::indexedSecurityCheck, + v8::Integer::New(V8ClassIndex::DOMWINDOW)); + // We set number of internal fields to match that in V8DOMWindow wrapper. + // See http://crbug.com/28961 + globalTemplate->SetInternalFieldCount(V8DOMWindow::internalFieldCount); + + *context = v8::Context::New(0 /* no extensions */, globalTemplate, v8::Handle<v8::Object>()); + v8::Context::Scope contextScope(*context); + v8::Handle<v8::Object> global = (*context)->Global(); + + v8::Handle<v8::String> implicitProtoString = v8::String::New("__proto__"); + global->Set(implicitProtoString, windowWrapper); + + // Give the code running in the new context a way to get access to the + // original context. + global->Set(v8::String::New("contentWindow"), windowGlobal); +} + +String DebuggerAgentImpl::executeUtilityFunction( + v8::Handle<v8::Context> context, + int callId, + const char* object, + const String &functionName, + const String& jsonArgs, + bool async, + String* exception) +{ + v8::HandleScope scope; + ASSERT(!context.IsEmpty()); + if (context.IsEmpty()) { + *exception = "No window context."; + return ""; + } + v8::Context::Scope contextScope(context); + + DebuggerAgentManager::UtilityContextScope utilityScope; + + v8::Handle<v8::Object> dispatchObject = v8::Handle<v8::Object>::Cast( + context->Global()->Get(v8::String::New(object))); + + v8::Handle<v8::Value> dispatchFunction = dispatchObject->Get(v8::String::New("dispatch")); + ASSERT(dispatchFunction->IsFunction()); + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatchFunction); + + v8::Handle<v8::String> functionNameWrapper = v8::Handle<v8::String>( + v8::String::New(functionName.utf8().data())); + v8::Handle<v8::String> jsonArgsWrapper = v8::Handle<v8::String>( + v8::String::New(jsonArgs.utf8().data())); + v8::Handle<v8::Number> callIdWrapper = v8::Handle<v8::Number>( + v8::Number::New(async ? callId : 0)); + + v8::Handle<v8::Value> args[] = { + functionNameWrapper, + jsonArgsWrapper, + callIdWrapper + }; + + v8::TryCatch tryCatch; + v8::Handle<v8::Value> resObj = function->Call(context->Global(), 3, args); + if (tryCatch.HasCaught()) { + v8::Local<v8::Message> message = tryCatch.Message(); + if (message.IsEmpty()) + *exception = "Unknown exception"; + else + *exception = WebCore::toWebCoreString(message->Get()); + return ""; + } + return WebCore::toWebCoreStringWithNullCheck(resObj); +} + +void DebuggerAgentImpl::executeVoidJavaScript(v8::Handle<v8::Context> context) +{ + v8::HandleScope scope; + ASSERT(!context.IsEmpty()); + v8::Context::Scope contextScope(context); + DebuggerAgentManager::UtilityContextScope utilityScope; + + v8::Handle<v8::Value> function = + context->Global()->Get(v8::String::New("devtools$$void")); + ASSERT(function->IsFunction()); + v8::Handle<v8::Value> args[] = { + v8::Local<v8::Value>() + }; + v8::Handle<v8::Function>::Cast(function)->Call(context->Global(), 0, args); +} + +WebCore::Page* DebuggerAgentImpl::page() +{ + return m_webViewImpl->page(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/DebuggerAgentImpl.h b/WebKit/chromium/src/DebuggerAgentImpl.h new file mode 100644 index 0000000..65dc14c --- /dev/null +++ b/WebKit/chromium/src/DebuggerAgentImpl.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DebuggerAgentImpl_h +#define DebuggerAgentImpl_h + +#include "DebuggerAgent.h" + +#include <v8.h> +#include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> + +namespace WebCore { +class Document; +class Frame; +class Node; +class Page; +class String; +} + +namespace WebKit { + +class WebDevToolsAgentImpl; +class WebViewImpl; + +class DebuggerAgentImpl : public DebuggerAgent { +public: + // Creates utility context with injected js agent. + static void createUtilityContext(WebCore::Frame* frame, v8::Persistent<v8::Context>* context); + + DebuggerAgentImpl(WebKit::WebViewImpl* webViewImpl, + DebuggerAgentDelegate* delegate, + WebDevToolsAgentImpl* webdevtoolsAgent); + virtual ~DebuggerAgentImpl(); + + // DebuggerAgent implementation. + virtual void getContextId(); + + void debuggerOutput(const WebCore::String& out); + + void setAutoContinueOnException(bool autoContinue) { m_autoContinueOnException = autoContinue; } + + bool autoContinueOnException() { return m_autoContinueOnException; } + + // Executes function with the given name in the utility context. Passes node + // and json args as parameters. Note that the function called must be + // implemented in the inject_dispatch.js file. + WebCore::String executeUtilityFunction( + v8::Handle<v8::Context> context, + int callId, + const char* object, + const WebCore::String& functionName, + const WebCore::String& jsonArgs, + bool async, + WebCore::String* exception); + + // Executes a no-op function in the utility context. We don't use + // executeUtilityFunction for that to avoid script evaluation leading to + // undesirable AfterCompile events. + void executeVoidJavaScript(v8::Handle<v8::Context> context); + + WebCore::Page* page(); + WebDevToolsAgentImpl* webdevtoolsAgent() { return m_webdevtoolsAgent; } + + WebKit::WebViewImpl* webView() { return m_webViewImpl; } + +private: + WebKit::WebViewImpl* m_webViewImpl; + DebuggerAgentDelegate* m_delegate; + WebDevToolsAgentImpl* m_webdevtoolsAgent; + bool m_autoContinueOnException; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/DebuggerAgentManager.cpp b/WebKit/chromium/src/DebuggerAgentManager.cpp new file mode 100644 index 0000000..faafaff --- /dev/null +++ b/WebKit/chromium/src/DebuggerAgentManager.cpp @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DebuggerAgentManager.h" + +#include "DebuggerAgentImpl.h" +#include "Frame.h" +#include "PageGroupLoadDeferrer.h" +#include "V8Proxy.h" +#include "WebDevToolsAgentImpl.h" +#include "WebFrameImpl.h" +#include "WebViewImpl.h" +#include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> + +namespace WebKit { + +WebDevToolsAgent::MessageLoopDispatchHandler DebuggerAgentManager::s_messageLoopDispatchHandler = 0; + +bool DebuggerAgentManager::s_inHostDispatchHandler = false; + +DebuggerAgentManager::DeferrersMap DebuggerAgentManager::s_pageDeferrers; + +bool DebuggerAgentManager::s_inUtilityContext = false; + +bool DebuggerAgentManager::s_debugBreakDelayed = false; + +namespace { + +class CallerIdWrapper : public v8::Debug::ClientData, public Noncopyable { +public: + CallerIdWrapper() : m_callerIsMananager(true), m_callerId(0) { } + explicit CallerIdWrapper(int callerId) + : m_callerIsMananager(false) + , m_callerId(callerId) { } + ~CallerIdWrapper() { } + bool callerIsMananager() const { return m_callerIsMananager; } + int callerId() const { return m_callerId; } +private: + bool m_callerIsMananager; + int m_callerId; +}; + +} // namespace + + +void DebuggerAgentManager::debugHostDispatchHandler() +{ + if (!s_messageLoopDispatchHandler || !s_attachedAgentsMap) + return; + + if (s_inHostDispatchHandler) + return; + + s_inHostDispatchHandler = true; + + Vector<WebViewImpl*> views; + // 1. Disable active objects and input events. + for (AttachedAgentsMap::iterator it = s_attachedAgentsMap->begin(); it != s_attachedAgentsMap->end(); ++it) { + DebuggerAgentImpl* agent = it->second; + s_pageDeferrers.set(agent->webView(), new WebCore::PageGroupLoadDeferrer(agent->page(), true)); + views.append(agent->webView()); + agent->webView()->setIgnoreInputEvents(true); + } + + // 2. Process messages. + s_messageLoopDispatchHandler(); + + // 3. Bring things back. + for (Vector<WebViewImpl*>::iterator it = views.begin(); it != views.end(); ++it) { + if (s_pageDeferrers.contains(*it)) { + // The view was not closed during the dispatch. + (*it)->setIgnoreInputEvents(false); + } + } + deleteAllValues(s_pageDeferrers); + s_pageDeferrers.clear(); + + s_inHostDispatchHandler = false; + if (!s_attachedAgentsMap) { + // Remove handlers if all agents were detached within host dispatch. + v8::Debug::SetMessageHandler(0); + v8::Debug::SetHostDispatchHandler(0); + } +} + +DebuggerAgentManager::AttachedAgentsMap* DebuggerAgentManager::s_attachedAgentsMap = 0; + +void DebuggerAgentManager::debugAttach(DebuggerAgentImpl* debuggerAgent) +{ + if (!s_attachedAgentsMap) { + s_attachedAgentsMap = new AttachedAgentsMap(); + v8::Debug::SetMessageHandler2(&DebuggerAgentManager::onV8DebugMessage); + v8::Debug::SetHostDispatchHandler(&DebuggerAgentManager::debugHostDispatchHandler, 100 /* ms */); + } + int hostId = debuggerAgent->webdevtoolsAgent()->hostId(); + ASSERT(hostId); + s_attachedAgentsMap->set(hostId, debuggerAgent); +} + +void DebuggerAgentManager::debugDetach(DebuggerAgentImpl* debuggerAgent) +{ + if (!s_attachedAgentsMap) { + ASSERT_NOT_REACHED(); + return; + } + int hostId = debuggerAgent->webdevtoolsAgent()->hostId(); + ASSERT(s_attachedAgentsMap->get(hostId) == debuggerAgent); + bool isOnBreakpoint = (findAgentForCurrentV8Context() == debuggerAgent); + s_attachedAgentsMap->remove(hostId); + + if (s_attachedAgentsMap->isEmpty()) { + delete s_attachedAgentsMap; + s_attachedAgentsMap = 0; + // Note that we do not empty handlers while in dispatch - we schedule + // continue and do removal once we are out of the dispatch. Also there is + // no need to send continue command in this case since removing message + // handler will cause debugger unload and all breakpoints will be cleared. + if (!s_inHostDispatchHandler) { + v8::Debug::SetMessageHandler2(0); + v8::Debug::SetHostDispatchHandler(0); + } + } else { + // Remove all breakpoints set by the agent. + String clearBreakpointGroupCmd = String::format( + "{\"seq\":1,\"type\":\"request\",\"command\":\"clearbreakpointgroup\"," + "\"arguments\":{\"groupId\":%d}}", + hostId); + sendCommandToV8(clearBreakpointGroupCmd, new CallerIdWrapper()); + + if (isOnBreakpoint) { + // Force continue if detach happened in nessted message loop while + // debugger was paused on a breakpoint(as long as there are other + // attached agents v8 will wait for explicit'continue' message). + sendContinueCommandToV8(); + } + } +} + +void DebuggerAgentManager::onV8DebugMessage(const v8::Debug::Message& message) +{ + v8::HandleScope scope; + v8::String::Value value(message.GetJSON()); + String out(reinterpret_cast<const UChar*>(*value), value.length()); + + // If callerData is not 0 the message is a response to a debugger command. + if (v8::Debug::ClientData* callerData = message.GetClientData()) { + CallerIdWrapper* wrapper = static_cast<CallerIdWrapper*>(callerData); + if (wrapper->callerIsMananager()) { + // Just ignore messages sent by this manager. + return; + } + DebuggerAgentImpl* debuggerAgent = debuggerAgentForHostId(wrapper->callerId()); + if (debuggerAgent) + debuggerAgent->debuggerOutput(out); + else if (!message.WillStartRunning()) { + // Autocontinue execution if there is no handler. + sendContinueCommandToV8(); + } + return; + } // Otherwise it's an event message. + ASSERT(message.IsEvent()); + + // Ignore unsupported event types. + if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception) + return; + + v8::Handle<v8::Context> context = message.GetEventContext(); + // If the context is from one of the inpected tabs it should have its context + // data. + if (context.IsEmpty()) { + // Unknown context, skip the event. + return; + } + + if (s_inUtilityContext && message.GetEvent() == v8::Break) { + // This may happen when two tabs are being debugged in the same process. + // Suppose that first debugger is pauesed on an exception. It will run + // nested MessageLoop which may process Break request from the second + // debugger. + s_debugBreakDelayed = true; + } else { + // If the context is from one of the inpected tabs or injected extension + // scripts it must have hostId in the data field. + int hostId = WebCore::V8Proxy::contextDebugId(context); + if (hostId != -1) { + DebuggerAgentImpl* agent = debuggerAgentForHostId(hostId); + if (agent) { + if (agent->autoContinueOnException() + && message.GetEvent() == v8::Exception) { + sendContinueCommandToV8(); + return; + } + + agent->debuggerOutput(out); + return; + } + } + } + + if (!message.WillStartRunning()) { + // Autocontinue execution on break and exception events if there is no + // handler. + sendContinueCommandToV8(); + } +} + +void DebuggerAgentManager::pauseScript() +{ + if (s_inUtilityContext) + s_debugBreakDelayed = true; + else + v8::Debug::DebugBreak(); +} + +void DebuggerAgentManager::executeDebuggerCommand(const String& command, int callerId) +{ + sendCommandToV8(command, new CallerIdWrapper(callerId)); +} + +void DebuggerAgentManager::setMessageLoopDispatchHandler(WebDevToolsAgent::MessageLoopDispatchHandler handler) +{ + s_messageLoopDispatchHandler = handler; +} + +void DebuggerAgentManager::setHostId(WebFrameImpl* webframe, int hostId) +{ + ASSERT(hostId > 0); + WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(webframe->frame()); + if (proxy) + proxy->setContextDebugId(hostId); +} + +void DebuggerAgentManager::onWebViewClosed(WebViewImpl* webview) +{ + if (s_pageDeferrers.contains(webview)) { + delete s_pageDeferrers.get(webview); + s_pageDeferrers.remove(webview); + } +} + +void DebuggerAgentManager::onNavigate() +{ + if (s_inHostDispatchHandler) + DebuggerAgentManager::sendContinueCommandToV8(); +} + +void DebuggerAgentManager::sendCommandToV8(const String& cmd, v8::Debug::ClientData* data) +{ + v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.characters()), cmd.length(), data); +} + +void DebuggerAgentManager::sendContinueCommandToV8() +{ + String continueCmd("{\"seq\":1,\"type\":\"request\",\"command\":\"continue\"}"); + sendCommandToV8(continueCmd, new CallerIdWrapper()); +} + +DebuggerAgentImpl* DebuggerAgentManager::findAgentForCurrentV8Context() +{ + if (!s_attachedAgentsMap) + return 0; + ASSERT(!s_attachedAgentsMap->isEmpty()); + + WebCore::Frame* frame = WebCore::V8Proxy::retrieveFrameForEnteredContext(); + if (!frame) + return 0; + WebCore::Page* page = frame->page(); + for (AttachedAgentsMap::iterator it = s_attachedAgentsMap->begin(); it != s_attachedAgentsMap->end(); ++it) { + if (it->second->page() == page) + return it->second; + } + return 0; +} + +DebuggerAgentImpl* DebuggerAgentManager::debuggerAgentForHostId(int hostId) +{ + if (!s_attachedAgentsMap) + return 0; + return s_attachedAgentsMap->get(hostId); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/DebuggerAgentManager.h b/WebKit/chromium/src/DebuggerAgentManager.h new file mode 100644 index 0000000..a2e9030 --- /dev/null +++ b/WebKit/chromium/src/DebuggerAgentManager.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DebuggerAgentManager_h +#define DebuggerAgentManager_h + +#include "WebDevToolsAgent.h" +#include <v8-debug.h> +#include <wtf/HashMap.h> +#include <wtf/Noncopyable.h> + +namespace WebCore { +class PageGroupLoadDeferrer; +class String; +} + +namespace WebKit { + +class DebuggerAgentImpl; +class DictionaryValue; +class WebFrameImpl; +class WebViewImpl; + +// There is single v8 instance per render process. Also there may be several +// RenderViews and consequently devtools agents in the process that want to talk +// to the v8 debugger. This class coordinates communication between the debug +// agents and v8 debugger. It will set debug output handler as long as at least +// one debugger agent is attached and remove it when last debugger agent is +// detached. When message is received from debugger it will route it to the +// right debugger agent if there is one otherwise the message will be ignored. +// +// v8 may send a message(e.g. exception event) after which it +// would expect some actions from the handler. If there is no appropriate +// debugger agent to handle such messages the manager will perform the action +// itself, otherwise v8 may hang waiting for the action. +class DebuggerAgentManager : public Noncopyable { +public: + static void debugAttach(DebuggerAgentImpl* debuggerAgent); + static void debugDetach(DebuggerAgentImpl* debuggerAgent); + static void pauseScript(); + static void executeDebuggerCommand(const WebCore::String& command, int callerId); + static void setMessageLoopDispatchHandler(WebDevToolsAgent::MessageLoopDispatchHandler handler); + + // Sets |hostId| as the frame context data. This id is used to filter scripts + // related to the inspected page. + static void setHostId(WebFrameImpl* webframe, int hostId); + + static void onWebViewClosed(WebViewImpl* webview); + + static void onNavigate(); + + class UtilityContextScope : public Noncopyable { + public: + UtilityContextScope() + { + ASSERT(!s_inUtilityContext); + s_inUtilityContext = true; + } + ~UtilityContextScope() + { + if (s_debugBreakDelayed) { + v8::Debug::DebugBreak(); + s_debugBreakDelayed = false; + } + s_inUtilityContext = false; + } + }; + +private: + DebuggerAgentManager(); + ~DebuggerAgentManager(); + + static void debugHostDispatchHandler(); + static void onV8DebugMessage(const v8::Debug::Message& message); + static void sendCommandToV8(const WebCore::String& cmd, + v8::Debug::ClientData* data); + static void sendContinueCommandToV8(); + + static DebuggerAgentImpl* findAgentForCurrentV8Context(); + static DebuggerAgentImpl* debuggerAgentForHostId(int hostId); + + typedef HashMap<int, DebuggerAgentImpl*> AttachedAgentsMap; + static AttachedAgentsMap* s_attachedAgentsMap; + + static WebDevToolsAgent::MessageLoopDispatchHandler s_messageLoopDispatchHandler; + static bool s_inHostDispatchHandler; + typedef HashMap<WebViewImpl*, WebCore::PageGroupLoadDeferrer*> DeferrersMap; + static DeferrersMap s_pageDeferrers; + + static bool s_inUtilityContext; + static bool s_debugBreakDelayed; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/DevToolsRPC.h b/WebKit/chromium/src/DevToolsRPC.h new file mode 100644 index 0000000..7176821 --- /dev/null +++ b/WebKit/chromium/src/DevToolsRPC.h @@ -0,0 +1,396 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// DevTools RPC subsystem is a simple string serialization-based rpc +// implementation. The client is responsible for defining the Rpc-enabled +// interface in terms of its macros: +// +// #define MYAPI_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3) +// METHOD0(Method1) +// METHOD1(Method3, int) +// (snippet above should be multiline macro, add trailing backslashes) +// +// DEFINE_RPC_CLASS(MyApi, MYAPI_STRUCT) +// +// The snippet above will generate three classes: MyApi, MyApiStub and +// MyApiDispatch. +// +// 1. For each method defined in the marco MyApi will have a +// pure virtual function generated, so that MyApi would look like: +// +// class MyApi { +// private: +// MyApi() { } +// ~MyApi() { } +// virtual void method1() = 0; +// virtual void method2( +// int param1, +// const String& param2, +// const Value& param3) = 0; +// virtual void method3(int param1) = 0; +// }; +// +// 2. MyApiStub will implement MyApi interface and would serialize all calls +// into the string-based calls of the underlying transport: +// +// DevToolsRPC::Delegate* transport; +// myApi = new MyApiStub(transport); +// myApi->method1(); +// myApi->method3(2); +// +// 3. MyApiDelegate is capable of dispatching the calls and convert them to the +// calls to the underlying MyApi methods: +// +// MyApi* realObject; +// MyApiDispatch::dispatch(realObject, rawStringCallGeneratedByStub); +// +// will make corresponding calls to the real object. + +#ifndef DevToolsRPC_h +#define DevToolsRPC_h + +#include "PlatformString.h" +#include "Vector.h" +#include "WebDevToolsMessageData.h" + +#include <wtf/Noncopyable.h> + +namespace WebCore { +class String; +} + +using WebCore::String; +using WTF::Vector; + +namespace WebKit { + +/////////////////////////////////////////////////////// +// RPC dispatch macro + +template<typename T> +struct RpcTypeTrait { + typedef T ApiType; +}; + +template<> +struct RpcTypeTrait<bool> { + typedef bool ApiType; + static bool parse(const WebCore::String& t) + { + return t == "true"; + } + static WebCore::String toString(bool b) + { + return b ? "true" : "false"; + } +}; + +template<> +struct RpcTypeTrait<int> { + typedef int ApiType; + static int parse(const WebCore::String& t) + { + bool success; + int i = t.toIntStrict(&success); + ASSERT(success); + return i; + } + static WebCore::String toString(int i) + { + return WebCore::String::number(i); + } +}; + +template<> +struct RpcTypeTrait<String> { + typedef const String& ApiType; + static String parse(const WebCore::String& t) + { + return t; + } + static WebCore::String toString(const String& t) + { + return t; + } +}; + +/////////////////////////////////////////////////////// +// RPC Api method declarations + +#define TOOLS_RPC_API_METHOD0(Method) \ + virtual void Method() = 0; + +#define TOOLS_RPC_API_METHOD1(Method, T1) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1) = 0; + +#define TOOLS_RPC_API_METHOD2(Method, T1, T2) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2) = 0; + +#define TOOLS_RPC_API_METHOD3(Method, T1, T2, T3) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2, \ + RpcTypeTrait<T3>::ApiType t3) = 0; + +#define TOOLS_RPC_API_METHOD4(Method, T1, T2, T3, T4) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2, \ + RpcTypeTrait<T3>::ApiType t3, \ + RpcTypeTrait<T4>::ApiType t4) = 0; + +#define TOOLS_RPC_API_METHOD5(Method, T1, T2, T3, T4, T5) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2, \ + RpcTypeTrait<T3>::ApiType t3, \ + RpcTypeTrait<T4>::ApiType t4, \ + RpcTypeTrait<T5>::ApiType t5) = 0; + +/////////////////////////////////////////////////////// +// RPC stub method implementations + +#define TOOLS_RPC_STUB_METHOD0(Method) \ + virtual void Method() { \ + Vector<String> args; \ + this->sendRpcMessage(m_className, #Method, args); \ + } + +#define TOOLS_RPC_STUB_METHOD1(Method, T1) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1) { \ + Vector<String> args(1); \ + args[0] = RpcTypeTrait<T1>::toString(t1); \ + this->sendRpcMessage(m_className, #Method, args); \ + } + +#define TOOLS_RPC_STUB_METHOD2(Method, T1, T2) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2) { \ + Vector<String> args(2); \ + args[0] = RpcTypeTrait<T1>::toString(t1); \ + args[1] = RpcTypeTrait<T2>::toString(t2); \ + this->sendRpcMessage(m_className, #Method, args); \ + } + +#define TOOLS_RPC_STUB_METHOD3(Method, T1, T2, T3) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2, \ + RpcTypeTrait<T3>::ApiType t3) { \ + Vector<String> args(3); \ + args[0] = RpcTypeTrait<T1>::toString(t1); \ + args[1] = RpcTypeTrait<T2>::toString(t2); \ + args[2] = RpcTypeTrait<T3>::toString(t3); \ + this->sendRpcMessage(m_className, #Method, args); \ + } + +#define TOOLS_RPC_STUB_METHOD4(Method, T1, T2, T3, T4) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2, \ + RpcTypeTrait<T3>::ApiType t3, \ + RpcTypeTrait<T4>::ApiType t4) { \ + Vector<String> args(4); \ + args[0] = RpcTypeTrait<T1>::toString(t1); \ + args[1] = RpcTypeTrait<T2>::toString(t2); \ + args[2] = RpcTypeTrait<T3>::toString(t3); \ + args[3] = RpcTypeTrait<T4>::toString(t4); \ + this->sendRpcMessage(m_className, #Method, args); \ + } + +#define TOOLS_RPC_STUB_METHOD5(Method, T1, T2, T3, T4, T5) \ + virtual void Method(RpcTypeTrait<T1>::ApiType t1, \ + RpcTypeTrait<T2>::ApiType t2, \ + RpcTypeTrait<T3>::ApiType t3, \ + RpcTypeTrait<T4>::ApiType t4, \ + RpcTypeTrait<T5>::ApiType t5) { \ + Vector<String> args(5); \ + args[0] = RpcTypeTrait<T1>::toString(t1); \ + args[1] = RpcTypeTrait<T2>::toString(t2); \ + args[2] = RpcTypeTrait<T3>::toString(t3); \ + args[3] = RpcTypeTrait<T4>::toString(t4); \ + args[4] = RpcTypeTrait<T5>::toString(t5); \ + this->sendRpcMessage(m_className, #Method, args); \ + } + +/////////////////////////////////////////////////////// +// RPC dispatch method implementations + +#define TOOLS_RPC_DISPATCH0(Method) \ +if (methodName == #Method) { \ + delegate->Method(); \ + return true; \ +} + +#define TOOLS_RPC_DISPATCH1(Method, T1) \ +if (methodName == #Method) { \ + delegate->Method(RpcTypeTrait<T1>::parse(args[0])); \ + return true; \ +} + +#define TOOLS_RPC_DISPATCH2(Method, T1, T2) \ +if (methodName == #Method) { \ + delegate->Method( \ + RpcTypeTrait<T1>::parse(args[0]), \ + RpcTypeTrait<T2>::parse(args[1]) \ + ); \ + return true; \ +} + +#define TOOLS_RPC_DISPATCH3(Method, T1, T2, T3) \ +if (methodName == #Method) { \ + delegate->Method( \ + RpcTypeTrait<T1>::parse(args[0]), \ + RpcTypeTrait<T2>::parse(args[1]), \ + RpcTypeTrait<T3>::parse(args[2]) \ + ); \ + return true; \ +} + +#define TOOLS_RPC_DISPATCH4(Method, T1, T2, T3, T4) \ +if (methodName == #Method) { \ + delegate->Method( \ + RpcTypeTrait<T1>::parse(args[0]), \ + RpcTypeTrait<T2>::parse(args[1]), \ + RpcTypeTrait<T3>::parse(args[2]), \ + RpcTypeTrait<T4>::parse(args[3]) \ + ); \ + return true; \ +} + +#define TOOLS_RPC_DISPATCH5(Method, T1, T2, T3, T4, T5) \ +if (methodName == #Method) { \ + delegate->Method( \ + RpcTypeTrait<T1>::parse(args[0]), \ + RpcTypeTrait<T2>::parse(args[1]), \ + RpcTypeTrait<T3>::parse(args[2]), \ + RpcTypeTrait<T4>::parse(args[3]), \ + RpcTypeTrait<T5>::parse(args[4]) \ + ); \ + return true; \ +} + +#define TOOLS_END_RPC_DISPATCH() \ +} + +// This macro defines three classes: Class with the Api, ClassStub that is +// serializing method calls and ClassDispatch that is capable of dispatching +// the serialized message into its delegate. +#define DEFINE_RPC_CLASS(Class, STRUCT) \ +class Class : public Noncopyable {\ +public: \ + Class() \ + { \ + m_className = #Class; \ + } \ + virtual ~Class() { } \ + \ + STRUCT( \ + TOOLS_RPC_API_METHOD0, \ + TOOLS_RPC_API_METHOD1, \ + TOOLS_RPC_API_METHOD2, \ + TOOLS_RPC_API_METHOD3, \ + TOOLS_RPC_API_METHOD4, \ + TOOLS_RPC_API_METHOD5) \ + WebCore::String m_className; \ +}; \ +\ +class Class##Stub \ + : public Class \ + , public DevToolsRPC { \ +public: \ + explicit Class##Stub(Delegate* delegate) : DevToolsRPC(delegate) { } \ + virtual ~Class##Stub() { } \ + typedef Class CLASS; \ + STRUCT( \ + TOOLS_RPC_STUB_METHOD0, \ + TOOLS_RPC_STUB_METHOD1, \ + TOOLS_RPC_STUB_METHOD2, \ + TOOLS_RPC_STUB_METHOD3, \ + TOOLS_RPC_STUB_METHOD4, \ + TOOLS_RPC_STUB_METHOD5) \ +}; \ +\ +class Class##Dispatch : public Noncopyable { \ +public: \ + Class##Dispatch() { } \ + virtual ~Class##Dispatch() { } \ + \ + static bool dispatch(Class* delegate, \ + const WebKit::WebDevToolsMessageData& data) { \ + String className = data.className; \ + if (className != #Class) \ + return false; \ + String methodName = data.methodName; \ + Vector<String> args; \ + for (size_t i = 0; i < data.arguments.size(); i++) \ + args.append(data.arguments[i]); \ + typedef Class CLASS; \ + STRUCT( \ + TOOLS_RPC_DISPATCH0, \ + TOOLS_RPC_DISPATCH1, \ + TOOLS_RPC_DISPATCH2, \ + TOOLS_RPC_DISPATCH3, \ + TOOLS_RPC_DISPATCH4, \ + TOOLS_RPC_DISPATCH5) \ + return false; \ + } \ +}; + +/////////////////////////////////////////////////////// +// RPC base class +class DevToolsRPC { +public: + class Delegate { + public: + Delegate() { } + virtual ~Delegate() { } + virtual void sendRpcMessage(const WebKit::WebDevToolsMessageData& data) = 0; + }; + + explicit DevToolsRPC(Delegate* delegate) : m_delegate(delegate) { } + virtual ~DevToolsRPC() { }; + +protected: + void sendRpcMessage(const String& className, + const String& methodName, + const Vector<String>& args) { + WebKit::WebVector<WebKit::WebString> webArgs(args.size()); + for (size_t i = 0; i < args.size(); i++) + webArgs[i] = args[i]; + WebKit::WebDevToolsMessageData data; + data.className = className; + data.methodName = methodName; + data.arguments.swap(webArgs); + this->m_delegate->sendRpcMessage(data); + } + + Delegate* m_delegate; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/DevToolsRPCJS.h b/WebKit/chromium/src/DevToolsRPCJS.h new file mode 100644 index 0000000..8ae279f --- /dev/null +++ b/WebKit/chromium/src/DevToolsRPCJS.h @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// Additional set of macros for the JS RPC. + +#ifndef DevToolsRPCJS_h +#define DevToolsRPCJS_h + +// Do not remove this one although it is not used. +#include "BoundObject.h" +#include "DevToolsRPC.h" +#include "WebFrame.h" +#include <wtf/Noncopyable.h> +#include <wtf/OwnPtr.h> + +namespace WebKit { + +/////////////////////////////////////////////////////// +// JS RPC binds and stubs + +#define TOOLS_RPC_JS_BIND_METHOD0(Method) \ + boundObj.addProtoFunction(#Method, OCLASS::js##Method); + +#define TOOLS_RPC_JS_BIND_METHOD1(Method, T1) \ + boundObj.addProtoFunction(#Method, OCLASS::js##Method); + +#define TOOLS_RPC_JS_BIND_METHOD2(Method, T1, T2) \ + boundObj.addProtoFunction(#Method, OCLASS::js##Method); + +#define TOOLS_RPC_JS_BIND_METHOD3(Method, T1, T2, T3) \ + boundObj.addProtoFunction(#Method, OCLASS::js##Method); + +#define TOOLS_RPC_JS_BIND_METHOD4(Method, T1, T2, T3, T4) \ + boundObj.addProtoFunction(#Method, OCLASS::js##Method); + +#define TOOLS_RPC_JS_BIND_METHOD5(Method, T1, T2, T3, T4, T5) \ + boundObj.addProtoFunction(#Method, OCLASS::js##Method); + +#define TOOLS_RPC_JS_STUB_METHOD0(Method) \ + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJS(#Method, args, 0); \ + return v8::Undefined(); \ + } + +#define TOOLS_RPC_JS_STUB_METHOD1(Method, T1) \ + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJS(#Method, args, 1); \ + return v8::Undefined(); \ + } + +#define TOOLS_RPC_JS_STUB_METHOD2(Method, T1, T2) \ + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJS(#Method, args, 2); \ + return v8::Undefined(); \ + } + +#define TOOLS_RPC_JS_STUB_METHOD3(Method, T1, T2, T3) \ + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJS(#Method, args, 3); \ + return v8::Undefined(); \ + } + +#define TOOLS_RPC_JS_STUB_METHOD4(Method, T1, T2, T3, T4) \ + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJS(#Method, args, 4); \ + return v8::Undefined(); \ + } + +#define TOOLS_RPC_JS_STUB_METHOD5(Method, T1, T2, T3, T4, T5) \ + static v8::Handle<v8::Value> js##Method(const v8::Arguments& args) { \ + sendRpcMessageFromJS(#Method, args, 5); \ + return v8::Undefined(); \ + } + +/////////////////////////////////////////////////////// +// JS RPC main obj macro + +#define DEFINE_RPC_JS_BOUND_OBJ(Class, STRUCT, DClass, DELEGATE_STRUCT) \ +class JS##Class##BoundObj : public Class##Stub { \ +public: \ + JS##Class##BoundObj(Delegate* rpcDelegate, \ + v8::Handle<v8::Context> context, \ + const char* classname) \ + : Class##Stub(rpcDelegate) { \ + BoundObject boundObj(context, this, classname); \ + STRUCT( \ + TOOLS_RPC_JS_BIND_METHOD0, \ + TOOLS_RPC_JS_BIND_METHOD1, \ + TOOLS_RPC_JS_BIND_METHOD2, \ + TOOLS_RPC_JS_BIND_METHOD3, \ + TOOLS_RPC_JS_BIND_METHOD4, \ + TOOLS_RPC_JS_BIND_METHOD5) \ + boundObj.build(); \ + } \ + virtual ~JS##Class##BoundObj() { } \ + typedef JS##Class##BoundObj OCLASS; \ + STRUCT( \ + TOOLS_RPC_JS_STUB_METHOD0, \ + TOOLS_RPC_JS_STUB_METHOD1, \ + TOOLS_RPC_JS_STUB_METHOD2, \ + TOOLS_RPC_JS_STUB_METHOD3, \ + TOOLS_RPC_JS_STUB_METHOD4, \ + TOOLS_RPC_JS_STUB_METHOD5) \ +private: \ + static void sendRpcMessageFromJS(const char* method, \ + const v8::Arguments& jsArguments, \ + size_t argsCount) \ + { \ + Vector<String> args(argsCount); \ + for (size_t i = 0; i < argsCount; i++) \ + args[i] = WebCore::toWebCoreStringWithNullCheck(jsArguments[i]); \ + void* selfPtr = v8::External::Cast(*jsArguments.Data())->Value(); \ + JS##Class##BoundObj* self = static_cast<JS##Class##BoundObj*>(selfPtr); \ + self->sendRpcMessage(#Class, method, args); \ + } \ +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/ProfilerAgent.h b/WebKit/chromium/src/ProfilerAgent.h new file mode 100644 index 0000000..52337b8 --- /dev/null +++ b/WebKit/chromium/src/ProfilerAgent.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ProfilerAgent_h +#define ProfilerAgent_h + +#include "DevToolsRPC.h" + +namespace WebKit { + +// Profiler agent provides API for retrieving profiler data. +// These methods are handled on the IO thread, so profiler can +// operate while a script on a page performs heavy work. +#define PROFILER_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4, METHOD5) \ + /* Requests current profiler state. */ \ + METHOD0(getActiveProfilerModules) \ + \ + /* Retrieves portion of profiler log. */ \ + METHOD1(getLogLines, int /* position */) + +DEFINE_RPC_CLASS(ProfilerAgent, PROFILER_AGENT_STRUCT) + +#define PROFILER_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4, METHOD5) \ + /* Response to getActiveProfilerModules. */ \ + METHOD1(didGetActiveProfilerModules, int /* flags */) \ + \ + /* Response to getLogLines. */ \ + METHOD2(didGetLogLines, int /* position */, String /* log */) + +DEFINE_RPC_CLASS(ProfilerAgentDelegate, PROFILER_AGENT_DELEGATE_STRUCT) + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/ProfilerAgentImpl.cpp b/WebKit/chromium/src/ProfilerAgentImpl.cpp new file mode 100644 index 0000000..07570df --- /dev/null +++ b/WebKit/chromium/src/ProfilerAgentImpl.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ProfilerAgentImpl.h" + +#include <v8.h> + +namespace WebKit { + +void ProfilerAgentImpl::getActiveProfilerModules() +{ + m_delegate->didGetActiveProfilerModules(v8::V8::GetActiveProfilerModules()); +} + +void ProfilerAgentImpl::getLogLines(int position) +{ + static char buffer[65536]; + const int readSize = v8::V8::GetLogLines(position, buffer, sizeof(buffer) - 1); + buffer[readSize] = '\0'; + position += readSize; + m_delegate->didGetLogLines(position, buffer); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/ProfilerAgentImpl.h b/WebKit/chromium/src/ProfilerAgentImpl.h new file mode 100644 index 0000000..d38f57c --- /dev/null +++ b/WebKit/chromium/src/ProfilerAgentImpl.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ProfilerAgentImpl_h +#define ProfilerAgentImpl_h + +#include "ProfilerAgent.h" + +namespace WebKit { + +class ProfilerAgentImpl : public ProfilerAgent { +public: + ProfilerAgentImpl(ProfilerAgentDelegate* delegate) : m_delegate(delegate) { } + virtual ~ProfilerAgentImpl() { } + + // ProfilerAgent implementation. + + // This method is called on IO thread. + virtual void getActiveProfilerModules(); + + // This method is called on IO thread. + virtual void getLogLines(int position); + +private: + ProfilerAgentDelegate* m_delegate; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/SharedWorkerRepository.cpp b/WebKit/chromium/src/SharedWorkerRepository.cpp index 5e5bc46..c803aac 100644 --- a/WebKit/chromium/src/SharedWorkerRepository.cpp +++ b/WebKit/chromium/src/SharedWorkerRepository.cpp @@ -61,26 +61,30 @@ using WebKit::WebSharedWorker; using WebKit::WebSharedWorkerRepository; // Callback class that keeps the SharedWorker and WebSharedWorker objects alive while loads are potentially happening, and also translates load errors into error events on the worker. -class SharedWorkerScriptLoader : private WorkerScriptLoaderClient, private WebSharedWorker::ConnectListener, private ActiveDOMObject { +class SharedWorkerScriptLoader : private WorkerScriptLoaderClient, private WebSharedWorker::ConnectListener { public: SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker) - : ActiveDOMObject(worker->scriptExecutionContext(), this) - , m_worker(worker) + : m_worker(worker) , m_url(url) , m_name(name) , m_webWorker(webWorker) , m_port(port) + , m_loading(false) { } + ~SharedWorkerScriptLoader(); void load(); - virtual void contextDestroyed(); + static void stopAllLoadersForContext(ScriptExecutionContext*); + private: // WorkerScriptLoaderClient callback virtual void notifyFinished(); virtual void connected(); + const ScriptExecutionContext* loadingContext() { return m_worker->scriptExecutionContext(); } + void sendConnect(); RefPtr<SharedWorker> m_worker; @@ -89,15 +93,47 @@ private: OwnPtr<WebSharedWorker> m_webWorker; OwnPtr<MessagePortChannel> m_port; WorkerScriptLoader m_scriptLoader; + bool m_loading; }; +static Vector<SharedWorkerScriptLoader*>& pendingLoaders() +{ + AtomicallyInitializedStatic(Vector<SharedWorkerScriptLoader*>&, loaders = *new Vector<SharedWorkerScriptLoader*>); + return loaders; +} + +void SharedWorkerScriptLoader::stopAllLoadersForContext(ScriptExecutionContext* context) +{ + // Walk our list of pending loaders and shutdown any that belong to this context. + Vector<SharedWorkerScriptLoader*>& loaders = pendingLoaders(); + for (unsigned i = 0; i < loaders.size(); ) { + SharedWorkerScriptLoader* loader = loaders[i]; + if (context == loader->loadingContext()) { + loaders.remove(i); + delete loader; + } else + i++; + } +} + +SharedWorkerScriptLoader::~SharedWorkerScriptLoader() +{ + if (m_loading) + m_worker->unsetPendingActivity(m_worker.get()); +} + void SharedWorkerScriptLoader::load() { + ASSERT(!m_loading); // If the shared worker is not yet running, load the script resource for it, otherwise just send it a connect event. if (m_webWorker->isStarted()) sendConnect(); - else + else { m_scriptLoader.loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this); + // Keep the worker + JS wrapper alive until the resource load is complete in case we need to dispatch an error event. + m_worker->setPendingActivity(m_worker.get()); + m_loading = true; + } } // Extracts a WebMessagePortChannel from a MessagePortChannel. @@ -128,12 +164,6 @@ void SharedWorkerScriptLoader::sendConnect() m_webWorker->connect(getWebPort(m_port.release()), this); } -void SharedWorkerScriptLoader::contextDestroyed() -{ - ActiveDOMObject::contextDestroyed(); - delete this; -} - void SharedWorkerScriptLoader::connected() { // Connect event has been sent, so free ourselves (this releases the SharedWorker so it can be freed as well if unreferenced). @@ -185,6 +215,10 @@ void SharedWorkerRepository::documentDetached(Document* document) WebSharedWorkerRepository* repo = WebKit::webKitClient()->sharedWorkerRepository(); if (repo) repo->documentDetached(getId(document)); + + // Stop the creation of any pending SharedWorkers for this context. + // FIXME: Need a way to invoke this for WorkerContexts as well when we support for nested workers. + SharedWorkerScriptLoader::stopAllLoadersForContext(document); } bool SharedWorkerRepository::hasSharedWorkers(Document* document) diff --git a/WebKit/chromium/src/ToolsAgent.h b/WebKit/chromium/src/ToolsAgent.h new file mode 100644 index 0000000..fd1fcb7 --- /dev/null +++ b/WebKit/chromium/src/ToolsAgent.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ToolsAgent_h +#define ToolsAgent_h + +#include "DevToolsRPC.h" + +namespace WebKit { + +// Tools agent provides API for enabling / disabling other agents as well as +// API for auxiliary UI functions such as dom elements highlighting. +#define TOOLS_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4, METHOD5) \ + /* Request the agent to to run a no-op JavaScript function to trigger v8 execution. */ \ + METHOD0(executeVoidJavaScript) \ + \ + /* Dispatches given function on the InspectorController object */ \ + METHOD3(dispatchOnInspectorController, int /* call_id */, \ + String /* function_name */, String /* json_args */) \ + \ + /* Dispatches given function on the InjectedScript object */ \ + METHOD5(dispatchOnInjectedScript, int /* call_id */, \ + int /* injected_script_id */, String /* function_name */, \ + String /* json_args */, bool /* async */) + +DEFINE_RPC_CLASS(ToolsAgent, TOOLS_AGENT_STRUCT) + +#define TOOLS_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4, METHOD5) \ + /* Updates focused node on the client. */ \ + METHOD1(frameNavigate, String /* url */) \ + \ + /* Response to the DispatchOn*. */ \ + METHOD3(didDispatchOn, int /* call_id */, String /* result */, String /* exception */) \ + \ + /* Sends InspectorFrontend message to be dispatched on client. */ \ + METHOD1(dispatchOnClient, String /* data */) + +DEFINE_RPC_CLASS(ToolsAgentDelegate, TOOLS_AGENT_DELEGATE_STRUCT) + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp new file mode 100644 index 0000000..9d386f3 --- /dev/null +++ b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp @@ -0,0 +1,566 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebDevToolsAgentImpl.h" + +#include "BoundObject.h" +#include "DebuggerAgentImpl.h" +#include "DebuggerAgentManager.h" +#include "Document.h" +#include "EventListener.h" +#include "InjectedScriptHost.h" +#include "InspectorBackend.h" +#include "InspectorController.h" +#include "InspectorFrontend.h" +#include "InspectorResource.h" +#include "Node.h" +#include "Page.h" +#include "PlatformString.h" +#include "ProfilerAgentImpl.h" +#include "ResourceError.h" +#include "ResourceRequest.h" +#include "ResourceResponse.h" +#include "ScriptObject.h" +#include "ScriptState.h" +#include "ScriptValue.h" +#include "V8Binding.h" +#include "V8Proxy.h" +#include "V8Utilities.h" +#include "WebDataSource.h" +#include "WebDevToolsAgentClient.h" +#include "WebDevToolsMessageData.h" +#include "WebFrameImpl.h" +#include "WebString.h" +#include "WebURL.h" +#include "WebURLError.h" +#include "WebURLRequest.h" +#include "WebURLResponse.h" +#include "WebViewImpl.h" +#include <wtf/Noncopyable.h> +#include <wtf/OwnPtr.h> + +using WebCore::Document; +using WebCore::DocumentLoader; +using WebCore::FrameLoader; +using WebCore::InjectedScriptHost; +using WebCore::InspectorBackend; +using WebCore::InspectorController; +using WebCore::InspectorFrontend; +using WebCore::InspectorResource; +using WebCore::Node; +using WebCore::Page; +using WebCore::ResourceError; +using WebCore::ResourceRequest; +using WebCore::ResourceResponse; +using WebCore::SafeAllocation; +using WebCore::ScriptObject; +using WebCore::ScriptState; +using WebCore::ScriptValue; +using WebCore::String; +using WebCore::V8ClassIndex; +using WebCore::V8DOMWrapper; +using WebCore::V8Proxy; + +namespace WebKit { + +namespace { + +void InspectorBackendWeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter) +{ + InspectorBackend* backend = static_cast<InspectorBackend*>(parameter); + backend->deref(); + object.Dispose(); +} + +void SetApuAgentEnabledInUtilityContext(v8::Handle<v8::Context> context, bool enabled) +{ + v8::HandleScope handleScope; + v8::Context::Scope contextScope(context); + v8::Handle<v8::Object> dispatcher = v8::Local<v8::Object>::Cast( + context->Global()->Get(v8::String::New("ApuAgentDispatcher"))); + if (dispatcher.IsEmpty()) + return; + dispatcher->Set(v8::String::New("enabled"), v8::Boolean::New(enabled)); +} + +// TODO(pfeldman): Make this public in WebDevToolsAgent API. +static const char kApuAgentFeatureName[] = "apu-agent"; + +// Keep these in sync with the ones in inject_dispatch.js. +static const char kTimelineFeatureName[] = "timeline-profiler"; +static const char kResourceTrackingFeatureName[] = "resource-tracking"; + +class IORPCDelegate : public DevToolsRPC::Delegate, public Noncopyable { +public: + IORPCDelegate() { } + virtual ~IORPCDelegate() { } + virtual void sendRpcMessage(const WebDevToolsMessageData& data) + { + WebDevToolsAgentClient::sendMessageToFrontendOnIOThread(data); + } +}; + +} // namespace + +WebDevToolsAgentImpl::WebDevToolsAgentImpl( + WebViewImpl* webViewImpl, + WebDevToolsAgentClient* client) + : m_hostId(client->hostIdentifier()) + , m_client(client) + , m_webViewImpl(webViewImpl) + , m_apuAgentEnabled(false) + , m_resourceTrackingWasEnabled(false) + , m_attached(false) +{ + m_debuggerAgentDelegateStub.set(new DebuggerAgentDelegateStub(this)); + m_toolsAgentDelegateStub.set(new ToolsAgentDelegateStub(this)); + m_apuAgentDelegateStub.set(new ApuAgentDelegateStub(this)); +} + +WebDevToolsAgentImpl::~WebDevToolsAgentImpl() +{ + DebuggerAgentManager::onWebViewClosed(m_webViewImpl); + disposeUtilityContext(); +} + +void WebDevToolsAgentImpl::disposeUtilityContext() +{ + if (!m_utilityContext.IsEmpty()) { + m_utilityContext.Dispose(); + m_utilityContext.Clear(); + } +} + +void WebDevToolsAgentImpl::unhideResourcesPanelIfNecessary() +{ + InspectorController* ic = m_webViewImpl->page()->inspectorController(); + ic->ensureResourceTrackingSettingsLoaded(); + String command = String::format("[\"setResourcesPanelEnabled\", %s]", + ic->resourceTrackingEnabled() ? "true" : "false"); + m_toolsAgentDelegateStub->dispatchOnClient(command); +} + +void WebDevToolsAgentImpl::attach() +{ + if (m_attached) + return; + m_debuggerAgentImpl.set( + new DebuggerAgentImpl(m_webViewImpl, + m_debuggerAgentDelegateStub.get(), + this)); + resetInspectorFrontendProxy(); + unhideResourcesPanelIfNecessary(); + // Allow controller to send messages to the frontend. + InspectorController* ic = inspectorController(); + + { // TODO(yurys): the source should have already been pushed by the frontend. + v8::HandleScope scope; + v8::Context::Scope contextScope(m_utilityContext); + v8::Handle<v8::Value> constructorValue = m_utilityContext->Global()->Get( + v8::String::New("injectedScriptConstructor")); + if (constructorValue->IsFunction()) { + String source = WebCore::toWebCoreString(constructorValue); + ic->injectedScriptHost()->setInjectedScriptSource("(" + source + ")"); + } + } + + ic->setWindowVisible(true, false); + m_attached = true; +} + +void WebDevToolsAgentImpl::detach() +{ + // Prevent controller from sending messages to the frontend. + InspectorController* ic = m_webViewImpl->page()->inspectorController(); + ic->hideHighlight(); + ic->close(); + disposeUtilityContext(); + m_debuggerAgentImpl.set(0); + m_attached = false; + m_apuAgentEnabled = false; +} + +void WebDevToolsAgentImpl::didNavigate() +{ + DebuggerAgentManager::onNavigate(); +} + +void WebDevToolsAgentImpl::didCommitProvisionalLoad(WebFrameImpl* webframe, bool isNewNavigation) +{ + if (!m_attached) + return; + WebDataSource* ds = webframe->dataSource(); + const WebURLRequest& request = ds->request(); + WebURL url = ds->hasUnreachableURL() ? + ds->unreachableURL() : + request.url(); + if (!webframe->parent()) { + resetInspectorFrontendProxy(); + m_toolsAgentDelegateStub->frameNavigate(WebCore::KURL(url).string()); + SetApuAgentEnabledInUtilityContext(m_utilityContext, m_apuAgentEnabled); + unhideResourcesPanelIfNecessary(); + } +} + +void WebDevToolsAgentImpl::didClearWindowObject(WebFrameImpl* webframe) +{ + DebuggerAgentManager::setHostId(webframe, m_hostId); + if (m_attached) { + // Push context id into the client if it is already attached. + m_debuggerAgentDelegateStub->setContextId(m_hostId); + } +} + +void WebDevToolsAgentImpl::forceRepaint() +{ + m_client->forceRepaint(); +} + +void WebDevToolsAgentImpl::dispatchOnInspectorController(int callId, const String& functionName, const String& jsonArgs) +{ + String result; + String exception; + result = m_debuggerAgentImpl->executeUtilityFunction(m_utilityContext, callId, + "InspectorControllerDispatcher", functionName, jsonArgs, false /* is sync */, &exception); + m_toolsAgentDelegateStub->didDispatchOn(callId, result, exception); +} + +void WebDevToolsAgentImpl::dispatchOnInjectedScript(int callId, int injectedScriptId, const String& functionName, const String& jsonArgs, bool async) +{ + inspectorController()->inspectorBackend()->dispatchOnInjectedScript( + callId, + injectedScriptId, + functionName, + jsonArgs, + async); +} + +void WebDevToolsAgentImpl::executeVoidJavaScript() +{ + m_debuggerAgentImpl->executeVoidJavaScript(m_utilityContext); +} + +void WebDevToolsAgentImpl::dispatchMessageFromFrontend(const WebDevToolsMessageData& data) +{ + if (ToolsAgentDispatch::dispatch(this, data)) + return; + + if (!m_attached) + return; + + if (m_debuggerAgentImpl.get() && DebuggerAgentDispatch::dispatch(m_debuggerAgentImpl.get(), data)) + return; +} + +void WebDevToolsAgentImpl::inspectElementAt(const WebPoint& point) +{ + m_webViewImpl->inspectElementAt(point); +} + +void WebDevToolsAgentImpl::setRuntimeFeatureEnabled(const WebString& feature, bool enabled) +{ + if (feature == kApuAgentFeatureName) + setApuAgentEnabled(enabled); + else if (feature == kTimelineFeatureName) + setTimelineProfilingEnabled(enabled); + else if (feature == kResourceTrackingFeatureName) { + InspectorController* ic = m_webViewImpl->page()->inspectorController(); + if (enabled) + ic->enableResourceTracking(false /* not sticky */, false /* no reload */); + else + ic->disableResourceTracking(false /* not sticky */); + } +} + +void WebDevToolsAgentImpl::sendRpcMessage(const WebDevToolsMessageData& data) +{ + m_client->sendMessageToFrontend(data); +} + +void WebDevToolsAgentImpl::compileUtilityScripts() +{ + v8::HandleScope handleScope; + v8::Context::Scope contextScope(m_utilityContext); + // Inject javascript into the context. + WebCString injectedScriptJs = m_client->injectedScriptSource(); + v8::Script::Compile(v8::String::New( + injectedScriptJs.data(), + injectedScriptJs.length()))->Run(); + WebCString injectDispatchJs = m_client->injectedScriptDispatcherSource(); + v8::Script::Compile(v8::String::New( + injectDispatchJs.data(), + injectDispatchJs.length()))->Run(); +} + +void WebDevToolsAgentImpl::initDevToolsAgentHost() +{ + BoundObject devtoolsAgentHost(m_utilityContext, this, "DevToolsAgentHost"); + devtoolsAgentHost.addProtoFunction( + "dispatch", + WebDevToolsAgentImpl::jsDispatchOnClient); + devtoolsAgentHost.addProtoFunction( + "dispatchToApu", + WebDevToolsAgentImpl::jsDispatchToApu); + devtoolsAgentHost.addProtoFunction( + "evaluateOnSelf", + WebDevToolsAgentImpl::jsEvaluateOnSelf); + devtoolsAgentHost.addProtoFunction( + "runtimeFeatureStateChanged", + WebDevToolsAgentImpl::jsOnRuntimeFeatureStateChanged); + devtoolsAgentHost.build(); + + v8::HandleScope scope; + v8::Context::Scope utilityScope(m_utilityContext); + // Call custom code to create inspector backend wrapper in the utility context + // instead of calling V8DOMWrapper::convertToV8Object that would create the + // wrapper in the Page main frame context. + v8::Handle<v8::Object> backendWrapper = createInspectorBackendV8Wrapper(); + if (backendWrapper.IsEmpty()) + return; + m_utilityContext->Global()->Set(v8::String::New("InspectorBackend"), backendWrapper); +} + +v8::Local<v8::Object> WebDevToolsAgentImpl::createInspectorBackendV8Wrapper() +{ + V8ClassIndex::V8WrapperType descriptorType = V8ClassIndex::INSPECTORBACKEND; + v8::Handle<v8::Function> function = V8DOMWrapper::getTemplate(descriptorType)->GetFunction(); + if (function.IsEmpty()) { + // Return if allocation failed. + return v8::Local<v8::Object>(); + } + v8::Local<v8::Object> instance = SafeAllocation::newInstance(function); + if (instance.IsEmpty()) { + // Avoid setting the wrapper if allocation failed. + return v8::Local<v8::Object>(); + } + InspectorBackend* backend = m_webViewImpl->page()->inspectorController()->inspectorBackend(); + V8DOMWrapper::setDOMWrapper(instance, V8ClassIndex::ToInt(descriptorType), backend); + // Create a weak reference to the v8 wrapper of InspectorBackend to deref + // InspectorBackend when the wrapper is garbage collected. + backend->ref(); + v8::Persistent<v8::Object> weakHandle = v8::Persistent<v8::Object>::New(instance); + weakHandle.MakeWeak(backend, &InspectorBackendWeakReferenceCallback); + return instance; +} + +void WebDevToolsAgentImpl::resetInspectorFrontendProxy() +{ + disposeUtilityContext(); + m_debuggerAgentImpl->createUtilityContext(m_webViewImpl->page()->mainFrame(), &m_utilityContext); + compileUtilityScripts(); + initDevToolsAgentHost(); + + v8::HandleScope scope; + v8::Context::Scope contextScope(m_utilityContext); + ScriptState* state = ScriptState::forContext( + v8::Local<v8::Context>::New(m_utilityContext)); + InspectorController* ic = inspectorController(); + ic->setFrontendProxyObject(state, ScriptObject(state, m_utilityContext->Global())); +} + +void WebDevToolsAgentImpl::setApuAgentEnabled(bool enabled) +{ + m_apuAgentEnabled = enabled; + SetApuAgentEnabledInUtilityContext(m_utilityContext, enabled); + InspectorController* ic = m_webViewImpl->page()->inspectorController(); + if (enabled) { + m_resourceTrackingWasEnabled = ic->resourceTrackingEnabled(); + ic->startTimelineProfiler(); + if (!m_resourceTrackingWasEnabled) { + // TODO(knorton): Introduce some kind of agents dependency here so that + // user could turn off resource tracking while apu agent is on. + ic->enableResourceTracking(false, false); + } + m_debuggerAgentImpl->setAutoContinueOnException(true); + } else { + ic->stopTimelineProfiler(); + if (!m_resourceTrackingWasEnabled) + ic->disableResourceTracking(false); + m_resourceTrackingWasEnabled = false; + } + m_client->runtimeFeatureStateChanged( + kApuAgentFeatureName, + enabled); +} + +// static +v8::Handle<v8::Value> WebDevToolsAgentImpl::jsDispatchOnClient(const v8::Arguments& args) +{ + v8::TryCatch exceptionCatcher; + String message = WebCore::toWebCoreStringWithNullCheck(args[0]); + if (message.isEmpty() || exceptionCatcher.HasCaught()) + return v8::Undefined(); + WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(v8::External::Cast(*args.Data())->Value()); + agent->m_toolsAgentDelegateStub->dispatchOnClient(message); + return v8::Undefined(); +} + +// static +v8::Handle<v8::Value> WebDevToolsAgentImpl::jsDispatchToApu(const v8::Arguments& args) +{ + v8::TryCatch exceptionCatcher; + String message = WebCore::toWebCoreStringWithNullCheck(args[0]); + if (message.isEmpty() || exceptionCatcher.HasCaught()) + return v8::Undefined(); + WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>( + v8::External::Cast(*args.Data())->Value()); + agent->m_apuAgentDelegateStub->dispatchToApu(message); + return v8::Undefined(); +} + +// static +v8::Handle<v8::Value> WebDevToolsAgentImpl::jsEvaluateOnSelf(const v8::Arguments& args) +{ + String code; + { + v8::TryCatch exceptionCatcher; + code = WebCore::toWebCoreStringWithNullCheck(args[0]); + if (code.isEmpty() || exceptionCatcher.HasCaught()) + return v8::Undefined(); + } + WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(v8::External::Cast(*args.Data())->Value()); + v8::Context::Scope(agent->m_utilityContext); + V8Proxy* proxy = V8Proxy::retrieve(agent->m_webViewImpl->page()->mainFrame()); + v8::Local<v8::Value> result = proxy->runScript(v8::Script::Compile(v8::String::New(code.utf8().data())), true); + return result; +} + +// static +v8::Handle<v8::Value> WebDevToolsAgentImpl::jsOnRuntimeFeatureStateChanged(const v8::Arguments& args) +{ + v8::TryCatch exceptionCatcher; + String feature = WebCore::toWebCoreStringWithNullCheck(args[0]); + bool enabled = args[1]->ToBoolean()->Value(); + if (feature.isEmpty() || exceptionCatcher.HasCaught()) + return v8::Undefined(); + WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(v8::External::Cast(*args.Data())->Value()); + agent->m_client->runtimeFeatureStateChanged(feature, enabled); + return v8::Undefined(); +} + + +WebCore::InspectorController* WebDevToolsAgentImpl::inspectorController() +{ + if (Page* page = m_webViewImpl->page()) + return page->inspectorController(); + return 0; +} + + +//------- plugin resource load notifications --------------- +void WebDevToolsAgentImpl::identifierForInitialRequest( + unsigned long resourceId, + WebFrame* frame, + const WebURLRequest& request) +{ + if (InspectorController* ic = inspectorController()) { + WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame); + FrameLoader* frameLoader = webFrameImpl->frame()->loader(); + DocumentLoader* loader = frameLoader->activeDocumentLoader(); + ic->identifierForInitialRequest(resourceId, loader, request.toResourceRequest()); + } +} + +void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, const WebURLRequest& request) +{ + if (InspectorController* ic = inspectorController()) + ic->willSendRequest(resourceId, request.toResourceRequest(), ResourceResponse()); +} + +void WebDevToolsAgentImpl::didReceiveData(unsigned long resourceId, int length) +{ + if (InspectorController* ic = inspectorController()) + ic->didReceiveContentLength(resourceId, length); +} + +void WebDevToolsAgentImpl::didReceiveResponse(unsigned long resourceId, const WebURLResponse& response) +{ + if (InspectorController* ic = inspectorController()) + ic->didReceiveResponse(resourceId, response.toResourceResponse()); +} + +void WebDevToolsAgentImpl::didFinishLoading(unsigned long resourceId) +{ + if (InspectorController* ic = inspectorController()) + ic->didFinishLoading(resourceId); +} + +void WebDevToolsAgentImpl::didFailLoading(unsigned long resourceId, const WebURLError& error) +{ + ResourceError resourceError; + if (InspectorController* ic = inspectorController()) + ic->didFailLoading(resourceId, resourceError); +} + +void WebDevToolsAgentImpl::evaluateInWebInspector(long callId, const WebString& script) +{ + InspectorController* ic = inspectorController(); + ic->evaluateForTestInFrontend(callId, script); +} + +void WebDevToolsAgentImpl::setTimelineProfilingEnabled(bool enabled) +{ + InspectorController* ic = inspectorController(); + if (enabled) + ic->startTimelineProfiler(); + else + ic->stopTimelineProfiler(); +} + +WebDevToolsAgent* WebDevToolsAgent::create(WebView* webview, WebDevToolsAgentClient* client) +{ + return new WebDevToolsAgentImpl(static_cast<WebViewImpl*>(webview), client); +} + +void WebDevToolsAgent::executeDebuggerCommand(const WebString& command, int callerId) +{ + DebuggerAgentManager::executeDebuggerCommand(command, callerId); +} + +void WebDevToolsAgent::debuggerPauseScript() +{ + DebuggerAgentManager::pauseScript(); +} + +void WebDevToolsAgent::setMessageLoopDispatchHandler(MessageLoopDispatchHandler handler) +{ + DebuggerAgentManager::setMessageLoopDispatchHandler(handler); +} + +bool WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread(const WebDevToolsMessageData& data) +{ + IORPCDelegate transport; + ProfilerAgentDelegateStub stub(&transport); + ProfilerAgentImpl agent(&stub); + return ProfilerAgentDispatch::dispatch(&agent, data); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.h b/WebKit/chromium/src/WebDevToolsAgentImpl.h new file mode 100644 index 0000000..3f5928b --- /dev/null +++ b/WebKit/chromium/src/WebDevToolsAgentImpl.h @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebDevToolsAgentImpl_h +#define WebDevToolsAgentImpl_h + +#include "APUAgentDelegate.h" +#include "DevToolsRPC.h" +#include "ToolsAgent.h" +#include "WebDevToolsAgentPrivate.h" + +#include <v8.h> +#include <wtf/OwnPtr.h> + +namespace WebCore { +class Document; +class InspectorController; +class Node; +class String; +} + +namespace WebKit { + +class DebuggerAgentDelegateStub; +class DebuggerAgentImpl; +class WebDevToolsAgentClient; +class WebFrame; +class WebFrameImpl; +class WebString; +class WebURLRequest; +class WebURLResponse; +class WebViewImpl; +struct WebURLError; +struct WebDevToolsMessageData; + +class WebDevToolsAgentImpl : public WebDevToolsAgentPrivate, + public ToolsAgent, + public DevToolsRPC::Delegate { +public: + WebDevToolsAgentImpl(WebViewImpl* webViewImpl, WebDevToolsAgentClient* client); + virtual ~WebDevToolsAgentImpl(); + + // ToolsAgent implementation. + virtual void dispatchOnInspectorController(int callId, const WebCore::String& functionName, const WebCore::String& jsonArgs); + virtual void dispatchOnInjectedScript(int callId, int injectedScriptId, const WebCore::String& functionName, const WebCore::String& jsonArgs, bool async); + virtual void executeVoidJavaScript(); + + // WebDevToolsAgentPrivate implementation. + virtual void didClearWindowObject(WebFrameImpl* frame); + virtual void didCommitProvisionalLoad(WebFrameImpl* frame, bool isNewNavigation); + + // WebDevToolsAgent implementation. + virtual void attach(); + virtual void detach(); + virtual void didNavigate(); + virtual void dispatchMessageFromFrontend(const WebDevToolsMessageData& data); + virtual void inspectElementAt(const WebPoint& point); + virtual void evaluateInWebInspector(long callId, const WebString& script); + virtual void setRuntimeFeatureEnabled(const WebString& feature, bool enabled); + virtual void setTimelineProfilingEnabled(bool enable); + + virtual void identifierForInitialRequest(unsigned long, WebFrame*, const WebURLRequest&); + virtual void willSendRequest(unsigned long, const WebURLRequest&); + virtual void didReceiveData(unsigned long, int length); + virtual void didReceiveResponse(unsigned long, const WebURLResponse&); + virtual void didFinishLoading(unsigned long); + virtual void didFailLoading(unsigned long, const WebURLError&); + + // DevToolsRPC::Delegate implementation. + virtual void sendRpcMessage(const WebDevToolsMessageData& data); + + void forceRepaint(); + + int hostId() { return m_hostId; } + +private: + static v8::Handle<v8::Value> jsDispatchOnClient(const v8::Arguments& args); + static v8::Handle<v8::Value> jsDispatchToApu(const v8::Arguments& args); + static v8::Handle<v8::Value> jsEvaluateOnSelf(const v8::Arguments& args); + static v8::Handle<v8::Value> jsOnRuntimeFeatureStateChanged(const v8::Arguments& args); + + void disposeUtilityContext(); + void unhideResourcesPanelIfNecessary(); + + void compileUtilityScripts(); + void initDevToolsAgentHost(); + void resetInspectorFrontendProxy(); + void setApuAgentEnabled(bool enabled); + + WebCore::InspectorController* inspectorController(); + + // Creates InspectorBackend v8 wrapper in the utility context so that it's + // methods prototype is Function.protoype object from the utility context. + // Otherwise some useful methods defined on Function.prototype(such as bind) + // are missing for InspectorController native methods. + v8::Local<v8::Object> createInspectorBackendV8Wrapper(); + + int m_hostId; + WebDevToolsAgentClient* m_client; + WebViewImpl* m_webViewImpl; + OwnPtr<DebuggerAgentDelegateStub> m_debuggerAgentDelegateStub; + OwnPtr<ToolsAgentDelegateStub> m_toolsAgentDelegateStub; + OwnPtr<DebuggerAgentImpl> m_debuggerAgentImpl; + OwnPtr<ApuAgentDelegateStub> m_apuAgentDelegateStub; + bool m_apuAgentEnabled; + bool m_resourceTrackingWasEnabled; + bool m_attached; + // TODO(pfeldman): This should not be needed once GC styles issue is fixed + // for matching rules. + v8::Persistent<v8::Context> m_utilityContext; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp b/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp new file mode 100644 index 0000000..0a92319 --- /dev/null +++ b/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp @@ -0,0 +1,396 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebDevToolsFrontendImpl.h" + +#include "BoundObject.h" +#include "ContextMenuController.h" +#include "ContextMenuItem.h" +#include "DOMWindow.h" +#include "DebuggerAgent.h" +#include "DevToolsRPCJS.h" +#include "Document.h" +#include "Event.h" +#include "Frame.h" +#include "InspectorBackend.h" +#include "InspectorController.h" +#include "InspectorFrontendHost.h" +#include "Node.h" +#include "Page.h" +#include "Pasteboard.h" +#include "PlatformString.h" +#include "ProfilerAgent.h" +#include "SecurityOrigin.h" +#include "Settings.h" +#include "ToolsAgent.h" +#include "V8Binding.h" +#include "V8CustomBinding.h" +#include "V8DOMWrapper.h" +#include "V8InspectorFrontendHost.h" +#include "V8Node.h" +#include "V8Proxy.h" +#include "V8Utilities.h" +#include "WebDevToolsFrontendClient.h" +#include "WebFrameImpl.h" +#include "WebScriptSource.h" +#include "WebViewImpl.h" +#include <wtf/OwnPtr.h> +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace WebKit { + +static v8::Local<v8::String> ToV8String(const String& s) +{ + if (s.isNull()) + return v8::Local<v8::String>(); + + return v8::String::New(reinterpret_cast<const uint16_t*>(s.characters()), s.length()); +} + +DEFINE_RPC_JS_BOUND_OBJ(DebuggerAgent, DEBUGGER_AGENT_STRUCT, DebuggerAgentDelegate, DEBUGGER_AGENT_DELEGATE_STRUCT) +DEFINE_RPC_JS_BOUND_OBJ(ProfilerAgent, PROFILER_AGENT_STRUCT, ProfilerAgentDelegate, PROFILER_AGENT_DELEGATE_STRUCT) +DEFINE_RPC_JS_BOUND_OBJ(ToolsAgent, TOOLS_AGENT_STRUCT, ToolsAgentDelegate, TOOLS_AGENT_DELEGATE_STRUCT) + +WebDevToolsFrontend* WebDevToolsFrontend::create( + WebView* view, + WebDevToolsFrontendClient* client, + const WebString& applicationLocale) +{ + return new WebDevToolsFrontendImpl( + static_cast<WebViewImpl*>(view), + client, + applicationLocale); +} + +WebDevToolsFrontendImpl::WebDevToolsFrontendImpl( + WebViewImpl* webViewImpl, + WebDevToolsFrontendClient* client, + const String& applicationLocale) + : m_webViewImpl(webViewImpl) + , m_client(client) + , m_applicationLocale(applicationLocale) + , m_loaded(false) +{ + WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); + v8::HandleScope scope; + v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame()); + + m_debuggerAgentObj.set(new JSDebuggerAgentBoundObj(this, frameContext, "RemoteDebuggerAgent")); + m_profilerAgentObj.set(new JSProfilerAgentBoundObj(this, frameContext, "RemoteProfilerAgent")); + m_toolsAgentObj.set(new JSToolsAgentBoundObj(this, frameContext, "RemoteToolsAgent")); + + // Debugger commands should be sent using special method. + BoundObject debuggerCommandExecutorObj(frameContext, this, "RemoteDebuggerCommandExecutor"); + debuggerCommandExecutorObj.addProtoFunction( + "DebuggerCommand", + WebDevToolsFrontendImpl::jsDebuggerCommand); + debuggerCommandExecutorObj.addProtoFunction( + "DebuggerPauseScript", + WebDevToolsFrontendImpl::jsDebuggerPauseScript); + debuggerCommandExecutorObj.build(); + + BoundObject devToolsHost(frameContext, this, "InspectorFrontendHost"); + devToolsHost.addProtoFunction( + "loaded", + WebDevToolsFrontendImpl::jsLoaded); + devToolsHost.addProtoFunction( + "platform", + WebDevToolsFrontendImpl::jsPlatform); + devToolsHost.addProtoFunction( + "port", + WebDevToolsFrontendImpl::jsPort); + devToolsHost.addProtoFunction( + "copyText", + WebDevToolsFrontendImpl::jsCopyText); + devToolsHost.addProtoFunction( + "activateWindow", + WebDevToolsFrontendImpl::jsActivateWindow); + devToolsHost.addProtoFunction( + "closeWindow", + WebDevToolsFrontendImpl::jsCloseWindow); + devToolsHost.addProtoFunction( + "attach", + WebDevToolsFrontendImpl::jsDockWindow); + devToolsHost.addProtoFunction( + "detach", + WebDevToolsFrontendImpl::jsUndockWindow); + devToolsHost.addProtoFunction( + "localizedStringsURL", + WebDevToolsFrontendImpl::jsLocalizedStringsURL); + devToolsHost.addProtoFunction( + "hiddenPanels", + WebDevToolsFrontendImpl::jsHiddenPanels); + devToolsHost.addProtoFunction( + "setting", + WebDevToolsFrontendImpl::jsSetting); + devToolsHost.addProtoFunction( + "setSetting", + WebDevToolsFrontendImpl::jsSetSetting); + devToolsHost.addProtoFunction( + "windowUnloading", + WebDevToolsFrontendImpl::jsWindowUnloading); + devToolsHost.addProtoFunction( + "showContextMenu", + WebDevToolsFrontendImpl::jsShowContextMenu); + devToolsHost.build(); +} + +WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl() +{ + if (m_menuProvider) + m_menuProvider->disconnect(); +} + +void WebDevToolsFrontendImpl::dispatchMessageFromAgent(const WebDevToolsMessageData& data) +{ + Vector<String> v; + v.append(data.className); + v.append(data.methodName); + for (size_t i = 0; i < data.arguments.size(); i++) + v.append(data.arguments[i]); + if (!m_loaded) { + m_pendingIncomingMessages.append(v); + return; + } + executeScript(v); +} + +void WebDevToolsFrontendImpl::executeScript(const Vector<String>& v) +{ + WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); + v8::HandleScope scope; + v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame()); + v8::Context::Scope contextScope(frameContext); + v8::Handle<v8::Value> dispatchFunction = frameContext->Global()->Get(v8::String::New("devtools$$dispatch")); + ASSERT(dispatchFunction->IsFunction()); + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatchFunction); + Vector< v8::Handle<v8::Value> > args; + for (size_t i = 0; i < v.size(); i++) + args.append(ToV8String(v.at(i))); + function->Call(frameContext->Global(), args.size(), args.data()); +} + +void WebDevToolsFrontendImpl::dispatchOnWebInspector(const String& methodName, const String& param) +{ + WebFrameImpl* frame = m_webViewImpl->mainFrameImpl(); + v8::HandleScope scope; + v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame()); + v8::Context::Scope contextScope(frameContext); + + v8::Handle<v8::Value> webInspector = frameContext->Global()->Get(v8::String::New("WebInspector")); + ASSERT(webInspector->IsObject()); + v8::Handle<v8::Object> webInspectorObj = v8::Handle<v8::Object>::Cast(webInspector); + + v8::Handle<v8::Value> method = webInspectorObj->Get(ToV8String(methodName)); + ASSERT(method->IsFunction()); + v8::Handle<v8::Function> methodFunc = v8::Handle<v8::Function>::Cast(method); + v8::Handle<v8::Value> args[] = { + ToV8String(param) + }; + methodFunc->Call(frameContext->Global(), 1, args); +} + +void WebDevToolsFrontendImpl::sendRpcMessage(const WebDevToolsMessageData& data) +{ + m_client->sendMessageToAgent(data); +} + +void WebDevToolsFrontendImpl::contextMenuItemSelected(ContextMenuItem* item) +{ + int itemNumber = item->action() - ContextMenuItemBaseCustomTag; + dispatchOnWebInspector("contextMenuItemSelected", String::number(itemNumber)); +} + +void WebDevToolsFrontendImpl::contextMenuCleared() +{ + dispatchOnWebInspector("contextMenuCleared", ""); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsLoaded(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + frontend->m_loaded = true; + + // Grant the devtools page the ability to have source view iframes. + Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); + SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin(); + origin->grantUniversalAccess(); + + for (Vector<Vector<String> >::iterator it = frontend->m_pendingIncomingMessages.begin(); + it != frontend->m_pendingIncomingMessages.end(); + ++it) { + frontend->executeScript(*it); + } + frontend->m_pendingIncomingMessages.clear(); + return v8::Undefined(); +} + +// static +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsPlatform(const v8::Arguments& args) +{ +#if defined(OS_MACOSX) + return v8String("mac"); +#elif defined(OS_LINUX) + return v8String("linux"); +#elif defined(OS_WIN) + return v8String("windows"); +#else + return v8String("unknown"); +#endif +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsPort(const v8::Arguments& args) +{ + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsCopyText(const v8::Arguments& args) +{ + String text = WebCore::toWebCoreStringWithNullCheck(args[0]); + Pasteboard::generalPasteboard()->writePlainText(text); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsActivateWindow(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + frontend->m_client->activateWindow(); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsCloseWindow(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + frontend->m_client->closeWindow(); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsDockWindow(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + frontend->m_client->dockWindow(); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsUndockWindow(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + frontend->m_client->undockWindow(); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsLocalizedStringsURL(const v8::Arguments& args) +{ + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsHiddenPanels(const v8::Arguments& args) +{ + return v8String(""); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsDebuggerCommand(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + WebString command = WebCore::toWebCoreStringWithNullCheck(args[0]); + frontend->m_client->sendDebuggerCommandToAgent(command); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsSetting(const v8::Arguments& args) +{ + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsSetSetting(const v8::Arguments& args) +{ + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsDebuggerPauseScript(const v8::Arguments& args) +{ + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + frontend->m_client->sendDebuggerPauseScript(); + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsWindowUnloading(const v8::Arguments& args) +{ + // TODO(pfeldman): Implement this. + return v8::Undefined(); +} + +v8::Handle<v8::Value> WebDevToolsFrontendImpl::jsShowContextMenu(const v8::Arguments& args) +{ + if (args.Length() < 2) + return v8::Undefined(); + + v8::Local<v8::Object> eventWrapper = v8::Local<v8::Object>::Cast(args[0]); + if (V8DOMWrapper::domWrapperType(eventWrapper) != V8ClassIndex::EVENT) + return v8::Undefined(); + + Event* event = V8Event::toNative(eventWrapper); + if (!args[1]->IsArray()) + return v8::Undefined(); + + v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]); + Vector<ContextMenuItem*> items; + + for (size_t i = 0; i < array->Length(); ++i) { + v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(array->Get(v8::Integer::New(i))); + v8::Local<v8::Value> label = item->Get(v8::String::New("label")); + v8::Local<v8::Value> id = item->Get(v8::String::New("id")); + if (label->IsUndefined() || id->IsUndefined()) { + items.append(new ContextMenuItem(SeparatorType, + ContextMenuItemTagNoAction, + String())); + } else { + ContextMenuAction typedId = static_cast<ContextMenuAction>( + ContextMenuItemBaseCustomTag + id->ToInt32()->Value()); + items.append(new ContextMenuItem(ActionType, + typedId, + toWebCoreStringWithNullCheck(label))); + } + } + + WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(v8::External::Cast(*args.Data())->Value()); + + frontend->m_menuProvider = MenuProvider::create(frontend, items); + + ContextMenuController* menuController = frontend->m_webViewImpl->page()->contextMenuController(); + menuController->showContextMenu(event, frontend->m_menuProvider); + + return v8::Undefined(); +} + +} // namespace WebKit diff --git a/WebKit/chromium/src/WebDevToolsFrontendImpl.h b/WebKit/chromium/src/WebDevToolsFrontendImpl.h new file mode 100644 index 0000000..62b34da --- /dev/null +++ b/WebKit/chromium/src/WebDevToolsFrontendImpl.h @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebDevToolsFrontendImpl_h +#define WebDevToolsFrontendImpl_h + +#include "ContextMenu.h" +#include "ContextMenuProvider.h" +#include "DevToolsRPC.h" +#include "WebDevToolsFrontend.h" +#include <v8.h> +#include <wtf/HashMap.h> +#include <wtf/Noncopyable.h> +#include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> + +namespace WebCore { +class ContextMenuItem; +class Node; +class Page; +class String; +} + +namespace WebKit { + +class JSDebuggerAgentBoundObj; +class JSProfilerAgentBoundObj; +class JSToolsAgentBoundObj; +class WebDevToolsClientDelegate; +class WebViewImpl; +struct WebDevToolsMessageData; + +class WebDevToolsFrontendImpl : public WebKit::WebDevToolsFrontend + , public DevToolsRPC::Delegate + , public Noncopyable { +public: + WebDevToolsFrontendImpl( + WebKit::WebViewImpl* webViewImpl, + WebKit::WebDevToolsFrontendClient* client, + const String& applicationLocale); + virtual ~WebDevToolsFrontendImpl(); + + // DevToolsRPC::Delegate implementation. + virtual void sendRpcMessage(const WebKit::WebDevToolsMessageData& data); + + // WebDevToolsFrontend implementation. + virtual void dispatchMessageFromAgent(const WebKit::WebDevToolsMessageData& data); + +private: + class MenuProvider : public WebCore::ContextMenuProvider { + public: + static PassRefPtr<MenuProvider> create(WebDevToolsFrontendImpl* frontendHost, const Vector<WebCore::ContextMenuItem*>& items) + { + return adoptRef(new MenuProvider(frontendHost, items)); + } + + virtual ~MenuProvider() + { + contextMenuCleared(); + } + + void disconnect() + { + m_frontendHost = 0; + } + + virtual void populateContextMenu(WebCore::ContextMenu* menu) + { + for (size_t i = 0; i < m_items.size(); ++i) + menu->appendItem(*m_items[i]); + } + + virtual void contextMenuItemSelected(WebCore::ContextMenuItem* item) + { + if (m_frontendHost) + m_frontendHost->contextMenuItemSelected(item); + } + + virtual void contextMenuCleared() + { + if (m_frontendHost) + m_frontendHost->contextMenuCleared(); + deleteAllValues(m_items); + m_items.clear(); + } + + private: + MenuProvider(WebDevToolsFrontendImpl* frontendHost, const Vector<WebCore::ContextMenuItem*>& items) + : m_frontendHost(frontendHost) + , m_items(items) { } + WebDevToolsFrontendImpl* m_frontendHost; + Vector<WebCore::ContextMenuItem*> m_items; + }; + + void executeScript(const Vector<String>& v); + void dispatchOnWebInspector(const String& method, const String& param); + + // friend class MenuSelectionHandler; + void contextMenuItemSelected(WebCore::ContextMenuItem* menuItem); + void contextMenuCleared(); + + static v8::Handle<v8::Value> jsLoaded(const v8::Arguments& args); + static v8::Handle<v8::Value> jsPlatform(const v8::Arguments& args); + static v8::Handle<v8::Value> jsPort(const v8::Arguments& args); + static v8::Handle<v8::Value> jsCopyText(const v8::Arguments& args); + + static v8::Handle<v8::Value> jsActivateWindow(const v8::Arguments& args); + static v8::Handle<v8::Value> jsCloseWindow(const v8::Arguments& args); + static v8::Handle<v8::Value> jsDockWindow(const v8::Arguments& args); + static v8::Handle<v8::Value> jsUndockWindow(const v8::Arguments& args); + static v8::Handle<v8::Value> jsLocalizedStringsURL(const v8::Arguments& args); + static v8::Handle<v8::Value> jsHiddenPanels(const v8::Arguments& args); + static v8::Handle<v8::Value> jsDebuggerCommand(const v8::Arguments& args); + static v8::Handle<v8::Value> jsSetting(const v8::Arguments& args); + static v8::Handle<v8::Value> jsSetSetting(const v8::Arguments& args); + static v8::Handle<v8::Value> jsDebuggerPauseScript(const v8::Arguments& args); + static v8::Handle<v8::Value> jsWindowUnloading(const v8::Arguments& args); + static v8::Handle<v8::Value> jsShowContextMenu(const v8::Arguments& args); + + WebKit::WebViewImpl* m_webViewImpl; + WebKit::WebDevToolsFrontendClient* m_client; + String m_applicationLocale; + OwnPtr<JSDebuggerAgentBoundObj> m_debuggerAgentObj; + OwnPtr<JSProfilerAgentBoundObj> m_profilerAgentObj; + OwnPtr<JSToolsAgentBoundObj> m_toolsAgentObj; + bool m_loaded; + Vector<Vector<String> > m_pendingIncomingMessages; + RefPtr<MenuProvider> m_menuProvider; +}; + +} // namespace WebKit + +#endif diff --git a/WebKit/chromium/src/WebFrameImpl.cpp b/WebKit/chromium/src/WebFrameImpl.cpp index 28c27cc..2f911f1 100644 --- a/WebKit/chromium/src/WebFrameImpl.cpp +++ b/WebKit/chromium/src/WebFrameImpl.cpp @@ -1077,6 +1077,28 @@ WebString WebFrameImpl::selectionAsMarkup() const return createMarkup(range.get(), 0); } +void WebFrameImpl::selectWordAroundPosition(Frame* frame, VisiblePosition pos) +{ + VisibleSelection selection(pos); + selection.expandUsingGranularity(WordGranularity); + + if (selection.isRange()) + frame->setSelectionGranularity(WordGranularity); + + if (frame->shouldChangeSelection(selection)) + frame->selection()->setSelection(selection); +} + +bool WebFrameImpl::selectWordAroundCaret() +{ + SelectionController* controller = frame()->selection(); + ASSERT(!controller->isNone()); + if (controller->isNone() || controller->isRange()) + return false; + selectWordAroundPosition(frame(), controller->selection().visibleStart()); + return true; +} + int WebFrameImpl::printBegin(const WebSize& pageSize) { ASSERT(!frame()->document()->isFrameSet()); @@ -1496,6 +1518,21 @@ WebString WebFrameImpl::counterValueForElementById(const WebString& id) const return counterValueForElement(element); } +int WebFrameImpl::pageNumberForElementById(const WebString& id, + float pageWidthInPixels, + float pageHeightInPixels) const +{ + if (!m_frame) + return -1; + + Element* element = m_frame->document()->getElementById(id); + if (!element) + return -1; + + FloatSize pageSize(pageWidthInPixels, pageHeightInPixels); + return PrintContext::pageNumberForElement(element, pageSize); +} + // WebFrameImpl public --------------------------------------------------------- PassRefPtr<WebFrameImpl> WebFrameImpl::create(WebFrameClient* client) diff --git a/WebKit/chromium/src/WebFrameImpl.h b/WebKit/chromium/src/WebFrameImpl.h index ba8d279..ccba6d4 100644 --- a/WebKit/chromium/src/WebFrameImpl.h +++ b/WebKit/chromium/src/WebFrameImpl.h @@ -141,6 +141,7 @@ public: virtual WebRange selectionRange() const; virtual WebString selectionAsText() const; virtual WebString selectionAsMarkup() const; + virtual bool selectWordAroundCaret(); virtual int printBegin(const WebSize& pageSize); virtual float printPage(int pageToPrint, WebCanvas*); virtual float getPrintPageShrink(int page); @@ -163,6 +164,9 @@ public: virtual WebString contentAsMarkup() const; virtual WebString renderTreeAsText() const; virtual WebString counterValueForElementById(const WebString& id) const; + virtual int pageNumberForElementById(const WebString& id, + float pageWidthInPixels, + float pageHeightInPixels) const; static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); ~WebFrameImpl(); @@ -219,6 +223,8 @@ public: WebFrameClient* client() const { return m_client; } void dropClient() { m_client = 0; } + static void selectWordAroundPosition(WebCore::Frame*, WebCore::VisiblePosition); + private: class DeferredScopeStringMatches; friend class DeferredScopeStringMatches; diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index c2a3535..b1f1f03 100644 --- a/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp +++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -85,10 +85,16 @@ void WebMediaPlayerClientImpl::readyStateChanged() m_mediaPlayer->readyStateChanged(); } -void WebMediaPlayerClientImpl::volumeChanged() +void WebMediaPlayerClientImpl::volumeChanged(float newVolume) { ASSERT(m_mediaPlayer); - m_mediaPlayer->volumeChanged(); + m_mediaPlayer->volumeChanged(newVolume); +} + +void WebMediaPlayerClientImpl::muteChanged(bool newMute) +{ + ASSERT(m_mediaPlayer); + m_mediaPlayer->muteChanged(newMute); } void WebMediaPlayerClientImpl::timeChanged() diff --git a/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/WebKit/chromium/src/WebMediaPlayerClientImpl.h index 7f087d0..4adbed2 100644 --- a/WebKit/chromium/src/WebMediaPlayerClientImpl.h +++ b/WebKit/chromium/src/WebMediaPlayerClientImpl.h @@ -53,7 +53,8 @@ public: // WebMediaPlayerClient methods: virtual void networkStateChanged(); virtual void readyStateChanged(); - virtual void volumeChanged(); + virtual void volumeChanged(float); + virtual void muteChanged(bool); virtual void timeChanged(); virtual void repaint(); virtual void durationChanged(); diff --git a/WebKit/chromium/src/WebSecurityOrigin.cpp b/WebKit/chromium/src/WebSecurityOrigin.cpp index 87916ca..81546da 100644 --- a/WebKit/chromium/src/WebSecurityOrigin.cpp +++ b/WebKit/chromium/src/WebSecurityOrigin.cpp @@ -47,6 +47,11 @@ WebSecurityOrigin* WebSecurityOrigin::createFromDatabaseIdentifier(const WebStri return new WebSecurityOrigin(SecurityOrigin::createFromDatabaseIdentifier(databaseIdentifier)); } +WebSecurityOrigin WebSecurityOrigin::createFromString(const WebString& origin) +{ + return WebSecurityOrigin(SecurityOrigin::createFromString(origin)); +} + void WebSecurityOrigin::reset() { assign(0); diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp index 97825e9..e030d72 100644 --- a/WebKit/chromium/src/WebViewImpl.cpp +++ b/WebKit/chromium/src/WebViewImpl.cpp @@ -1316,9 +1316,9 @@ void WebViewImpl::performMediaPlayerAction(const WebMediaPlayerAction& action, switch (action.type) { case WebMediaPlayerAction::Play: if (action.enable) - mediaElement->play(); + mediaElement->play(mediaElement->processingUserGesture()); else - mediaElement->pause(); + mediaElement->pause(mediaElement->processingUserGesture()); break; case WebMediaPlayerAction::Mute: mediaElement->setMuted(action.enable); @@ -1694,6 +1694,20 @@ void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor, #endif } +void WebViewImpl::addUserScript(const WebString& sourceCode, bool runAtStart) +{ + PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName); + RefPtr<DOMWrapperWorld> world(DOMWrapperWorld::create()); + pageGroup->addUserScriptToWorld(world.get(), sourceCode, WebURL(), 0, 0, + runAtStart ? InjectAtDocumentStart : InjectAtDocumentEnd); +} + +void WebViewImpl::removeAllUserContent() +{ + PageGroup* pageGroup = PageGroup::pageGroup(pageGroupName); + pageGroup->removeAllUserContent(); +} + void WebViewImpl::didCommitLoad(bool* isNewNavigation) { if (isNewNavigation) diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h index ed5cc5f..e2292f4 100644 --- a/WebKit/chromium/src/WebViewImpl.h +++ b/WebKit/chromium/src/WebViewImpl.h @@ -162,6 +162,9 @@ public: unsigned inactiveBackgroundColor, unsigned inactiveForegroundColor); virtual void performCustomContextMenuAction(unsigned action); + virtual void addUserScript(const WebString& sourceCode, + bool runAtStart); + virtual void removeAllUserContent(); // WebViewImpl diff --git a/WebKit/chromium/src/linux/WebRenderTheme.cpp b/WebKit/chromium/src/linux/WebRenderTheme.cpp new file mode 100644 index 0000000..16ea22c --- /dev/null +++ b/WebKit/chromium/src/linux/WebRenderTheme.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 Joel Stanley. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebRenderTheme.h" + +#include "RenderThemeChromiumLinux.h" +#include "WebView.h" + +using WebCore::RenderTheme; +using WebCore::RenderThemeChromiumLinux; + +namespace WebKit { + +void setCaretBlinkInterval(double interval) +{ + RenderThemeChromiumLinux::setCaretBlinkInterval(interval); +} + +} // namespace WebKit diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index 3cd90de..92de7e4 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,29 @@ +2010-02-02 Gustavo Noronha Silva <gns@gnome.org> + + Reviewed by Xan Lopez. + + Changes in 1.1.20, and documentation control files update. + + * NEWS: + * docs/webkitgtk-docs.sgml: + +2010-02-02 Martin Robinson <martin.james.robinson@gmail.com> + + Reviewed by Gustavo Noronha Silva. + + [GTK] When selection changes selections in other WebView are not collapsed + https://bugs.webkit.org/show_bug.cgi?id=34043 + + Collapse the selection of a WebView even when the new selection owner is + a new WebView. + + * WebCoreSupport/PasteboardHelperGtk.cpp: + (WebKit::clearClipboardContentsCallback): Only clear the DataObject we are setting + is not the same as the one referenced in this callback. Use the same behavior for + collapsing the selection. + (WebKit::PasteboardHelperGtk::writeClipboardContents): Instead of recording a boolean + record the actual data used while writing to the clipboard. + 2010-01-27 Martin Robinson <mrobinson@webkit.org> Reviewed by Gustavo Noronha Silva. diff --git a/WebKit/gtk/NEWS b/WebKit/gtk/NEWS index 18b5e3c..807fca4 100644 --- a/WebKit/gtk/NEWS +++ b/WebKit/gtk/NEWS @@ -1,4 +1,18 @@ ================= +WebKitGTK+ 1.1.20 +================= + +What's new in WebKitGTK+ 1.1.20? + + - Fixes to the HTML5 Media Player infrastructure to satisfy sites + that require cookies, and Referer to be sent; this makes + WebKitGTK+ able to support the new HTML5 support added to Youtube, + and Vimeo, for instance. + - Windowless plugin support is finally here, making it possible to + get plugins to behave on various web pages. + - The usual stream of fixes, and improvements + +================= WebKitGTK+ 1.1.19 ================= diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp index 8406ada..b8eb92d 100644 --- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp @@ -105,7 +105,8 @@ static GtkTargetList* targetListForDataObject(DataObjectGtk* dataObject) return list; } -static bool settingClipboard = false; +static DataObjectGtk* settingClipboardDataObject = 0; +static gpointer settingClipboardData = 0; static void getClipboardContentsCallback(GtkClipboard* clipboard, GtkSelectionData *selectionData, guint info, gpointer data) { DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); @@ -115,17 +116,16 @@ static void getClipboardContentsCallback(GtkClipboard* clipboard, GtkSelectionDa static void clearClipboardContentsCallback(GtkClipboard* clipboard, gpointer data) { - // GTK will call the clear clipboard callback while setting clipboard data. - // We don't actually want to clear the DataObject during that time. - if (settingClipboard) - return; - DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); ASSERT(dataObject); - dataObject->clear(); - // This will be true for clipboards other than X11 primary. - if (!data) + // Only clear the DataObject for this clipboard if we are not currently setting it. + if (dataObject != settingClipboardDataObject) + dataObject->clear(); + + // Only collapse the selection if this is an X11 primary clipboard + // and we aren't currently setting the clipboard for this WebView. + if (!data || data == settingClipboardData) return; WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); @@ -154,7 +154,8 @@ void PasteboardHelperGtk::writeClipboardContents(GtkClipboard* clipboard, gpoint GtkTargetEntry* table = gtk_target_table_new_from_list(list, &numberOfTargets); if (numberOfTargets > 0 && table) { - settingClipboard = true; + settingClipboardDataObject = dataObject; + settingClipboardData = data; // Protect the web view from being destroyed before one of the clipboard callbacks // is called. Balanced in both getClipboardContentsCallback and @@ -168,7 +169,8 @@ void PasteboardHelperGtk::writeClipboardContents(GtkClipboard* clipboard, gpoint if (!succeeded) g_object_unref(webView); - settingClipboard = false; + settingClipboardDataObject = 0; + settingClipboardData = 0; } else gtk_clipboard_clear(clipboard); diff --git a/WebKit/gtk/docs/webkitgtk-docs.sgml b/WebKit/gtk/docs/webkitgtk-docs.sgml index d61a4fd..77f3482 100644 --- a/WebKit/gtk/docs/webkitgtk-docs.sgml +++ b/WebKit/gtk/docs/webkitgtk-docs.sgml @@ -100,4 +100,7 @@ <index id="index-1.1.18" role="1.1.18"> <title>Index of new symbols in 1.1.18</title> </index> + <index id="index-1.1.20" role="1.1.20"> + <title>Index of new symbols in 1.1.20</title> + </index> </book> diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index 205583a..8bbd4de 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1 +1,38 @@ +2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Eric Seidel. + + Provide a way to get page number with layoutTestController + https://bugs.webkit.org/show_bug.cgi?id=33840 + + * Misc/WebCoreStatistics.h: + * Misc/WebCoreStatistics.mm: + (-[WebFrame pageNumberForElement:element:pageWidth:]): + +2010-01-29 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Sam Weinig + Oliver Hunt. + + Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds + + Pass processeing user gensture flag to media play/pause methods. + + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController setPlaying:]): + +2010-02-01 Dan Bernstein <mitz@apple.com> + + Reviewed by Anders Carlsson. + + <rdar://problem/7044385> Crash at NetscapePlugInStreamLoader::didReceiveResponse() + + The crash was caused by having two streams with a streamID of 1. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::NetscapePluginInstanceProxy): Fixed a typo. Now + correctly increments m_currentURLRequestID to account for the manual stream. + (WebKit::NetscapePluginInstanceProxy::disconnectStream): If the stream is the manual stream, + null it out instead of trying to remove it from the map. Added an assertion. + (WebKit::NetscapePluginInstanceProxy::loadRequest): Added an assertion. + == Rolled over to ChangeLog-2010-01-29 == diff --git a/WebKit/mac/Misc/WebCoreStatistics.h b/WebKit/mac/Misc/WebCoreStatistics.h index 7a189ae..6c45fb9 100644 --- a/WebKit/mac/Misc/WebCoreStatistics.h +++ b/WebKit/mac/Misc/WebCoreStatistics.h @@ -84,4 +84,5 @@ @interface WebFrame (WebKitDebug) - (NSString *)renderTreeAsExternalRepresentation; - (NSString *)counterValueForElement:(DOMElement*)element; +- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels; @end diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm index f204ddb..b18ee29 100644 --- a/WebKit/mac/Misc/WebCoreStatistics.mm +++ b/WebKit/mac/Misc/WebCoreStatistics.mm @@ -40,6 +40,7 @@ #import <WebCore/IconDatabase.h> #import <WebCore/JSDOMWindow.h> #import <WebCore/PageCache.h> +#import <WebCore/PrintContext.h> #import <WebCore/RenderTreeAsText.h> #import <WebCore/RenderView.h> @@ -250,4 +251,9 @@ using namespace WebCore; return counterValueForElement(core(element)); } +- (int)pageNumberForElement:(DOMElement*)element:(float)pageWidthInPixels:(float)pageHeightInPixels +{ + return PrintContext::pageNumberForElement(core(element), FloatSize(pageWidthInPixels, pageHeightInPixels)); +} + @end diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm index 187b0ea..e4fe1d2 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm @@ -126,7 +126,7 @@ NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy if (fullFramePlugin) { // For full frame plug-ins, the first requestID will always be the one for the already // open stream. - ++m_currentRequestID; + ++m_currentURLRequestID; } // Assign a plug-in ID. @@ -261,6 +261,12 @@ bool NetscapePluginInstanceProxy::cancelStreamLoad(uint32_t streamID, NPReason r void NetscapePluginInstanceProxy::disconnectStream(HostedNetscapePluginStream* stream) { + if (stream == m_manualStream) { + m_manualStream = 0; + return; + } + + ASSERT(m_streams.get(stream->streamID()) == stream); m_streams.remove(stream->streamID()); } @@ -655,6 +661,7 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch } else { RefPtr<HostedNetscapePluginStream> stream = HostedNetscapePluginStream::create(this, requestID, request); + ASSERT(!m_streams.contains(requestID)); m_streams.add(requestID, stream); stream->start(); } diff --git a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm index 82cb1bf..83e2d09 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm +++ b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm @@ -578,13 +578,15 @@ static NSTextField *createTimeTextField(NSRect frame) - (void)setPlaying:(BOOL)playing { - if (![_delegate mediaElement]) + HTMLMediaElement* mediaElement = [_delegate mediaElement]; + + if (!mediaElement) return; if (playing) - [_delegate mediaElement]->play(); + mediaElement->play(mediaElement->processingUserGesture()); else - [_delegate mediaElement]->pause(); + mediaElement->pause(mediaElement->processingUserGesture()); } static NSString *timeToString(double time) diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp index 7e3b084..ea2401b 100644 --- a/WebKit/qt/Api/qwebpage.cpp +++ b/WebKit/qt/Api/qwebpage.cpp @@ -105,6 +105,7 @@ #include <QStyle> #include <QSysInfo> #include <QTextCharFormat> +#include <QTextDocument> #include <QNetworkAccessManager> #include <QNetworkRequest> #if defined(Q_WS_X11) @@ -1871,7 +1872,7 @@ void QWebPage::javaScriptAlert(QWebFrame *frame, const QString& msg) { Q_UNUSED(frame) #ifndef QT_NO_MESSAGEBOX - QMessageBox::information(view(), tr("JavaScript Alert - %1").arg(mainFrame()->url().host()), msg, QMessageBox::Ok); + QMessageBox::information(view(), tr("JavaScript Alert - %1").arg(mainFrame()->url().host()), Qt::escape(msg), QMessageBox::Ok); #endif } @@ -1887,7 +1888,7 @@ bool QWebPage::javaScriptConfirm(QWebFrame *frame, const QString& msg) #ifdef QT_NO_MESSAGEBOX return true; #else - return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()), msg, QMessageBox::Yes, QMessageBox::No); + return QMessageBox::Yes == QMessageBox::information(view(), tr("JavaScript Confirm - %1").arg(mainFrame()->url().host()), Qt::escape(msg), QMessageBox::Yes, QMessageBox::No); #endif } @@ -1906,7 +1907,7 @@ bool QWebPage::javaScriptPrompt(QWebFrame *frame, const QString& msg, const QStr Q_UNUSED(frame) bool ok = false; #ifndef QT_NO_INPUTDIALOG - QString x = QInputDialog::getText(view(), tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()), msg, QLineEdit::Normal, defaultValue, &ok); + QString x = QInputDialog::getText(view(), tr("JavaScript Prompt - %1").arg(mainFrame()->url().host()), Qt::escape(msg), QLineEdit::Normal, defaultValue, &ok); if (ok && result) *result = x; #endif diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 170665a..e63ee86 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,78 @@ +2010-02-03 Andras Becsi <abecsi@webkit.org> + + Unreviewed build fix. + + [Qt] Roll-out r54281 because it broke the build on the Qt Release bot. + + * Api/qgraphicswebview.cpp: + (QGraphicsWebViewPrivate::QGraphicsWebViewPrivate): + (QGraphicsWebViewPrivate::markForSync): + (QGraphicsWebViewPrivate::update): + (QGraphicsWebView::paint): + +2010-02-02 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Ariya Hidayat. + + Do not use a proxy widget for the QComboBox on Maemo 5, as it + is not working properly and it is not needed at all, as the + comboboxes comes up in their full width on the screen and + do not depend on view. + + * WebCoreSupport/QtFallbackWebPopup.cpp: + (WebCore::QtFallbackWebPopup::show): + +2010-02-02 Jessie Berlin <jberlin@webkit.org> + + Rubber Stamped by Holger Freyther. + + [Qt] Fix style issue identified in bug: + https://bugs.webkit.org/show_bug.cgi?id=34329 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientWebPage::InspectorClientWebPage): + Fix indentation. + +2010-02-01 Jessie Berlin <jberlin@webkit.org> + + Reviewed by Holger Freyther. + + [Qt] Enable inspecting the Web Inspector in QtLauncher + + https://bugs.webkit.org/show_bug.cgi?id=34329 + + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientWebPage::InspectorClientWebPage): + Allow the DeveloperExtrasEnabled setting to default to true for the page containing the Web Inspector. + +2010-02-02 Andreas Kling <andreas.kling@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Display HTML tags verbatim in JS alert/confirm/prompt boxes + + https://bugs.webkit.org/show_bug.cgi?id=34429 + + * Api/qwebpage.cpp: + (QWebPage::javaScriptAlert): + (QWebPage::javaScriptConfirm): + (QWebPage::javaScriptPrompt): + +2010-02-02 Noam Rosenthal <noam.rosenthal@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Enable a way to measure FPS in QGVLauncher + run QGVLauncher with --show-fps to see ongoing fps measurements + This is not meant as accurate FPS, but rather as a way to find + improvements/regressions + https://bugs.webkit.org/show_bug.cgi?id=34450 + + * QGVLauncher/main.cpp: + (MainView::MainView): initialize FPS values + (MainView::paintEvent): count a painted frame here + (MainView::printFps): we print the fps with qDebug every 5 seconds. + 2010-01-29 Ben Murdoch <benm@google.com> Reviewed by Dimitri Glazkov. diff --git a/WebKit/qt/QGVLauncher/main.cpp b/WebKit/qt/QGVLauncher/main.cpp index eefff7f..0536af5 100644 --- a/WebKit/qt/QGVLauncher/main.cpp +++ b/WebKit/qt/QGVLauncher/main.cpp @@ -125,12 +125,22 @@ public: MainView(QWidget* parent) : QGraphicsView(parent) , m_mainWidget(0) + , m_measureFps(QApplication::instance()->arguments().contains("--show-fps")) + , m_numTotalPaints(0) + , m_numPaintsSinceLastMeasure(0) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFrameShape(QFrame::NoFrame); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + if (m_measureFps) { + QTimer* fpsTimer = new QTimer(this); + fpsTimer->setInterval(5000); + m_totalStartTime = m_startTime = QTime::currentTime(); + connect(fpsTimer, SIGNAL(timeout()), this, SLOT(printFps())); + fpsTimer->start(); + } } void setMainWidget(QGraphicsWidget* widget) @@ -149,6 +159,15 @@ public: m_mainWidget->setGeometry(rect); } + void paintEvent(QPaintEvent* event) + { + QGraphicsView::paintEvent(event); + if (m_measureFps) { + ++m_numPaintsSinceLastMeasure; + ++m_numTotalPaints; + } + } + void setWaitCursor() { m_mainWidget->setCursor(Qt::WaitCursor); @@ -195,11 +214,29 @@ public slots: emit flipRequest(); } + void printFps() + { + // note that this might have a bug if you measure right around midnight, but we can live with that + QTime now = QTime::currentTime(); + int msecs = m_startTime.msecsTo(now); + int totalMsecs = m_totalStartTime.msecsTo(now); + int totalFps = totalMsecs ? m_numTotalPaints * 1000 / totalMsecs : 0; + int curFps = msecs ? m_numPaintsSinceLastMeasure * 1000 / msecs : 0; + qDebug("[FPS] From start: %d, from last paint: %d", totalFps, curFps); + m_startTime = now; + m_numPaintsSinceLastMeasure = 0; + } + signals: void flipRequest(); private: QGraphicsWidget* m_mainWidget; + bool m_measureFps; + int m_numTotalPaints; + int m_numPaintsSinceLastMeasure; + QTime m_startTime; + QTime m_totalStartTime; }; class SharedScene : public QSharedData { diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index 1caf96d..4927ea8 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -58,9 +58,8 @@ class InspectorClientWebPage : public QWebPage { friend class InspectorClientQt; public: InspectorClientWebPage(QObject* parent = 0) - : QWebPage(parent) + : QWebPage(parent) { - settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false); } QWebPage* createWindow(QWebPage::WebWindowType) diff --git a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp index 7ee2b7c..c553c45 100644 --- a/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp +++ b/WebKit/qt/WebCoreSupport/QtFallbackWebPopup.cpp @@ -95,6 +95,15 @@ void QtFallbackWebPopup::show() { populate(); m_combo->setCurrentIndex(currentIndex()); + +#if defined(Q_WS_MAEMO_5) + // Comboboxes with Qt on Maemo 5 come up in their full width on the screen, so neither + // the proxy widget, nor the coordinates are needed. + m_combo->setParent(pageClient()->ownerWidget()); + m_combo->showPopup(); + return; +#endif + QRect rect = geometry(); if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) { if (!m_proxy) { @@ -110,16 +119,11 @@ void QtFallbackWebPopup::show() } - // QCursor::pos() is not a great idea for a touch screen, but we don't need the coordinates - // as comboboxes with Qt on Maemo 5 come up in their full width on the screen. - // On the other platforms it's okay to use QCursor::pos(). -#if defined(Q_WS_MAEMO_5) - m_combo->showPopup(); -#else + // QCursor::pos() is not a great idea for a touch screen, but as Maemo 5 is handled + // separately above, this should be okay. QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QCoreApplication::sendEvent(m_combo, &event); -#endif } void QtFallbackWebPopup::hide() diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog index 6cc5d6e..36d3144 100644 --- a/WebKit/win/ChangeLog +++ b/WebKit/win/ChangeLog @@ -1,3 +1,67 @@ +2010-02-03 Brian Weinstein <bweinstein@apple.com> + + Reviewed by Steve Falkenburg. + + Scroll does not work with IBM Thinkpad. + <https://bugs.webkit.org/show_bug.cgi?id=14227> + <rdar://7142545> + + When initializing the WebView, add two scrollbar Windows inside of + our WebView, to allow it to receive WM_VSCROLL and WM_HSCROLL events. + (similar to what Firefox did in: <https://bugzilla.mozilla.org/show_bug.cgi?id=507222>. + + Only do this if the user has installed some kind of Trackpoint driver, using an algorithm + like <https://bugzilla.mozilla.org/show_bug.cgi?id=514927>. + + Also, add code to handle WM_HSCROLL and WM_VSCROLL messages to scroll + the WebView. + + * WebView.cpp: + (WebView::verticalScroll): Handle the WM_VSCROLL messages, and scroll up and down + by lines or pages. + (WebView::horizontalScroll): Handle the WM_HSCROLL messages, and scroll left or right + by lines or pages. + (WebView::WebViewWndProc): Add cases for WM_VSCROLL and WM_HSCROLL. + (WebView::initWithFrame): Call shouldInitializeTrackPointHack, and if we should, create + vertical and horizontal scrollbars to receive WM_VSCROLL and WM_HSCROLL messages. + (WebView::shouldInitializeTrackPointHack): Check if there is a registry key for + the some kind of IBM Trackpoint driver. + * WebView.h: + +2010-02-02 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Darin Adler. + + Copyright year updating for Windows version resources should be automatic + https://bugs.webkit.org/show_bug.cgi?id=34503 + + * WebKit.vcproj/WebKit.rc: + +2010-02-02 Adam Roben <aroben@apple.com> + + Stop copying WebCore's IDL files from SRCROOT to OBJROOT + + WebKit doesn't use these anymore (as of r52921). + + Part of Bug 34496: Clean up WebCore's IDL/script copying + <https://bugs.webkit.org/show_bug.cgi?id=34496> + + Reviewed by Steve Falkenburg. + + * WebKit.vcproj/WebKit.make: + +2010-01-29 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Sam Weinig + Oliver Hunt. + + Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds + + Pass processeing user gensture flag to media play/pause methods. + + * FullscreenVideoController.cpp: + (FullscreenVideoController::play): + (FullscreenVideoController::pause): + 2010-01-29 Brian Weinstein <bweinstein@apple.com> Reviewed by Adam Roben. diff --git a/WebKit/win/FullscreenVideoController.cpp b/WebKit/win/FullscreenVideoController.cpp index 6b8e5ac..dbfc794 100644 --- a/WebKit/win/FullscreenVideoController.cpp +++ b/WebKit/win/FullscreenVideoController.cpp @@ -243,13 +243,13 @@ bool FullscreenVideoController::canPlay() const void FullscreenVideoController::play() { if (m_mediaElement) - m_mediaElement->play(); + m_mediaElement->play(m_mediaElement->processingUserGesture()); } void FullscreenVideoController::pause() { if (m_mediaElement) - m_mediaElement->pause(); + m_mediaElement->pause(m_mediaElement->processingUserGesture()); } float FullscreenVideoController::volume() const diff --git a/WebKit/win/WebKit.vcproj/WebKit.make b/WebKit/win/WebKit.vcproj/WebKit.make index 072d724..6c2ce85 100755 --- a/WebKit/win/WebKit.vcproj/WebKit.make +++ b/WebKit/win/WebKit.vcproj/WebKit.make @@ -8,7 +8,6 @@ install: set WebKitLibrariesDir=$(SRCROOT)\AppleInternal set WebKitOutputDir=$(OBJROOT) set PRODUCTION=1 - xcopy "$(SRCROOT)\AppleInternal\obj\WebKit\DOMInterfaces\*" "$(OBJROOT)\obj\WebKit\DOMInterfaces" /e/v/i/h/y devenv "WebKit.submit.sln" /rebuild $(BUILDSTYLE) -xcopy "$(OBJROOT)\bin\*.exe" "$(DSTROOT)\AppleInternal\bin\" /e/v/i/h/y xcopy "$(OBJROOT)\bin\*.pdb" "$(DSTROOT)\AppleInternal\bin\" /e/v/i/h/y diff --git a/WebKit/win/WebKit.vcproj/WebKit.rc b/WebKit/win/WebKit.vcproj/WebKit.rc index fa57ca3..92d1e6c 100644 --- a/WebKit/win/WebKit.vcproj/WebKit.rc +++ b/WebKit/win/WebKit.vcproj/WebKit.rc @@ -42,7 +42,7 @@ BEGIN VALUE "FileVersion", __VERSION_TEXT__ VALUE "CompanyName", "Apple Inc." VALUE "InternalName", "WebKit" - VALUE "LegalCopyright", "Copyright Apple Inc. 2003-2010" + VALUE "LegalCopyright", "Copyright Apple Inc. 2003-" __COPYRIGHT_YEAR_END_TEXT__ VALUE "OriginalFilename", "WebKit.dll" VALUE "ProductName", "WebKit" VALUE "ProductVersion", __BUILD_NUMBER_SHORT__ diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp index 4d67110..6144532 100644 --- a/WebKit/win/WebView.cpp +++ b/WebKit/win/WebView.cpp @@ -1589,6 +1589,66 @@ bool WebView::mouseWheel(WPARAM wParam, LPARAM lParam, bool isMouseHWheel) return coreFrame->eventHandler()->handleWheelEvent(wheelEvent); } +bool WebView::verticalScroll(WPARAM wParam, LPARAM /*lParam*/) +{ + ScrollDirection direction; + ScrollGranularity granularity; + switch (LOWORD(wParam)) { + case SB_LINEDOWN: + granularity = ScrollByLine; + direction = ScrollDown; + break; + case SB_LINEUP: + granularity = ScrollByLine; + direction = ScrollUp; + break; + case SB_PAGEDOWN: + granularity = ScrollByDocument; + direction = ScrollDown; + break; + case SB_PAGEUP: + granularity = ScrollByDocument; + direction = ScrollUp; + break; + default: + return false; + break; + } + + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + return frame->eventHandler()->scrollRecursively(direction, granularity); +} + +bool WebView::horizontalScroll(WPARAM wParam, LPARAM /*lParam*/) +{ + ScrollDirection direction; + ScrollGranularity granularity; + switch (LOWORD(wParam)) { + case SB_LINELEFT: + granularity = ScrollByLine; + direction = ScrollLeft; + break; + case SB_LINERIGHT: + granularity = ScrollByLine; + direction = ScrollRight; + break; + case SB_PAGELEFT: + granularity = ScrollByDocument; + direction = ScrollLeft; + break; + case SB_PAGERIGHT: + granularity = ScrollByDocument; + direction = ScrollRight; + break; + default: + return false; + } + + Frame* frame = m_page->focusController()->focusedOrMainFrame(); + return frame->eventHandler()->scrollRecursively(direction, granularity); +} + + bool WebView::execCommand(WPARAM wParam, LPARAM /*lParam*/) { Frame* frame = m_page->focusController()->focusedOrMainFrame(); @@ -2155,6 +2215,12 @@ LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, break; __fallthrough; + case WM_VSCROLL: + handled = webView->verticalScroll(wParam, lParam); + break; + case WM_HSCROLL: + handled = webView->horizontalScroll(wParam, lParam); + break; default: handled = false; break; @@ -2387,6 +2453,34 @@ static void WebKitSetApplicationCachePathIfNecessary() initialized = true; } + +bool WebView::shouldInitializeTrackPointHack() +{ + static bool shouldCreateScrollbars; + static bool hasRunTrackPointCheck; + + if (hasRunTrackPointCheck) + return shouldCreateScrollbars; + + hasRunTrackPointCheck = true; + const TCHAR trackPointKeys[][50] = { TEXT("Software\\Lenovo\\TrackPoint"), + TEXT("Software\\Lenovo\\UltraNav"), + TEXT("Software\\Alps\\Apoint\\TrackPoint"), + TEXT("Software\\Synaptics\\SynTPEnh\\UltraNavUSB"), + TEXT("Software\\Synaptics\\SynTPEnh\\UltraNavPS2") }; + + for (int i = 0; i < 5; ++i) { + HKEY trackPointKey; + int readKeyResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, trackPointKeys[i], 0, KEY_READ, &trackPointKey); + ::RegCloseKey(trackPointKey); + if (readKeyResult == ERROR_SUCCESS) { + shouldCreateScrollbars = true; + return shouldCreateScrollbars; + } + } + + return shouldCreateScrollbars; +} HRESULT STDMETHODCALLTYPE WebView::initWithFrame( /* [in] */ RECT frame, @@ -2404,6 +2498,14 @@ HRESULT STDMETHODCALLTYPE WebView::initWithFrame( frame.left, frame.top, frame.right - frame.left, frame.bottom - frame.top, m_hostWindow ? m_hostWindow : HWND_MESSAGE, 0, gInstance, 0); ASSERT(::IsWindow(m_viewWindow)); + if (shouldInitializeTrackPointHack()) { + // If we detected a registry key belonging to a TrackPoint driver, then create fake trackpoint + // scrollbars, so the WebView will receive WM_VSCROLL and WM_HSCROLL messages. We create one + // vertical scrollbar and one horizontal to allow for receiving both types of messages. + ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTHSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_HORZ, 0, 0, 0, 0, m_viewWindow, 0, gInstance, 0); + ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTVSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_VERT, 0, 0, 0, 0, m_viewWindow, 0, gInstance, 0); + } + hr = registerDragDrop(); if (FAILED(hr)) return hr; diff --git a/WebKit/win/WebView.h b/WebKit/win/WebView.h index cd857a8..56fb40c 100644 --- a/WebKit/win/WebView.h +++ b/WebKit/win/WebView.h @@ -793,6 +793,8 @@ public: bool onUninitMenuPopup(WPARAM, LPARAM); void performContextMenuAction(WPARAM, LPARAM, bool byPosition); bool mouseWheel(WPARAM, LPARAM, bool isMouseHWheel); + bool verticalScroll(WPARAM, LPARAM); + bool horizontalScroll(WPARAM, LPARAM); bool gesture(WPARAM, LPARAM); bool gestureNotify(WPARAM, LPARAM); bool execCommand(WPARAM wParam, LPARAM lParam); @@ -919,6 +921,8 @@ protected: LRESULT onIMERequestReconvertString(WebCore::Frame*, RECONVERTSTRING*); bool developerExtrasEnabled() const; + bool shouldInitializeTrackPointHack(); + // AllWebViewSet functions void addToAllWebViewsSet(); void removeFromAllWebViewsSet(); diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog index 1c7adf2..26d14d6 100644 --- a/WebKit/wx/ChangeLog +++ b/WebKit/wx/ChangeLog @@ -1,3 +1,17 @@ +2010-02-03 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + Add wxWebKitWindowFeatures and have createWindow send a notification for + clients to handle. + + https://bugs.webkit.org/show_bug.cgi?id=34542 + + * WebKitSupport/ChromeClientWx.cpp: + (WebCore::wkFeaturesforWindowFeatures): + (WebCore::ChromeClientWx::createWindow): + * WebView.h: + 2010-01-27 Kevin Watters <kevinwatters@gmail.com> Reviewed by Kevin Ollivier. diff --git a/WebKit/wx/WebKitSupport/ChromeClientWx.cpp b/WebKit/wx/WebKitSupport/ChromeClientWx.cpp index 17f6f43..4d524bc 100644 --- a/WebKit/wx/WebKitSupport/ChromeClientWx.cpp +++ b/WebKit/wx/WebKitSupport/ChromeClientWx.cpp @@ -37,6 +37,7 @@ #include "FrameLoadRequest.h" #include "NotImplemented.h" #include "PlatformString.h" +#include "WindowFeatures.h" #include <stdio.h> @@ -53,6 +54,21 @@ namespace WebCore { +wxWebKitWindowFeatures wkFeaturesforWindowFeatures(const WindowFeatures& features) +{ + wxWebKitWindowFeatures wkFeatures; + wkFeatures.menuBarVisible = features.menuBarVisible; + wkFeatures.statusBarVisible = features.statusBarVisible; + wkFeatures.toolBarVisible = features.toolBarVisible; + wkFeatures.locationBarVisible = features.locationBarVisible; + wkFeatures.scrollbarsVisible = features.scrollbarsVisible; + wkFeatures.resizable = features.resizable; + wkFeatures.fullscreen = features.fullscreen; + wkFeatures.dialog = features.dialog; + + return wkFeatures; +} + ChromeClientWx::ChromeClientWx(wxWebView* webView) { m_webView = webView; @@ -115,22 +131,21 @@ void ChromeClientWx::focusedNodeChanged(Node*) { } -Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures&) +Page* ChromeClientWx::createWindow(Frame*, const FrameLoadRequest& request, const WindowFeatures& features) { - - // FIXME: Create a EVT_WEBKIT_NEW_WINDOW event, and only run this code - // when that event is not handled. - Page* myPage = 0; - wxWebBrowserShell* newFrame = new wxWebBrowserShell(wxTheApp->GetAppName()); + wxWebViewNewWindowEvent wkEvent(m_webView); + wkEvent.SetURL(request.resourceRequest().url().string()); - if (newFrame->webview) { - newFrame->webview->LoadURL(request.resourceRequest().url().string()); - newFrame->Show(true); - - WebViewPrivate* impl = newFrame->webview->m_impl; - if (impl) - myPage = impl->page; + wxWebKitWindowFeatures wkFeatures = wkFeaturesforWindowFeatures(features); + wkEvent.SetWindowFeatures(wkFeatures); + + if (m_webView->GetEventHandler()->ProcessEvent(wkEvent)) { + if (wxWebView* webView = wkEvent.GetWebView()) { + WebViewPrivate* impl = webView->m_impl; + if (impl) + myPage = impl->page; + } } return myPage; diff --git a/WebKit/wx/WebView.h b/WebKit/wx/WebView.h index 7d923a3..9a6546c 100644 --- a/WebKit/wx/WebView.h +++ b/WebKit/wx/WebView.h @@ -203,7 +203,6 @@ public: const wxString& password = wxEmptyString); wxWebSettings GetWebSettings(); - wxWebKitParseMode GetParseMode() const; protected: @@ -304,6 +303,30 @@ private: wxString m_url; }; +class WXDLLIMPEXP_WEBKIT wxWebKitWindowFeatures +{ +public: + wxWebKitWindowFeatures() + : menuBarVisible(true) + , statusBarVisible(true) + , toolBarVisible(true) + , locationBarVisible(true) + , scrollbarsVisible(true) + , resizable(true) + , fullscreen(false) + , dialog(false) + { } + + bool menuBarVisible; + bool statusBarVisible; + bool toolBarVisible; + bool locationBarVisible; + bool scrollbarsVisible; + bool resizable; + bool fullscreen; + bool dialog; +}; + class WXDLLIMPEXP_WEBKIT wxWebViewNewWindowEvent : public wxCommandEvent { #ifndef SWIG @@ -315,11 +338,17 @@ public: void SetURL(const wxString& url) { m_url = url; } wxString GetTargetName() const { return m_targetName; } void SetTargetName(const wxString& name) { m_targetName = name; } + wxWebView* GetWebView() { return m_webView; } + void SetWebView(wxWebView* webView) { m_webView = webView; } + wxWebKitWindowFeatures GetWindowFeatures() { return m_features; } + void SetWindowFeatures(wxWebKitWindowFeatures features) { m_features = features; } wxWebViewNewWindowEvent( wxWindow* win = static_cast<wxWindow*>(NULL)); wxEvent *Clone(void) const { return new wxWebViewNewWindowEvent(*this); } private: + wxWebView* m_webView; + wxWebKitWindowFeatures m_features; wxString m_url; wxString m_targetName; }; diff --git a/WebKitLibraries/ChangeLog b/WebKitLibraries/ChangeLog index b4d72ac..4f8f848 100644 --- a/WebKitLibraries/ChangeLog +++ b/WebKitLibraries/ChangeLog @@ -1,3 +1,28 @@ +2010-02-03 Dan Bernstein <mitz@apple.com> + + Reviewed by Anders Carlsson. + + Fixed a bug where WKSetNSURLConnectionDefersCallbacks(true) did not defer callbacks during modal dialogs. + + * libWebKitSystemInterfaceLeopard.a: + +2010-02-02 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Darin Adler. + + Copyright year updating for Windows version resources should be automatic + https://bugs.webkit.org/show_bug.cgi?id=34503 + + * win/tools/scripts/auto-version.sh: + +2010-02-02 Martin Robinson <mrobinson@webkit.org> + + Unreviewed build fix. + + The WinCairo build requires this script to be executable. + + * win/tools/scripts/feature-defines.sh: Added property svn:executable. + 2010-01-29 Mark Rowe <mrowe@apple.com> Keep the Windows feature defines in sync with FeatureDefines.xcconfig. diff --git a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a Binary files differindex a9d0480..722044f 100644 --- a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a +++ b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a diff --git a/WebKitLibraries/win/tools/scripts/COPYRIGHT-END-YEAR b/WebKitLibraries/win/tools/scripts/COPYRIGHT-END-YEAR new file mode 100644 index 0000000..48ad625 --- /dev/null +++ b/WebKitLibraries/win/tools/scripts/COPYRIGHT-END-YEAR @@ -0,0 +1 @@ +2010 diff --git a/WebKitLibraries/win/tools/scripts/auto-version.sh b/WebKitLibraries/win/tools/scripts/auto-version.sh index c448db7..cbdc1af 100755 --- a/WebKitLibraries/win/tools/scripts/auto-version.sh +++ b/WebKitLibraries/win/tools/scripts/auto-version.sh @@ -87,6 +87,10 @@ if [ -z ${ENVIRONMENT_VERSION} ]; then VERSION_TEXT="${VERSION_TEXT_SHORT} ${USER} - ${BUILD_DATE} - r${SVN_REVISION}" fi +COPYRIGHT_END_YEAR_PATH=`cygpath -u "$WEBKITLIBRARIESDIR\\tools\\scripts\\COPYRIGHT-END-YEAR"` +COPYRIGHT_END_YEAR=$(cat "$COPYRIGHT_END_YEAR_PATH"); +chomp COPYRIGHT_END_YEAR + cat > "$OUTPUT_FILE" <<EOF #define __VERSION_TEXT__ "${VERSION_TEXT}" #define __BUILD_NUMBER__ "${VERSION_TEXT}" @@ -99,4 +103,5 @@ cat > "$OUTPUT_FILE" <<EOF #define __BUILD_NUMBER_MINOR__ ${BUILD_MINOR_VERSION} #define __BUILD_NUMBER_VARIANT__ ${BUILD_TINY_VERSION} #define __SVN_REVISION__ ${SVN_REVISION} +#define __COPYRIGHT_YEAR_END_TEXT__ "${COPYRIGHT_END_YEAR}" EOF diff --git a/WebKitLibraries/win/tools/scripts/feature-defines.sh b/WebKitLibraries/win/tools/scripts/feature-defines.sh index 71c3a9b..71c3a9b 100644..100755 --- a/WebKitLibraries/win/tools/scripts/feature-defines.sh +++ b/WebKitLibraries/win/tools/scripts/feature-defines.sh diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog index 38cd459..ed2e4bf 100644 --- a/WebKitTools/ChangeLog +++ b/WebKitTools/ChangeLog @@ -1,3 +1,402 @@ +2010-01-22 Tor Arne Vestbø <tor.arne.vestbo@nokia.com> + + Reviewed by Simon Hausmann. + + Make run-webkit-tests work under Cygwin for the Qt port + + setPathForRunningWebKitApp() is implemented for the Qt port + by using qmake to query for the location of the Qt libraries. + + This requires the original environment (%ENV) to be untouched, + so launchWithCurrentEnv() was refactored to launchWithEnv(), + and the code in openDumpTool() to not use %ENV but a %CLEAN_ENV + instead. This has the added benefit of getting rid of the temp + variables used for storing the current env. + + openDumpTool() is also refactored a bit into platform-spesific, + port-spesific, and generic environment variables. + + Checks for undef was added a few places to fix Perl concat + warnings when run-webkit-tests is aborted. + + https://bugs.webkit.org/show_bug.cgi?id=33895 + + * Scripts/run-webkit-tests: + * Scripts/webkitdirs.pm: + +2010-02-04 Yuzo Fujishima <yuzo@google.com> + + Unreviewed. + + Add Yuzo to the committers list. + + * Scripts/webkitpy/committers.py: + +2010-02-03 Dirk Pranke <dpranke@chromium.org> + + Rubber-stamped by Eric Seidel. + + Change "the Chromium name" to "the name of Google Inc." in the licenses + + https://bugs.webkit.org/show_bug.cgi?id=34511 + + * Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py: + * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py: + * Scripts/webkitpy/layout_tests/layout_package/metered_stream.py: + * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py: + * Scripts/webkitpy/layout_tests/layout_package/test_failures.py: + * Scripts/webkitpy/layout_tests/layout_package/test_files.py: + * Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py: + * Scripts/webkitpy/layout_tests/port/__init__.py: + * Scripts/webkitpy/layout_tests/port/apache_http_server.py: + * Scripts/webkitpy/layout_tests/port/chromium_linux.py: + * Scripts/webkitpy/layout_tests/port/chromium_mac.py: + * Scripts/webkitpy/layout_tests/port/chromium_win.py: + * Scripts/webkitpy/layout_tests/port/http_server.py: + * Scripts/webkitpy/layout_tests/port/http_server_base.py: + * Scripts/webkitpy/layout_tests/port/path_utils.py: + * Scripts/webkitpy/layout_tests/port/websocket_server.py: + * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py: + * Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py: + * Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py: + * Scripts/webkitpy/layout_tests/test_types/image_diff.py: + * Scripts/webkitpy/layout_tests/test_types/test_type_base.py: + * Scripts/webkitpy/layout_tests/test_types/text_diff.py: + +2010-02-03 Dirk Pranke <dpranke@chromium.org> + + Rubber-stamped by Eric Siedel. + + Rename files as part of refactoring the layout_tests package. All + the platform_utils* module, the path_utils.py module, and + the http server and web socket server modules are moved into a new + port/ package. + + https://bugs.webkit.org/show_bug.cgi?id=34511 + + * Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/http_server.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/http_server_base.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/httpd2.pem: Removed. + * Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py: + * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py: + * Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf: Removed. + * Scripts/webkitpy/layout_tests/layout_package/path_utils.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/platform_utils.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py: Removed. + * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py: + * Scripts/webkitpy/layout_tests/layout_package/test_files.py: + * Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py: + * Scripts/webkitpy/layout_tests/layout_package/websocket_server.py: Removed. + * Scripts/webkitpy/layout_tests/port: Added. + * Scripts/webkitpy/layout_tests/port/__init__.py: Copied from Scripts/webkitpy/layout_tests/layout_package/platform_utils.py. + * Scripts/webkitpy/layout_tests/port/apache_http_server.py: Copied from Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py. + * Scripts/webkitpy/layout_tests/port/chromium_linux.py: Copied from Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py. + * Scripts/webkitpy/layout_tests/port/chromium_mac.py: Copied from Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py. + * Scripts/webkitpy/layout_tests/port/chromium_win.py: Copied from Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py. + * Scripts/webkitpy/layout_tests/port/http_server.py: Copied from Scripts/webkitpy/layout_tests/layout_package/http_server.py. + * Scripts/webkitpy/layout_tests/port/http_server_base.py: Copied from Scripts/webkitpy/layout_tests/layout_package/http_server_base.py. + * Scripts/webkitpy/layout_tests/port/httpd2.pem: Copied from Scripts/webkitpy/layout_tests/layout_package/httpd2.pem. + * Scripts/webkitpy/layout_tests/port/lighttpd.conf: Copied from Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf. + * Scripts/webkitpy/layout_tests/port/path_utils.py: Copied from Scripts/webkitpy/layout_tests/layout_package/path_utils.py. + * Scripts/webkitpy/layout_tests/port/websocket_server.py: Copied from Scripts/webkitpy/layout_tests/layout_package/websocket_server.py. + * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py: + * Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py: + * Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py: + * Scripts/webkitpy/layout_tests/test_types/image_diff.py: + * Scripts/webkitpy/layout_tests/test_types/test_type_base.py: + * Scripts/webkitpy/layout_tests/test_types/text_diff.py: + + +2010-02-03 Csaba Osztrogonác <ossy@webkit.org> + + Rubber-stamped by Eric Seidel. + + Roll back r53559 and r54084 again, because roll out didn't solve flakeyness on the Windows Test bots + https://bugs.webkit.org/show_bug.cgi?id=34399 + + * Scripts/run-iexploder-tests: + * Scripts/run-webkit-httpd: + * Scripts/run-webkit-tests: + * Scripts/webkitperl/httpd.pm: Added. + +2010-02-03 Csaba Osztrogonác <ossy@webkit.org> + + Rubber-stamped by Eric Seidel. + + Roll out r53559 and r54084, because it might caused flakeyness on the Windows Test bots + + * Scripts/run-iexploder-tests: + * Scripts/run-webkit-httpd: + * Scripts/run-webkit-tests: + * Scripts/webkitperl/httpd.pm: Removed. + +2010-02-03 Csaba Osztrogonác <ossy@webkit.org> + + Rubber-stamped by Ariya Hidayat. + + Roll back r53889 again, because roll out didn't solve flakeyness on the Windows Test bots + https://bugs.webkit.org/show_bug.cgi?id=34399 + + * DumpRenderTree/win/EventSender.cpp: + (buildModifierFlags): + (mouseDownCallback): + (mouseUpCallback): + (keyDownCallback): + +2010-02-03 Eric Seidel <eric@webkit.org> + + No review, just fixing copyrights. + + Concerns were expressed about "The Chromium Authors" being + a valid legal entity for copyright assignment in the WebKit repository, + so this change removes all "The Chromium Authors". + + I looked at the svn logs in src.chromium.org and failed to find any + non-google contributions to these files, so they are all now + marked as copyright "Google Inc" as all Google contributers assign + copyright to "Google Inc" as part of their employment agreement. + + * Scripts/rebaseline-chromium-webkit-tests: + * Scripts/run-chromium-webkit-tests: + * Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py: + * Scripts/webkitpy/layout_tests/layout_package/http_server.py: + * Scripts/webkitpy/layout_tests/layout_package/http_server_base.py: + * Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py: + * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py: + * Scripts/webkitpy/layout_tests/layout_package/metered_stream.py: + * Scripts/webkitpy/layout_tests/layout_package/path_utils.py: + * Scripts/webkitpy/layout_tests/layout_package/platform_utils.py: + * Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py: + * Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py: + * Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py: + * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py: + * Scripts/webkitpy/layout_tests/layout_package/test_failures.py: + * Scripts/webkitpy/layout_tests/layout_package/test_files.py: + * Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py: + * Scripts/webkitpy/layout_tests/layout_package/websocket_server.py: + * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py: + * Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py: + * Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py: + * Scripts/webkitpy/layout_tests/test_types/image_diff.py: + * Scripts/webkitpy/layout_tests/test_types/test_type_base.py: + * Scripts/webkitpy/layout_tests/test_types/text_diff.py: + +2010-02-03 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Ariya Hidayat. + + [Qt] QtLauncher, refactor argument handling in preparation of merge + with QGVLauncher + + * QtLauncher/main.cpp: + (LauncherApplication::urls): + (LauncherApplication::isRobotized): + (LauncherApplication::applyDefaultSettings): + (LauncherApplication::LauncherApplication): + (LauncherApplication::formatKeys): + (LauncherApplication::enumToKeys): + (fail): + (LauncherApplication::handleUserOptions): + (main): + +2010-02-03 Csaba Osztrogonác <ossy@webkit.org> + + Rubber-stamped by Ariya Hidayat. + + Rolling out r53889, because it might caused flakeyness on the Windows Test bots + https://bugs.webkit.org/show_bug.cgi?id=34399 + + * DumpRenderTree/win/EventSender.cpp: + (mouseDownCallback): + (mouseUpCallback): + (keyDownCallback): + +2010-02-03 Csaba Osztrogonác <ossy@webkit.org> + + Reviewed by Ariya Hidayat. + + [Qt] Fix pixel tests support. + https://bugs.webkit.org/show_bug.cgi?id=27813 + + * DumpRenderTree/qt/DumpRenderTreeQt.cpp: + (WebCore::DumpRenderTree::open): + (WebCore::DumpRenderTree::processLine): + - Hash processing mechanism moved from DumpRenderTree::open to DumpRenderTree::processLine. + (WebCore::DumpRenderTree::dump): Fixed and renamed variables. + +2010-02-03 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + [wx] Enable JIT compilation for wx. + + https://bugs.webkit.org/show_bug.cgi?id=34536 + + * wx/build/settings.py: + +2010-02-02 Kevin Ollivier <kevino@theolliviers.com> + + [wx] Build fix after introduction of pageNumberForElementById. + + * DumpRenderTree/wx/LayoutTestControllerWx.cpp: + (LayoutTestController::pageNumberForElementById): + +2010-02-02 Shu Chang <Chang.Shu@nokia.com> + + Unreviewed. + + Add myself to list of committers. + + * Scripts/webkitpy/committers.py: + +2010-02-02 Chris Jerdonek <cjerdonek@webkit.org> + + Reviewed by Shinichiro Hamaji. + + Moved filter-related check-webkit-style code into a separate + filter module. + + https://bugs.webkit.org/show_bug.cgi?id=34408 + + This is preparatory refactoring for Bug 33684, which will allow + file and folder-specific filter rules. + + * Scripts/webkitpy/style/checker.py: + - Removed CategoryFilter class (moved to filter.py). + + * Scripts/webkitpy/style/checker_unittest.py: + - Removed CategoryFilter unit tests (moved to filter_unittest.py). + + * Scripts/webkitpy/style/filter.py: Added. + - Added CategoryFilter class (moved from checker.py). + + * Scripts/webkitpy/style/filter_unittest.py: Added. + - Added CategoryFilter unit tests (moved from checker_unittest.py). + + * Scripts/webkitpy/style/unittests.py: + - Added reference to filter_unittest.py. + +2010-02-01 Chris Jerdonek <cjerdonek@webkit.org> + + Reviewed by Shinichiro Hamaji. + + Addressed FIXME in check-webkit-style so that the carriage-return + check will work for patches. + + https://bugs.webkit.org/show_bug.cgi?id=34260 + + Also added support for limiting the number of errors reported + per category, per file. + + * Scripts/webkitpy/style/checker.py: + - Added new "whitespace/carriage_return" category from common.py. + - Added MAX_REPORTS_PER_CATEGORY dictionary. + - Added max_reports_per_category attribute to ProcessorOptions class. + - Refactored StyleChecker._process_file(). + + * Scripts/webkitpy/style/checker_unittest.py: + - Updated ProcessorOptionsTest tests. + - Added test to check MAX_REPORTS_PER_CATEGORY. + + * Scripts/webkitpy/style/error_handlers.py: + - Added support for suppressing the display of errors after + reaching a per-category maximum (from max_reports_per_category). + + * Scripts/webkitpy/style/error_handlers_unittest.py: + - Added test for suppressing error display. + + * Scripts/webkitpy/style/processors/common.py: Added. + - Moved carriage-return check to new file. + + * Scripts/webkitpy/style/processors/common_unittest.py: Added. + - Added unit tests for carriage-return check. + + * Scripts/webkitpy/style/unittests.py: + - Added reference to common_unittest.py. + +2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> + + Reviewed by Eric Seidel. + + Provide a way to get page number with layoutTestController + https://bugs.webkit.org/show_bug.cgi?id=33840 + + * DumpRenderTree/LayoutTestController.cpp: + (pageNumberForElementByIdCallback): + (LayoutTestController::staticFunctions): + * DumpRenderTree/LayoutTestController.h: + * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: + (LayoutTestController::pageNumberForElementById): + * DumpRenderTree/mac/LayoutTestControllerMac.mm: + (LayoutTestController::pageNumberForElementById): + * DumpRenderTree/win/LayoutTestControllerWin.cpp: + (LayoutTestController::pageNumberForElementById): + +2010-02-01 Shinichiro Hamaji <hamaji@chromium.org> + + Unreviewed fix for an invalid function call. + + check-webkit-style: Remove filename parameter from all functions where no longer used + https://bugs.webkit.org/show_bug.cgi?id=34249 + + * Scripts/webkitpy/style/checker.py: + +2010-02-01 Diego Gonzalez <diego.gonzalez@openbossa.org> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] DRT Provide global flag ability + https://bugs.webkit.org/show_bug.cgi?id=34418 + + Add the globalFlag property to the Qt LayoutTestController to allow + cross-domain indications. + + * DumpRenderTree/qt/LayoutTestControllerQt.cpp: + (LayoutTestController::reset): + * DumpRenderTree/qt/LayoutTestControllerQt.h: + (LayoutTestController::globalFlag): + (LayoutTestController::setGlobalFlag): + +2010-02-01 Brady Eidson <beidson@apple.com> + + Reviewed by Adele Peterson. + + Crash in Safari opening new tabs to "same page" + <rdar://problem/7593857> and https://bugs.webkit.org/show_bug.cgi?id=34444 + + Add a mode (Mac-only for now) that exercises the WebView SPI _loadBackForwardListFromOtherView: + + * DumpRenderTree/LayoutTestController.cpp: + (LayoutTestController::LayoutTestController): + (setNewWindowsCopyBackForwardListCallback): + (LayoutTestController::staticFunctions): + + * DumpRenderTree/LayoutTestController.h: + (LayoutTestController::newWindowsCopyBackForwardList): + (LayoutTestController::setNewWindowsCopyBackForwardList): + + * DumpRenderTree/mac/UIDelegate.mm: + (-[UIDelegate webView:createWebViewWithRequest:]): + +2010-02-01 Carol Szabo <carol.szabo@nokia.com> + + Unreviewed. + + Add myself to list of committers. + + * Scripts/webkitpy/committers.py: + +2010-02-01 Nate Chapin <japhet@chromium.org> + + Rubber-stamped by David Levin. + + Add myself to reviewer list. + + * Scripts/webkitpy/committers.py: + 2010-01-31 Chris Jerdonek <cjerdonek@webkit.org> Reviewed by Shinichiro Hamaji. diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.cpp b/WebKitTools/DumpRenderTree/LayoutTestController.cpp index e71cd29..0537d7c 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.cpp +++ b/WebKitTools/DumpRenderTree/LayoutTestController.cpp @@ -61,6 +61,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con , m_callCloseOnWebViews(true) , m_canOpenWindows(false) , m_closeRemainingWindowsWhenComplete(true) + , m_newWindowsCopyBackForwardList(false) , m_stopProvisionalFrameLoads(false) , m_testOnscreen(false) , m_testRepaint(false) @@ -464,6 +465,36 @@ static JSValueRef notifyDoneCallback(JSContextRef context, JSObjectRef function, return JSValueMakeUndefined(context); } +static JSValueRef pageNumberForElementByIdCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // FIXME: These values should sync with maxViewWidth/Height in + // DumpRenderTree.mm. Factor these values out to somewhere. + float pageWidthInPixels = 800; + float pageHeightInPixels = 600; + switch (argumentCount) { + case 1: + break; + case 3: + pageWidthInPixels = static_cast<float>(JSValueToNumber(context, arguments[1], exception)); + if (*exception) + return JSValueMakeUndefined(context); + pageHeightInPixels = static_cast<float>(JSValueToNumber(context, arguments[2], exception)); + if (*exception) + return JSValueMakeUndefined(context); + break; + default: + return JSValueMakeUndefined(context); + } + + JSRetainPtr<JSStringRef> elementId(Adopt, JSValueToStringCopy(context, arguments[0], exception)); + if (*exception) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + int pageNumber = controller->pageNumberForElementById(elementId.get(), pageWidthInPixels, pageHeightInPixels); + return JSValueMakeNumber(context, pageNumber); +} + static JSValueRef queueBackNavigationCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac & windows implementation @@ -743,6 +774,18 @@ static JSValueRef setMockGeolocationErrorCallback(JSContextRef context, JSObject return JSValueMakeUndefined(context); } +static JSValueRef setNewWindowsCopyBackForwardListCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + // Has mac implementation + if (argumentCount < 1) + return JSValueMakeUndefined(context); + + LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); + controller->setNewWindowsCopyBackForwardList(JSValueToBoolean(context, arguments[0])); + + return JSValueMakeUndefined(context); +} + static JSValueRef setGeolocationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { // Has mac implementation @@ -1289,6 +1332,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "notifyDone", notifyDoneCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "numberOfActiveAnimations", numberOfActiveAnimationsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "overridePreference", overridePreferenceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "pageNumberForElementById", pageNumberForElementByIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pathToLocalResource", pathToLocalResourceCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseAnimationAtTimeOnElementWithId", pauseAnimationAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "pauseTransitionAtTimeOnElementWithId", pauseTransitionAtTimeOnElementWithIdCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, @@ -1324,6 +1368,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() { "setMainFrameIsFirstResponder", setMainFrameIsFirstResponderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setMockGeolocationError", setMockGeolocationErrorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, + { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setPrivateBrowsingEnabled", setPrivateBrowsingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, diff --git a/WebKitTools/DumpRenderTree/LayoutTestController.h b/WebKitTools/DumpRenderTree/LayoutTestController.h index c8da6ab..76e7cb3 100644 --- a/WebKitTools/DumpRenderTree/LayoutTestController.h +++ b/WebKitTools/DumpRenderTree/LayoutTestController.h @@ -57,6 +57,7 @@ public: void keepWebHistory(); void notifyDone(); void overridePreference(JSStringRef key, JSStringRef value); + int pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels); JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); void queueBackNavigation(int howFarBackward); void queueForwardNavigation(int howFarForward); @@ -66,28 +67,29 @@ public: void queueReload(); void removeAllVisitedLinks(); void setAcceptsEditing(bool acceptsEditing); - void setAppCacheMaximumSize(unsigned long long quota); void setAllowUniversalAccessFromFileURLs(bool); + void setAppCacheMaximumSize(unsigned long long quota); void setAuthorAndUserStylesEnabled(bool); void setCacheModel(int); void setCustomPolicyDelegate(bool setDelegate, bool permissive); void setDatabaseQuota(unsigned long long quota); void setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme); - void setMockGeolocationPosition(double latitude, double longitude, double accuracy); - void setMockGeolocationError(int code, JSStringRef message); void setIconDatabaseEnabled(bool iconDatabaseEnabled); void setJavaScriptProfilingEnabled(bool profilingEnabled); void setMainFrameIsFirstResponder(bool flag); + void setMockGeolocationError(int code, JSStringRef message); + void setMockGeolocationPosition(double latitude, double longitude, double accuracy); void setPersistentUserStyleSheetLocation(JSStringRef path); void setPopupBlockingEnabled(bool flag); void setPrivateBrowsingEnabled(bool flag); - void setXSSAuditorEnabled(bool flag); void setSelectTrailingWhitespaceEnabled(bool flag); void setSmartInsertDeleteEnabled(bool flag); void setTabKeyCyclesThroughElements(bool cycles); void setUseDashboardCompatibilityMode(bool flag); void setUserStyleSheetEnabled(bool flag); void setUserStyleSheetLocation(JSStringRef path); + void setXSSAuditorEnabled(bool flag); + void waitForPolicyDelegate(); size_t webHistoryItemCount(); unsigned workerThreadCount() const; @@ -161,6 +163,9 @@ public: bool closeRemainingWindowsWhenComplete() const { return m_closeRemainingWindowsWhenComplete; } void setCloseRemainingWindowsWhenComplete(bool closeRemainingWindowsWhenComplete) { m_closeRemainingWindowsWhenComplete = closeRemainingWindowsWhenComplete; } + bool newWindowsCopyBackForwardList() const { return m_newWindowsCopyBackForwardList; } + void setNewWindowsCopyBackForwardList(bool newWindowsCopyBackForwardList) { m_newWindowsCopyBackForwardList = newWindowsCopyBackForwardList; } + bool stopProvisionalFrameLoads() const { return m_stopProvisionalFrameLoads; } void setStopProvisionalFrameLoads(bool stopProvisionalFrameLoads) { m_stopProvisionalFrameLoads = stopProvisionalFrameLoads; } @@ -248,6 +253,7 @@ private: bool m_callCloseOnWebViews; bool m_canOpenWindows; bool m_closeRemainingWindowsWhenComplete; + bool m_newWindowsCopyBackForwardList; bool m_stopProvisionalFrameLoads; bool m_testOnscreen; bool m_testRepaint; diff --git a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp index a74f7ad..bad09fb 100644 --- a/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp +++ b/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp @@ -140,6 +140,12 @@ void LayoutTestController::keepWebHistory() // FIXME: implement } +int LayoutTestController::pageNumberForElementById(JSStringRef, float, float) +{ + // FIXME: implement + return -1; +} + size_t LayoutTestController::webHistoryItemCount() { // FIXME: implement diff --git a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm index 5f020fa..67c8c91 100644 --- a/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm +++ b/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm @@ -176,6 +176,18 @@ void LayoutTestController::keepWebHistory() } } +int LayoutTestController::pageNumberForElementById(JSStringRef id, float pageWidthInPixels, float pageHeightInPixels) +{ + RetainPtr<CFStringRef> idCF(AdoptCF, JSStringCopyCFString(kCFAllocatorDefault, id)); + NSString *idNS = (NSString *)idCF.get(); + + DOMElement *element = [[mainFrame DOMDocument] getElementById:idNS]; + if (!element) + return -1; + + return [mainFrame pageNumberForElement:element:pageWidthInPixels:pageHeightInPixels]; +} + size_t LayoutTestController::webHistoryItemCount() { return [[[WebHistory optionalSharedHistory] allItems] count]; diff --git a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm index 81c03d2..19ceb95 100644 --- a/WebKitTools/DumpRenderTree/mac/UIDelegate.mm +++ b/WebKitTools/DumpRenderTree/mac/UIDelegate.mm @@ -38,6 +38,7 @@ #import <WebKit/WebSecurityOriginPrivate.h> #import <WebKit/WebUIDelegatePrivate.h> #import <WebKit/WebView.h> +#import <WebKit/WebViewPrivate.h> #import <wtf/Assertions.h> DumpRenderTreeDraggingInfo *draggingInfo = nil; @@ -122,6 +123,9 @@ DumpRenderTreeDraggingInfo *draggingInfo = nil; WebView *webView = createWebViewAndOffscreenWindow(); + if (gLayoutTestController->newWindowsCopyBackForwardList()) + [webView _loadBackForwardListFromOtherView:sender]; + return [webView autorelease]; } diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp index 9916f24..c16a786 100644 --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp @@ -412,23 +412,10 @@ void DumpRenderTree::resetToConsistentStateBeforeTesting() setlocale(LC_ALL, ""); } -void DumpRenderTree::open(const QUrl& aurl) +void DumpRenderTree::open(const QUrl& url) { resetToConsistentStateBeforeTesting(); - QUrl url = aurl; - m_expectedHash = QString(); - if (m_dumpPixels) { - // single quote marks the pixel dump hash - QString str = url.toString(); - int i = str.indexOf('\''); - if (i > -1) { - m_expectedHash = str.mid(i + 1, str.length()); - str.remove(i, str.length()); - url = QUrl(str); - } - } - // W3C SVG tests expect to be 480x360 bool isW3CTest = url.toString().contains("svg/W3C-SVG-1.1"); int width = isW3CTest ? 480 : maxViewWidth; @@ -477,6 +464,16 @@ void DumpRenderTree::processLine(const QString &input) { QString line = input; + m_expectedHash = QString(); + if (m_dumpPixels) { + // single quote marks the pixel dump hash + int i = line.indexOf('\''); + if (i > -1) { + m_expectedHash = line.mid(i + 1, line.length()); + line.remove(i, line.length()); + } + } + if (line.startsWith(QLatin1String("http:")) || line.startsWith(QLatin1String("https:")) || line.startsWith(QLatin1String("file:"))) { @@ -720,14 +717,16 @@ void DumpRenderTree::dump() printf("Content-Type: %s\n", "image/png"); printf("Content-Length: %lu\n", static_cast<unsigned long>(data.length())); + const quint32 bytesToWriteInOneChunk = 1 << 15; + quint32 dataRemainingToWrite = data.length(); const char *ptr = data.data(); - for(quint32 left = data.length(); left; ) { - quint32 block = qMin(left, quint32(1 << 15)); - quint32 written = fwrite(ptr, 1, block, stdout); - ptr += written; - left -= written; - if (written == block) + while (dataRemainingToWrite) { + quint32 bytesToWriteInThisChunk = qMin(dataRemainingToWrite, bytesToWriteInOneChunk); + quint32 bytesWritten = fwrite(ptr, 1, bytesToWriteInThisChunk, stdout); + if (bytesWritten != bytesToWriteInThisChunk) break; + dataRemainingToWrite -= bytesWritten; + ptr += bytesWritten; } } diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp index 9430ec7..ca48003 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp @@ -73,6 +73,7 @@ void LayoutTestController::reset() m_waitForPolicy = false; m_handleErrorPages = false; m_webHistory = 0; + m_globalFlag = false; qt_dump_editing_callbacks(false); qt_dump_resource_load_callbacks(false); emit hidePage(); diff --git a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h index 64b3a15..365640d 100644 --- a/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h +++ b/WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h @@ -53,6 +53,7 @@ class LayoutTestController : public QObject { Q_OBJECT Q_PROPERTY(int webHistoryItemCount READ webHistoryItemCount) Q_PROPERTY(int workerThreadCount READ workerThreadCount) + Q_PROPERTY(bool globalFlag READ globalFlag WRITE setGlobalFlag) public: LayoutTestController(WebCore::DumpRenderTree* drt); @@ -91,6 +92,8 @@ public slots: void keepWebHistory(); void notifyDone(); void dumpBackForwardList() { m_dumpBackForwardList = true; } + bool globalFlag() const { return m_globalFlag; } + void setGlobalFlag(bool flag) { m_globalFlag = flag; } void handleErrorPages() { m_handleErrorPages = true; } void dumpEditingCallbacks(); void dumpResourceLoadCallbacks(); @@ -160,6 +163,7 @@ private: bool m_waitForPolicy; bool m_handleErrorPages; bool m_loadFinished; + bool m_globalFlag; QUrl m_userStyleSheetLocation; QBasicTimer m_timeoutTimer; diff --git a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp index b7a63fc..4f5e925 100644 --- a/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp +++ b/WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp @@ -1104,3 +1104,8 @@ JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStri return counterValueJS; } +int LayoutTestController::pageNumberForElementById(JSStringRef, float, float) +{ + // FIXME: implement + return -1; +} diff --git a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp index 4b811ec..6d3b624 100644 --- a/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp +++ b/WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp @@ -359,3 +359,9 @@ JSRetainPtr<JSStringRef> LayoutTestController::counterValueForElementById(JSStri { return 0; } + +int LayoutTestController::pageNumberForElementById(JSStringRef, float, float) +{ + // FIXME: implement + return -1; +} diff --git a/WebKitTools/QtLauncher/main.cpp b/WebKitTools/QtLauncher/main.cpp index 081b8f0..31bca8e 100644 --- a/WebKitTools/QtLauncher/main.cpp +++ b/WebKitTools/QtLauncher/main.cpp @@ -525,8 +525,6 @@ QObject* WebPage::createPlugin(const QString &classId, const QUrl&, const QStrin } -#include "main.moc" - int launcherMain(const QApplication& app) { #ifndef NDEBUG @@ -539,60 +537,185 @@ int launcherMain(const QApplication& app) #endif } -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); +class LauncherApplication : public QApplication { + Q_OBJECT - QWebSettings::setMaximumPagesInCache(4); +public: + LauncherApplication(int& argc, char** argv); + QStringList urls() const { return m_urls; } + bool isRobotized() const { return m_isRobotized; } + +private: + void handleUserOptions(); + void applyDefaultSettings(); - app.setApplicationName("QtLauncher"); - app.setApplicationVersion("0.1"); + QList<QString> enumToKeys(const QMetaObject o, const QString& name, const QString& strip); + QString formatKeys(QList<QString> keys); + +private: + bool m_isRobotized; + QStringList m_urls; +}; + +void LauncherApplication::applyDefaultSettings() +{ + QWebSettings::setMaximumPagesInCache(4); QWebSettings::setObjectCacheCapacities((16*1024*1024) / 8, (16*1024*1024) / 8, 16*1024*1024); QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true); QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); QWebSettings::enablePersistentStorage(); +} +LauncherApplication::LauncherApplication(int& argc, char** argv) + : QApplication(argc, argv) + , m_isRobotized(false) +{ // To allow QWebInspector's configuration persistence - QCoreApplication::setOrganizationName("Nokia"); - QCoreApplication::setApplicationName("QtLauncher"); + setOrganizationName("Nokia"); + setApplicationName("QtLauncher"); + setApplicationVersion("0.1"); - const QStringList args = app.arguments(); + applyDefaultSettings(); - if (args.contains(QLatin1String("-r"))) { - // robotized - QString listFile = args.at(2); - if (!(args.count() == 3) && QFile::exists(listFile)) { - qDebug() << "Usage: QtLauncher -r listfile"; - exit(0); + handleUserOptions(); +} + +QString LauncherApplication::formatKeys(QList<QString> keys) +{ + QString result; + for (int i = 0; i < keys.count() - 1; i++) + result.append(keys.at(i) + "|"); + result.append(keys.last()); + return result; +} + +QList<QString> LauncherApplication::enumToKeys(const QMetaObject o, const QString& name, const QString& strip) +{ + QList<QString> list; + + int enumIndex = o.indexOfEnumerator(name.toLatin1().data()); + QMetaEnum enumerator = o.enumerator(enumIndex); + + if (enumerator.isValid()) { + for (int i = 0; i < enumerator.keyCount(); i++) { + QString key(enumerator.valueToKey(i)); + list.append(key.remove(strip)); } + } + + return list; +} + +static void fail(const QString& errorMsg) +{ + qDebug() << "ERROR:" << errorMsg.toLatin1().data(); + exit(1); +} + +void LauncherApplication::handleUserOptions() +{ + QStringList args = arguments(); + QFileInfo program(args.at(0)); + QString programName("QtLauncher"); + if (program.exists()) + programName = program.baseName(); + + QList<QString> updateModes(enumToKeys(QGraphicsView::staticMetaObject, + "ViewportUpdateMode", "ViewportUpdate")); + + if (args.contains("--help")) { + qDebug() << "Usage:" << programName.toLatin1().data() + << "[--graphicsbased]" + << "[--compositing]" + << QString("[--viewport-update-mode %1]").arg(formatKeys(updateModes)).toLatin1().data() + << "[--cache-webview]" + << "[-r list]" + << "URLs"; + exit(0); + } + + bool useGraphicsView = false; + + if (args.contains("--graphicsbased")) + useGraphicsView = true; + + if (args.contains("--compositing") && useGraphicsView) + QWebSettings::globalSettings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true); + + if (args.contains("--cache-webview") && useGraphicsView) + ; // view->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + int modeIndex = args.indexOf("--viewport-update-mode"); + if (modeIndex != -1 && ++modeIndex < args.count() && !args.at(modeIndex).startsWith("-")) { + QString mode = args.takeAt(modeIndex); + if (useGraphicsView) { + int idx = updateModes.indexOf(mode); + if (idx != -1) { + ; // view->setViewportUpdateMode(static_cast<QGraphicsView::ViewportUpdateMode>(idx)); + } else { + fail(QString("--viewport-update-mode value has to be one of [%1]") + .arg(formatKeys(updateModes)).toLatin1().data()); + } + } + } + + int robotIndex = args.indexOf("-r"); + if (robotIndex != -1) { + if (++robotIndex < args.count() && !args.at(robotIndex).startsWith("-")) { + QString listFile = args.takeAt(robotIndex); + if (!QFile::exists(listFile)) + fail(QString("The list file supplied to -r does not exist.")); + else { + m_isRobotized = true; + m_urls = QStringList(listFile); + return; + } + } + else + fail(QString("-r needs a list file to start in robotized mode")); + } + + int lastArg = args.lastIndexOf(QRegExp("^-.*")); + m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1); +} + + +int main(int argc, char **argv) +{ + LauncherApplication app(argc, argv); + + if (app.isRobotized()) { LauncherWindow* window = new LauncherWindow; QWebView* view = window->webView(); - UrlLoader loader(view->page()->mainFrame(), listFile); + UrlLoader loader(view->page()->mainFrame(), app.urls().at(0)); QObject::connect(view->page()->mainFrame(), SIGNAL(loadFinished(bool)), &loader, SLOT(loadNext())); loader.loadNext(); window->show(); - launcherMain(app); - } else { - LauncherWindow* window = 0; - - // Look though the args for something we can open - for (int i = 1; i < args.count(); i++) { - if (!args.at(i).startsWith("-")) { - if (!window) - window = new LauncherWindow(args.at(i)); - else - window->newWindow(args.at(i)); - } - } + return launcherMain(app); + } - // If not, just open the default URL - if (!window) - window = new LauncherWindow(defaultUrl); + QStringList urls = app.urls(); - window->show(); - launcherMain(app); + if (urls.isEmpty()) { + QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html")); + if (QDir(defaultUrl).exists()) + urls.append(defaultUrl); + else + urls.append(""); + } + + LauncherWindow* window = 0; + foreach (QString url, urls) { + if (!window) + window = new LauncherWindow(url); + else + window->newWindow(url); } + + window->show(); + return launcherMain(app); } + +#include "main.moc" diff --git a/WebKitTools/Scripts/rebaseline-chromium-webkit-tests b/WebKitTools/Scripts/rebaseline-chromium-webkit-tests index d22c0c4..9a8a156 100755 --- a/WebKitTools/Scripts/rebaseline-chromium-webkit-tests +++ b/WebKitTools/Scripts/rebaseline-chromium-webkit-tests @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are diff --git a/WebKitTools/Scripts/run-chromium-webkit-tests b/WebKitTools/Scripts/run-chromium-webkit-tests index 8712836..9c027b8 100755 --- a/WebKitTools/Scripts/run-chromium-webkit-tests +++ b/WebKitTools/Scripts/run-chromium-webkit-tests @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests index bb4fb34..6b21e48 100755 --- a/WebKitTools/Scripts/run-webkit-tests +++ b/WebKitTools/Scripts/run-webkit-tests @@ -87,7 +87,7 @@ sub expectedDirectoryForTest($;$;$); sub fileNameWithNumber($$); sub htmlForResultsSection(\@$&); sub isTextOnlyTest($); -sub launchWithCurrentEnv(@); +sub launchWithEnv(\@\%); sub resolveAndMakeTestResultsDirectory(); sub numericcmp($$); sub openDiffTool(); @@ -659,7 +659,7 @@ for my $test (@tests) { } else { $testPath = canonpath($testPath); } - print OUT "$testPath$suffixExpectedHash\n"; + print OUT "$testPath$suffixExpectedHash\n" if defined $testPath; } # DumpRenderTree is expected to dump two "blocks" to stdout for each test. @@ -1027,6 +1027,10 @@ if (isGtk()) { system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari; } elsif (isQt()) { unshift @configurationArgs, qw(-graphicssystem raster -style windows); + if (isCygwin()) { + $testResults = "/" . toWindowsPath($testResults); + $testResults =~ s/\\/\//g; + } system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari; } elsif (isCygwin()) { system "cygstart", $testResults if $launchSafari; @@ -1210,20 +1214,20 @@ sub slowestcmp($$) return pathcmp($testa, $testb); } -sub launchWithCurrentEnv(@) +sub launchWithEnv(\@\%) { - my (@args) = @_; + my ($args, $env) = @_; # Dump the current environment as perl code and then put it in quotes so it is one parameter. - my $environmentDumper = Data::Dumper->new([\%ENV], [qw(*ENV)]); + my $environmentDumper = Data::Dumper->new([\%{$env}], [qw(*ENV)]); $environmentDumper->Indent(0); $environmentDumper->Purity(1); my $allEnvVars = $environmentDumper->Dump(); - unshift @args, "\"$allEnvVars\""; + unshift @{$args}, "\"$allEnvVars\""; my $execScript = File::Spec->catfile(sourceDir(), qw(WebKitTools Scripts execAppWithEnv)); - unshift @args, $execScript; - return @args; + unshift @{$args}, $execScript; + return @{$args}; } sub resolveAndMakeTestResultsDirectory() @@ -1238,10 +1242,9 @@ sub openDiffTool() return if $isDiffToolOpen; return if !$pixelTests; - local %ENV; - $ENV{MallocStackLogging} = 1 if $shouldCheckLeaks; - $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, $imageDiffTool, launchWithCurrentEnv(@diffToolArgs)) or die "unable to open $imageDiffTool\n"; - $ENV{MallocStackLogging} = 0 if $shouldCheckLeaks; + my %CLEAN_ENV; + $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks; + $imageDiffToolPID = open2(\*DIFFIN, \*DIFFOUT, $imageDiffTool, launchWithEnv(@diffToolArgs, %CLEAN_ENV)) or die "unable to open $imageDiffTool\n"; $isDiffToolOpen = 1; } @@ -1249,56 +1252,53 @@ sub openDumpTool() { return if $isDumpToolOpen; - # Save environment variables required for the linux environment. - my $homeDir = $ENV{'HOME'}; - my $libraryPath = $ENV{'LD_LIBRARY_PATH'}; - my $dyldLibraryPath = $ENV{'DYLD_LIBRARY_PATH'}; - my $dbusAddress = $ENV{'DBUS_SESSION_BUS_ADDRESS'}; - my $display = $ENV{'DISPLAY'}; - my $xauthority = $ENV{'XAUTHORITY'}; - my $testfonts = $ENV{'WEBKIT_TESTFONTS'}; - - my $homeDrive = $ENV{'HOMEDRIVE'}; - my $homePath = $ENV{'HOMEPATH'}; - - local %ENV; - if (isQt() || isGtk()) { - if (defined $display) { - $ENV{DISPLAY} = $display; + my %CLEAN_ENV; + + # Generic environment variables + if (defined $ENV{'WEBKIT_TESTFONTS'}) { + $CLEAN_ENV{WEBKIT_TESTFONTS} = $ENV{'WEBKIT_TESTFONTS'}; + } + + $CLEAN_ENV{XML_CATALOG_FILES} = ""; # work around missing /etc/catalog <rdar://problem/4292995> + + # Platform spesifics + if (isLinux()) { + if (defined $ENV{'DISPLAY'}) { + $CLEAN_ENV{DISPLAY} = $ENV{'DISPLAY'}; } else { - $ENV{DISPLAY} = ":1"; + $CLEAN_ENV{DISPLAY} = ":1"; } - if (defined $xauthority) { - $ENV{XAUTHORITY} = $xauthority; + if (defined $ENV{'XAUTHORITY'}) { + $CLEAN_ENV{XAUTHORITY} = $ENV{'XAUTHORITY'}; } - $ENV{'WEBKIT_TESTFONTS'} = $testfonts if defined($testfonts); - $ENV{HOME} = $homeDir; - if (defined $libraryPath) { - $ENV{LD_LIBRARY_PATH} = $libraryPath; + + $CLEAN_ENV{HOME} = $ENV{'HOME'}; + + if (defined $ENV{'LD_LIBRARY_PATH'}) { + $CLEAN_ENV{LD_LIBRARY_PATH} = $ENV{'LD_LIBRARY_PATH'}; } - if (defined $dyldLibraryPath) { - $ENV{DYLD_LIBRARY_PATH} = $dyldLibraryPath; + if (defined $ENV{'DBUS_SESSION_BUS_ADDRESS'}) { + $CLEAN_ENV{DBUS_SESSION_BUS_ADDRESS} = $ENV{'DBUS_SESSION_BUS_ADDRESS'}; } - if (defined $dbusAddress) { - $ENV{DBUS_SESSION_BUS_ADDRESS} = $dbusAddress; + } elsif (isDarwin()) { + if (defined $ENV{'DYLD_LIBRARY_PATH'}) { + $CLEAN_ENV{DYLD_LIBRARY_PATH} = $ENV{'DYLD_LIBRARY_PATH'}; } + + $CLEAN_ENV{DYLD_FRAMEWORK_PATH} = $productDir; + $CLEAN_ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc; + } elsif (isCygwin()) { + $CLEAN_ENV{HOMEDRIVE} = $ENV{'HOMEDRIVE'}; + $CLEAN_ENV{HOMEPATH} = $ENV{'HOMEPATH'}; + + setPathForRunningWebKitApp(\%CLEAN_ENV); } + + # Port spesifics if (isQt()) { - $ENV{QTWEBKIT_PLUGIN_PATH} = productDir() . "/lib/plugins"; + $CLEAN_ENV{QTWEBKIT_PLUGIN_PATH} = productDir() . "/lib/plugins"; } - $ENV{DYLD_FRAMEWORK_PATH} = $productDir; - $ENV{XML_CATALOG_FILES} = ""; # work around missing /etc/catalog <rdar://problem/4292995> - $ENV{DYLD_INSERT_LIBRARIES} = "/usr/lib/libgmalloc.dylib" if $guardMalloc; - if (isCygwin()) { - $ENV{HOMEDRIVE} = $homeDrive; - $ENV{HOMEPATH} = $homePath; - if ($testfonts) { - $ENV{WEBKIT_TESTFONTS} = $testfonts; - } - setPathForRunningWebKitApp(\%ENV) if isCygwin(); - } - my @args = ($dumpTool, @toolArgs); if (isAppleMacWebKit() and !isTiger()) { unshift @args, "arch", "-" . architecture(); @@ -1307,10 +1307,10 @@ sub openDumpTool() if ($useValgrind) { unshift @args, "valgrind", "--suppressions=$platformBaseDirectory/qt/SuppressedValgrindErrors"; } - - $ENV{MallocStackLogging} = 1 if $shouldCheckLeaks; - $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithCurrentEnv(@args)) or die "Failed to start tool: $dumpTool\n"; - $ENV{MallocStackLogging} = 0 if $shouldCheckLeaks; + + $CLEAN_ENV{MallocStackLogging} = 1 if $shouldCheckLeaks; + + $dumpToolPID = open3(\*OUT, \*IN, \*ERROR, launchWithEnv(@args, %CLEAN_ENV)) or die "Failed to start tool: $dumpTool\n"; $isDumpToolOpen = 1; $dumpToolCrashed = 0; } @@ -1337,7 +1337,6 @@ sub dumpToolDidCrash() { return 1 if $dumpToolCrashed; return 0 unless $isDumpToolOpen; - my $pid = waitpid(-1, WNOHANG); return 1 if ($pid == $dumpToolPID); @@ -1617,7 +1616,8 @@ sub convertPathUsingCygpath($$) local *inFH = $cygpath->{"in"}; local *outFH = $cygpath->{"out"}; print outFH $path . "\n"; - chomp(my $convertedPath = <inFH>); + my $convertedPath = <inFH>; + chomp($convertedPath) if defined $convertedPath; return $convertedPath; } diff --git a/WebKitTools/Scripts/webkitdirs.pm b/WebKitTools/Scripts/webkitdirs.pm index d667a8a..8b2ecc1 100644 --- a/WebKitTools/Scripts/webkitdirs.pm +++ b/WebKitTools/Scripts/webkitdirs.pm @@ -541,9 +541,10 @@ sub builtDylibPathForName if (isDarwin() and -d "$configurationProductDir/lib/$libraryName.framework") { return "$configurationProductDir/lib/$libraryName.framework/$libraryName"; } elsif (isWindows()) { - chomp(my $mkspec = `qmake -query QMAKE_MKSPECS`); + my $mkspec = `qmake -query QMAKE_MKSPECS`; + $mkspec =~ s/[\n|\r]$//g; my $qtMajorVersion = retrieveQMakespecVar("$mkspec/qconfig.pri", "QT_MAJOR_VERSION"); - if ($qtMajorVersion eq "unknown") { + if (not $qtMajorVersion) { $qtMajorVersion = ""; } return "$configurationProductDir/lib/$libraryName$qtMajorVersion.dll"; @@ -1328,11 +1329,11 @@ sub retrieveQMakespecVar my $mkspec = $_[0]; my $varname = $_[1]; - my $compiler = "unknown"; + my $varvalue = undef; #print "retrieveMakespecVar " . $mkspec . ", " . $varname . "\n"; local *SPEC; - open SPEC, "<$mkspec" or return "make"; + open SPEC, "<$mkspec" or return $varvalue; while (<SPEC>) { if ($_ =~ /\s*include\((.+)\)/) { # open the included mkspec @@ -1340,15 +1341,15 @@ sub retrieveQMakespecVar (my $volume, my $directories, my $file) = File::Spec->splitpath($mkspec); my $newcwd = "$volume$directories"; chdir $newcwd if $newcwd; - $compiler = retrieveQMakespecVar($1, $varname); + $varvalue = retrieveQMakespecVar($1, $varname); chdir $oldcwd; } elsif ($_ =~ /$varname\s*=\s*([^\s]+)/) { - $compiler = $1; + $varvalue = $1; last; } } close SPEC; - return $compiler; + return $varvalue; } sub qtMakeCommand($) @@ -1645,9 +1646,13 @@ sub setPathForRunningWebKitApp { my ($env) = @_; - return unless isAppleWinWebKit(); - - $env->{PATH} = join(':', productDir(), dirname(installedSafariPath()), appleApplicationSupportPath(), $env->{PATH} || ""); + if (isAppleWinWebKit()) { + $env->{PATH} = join(':', productDir(), dirname(installedSafariPath()), appleApplicationSupportPath(), $env->{PATH} || ""); + } elsif (isQt()) { + my $qtLibs = `qmake -query QT_INSTALL_LIBS`; + $qtLibs =~ s/[\n|\r]$//g; + $env->{PATH} = join(';', $qtLibs, productDir() . "/lib", $env->{PATH} || ""); + } } sub runSafari diff --git a/WebKitTools/Scripts/webkitpy/committers.py b/WebKitTools/Scripts/webkitpy/committers.py index 73e4172..0efb4e7 100644 --- a/WebKitTools/Scripts/webkitpy/committers.py +++ b/WebKitTools/Scripts/webkitpy/committers.py @@ -80,6 +80,8 @@ committers_unable_to_review = [ Committer("Brett Wilson", "brettw@chromium.org"), Committer("Brian Weinstein", "bweinstein@apple.com"), Committer("Cameron McCormack", "cam@webkit.org"), + Committer("Carol Szabo", "carol.szabo@nokia.com"), + Committer("Chang Shu", "chang.shu@nokia.com"), Committer("Chris Fleizach", "cfleizach@apple.com"), Committer("Chris Jerdonek", "cjerdonek@webkit.org"), Committer("Chris Marrin", "cmarrin@apple.com"), @@ -131,7 +133,7 @@ committers_unable_to_review = [ Committer("Mike Belshe", ["mbelshe@chromium.org", "mike@belshe.com"]), Committer("Mike Fenton", ["mike.fenton@torchmobile.com", "mifenton@rim.com"]), Committer("Mike Thole", ["mthole@mikethole.com", "mthole@apple.com"]), - Committer("Nate Chapin", "japhet@chromium.org"), + Committer("Mikhail Naganov", "mnaganov@chromium.org"), Committer("Ojan Vafai", "ojan@chromium.org"), Committer("Pam Greene", "pam@chromium.org"), Committer("Peter Kasting", ["pkasting@google.com", "pkasting@chromium.org"]), @@ -153,6 +155,7 @@ committers_unable_to_review = [ Committer("Yong Li", ["yong.li@torchmobile.com", "yong.li.webkit@gmail.com"]), Committer("Yongjun Zhang", "yongjun.zhang@nokia.com"), Committer("Yury Semikhatsky", "yurys@chromium.org"), + Committer("Yuzo Fujishima", "yuzo@google.com"), Committer("Zoltan Herczeg", "zherczeg@webkit.org"), Committer("Zoltan Horvath", "zoltan@webkit.org"), ] @@ -211,6 +214,7 @@ reviewers_list = [ Reviewer("Laszlo Gombos", "laszlo.1.gombos@nokia.com"), Reviewer("Maciej Stachowiak", "mjs@apple.com"), Reviewer("Mark Rowe", "mrowe@apple.com"), + Reviewer("Nate Chapin", "japhet@chromium.org"), Reviewer("Nikolas Zimmermann", ["zimmermann@kde.org", "zimmermann@physik.rwth-aachen.de", "zimmermann@webkit.org"]), Reviewer("Oliver Hunt", "oliver@apple.com"), Reviewer("Pavel Feldman", "pfeldman@chromium.org"), diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py index b7b26e9..f38a7ab 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -31,7 +31,7 @@ import logging import os from layout_package import json_results_generator -from layout_package import path_utils +from port import path_utils from layout_package import test_expectations from layout_package import test_failures diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py index 596e1e4..dc24ade 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -35,7 +35,7 @@ import time import urllib2 import xml.dom.minidom -from layout_package import path_utils +from port import path_utils from layout_package import test_expectations sys.path.append(path_utils.path_from_base('third_party', 'WebKit', diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py index 6c094e3..72b30a1 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py index f1647f7..5b0d186 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -36,7 +36,7 @@ import os import re import sys import time -import path_utils +from port import path_utils sys.path.append(path_utils.path_from_base('third_party', 'WebKit', 'WebKitTools')) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py index 6957dea..56d7b5a 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py index 91fe136..b7e620d 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -36,7 +36,7 @@ under that directory.""" import glob import os -import path_utils +from port import path_utils # When collecting test cases, we include any file with these extensions. _supported_file_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl', diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py index 10d0509..9f52686 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -46,7 +46,7 @@ import thread import threading import time -import path_utils +from port import path_utils import test_failures diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/__init__.py index 09e7b4b..1730085 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -30,7 +30,7 @@ """Platform-specific utilities and pseudo-constants Any functions whose implementations or values differ from one platform to -another should be defined in their respective platform_utils_<platform>.py +another should be defined in their respective <platform>.py modules. The appropriate one of those will be imported into this module to provide callers with a common, platform-independent interface. @@ -43,8 +43,8 @@ import sys # especially has had problems), but we'll allow the platform utils to be # included in any case so we don't get an import error. if sys.platform in ('cygwin', 'win32'): - from platform_utils_win import * + from chromium_win import * elif sys.platform == 'darwin': - from platform_utils_mac import * + from chromium_mac import * elif sys.platform in ('linux', 'linux2', 'freebsd7', 'openbsd4'): - from platform_utils_linux import * + from chromium_linux import * diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py index 15f2065..1fb0367 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -38,7 +38,7 @@ import sys import http_server_base import path_utils -import platform_utils +import port class LayoutTestApacheHttpd(http_server_base.HttpServerBase): @@ -78,7 +78,7 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase): error_log = self._cygwin_safe_join(output_dir, "error_log.txt") document_root = self._cygwin_safe_join(test_dir, "http", "tests") - executable = platform_utils.apache_executable_path() + executable = port.apache_executable_path() if self._is_cygwin(): executable = self._get_cygwin_path(executable) @@ -146,7 +146,7 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase): test_dir: absolute path to the LayoutTests directory. output_dir: absolute path to the layout test results directory. """ - httpd_config = platform_utils.apache_config_file_path() + httpd_config = port.apache_config_file_path() httpd_config_copy = os.path.join(output_dir, "httpd.conf") httpd_conf = open(httpd_config).read() if self._is_cygwin(): diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py index 87b27c7..9ffc401 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -27,7 +27,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -"""This is the Linux implementation of the layout_package.platform_utils +"""This is the Linux implementation of the port package. This file should only be imported by that package.""" import os @@ -36,8 +36,8 @@ import subprocess import sys import logging +import chromium_win import path_utils -import platform_utils_win def platform_name(): @@ -75,7 +75,7 @@ def baseline_search_path(platform=None): """Returns the list of directories to search for baselines/results, in order of preference. Paths are relative to the top of the source tree.""" return [baseline_path(platform), - platform_utils_win.baseline_path('chromium-win'), + chromium_win.baseline_path('chromium-win'), path_utils.webkit_baseline_path('win'), path_utils.webkit_baseline_path('mac')] diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py index 1eaa10c..d0fbc01 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -27,7 +27,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -"""This is the Mac implementation of the layout_package.platform_utils +"""This is the Mac implementation of the port interface package. This file should only be imported by that package.""" import os diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py index 3cbbec3..1e0b212 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -27,14 +27,14 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -"""This is the Linux implementation of the layout_package.platform_utils +"""This is the Linux implementation of the port package. This file should only be imported by that package.""" import os -import path_utils import subprocess import sys +import path_utils def platform_name(): """Returns the name of the platform we're currently running on.""" diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py index dfcb44f..99e2ea1 100755 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server_base.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server_base.py index 2720486..026e070 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server_base.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server_base.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/httpd2.pem b/WebKitTools/Scripts/webkitpy/layout_tests/port/httpd2.pem index 6349b78..6349b78 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/httpd2.pem +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/httpd2.pem diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf b/WebKitTools/Scripts/webkitpy/layout_tests/port/lighttpd.conf index d3150dd..d3150dd 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/lighttpd.conf diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/path_utils.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/path_utils.py index 26d062b..70b8c03 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/path_utils.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/path_utils.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -29,9 +29,9 @@ """This package contains utility methods for manipulating paths and filenames for test results and baselines. It also contains wrappers -of a few routines in platform_utils.py so that platform_utils.py can +of a few routines in port/ so that the port package can be considered a 'protected' package - i.e., this file should be -the only file that ever includes platform_utils. This leads to +the only file that ever includes port. This leads to us including a few things that don't really have anything to do with paths, unfortunately.""" @@ -40,10 +40,10 @@ import os import stat import sys -import platform_utils -import platform_utils_win -import platform_utils_mac -import platform_utils_linux +import port +import chromium_win +import chromium_mac +import chromium_linux # Cache some values so we don't have to recalculate them. _basedir is # used by PathFromBase() and caches the full (native) path to the top @@ -69,20 +69,20 @@ def chromium_baseline_path(platform=None): baseline results from chromium ports. If |platform| is None, the currently executing platform is used. - Note: although directly referencing individual platform_utils_* files is + Note: although directly referencing individual port/* files is usually discouraged, we allow it here so that the rebaselining tool can pull baselines for platforms other than the host platform.""" # Normalize the platform string. platform = platform_name(platform) if platform.startswith('chromium-mac'): - return platform_utils_mac.baseline_path(platform) + return chromium_mac.baseline_path(platform) elif platform.startswith('chromium-win'): - return platform_utils_win.baseline_path(platform) + return chromium_win.baseline_path(platform) elif platform.startswith('chromium-linux'): - return platform_utils_linux.baseline_path(platform) + return chromium_linux.baseline_path(platform) - return platform_utils.baseline_path() + return port.baseline_path() def webkit_baseline_path(platform): @@ -98,19 +98,19 @@ def baseline_search_path(platform=None): the source tree. If parameter platform is None, returns the list for the current platform that the script is running on. - Note: although directly referencing individual platform_utils_* files is + Note: although directly referencing individual port/* files is usually discouraged, we allow it here so that the rebaselining tool can pull baselines for platforms other than the host platform.""" # Normalize the platform name. platform = platform_name(platform) if platform.startswith('chromium-mac'): - return platform_utils_mac.baseline_search_path(platform) + return chromium_mac.baseline_search_path(platform) elif platform.startswith('chromium-win'): - return platform_utils_win.baseline_search_path(platform) + return chromium_win.baseline_search_path(platform) elif platform.startswith('chromium-linux'): - return platform_utils_linux.baseline_search_path(platform) - return platform_utils.baseline_search_path() + return chromium_linux.baseline_search_path(platform) + return port.baseline_search_path() def expected_baselines(filename, suffix, platform=None, all_baselines=False): @@ -200,7 +200,7 @@ def _win_path_to_unix(path): # # Routines that are arguably platform-specific but have been made -# generic for now (they used to be in platform_utils_*) +# generic for now # @@ -335,7 +335,7 @@ def remove_directory(*path): remove_with_retry(os.rmdir, file_path) # -# Wrappers around platform_utils +# Wrappers around port/ # @@ -345,51 +345,51 @@ def platform_name(platform=None): currently running system. If |platform| is of the form 'chromium-*', it is returned unchanged, otherwise 'chromium-' is prepended.""" if platform == None: - return platform_utils.platform_name() + return port.platform_name() if not platform.startswith('chromium-'): platform = "chromium-" + platform return platform def platform_version(): - return platform_utils.platform_version() + return port.platform_version() def lighttpd_executable_path(): - return platform_utils.lighttpd_executable_path() + return port.lighttpd_executable_path() def lighttpd_module_path(): - return platform_utils.lighttpd_module_path() + return port.lighttpd_module_path() def lighttpd_php_path(): - return platform_utils.lighttpd_php_path() + return port.lighttpd_php_path() def wdiff_path(): - return platform_utils.wdiff_path() + return port.wdiff_path() def test_shell_path(target): - return platform_utils.test_shell_path(target) + return port.test_shell_path(target) def image_diff_path(target): - return platform_utils.image_diff_path(target) + return port.image_diff_path(target) def layout_test_helper_path(target): - return platform_utils.layout_test_helper_path(target) + return port.layout_test_helper_path(target) def fuzzy_match_path(): - return platform_utils.fuzzy_match_path() + return port.fuzzy_match_path() def shut_down_http_server(server_pid): - return platform_utils.shut_down_http_server(server_pid) + return port.shut_down_http_server(server_pid) def kill_all_test_shells(): - platform_utils.kill_all_test_shells() + port.kill_all_test_shells() diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/websocket_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py index 7fc47a0..c6c7527 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/websocket_server.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -40,7 +40,7 @@ import time import urllib import path_utils -import platform_utils +import port import http_server _WS_LOG_PREFIX = 'pywebsocket.ws.log-' @@ -255,7 +255,7 @@ class PyWebSocket(http_server.Lighttpd): 'Failed to find %s server pid.' % self._server_name) logging.debug('Shutting down %s server %d.' % (self._server_name, pid)) - platform_utils.kill_process(pid) + port.kill_process(pid) if self._process: self._process.wait() diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py index 1db811f..414baaf 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -54,7 +54,7 @@ import urllib import webbrowser import zipfile -from layout_package import path_utils +from port import path_utils from layout_package import test_expectations from test_types import image_diff from test_types import text_diff diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py b/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py index 88b97f8..571ae3f 100755 --- a/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -59,17 +59,19 @@ import sys import time import traceback -from layout_package import apache_http_server from layout_package import test_expectations -from layout_package import http_server from layout_package import json_layout_results_generator from layout_package import metered_stream -from layout_package import path_utils -from layout_package import platform_utils from layout_package import test_failures from layout_package import test_shell_thread from layout_package import test_files -from layout_package import websocket_server + +import port +from port import apache_http_server +from port import http_server +from port import path_utils +from port import websocket_server + from test_types import fuzzy_image_diff from test_types import image_diff from test_types import test_type_base @@ -1469,7 +1471,7 @@ def main(options, args): if not options.num_test_shells: # TODO(ojan): Investigate perf/flakiness impact of using numcores + 1. - options.num_test_shells = platform_utils.get_num_cores() + options.num_test_shells = port.get_num_cores() write = create_logging_writer(options, 'config') write("Running %s test_shells in parallel" % options.num_test_shells) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py index 134b507..100fd0d 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -37,7 +37,7 @@ import os import shutil import subprocess -from layout_package import path_utils +from port import path_utils from layout_package import test_failures from test_types import test_type_base diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py index b0bf189..86b9659 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -40,7 +40,7 @@ import os import shutil import subprocess -from layout_package import path_utils +from port import path_utils from layout_package import test_failures from test_types import test_type_base diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py index 334ae70..79b7e34 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -39,7 +39,7 @@ import logging import os.path import subprocess -from layout_package import path_utils +from port import path_utils class TestArguments(object): diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py index 8cff9e6..3c895af 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2010 The Chromium Authors. All rights reserved. +# Copyright (C) 2010 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -11,7 +11,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the Chromium name nor the names of its +# * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -37,7 +37,7 @@ import errno import logging import os.path -from layout_package import path_utils +from port import path_utils from layout_package import test_failures from test_types import test_type_base diff --git a/WebKitTools/Scripts/webkitpy/style/checker.py b/WebKitTools/Scripts/webkitpy/style/checker.py index faf954f..dc14ea3 100644 --- a/WebKitTools/Scripts/webkitpy/style/checker.py +++ b/WebKitTools/Scripts/webkitpy/style/checker.py @@ -37,6 +37,9 @@ import sys from .. style_references import parse_patch from error_handlers import DefaultStyleErrorHandler from error_handlers import PatchStyleErrorHandler +from filter import CategoryFilter +from processors.common import check_no_carriage_return +from processors.common import categories as CommonCategories from processors.cpp import CppProcessor from processors.text import TextProcessor @@ -106,10 +109,17 @@ SKIPPED_FILES_WITHOUT_WARNING = [ ] +# The maximum number of errors to report per file, per category. +# If a category is not a key, then it has no maximum. +MAX_REPORTS_PER_CATEGORY = { + "whitespace/carriage_return": 1 +} + + def style_categories(): """Return the set of all categories used by check-webkit-style.""" - # If other processors had categories, we would take their union here. - return CppProcessor.categories + # Take the union across all processors. + return CommonCategories.union(CppProcessor.categories) def webkit_argument_defaults(): @@ -191,79 +201,6 @@ Syntax: %(program_name)s [--verbose=#] [--git-commit=<SingleCommit>] [--output=v return usage -class CategoryFilter(object): - - """Filters whether to check style categories.""" - - def __init__(self, filter_rules=None): - """Create a category filter. - - This method performs argument validation but does not strip - leading or trailing white space. - - Args: - filter_rules: A list of strings that are filter rules, which - are strings beginning with the plus or minus - symbol (+/-). The list should include any - default filter rules at the beginning. - Defaults to the empty list. - - Raises: - ValueError: Invalid filter rule if a rule does not start with - plus ("+") or minus ("-"). - - """ - if filter_rules is None: - filter_rules = [] - - for rule in filter_rules: - if not (rule.startswith('+') or rule.startswith('-')): - raise ValueError('Invalid filter rule "%s": every rule ' - 'rule in the --filter flag must start ' - 'with + or -.' % rule) - - self._filter_rules = filter_rules - self._should_check_category = {} # Cached dictionary of category to True/False - - def __str__(self): - return ",".join(self._filter_rules) - - # Useful for unit testing. - def __eq__(self, other): - """Return whether this CategoryFilter instance is equal to another.""" - return self._filter_rules == other._filter_rules - - # Useful for unit testing. - def __ne__(self, other): - # Python does not automatically deduce from __eq__(). - return not (self == other) - - def should_check(self, category): - """Return whether the category should be checked. - - The rules for determining whether a category should be checked - are as follows. By default all categories should be checked. - Then apply the filter rules in order from first to last, with - later flags taking precedence. - - A filter rule applies to a category if the string after the - leading plus/minus (+/-) matches the beginning of the category - name. A plus (+) means the category should be checked, while a - minus (-) means the category should not be checked. - - """ - if category in self._should_check_category: - return self._should_check_category[category] - - should_check = True # All categories checked by default. - for rule in self._filter_rules: - if not category.startswith(rule[1:]): - continue - should_check = rule.startswith('+') - self._should_check_category[category] = should_check # Update cache. - return should_check - - # This class should not have knowledge of the flag key names. class ProcessorOptions(object): @@ -290,12 +227,19 @@ class ProcessorOptions(object): """ - def __init__(self, output_format="emacs", verbosity=1, filter=None, - git_commit=None, extra_flag_values=None): - if filter is None: - filter = CategoryFilter() + def __init__(self, + output_format="emacs", + verbosity=1, + filter=None, + max_reports_per_category=None, + git_commit=None, + extra_flag_values=None): if extra_flag_values is None: extra_flag_values = {} + if filter is None: + filter = CategoryFilter() + if max_reports_per_category is None: + max_reports_per_category = {} if output_format not in ("emacs", "vs7"): raise ValueError('Invalid "output_format" parameter: ' @@ -307,24 +251,27 @@ class ProcessorOptions(object): "value must be an integer between 1-5 inclusive. " 'Value given: "%s".' % verbosity) - self.output_format = output_format - self.verbosity = verbosity + self.extra_flag_values = extra_flag_values self.filter = filter self.git_commit = git_commit - self.extra_flag_values = extra_flag_values + self.max_reports_per_category = max_reports_per_category + self.output_format = output_format + self.verbosity = verbosity # Useful for unit testing. def __eq__(self, other): """Return whether this ProcessorOptions instance is equal to another.""" - if self.output_format != other.output_format: - return False - if self.verbosity != other.verbosity: + if self.extra_flag_values != other.extra_flag_values: return False if self.filter != other.filter: return False if self.git_commit != other.git_commit: return False - if self.extra_flag_values != other.extra_flag_values: + if self.max_reports_per_category != other.max_reports_per_category: + return False + if self.output_format != other.output_format: + return False + if self.verbosity != other.verbosity: return False return True @@ -568,8 +515,12 @@ class ArgumentParser(object): filter = CategoryFilter(filter_rules) - options = ProcessorOptions(output_format, verbosity, filter, - git_commit, extra_flag_values) + options = ProcessorOptions(extra_flag_values=extra_flag_values, + filter=filter, + git_commit=git_commit, + max_reports_per_category=MAX_REPORTS_PER_CATEGORY, + output_format=output_format, + verbosity=verbosity) return (filenames, options) @@ -720,35 +671,36 @@ class StyleChecker(object): # '\r\n' as in Windows), a warning is issued below if this file # is processed. if file_path == '-': - lines = codecs.StreamReaderWriter(sys.stdin, - codecs.getreader('utf8'), - codecs.getwriter('utf8'), - 'replace').read().split('\n') + file = codecs.StreamReaderWriter(sys.stdin, + codecs.getreader('utf8'), + codecs.getwriter('utf8'), + 'replace') else: - lines = codecs.open(file_path, 'r', 'utf8', 'replace').read().split('\n') + file = codecs.open(file_path, 'r', 'utf8', 'replace') - carriage_return_found = False - # Remove trailing '\r'. - for line_number in range(len(lines)): - if lines[line_number].endswith('\r'): - lines[line_number] = lines[line_number].rstrip('\r') - carriage_return_found = True + contents = file.read() except IOError: self._stderr_write("Skipping input '%s': Can't open for reading\n" % file_path) return - processor.process(lines) + lines = contents.split("\n") - if carriage_return_found and os.linesep != '\r\n': - # FIXME: Make sure this error also shows up when checking - # patches, if appropriate. + for line_number in range(len(lines)): + # FIXME: We should probably use the SVN "eol-style" property + # or a white list to decide whether or not to do + # the carriage-return check. Originally, we did the + # check only if (os.linesep != '\r\n'). # - # Use 0 for line_number since outputting only one error for - # potentially several lines. - handle_style_error(file_path, 0, 'whitespace/newline', 1, - 'One or more unexpected \\r (^M) found;' - 'better to use only a \\n') + # FIXME: As a minor optimization, we can have + # check_no_carriage_return() return whether + # the line ends with "\r". + check_no_carriage_return(lines[line_number], line_number, + handle_style_error) + if lines[line_number].endswith("\r"): + lines[line_number] = lines[line_number].rstrip("\r") + + processor.process(lines) def check_file(self, file_path, handle_style_error=None, process_file=None): """Check style in the given file. diff --git a/WebKitTools/Scripts/webkitpy/style/checker_unittest.py b/WebKitTools/Scripts/webkitpy/style/checker_unittest.py index 4d6b2e7..814bd41 100755 --- a/WebKitTools/Scripts/webkitpy/style/checker_unittest.py +++ b/WebKitTools/Scripts/webkitpy/style/checker_unittest.py @@ -37,67 +37,13 @@ import unittest import checker as style -from checker import CategoryFilter from checker import ProcessorDispatcher from checker import ProcessorOptions from checker import StyleChecker +from filter import CategoryFilter from processors.cpp import CppProcessor from processors.text import TextProcessor -class CategoryFilterTest(unittest.TestCase): - - """Tests CategoryFilter class.""" - - def test_init(self): - """Test __init__ constructor.""" - self.assertRaises(ValueError, CategoryFilter, ["no_prefix"]) - CategoryFilter() # No ValueError: works - CategoryFilter(["+"]) # No ValueError: works - CategoryFilter(["-"]) # No ValueError: works - - def test_str(self): - """Test __str__ "to string" operator.""" - filter = CategoryFilter(["+a", "-b"]) - self.assertEquals(str(filter), "+a,-b") - - def test_eq(self): - """Test __eq__ equality function.""" - filter1 = CategoryFilter(["+a", "+b"]) - filter2 = CategoryFilter(["+a", "+b"]) - filter3 = CategoryFilter(["+b", "+a"]) - - # == calls __eq__. - self.assertTrue(filter1 == filter2) - self.assertFalse(filter1 == filter3) # Cannot test with assertNotEqual. - - def test_ne(self): - """Test __ne__ inequality function.""" - # != calls __ne__. - # By default, __ne__ always returns true on different objects. - # Thus, just check the distinguishing case to verify that the - # code defines __ne__. - self.assertFalse(CategoryFilter() != CategoryFilter()) - - def test_should_check(self): - """Test should_check() method.""" - filter = CategoryFilter() - self.assertTrue(filter.should_check("everything")) - # Check a second time to exercise cache. - self.assertTrue(filter.should_check("everything")) - - filter = CategoryFilter(["-"]) - self.assertFalse(filter.should_check("anything")) - # Check a second time to exercise cache. - self.assertFalse(filter.should_check("anything")) - - filter = CategoryFilter(["-", "+ab"]) - self.assertTrue(filter.should_check("abc")) - self.assertFalse(filter.should_check("a")) - - filter = CategoryFilter(["+", "-ab"]) - self.assertFalse(filter.should_check("abc")) - self.assertTrue(filter.should_check("a")) - class ProcessorOptionsTest(unittest.TestCase): @@ -110,6 +56,7 @@ class ProcessorOptionsTest(unittest.TestCase): self.assertEquals(options.extra_flag_values, {}) self.assertEquals(options.filter, CategoryFilter()) self.assertEquals(options.git_commit, None) + self.assertEquals(options.max_reports_per_category, {}) self.assertEquals(options.output_format, "emacs") self.assertEquals(options.verbosity, 1) @@ -126,11 +73,13 @@ class ProcessorOptionsTest(unittest.TestCase): options = ProcessorOptions(extra_flag_values={"extra_value" : 2}, filter=CategoryFilter(["+"]), git_commit="commit", + max_reports_per_category={"category": 3}, output_format="vs7", verbosity=3) self.assertEquals(options.extra_flag_values, {"extra_value" : 2}) self.assertEquals(options.filter, CategoryFilter(["+"])) self.assertEquals(options.git_commit, "commit") + self.assertEquals(options.max_reports_per_category, {"category": 3}) self.assertEquals(options.output_format, "vs7") self.assertEquals(options.verbosity, 3) @@ -143,11 +92,14 @@ class ProcessorOptionsTest(unittest.TestCase): options = ProcessorOptions(extra_flag_values={"extra_value" : 1}, filter=CategoryFilter(["+"]), git_commit="commit", + max_reports_per_category={"category": 3}, output_format="vs7", verbosity=1) self.assertFalse(options == ProcessorOptions(extra_flag_values={"extra_value" : 2})) self.assertFalse(options == ProcessorOptions(filter=CategoryFilter(["-"]))) self.assertFalse(options == ProcessorOptions(git_commit="commit2")) + self.assertFalse(options == ProcessorOptions(max_reports_per_category= + {"category": 2})) self.assertFalse(options == ProcessorOptions(output_format="emacs")) self.assertFalse(options == ProcessorOptions(verbosity=2)) @@ -173,9 +125,9 @@ class ProcessorOptionsTest(unittest.TestCase): self.assertFalse(options.is_reportable("xyz", 3)) -class WebKitArgumentDefaultsTest(unittest.TestCase): +class GlobalVariablesTest(unittest.TestCase): - """Tests validity of default arguments used by check-webkit-style.""" + """Tests validity of the global variables.""" def defaults(self): return style.webkit_argument_defaults() @@ -206,6 +158,13 @@ class WebKitArgumentDefaultsTest(unittest.TestCase): # on valid arguments elsewhere. parser.parse([]) # arguments valid: no error or SystemExit + def test_max_reports_per_category(self): + """Check that MAX_REPORTS_PER_CATEGORY is valid.""" + categories = style.style_categories() + for category in style.MAX_REPORTS_PER_CATEGORY.iterkeys(): + self.assertTrue(category in categories, + 'Key "%s" is not a category' % category) + class ArgumentPrinterTest(unittest.TestCase): @@ -217,8 +176,11 @@ class ArgumentPrinterTest(unittest.TestCase): filter_rules=[], git_commit=None, extra_flag_values={}): filter = CategoryFilter(filter_rules) - return style.ProcessorOptions(output_format, verbosity, filter, - git_commit, extra_flag_values) + return style.ProcessorOptions(extra_flag_values=extra_flag_values, + filter=filter, + git_commit=git_commit, + output_format=output_format, + verbosity=verbosity) def test_to_flag_string(self): options = self._create_options('vs7', 5, ['+foo', '-bar'], 'git', diff --git a/WebKitTools/Scripts/webkitpy/style/error_handlers.py b/WebKitTools/Scripts/webkitpy/style/error_handlers.py index 54b1d76..31140de 100644 --- a/WebKitTools/Scripts/webkitpy/style/error_handlers.py +++ b/WebKitTools/Scripts/webkitpy/style/error_handlers.py @@ -32,7 +32,9 @@ Methods: Handle the occurrence of a style error. - Check whether the error is reportable. If so, report the details. + Check whether the error is reportable. If so, increment the total + error count and report the details. Note that error reporting can + be suppressed after reaching a certain number of reports. Args: line_number: The integer line number of the line containing the error. @@ -79,6 +81,28 @@ class DefaultStyleErrorHandler(object): self._options = options self._stderr_write = stderr_write + # A string to integer dictionary cache of the number of reportable + # errors per category passed to this instance. + self._category_totals = { } + + def _add_reportable_error(self, category): + """Increment the error count and return the new category total.""" + self._increment_error_count() # Increment the total. + + # Increment the category total. + if not category in self._category_totals: + self._category_totals[category] = 1 + else: + self._category_totals[category] += 1 + + return self._category_totals[category] + + def _max_reports(self, category): + """Return the maximum number of errors to report.""" + if not category in self._options.max_reports_per_category: + return None + return self._options.max_reports_per_category[category] + def __call__(self, line_number, category, confidence, message): """Handle the occurrence of a style error. @@ -88,13 +112,23 @@ class DefaultStyleErrorHandler(object): if not self._options.is_reportable(category, confidence): return - self._increment_error_count() + category_total = self._add_reportable_error(category) + + max_reports = self._max_reports(category) + + if (max_reports is not None) and (category_total > max_reports): + # Then suppress displaying the error. + return if self._options.output_format == 'vs7': format_string = "%s(%s): %s [%s] [%d]\n" else: format_string = "%s:%s: %s [%s] [%d]\n" + if category_total == max_reports: + format_string += ("Suppressing further [%s] reports for this " + "file.\n" % category) + self._stderr_write(format_string % (self._file_path, line_number, message, @@ -130,7 +164,7 @@ class PatchStyleErrorHandler(object): if not self._line_numbers: for line in self._diff.lines: # When deleted line is not set, it means that - # the line is newly added. + # the line is newly added (or modified). if not line[0]: self._line_numbers.add(line[1]) @@ -140,9 +174,9 @@ class PatchStyleErrorHandler(object): """Handle the occurrence of a style error. This function does not report errors occurring in lines not - modified or added. + marked as modified or added in the patch. - Args: see the DefaultStyleErrorHandler.__call__() documentation. + See the docstring of this module for more information. """ if line_number not in self._get_line_numbers(): diff --git a/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py b/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py index 6a91ff2..83bdbb9 100644 --- a/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py +++ b/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py @@ -50,9 +50,6 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase): _category = "whitespace/tab" - def _options(self, output_format): - return ProcessorOptions(verbosity=3, output_format=output_format) - def _error_handler(self, options): file_path = "foo.h" return DefaultStyleErrorHandler(file_path, @@ -60,29 +57,28 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase): self._mock_increment_error_count, self._mock_stderr_write) - def _prepare_call(self, output_format="emacs"): - """Return options after initializing.""" - options = self._options(output_format) - - # Test that count is initialized to zero. + def _check_initialized(self): + """Check that count and error messages are initialized.""" self.assertEquals(0, self._error_count) self.assertEquals("", self._error_messages) - return options - - def _call_error_handler(self, options, confidence): - """Handle an error with given confidence.""" - handle_error = self._error_handler(options) - + def _call(self, handle_error, options, confidence): + """Handle an error with the given error handler.""" line_number = 100 message = "message" handle_error(line_number, self._category, confidence, message) + def _call_error_handler(self, options, confidence): + """Handle an error using a new error handler.""" + handle_error = self._error_handler(options) + self._call(handle_error, options, confidence) + def test_call_non_reportable(self): """Test __call__() method with a non-reportable error.""" confidence = 1 - options = self._prepare_call() + options = ProcessorOptions(verbosity=3) + self._check_initialized() # Confirm the error is not reportable. self.assertFalse(options.is_reportable(self._category, confidence)) @@ -95,7 +91,8 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase): def test_call_reportable_emacs(self): """Test __call__() method with a reportable error and emacs format.""" confidence = 5 - options = self._prepare_call("emacs") + options = ProcessorOptions(verbosity=3, output_format="emacs") + self._check_initialized() self._call_error_handler(options, confidence) @@ -106,7 +103,8 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase): def test_call_reportable_vs7(self): """Test __call__() method with a reportable error and vs7 format.""" confidence = 5 - options = self._prepare_call("vs7") + options = ProcessorOptions(verbosity=3, output_format="vs7") + self._check_initialized() self._call_error_handler(options, confidence) @@ -114,6 +112,36 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase): self.assertEquals(self._error_messages, "foo.h(100): message [whitespace/tab] [5]\n") + def test_call_max_reports_per_category(self): + """Test error report suppression in __call__() method.""" + confidence = 5 + options = ProcessorOptions(verbosity=3, + max_reports_per_category={self._category: 2}) + error_handler = self._error_handler(options) + + self._check_initialized() + + # First call: usual reporting. + self._call(error_handler, options, confidence) + self.assertEquals(1, self._error_count) + self.assertEquals(self._error_messages, + "foo.h:100: message [whitespace/tab] [5]\n") + + # Second call: suppression message reported. + self._error_messages = "" + self._call(error_handler, options, confidence) + self.assertEquals(2, self._error_count) + self.assertEquals(self._error_messages, + "foo.h:100: message [whitespace/tab] [5]\n" + "Suppressing further [%s] reports for this file.\n" + % self._category) + + # Third call: no report. + self._error_messages = "" + self._call(error_handler, options, confidence) + self.assertEquals(3, self._error_count) + self.assertEquals(self._error_messages, "") + class PatchStyleErrorHandlerTest(StyleErrorHandlerTestBase): diff --git a/WebKitTools/Scripts/webkitpy/style/filter.py b/WebKitTools/Scripts/webkitpy/style/filter.py new file mode 100644 index 0000000..1b41424 --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/style/filter.py @@ -0,0 +1,97 @@ +# Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Contains filter-related code.""" + + +class CategoryFilter(object): + + """Filters whether to check style categories.""" + + def __init__(self, filter_rules=None): + """Create a category filter. + + This method performs argument validation but does not strip + leading or trailing white space. + + Args: + filter_rules: A list of strings that are filter rules, which + are strings beginning with the plus or minus + symbol (+/-). The list should include any + default filter rules at the beginning. + Defaults to the empty list. + + Raises: + ValueError: Invalid filter rule if a rule does not start with + plus ("+") or minus ("-"). + + """ + if filter_rules is None: + filter_rules = [] + + for rule in filter_rules: + if not (rule.startswith('+') or rule.startswith('-')): + raise ValueError('Invalid filter rule "%s": every rule ' + 'rule in the --filter flag must start ' + 'with + or -.' % rule) + + self._filter_rules = filter_rules + self._should_check_category = {} # Cached dictionary of category to True/False + + def __str__(self): + return ",".join(self._filter_rules) + + # Useful for unit testing. + def __eq__(self, other): + """Return whether this CategoryFilter instance is equal to another.""" + return self._filter_rules == other._filter_rules + + # Useful for unit testing. + def __ne__(self, other): + # Python does not automatically deduce from __eq__(). + return not (self == other) + + def should_check(self, category): + """Return whether the category should be checked. + + The rules for determining whether a category should be checked + are as follows. By default all categories should be checked. + Then apply the filter rules in order from first to last, with + later flags taking precedence. + + A filter rule applies to a category if the string after the + leading plus/minus (+/-) matches the beginning of the category + name. A plus (+) means the category should be checked, while a + minus (-) means the category should not be checked. + + """ + if category in self._should_check_category: + return self._should_check_category[category] + + should_check = True # All categories checked by default. + for rule in self._filter_rules: + if not category.startswith(rule[1:]): + continue + should_check = rule.startswith('+') + self._should_check_category[category] = should_check # Update cache. + return should_check + diff --git a/WebKitTools/Scripts/webkitpy/style/filter_unittest.py b/WebKitTools/Scripts/webkitpy/style/filter_unittest.py new file mode 100644 index 0000000..0b12123 --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/style/filter_unittest.py @@ -0,0 +1,84 @@ +# Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Unit tests for filter.py.""" + + +import unittest + +from filter import CategoryFilter + + +class CategoryFilterTest(unittest.TestCase): + + """Tests CategoryFilter class.""" + + def test_init(self): + """Test __init__ constructor.""" + self.assertRaises(ValueError, CategoryFilter, ["no_prefix"]) + CategoryFilter() # No ValueError: works + CategoryFilter(["+"]) # No ValueError: works + CategoryFilter(["-"]) # No ValueError: works + + def test_str(self): + """Test __str__ "to string" operator.""" + filter = CategoryFilter(["+a", "-b"]) + self.assertEquals(str(filter), "+a,-b") + + def test_eq(self): + """Test __eq__ equality function.""" + filter1 = CategoryFilter(["+a", "+b"]) + filter2 = CategoryFilter(["+a", "+b"]) + filter3 = CategoryFilter(["+b", "+a"]) + + # == calls __eq__. + self.assertTrue(filter1 == filter2) + self.assertFalse(filter1 == filter3) # Cannot test with assertNotEqual. + + def test_ne(self): + """Test __ne__ inequality function.""" + # != calls __ne__. + # By default, __ne__ always returns true on different objects. + # Thus, just check the distinguishing case to verify that the + # code defines __ne__. + self.assertFalse(CategoryFilter() != CategoryFilter()) + + def test_should_check(self): + """Test should_check() method.""" + filter = CategoryFilter() + self.assertTrue(filter.should_check("everything")) + # Check a second time to exercise cache. + self.assertTrue(filter.should_check("everything")) + + filter = CategoryFilter(["-"]) + self.assertFalse(filter.should_check("anything")) + # Check a second time to exercise cache. + self.assertFalse(filter.should_check("anything")) + + filter = CategoryFilter(["-", "+ab"]) + self.assertTrue(filter.should_check("abc")) + self.assertFalse(filter.should_check("a")) + + filter = CategoryFilter(["+", "-ab"]) + self.assertFalse(filter.should_check("abc")) + self.assertTrue(filter.should_check("a")) + diff --git a/WebKitTools/Scripts/webkitpy/style/processors/common.py b/WebKitTools/Scripts/webkitpy/style/processors/common.py new file mode 100644 index 0000000..dbf4bea --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/style/processors/common.py @@ -0,0 +1,59 @@ +# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Supports style checking not specific to any one processor.""" + + +# FIXME: Test this list in the same way that the list of CppProcessor +# categories is tested, for example by checking that all of its +# elements appear in the unit tests. This should probably be done +# after moving the relevant cpp_unittest.ErrorCollector code +# into a shared location and refactoring appropriately. +categories = set([ + "whitespace/carriage_return", +]) + + +def check_no_carriage_return(line, line_number, error): + """Check that a line does not end with a carriage return. + + Returns true if the check is successful (i.e. if the line does not + end with a carriage return), and false otherwise. + + Args: + line: A string that is the line to check. + line_number: The line number. + error: The function to call with any errors found. + + """ + + if line.endswith("\r"): + error(line_number, + "whitespace/carriage_return", + 1, + "One or more unexpected \\r (^M) found; " + "better to use only a \\n") + return False + + return True + + diff --git a/WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py b/WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py new file mode 100644 index 0000000..9362b65 --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py @@ -0,0 +1,82 @@ +# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +"""Unit tests for common.py.""" + + +import unittest + +from common import check_no_carriage_return + + +# FIXME: The unit tests for the cpp, text, and common processors should +# share supporting test code. This can include, for example, the +# mock style error handling code and the code to check that all +# of a processor's categories are covered by the unit tests. +# Such shared code can be located in a shared test file, perhaps +# ilke this one. +class CarriageReturnTest(unittest.TestCase): + + """Tests check_no_carriage_return().""" + + _category = "whitespace/carriage_return" + _confidence = 1 + + def setUp(self): + self._style_errors = [] # The list of accumulated style errors. + + def _mock_style_error_handler(self, line_number, category, confidence, + message): + """Append the error information to the list of style errors.""" + error = (line_number, category, confidence, message) + self._style_errors.append(error) + + def assert_carriage_return(self, line, is_error): + """Call check_no_carriage_return() and assert the result.""" + line_number = 100 + handle_style_error = self._mock_style_error_handler + + check_no_carriage_return(line, line_number, handle_style_error) + + expected_message = ("One or more unexpected \\r (^M) found; " + "better to use only a \\n") + + if is_error: + expected_errors = [(line_number, self._category, self._confidence, + expected_message)] + self.assertEquals(self._style_errors, expected_errors) + else: + self.assertEquals(self._style_errors, []) + + def test_ends_with_carriage(self): + self.assert_carriage_return("carriage return\r", is_error=True) + + def test_ends_with_nothing(self): + self.assert_carriage_return("no carriage return", is_error=False) + + def test_ends_with_newline(self): + self.assert_carriage_return("no carriage return\n", is_error=False) + + def test_ends_with_carriage_newline(self): + # Check_no_carriage_return only() checks the final character. + self.assert_carriage_return("carriage\r in a string", is_error=False) + diff --git a/WebKitTools/Scripts/webkitpy/style/unittests.py b/WebKitTools/Scripts/webkitpy/style/unittests.py index 11c10e7..f8e3f71 100644 --- a/WebKitTools/Scripts/webkitpy/style/unittests.py +++ b/WebKitTools/Scripts/webkitpy/style/unittests.py @@ -37,5 +37,7 @@ import unittest from checker_unittest import * from error_handlers_unittest import * +from filter_unittest import * +from processors.common_unittest import * from processors.cpp_unittest import * from processors.text_unittest import * diff --git a/WebKitTools/wx/build/settings.py b/WebKitTools/wx/build/settings.py index 9b8165d..60a4db6 100644 --- a/WebKitTools/wx/build/settings.py +++ b/WebKitTools/wx/build/settings.py @@ -92,6 +92,7 @@ jscore_dirs = [ 'wtf', 'wtf/unicode', 'wtf/unicode/icu', + 'yarr', ] webcore_dirs = [ |